From 956cf8d7bfbca187ad9d1e0aabbe6c25348d5e07 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Thu, 2 Sep 2021 10:49:44 -0700 Subject: [Keyboard] Work Louder board fixup (#14247) * [Keyboard] Add some last minute tweaks to Work board * Additional fixes * Fix rgb pin * Fix ws2812 hackery * additional led tweaks * Add indicator LEDs * fix bootmagic settings * Fix up RGB stuff * Limit power draw for entire board * fixup lights and such * change LED order on loop * Fix indicators if via is not enabled * Enable Sleep for rgb matrix * Even more LED tweaks * Final tweaks? * Tweak keycodes --- keyboards/work_louder/work_board/config.h | 78 ++++++++++++---------- .../work_louder/work_board/keymaps/via/keymap.c | 31 +++++++-- keyboards/work_louder/work_board/work_board.c | 55 ++++++++++++--- 3 files changed, 112 insertions(+), 52 deletions(-) (limited to 'keyboards/work_louder/work_board') diff --git a/keyboards/work_louder/work_board/config.h b/keyboards/work_louder/work_board/config.h index 2ccc1be4c4..fb9723db0b 100644 --- a/keyboards/work_louder/work_board/config.h +++ b/keyboards/work_louder/work_board/config.h @@ -27,8 +27,8 @@ along with this program. If not, see . #define PRODUCT Work Board /* key matrix size */ -#define MATRIX_ROWS 4 -#define MATRIX_COLS 13 +#define MATRIX_ROWS 4 +#define MATRIX_COLS 13 /* * Keyboard Matrix Assignments @@ -40,42 +40,35 @@ along with this program. If not, see . * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) * */ -#define MATRIX_ROW_PINS { F0, F1, F4, F5 } -#define MATRIX_COL_PINS { D3, D5, D4, D6, D7, B4, B5, B6, C6, C7, F7, F6, E6 } +#define MATRIX_ROW_PINS \ + { F0, F1, F4, F5 } +#define MATRIX_COL_PINS \ + { D3, D5, D4, D6, D7, B4, B5, B6, C6, C7, F7, F6, E6 } #define UNUSED_PINS /* COL2ROW, ROW2COL */ -#define DIODE_DIRECTION COL2ROW +#define DIODE_DIRECTION COL2ROW -#define LED_NUM_LOCK_PIN B2 -#define LED_CAPS_LOCK_PIN B3 -#define LED_SCROLL_LOCK_PIN B7 -//#define LED_COMPOSE_PIN B3 -//#define LED_KANA_PIN B4 - -//#define BACKLIGHT_PIN B7 -//#define BACKLIGHT_LEVELS 3 -//#define BACKLIGHT_BREATHING - -#define RGBLIGHT_DI_PIN D2 -# define RGBLED_NUM 26 +#define RGBLIGHT_DI_PIN D2 +#define RGBLED_NUM 26 //# define RGBLIGHT_HUE_STEP 8 //# define RGBLIGHT_SAT_STEP 8 //# define RGBLIGHT_VAL_STEP 8 -# define RGBLIGHT_LIMIT_VAL 100 /* The maximum brightness level */ -# define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */ -/*== all animations enable ==*/ -# define RGBLIGHT_ANIMATIONS +#define RGBLIGHT_LIMIT_VAL 120 /* The maximum brightness level */ +#define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */ /*== or choose animations ==*/ -//# define RGBLIGHT_EFFECT_BREATHING -//# define RGBLIGHT_EFFECT_RAINBOW_MOOD -//# define RGBLIGHT_EFFECT_RAINBOW_SWIRL -//# define RGBLIGHT_EFFECT_SNAKE -//# define RGBLIGHT_EFFECT_KNIGHT -//# define RGBLIGHT_EFFECT_CHRISTMAS -//# define RGBLIGHT_EFFECT_STATIC_GRADIENT -//# define RGBLIGHT_EFFECT_RGB_TEST -//# define RGBLIGHT_EFFECT_ALTERNATING +#define RGBLIGHT_EFFECT_BREATHING +#define RGBLIGHT_EFFECT_RAINBOW_MOOD +#define RGBLIGHT_EFFECT_RAINBOW_SWIRL +#define RGBLIGHT_EFFECT_SNAKE +#define RGBLIGHT_EFFECT_KNIGHT +#define RGBLIGHT_EFFECT_CHRISTMAS +#define RGBLIGHT_EFFECT_STATIC_GRADIENT +#define RGBLIGHT_EFFECT_RGB_TEST +#define RGBLIGHT_EFFECT_TWINKLE + +#define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_STATIC_GRADIENT + 9 +#define RGBLIGHT_DEFAULT_HUE 213 /*== customize breathing effect ==*/ /*==== (DEFAULT) use fixed table instead of exp() and sin() ====*/ //# define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256(default) or 128 or 64 @@ -84,10 +77,11 @@ along with this program. If not, see . //# define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0 to 255 //#endif -#define RGB_DI_PIN D0 -#define DRIVER_LED_TOTAL 50 -#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 100 +#define RGB_DI_PIN D1 +#define DRIVER_LED_TOTAL 49 +#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 120 #define RGB_MATRIX_DISABLE_KEYCODES +#define RGB_DISABLE_WHEN_USB_SUSPENDED /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ #define DEBOUNCE 5 @@ -146,14 +140,24 @@ along with this program. If not, see . #define NO_ACTION_MACRO #define NO_ACTION_FUNCTION -#define ENCODERS_PAD_A { B0 } -#define ENCODERS_PAD_B { B1 } +#define ENCODERS_PAD_A \ + { B0 } +#define ENCODERS_PAD_B \ + { B1 } #define ENCODERS 1 -#define ENCODERS_CW_KEY { { 12, 1 } } -#define ENCODERS_CCW_KEY { { 12, 2 } } +#define ENCODERS_CW_KEY \ + { \ + { 12, 1 } \ + } +#define ENCODERS_CCW_KEY \ + { \ + { 12, 2 } \ + } /* Bootmagic Lite key configuration */ //#define BOOTMAGIC_LITE_ROW 0 //#define BOOTMAGIC_LITE_COLUMN 0 + +#define VIA_EEPROM_LAYOUT_OPTIONS_DEFAULT 0x1 diff --git a/keyboards/work_louder/work_board/keymaps/via/keymap.c b/keyboards/work_louder/work_board/keymaps/via/keymap.c index 6bdc75ac22..1cf5e07577 100644 --- a/keyboards/work_louder/work_board/keymaps/via/keymap.c +++ b/keyboards/work_louder/work_board/keymaps/via/keymap.c @@ -27,14 +27,15 @@ enum tap_dances { ENC_TAP, }; -#define LOWER KC_FN13 -#define RAISE KC_FN23 +#define LOWER FN_MO13 +#define RAISE FN_MO23 +// clang-format off const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_QWERTY] = LAYOUT_via( KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, USER09, - KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_VOLD, - KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , KC_VOLU, + KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_VOLU, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , KC_VOLD, KC_LSFT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT ), @@ -59,7 +60,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ ) }; - +// clang-format on void dance_enc_finished(qk_tap_dance_state_t *state, void *user_data) { if (state->count == 1) { @@ -93,3 +94,23 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } return true; } + +layer_state_t layer_state_set_user(layer_state_t state) { + writePinLow(B2); + writePinLow(B3); + writePinLow(B7); + + switch (get_highest_layer(state)) { + case 1: + writePinHigh(B2); + break; + case 2: + writePinHigh(B3); + break; + case 3: + writePinHigh(B7); + break; + } + + return state; +} diff --git a/keyboards/work_louder/work_board/work_board.c b/keyboards/work_louder/work_board/work_board.c index e17f7417cc..a2722a055a 100644 --- a/keyboards/work_louder/work_board/work_board.c +++ b/keyboards/work_louder/work_board/work_board.c @@ -18,7 +18,9 @@ #if !defined(VIA_ENABLE) && defined(ENCODER_ENABLE) bool encoder_update_kb(uint8_t index, bool clockwise) { - if (!encoder_update_user(index, clockwise)) { return false; } + if (!encoder_update_user(index, clockwise)) { + return false; + } if (clockwise) { tap_code(KC_VOLD); } else { @@ -71,23 +73,56 @@ __attribute__((weak)) void oled_task_user(void) { } #endif - #ifdef RGB_MATRIX_ENABLE +// clang-format off led_config_t g_led_config = { { - { 49, 48, 47, 46, 45, 43, 42, 41, 40, 39, 38, 37}, - { 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36 }, - { 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13 }, - { 0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12 }, + { 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48 }, + { 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25 }, + { 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 }, + { 12, 11, 10, 9, 8, 7, 5, 4, 3, 2, 1, 0} }, { - { 223, 63 }, { 203, 63 }, { 183, 63 }, { 162, 63 }, { 142, 63 }, { 122, 63 }, { 101, 63 }, { 81, 63 }, { 61, 63 }, { 40, 63 }, { 20, 63 }, { 0, 63 }, + { 223, 63 }, { 203, 63 }, { 183, 63 }, { 162, 63 }, { 142, 63 }, { 122, 63 }, { 112, 63 }, { 101, 63 }, { 81, 63 }, { 61, 63 }, { 40, 63 }, { 20, 63 }, { 0, 63 }, { 0, 42 }, { 20, 42 }, { 40, 42 }, { 61, 42 }, { 81, 42 }, { 101, 42 }, { 122, 42 }, { 142, 42 }, { 162, 42 }, { 183, 42 }, { 203, 42 }, { 223, 42 }, { 223, 21 }, { 203, 21 }, { 183, 21 }, { 162, 21 }, { 142, 21 }, { 122, 21 }, { 101, 21 }, { 81, 21 }, { 61, 21 }, { 40, 21 }, { 20, 21 }, { 0, 21 }, - { 0, 0 }, { 20, 0 }, { 40, 0 }, { 61, 0 }, { 81, 0 }, { 101, 0 }, { 122, 0 }, { 132, 0 }, { 142, 0 }, { 162, 0 }, { 183, 0 }, { 203, 0 }, { 223, 0 }, + { 0, 0 }, { 20, 0 }, { 40, 0 }, { 61, 0 }, { 81, 0 }, { 101, 0 }, { 122, 0 }, { 142, 0 }, { 162, 0 }, { 183, 0 }, { 203, 0 }, { 223, 0 } }, { + 1, 1, 1, 1, 1, 4,4,4, 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, - 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, - 1, 1, 1, 1, 1, 4,4,4, 1, 1, 1, 1, 1 + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1 } }; +// clang-format on + +__attribute__((weak)) void rgb_matrix_indicators_user(void) { +# ifdef VIA_ENABLE + static bool layout_2u = false; + static uint16_t timer = 0; + if (timer_elapsed(timer) > 500) { + timer = timer_read(); + layout_2u = (bool)via_get_layout_options(); + } + if (layout_2u) { + rgb_matrix_set_color(5, 0, 0, 0); + rgb_matrix_set_color(7, 0, 0, 0); + } else { + rgb_matrix_set_color(6, 0, 0, 0); + } +# else + rgb_matrix_set_color(5, 0, 0, 0); + rgb_matrix_set_color(7, 0, 0, 0); +# endif +} + +void keyboard_pre_init_kb(void) { + setPinOutput(B2); + setPinOutput(B3); + setPinOutput(B7); + + writePinLow(B2); + writePinLow(B3); + writePinLow(B7); + + keyboard_pre_init_user(); +} #endif -- cgit v1.2.3