aboutsummaryrefslogtreecommitdiff
path: root/users/drashna
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2021-08-21 13:34:44 -0700
committerGitHub <noreply@github.com>2021-08-21 13:34:44 -0700
commit58a5030661b57f1dd05693053df2eddadc285f64 (patch)
tree025a7a2d0dc6643ce806b72798c92139eafb4ca6 /users/drashna
parentda1c011afc67dab0049b30a4c021dc38a36cb9aa (diff)
downloadqmk_firmware-58a5030661b57f1dd05693053df2eddadc285f64.tar.gz
qmk_firmware-58a5030661b57f1dd05693053df2eddadc285f64.zip
[Keymap] Drashna's Improve OLEDs and custom Split code (#14063)
* Fill the oleds with right mods * Enable double mods on x32 oleds * Disable forced NKRO * Make oleds fancy only on good MCUs * Overhaul oled display * Further enhance oled, with kitty! * Final oled form * Not working transport * Transport id of woring * Add acceleration * fix button placement for accel macro * Fix accelartion location and behavior * Remove OLED sync code * Fix alignment issue * Remove audio hack * Fix up zima keymap * Add matrix slave scan function and cleanup drashna.h * Clean up user space * Allow userspace sync to be disable-able * Fix weird issue with audio * Fix alignment issue with user split sync * Disable second rgb matrix task * Disable additional animations * Change dynamic keymap settings * Hacky fix for borked corne * Add Blackpill (F411) support to tractyl manuform * remove manual via eeprom reset * Remove all references to rgblight twinkle * Fix issues with config processing
Diffstat (limited to 'users/drashna')
-rw-r--r--users/drashna/config.h57
-rw-r--r--users/drashna/drashna.c95
-rw-r--r--users/drashna/drashna.h7
-rw-r--r--users/drashna/oled_stuff.c101
-rw-r--r--users/drashna/oled_stuff.h13
-rw-r--r--users/drashna/post_config.h40
-rw-r--r--users/drashna/process_records.c12
-rw-r--r--users/drashna/process_records.h1
-rw-r--r--users/drashna/rgb_matrix_stuff.c5
-rw-r--r--users/drashna/rgb_stuff.c135
-rw-r--r--users/drashna/rgb_stuff.h13
-rw-r--r--users/drashna/rules.mk11
-rw-r--r--users/drashna/transport_sync.c122
13 files changed, 303 insertions, 309 deletions
diff --git a/users/drashna/config.h b/users/drashna/config.h
index ab0080234..c8007a61b 100644
--- a/users/drashna/config.h
+++ b/users/drashna/config.h
@@ -30,8 +30,15 @@
30# ifdef WPM_ENABLE 30# ifdef WPM_ENABLE
31# define SPLIT_WPM_ENABLE 31# define SPLIT_WPM_ENABLE
32# endif 32# endif
33# define SELECT_SOFT_SERIAL_SPEED 1 33# ifdef OLED_DRIVER_ENABLE
34# define SPLIT_TRANSACTION_IDS_USER RPC_ID_USER_STATE_SYNC, RPC_ID_USER_KEYMAP_SYNC, RPC_ID_USER_CONFIG_SYNC 34# define SPLIT_OLED_ENABLE
35# endif
36# if defined(__AVR__) && !defined(SELECT_SOFT_SERIAL_SPEED)
37# define SELECT_SOFT_SERIAL_SPEED 1
38# endif
39# ifdef CUSTOM_SPLIT_TRANSPORT_SYNC
40# define SPLIT_TRANSACTION_IDS_USER RPC_ID_USER_STATE_SYNC, RPC_ID_USER_KEYMAP_SYNC, RPC_ID_USER_CONFIG_SYNC
41# endif
35#endif 42#endif
36 43
37#ifdef AUDIO_ENABLE 44#ifdef AUDIO_ENABLE
@@ -65,23 +72,6 @@
65 72
66#ifdef RGBLIGHT_ENABLE 73#ifdef RGBLIGHT_ENABLE
67# define RGBLIGHT_SLEEP 74# define RGBLIGHT_SLEEP
68# undef RGBLIGHT_ANIMATIONS
69# if defined(__AVR__) && !defined(__AVR_AT90USB1286__)
70# define RGBLIGHT_EFFECT_BREATHING
71# define RGBLIGHT_EFFECT_SNAKE
72# define RGBLIGHT_EFFECT_KNIGHT
73# else
74# define RGBLIGHT_EFFECT_BREATHING
75# define RGBLIGHT_EFFECT_RAINBOW_MOOD
76# define RGBLIGHT_EFFECT_RAINBOW_SWIRL
77# define RGBLIGHT_EFFECT_SNAKE
78# define RGBLIGHT_EFFECT_KNIGHT
79// # define RGBLIGHT_EFFECT_CHRISTMAS
80// # define RGBLIGHT_EFFECT_STATIC_GRADIENT
81// # define RGBLIGHT_EFFECT_RGB_TEST
82// # define RGBLIGHT_EFFECT_ALTERNATING
83# define RGBLIGHT_EFFECT_TWINKLE
84# endif
85# define RGBLIGHT_EFFECT_TWINKLE_LIFE 250 75# define RGBLIGHT_EFFECT_TWINKLE_LIFE 250
86# define RGBLIGHT_EFFECT_TWINKLE_PROBABILITY 1 / 24 76# define RGBLIGHT_EFFECT_TWINKLE_PROBABILITY 1 / 24
87#endif // RGBLIGHT_ENABLE 77#endif // RGBLIGHT_ENABLE
@@ -107,8 +97,10 @@
107# define DISABLE_RGB_MATRIX_CYCLE_ALL 97# define DISABLE_RGB_MATRIX_CYCLE_ALL
108# define DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT 98# define DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
109# define DISABLE_RGB_MATRIX_CYCLE_UP_DOWN 99# define DISABLE_RGB_MATRIX_CYCLE_UP_DOWN
110// # define DISABLE_RGB_MATRIX_CYCLE_OUT_IN 100# if defined(SPLIT_KEYBOARD) || defined(KEYBOARD_ergodox_ez) || defined(KEYBOARD_moonlander)
101# define DISABLE_RGB_MATRIX_CYCLE_OUT_IN
111// # define DISABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL 102// # define DISABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL
103# endif
112# define DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON 104# define DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
113# define DISABLE_RGB_MATRIX_DUAL_BEACON 105# define DISABLE_RGB_MATRIX_DUAL_BEACON
114# define DISABLE_RGB_MATRIX_CYCLE_PINWHEEL 106# define DISABLE_RGB_MATRIX_CYCLE_PINWHEEL
@@ -117,6 +109,12 @@
117# define DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS 109# define DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS
118# define DISABLE_RGB_MATRIX_RAINDROPS 110# define DISABLE_RGB_MATRIX_RAINDROPS
119# define DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS 111# define DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
112# define DISABLE_RGB_MATRIX_HUE_BREATHING
113# define DISABLE_RGB_MATRIX_HUE_PENDULUM
114# define DISABLE_RGB_MATRIX_HUE_WAVE
115# define DISABLE_RGB_MATRIX_PIXEL_RAIN
116# define DISABLE_RGB_MATRIX_PIXEL_FLOW
117# define DISABLE_RGB_MATRIX_PIXEL_FRACTAL
120// # define DISABLE_RGB_MATRIX_TYPING_HEATMAP 118// # define DISABLE_RGB_MATRIX_TYPING_HEATMAP
121# define DISABLE_RGB_MATRIX_DIGITAL_RAIN 119# define DISABLE_RGB_MATRIX_DIGITAL_RAIN
122# define DISABLE_RGB_MATRIX_SOLID_REACTIVE 120# define DISABLE_RGB_MATRIX_SOLID_REACTIVE
@@ -132,7 +130,15 @@
132# define DISABLE_RGB_MATRIX_SOLID_SPLASH 130# define DISABLE_RGB_MATRIX_SOLID_SPLASH
133# define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH 131# define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH
134# endif // AVR 132# endif // AVR
135#endif // RGB_MATRIX_ENABLE 133# ifndef RGB_MATRIX_REST_MODE
134# if defined(SPLIT_KEYBOARD) || defined(KEYBOARD_ergodox_ez) || defined(KEYBOARD_moonlander)
135# define RGB_MATRIX_REST_MODE RGB_MATRIX_CYCLE_OUT_IN_DUAL
136# else
137# define RGB_MATRIX_REST_MODE RGB_MATRIX_CYCLE_OUT_IN
138# endif
139# endif
140# define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_REST_MODE
141#endif // RGB_MATRIX_ENABLE
136 142
137#ifdef OLED_DRIVER_ENABLE 143#ifdef OLED_DRIVER_ENABLE
138# ifdef SPLIT_KEYBOARD 144# ifdef SPLIT_KEYBOARD
@@ -182,8 +188,6 @@
182# define TAPPING_TERM_PER_KEY 188# define TAPPING_TERM_PER_KEY
183#endif 189#endif
184 190
185#define FORCE_NKRO
186
187#ifndef TAPPING_TOGGLE 191#ifndef TAPPING_TOGGLE
188# define TAPPING_TOGGLE 1 192# define TAPPING_TOGGLE 1
189#endif 193#endif
@@ -209,7 +213,12 @@
209# undef LOCKING_RESYNC_ENABLE 213# undef LOCKING_RESYNC_ENABLE
210#endif 214#endif
211 215
212#define LAYER_STATE_16BIT 216#if !defined(LAYER_STATE_16BIT) && !defined(LAYER_STATE_8BIT) && !defined(LAYER_STATE_32BIT)
217# define LAYER_STATE_16BIT
218#endif
219#ifndef DYNAMIC_KEYMAP_LAYER_COUNT
220# define DYNAMIC_KEYMAP_LAYER_COUNT 11
221#endif
213 222
214#ifdef CONVERT_TO_PROTON_C 223#ifdef CONVERT_TO_PROTON_C
215// pins that are available but not present on Pro Micro 224// pins that are available but not present on Pro Micro
diff --git a/users/drashna/drashna.c b/users/drashna/drashna.c
index 4cef5433d..27b9b5bc9 100644
--- a/users/drashna/drashna.c
+++ b/users/drashna/drashna.c
@@ -50,8 +50,7 @@ bool mod_key_press(uint16_t code, uint16_t mod_code, bool pressed, uint16_t this
50} 50}
51 51
52__attribute__((weak)) void keyboard_pre_init_keymap(void) {} 52__attribute__((weak)) void keyboard_pre_init_keymap(void) {}
53 53void keyboard_pre_init_user(void) {
54void keyboard_pre_init_user(void) {
55 userspace_config.raw = eeconfig_read_user(); 54 userspace_config.raw = eeconfig_read_user();
56 keyboard_pre_init_keymap(); 55 keyboard_pre_init_keymap();
57} 56}
@@ -59,12 +58,11 @@ void keyboard_pre_init_user(void) {
59// This allows for a global, userspace functions, and continued 58// This allows for a global, userspace functions, and continued
60// customization of the keymap. Use _keymap instead of _user 59// customization of the keymap. Use _keymap instead of _user
61// functions in the keymaps 60// functions in the keymaps
62__attribute__((weak)) void matrix_init_keymap(void) {}
63__attribute__((weak)) void matrix_init_secret(void) {}
64
65// Call user matrix init, set default RGB colors and then 61// Call user matrix init, set default RGB colors and then
66// call the keymap's init function 62// call the keymap's init function
67void matrix_init_user(void) { 63__attribute__((weak)) void matrix_init_keymap(void) {}
64__attribute__((weak)) void matrix_init_secret(void) {}
65void matrix_init_user(void) {
68#if defined(BOOTLOADER_CATERINA) && defined(__AVR__) 66#if defined(BOOTLOADER_CATERINA) && defined(__AVR__)
69 DDRD &= ~(1 << 5); 67 DDRD &= ~(1 << 5);
70 PORTD &= ~(1 << 5); 68 PORTD &= ~(1 << 5);
@@ -75,11 +73,15 @@ void matrix_init_user(void) {
75 73
76 matrix_init_secret(); 74 matrix_init_secret();
77 matrix_init_keymap(); 75 matrix_init_keymap();
76#if defined(AUDIO_ENABLE) && defined(SPLIT_KEYBOARD)
77 if (!is_keyboard_master()) {
78 stop_all_notes();
79 }
80#endif
78} 81}
79 82
80__attribute__((weak)) void keyboard_post_init_keymap(void) {} 83__attribute__((weak)) void keyboard_post_init_keymap(void) {}
81 84void keyboard_post_init_user(void) {
82void keyboard_post_init_user(void) {
83#if defined(RGBLIGHT_ENABLE) 85#if defined(RGBLIGHT_ENABLE)
84 keyboard_post_init_rgb_light(); 86 keyboard_post_init_rgb_light();
85#endif 87#endif
@@ -92,13 +94,12 @@ void keyboard_post_init_user(void) {
92 keyboard_post_init_keymap(); 94 keyboard_post_init_keymap();
93} 95}
94 96
95__attribute__((weak)) void shutdown_keymap(void) {}
96
97#ifdef RGB_MATRIX_ENABLE 97#ifdef RGB_MATRIX_ENABLE
98void rgb_matrix_update_pwm_buffers(void); 98void rgb_matrix_update_pwm_buffers(void);
99#endif 99#endif
100 100
101void shutdown_user(void) { 101__attribute__((weak)) void shutdown_keymap(void) {}
102void shutdown_user(void) {
102#ifdef RGBLIGHT_ENABLE 103#ifdef RGBLIGHT_ENABLE
103 rgblight_enable_noeeprom(); 104 rgblight_enable_noeeprom();
104 rgblight_mode_noeeprom(1); 105 rgblight_mode_noeeprom(1);
@@ -113,8 +114,7 @@ void shutdown_user(void) {
113} 114}
114 115
115__attribute__((weak)) void suspend_power_down_keymap(void) {} 116__attribute__((weak)) void suspend_power_down_keymap(void) {}
116 117void suspend_power_down_user(void) {
117void suspend_power_down_user(void) {
118#ifdef OLED_DRIVER_ENABLE 118#ifdef OLED_DRIVER_ENABLE
119 oled_off(); 119 oled_off();
120#endif 120#endif
@@ -122,8 +122,7 @@ void suspend_power_down_user(void) {
122} 122}
123 123
124__attribute__((weak)) void suspend_wakeup_init_keymap(void) {} 124__attribute__((weak)) void suspend_wakeup_init_keymap(void) {}
125 125void suspend_wakeup_init_user(void) {
126void suspend_wakeup_init_user(void) {
127 if (layer_state_is(_GAMEPAD)) { 126 if (layer_state_is(_GAMEPAD)) {
128 layer_off(_GAMEPAD); 127 layer_off(_GAMEPAD);
129 } 128 }
@@ -133,13 +132,11 @@ void suspend_wakeup_init_user(void) {
133 suspend_wakeup_init_keymap(); 132 suspend_wakeup_init_keymap();
134} 133}
135 134
136__attribute__((weak)) void matrix_scan_keymap(void) {}
137
138__attribute__((weak)) void matrix_scan_secret(void) {}
139
140// No global matrix scan code, so just run keymap's matrix 135// No global matrix scan code, so just run keymap's matrix
141// scan function 136// scan function
142void matrix_scan_user(void) { 137__attribute__((weak)) void matrix_scan_keymap(void) {}
138__attribute__((weak)) void matrix_scan_secret(void) {}
139void matrix_scan_user(void) {
143 static bool has_ran_yet; 140 static bool has_ran_yet;
144 if (!has_ran_yet) { 141 if (!has_ran_yet) {
145 has_ran_yet = true; 142 has_ran_yet = true;
@@ -166,11 +163,10 @@ void matrix_scan_user(void) {
166float doom_song[][2] = SONG(E1M1_DOOM); 163float doom_song[][2] = SONG(E1M1_DOOM);
167#endif 164#endif
168 165
169__attribute__((weak)) layer_state_t layer_state_set_keymap(layer_state_t state) { return state; }
170
171// on layer change, no matter where the change was initiated 166// on layer change, no matter where the change was initiated
172// Then runs keymap's layer change check 167// Then runs keymap's layer change check
173layer_state_t layer_state_set_user(layer_state_t state) { 168__attribute__((weak)) layer_state_t layer_state_set_keymap(layer_state_t state) { return state; }
169layer_state_t layer_state_set_user(layer_state_t state) {
174 if (!is_keyboard_master()) { 170 if (!is_keyboard_master()) {
175 return state; 171 return state;
176 } 172 }
@@ -194,10 +190,9 @@ layer_state_t layer_state_set_user(layer_state_t state) {
194 return state; 190 return state;
195} 191}
196 192
197__attribute__((weak)) layer_state_t default_layer_state_set_keymap(layer_state_t state) { return state; }
198
199// Runs state check and changes underglow color and animation 193// Runs state check and changes underglow color and animation
200layer_state_t default_layer_state_set_user(layer_state_t state) { 194__attribute__((weak)) layer_state_t default_layer_state_set_keymap(layer_state_t state) { return state; }
195layer_state_t default_layer_state_set_user(layer_state_t state) {
201 if (!is_keyboard_master()) { 196 if (!is_keyboard_master()) {
202 return state; 197 return state;
203 } 198 }
@@ -212,22 +207,14 @@ layer_state_t default_layer_state_set_user(layer_state_t state) {
212} 207}
213 208
214__attribute__((weak)) void led_set_keymap(uint8_t usb_led) {} 209__attribute__((weak)) void led_set_keymap(uint8_t usb_led) {}
215 210void led_set_user(uint8_t usb_led) { led_set_keymap(usb_led); }
216// Any custom LED code goes here.
217// So far, I only have keyboard specific code,
218// So nothing goes here.
219void led_set_user(uint8_t usb_led) { led_set_keymap(usb_led); }
220 211
221__attribute__((weak)) void eeconfig_init_keymap(void) {} 212__attribute__((weak)) void eeconfig_init_keymap(void) {}
222 213void eeconfig_init_user(void) {
223void eeconfig_init_user(void) {
224 userspace_config.raw = 0; 214 userspace_config.raw = 0;
225 userspace_config.rgb_layer_change = true; 215 userspace_config.rgb_layer_change = true;
226 eeconfig_update_user(userspace_config.raw); 216 eeconfig_update_user(userspace_config.raw);
227 eeconfig_init_keymap(); 217 eeconfig_init_keymap();
228#ifdef VIA_ENABLE
229 via_eeprom_reset();
230#endif
231 keyboard_init(); 218 keyboard_init();
232} 219}
233 220
@@ -237,3 +224,39 @@ bool hasAllBitsInMask(uint8_t value, uint8_t mask) {
237 224
238 return (value & mask) == mask; 225 return (value & mask) == mask;
239} 226}
227
228#ifdef SPLIT_KEYBOARD
229# if defined(AUDIO_ENABLE)
230bool delayed_tasks_run = false;
231# endif
232__attribute__((weak)) void matrix_slave_scan_keymap(void) {}
233void matrix_slave_scan_user(void) {
234# if defined(AUDIO_ENABLE)
235# if !defined(NO_MUSIC_MODE)
236 music_task();
237# endif
238 if (!is_keyboard_master()) {
239 static uint16_t delayed_task_timer = 0;
240 if (!delayed_tasks_run) {
241 if (!delayed_task_timer) {
242 delayed_task_timer = timer_read();
243 } else if (timer_elapsed(delayed_task_timer) > 300) {
244 audio_startup();
245 delayed_tasks_run = true;
246 }
247 }
248 }
249# endif
250# ifdef SEQUENCER_ENABLE
251 sequencer_task();
252# endif
253# ifdef LED_MATRIX_ENABLE
254 led_matrix_task();
255# endif
256# ifdef HAPTIC_ENABLE
257 haptic_task();
258# endif
259
260 matrix_slave_scan_keymap();
261}
262#endif
diff --git a/users/drashna/drashna.h b/users/drashna/drashna.h
index ca849b050..0ae5f779a 100644
--- a/users/drashna/drashna.h
+++ b/users/drashna/drashna.h
@@ -94,6 +94,9 @@ layer_state_t default_layer_state_set_keymap(layer_state_t state);
94void led_set_keymap(uint8_t usb_led); 94void led_set_keymap(uint8_t usb_led);
95void eeconfig_init_keymap(void); 95void eeconfig_init_keymap(void);
96bool hasAllBitsInMask(uint8_t value, uint8_t mask); 96bool hasAllBitsInMask(uint8_t value, uint8_t mask);
97#ifdef SPLIT_KEYBOARD
98void matrix_slave_scan_keymap(void);
99#endif
97 100
98// clang-format off 101// clang-format off
99typedef union { 102typedef union {
@@ -126,7 +129,3 @@ We use custom codes here, so we can substitute the right stuff
126# define KC_D3_3 KC_3 129# define KC_D3_3 KC_3
127# define KC_D3_4 KC_4 130# define KC_D3_4 KC_4
128#endif // TAP_DANCE_ENABLE 131#endif // TAP_DANCE_ENABLE
129
130#if defined(DRASHNA_CUSTOM_TRANSPORT) && defined(POINTING_DEVICE_ENABLE)
131void master_mouse_send(int8_t x, int8_t y);
132#endif
diff --git a/users/drashna/oled_stuff.c b/users/drashna/oled_stuff.c
index 103b1fc7a..0d63c38fa 100644
--- a/users/drashna/oled_stuff.c
+++ b/users/drashna/oled_stuff.c
@@ -18,7 +18,7 @@
18 18
19#ifndef KEYLOGGER_LENGTH 19#ifndef KEYLOGGER_LENGTH
20// # ifdef OLED_DISPLAY_128X64 20// # ifdef OLED_DISPLAY_128X64
21# define KEYLOGGER_LENGTH ((int)(OLED_DISPLAY_HEIGHT / OLED_FONT_WIDTH)) 21# define KEYLOGGER_LENGTH ((uint8_t)(OLED_DISPLAY_HEIGHT / OLED_FONT_WIDTH))
22// # else 22// # else
23// # define KEYLOGGER_LENGTH (uint8_t *(OLED_DISPLAY_WIDTH / OLED_FONT_HEIGHT)) 23// # define KEYLOGGER_LENGTH (uint8_t *(OLED_DISPLAY_WIDTH / OLED_FONT_HEIGHT))
24// # endif 24// # endif
@@ -160,17 +160,21 @@ void render_matrix_scan_rate(void) {
160void render_mod_status(uint8_t modifiers) { 160void render_mod_status(uint8_t modifiers) {
161 static const char PROGMEM mod_status[5][3] = {{0xE8, 0xE9, 0}, {0xE4, 0xE5, 0}, {0xE6, 0xE7, 0}, {0xEA, 0xEB, 0}, {0xEC, 0xED, 0}}; 161 static const char PROGMEM mod_status[5][3] = {{0xE8, 0xE9, 0}, {0xE4, 0xE5, 0}, {0xE6, 0xE7, 0}, {0xEA, 0xEB, 0}, {0xEC, 0xED, 0}};
162 oled_write_P(PSTR(OLED_RENDER_MODS_NAME), false); 162 oled_write_P(PSTR(OLED_RENDER_MODS_NAME), false);
163#if defined(OLED_DISPLAY_128X64)
164 oled_write_P(mod_status[0], (modifiers & MOD_BIT(KC_LSHIFT)));
165 oled_write_P(mod_status[!keymap_config.swap_lctl_lgui ? 3 : 4], (modifiers & MOD_BIT(KC_LGUI)));
166 oled_write_P(mod_status[2], (modifiers & MOD_BIT(KC_LALT)));
167 oled_write_P(mod_status[1], (modifiers & MOD_BIT(KC_LCTL)));
168 oled_write_P(mod_status[1], (modifiers & MOD_BIT(KC_RCTL)));
169 oled_write_P(mod_status[2], (modifiers & MOD_BIT(KC_RALT)));
170 oled_write_P(mod_status[!keymap_config.swap_lctl_lgui ? 3 : 4], (modifiers & MOD_BIT(KC_RGUI)));
171 oled_write_P(mod_status[0], (modifiers & MOD_BIT(KC_RSHIFT)));
172#else
163 oled_write_P(mod_status[0], (modifiers & MOD_MASK_SHIFT)); 173 oled_write_P(mod_status[0], (modifiers & MOD_MASK_SHIFT));
164 oled_write_P(mod_status[!keymap_config.swap_lctl_lgui ? 3 : 4], (modifiers & MOD_MASK_GUI)); 174 oled_write_P(mod_status[!keymap_config.swap_lctl_lgui ? 3 : 4], (modifiers & MOD_MASK_GUI));
165#if !defined(OLED_DISPLAY_128X64)
166 oled_write_P(PSTR(" "), false); 175 oled_write_P(PSTR(" "), false);
167#endif
168 oled_write_P(mod_status[2], (modifiers & MOD_MASK_ALT)); 176 oled_write_P(mod_status[2], (modifiers & MOD_MASK_ALT));
169 oled_write_P(mod_status[1], (modifiers & MOD_MASK_CTRL)); 177 oled_write_P(mod_status[1], (modifiers & MOD_MASK_CTRL));
170
171 render_matrix_scan_rate();
172#if defined(OLED_DISPLAY_128X64)
173 oled_advance_page(true);
174#endif 178#endif
175} 179}
176 180
@@ -279,7 +283,7 @@ void render_user_status(void) {
279#endif 283#endif
280} 284}
281 285
282__attribute__((weak)) void oled_driver_render_logo(void) { 286void oled_driver_render_logo(void) {
283 // clang-format off 287 // clang-format off
284 static const char PROGMEM qmk_logo[] = { 288 static const char PROGMEM qmk_logo[] = {
285 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94, 289 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
@@ -289,75 +293,86 @@ __attribute__((weak)) void oled_driver_render_logo(void) {
289 oled_write_P(qmk_logo, false); 293 oled_write_P(qmk_logo, false);
290} 294}
291 295
292void render_wpm(void) { 296void render_wpm(uint8_t padding) {
293#ifdef WPM_ENABLE 297#ifdef WPM_ENABLE
294 uint8_t n = get_current_wpm(); 298 uint8_t n = get_current_wpm();
295# ifdef OLED_DISPLAY_128X64 299 char wpm_counter[4];
296 char wpm_counter[4];
297 wpm_counter[3] = '\0'; 300 wpm_counter[3] = '\0';
298 wpm_counter[2] = '0' + n % 10; 301 wpm_counter[2] = '0' + n % 10;
299 wpm_counter[1] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; 302 wpm_counter[1] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
300 wpm_counter[0] = n / 10 ? '0' + n / 10 : ' '; 303 wpm_counter[0] = n / 10 ? '0' + n / 10 : ' ';
301# else
302 char wpm_counter[6];
303 wpm_counter[5] = '\0';
304 wpm_counter[4] = '0' + n % 10;
305 wpm_counter[3] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
306 wpm_counter[2] = n / 10 ? '0' + n / 10 : ' ';
307 wpm_counter[1] = ' ';
308 wpm_counter[0] = ' ';
309# endif
310 oled_write_P(PSTR(OLED_RENDER_WPM_COUNTER), false); 304 oled_write_P(PSTR(OLED_RENDER_WPM_COUNTER), false);
305 if (padding) {
306 for (uint8_t n = padding; n > 0; n--) {
307 oled_write_P(PSTR(" "), false);
308 }
309 }
311 oled_write(wpm_counter, false); 310 oled_write(wpm_counter, false);
312#endif 311#endif
313} 312}
314 313
315#if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right) 314#if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right)
316 315extern kb_config_data_t kb_config;
317extern kb_runtime_config_t kb_state; 316void render_pointing_dpi_status(uint8_t padding) {
318void render_pointing_dpi_status(void) { 317 char dpi_status[5];
319 char dpi_status[6]; 318 uint16_t n = kb_config.device_cpi;
320 uint16_t n = kb_state.device_cpi; 319 dpi_status[4] = '\0';
321 dpi_status[5] = '\0'; 320 dpi_status[3] = '0' + n % 10;
322 dpi_status[4] = '0' + n % 10;
323 dpi_status[3] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
324 dpi_status[2] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; 321 dpi_status[2] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
325 dpi_status[1] = n / 10 ? '0' + n / 10 : ' '; 322 dpi_status[1] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
326 dpi_status[0] = ' '; 323 dpi_status[0] = n / 10 ? '0' + n / 10 : ' ';
327 oled_write_P(PSTR(" DPI: "), false); 324 oled_write_P(PSTR("DPI: "), false);
325 if (padding) {
326 for (uint8_t n = padding; n > 0; n--) {
327 oled_write_P(PSTR(" "), false);
328 }
329 }
328 oled_write(dpi_status, false); 330 oled_write(dpi_status, false);
329} 331}
330#endif 332#endif
331 333
332void render_status_secondary(void) { 334__attribute__((weak)) void oled_driver_render_logo_right(void) {
333#if defined(OLED_DISPLAY_128X64) 335#if defined(OLED_DISPLAY_128X64)
334 oled_driver_render_logo(); 336 oled_driver_render_logo();
335#endif
336 /* Show Keyboard Layout */
337 render_default_layer_state(); 337 render_default_layer_state();
338 render_layer_state(); 338 oled_set_cursor(0, 4);
339 render_mod_status(get_mods() | get_oneshot_mods()); 339#else
340#if !defined(OLED_DISPLAY_128X64) && defined(WPM_ENABLE) 340 render_default_layer_state();
341 render_wpm();
342#endif 341#endif
343 // render_keylock_status(host_keyboard_leds());
344} 342}
345 343
346void render_status_main(void) { 344__attribute__((weak)) void oled_driver_render_logo_left(void) {
347#if defined(OLED_DISPLAY_128X64) 345#if defined(OLED_DISPLAY_128X64)
348 oled_driver_render_logo(); 346 oled_driver_render_logo();
349# ifdef DEBUG_MATRIX_SCAN_RATE 347# ifdef DEBUG_MATRIX_SCAN_RATE
350 render_matrix_scan_rate(); 348 render_matrix_scan_rate();
351# elif defined(WPM_ENABLE) 349# elif defined(WPM_ENABLE)
352 render_wpm(); 350 render_wpm(0);
353# endif 351# endif
352 oled_write_P(PSTR(" "), false);
354# if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right) 353# if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right)
355 render_pointing_dpi_status(); 354 render_pointing_dpi_status(1);
356# endif 355# endif
357 oled_write_P(PSTR("\n"), false); 356 oled_set_cursor(0, 4);
358#else 357#else
359 render_default_layer_state(); 358 render_default_layer_state();
360#endif 359#endif
360}
361
362void render_status_secondary(void) {
363 oled_driver_render_logo_right();
364 /* Show Keyboard Layout */
365 render_layer_state();
366 render_mod_status(get_mods() | get_oneshot_mods());
367#if !defined(OLED_DISPLAY_128X64) && defined(WPM_ENABLE)
368 render_wpm(2);
369#endif
370 // render_keylock_status(host_keyboard_leds());
371}
372
373void render_status_main(void) {
374 oled_driver_render_logo_left();
375
361 /* Show Keyboard Layout */ 376 /* Show Keyboard Layout */
362 // render_keylock_status(host_keyboard_leds()); 377 // render_keylock_status(host_keyboard_leds());
363 render_bootmagic_status(); 378 render_bootmagic_status();
diff --git a/users/drashna/oled_stuff.h b/users/drashna/oled_stuff.h
index bba3f39cb..8795684d6 100644
--- a/users/drashna/oled_stuff.h
+++ b/users/drashna/oled_stuff.h
@@ -23,6 +23,19 @@ void oled_driver_render_logo(void);
23bool process_record_user_oled(uint16_t keycode, keyrecord_t *record); 23bool process_record_user_oled(uint16_t keycode, keyrecord_t *record);
24oled_rotation_t oled_init_keymap(oled_rotation_t rotation); 24oled_rotation_t oled_init_keymap(oled_rotation_t rotation);
25extern uint32_t oled_timer; 25extern uint32_t oled_timer;
26void render_keylogger_status(void);
27void render_default_layer_state(void);
28void render_layer_state(void);
29void render_keylock_status(uint8_t led_usb_state);
30void render_matrix_scan_rate(void);
31void render_mod_status(uint8_t modifiers);
32void render_bootmagic_status(void);
33void render_user_status(void);
34void oled_driver_render_logo(void);
35void render_wpm(uint8_t padding);
36void render_pointing_dpi_status(uint8_t padding);
37void oled_driver_render_logo_left(void);
38void oled_driver_render_logo_right(void);
26 39
27#ifdef OLED_DISPLAY_128X64 40#ifdef OLED_DISPLAY_128X64
28# define OLED_RENDER_KEYLOGGER "Keylogger: " 41# define OLED_RENDER_KEYLOGGER "Keylogger: "
diff --git a/users/drashna/post_config.h b/users/drashna/post_config.h
new file mode 100644
index 000000000..7c214b66d
--- /dev/null
+++ b/users/drashna/post_config.h
@@ -0,0 +1,40 @@
1/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#pragma once
18
19// because layouts seem to not be respecting config.h order atm
20#ifdef RGBLIGHT_ENABLE
21# undef RGBLIGHT_ANIMATIONS
22# if defined(__AVR__) && (!defined(__AVR_AT90USB1286__) && !defined(RGBLIGHT_ALL_ANIMATIONS))
23# define RGBLIGHT_EFFECT_BREATHING
24# define RGBLIGHT_EFFECT_SNAKE
25# define RGBLIGHT_EFFECT_KNIGHT
26# else
27# define RGBLIGHT_EFFECT_BREATHING
28# define RGBLIGHT_EFFECT_RAINBOW_MOOD
29# define RGBLIGHT_EFFECT_RAINBOW_SWIRL
30# define RGBLIGHT_EFFECT_SNAKE
31# define RGBLIGHT_EFFECT_KNIGHT
32# if defined(RGBLIGHT_ALL_ANIMATIONS)
33# define RGBLIGHT_EFFECT_CHRISTMAS
34# define RGBLIGHT_EFFECT_STATIC_GRADIENT
35# define RGBLIGHT_EFFECT_RGB_TEST
36# define RGBLIGHT_EFFECT_ALTERNATING
37# endif
38# define RGBLIGHT_EFFECT_TWINKLE
39# endif
40#endif
diff --git a/users/drashna/process_records.c b/users/drashna/process_records.c
index 1e6ecc1d6..f5e6a867a 100644
--- a/users/drashna/process_records.c
+++ b/users/drashna/process_records.c
@@ -19,13 +19,12 @@
19 19
20uint16_t copy_paste_timer; 20uint16_t copy_paste_timer;
21 21
22__attribute__((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; }
23
24__attribute__((weak)) bool process_record_secrets(uint16_t keycode, keyrecord_t *record) { return true; }
25
26// Defines actions tor my global custom keycodes. Defined in drashna.h file 22// Defines actions tor my global custom keycodes. Defined in drashna.h file
27// Then runs the _keymap's record handier if not processed here 23// Then runs the _keymap's record handier if not processed here
28bool process_record_user(uint16_t keycode, keyrecord_t *record) { 24
25__attribute__((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; }
26__attribute__((weak)) bool process_record_secrets(uint16_t keycode, keyrecord_t *record) { return true; }
27bool process_record_user(uint16_t keycode, keyrecord_t *record) {
29 // If console is enabled, it will print the matrix position and status of each key pressed 28 // If console is enabled, it will print the matrix position and status of each key pressed
30#ifdef KEYLOGGER_ENABLE 29#ifdef KEYLOGGER_ENABLE
31 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); 30 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);
@@ -203,3 +202,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
203 } 202 }
204 return true; 203 return true;
205} 204}
205
206__attribute__((weak)) void post_process_record_keymap(uint16_t keycode, keyrecord_t *record) {}
207void post_process_record_user(uint16_t keycode, keyrecord_t *record) { post_process_record_keymap(keycode, record); }
diff --git a/users/drashna/process_records.h b/users/drashna/process_records.h
index 460d41d4d..231480ac5 100644
--- a/users/drashna/process_records.h
+++ b/users/drashna/process_records.h
@@ -51,6 +51,7 @@ enum userspace_custom_keycodes {
51 51
52bool process_record_secrets(uint16_t keycode, keyrecord_t *record); 52bool process_record_secrets(uint16_t keycode, keyrecord_t *record);
53bool process_record_keymap(uint16_t keycode, keyrecord_t *record); 53bool process_record_keymap(uint16_t keycode, keyrecord_t *record);
54void post_process_record_keymap(uint16_t keycode, keyrecord_t *record);
54 55
55#define LOWER MO(_LOWER) 56#define LOWER MO(_LOWER)
56#define RAISE MO(_RAISE) 57#define RAISE MO(_RAISE)
diff --git a/users/drashna/rgb_matrix_stuff.c b/users/drashna/rgb_matrix_stuff.c
index 5adbd8ab1..97811092c 100644
--- a/users/drashna/rgb_matrix_stuff.c
+++ b/users/drashna/rgb_matrix_stuff.c
@@ -20,11 +20,6 @@
20extern led_config_t g_led_config; 20extern led_config_t g_led_config;
21 21
22static uint32_t hypno_timer; 22static uint32_t hypno_timer;
23#if defined(SPLIT_KEYBOARD) || defined(KEYBOARD_ergodox_ez) || defined(KEYBOARD_crkbd)
24# define RGB_MATRIX_REST_MODE RGB_MATRIX_CYCLE_OUT_IN_DUAL
25#else
26# define RGB_MATRIX_REST_MODE RGB_MATRIX_CYCLE_OUT_IN
27#endif
28 23
29void rgb_matrix_layer_helper(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode, uint8_t speed, uint8_t led_type, uint8_t led_min, uint8_t led_max) { 24void rgb_matrix_layer_helper(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode, uint8_t speed, uint8_t led_type, uint8_t led_min, uint8_t led_max) {
30 HSV hsv = {hue, sat, val}; 25 HSV hsv = {hue, sat, val};
diff --git a/users/drashna/rgb_stuff.c b/users/drashna/rgb_stuff.c
index 8a0866539..15108bde0 100644
--- a/users/drashna/rgb_stuff.c
+++ b/users/drashna/rgb_stuff.c
@@ -23,106 +23,19 @@
23bool has_initialized; 23bool has_initialized;
24 24
25void rgblight_sethsv_default_helper(uint8_t index) { rgblight_sethsv_at(rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val(), index); } 25void rgblight_sethsv_default_helper(uint8_t index) { rgblight_sethsv_at(rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val(), index); }
26 26void rgblight_set_hsv_and_mode(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode) {
27# ifdef RGBLIGHT_TWINKLE 27 rgblight_sethsv_noeeprom(hue, sat, val);
28static rgblight_fadeout lights[RGBLED_NUM]; 28 // wait_us(175); // Add a slight delay between color and mode to ensure it's processed correctly
29 29 rgblight_mode_noeeprom(mode);
30/* Handler for fading/twinkling effect */
31void scan_rgblight_fadeout(void) { // Don't effing change this function .... rgblight_sethsv is supppppper intensive
32 bool litup = false;
33
34 for (uint8_t light_index = 0; light_index < RGBLED_NUM; ++light_index) {
35 if (lights[light_index].enabled && sync_timer_elapsed(lights[light_index].timer) > 10) {
36 rgblight_fadeout *light = &lights[light_index];
37 litup = true;
38
39 if (light->life) {
40 light->life -= 1;
41 if (get_highest_layer(layer_state) == 0) {
42 sethsv(light->hue + rand() % 0xF, 255, light->life, (LED_TYPE *)&led[light_index]);
43 }
44 light->timer = sync_timer_read();
45 } else {
46 if (light->enabled && get_highest_layer(layer_state) == 0) {
47 rgblight_sethsv_default_helper(light_index);
48 }
49 litup = light->enabled = false;
50 }
51 }
52 }
53 if (litup && get_highest_layer(layer_state) == 0) {
54 rgblight_set();
55 }
56}
57
58/* Triggers a LED to fade/twinkle.
59 * This function handles the selection of the LED and prepres for it to be used.
60 */
61void start_rgb_light(void) {
62 uint8_t indices[RGBLED_NUM];
63 uint8_t indices_count = 0;
64 uint8_t min_life = 0xFF;
65 uint8_t min_life_index = -1;
66
67 for (uint8_t index = 0; index < RGBLED_NUM; ++index) {
68 if (lights[index].enabled) {
69 if (min_life_index == -1 || lights[index].life < min_life) {
70 min_life = lights[index].life;
71 min_life_index = index;
72 }
73 continue;
74 }
75
76 indices[indices_count] = index;
77 ++indices_count;
78 }
79
80 uint8_t light_index;
81 if (!indices_count) {
82 light_index = min_life_index;
83 } else {
84 light_index = indices[rand() % indices_count];
85 }
86
87 rgblight_fadeout *light = &lights[light_index];
88 light->enabled = true;
89 light->timer = sync_timer_read();
90 light->life = 0xC0 + rand() % 0x40;
91
92 light->hue = rgblight_get_hue() + (rand() % 0xB4) - 0x54;
93
94 rgblight_sethsv_at(light->hue, 255, light->life, light_index);
95} 30}
96# endif
97
98bool process_record_user_rgb_light(uint16_t keycode, keyrecord_t *record) {
99 uint16_t temp_keycode = keycode;
100 // Filter out the actual keycode from MT and LT keys.
101 if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) {
102 temp_keycode &= 0xFF;
103 }
104 31
105 switch (temp_keycode) { 32bool process_record_user_rgb_light(uint16_t keycode, keyrecord_t *record) { return true; }
106# ifdef RGBLIGHT_TWINKLE
107 case KC_A ... KC_SLASH:
108 case KC_F1 ... KC_F12:
109 case KC_INSERT ... KC_UP:
110 case KC_KP_SLASH ... KC_KP_DOT:
111 case KC_F13 ... KC_F24:
112 case KC_AUDIO_MUTE ... KC_MEDIA_REWIND:
113 if (record->event.pressed) {
114 start_rgb_light();
115 }
116 break;
117# endif // RGBLIGHT_TWINKLE
118 }
119 return true;
120}
121 33
122# if defined(RGBLIGHT_STARTUP_ANIMATION) 34# if defined(RGBLIGHT_STARTUP_ANIMATION)
123static bool is_enabled; 35static bool is_enabled;
124static bool is_rgblight_startup; 36static bool is_rgblight_startup;
125static uint8_t old_hue; 37static HSV old_hsv;
38static uint8_t old_mode;
126static uint16_t rgblight_startup_loop_timer; 39static uint16_t rgblight_startup_loop_timer;
127# endif 40# endif
128 41
@@ -130,37 +43,35 @@ void keyboard_post_init_rgb_light(void) {
130# if defined(RGBLIGHT_STARTUP_ANIMATION) 43# if defined(RGBLIGHT_STARTUP_ANIMATION)
131 is_enabled = rgblight_is_enabled(); 44 is_enabled = rgblight_is_enabled();
132 if (userspace_config.rgb_layer_change) { 45 if (userspace_config.rgb_layer_change) {
133 rgblight_enable_noeeprom();
134 }
135 if (rgblight_is_enabled()) {
136 layer_state_set_rgb_light(layer_state); 46 layer_state_set_rgb_light(layer_state);
137 old_hue = rgblight_get_hue();
138 rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
139 is_rgblight_startup = true;
140 } 47 }
48 old_hsv = rgblight_get_hsv();
49 old_mode = rgblight_get_mode();
50 rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
51 is_rgblight_startup = true;
141# endif 52# endif
142 layer_state_set_rgb_light(layer_state); 53 if (userspace_config.rgb_layer_change) {
54 layer_state_set_rgb_light(layer_state);
55 }
143} 56}
144 57
145void matrix_scan_rgb_light(void) { 58void matrix_scan_rgb_light(void) {
146# ifdef RGBLIGHT_TWINKLE
147 scan_rgblight_fadeout();
148# endif // RGBLIGHT_ENABLE
149
150# if defined(RGBLIGHT_STARTUP_ANIMATION) 59# if defined(RGBLIGHT_STARTUP_ANIMATION)
151 if (is_rgblight_startup && is_keyboard_master()) { 60 if (is_rgblight_startup && is_keyboard_master()) {
152 if (sync_timer_elapsed(rgblight_startup_loop_timer) > 10) { 61 if (sync_timer_elapsed(rgblight_startup_loop_timer) > 10) {
153 static uint8_t counter; 62 static uint8_t counter;
154 counter++; 63 counter++;
155 rgblight_sethsv_noeeprom((counter + old_hue) % 255, 255, 255); 64 rgblight_sethsv_noeeprom((counter + old_hsv.h) % 255, 255, 255);
156 rgblight_startup_loop_timer = sync_timer_read(); 65 rgblight_startup_loop_timer = sync_timer_read();
157 if (counter == 255) { 66 if (counter == 255) {
158 is_rgblight_startup = false; 67 is_rgblight_startup = false;
159 if (!is_enabled) {
160 rgblight_disable_noeeprom();
161 }
162 if (userspace_config.rgb_layer_change) { 68 if (userspace_config.rgb_layer_change) {
163 layer_state_set_rgb_light(layer_state); 69 layer_state_set_rgb_light(layer_state);
70 } else {
71 rgblight_set_hsv_and_mode(old_hsv.h, old_hsv.s, old_hsv.v, old_mode);
72 }
73 if (!is_enabled) {
74 rgblight_disable_noeeprom();
164 } 75 }
165 } 76 }
166 } 77 }
@@ -168,12 +79,6 @@ void matrix_scan_rgb_light(void) {
168# endif 79# endif
169} 80}
170 81
171void rgblight_set_hsv_and_mode(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode) {
172 rgblight_sethsv_noeeprom(hue, sat, val);
173 // wait_us(175); // Add a slight delay between color and mode to ensure it's processed correctly
174 rgblight_mode_noeeprom(mode);
175}
176
177layer_state_t layer_state_set_rgb_light(layer_state_t state) { 82layer_state_t layer_state_set_rgb_light(layer_state_t state) {
178# ifdef RGBLIGHT_ENABLE 83# ifdef RGBLIGHT_ENABLE
179 if (userspace_config.rgb_layer_change) { 84 if (userspace_config.rgb_layer_change) {
diff --git a/users/drashna/rgb_stuff.h b/users/drashna/rgb_stuff.h
index 0153adb54..af1acdde7 100644
--- a/users/drashna/rgb_stuff.h
+++ b/users/drashna/rgb_stuff.h
@@ -17,22 +17,9 @@
17#pragma once 17#pragma once
18#include "quantum.h" 18#include "quantum.h"
19 19
20#if defined(RGBLIGHT_TWINKLE)
21typedef struct {
22 bool enabled;
23 uint8_t hue;
24 uint16_t timer;
25 uint8_t life;
26} rgblight_fadeout;
27#endif
28
29bool process_record_user_rgb_light(uint16_t keycode, keyrecord_t *record); 20bool process_record_user_rgb_light(uint16_t keycode, keyrecord_t *record);
30void keyboard_post_init_rgb_light(void); 21void keyboard_post_init_rgb_light(void);
31void matrix_scan_rgb_light(void); 22void matrix_scan_rgb_light(void);
32layer_state_t layer_state_set_rgb_light(layer_state_t state); 23layer_state_t layer_state_set_rgb_light(layer_state_t state);
33layer_state_t default_layer_state_set_rgb_light(layer_state_t state); 24layer_state_t default_layer_state_set_rgb_light(layer_state_t state);
34void rgblight_sethsv_default_helper(uint8_t index); 25void rgblight_sethsv_default_helper(uint8_t index);
35
36#if defined(RGBLIGHT_TWINKLE)
37void scan_rgblight_fadeout(void);
38#endif
diff --git a/users/drashna/rules.mk b/users/drashna/rules.mk
index b93ab1ee6..02a75a7b7 100644
--- a/users/drashna/rules.mk
+++ b/users/drashna/rules.mk
@@ -29,9 +29,6 @@ CUSTOM_RGBLIGHT ?= yes
29ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) 29ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
30 ifeq ($(strip $(CUSTOM_RGBLIGHT)), yes) 30 ifeq ($(strip $(CUSTOM_RGBLIGHT)), yes)
31 SRC += rgb_stuff.c 31 SRC += rgb_stuff.c
32 ifeq ($(strip $(RGBLIGHT_TWINKLE)), yes)
33 OPT_DEFS += -DRGBLIGHT_TWINKLE
34 endif
35 ifeq ($(strip $(RGBLIGHT_NOEEPROM)), yes) 32 ifeq ($(strip $(RGBLIGHT_NOEEPROM)), yes)
36 OPT_DEFS += -DRGBLIGHT_NOEEPROM 33 OPT_DEFS += -DRGBLIGHT_NOEEPROM
37 endif 34 endif
@@ -81,8 +78,12 @@ ifeq ($(strip $(PIMORONI_TRACKBALL_ENABLE)), yes)
81 QUANTUM_LIB_SRC += i2c_master.c 78 QUANTUM_LIB_SRC += i2c_master.c
82endif 79endif
83 80
84ifeq ($(strip $(SPLIT_KEYBOARD)), yes) 81CUSTOM_SPLIT_TRANSPORT_SYNC ?= yes
85 QUANTUM_LIB_SRC += transport_sync.c 82ifeq ($(strip $(CUSTOM_SPLIT_TRANSPORT_SYNC)), yes)
83 ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
84 QUANTUM_LIB_SRC += transport_sync.c
85 OPT_DEFS += -DCUSTOM_SPLIT_TRANSPORT_SYNC
86 endif
86endif 87endif
87 88
88# DEBUG_MATRIX_SCAN_RATE_ENABLE = api 89# DEBUG_MATRIX_SCAN_RATE_ENABLE = api
diff --git a/users/drashna/transport_sync.c b/users/drashna/transport_sync.c
index c3ef2eff5..fdd596c04 100644
--- a/users/drashna/transport_sync.c
+++ b/users/drashna/transport_sync.c
@@ -1,30 +1,44 @@
1#ifdef SPLIT_TRANSACTION_IDS_USER 1/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
2# include "transport_sync.h" 2 *
3# include "transactions.h" 3 * This program is free software: you can redistribute it and/or modify
4# include <string.h> 4 * it under the terms of the GNU General Public License as published by
5 5 * the Free Software Foundation, either version 2 of the License, or
6# ifdef UNICODE_ENABLE 6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "transport_sync.h"
18#include "transactions.h"
19#include <string.h>
20
21#ifdef UNICODE_ENABLE
7extern unicode_config_t unicode_config; 22extern unicode_config_t unicode_config;
8# endif 23#endif
9# ifdef AUDIO_ENABLE 24#ifdef AUDIO_ENABLE
10# include "audio.h" 25# include "audio.h"
11# endif 26extern bool delayed_tasks_run;
12# if defined(POINTING_DEVICE_ENABLE) && defined(KEYBOARD_handwired_tractyl_manuform) 27#endif
28#if defined(POINTING_DEVICE_ENABLE) && defined(KEYBOARD_handwired_tractyl_manuform)
13extern bool tap_toggling; 29extern bool tap_toggling;
14# endif 30#endif
15# ifdef SWAP_HANDS_ENABLE 31#ifdef SWAP_HANDS_ENABLE
16extern bool swap_hands; 32extern bool swap_hands;
17# endif 33#endif
18extern userspace_config_t userspace_config; 34extern userspace_config_t userspace_config;
19 35
20typedef struct { 36__attribute__((aligned(8))) typedef struct {
21 bool oled_on; 37 bool audio_enable;
22 bool audio_enable; 38 bool audio_clicky_enable;
23 bool audio_clicky_enable; 39 bool tap_toggling;
24 bool tap_toggling; 40 bool unicode_mode;
25 bool unicode_mode; 41 bool swap_hands;
26 bool swap_hands;
27 uint8_t reserved :2;
28} user_runtime_config_t; 42} user_runtime_config_t;
29 43
30uint16_t transport_keymap_config = 0; 44uint16_t transport_keymap_config = 0;
@@ -57,58 +71,49 @@ void keyboard_post_init_transport_sync(void) {
57 71
58void user_transport_update(void) { 72void user_transport_update(void) {
59 if (is_keyboard_master()) { 73 if (is_keyboard_master()) {
60# ifdef OLED_DRIVER_ENABLE
61 user_state.oled_on = is_oled_on();
62# endif
63
64 transport_keymap_config = keymap_config.raw; 74 transport_keymap_config = keymap_config.raw;
65 transport_userspace_config = userspace_config.raw; 75 transport_userspace_config = userspace_config.raw;
66# ifdef AUDIO_ENABLE 76#ifdef AUDIO_ENABLE
67 user_state.audio_enable = is_audio_on(); 77 user_state.audio_enable = is_audio_on();
68 user_state.audio_clicky_enable = is_clicky_on(); 78 user_state.audio_clicky_enable = is_clicky_on();
69# endif 79#endif
70# if defined(POINTING_DEVICE_ENABLE) && defined(KEYBOARD_handwired_tractyl_manuform) 80#if defined(POINTING_DEVICE_ENABLE) && defined(KEYBOARD_handwired_tractyl_manuform)
71 user_state.tap_toggling = tap_toggling; 81 user_state.tap_toggling = tap_toggling;
72# endif 82#endif
73# ifdef SWAP_HANDS_ENABLE 83#ifdef SWAP_HANDS_ENABLE
74 user_state.swap_hands = swap_hands; 84 user_state.swap_hands = swap_hands;
75# endif 85#endif
76 86
77 } else { 87 } else {
78# ifdef OLED_DRIVER_ENABLE
79 if (user_state.oled_on) {
80 oled_on();
81 } else {
82 oled_off();
83 }
84# endif
85 keymap_config.raw = transport_keymap_config; 88 keymap_config.raw = transport_keymap_config;
86 userspace_config.raw = transport_userspace_config; 89 userspace_config.raw = transport_userspace_config;
87# ifdef UNICODE_ENABLE 90#ifdef UNICODE_ENABLE
88 unicode_config.input_mode = user_state.unicode_mode; 91 unicode_config.input_mode = user_state.unicode_mode;
89# endif 92#endif
90# ifdef AUDIO_ENABLE 93#ifdef AUDIO_ENABLE
91 if (user_state.audio_enable != is_audio_on()) { 94 if (delayed_tasks_run) {
92 if (user_state.audio_enable) { 95 if (user_state.audio_enable != is_audio_on()) {
93 audio_on(); 96 if (user_state.audio_enable) {
94 } else { 97 audio_on();
95 audio_off(); 98 } else {
99 audio_off();
100 }
96 } 101 }
97 } 102 if (user_state.audio_clicky_enable != is_clicky_on()) {
98 if (user_state.audio_clicky_enable != is_clicky_on()) { 103 if (user_state.audio_clicky_enable) {
99 if (user_state.audio_clicky_enable) { 104 clicky_on();
100 clicky_on(); 105 } else {
101 } else { 106 clicky_off();
102 clicky_off(); 107 }
103 } 108 }
104 } 109 }
105# endif 110#endif
106# if defined(POINTING_DEVICE_ENABLE) && defined(KEYBOARD_handwired_tractyl_manuform) 111#if defined(POINTING_DEVICE_ENABLE) && defined(KEYBOARD_handwired_tractyl_manuform)
107 tap_toggling = user_state.tap_toggling; 112 tap_toggling = user_state.tap_toggling;
108# endif 113#endif
109# ifdef SWAP_HANDS_ENABLE 114#ifdef SWAP_HANDS_ENABLE
110 swap_hands = user_state.swap_hands; 115 swap_hands = user_state.swap_hands;
111# endif 116#endif
112 } 117 }
113} 118}
114 119
@@ -185,4 +190,3 @@ void housekeeping_task_user(void) {
185 // Data sync from master to slave 190 // Data sync from master to slave
186 user_transport_sync(); 191 user_transport_sync();
187} 192}
188#endif