aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2021-09-02 10:49:44 -0700
committerGitHub <noreply@github.com>2021-09-02 10:49:44 -0700
commit956cf8d7bfbca187ad9d1e0aabbe6c25348d5e07 (patch)
treedb604cf57706a84bfeac69db13e16cdf2ade3dfb
parentd36a7c512d14e3bc6534f311e8f1a8a69878acb3 (diff)
downloadqmk_firmware-956cf8d7bfbca187ad9d1e0aabbe6c25348d5e07.tar.gz
qmk_firmware-956cf8d7bfbca187ad9d1e0aabbe6c25348d5e07.zip
[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
-rw-r--r--keyboards/work_louder/loop/config.h35
-rw-r--r--keyboards/work_louder/loop/keymaps/via/keymap.c4
-rw-r--r--keyboards/work_louder/loop/loop.c5
-rw-r--r--keyboards/work_louder/nano/config.h78
-rw-r--r--keyboards/work_louder/rgb_functions.c157
-rw-r--r--keyboards/work_louder/work_board/config.h78
-rw-r--r--keyboards/work_louder/work_board/keymaps/via/keymap.c31
-rw-r--r--keyboards/work_louder/work_board/work_board.c55
8 files changed, 331 insertions, 112 deletions
diff --git a/keyboards/work_louder/loop/config.h b/keyboards/work_louder/loop/config.h
index 011fe4f32..bd8e3d075 100644
--- a/keyboards/work_louder/loop/config.h
+++ b/keyboards/work_louder/loop/config.h
@@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
24#define PRODUCT_ID 0x1DF8 24#define PRODUCT_ID 0x1DF8
25#define DEVICE_VER 0x0001 25#define DEVICE_VER 0x0001
26#define MANUFACTURER Work Louder 26#define MANUFACTURER Work Louder
27#define PRODUCT loop 27#define PRODUCT Loop Pad
28 28
29/* key matrix size */ 29/* key matrix size */
30#define MATRIX_ROWS 2 30#define MATRIX_ROWS 2
@@ -40,7 +40,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
40 * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) 40 * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
41 * 41 *
42 */ 42 */
43#define MATRIX_ROW_PINS { F5 } 43#define MATRIX_ROW_PINS \
44 { F5, NO_PIN }
44#define MATRIX_COL_PINS { B3, B2, B1, D6, D7, B4, B5, B6, C6, C7, F7, F6 } 45#define MATRIX_COL_PINS { B3, B2, B1, D6, D7, B4, B5, B6, C6, C7, F7, F6 }
45#define UNUSED_PINS 46#define UNUSED_PINS
46 47
@@ -63,20 +64,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
63//# define RGBLIGHT_HUE_STEP 8 64//# define RGBLIGHT_HUE_STEP 8
64//# define RGBLIGHT_SAT_STEP 8 65//# define RGBLIGHT_SAT_STEP 8
65//# define RGBLIGHT_VAL_STEP 8 66//# define RGBLIGHT_VAL_STEP 8
66//# define RGBLIGHT_LIMIT_VAL 255 /* The maximum brightness level */ 67#define RGBLIGHT_LIMIT_VAL 120 /* The maximum brightness level */
67# define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */ 68#define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */
68/*== all animations enable ==*/
69# define RGBLIGHT_ANIMATIONS
70/*== or choose animations ==*/ 69/*== or choose animations ==*/
71//# define RGBLIGHT_EFFECT_BREATHING 70#define RGBLIGHT_EFFECT_BREATHING
72//# define RGBLIGHT_EFFECT_RAINBOW_MOOD 71#define RGBLIGHT_EFFECT_RAINBOW_MOOD
73//# define RGBLIGHT_EFFECT_RAINBOW_SWIRL 72#define RGBLIGHT_EFFECT_RAINBOW_SWIRL
74//# define RGBLIGHT_EFFECT_SNAKE 73#define RGBLIGHT_EFFECT_SNAKE
75//# define RGBLIGHT_EFFECT_KNIGHT 74#define RGBLIGHT_EFFECT_KNIGHT
76//# define RGBLIGHT_EFFECT_CHRISTMAS 75#define RGBLIGHT_EFFECT_CHRISTMAS
77//# define RGBLIGHT_EFFECT_STATIC_GRADIENT 76#define RGBLIGHT_EFFECT_STATIC_GRADIENT
78//# define RGBLIGHT_EFFECT_RGB_TEST 77#define RGBLIGHT_EFFECT_RGB_TEST
79//# define RGBLIGHT_EFFECT_ALTERNATING 78#define RGBLIGHT_EFFECT_TWINKLE
79
80#define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_STATIC_LIGHT
81#define RGBLIGHT_DEFAULT_HUE 36
80/*== customize breathing effect ==*/ 82/*== customize breathing effect ==*/
81/*==== (DEFAULT) use fixed table instead of exp() and sin() ====*/ 83/*==== (DEFAULT) use fixed table instead of exp() and sin() ====*/
82//# define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256(default) or 128 or 64 84//# define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256(default) or 128 or 64
@@ -87,7 +89,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
87 89
88#define RGB_DI_PIN F1 90#define RGB_DI_PIN F1
89#define DRIVER_LED_TOTAL 9 91#define DRIVER_LED_TOTAL 9
92#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 120
90#define RGB_MATRIX_DISABLE_KEYCODES 93#define RGB_MATRIX_DISABLE_KEYCODES
94#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_LEFT_RIGHT // Sets the default mode, if none has been set
95#define RGB_DISABLE_WHEN_USB_SUSPENDED
91 96
92/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ 97/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
93#define DEBOUNCE 5 98#define DEBOUNCE 5
diff --git a/keyboards/work_louder/loop/keymaps/via/keymap.c b/keyboards/work_louder/loop/keymaps/via/keymap.c
index 134bce65d..c5769b991 100644
--- a/keyboards/work_louder/loop/keymaps/via/keymap.c
+++ b/keyboards/work_louder/loop/keymaps/via/keymap.c
@@ -15,11 +15,11 @@
15 */ 15 */
16#include QMK_KEYBOARD_H 16#include QMK_KEYBOARD_H
17 17
18// clang-format off
18const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 19const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
19 /* Base */
20 [0] = LAYOUT_via( 20 [0] = LAYOUT_via(
21 KC_MUTE, KC_MPLY, R_M_TOG, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, MO(1), 21 KC_MUTE, KC_MPLY, R_M_TOG, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, MO(1),
22 KC_VOLD, KC_VOLD, KC_MPRV, KC_MNXT, R_M_MOD, R_M_RMOD 22 KC_VOLU, KC_VOLD, KC_MNXT, KC_MPRV, R_M_MOD, R_M_RMOD
23 ), 23 ),
24 [1] = LAYOUT_via( 24 [1] = LAYOUT_via(
25 RESET, _______, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, MO(2), _______, 25 RESET, _______, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, MO(2), _______,
diff --git a/keyboards/work_louder/loop/loop.c b/keyboards/work_louder/loop/loop.c
index 355199531..5c0d108d1 100644
--- a/keyboards/work_louder/loop/loop.c
+++ b/keyboards/work_louder/loop/loop.c
@@ -43,14 +43,15 @@ bool encoder_update_kb(uint8_t index, bool clockwise) {
43#endif 43#endif
44 44
45#ifdef RGB_MATRIX_ENABLE 45#ifdef RGB_MATRIX_ENABLE
46// clang-format off
46led_config_t g_led_config = { 47led_config_t g_led_config = {
47 { 48 {
48 { NO_LED, NO_LED, NO_LED, 8, 7, 6, 5, 4, 3, 2, 1, 0 } 49 { NO_LED, NO_LED, NO_LED, 8, 7, 6, 5, 4, 3, 2, 1, 0 }
49 }, { 50 }, {
50 { 36, 32 }, { 55, 32 }, { 74, 32 }, { 93, 32 }, { 112, 32 }, { 131, 32 }, { 150, 32 }, { 169, 32 }, { 188, 32 } 51 {188, 32}, {169, 32}, {150, 32}, {131, 32}, {112, 32}, {93, 32}, {74, 32}, {55, 32}, {36, 32}
51 }, { 52 }, {
52 4, 4, 4, 4, 4, 4, 4, 4, 4 53 4, 4, 4, 4, 4, 4, 4, 4, 4
53 } 54 }
54}; 55};
55 56// clang-format on
56#endif 57#endif
diff --git a/keyboards/work_louder/nano/config.h b/keyboards/work_louder/nano/config.h
index 4c897b7e5..1a47e725b 100644
--- a/keyboards/work_louder/nano/config.h
+++ b/keyboards/work_louder/nano/config.h
@@ -24,15 +24,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
24#define PRODUCT_ID 0xE6EF 24#define PRODUCT_ID 0xE6EF
25#define DEVICE_VER 0x0001 25#define DEVICE_VER 0x0001
26#define MANUFACTURER Work Louder 26#define MANUFACTURER Work Louder
27#define PRODUCT nano 27#define PRODUCT Nano Pad
28 28
29/* key matrix size */ 29/* key matrix size */
30#define MATRIX_ROWS 1 30#define MATRIX_ROWS 1
31#ifdef VIA_ENABLE 31#define MATRIX_COLS 5
32# define MATRIX_COLS 5
33#else
34# define MATRIX_COLS 3
35#endif
36 32
37/* 33/*
38 * Keyboard Matrix Assignments 34 * Keyboard Matrix Assignments
@@ -44,13 +40,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
44 * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) 40 * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
45 * 41 *
46 */ 42 */
47#define MATRIX_ROW_PINS { F7 } 43#define MATRIX_ROW_PINS \
48#define MATRIX_COL_PINS { B5, B6, C6 } 44 { F7 }
49#define UNUSED_PINS 45#define MATRIX_COL_PINS \
46 { B5, B6, C6, NO_PIN, NO_PIN }
50 47
51/* COL2ROW, ROW2COL */ 48/* COL2ROW, ROW2COL */
52#define DIODE_DIRECTION COL2ROW 49#define DIODE_DIRECTION COL2ROW
53
54 50
55//#define LED_NUM_LOCK_PIN B0 51//#define LED_NUM_LOCK_PIN B0
56//#define LED_CAPS_LOCK_PIN B1 52//#define LED_CAPS_LOCK_PIN B1
@@ -62,25 +58,26 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
62//#define BACKLIGHT_LEVELS 3 58//#define BACKLIGHT_LEVELS 3
63//#define BACKLIGHT_BREATHING 59//#define BACKLIGHT_BREATHING
64 60
65#define RGBLIGHT_DI_PIN C7 61#define RGBLIGHT_DI_PIN C7
66# define RGBLED_NUM 6 62#define RGBLED_NUM 6
67//# define RGBLIGHT_HUE_STEP 8 63//# define RGBLIGHT_HUE_STEP 8
68//# define RGBLIGHT_SAT_STEP 8 64//# define RGBLIGHT_SAT_STEP 8
69//# define RGBLIGHT_VAL_STEP 8 65//# define RGBLIGHT_VAL_STEP 8
70//# define RGBLIGHT_LIMIT_VAL 255 /* The maximum brightness level */ 66#define RGBLIGHT_LIMIT_VAL 120 /* The maximum brightness level */
71# define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */ 67#define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */
72/*== all animations enable ==*/
73# define RGBLIGHT_ANIMATIONS
74/*== or choose animations ==*/ 68/*== or choose animations ==*/
75//# define RGBLIGHT_EFFECT_BREATHING 69#define RGBLIGHT_EFFECT_BREATHING
76//# define RGBLIGHT_EFFECT_RAINBOW_MOOD 70#define RGBLIGHT_EFFECT_RAINBOW_MOOD
77//# define RGBLIGHT_EFFECT_RAINBOW_SWIRL 71#define RGBLIGHT_EFFECT_RAINBOW_SWIRL
78//# define RGBLIGHT_EFFECT_SNAKE 72#define RGBLIGHT_EFFECT_SNAKE
79//# define RGBLIGHT_EFFECT_KNIGHT 73#define RGBLIGHT_EFFECT_KNIGHT
80//# define RGBLIGHT_EFFECT_CHRISTMAS 74#define RGBLIGHT_EFFECT_CHRISTMAS
81//# define RGBLIGHT_EFFECT_STATIC_GRADIENT 75#define RGBLIGHT_EFFECT_STATIC_GRADIENT
82//# define RGBLIGHT_EFFECT_RGB_TEST 76#define RGBLIGHT_EFFECT_RGB_TEST
83//# define RGBLIGHT_EFFECT_ALTERNATING 77#define RGBLIGHT_EFFECT_TWINKLE
78#define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_STATIC_LIGHT
79#define RGBLIGHT_DEFAULT_HUE 170
80
84/*== customize breathing effect ==*/ 81/*== customize breathing effect ==*/
85/*==== (DEFAULT) use fixed table instead of exp() and sin() ====*/ 82/*==== (DEFAULT) use fixed table instead of exp() and sin() ====*/
86//# define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256(default) or 128 or 64 83//# define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256(default) or 128 or 64
@@ -89,9 +86,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
89//# define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0 to 255 86//# define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0 to 255
90//#endif 87//#endif
91 88
92#define RGB_DI_PIN F6 89#define RGB_DI_PIN F6
93#define DRIVER_LED_TOTAL 2 90#define DRIVER_LED_TOTAL 2
91#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 120
94#define RGB_MATRIX_DISABLE_KEYCODES 92#define RGB_MATRIX_DISABLE_KEYCODES
93#define RGB_DISABLE_WHEN_USB_SUSPENDED
95 94
96/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ 95/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
97#define DEBOUNCE 5 96#define DEBOUNCE 5
@@ -151,14 +150,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
151#define NO_ACTION_FUNCTION 150#define NO_ACTION_FUNCTION
152 151
153/* Bootmagic Lite key configuration */ 152/* Bootmagic Lite key configuration */
154#define BOOTMAGIC_LITE_ROW 0 153#define BOOTMAGIC_LITE_ROW 0
155#define BOOTMAGIC_LITE_COLUMN 3 154#define BOOTMAGIC_LITE_COLUMN 2
156
157 155
158#define ENCODERS_PAD_A { D7 } 156#define ENCODERS_PAD_A \
159#define ENCODERS_PAD_B { B4 } 157 { D7 }
158#define ENCODERS_PAD_B \
159 { B4 }
160 160
161#define ENCODERS 1 161#define ENCODERS 1
162 162
163#define ENCODERS_CW_KEY { { 3, 0 } } 163#define ENCODERS_CW_KEY \
164#define ENCODERS_CCW_KEY { { 4, 0 } } 164 { \
165 { 3, 0 } \
166 }
167#define ENCODERS_CCW_KEY \
168 { \
169 { 4, 0 } \
170 }
diff --git a/keyboards/work_louder/rgb_functions.c b/keyboards/work_louder/rgb_functions.c
index 5a2043f9b..c9106b397 100644
--- a/keyboards/work_louder/rgb_functions.c
+++ b/keyboards/work_louder/rgb_functions.c
@@ -17,13 +17,160 @@
17#include QMK_KEYBOARD_H 17#include QMK_KEYBOARD_H
18#include "rgb_functions.h" 18#include "rgb_functions.h"
19 19
20#if defined(RGBLIGHT_ENABLE) && defined(RGB_MATRIX_EANBLE) 20#ifdef RGBLIGHT_ENABLE
21# undef RGB_DI_PIN 21# include "ws2812.h"
22# define RGBLIGHT_DI_PIN 22# include <avr/interrupt.h>
23# include "ws2812.c" 23# include <avr/io.h>
24# include <util/delay.h>
25
26# define pinmask(pin) (_BV((pin)&0xF))
27
28/*
29 * Forward declare internal functions
30 *
31 * The functions take a byte-array and send to the data output as WS2812 bitstream.
32 * The length is the number of bytes to send - three per LED.
33 */
34
35static inline void ws2812_sendarray_mask(uint8_t *data, uint16_t datlen, uint8_t masklo, uint8_t maskhi);
36
37/*
38 This routine writes an array of bytes with RGB values to the Dataout pin
39 using the fast 800kHz clockless WS2811/2812 protocol.
40*/
41
42// Timing in ns
43# define w_zeropulse 350
44# define w_onepulse 900
45# define w_totalperiod 1250
46
47// Fixed cycles used by the inner loop
48# define w_fixedlow 2
49# define w_fixedhigh 4
50# define w_fixedtotal 8
51
52// Insert NOPs to match the timing, if possible
53# define w_zerocycles (((F_CPU / 1000) * w_zeropulse) / 1000000)
54# define w_onecycles (((F_CPU / 1000) * w_onepulse + 500000) / 1000000)
55# define w_totalcycles (((F_CPU / 1000) * w_totalperiod + 500000) / 1000000)
56
57// w1_nops - nops between rising edge and falling edge - low
58# if w_zerocycles >= w_fixedlow
59# define w1_nops (w_zerocycles - w_fixedlow)
60# else
61# define w1_nops 0
62# endif
63
64// w2_nops - nops between fe low and fe high
65# if w_onecycles >= (w_fixedhigh + w1_nops)
66# define w2_nops (w_onecycles - w_fixedhigh - w1_nops)
67# else
68# define w2_nops 0
69# endif
70
71// w3_nops - nops to complete loop
72# if w_totalcycles >= (w_fixedtotal + w1_nops + w2_nops)
73# define w3_nops (w_totalcycles - w_fixedtotal - w1_nops - w2_nops)
74# else
75# define w3_nops 0
76# endif
77
78// The only critical timing parameter is the minimum pulse length of the "0"
79// Warn or throw error if this timing can not be met with current F_CPU settings.
80# define w_lowtime ((w1_nops + w_fixedlow) * 1000000) / (F_CPU / 1000)
81# if w_lowtime > 550
82# error "Light_ws2812: Sorry, the clock speed is too low. Did you set F_CPU correctly?"
83# elif w_lowtime > 450
84# warning "Light_ws2812: The timing is critical and may only work on WS2812B, not on WS2812(S)."
85# warning "Please consider a higher clockspeed, if possible"
86# endif
87
88# define w_nop1 "nop \n\t"
89# define w_nop2 "rjmp .+0 \n\t"
90# define w_nop4 w_nop2 w_nop2
91# define w_nop8 w_nop4 w_nop4
92# define w_nop16 w_nop8 w_nop8
93
94static inline void ws2812_sendarray_mask(uint8_t *data, uint16_t datlen, uint8_t masklo, uint8_t maskhi) {
95 uint8_t curbyte, ctr, sreg_prev;
96
97 sreg_prev = SREG;
98 cli();
99
100 while (datlen--) {
101 curbyte = (*data++);
102
103 asm volatile(" ldi %0,8 \n\t"
104 "loop%=: \n\t"
105 " out %2,%3 \n\t" // '1' [01] '0' [01] - re
106# if (w1_nops & 1)
107 w_nop1
108# endif
109# if (w1_nops & 2)
110 w_nop2
111# endif
112# if (w1_nops & 4)
113 w_nop4
114# endif
115# if (w1_nops & 8)
116 w_nop8
117# endif
118# if (w1_nops & 16)
119 w_nop16
120# endif
121 " sbrs %1,7 \n\t" // '1' [03] '0' [02]
122 " out %2,%4 \n\t" // '1' [--] '0' [03] - fe-low
123 " lsl %1 \n\t" // '1' [04] '0' [04]
124# if (w2_nops & 1)
125 w_nop1
126# endif
127# if (w2_nops & 2)
128 w_nop2
129# endif
130# if (w2_nops & 4)
131 w_nop4
132# endif
133# if (w2_nops & 8)
134 w_nop8
135# endif
136# if (w2_nops & 16)
137 w_nop16
138# endif
139 " out %2,%4 \n\t" // '1' [+1] '0' [+1] - fe-high
140# if (w3_nops & 1)
141 w_nop1
142# endif
143# if (w3_nops & 2)
144 w_nop2
145# endif
146# if (w3_nops & 4)
147 w_nop4
148# endif
149# if (w3_nops & 8)
150 w_nop8
151# endif
152# if (w3_nops & 16)
153 w_nop16
154# endif
155
156 " dec %0 \n\t" // '1' [+2] '0' [+2]
157 " brne loop%=\n\t" // '1' [+3] '0' [+4]
158 : "=&d"(ctr)
159 : "r"(curbyte), "I"(_SFR_IO_ADDR(PORTx_ADDRESS(RGBLIGHT_DI_PIN))), "r"(maskhi), "r"(masklo));
160 }
161
162 SREG = sreg_prev;
163}
24 164
25void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) { 165void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) {
26 ws2812_setleds(start_led, num_leds); 166 DDRx_ADDRESS(RGBLIGHT_DI_PIN) |= pinmask(RGBLIGHT_DI_PIN);
167
168 uint8_t masklo = ~(pinmask(RGBLIGHT_DI_PIN)) & PORTx_ADDRESS(RGBLIGHT_DI_PIN);
169 uint8_t maskhi = pinmask(RGBLIGHT_DI_PIN) | PORTx_ADDRESS(RGBLIGHT_DI_PIN);
170
171 ws2812_sendarray_mask((uint8_t *)start_led, num_leds * sizeof(LED_TYPE), masklo, maskhi);
172
173 _delay_us(WS2812_TRST_US);
27} 174}
28#endif 175#endif
29 176
diff --git a/keyboards/work_louder/work_board/config.h b/keyboards/work_louder/work_board/config.h
index 2ccc1be4c..fb9723db0 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 <http://www.gnu.org/licenses/>.
27#define PRODUCT Work Board 27#define PRODUCT Work Board
28 28
29/* key matrix size */ 29/* key matrix size */
30#define MATRIX_ROWS 4 30#define MATRIX_ROWS 4
31#define MATRIX_COLS 13 31#define MATRIX_COLS 13
32 32
33/* 33/*
34 * Keyboard Matrix Assignments 34 * Keyboard Matrix Assignments
@@ -40,42 +40,35 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
40 * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) 40 * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
41 * 41 *
42 */ 42 */
43#define MATRIX_ROW_PINS { F0, F1, F4, F5 } 43#define MATRIX_ROW_PINS \
44#define MATRIX_COL_PINS { D3, D5, D4, D6, D7, B4, B5, B6, C6, C7, F7, F6, E6 } 44 { F0, F1, F4, F5 }
45#define MATRIX_COL_PINS \
46 { D3, D5, D4, D6, D7, B4, B5, B6, C6, C7, F7, F6, E6 }
45#define UNUSED_PINS 47#define UNUSED_PINS
46 48
47/* COL2ROW, ROW2COL */ 49/* COL2ROW, ROW2COL */
48#define DIODE_DIRECTION COL2ROW 50#define DIODE_DIRECTION COL2ROW
49 51
50#define LED_NUM_LOCK_PIN B2 52#define RGBLIGHT_DI_PIN D2
51#define LED_CAPS_LOCK_PIN B3 53#define RGBLED_NUM 26
52#define LED_SCROLL_LOCK_PIN B7
53//#define LED_COMPOSE_PIN B3
54//#define LED_KANA_PIN B4
55
56//#define BACKLIGHT_PIN B7
57//#define BACKLIGHT_LEVELS 3
58//#define BACKLIGHT_BREATHING
59
60#define RGBLIGHT_DI_PIN D2
61# define RGBLED_NUM 26
62//# define RGBLIGHT_HUE_STEP 8 54//# define RGBLIGHT_HUE_STEP 8
63//# define RGBLIGHT_SAT_STEP 8 55//# define RGBLIGHT_SAT_STEP 8
64//# define RGBLIGHT_VAL_STEP 8 56//# define RGBLIGHT_VAL_STEP 8
65# define RGBLIGHT_LIMIT_VAL 100 /* The maximum brightness level */ 57#define RGBLIGHT_LIMIT_VAL 120 /* The maximum brightness level */
66# define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */ 58#define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */
67/*== all animations enable ==*/
68# define RGBLIGHT_ANIMATIONS
69/*== or choose animations ==*/ 59/*== or choose animations ==*/
70//# define RGBLIGHT_EFFECT_BREATHING 60#define RGBLIGHT_EFFECT_BREATHING
71//# define RGBLIGHT_EFFECT_RAINBOW_MOOD 61#define RGBLIGHT_EFFECT_RAINBOW_MOOD
72//# define RGBLIGHT_EFFECT_RAINBOW_SWIRL 62#define RGBLIGHT_EFFECT_RAINBOW_SWIRL
73//# define RGBLIGHT_EFFECT_SNAKE 63#define RGBLIGHT_EFFECT_SNAKE
74//# define RGBLIGHT_EFFECT_KNIGHT 64#define RGBLIGHT_EFFECT_KNIGHT
75//# define RGBLIGHT_EFFECT_CHRISTMAS 65#define RGBLIGHT_EFFECT_CHRISTMAS
76//# define RGBLIGHT_EFFECT_STATIC_GRADIENT 66#define RGBLIGHT_EFFECT_STATIC_GRADIENT
77//# define RGBLIGHT_EFFECT_RGB_TEST 67#define RGBLIGHT_EFFECT_RGB_TEST
78//# define RGBLIGHT_EFFECT_ALTERNATING 68#define RGBLIGHT_EFFECT_TWINKLE
69
70#define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_STATIC_GRADIENT + 9
71#define RGBLIGHT_DEFAULT_HUE 213
79/*== customize breathing effect ==*/ 72/*== customize breathing effect ==*/
80/*==== (DEFAULT) use fixed table instead of exp() and sin() ====*/ 73/*==== (DEFAULT) use fixed table instead of exp() and sin() ====*/
81//# define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256(default) or 128 or 64 74//# define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256(default) or 128 or 64
@@ -84,10 +77,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
84//# define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0 to 255 77//# define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0 to 255
85//#endif 78//#endif
86 79
87#define RGB_DI_PIN D0 80#define RGB_DI_PIN D1
88#define DRIVER_LED_TOTAL 50 81#define DRIVER_LED_TOTAL 49
89#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 100 82#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 120
90#define RGB_MATRIX_DISABLE_KEYCODES 83#define RGB_MATRIX_DISABLE_KEYCODES
84#define RGB_DISABLE_WHEN_USB_SUSPENDED
91 85
92/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ 86/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
93#define DEBOUNCE 5 87#define DEBOUNCE 5
@@ -146,14 +140,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
146#define NO_ACTION_MACRO 140#define NO_ACTION_MACRO
147#define NO_ACTION_FUNCTION 141#define NO_ACTION_FUNCTION
148 142
149#define ENCODERS_PAD_A { B0 } 143#define ENCODERS_PAD_A \
150#define ENCODERS_PAD_B { B1 } 144 { B0 }
145#define ENCODERS_PAD_B \
146 { B1 }
151 147
152#define ENCODERS 1 148#define ENCODERS 1
153 149
154#define ENCODERS_CW_KEY { { 12, 1 } } 150#define ENCODERS_CW_KEY \
155#define ENCODERS_CCW_KEY { { 12, 2 } } 151 { \
152 { 12, 1 } \
153 }
154#define ENCODERS_CCW_KEY \
155 { \
156 { 12, 2 } \
157 }
156 158
157/* Bootmagic Lite key configuration */ 159/* Bootmagic Lite key configuration */
158//#define BOOTMAGIC_LITE_ROW 0 160//#define BOOTMAGIC_LITE_ROW 0
159//#define BOOTMAGIC_LITE_COLUMN 0 161//#define BOOTMAGIC_LITE_COLUMN 0
162
163#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 6bdc75ac2..1cf5e0757 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 {
27 ENC_TAP, 27 ENC_TAP,
28}; 28};
29 29
30#define LOWER KC_FN13 30#define LOWER FN_MO13
31#define RAISE KC_FN23 31#define RAISE FN_MO23
32 32
33// clang-format off
33const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 34const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
34 [_QWERTY] = LAYOUT_via( 35 [_QWERTY] = LAYOUT_via(
35 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, 36 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,
36 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, 37 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,
37 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, 38 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,
38 KC_LSFT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT 39 KC_LSFT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
39 ), 40 ),
40 41
@@ -59,7 +60,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
59 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ 60 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
60 ) 61 )
61}; 62};
62 63// clang-format on
63 64
64void dance_enc_finished(qk_tap_dance_state_t *state, void *user_data) { 65void dance_enc_finished(qk_tap_dance_state_t *state, void *user_data) {
65 if (state->count == 1) { 66 if (state->count == 1) {
@@ -93,3 +94,23 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
93 } 94 }
94 return true; 95 return true;
95} 96}
97
98layer_state_t layer_state_set_user(layer_state_t state) {
99 writePinLow(B2);
100 writePinLow(B3);
101 writePinLow(B7);
102
103 switch (get_highest_layer(state)) {
104 case 1:
105 writePinHigh(B2);
106 break;
107 case 2:
108 writePinHigh(B3);
109 break;
110 case 3:
111 writePinHigh(B7);
112 break;
113 }
114
115 return state;
116}
diff --git a/keyboards/work_louder/work_board/work_board.c b/keyboards/work_louder/work_board/work_board.c
index e17f7417c..a2722a055 100644
--- a/keyboards/work_louder/work_board/work_board.c
+++ b/keyboards/work_louder/work_board/work_board.c
@@ -18,7 +18,9 @@
18 18
19#if !defined(VIA_ENABLE) && defined(ENCODER_ENABLE) 19#if !defined(VIA_ENABLE) && defined(ENCODER_ENABLE)
20bool encoder_update_kb(uint8_t index, bool clockwise) { 20bool encoder_update_kb(uint8_t index, bool clockwise) {
21 if (!encoder_update_user(index, clockwise)) { return false; } 21 if (!encoder_update_user(index, clockwise)) {
22 return false;
23 }
22 if (clockwise) { 24 if (clockwise) {
23 tap_code(KC_VOLD); 25 tap_code(KC_VOLD);
24 } else { 26 } else {
@@ -71,23 +73,56 @@ __attribute__((weak)) void oled_task_user(void) {
71} 73}
72#endif 74#endif
73 75
74
75#ifdef RGB_MATRIX_ENABLE 76#ifdef RGB_MATRIX_ENABLE
77// clang-format off
76led_config_t g_led_config = { { 78led_config_t g_led_config = { {
77 { 49, 48, 47, 46, 45, 43, 42, 41, 40, 39, 38, 37}, 79 { 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48 },
78 { 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36 }, 80 { 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25 },
79 { 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13 }, 81 { 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 },
80 { 0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12 }, 82 { 12, 11, 10, 9, 8, 7, 5, 4, 3, 2, 1, 0}
81}, { 83}, {
82 { 223, 63 }, { 203, 63 }, { 183, 63 }, { 162, 63 }, { 142, 63 }, { 122, 63 }, { 101, 63 }, { 81, 63 }, { 61, 63 }, { 40, 63 }, { 20, 63 }, { 0, 63 }, 84 { 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 },
83 { 0, 42 }, { 20, 42 }, { 40, 42 }, { 61, 42 }, { 81, 42 }, { 101, 42 }, { 122, 42 }, { 142, 42 }, { 162, 42 }, { 183, 42 }, { 203, 42 }, { 223, 42 }, 85 { 0, 42 }, { 20, 42 }, { 40, 42 }, { 61, 42 }, { 81, 42 }, { 101, 42 }, { 122, 42 }, { 142, 42 }, { 162, 42 }, { 183, 42 }, { 203, 42 }, { 223, 42 },
84 { 223, 21 }, { 203, 21 }, { 183, 21 }, { 162, 21 }, { 142, 21 }, { 122, 21 }, { 101, 21 }, { 81, 21 }, { 61, 21 }, { 40, 21 }, { 20, 21 }, { 0, 21 }, 86 { 223, 21 }, { 203, 21 }, { 183, 21 }, { 162, 21 }, { 142, 21 }, { 122, 21 }, { 101, 21 }, { 81, 21 }, { 61, 21 }, { 40, 21 }, { 20, 21 }, { 0, 21 },
85 { 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 }, 87 { 0, 0 }, { 20, 0 }, { 40, 0 }, { 61, 0 }, { 81, 0 }, { 101, 0 }, { 122, 0 }, { 142, 0 }, { 162, 0 }, { 183, 0 }, { 203, 0 }, { 223, 0 }
86}, { 88}, {
89 1, 1, 1, 1, 1, 4,4,4, 1, 1, 1, 1, 1,
87 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 90 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
88 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 91 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
89 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 92 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1
90 1, 1, 1, 1, 1, 4,4,4, 1, 1, 1, 1, 1
91} }; 93} };
94// clang-format on
95
96__attribute__((weak)) void rgb_matrix_indicators_user(void) {
97# ifdef VIA_ENABLE
98 static bool layout_2u = false;
99 static uint16_t timer = 0;
100 if (timer_elapsed(timer) > 500) {
101 timer = timer_read();
102 layout_2u = (bool)via_get_layout_options();
103 }
104 if (layout_2u) {
105 rgb_matrix_set_color(5, 0, 0, 0);
106 rgb_matrix_set_color(7, 0, 0, 0);
107 } else {
108 rgb_matrix_set_color(6, 0, 0, 0);
109 }
110# else
111 rgb_matrix_set_color(5, 0, 0, 0);
112 rgb_matrix_set_color(7, 0, 0, 0);
113# endif
114}
115
116void keyboard_pre_init_kb(void) {
117 setPinOutput(B2);
118 setPinOutput(B3);
119 setPinOutput(B7);
120
121 writePinLow(B2);
122 writePinLow(B3);
123 writePinLow(B7);
124
125 keyboard_pre_init_user();
126}
92 127
93#endif 128#endif