From 3d8eac0447e2c883e29cc4f04d17e34eeafb7c68 Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Sat, 5 Nov 2022 12:32:14 -0700 Subject: [PATCH 1/8] [Keyboard] Fix LED order and VIA TO handling for Work Louder Micro --- keyboards/work_louder/micro/config.h | 8 ++++++-- .../work_louder/micro/keymaps/via/keymap.c | 18 ++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/keyboards/work_louder/micro/config.h b/keyboards/work_louder/micro/config.h index a4d5ca2c9366..7ea41cd0c1ec 100644 --- a/keyboards/work_louder/micro/config.h +++ b/keyboards/work_louder/micro/config.h @@ -5,6 +5,10 @@ #include "config_common.h" + +#define MATRIX_ROWS 4 +#define MATRIX_COLS 4 + /* * Feature disable options * These options are also useful to firmware size reduction. @@ -84,6 +88,6 @@ #define ENCODERS_PAD_B \ { D6, B1 } -#define WORK_LOUDER_LED_PIN_1 B7 -#define WORK_LOUDER_LED_PIN_2 B6 +#define WORK_LOUDER_LED_PIN_1 B6 +#define WORK_LOUDER_LED_PIN_2 B7 #define WORK_LOUDER_LED_PIN_3 B5 diff --git a/keyboards/work_louder/micro/keymaps/via/keymap.c b/keyboards/work_louder/micro/keymaps/via/keymap.c index da910af6b227..de675e9ac126 100644 --- a/keyboards/work_louder/micro/keymaps/via/keymap.c +++ b/keyboards/work_louder/micro/keymaps/via/keymap.c @@ -8,26 +8,26 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_MPLY, KC_9, KC_0, KC_NO, KC_5, KC_6, KC_7, KC_8, KC_1, KC_2, KC_3, KC_4, - TO(1), KC_DOT, KC_COMM, USER09 + USER09, KC_DOT, KC_COMM, 0x5011 ), LAYOUT( _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - TO(2), _______, _______, _______ + _______, _______, _______, 0x5012 ), LAYOUT( _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - TO(3), _______, _______, _______ + _______, _______, _______, 0x5013 ), LAYOUT( _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - TO(0), _______, _______, _______ + _______, _______, _______, 0x5010 ) }; @@ -67,6 +67,16 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { layer_state_set_kb(layer_state); } break; + case 0x5000 ... 0x500F: + if (record->event.pressed) { + layer_move(keycode - 0x5000); + } + return false; break; + case 0x5010 ... 0x501F: + if (record->event.pressed) { + layer_move(keycode - 0x5010); + } + return false; break; } return true; } From c9fac2905fd8bfa4cd06deb02d971b25d56a288b Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Sat, 5 Nov 2022 12:33:54 -0700 Subject: [PATCH 2/8] disable additional features --- keyboards/work_louder/micro/keymaps/via/rules.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/keyboards/work_louder/micro/keymaps/via/rules.mk b/keyboards/work_louder/micro/keymaps/via/rules.mk index f1adcab005e8..a067e071fe99 100644 --- a/keyboards/work_louder/micro/keymaps/via/rules.mk +++ b/keyboards/work_louder/micro/keymaps/via/rules.mk @@ -1,2 +1,4 @@ -VIA_ENABLE = yes +VIA_ENABLE = yes ENCODER_MAP_ENABLE = yes +MAGIC_ENABLE = no +SPACE_CADET_ENABLE = no From 8a3e6d748948f49c33b3f76805cc85776e53307b Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Sun, 6 Nov 2022 12:53:24 -0800 Subject: [PATCH 3/8] Fix pwm leds --- keyboards/work_louder/micro/config.h | 4 -- .../work_louder/micro/keymaps/via/keymap.c | 4 -- keyboards/work_louder/micro/micro.c | 60 +++++-------------- keyboards/work_louder/micro/rules.mk | 2 - 4 files changed, 14 insertions(+), 56 deletions(-) diff --git a/keyboards/work_louder/micro/config.h b/keyboards/work_louder/micro/config.h index 7ea41cd0c1ec..580db3e5944f 100644 --- a/keyboards/work_louder/micro/config.h +++ b/keyboards/work_louder/micro/config.h @@ -5,10 +5,6 @@ #include "config_common.h" - -#define MATRIX_ROWS 4 -#define MATRIX_COLS 4 - /* * Feature disable options * These options are also useful to firmware size reduction. diff --git a/keyboards/work_louder/micro/keymaps/via/keymap.c b/keyboards/work_louder/micro/keymaps/via/keymap.c index de675e9ac126..ea06554366ea 100644 --- a/keyboards/work_louder/micro/keymaps/via/keymap.c +++ b/keyboards/work_louder/micro/keymaps/via/keymap.c @@ -51,10 +51,6 @@ typedef union { work_louder_config_t work_louder_config; bool process_record_user(uint16_t keycode, keyrecord_t *record) { -#ifdef CONSOLE_ENABLE - uprintf("KL: kc: 0x%04X, col: %2u, row: %2u, pressed: %b, time: %5u, int: %b, count: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed, record->event.time, record->tap.interrupted, record->tap.count); -#endif - switch (keycode) { case USER09: if (record->event.pressed) { diff --git a/keyboards/work_louder/micro/micro.c b/keyboards/work_louder/micro/micro.c index 80d39274178c..2eb4ec00af63 100644 --- a/keyboards/work_louder/micro/micro.c +++ b/keyboards/work_louder/micro/micro.c @@ -49,22 +49,28 @@ bool encoder_update_kb(uint8_t index, bool clockwise) { #endif void work_louder_micro_led_1_on(void) { + setPinOutput(WORK_LOUDER_LED_PIN_1); writePin(WORK_LOUDER_LED_PIN_1, true); } void work_louder_micro_led_2_on(void) { + setPinOutput(WORK_LOUDER_LED_PIN_2); writePin(WORK_LOUDER_LED_PIN_2, true); } void work_louder_micro_led_3_on(void) { + setPinOutput(WORK_LOUDER_LED_PIN_3); writePin(WORK_LOUDER_LED_PIN_3, true); } void work_louder_micro_led_1_off(void) { + setPinInput(WORK_LOUDER_LED_PIN_1); writePin(WORK_LOUDER_LED_PIN_1, false); } void work_louder_micro_led_2_off(void) { + setPinInput(WORK_LOUDER_LED_PIN_2); writePin(WORK_LOUDER_LED_PIN_2, false); } void work_louder_micro_led_3_off(void) { + setPinInput(WORK_LOUDER_LED_PIN_3); writePin(WORK_LOUDER_LED_PIN_3, false); } @@ -81,15 +87,15 @@ void work_louder_micro_led_all_off(void) { } void work_louder_micro_led_1_set(uint8_t n) { -#if WORK_LOUDER_LED_PIN_1 == B7 - OCR1C = n; +#if WORK_LOUDER_LED_PIN_1 == B6 + OCR1B = n; #else n ? work_louder_micro_led_1_on() : work_louder_micro_led_1_off(); #endif } void work_louder_micro_led_2_set(uint8_t n) { -#if WORK_LOUDER_LED_PIN_2 == B6 - OCR1B = n; +#if WORK_LOUDER_LED_PIN_2 == B7 + OCR1C = n; #else n ? work_louder_micro_led_2_on() : work_louder_micro_led_2_off(); #endif @@ -108,49 +114,13 @@ void work_louder_micro_led_all_set(uint8_t n) { work_louder_micro_led_3_set(n); } -#ifdef DEFER_EXEC_ENABLE -uint32_t startup_animation(uint32_t trigger_time, void *cb_arg) { - static uint8_t index = 0; - - switch (index) { - case 0: - work_louder_micro_led_1_on(); - break; - case 1: - work_louder_micro_led_2_on(); - break; - case 2: - work_louder_micro_led_3_on(); - break; - case 3: - work_louder_micro_led_1_off(); - break; - case 4: - work_louder_micro_led_2_off(); - break; - case 5: - work_louder_micro_led_3_off(); - break; - default: - return 0; - } - index++; - return 100; -} -#endif - void matrix_init_kb(void) { + TCCR1A = 0b10101001; // set and configure fast PWM + TCCR1B = 0b00001001; // set and configure fast PWM - setPinOutput(WORK_LOUDER_LED_PIN_1); // left led - writePin(WORK_LOUDER_LED_PIN_1, false); - setPinOutput(WORK_LOUDER_LED_PIN_2); // middle led - writePin(WORK_LOUDER_LED_PIN_2, false); - setPinOutput(WORK_LOUDER_LED_PIN_3); // right led - writePin(WORK_LOUDER_LED_PIN_3, false); + work_louder_micro_led_all_off(); + work_louder_micro_led_all_set(255); -#ifdef DEFER_EXEC_ENABLE - defer_exec(500, startup_animation, NULL); -#else wait_ms(500); work_louder_micro_led_1_on(); wait_ms(100); @@ -164,7 +134,5 @@ void matrix_init_kb(void) { wait_ms(100); work_louder_micro_led_3_off(); wait_ms(200); -#endif matrix_init_user(); - } diff --git a/keyboards/work_louder/micro/rules.mk b/keyboards/work_louder/micro/rules.mk index 757b87cfe4ee..bf0aa919117f 100644 --- a/keyboards/work_louder/micro/rules.mk +++ b/keyboards/work_louder/micro/rules.mk @@ -2,5 +2,3 @@ RGB_MATRIX_DRIVER = WS2812 SRC += rgb_functions.c \ matrix.c - -DEFERRED_EXEC_ENABLE = yes From e038f669236faad27e81e541e9338158a1dcef05 Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Sun, 6 Nov 2022 12:57:57 -0800 Subject: [PATCH 4/8] Minor tweak --- keyboards/work_louder/micro/micro.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/keyboards/work_louder/micro/micro.c b/keyboards/work_louder/micro/micro.c index 2eb4ec00af63..ec694a71d839 100644 --- a/keyboards/work_louder/micro/micro.c +++ b/keyboards/work_louder/micro/micro.c @@ -118,8 +118,8 @@ void matrix_init_kb(void) { TCCR1A = 0b10101001; // set and configure fast PWM TCCR1B = 0b00001001; // set and configure fast PWM + matrix_init_user(); work_louder_micro_led_all_off(); - work_louder_micro_led_all_set(255); wait_ms(500); work_louder_micro_led_1_on(); @@ -134,5 +134,4 @@ void matrix_init_kb(void) { wait_ms(100); work_louder_micro_led_3_off(); wait_ms(200); - matrix_init_user(); } From a7619380c463f80bb5bd4511fa4f969857e054e7 Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Sun, 6 Nov 2022 13:01:52 -0800 Subject: [PATCH 5/8] change functions --- keyboards/work_louder/micro/keymaps/via/keymap.c | 6 +++--- keyboards/work_louder/micro/micro.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/keyboards/work_louder/micro/keymaps/via/keymap.c b/keyboards/work_louder/micro/keymaps/via/keymap.c index ea06554366ea..acd4a98dc5f2 100644 --- a/keyboards/work_louder/micro/keymaps/via/keymap.c +++ b/keyboards/work_louder/micro/keymaps/via/keymap.c @@ -56,7 +56,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { work_louder_config.led_level++; if (work_louder_config.led_level > 4) { - work_louder_config.led_level = 0; + work_louder_config.led_level = 1; } work_louder_micro_led_all_set((uint8_t)(work_louder_config.led_level * 255 / 4)); eeconfig_update_user(work_louder_config.raw); @@ -88,11 +88,11 @@ layer_state_t layer_state_set_user(layer_state_t state) { void eeconfig_init_user(void) { work_louder_config.raw = 0; - work_louder_config.led_level = 1; + work_louder_config.led_level = 4; eeconfig_update_user(work_louder_config.raw); } -void matrix_init_user(void) { +void keyboard_post_init_user(void) { work_louder_config.raw = eeconfig_read_user(); work_louder_micro_led_all_set((uint8_t)(work_louder_config.led_level * 255 / 4)); } diff --git a/keyboards/work_louder/micro/micro.c b/keyboards/work_louder/micro/micro.c index ec694a71d839..0baedc3c1b80 100644 --- a/keyboards/work_louder/micro/micro.c +++ b/keyboards/work_louder/micro/micro.c @@ -114,11 +114,11 @@ void work_louder_micro_led_all_set(uint8_t n) { work_louder_micro_led_3_set(n); } -void matrix_init_kb(void) { +void keyboard_post_init_kb(void) { TCCR1A = 0b10101001; // set and configure fast PWM TCCR1B = 0b00001001; // set and configure fast PWM - matrix_init_user(); + keyboard_post_init_user(); work_louder_micro_led_all_off(); wait_ms(500); From 0b2cec436ef1746d6cd73b17cbd618ac34681ed2 Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Tue, 8 Nov 2022 19:36:26 -0800 Subject: [PATCH 6/8] More tweaks --- keyboards/work_louder/micro/keymaps/via/keymap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/keyboards/work_louder/micro/keymaps/via/keymap.c b/keyboards/work_louder/micro/keymaps/via/keymap.c index acd4a98dc5f2..33e873010bc9 100644 --- a/keyboards/work_louder/micro/keymaps/via/keymap.c +++ b/keyboards/work_louder/micro/keymaps/via/keymap.c @@ -8,7 +8,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_MPLY, KC_9, KC_0, KC_NO, KC_5, KC_6, KC_7, KC_8, KC_1, KC_2, KC_3, KC_4, - USER09, KC_DOT, KC_COMM, 0x5011 + RGB_TOG, KC_DOT, KC_COMM, 0x5011 ), LAYOUT( _______, _______, _______, _______, @@ -88,7 +88,7 @@ layer_state_t layer_state_set_user(layer_state_t state) { void eeconfig_init_user(void) { work_louder_config.raw = 0; - work_louder_config.led_level = 4; + work_louder_config.led_level = 1; eeconfig_update_user(work_louder_config.raw); } From 516975756cf68665d93cf98e5b27d455900f0db0 Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Wed, 9 Nov 2022 16:57:31 -0800 Subject: [PATCH 7/8] keymap update --- .../work_louder/micro/keymaps/via/keymap.c | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/keyboards/work_louder/micro/keymaps/via/keymap.c b/keyboards/work_louder/micro/keymaps/via/keymap.c index 33e873010bc9..84852e84490b 100644 --- a/keyboards/work_louder/micro/keymaps/via/keymap.c +++ b/keyboards/work_louder/micro/keymaps/via/keymap.c @@ -4,30 +4,29 @@ #include QMK_KEYBOARD_H const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - LAYOUT( - KC_MPLY, KC_9, KC_0, KC_NO, - KC_5, KC_6, KC_7, KC_8, - KC_1, KC_2, KC_3, KC_4, - RGB_TOG, KC_DOT, KC_COMM, 0x5011 + [0] = LAYOUT( + KC_MPLY, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + RGB_TOG, XXXXXXX, XXXXXXX, 0x5011 ), - LAYOUT( - _______, _______, _______, _______, - _______, _______, _______, _______, - _______, _______, _______, _______, - _______, _______, _______, 0x5012 - + [1] = LAYOUT( + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, 0x5012 ), - LAYOUT( - _______, _______, _______, _______, - _______, _______, _______, _______, - _______, _______, _______, _______, - _______, _______, _______, 0x5013 + [2] = LAYOUT( + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, 0x5013 ), - LAYOUT( - _______, _______, _______, _______, - _______, _______, _______, _______, - _______, _______, _______, _______, - _______, _______, _______, 0x5010 + [3] = LAYOUT( + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + USER00, USER01, USER03, USER05, + XXXXXXX, USER02, USER04, USER06, + XXXXXXX, XXXXXXX, XXXXXXX, 0x5010 ) }; From 1b0328f4d07d7daa199ee194634e9bb8f667e439 Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Thu, 1 Dec 2022 13:18:11 -0800 Subject: [PATCH 8/8] Fix suspend issues with LED --- keyboards/work_louder/micro/keymaps/via/keymap.c | 4 ++++ keyboards/work_louder/micro/micro.c | 14 ++++++++++++++ keyboards/work_louder/micro/micro.h | 1 + 3 files changed, 19 insertions(+) diff --git a/keyboards/work_louder/micro/keymaps/via/keymap.c b/keyboards/work_louder/micro/keymaps/via/keymap.c index 84852e84490b..d4be308b2ac7 100644 --- a/keyboards/work_louder/micro/keymaps/via/keymap.c +++ b/keyboards/work_louder/micro/keymaps/via/keymap.c @@ -95,3 +95,7 @@ void keyboard_post_init_user(void) { work_louder_config.raw = eeconfig_read_user(); work_louder_micro_led_all_set((uint8_t)(work_louder_config.led_level * 255 / 4)); } + +void suspend_wakeup_init_user(void) { + layer_state_set_user(layer_state); +} diff --git a/keyboards/work_louder/micro/micro.c b/keyboards/work_louder/micro/micro.c index 0baedc3c1b80..42bc2db52980 100644 --- a/keyboards/work_louder/micro/micro.c +++ b/keyboards/work_louder/micro/micro.c @@ -119,6 +119,9 @@ void keyboard_post_init_kb(void) { TCCR1B = 0b00001001; // set and configure fast PWM keyboard_post_init_user(); +} + +void work_louder_led_init_animation(void) { work_louder_micro_led_all_off(); wait_ms(500); @@ -135,3 +138,14 @@ void keyboard_post_init_kb(void) { work_louder_micro_led_3_off(); wait_ms(200); } + + +void suspend_power_down_kb(void) { + suspend_power_down_user(); + work_louder_micro_led_all_off(); +} + +void suspend_wakeup_init_kb(void) { + work_louder_led_init_animation(); + suspend_wakeup_init_user(); +} diff --git a/keyboards/work_louder/micro/micro.h b/keyboards/work_louder/micro/micro.h index 715b09eb33af..1d25b91c80d2 100644 --- a/keyboards/work_louder/micro/micro.h +++ b/keyboards/work_louder/micro/micro.h @@ -20,3 +20,4 @@ extern void work_louder_micro_led_2_set(uint8_t n); extern void work_louder_micro_led_3_set(uint8_t n); extern void work_louder_micro_led_all_set(uint8_t n); +void work_louder_led_init_animation(void);