[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
This commit is contained in:
parent
da1c011afc
commit
58a5030661
42 changed files with 936 additions and 521 deletions
|
@ -23,106 +23,19 @@
|
|||
bool has_initialized;
|
||||
|
||||
void rgblight_sethsv_default_helper(uint8_t index) { rgblight_sethsv_at(rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val(), index); }
|
||||
|
||||
# ifdef RGBLIGHT_TWINKLE
|
||||
static rgblight_fadeout lights[RGBLED_NUM];
|
||||
|
||||
/* Handler for fading/twinkling effect */
|
||||
void scan_rgblight_fadeout(void) { // Don't effing change this function .... rgblight_sethsv is supppppper intensive
|
||||
bool litup = false;
|
||||
|
||||
for (uint8_t light_index = 0; light_index < RGBLED_NUM; ++light_index) {
|
||||
if (lights[light_index].enabled && sync_timer_elapsed(lights[light_index].timer) > 10) {
|
||||
rgblight_fadeout *light = &lights[light_index];
|
||||
litup = true;
|
||||
|
||||
if (light->life) {
|
||||
light->life -= 1;
|
||||
if (get_highest_layer(layer_state) == 0) {
|
||||
sethsv(light->hue + rand() % 0xF, 255, light->life, (LED_TYPE *)&led[light_index]);
|
||||
}
|
||||
light->timer = sync_timer_read();
|
||||
} else {
|
||||
if (light->enabled && get_highest_layer(layer_state) == 0) {
|
||||
rgblight_sethsv_default_helper(light_index);
|
||||
}
|
||||
litup = light->enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (litup && get_highest_layer(layer_state) == 0) {
|
||||
rgblight_set();
|
||||
}
|
||||
void rgblight_set_hsv_and_mode(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode) {
|
||||
rgblight_sethsv_noeeprom(hue, sat, val);
|
||||
// wait_us(175); // Add a slight delay between color and mode to ensure it's processed correctly
|
||||
rgblight_mode_noeeprom(mode);
|
||||
}
|
||||
|
||||
/* Triggers a LED to fade/twinkle.
|
||||
* This function handles the selection of the LED and prepres for it to be used.
|
||||
*/
|
||||
void start_rgb_light(void) {
|
||||
uint8_t indices[RGBLED_NUM];
|
||||
uint8_t indices_count = 0;
|
||||
uint8_t min_life = 0xFF;
|
||||
uint8_t min_life_index = -1;
|
||||
|
||||
for (uint8_t index = 0; index < RGBLED_NUM; ++index) {
|
||||
if (lights[index].enabled) {
|
||||
if (min_life_index == -1 || lights[index].life < min_life) {
|
||||
min_life = lights[index].life;
|
||||
min_life_index = index;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
indices[indices_count] = index;
|
||||
++indices_count;
|
||||
}
|
||||
|
||||
uint8_t light_index;
|
||||
if (!indices_count) {
|
||||
light_index = min_life_index;
|
||||
} else {
|
||||
light_index = indices[rand() % indices_count];
|
||||
}
|
||||
|
||||
rgblight_fadeout *light = &lights[light_index];
|
||||
light->enabled = true;
|
||||
light->timer = sync_timer_read();
|
||||
light->life = 0xC0 + rand() % 0x40;
|
||||
|
||||
light->hue = rgblight_get_hue() + (rand() % 0xB4) - 0x54;
|
||||
|
||||
rgblight_sethsv_at(light->hue, 255, light->life, light_index);
|
||||
}
|
||||
# endif
|
||||
|
||||
bool process_record_user_rgb_light(uint16_t keycode, keyrecord_t *record) {
|
||||
uint16_t temp_keycode = keycode;
|
||||
// Filter out the actual keycode from MT and LT keys.
|
||||
if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) {
|
||||
temp_keycode &= 0xFF;
|
||||
}
|
||||
|
||||
switch (temp_keycode) {
|
||||
# ifdef RGBLIGHT_TWINKLE
|
||||
case KC_A ... KC_SLASH:
|
||||
case KC_F1 ... KC_F12:
|
||||
case KC_INSERT ... KC_UP:
|
||||
case KC_KP_SLASH ... KC_KP_DOT:
|
||||
case KC_F13 ... KC_F24:
|
||||
case KC_AUDIO_MUTE ... KC_MEDIA_REWIND:
|
||||
if (record->event.pressed) {
|
||||
start_rgb_light();
|
||||
}
|
||||
break;
|
||||
# endif // RGBLIGHT_TWINKLE
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool process_record_user_rgb_light(uint16_t keycode, keyrecord_t *record) { return true; }
|
||||
|
||||
# if defined(RGBLIGHT_STARTUP_ANIMATION)
|
||||
static bool is_enabled;
|
||||
static bool is_rgblight_startup;
|
||||
static uint8_t old_hue;
|
||||
static HSV old_hsv;
|
||||
static uint8_t old_mode;
|
||||
static uint16_t rgblight_startup_loop_timer;
|
||||
# endif
|
||||
|
||||
|
@ -130,37 +43,35 @@ void keyboard_post_init_rgb_light(void) {
|
|||
# if defined(RGBLIGHT_STARTUP_ANIMATION)
|
||||
is_enabled = rgblight_is_enabled();
|
||||
if (userspace_config.rgb_layer_change) {
|
||||
rgblight_enable_noeeprom();
|
||||
}
|
||||
if (rgblight_is_enabled()) {
|
||||
layer_state_set_rgb_light(layer_state);
|
||||
old_hue = rgblight_get_hue();
|
||||
rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
|
||||
is_rgblight_startup = true;
|
||||
}
|
||||
old_hsv = rgblight_get_hsv();
|
||||
old_mode = rgblight_get_mode();
|
||||
rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
|
||||
is_rgblight_startup = true;
|
||||
# endif
|
||||
layer_state_set_rgb_light(layer_state);
|
||||
if (userspace_config.rgb_layer_change) {
|
||||
layer_state_set_rgb_light(layer_state);
|
||||
}
|
||||
}
|
||||
|
||||
void matrix_scan_rgb_light(void) {
|
||||
# ifdef RGBLIGHT_TWINKLE
|
||||
scan_rgblight_fadeout();
|
||||
# endif // RGBLIGHT_ENABLE
|
||||
|
||||
# if defined(RGBLIGHT_STARTUP_ANIMATION)
|
||||
if (is_rgblight_startup && is_keyboard_master()) {
|
||||
if (sync_timer_elapsed(rgblight_startup_loop_timer) > 10) {
|
||||
static uint8_t counter;
|
||||
counter++;
|
||||
rgblight_sethsv_noeeprom((counter + old_hue) % 255, 255, 255);
|
||||
rgblight_sethsv_noeeprom((counter + old_hsv.h) % 255, 255, 255);
|
||||
rgblight_startup_loop_timer = sync_timer_read();
|
||||
if (counter == 255) {
|
||||
is_rgblight_startup = false;
|
||||
if (!is_enabled) {
|
||||
rgblight_disable_noeeprom();
|
||||
}
|
||||
if (userspace_config.rgb_layer_change) {
|
||||
layer_state_set_rgb_light(layer_state);
|
||||
} else {
|
||||
rgblight_set_hsv_and_mode(old_hsv.h, old_hsv.s, old_hsv.v, old_mode);
|
||||
}
|
||||
if (!is_enabled) {
|
||||
rgblight_disable_noeeprom();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -168,12 +79,6 @@ void matrix_scan_rgb_light(void) {
|
|||
# endif
|
||||
}
|
||||
|
||||
void rgblight_set_hsv_and_mode(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode) {
|
||||
rgblight_sethsv_noeeprom(hue, sat, val);
|
||||
// wait_us(175); // Add a slight delay between color and mode to ensure it's processed correctly
|
||||
rgblight_mode_noeeprom(mode);
|
||||
}
|
||||
|
||||
layer_state_t layer_state_set_rgb_light(layer_state_t state) {
|
||||
# ifdef RGBLIGHT_ENABLE
|
||||
if (userspace_config.rgb_layer_change) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue