forked from mirrors/qmk_userspace
Added wireless support; Added Lemokey L3; Added Keychron V1 Max
This commit is contained in:
parent
9539f135d8
commit
4ae5990fcc
31585 changed files with 99327 additions and 1763186 deletions
|
@ -60,6 +60,9 @@ __attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) {
|
|||
// -----End rgb effect includes macros-------
|
||||
// ------------------------------------------
|
||||
|
||||
#if defined(RGB_MATRIX_BRIGHTNESS_TURN_OFF_VAL) && (RGB_MATRIX_BRIGHTNESS_TURN_OFF_VAL >= RGB_MATRIX_MAXIMUM_BRIGHTNESS)
|
||||
# pragma error("RGB_MATRIX_BRIGHTNESS_TURN_OFF_VAL must be less than RGB_MATRIX_MAXIMUM_BRIGHTNESS")
|
||||
#endif
|
||||
// globals
|
||||
rgb_config_t rgb_matrix_config; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr
|
||||
uint32_t g_rgb_timer;
|
||||
|
@ -71,6 +74,9 @@ last_hit_t g_last_hit_tracker;
|
|||
#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
|
||||
|
||||
// internals
|
||||
#ifdef RGB_MATRIX_DRIVER_SHUTDOWN_ENABLE
|
||||
static bool driver_shutdown = false;
|
||||
#endif
|
||||
static bool suspend_state = false;
|
||||
static uint8_t rgb_last_enable = UINT8_MAX;
|
||||
static uint8_t rgb_last_effect = UINT8_MAX;
|
||||
|
@ -78,6 +84,7 @@ static effect_params_t rgb_effect_params = {0, LED_FLAG_ALL, false};
|
|||
static rgb_task_states rgb_task_state = SYNCING;
|
||||
#if RGB_MATRIX_TIMEOUT > 0
|
||||
static uint32_t rgb_anykey_timer;
|
||||
static uint32_t rgb_matrix_timeout = RGB_MATRIX_TIMEOUT;
|
||||
#endif // RGB_MATRIX_TIMEOUT > 0
|
||||
|
||||
// double buffers
|
||||
|
@ -93,6 +100,8 @@ const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT;
|
|||
|
||||
EECONFIG_DEBOUNCE_HELPER(rgb_matrix, EECONFIG_RGB_MATRIX, rgb_matrix_config);
|
||||
|
||||
void rgb_matrix_increase_val_helper(bool write_to_eeprom);
|
||||
|
||||
void eeconfig_update_rgb_matrix(void) {
|
||||
eeconfig_flush_rgb_matrix(true);
|
||||
}
|
||||
|
@ -236,12 +245,22 @@ void rgb_matrix_test(void) {
|
|||
}
|
||||
}
|
||||
|
||||
void rgb_matrix_none_indicators(void) {
|
||||
rgb_matrix_none_indicators_kb();
|
||||
rgb_matrix_none_indicators_user();
|
||||
}
|
||||
|
||||
__attribute__((weak)) void rgb_matrix_none_indicators_kb(void) {}
|
||||
|
||||
__attribute__((weak)) void rgb_matrix_none_indicators_user(void) {}
|
||||
|
||||
static bool rgb_matrix_none(effect_params_t *params) {
|
||||
if (!params->init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
rgb_matrix_set_color_all(0, 0, 0);
|
||||
rgb_matrix_none_indicators();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -355,9 +374,20 @@ static void rgb_task_flush(uint8_t effect) {
|
|||
// update last trackers after the first full render so we can init over several frames
|
||||
rgb_last_effect = effect;
|
||||
rgb_last_enable = rgb_matrix_config.enable;
|
||||
|
||||
#ifdef RGB_MATRIX_DRIVER_SHUTDOWN_ENABLE
|
||||
// exit from shutdown to if neccesary
|
||||
if (driver_shutdown) {
|
||||
rgb_matrix_driver_exit_shutdown();
|
||||
}
|
||||
#endif
|
||||
// update pwm buffers
|
||||
rgb_matrix_update_pwm_buffers();
|
||||
#ifdef RGB_MATRIX_DRIVER_SHUTDOWN_ENABLE
|
||||
// shutdown to if neccesary
|
||||
if (effect == RGB_MATRIX_NONE && !driver_shutdown && rgb_matrix_driver_allow_shutdown()) {
|
||||
rgb_matrix_driver_shutdown();
|
||||
}
|
||||
#endif
|
||||
|
||||
// next task
|
||||
rgb_task_state = SYNCING;
|
||||
|
@ -370,7 +400,7 @@ void rgb_matrix_task(void) {
|
|||
// while suspended and just do a software shutdown. This is a cheap hack for now.
|
||||
bool suspend_backlight = suspend_state ||
|
||||
#if RGB_MATRIX_TIMEOUT > 0
|
||||
(rgb_anykey_timer > (uint32_t)RGB_MATRIX_TIMEOUT) ||
|
||||
(rgb_anykey_timer > rgb_matrix_timeout) ||
|
||||
#endif // RGB_MATRIX_TIMEOUT > 0
|
||||
false;
|
||||
|
||||
|
@ -460,6 +490,9 @@ __attribute__((weak)) bool rgb_matrix_indicators_advanced_user(uint8_t led_min,
|
|||
|
||||
void rgb_matrix_init(void) {
|
||||
rgb_matrix_driver.init();
|
||||
#ifdef RGB_MATRIX_DRIVER_SHUTDOWN_ENABLE
|
||||
driver_shutdown = false;
|
||||
#endif
|
||||
|
||||
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
|
||||
g_last_hit_tracker.count = 0;
|
||||
|
@ -506,6 +539,11 @@ void rgb_matrix_toggle_eeprom_helper(bool write_to_eeprom) {
|
|||
rgb_task_state = STARTING;
|
||||
eeconfig_flag_rgb_matrix(write_to_eeprom);
|
||||
dprintf("rgb matrix toggle [%s]: rgb_matrix_config.enable = %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.enable);
|
||||
#ifdef RGB_MATRIX_BRIGHTNESS_TURN_OFF_VAL
|
||||
while (rgb_matrix_config.enable && rgb_matrix_config.hsv.v < RGB_MATRIX_BRIGHTNESS_TURN_OFF_VAL) {
|
||||
rgb_matrix_increase_val_helper(write_to_eeprom);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
void rgb_matrix_toggle_noeeprom(void) {
|
||||
rgb_matrix_toggle_eeprom_helper(false);
|
||||
|
@ -517,11 +555,21 @@ void rgb_matrix_toggle(void) {
|
|||
void rgb_matrix_enable(void) {
|
||||
rgb_matrix_enable_noeeprom();
|
||||
eeconfig_flag_rgb_matrix(true);
|
||||
#ifdef RGB_MATRIX_BRIGHTNESS_TURN_OFF_VAL
|
||||
while (rgb_matrix_config.hsv.v < RGB_MATRIX_BRIGHTNESS_TURN_OFF_VAL) {
|
||||
rgb_matrix_increase_val_helper(true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void rgb_matrix_enable_noeeprom(void) {
|
||||
if (!rgb_matrix_config.enable) rgb_task_state = STARTING;
|
||||
rgb_matrix_config.enable = 1;
|
||||
#ifdef RGB_MATRIX_BRIGHTNESS_TURN_OFF_VAL
|
||||
while (rgb_matrix_config.hsv.v < RGB_MATRIX_BRIGHTNESS_TURN_OFF_VAL) {
|
||||
rgb_matrix_increase_val_helper(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void rgb_matrix_disable(void) {
|
||||
|
@ -657,6 +705,12 @@ void rgb_matrix_decrease_sat(void) {
|
|||
}
|
||||
|
||||
void rgb_matrix_increase_val_helper(bool write_to_eeprom) {
|
||||
#ifdef RGB_MATRIX_BRIGHTNESS_TURN_OFF_VAL
|
||||
if (!rgb_matrix_config.enable) {
|
||||
rgb_matrix_toggle_eeprom_helper(write_to_eeprom);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, qadd8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP), write_to_eeprom);
|
||||
}
|
||||
void rgb_matrix_increase_val_noeeprom(void) {
|
||||
|
@ -668,6 +722,11 @@ void rgb_matrix_increase_val(void) {
|
|||
|
||||
void rgb_matrix_decrease_val_helper(bool write_to_eeprom) {
|
||||
rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, qsub8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP), write_to_eeprom);
|
||||
#ifdef RGB_MATRIX_BRIGHTNESS_TURN_OFF_VAL
|
||||
if (rgb_matrix_config.enable && rgb_matrix_config.hsv.v <= RGB_MATRIX_BRIGHTNESS_TURN_OFF_VAL) {
|
||||
rgb_matrix_toggle_eeprom_helper(write_to_eeprom);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
void rgb_matrix_decrease_val_noeeprom(void) {
|
||||
rgb_matrix_decrease_val_helper(false);
|
||||
|
@ -729,3 +788,36 @@ void rgb_matrix_set_flags(led_flags_t flags) {
|
|||
void rgb_matrix_set_flags_noeeprom(led_flags_t flags) {
|
||||
rgb_matrix_set_flags_eeprom_helper(flags, false);
|
||||
}
|
||||
|
||||
#if RGB_MATRIX_TIMEOUT > 0
|
||||
void rgb_matrix_disable_timeout_set(uint32_t timeout) {
|
||||
rgb_matrix_timeout = timeout;
|
||||
}
|
||||
void rgb_matrix_disable_time_reset(void) {
|
||||
rgb_anykey_timer = 0;
|
||||
}
|
||||
|
||||
bool rgb_matrix_timeouted(void) {
|
||||
return (rgb_anykey_timer > rgb_matrix_timeout);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef RGB_MATRIX_DRIVER_SHUTDOWN_ENABLE
|
||||
void rgb_matrix_driver_shutdown(void) {
|
||||
rgb_matrix_driver.shutdown();
|
||||
driver_shutdown = true;
|
||||
};
|
||||
|
||||
void rgb_matrix_driver_exit_shutdown(void) {
|
||||
rgb_matrix_driver.exit_shutdown();
|
||||
driver_shutdown = false;
|
||||
};
|
||||
|
||||
bool rgb_matrix_is_driver_shutdown(void) {
|
||||
return driver_shutdown;
|
||||
}
|
||||
|
||||
__attribute__((weak)) bool rgb_matrix_driver_allow_shutdown(void) {
|
||||
return true;
|
||||
};
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue