fl16: On sleep pin only turn off backlight
Other low power states should be handled perfectly fine by USB suspend, since this is now fixed in chibios. Signed-off-by: Daniel Schaefer <dhs@frame.work>
This commit is contained in:
parent
1fe412facf
commit
27f917f945
@ -259,26 +259,46 @@ static adc10ksample_t read_adc(void) {
|
||||
* If the host is awake but the keyboard is idle it should enter a low-power state
|
||||
*/
|
||||
bool handle_idle(void) {
|
||||
bool asleep = readPin(SLEEP_GPIO);
|
||||
bool asleep = !readPin(SLEEP_GPIO);
|
||||
static uint8_t prev_asleep = -1;
|
||||
static int host_sleep = 0;
|
||||
/* reduce the scan speed to 10Hz */
|
||||
if (prev_asleep != asleep) {
|
||||
prev_asleep = asleep;
|
||||
if (!asleep) {
|
||||
suspend_power_down_quantum();
|
||||
}
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
if (rgb_matrix_get_suspend_state() != asleep) {
|
||||
rgb_matrix_set_suspend_state(asleep);
|
||||
}
|
||||
#endif
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
if (!is_backlight_enabled() != asleep) {
|
||||
if (asleep) {
|
||||
backlight_disable();
|
||||
} else {
|
||||
suspend_wakeup_init_quantum();
|
||||
}
|
||||
}
|
||||
if (!asleep) {
|
||||
if (timer_elapsed32(host_sleep) < 100) {
|
||||
port_wait_for_interrupt();
|
||||
return true;
|
||||
} else {
|
||||
host_sleep = timer_read32();
|
||||
backlight_enable_old_level();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO: Try this again later, but for now USB suspend should be fine
|
||||
// This seems to cause issues with waking up the host by keypresses
|
||||
// static int host_sleep = 0;
|
||||
// /* reduce the scan speed to 10Hz */
|
||||
// if (prev_asleep != asleep) {
|
||||
// prev_asleep = asleep;
|
||||
// if (!asleep) {
|
||||
// suspend_power_down_quantum();
|
||||
// } else {
|
||||
// suspend_wakeup_init_quantum();
|
||||
// }
|
||||
// }
|
||||
// if (!asleep) {
|
||||
// if (timer_elapsed32(host_sleep) < 100) {
|
||||
// port_wait_for_interrupt();
|
||||
// return true;
|
||||
// } else {
|
||||
// host_sleep = timer_read32();
|
||||
// }
|
||||
// }
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -104,6 +104,14 @@ void backlight_enable(void) {
|
||||
backlight_set(backlight_config.level);
|
||||
}
|
||||
|
||||
void backlight_enable_old_level(void) {
|
||||
if (backlight_config.enable) return; // do nothing if backlight is already on
|
||||
|
||||
eeconfig_update_backlight(backlight_config.raw);
|
||||
dprintf("backlight enable\n");
|
||||
backlight_set(backlight_config.level);
|
||||
}
|
||||
|
||||
/** \brief Disable backlight
|
||||
*
|
||||
* FIXME: needs doc
|
||||
|
@ -49,6 +49,7 @@ _Static_assert(sizeof(backlight_config_t) == sizeof(uint8_t), "Backlight EECONFI
|
||||
void backlight_init(void);
|
||||
void backlight_toggle(void);
|
||||
void backlight_enable(void);
|
||||
void backlight_enable_old_level(void);
|
||||
void backlight_disable(void);
|
||||
bool is_backlight_enabled(void);
|
||||
void backlight_step(void);
|
||||
|
Loading…
Reference in New Issue
Block a user