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
|
@ -58,6 +58,9 @@ const led_point_t k_led_matrix_center = LED_MATRIX_CENTER;
|
|||
// -----End led effect includes macros-------
|
||||
// ------------------------------------------
|
||||
|
||||
#if defined(LED_MATRIX_BRIGHTNESS_TURN_OFF_VAL) && (LED_MATRIX_BRIGHTNESS_TURN_OFF_VAL >= LED_MATRIX_MAXIMUM_BRIGHTNESS)
|
||||
# pragma error("LED_MATRIX_BRIGHTNESS_TURN_OFF_VAL must be less than LED_MATRIX_MAXIMUM_BRIGHTNESS")
|
||||
#endif
|
||||
// globals
|
||||
led_eeconfig_t led_matrix_eeconfig; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr
|
||||
uint32_t g_led_timer;
|
||||
|
@ -69,6 +72,9 @@ last_hit_t g_last_hit_tracker;
|
|||
#endif // LED_MATRIX_KEYREACTIVE_ENABLED
|
||||
|
||||
// internals
|
||||
#ifdef LED_MATRIX_DRIVER_SHUTDOWN_ENABLE
|
||||
static bool driver_shutdown = false;
|
||||
#endif
|
||||
static bool suspend_state = false;
|
||||
static uint8_t led_last_enable = UINT8_MAX;
|
||||
static uint8_t led_last_effect = UINT8_MAX;
|
||||
|
@ -76,6 +82,7 @@ static effect_params_t led_effect_params = {0, LED_FLAG_ALL, false};
|
|||
static led_task_states led_task_state = SYNCING;
|
||||
#if LED_MATRIX_TIMEOUT > 0
|
||||
static uint32_t led_anykey_timer;
|
||||
static uint32_t led_matrix_timeout = LED_MATRIX_TIMEOUT;
|
||||
#endif // LED_MATRIX_TIMEOUT > 0
|
||||
|
||||
// double buffers
|
||||
|
@ -91,6 +98,8 @@ const uint8_t k_led_matrix_split[2] = LED_MATRIX_SPLIT;
|
|||
|
||||
EECONFIG_DEBOUNCE_HELPER(led_matrix, EECONFIG_LED_MATRIX, led_matrix_eeconfig);
|
||||
|
||||
void led_matrix_increase_val_helper(bool write_to_eeprom);
|
||||
|
||||
void eeconfig_update_led_matrix(void) {
|
||||
eeconfig_flush_led_matrix(true);
|
||||
}
|
||||
|
@ -198,12 +207,22 @@ void process_led_matrix(uint8_t row, uint8_t col, bool pressed) {
|
|||
#endif // defined(LED_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_LED_MATRIX_TYPING_HEATMAP)
|
||||
}
|
||||
|
||||
void led_matrix_none_indicators(void) {
|
||||
led_matrix_none_indicators_kb();
|
||||
led_matrix_none_indicators_user();
|
||||
}
|
||||
|
||||
__attribute__((weak)) void led_matrix_none_indicators_kb(void) {}
|
||||
|
||||
__attribute__((weak)) void led_matrix_none_indicators_user(void) {}
|
||||
|
||||
static bool led_matrix_none(effect_params_t *params) {
|
||||
if (!params->init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
led_matrix_set_value_all(0);
|
||||
led_matrix_none_indicators();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -314,10 +333,23 @@ static void led_task_flush(uint8_t effect) {
|
|||
// update last trackers after the first full render so we can init over several frames
|
||||
led_last_effect = effect;
|
||||
led_last_enable = led_matrix_eeconfig.enable;
|
||||
#ifdef LED_MATRIX_DRIVER_SHUTDOWN_ENABLE
|
||||
// exit from shutdown to if neccesary
|
||||
if (driver_shutdown) {
|
||||
led_matrix_driver_exit_shutdown();
|
||||
}
|
||||
#endif
|
||||
|
||||
// update pwm buffers
|
||||
led_matrix_update_pwm_buffers();
|
||||
|
||||
#ifdef LED_MATRIX_DRIVER_SHUTDOWN_ENABLE
|
||||
// shutdown if neccesary
|
||||
if (effect == LED_MATRIX_NONE && !driver_shutdown && led_matrix_driver_allow_shutdown()) {
|
||||
led_matrix_driver_shutdown();
|
||||
}
|
||||
#endif
|
||||
|
||||
// next task
|
||||
led_task_state = SYNCING;
|
||||
}
|
||||
|
@ -329,8 +361,8 @@ void led_matrix_task(void) {
|
|||
// while suspended and just do a software shutdown. This is a cheap hack for now.
|
||||
bool suspend_backlight = suspend_state ||
|
||||
#if LED_MATRIX_TIMEOUT > 0
|
||||
(led_anykey_timer > (uint32_t)LED_MATRIX_TIMEOUT) ||
|
||||
#endif // LED_MATRIX_TIMEOUT > 0
|
||||
(led_anykey_timer > led_matrix_timeout) ||
|
||||
#endif // led_matrix_timeout > 0
|
||||
false;
|
||||
|
||||
uint8_t effect = suspend_backlight || !led_matrix_eeconfig.enable ? 0 : led_matrix_eeconfig.mode;
|
||||
|
@ -465,6 +497,11 @@ void led_matrix_toggle_eeprom_helper(bool write_to_eeprom) {
|
|||
led_task_state = STARTING;
|
||||
eeconfig_flag_led_matrix(write_to_eeprom);
|
||||
dprintf("led matrix toggle [%s]: led_matrix_eeconfig.enable = %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.enable);
|
||||
#ifdef LED_MATRIX_BRIGHTNESS_TURN_OFF_VAL
|
||||
while (led_matrix_eeconfig.enable && led_matrix_eeconfig.val <= LED_MATRIX_BRIGHTNESS_TURN_OFF_VAL) {
|
||||
led_matrix_increase_val_helper(write_to_eeprom);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
void led_matrix_toggle_noeeprom(void) {
|
||||
led_matrix_toggle_eeprom_helper(false);
|
||||
|
@ -476,11 +513,21 @@ void led_matrix_toggle(void) {
|
|||
void led_matrix_enable(void) {
|
||||
led_matrix_enable_noeeprom();
|
||||
eeconfig_flag_led_matrix(true);
|
||||
#ifdef LED_MATRIX_BRIGHTNESS_TURN_OFF_VAL
|
||||
while (led_matrix_eeconfig.val <= LED_MATRIX_BRIGHTNESS_TURN_OFF_VAL) {
|
||||
led_matrix_increase_val_helper(true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void led_matrix_enable_noeeprom(void) {
|
||||
if (!led_matrix_eeconfig.enable) led_task_state = STARTING;
|
||||
led_matrix_eeconfig.enable = 1;
|
||||
#ifdef LED_MATRIX_BRIGHTNESS_TURN_OFF_VAL
|
||||
while (led_matrix_eeconfig.val <= LED_MATRIX_BRIGHTNESS_TURN_OFF_VAL) {
|
||||
led_matrix_increase_val_helper(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void led_matrix_disable(void) {
|
||||
|
@ -565,6 +612,12 @@ uint8_t led_matrix_get_val(void) {
|
|||
}
|
||||
|
||||
void led_matrix_increase_val_helper(bool write_to_eeprom) {
|
||||
#ifdef LED_MATRIX_BRIGHTNESS_TURN_OFF_VAL
|
||||
if (!led_matrix_eeconfig.enable) {
|
||||
led_matrix_toggle_eeprom_helper(write_to_eeprom);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
led_matrix_set_val_eeprom_helper(qadd8(led_matrix_eeconfig.val, LED_MATRIX_VAL_STEP), write_to_eeprom);
|
||||
}
|
||||
void led_matrix_increase_val_noeeprom(void) {
|
||||
|
@ -576,6 +629,11 @@ void led_matrix_increase_val(void) {
|
|||
|
||||
void led_matrix_decrease_val_helper(bool write_to_eeprom) {
|
||||
led_matrix_set_val_eeprom_helper(qsub8(led_matrix_eeconfig.val, LED_MATRIX_VAL_STEP), write_to_eeprom);
|
||||
#ifdef LED_MATRIX_BRIGHTNESS_TURN_OFF_VAL
|
||||
if (led_matrix_eeconfig.enable && led_matrix_eeconfig.val <= LED_MATRIX_BRIGHTNESS_TURN_OFF_VAL) {
|
||||
led_matrix_toggle_eeprom_helper(write_to_eeprom);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
void led_matrix_decrease_val_noeeprom(void) {
|
||||
led_matrix_decrease_val_helper(false);
|
||||
|
@ -637,3 +695,36 @@ void led_matrix_set_flags(led_flags_t flags) {
|
|||
void led_matrix_set_flags_noeeprom(led_flags_t flags) {
|
||||
led_matrix_set_flags_eeprom_helper(flags, false);
|
||||
}
|
||||
|
||||
#if LED_MATRIX_TIMEOUT > 0
|
||||
void led_matrix_disable_timeout_set(uint32_t timeout) {
|
||||
led_matrix_timeout = timeout;
|
||||
}
|
||||
void led_matrix_disable_time_reset(void) {
|
||||
led_anykey_timer = 0;
|
||||
}
|
||||
|
||||
bool led_matrix_timeouted(void) {
|
||||
return led_anykey_timer > led_matrix_timeout;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LED_MATRIX_DRIVER_SHUTDOWN_ENABLE
|
||||
void led_matrix_driver_shutdown(void) {
|
||||
led_matrix_driver.shutdown();
|
||||
driver_shutdown = true;
|
||||
};
|
||||
|
||||
void led_matrix_driver_exit_shutdown(void) {
|
||||
led_matrix_driver.exit_shutdown();
|
||||
driver_shutdown = false;
|
||||
};
|
||||
|
||||
bool led_matrix_is_driver_shutdown(void) {
|
||||
return driver_shutdown;
|
||||
}
|
||||
|
||||
__attribute__((weak)) bool led_matrix_driver_allow_shutdown(void) {
|
||||
return true;
|
||||
};
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue