Skip to content

Commit

Permalink
workflow fixes (#395)
Browse files Browse the repository at this point in the history
* voyager: fix compilation errors

* workflow: fix firmware building to work correctly

* Calculate and print stack size on AVR builds

* workflow: add oryx keymaps

* Fix issues due to tests

Proof that they're working!
  • Loading branch information
drashna authored Aug 1, 2024
1 parent ac32098 commit 3a09636
Show file tree
Hide file tree
Showing 12 changed files with 405 additions and 100 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ jobs:
build-firmware:
runs-on: ubuntu-latest
container: qmkfm/qmk_cli
strategy:
fail-fast: false
matrix:
keymap:
- default
- oryx

steps:
- name: Checkout QMK Firmware
Expand All @@ -25,4 +31,4 @@ jobs:
- name: Build
id: build
run: |
qmk mass-compile -f manufacturer="ZSA Technology Labs" -km default
qmk mass-compile -f manufacturer="ZSA Technology Labs" -km ${{ matrix.keymap }} -e SKIP_GIT=1
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ via*.json
!/keyboards/zsa/**
/keyboards/zsa/**/keymaps/**
!/keyboards/zsa/**/keymaps/default
!/keyboards/zsa/**/keymaps/default/**
!/keyboards/zsa/**/keymaps/oryx
!/keyboards/zsa/**/keymaps/oryx/**
3 changes: 3 additions & 0 deletions builddefs/message.mk
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ endef
MSG_AVAILABLE_KEYMAPS = $(eval $(call GENERATE_MSG_AVAILABLE_KEYMAPS))$(MSG_AVAILABLE_KEYMAPS_ACTUAL)

MSG_BOOTLOADER_NOT_FOUND_BASE = Bootloader not found. Make sure the board is in bootloader mode. See https://docs.qmk.fm/\#/newbs_flashing\n
MSG_CHECK_STACKSIZE = Checking stack size of $(TARGET)
MSG_CHECK_FILESIZE = Checking file size of $(TARGET).$(FIRMWARE_FORMAT)
MSG_MEMORY_OVERFLOW = $(ERROR_COLOR)RAM usage (not including stack) exceeds available RAM by $(RAM_OVERFLOW_AMOUNT) bytes\n
MSG_STACK_SIZE = Available stack size: $(STACK_SIZE) bytes\n
MSG_FILE_TOO_BIG = $(ERROR_COLOR)The firmware is too large!$(NO_COLOR) $(CURRENT_SIZE)/$(MAX_SIZE) ($(OVER_SIZE) bytes over)\n
MSG_FILE_TOO_SMALL = The firmware is too small! $(CURRENT_SIZE)/$(MAX_SIZE)\n
MSG_FILE_JUST_RIGHT = The firmware size is fine - $(CURRENT_SIZE)/$(MAX_SIZE) ($(PERCENT_SIZE)%%, $(FREE_SIZE) bytes free)\n
Expand Down
6 changes: 0 additions & 6 deletions keyboards/zsa/ergodox_ez/keymaps/oryx/config.h

This file was deleted.

199 changes: 109 additions & 90 deletions keyboards/zsa/ergodox_ez/keymaps/oryx/keymap.c

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions keyboards/zsa/ergodox_ez/m32u4/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"processor": "atmega32u4",
"ws2812": {
"pin": "D7"
},
"build": {
"lto": true
}
}
73 changes: 73 additions & 0 deletions keyboards/zsa/moonlander/keymaps/oryx/keymap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/* Copyright 2020 ZSA Technology Labs, Inc <@zsa>
* Copyright 2020 Jack Humbert <[email protected]>
* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/



#include QMK_KEYBOARD_H
#include "version.h"

enum layers {
BASE, // default layer
SYMB, // symbols
MDIA, // media keys
};

enum custom_keycodes {
VRSN = SAFE_RANGE,
};

// clang-format off
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[BASE] = LAYOUT(
KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_LEFT, KC_RGHT, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,
KC_DEL, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(SYMB), TG(SYMB), KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS,
KC_BSPC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_HYPR, KC_MEH, KC_H, KC_J, KC_K, KC_L, LT(MDIA, KC_SCLN), LGUI_T(KC_QUOT),
KC_LSFT, LCTL_T(KC_Z),KC_X,KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, RCTL_T(KC_SLSH), KC_RSFT,
LT(SYMB,KC_GRV),WEBUSB_PAIR,A(KC_LSFT),KC_LEFT, KC_RGHT, LALT_T(KC_APP), RCTL_T(KC_ESC), KC_UP, KC_DOWN, KC_LBRC, KC_RBRC, MO(SYMB),
KC_SPC, KC_BSPC, KC_LGUI, KC_LALT, KC_TAB, KC_ENT
),

[SYMB] = LAYOUT(
VRSN, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, _______, _______, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
_______, KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_PIPE, _______, _______, KC_UP, KC_7, KC_8, KC_9, KC_ASTR, KC_F12,
_______, KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, KC_GRV, _______, _______, KC_DOWN, KC_4, KC_5, KC_6, KC_PLUS, _______,
_______, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_TILD, KC_AMPR, KC_1, KC_2, KC_3, KC_BSLS, _______,
EE_CLR, _______, _______, _______, _______, RGB_VAI, RGB_TOG, _______, KC_DOT, KC_0, KC_EQL, _______,
RGB_HUD, RGB_VAD, RGB_HUI, TOGGLE_LAYER_COLOR,_______, _______
),

[MDIA] = LAYOUT(
LED_LEVEL,_______,_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, QK_BOOT,
_______, _______, _______, KC_MS_U, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, KC_MS_L, KC_MS_D, KC_MS_R, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPLY,
_______, _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_MNXT, _______, _______,
_______, _______, _______, KC_BTN1, KC_BTN2, _______, _______, KC_VOLU, KC_VOLD, KC_MUTE, _______, _______,
_______, _______, _______, _______, _______, _______
),
};

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
switch (keycode) {
case VRSN:
SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
return false;
}
}
return true;
}
2 changes: 2 additions & 0 deletions keyboards/zsa/moonlander/keymaps/oryx/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ORYX_ENABLE = yes
LAYER_LOCK_ENABLE = yes
187 changes: 187 additions & 0 deletions keyboards/zsa/voyager/keymaps/oryx/keymap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
#include QMK_KEYBOARD_H
#include "version.h"
#define MOON_LED_LEVEL LED_LEVEL
#define ML_SAFE_RANGE SAFE_RANGE

enum custom_keycodes {
RGB_SLD = ML_SAFE_RANGE,
HSV_0_255_255,
HSV_74_255_255,
HSV_169_255_255,
};



enum tap_dance_codes {
DANCE_0,
DANCE_1,
};

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT_voyager(
TD(DANCE_0), KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSLS,
CW_TOGG, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_MINUS,
MT(MOD_LSFT, KC_BSPC),TD(DANCE_1), KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, MT(MOD_RSFT, KC_QUOTE),
KC_LEFT_GUI, MT(MOD_LALT, KC_Z),KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMMA, KC_DOT, MT(MOD_RALT, KC_SLASH),KC_RIGHT_CTRL,
LT(1,KC_ENTER), MT(MOD_LCTL, KC_TAB), MT(MOD_LSFT, KC_BSPC),LT(2,KC_SPACE)
),
[1] = LAYOUT_voyager(
KC_ESCAPE, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
KC_GRAVE, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_7, KC_8, KC_9, KC_MINUS, KC_SLASH, KC_F12,
QK_LLCK, KC_TRANSPARENT, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_4, KC_5, KC_6, KC_PLUS, KC_ASTR, KC_BSPC,
KC_TRANSPARENT, KC_TRANSPARENT, KC_LBRC, KC_RBRC, KC_LCBR, KC_RCBR, KC_1, KC_2, KC_3, KC_DOT, KC_EQUAL, KC_ENTER,
KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_0
),
[2] = LAYOUT_voyager(
RGB_TOG, TOGGLE_LAYER_COLOR,RGB_MODE_FORWARD,RGB_SLD, RGB_VAD, RGB_VAI, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, QK_BOOT,
KC_TRANSPARENT, KC_TRANSPARENT, KC_AUDIO_VOL_DOWN,KC_AUDIO_VOL_UP,KC_AUDIO_MUTE, KC_TRANSPARENT, KC_PAGE_UP, KC_HOME, KC_UP, KC_END, KC_TRANSPARENT, KC_TRANSPARENT,
KC_TRANSPARENT, KC_MEDIA_PREV_TRACK,KC_MEDIA_NEXT_TRACK,KC_MEDIA_STOP, KC_MEDIA_PLAY_PAUSE,KC_TRANSPARENT, KC_PGDN, KC_LEFT, KC_DOWN, KC_RIGHT, KC_TRANSPARENT, KC_TRANSPARENT,
KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, HSV_0_255_255, HSV_74_255_255, HSV_169_255_255, KC_TRANSPARENT, LCTL(LSFT(KC_TAB)),LCTL(KC_TAB), KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT,
KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT
),
};




bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {

case RGB_SLD:
if (record->event.pressed) {
rgblight_mode(1);
}
return false;
case HSV_0_255_255:
if (record->event.pressed) {
rgblight_mode(1);
rgblight_sethsv(0,255,255);
}
return false;
case HSV_74_255_255:
if (record->event.pressed) {
rgblight_mode(1);
rgblight_sethsv(74,255,255);
}
return false;
case HSV_169_255_255:
if (record->event.pressed) {
rgblight_mode(1);
rgblight_sethsv(169,255,255);
}
return false;
}
return true;
}


typedef struct {
bool is_press_action;
uint8_t step;
} tap;

enum {
SINGLE_TAP = 1,
SINGLE_HOLD,
DOUBLE_TAP,
DOUBLE_HOLD,
DOUBLE_SINGLE_TAP,
MORE_TAPS
};

static tap dance_state[2];

uint8_t dance_step(tap_dance_state_t *state);

uint8_t dance_step(tap_dance_state_t *state) {
if (state->count == 1) {
if (state->interrupted || !state->pressed) return SINGLE_TAP;
else return SINGLE_HOLD;
} else if (state->count == 2) {
if (state->interrupted) return DOUBLE_SINGLE_TAP;
else if (state->pressed) return DOUBLE_HOLD;
else return DOUBLE_TAP;
}
return MORE_TAPS;
}


void on_dance_0(tap_dance_state_t *state, void *user_data);
void dance_0_finished(tap_dance_state_t *state, void *user_data);
void dance_0_reset(tap_dance_state_t *state, void *user_data);

void on_dance_0(tap_dance_state_t *state, void *user_data) {
if(state->count == 3) {
tap_code16(KC_EQUAL);
tap_code16(KC_EQUAL);
tap_code16(KC_EQUAL);
}
if(state->count > 3) {
tap_code16(KC_EQUAL);
}
}

void dance_0_finished(tap_dance_state_t *state, void *user_data) {
dance_state[0].step = dance_step(state);
switch (dance_state[0].step) {
case SINGLE_TAP: register_code16(KC_EQUAL); break;
case SINGLE_HOLD: register_code16(KC_ESCAPE); break;
case DOUBLE_TAP: register_code16(KC_EQUAL); register_code16(KC_EQUAL); break;
case DOUBLE_SINGLE_TAP: tap_code16(KC_EQUAL); register_code16(KC_EQUAL);
}
}

void dance_0_reset(tap_dance_state_t *state, void *user_data) {
wait_ms(10);
switch (dance_state[0].step) {
case SINGLE_TAP: unregister_code16(KC_EQUAL); break;
case SINGLE_HOLD: unregister_code16(KC_ESCAPE); break;
case DOUBLE_TAP: unregister_code16(KC_EQUAL); break;
case DOUBLE_SINGLE_TAP: unregister_code16(KC_EQUAL); break;
}
dance_state[0].step = 0;
}
void on_dance_1(tap_dance_state_t *state, void *user_data);
void dance_1_finished(tap_dance_state_t *state, void *user_data);
void dance_1_reset(tap_dance_state_t *state, void *user_data);

void on_dance_1(tap_dance_state_t *state, void *user_data) {
if(state->count == 3) {
tap_code16(KC_A);
tap_code16(KC_A);
tap_code16(KC_A);
}
if(state->count > 3) {
tap_code16(KC_A);
}
}

void dance_1_finished(tap_dance_state_t *state, void *user_data) {
dance_state[1].step = dance_step(state);
switch (dance_state[1].step) {
case SINGLE_TAP: register_code16(KC_A); break;
case SINGLE_HOLD: layer_on(1); break;
case DOUBLE_TAP: register_code16(KC_U); break;
case DOUBLE_SINGLE_TAP: tap_code16(KC_A); register_code16(KC_A);
}
}

void dance_1_reset(tap_dance_state_t *state, void *user_data) {
wait_ms(10);
switch (dance_state[1].step) {
case SINGLE_TAP: unregister_code16(KC_A); break;
case SINGLE_HOLD:
if(!is_layer_locked(1)) {
layer_off(1);
}
break;
case DOUBLE_TAP: unregister_code16(KC_U); break;
case DOUBLE_SINGLE_TAP: unregister_code16(KC_A); break;
}
dance_state[1].step = 0;
}

tap_dance_action_t tap_dance_actions[] = {
[DANCE_0] = ACTION_TAP_DANCE_FN_ADVANCED(on_dance_0, dance_0_finished, dance_0_reset),
[DANCE_1] = ACTION_TAP_DANCE_FN_ADVANCED(on_dance_1, dance_1_finished, dance_1_reset),
};
3 changes: 3 additions & 0 deletions keyboards/zsa/voyager/keymaps/oryx/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ORYX_ENABLE = yes
TAP_DANCE_ENABLE = yes
LAYER_LOCK_ENABLE = yes
6 changes: 3 additions & 3 deletions keyboards/zsa/voyager/voyager.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ bool is_launching = false;

#if defined(DEFERRED_EXEC_ENABLE)
# if defined(DYNAMIC_MACRO_ENABLE)
deferred_token dynamic_macro_token = INVALID_DEFERRED_TOKEN;
deferred_token dynamic_macro_token = INVALID_DEFERRED_TOKEN;
static uint32_t dynamic_macro_led(uint32_t trigger_time, void *cb_arg) {
static bool led_state = true;
if (!is_launching) {
Expand Down Expand Up @@ -97,9 +97,9 @@ layer_state_t layer_state_set_kb(layer_state_t state) {
#if !defined(VOYAGER_USER_LEDS)
state = layer_state_set_user(state);
if (is_launching || !keyboard_config.led_level) return state;
#ifdef ORYX_ENABLE
# ifdef ORYX_ENABLE
if (rawhid_state.status_led_control) return state;
#endif
# endif
uint8_t layer = get_highest_layer(state);
STATUS_LED_1(layer & (1 << 0));
STATUS_LED_2(layer & (1 << 1));
Expand Down
12 changes: 12 additions & 0 deletions platforms/avr/platform.mk
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@ check-size:
fi ; \
fi ; \
fi
$(eval END_POINTER=$(shell printf "%d" $$(( 0xffff & 0x$$( if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then avr-objdump -t $(BUILD_DIR)/$(TARGET).elf | grep -e '\b_end\b' | cut -c -8; else printf 0; fi ) )) ))
$(eval STACK_POINTER=$(shell printf "%d" $$(( 0xffff & 0x$$( if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then avr-objdump -t $(BUILD_DIR)/$(TARGET).elf | grep -e '\b__stack\b' | cut -c -8; else printf 0; fi ) )) ))
$(eval STACK_SIZE=$(shell expr $(STACK_POINTER) + 1 - $(END_POINTER)))
$(eval RAM_OVERFLOW_AMOUNT=$(shell expr 0 - $(STACK_SIZE)))
if [ $(STACK_POINTER) -gt 0 ] && [ $(END_POINTER) -gt 0 ]; then \
$(SILENT) || printf "$(MSG_CHECK_STACKSIZE)" | $(AWK_CMD); \
if [ $(STACK_SIZE) -lt 0 ] ; then \
printf "\n * $(MSG_MEMORY_OVERFLOW)"; $(PRINT_ERROR_PLAIN); \
else \
$(SILENT) || printf "\n * $(MSG_STACK_SIZE)"; \
fi ; \
fi

# Convert hex to bin.
bin: $(BUILD_DIR)/$(TARGET).hex
Expand Down

0 comments on commit 3a09636

Please sign in to comment.