diff --git a/keyboards/work_louder/micro/config.h b/keyboards/work_louder/micro/config.h index a4d5ca2c9366..580db3e5944f 100644 --- a/keyboards/work_louder/micro/config.h +++ b/keyboards/work_louder/micro/config.h @@ -84,6 +84,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..d4be308b2ac7 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, - TO(1), KC_DOT, KC_COMM, USER09 + [0] = LAYOUT( + KC_MPLY, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + RGB_TOG, XXXXXXX, XXXXXXX, 0x5011 ), - LAYOUT( - _______, _______, _______, _______, - _______, _______, _______, _______, - _______, _______, _______, _______, - TO(2), _______, _______, _______ - + [1] = LAYOUT( + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, 0x5012 ), - LAYOUT( - _______, _______, _______, _______, - _______, _______, _______, _______, - _______, _______, _______, _______, - TO(3), _______, _______, _______ + [2] = LAYOUT( + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + XXXXXXX, XXXXXXX, XXXXXXX, 0x5013 ), - LAYOUT( - _______, _______, _______, _______, - _______, _______, _______, _______, - _______, _______, _______, _______, - TO(0), _______, _______, _______ + [3] = LAYOUT( + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + USER00, USER01, USER03, USER05, + XXXXXXX, USER02, USER04, USER06, + XXXXXXX, XXXXXXX, XXXXXXX, 0x5010 ) }; @@ -51,22 +50,28 @@ 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) { 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); 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; } @@ -86,7 +91,11 @@ void eeconfig_init_user(void) { 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)); } + +void suspend_wakeup_init_user(void) { + layer_state_set_user(layer_state); +} 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 diff --git a/keyboards/work_louder/micro/micro.c b/keyboards/work_louder/micro/micro.c index 80d39274178c..42bc2db52980 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,16 @@ 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; +void keyboard_post_init_kb(void) { + TCCR1A = 0b10101001; // set and configure fast PWM + TCCR1B = 0b00001001; // set and configure fast PWM + + keyboard_post_init_user(); } -#endif -void matrix_init_kb(void) { +void work_louder_led_init_animation(void) { + work_louder_micro_led_all_off(); - 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); - -#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 +137,15 @@ void matrix_init_kb(void) { wait_ms(100); work_louder_micro_led_3_off(); wait_ms(200); -#endif - matrix_init_user(); +} + + +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); 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