-
-
Notifications
You must be signed in to change notification settings - Fork 39.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rgblight idle timeout feature #6450
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,12 +93,16 @@ bool is_rgblight_initialized = false; | |
animation_status_t animation_status = {}; | ||
#endif | ||
|
||
#ifdef RGBLIGHT_IDLE_ENABLE | ||
bool rgblight_idle_timedout = false; | ||
uint32_t rgblight_idle_timer; | ||
#endif | ||
|
||
#ifndef LED_ARRAY | ||
LED_TYPE led[RGBLED_NUM]; | ||
#define LED_ARRAY led | ||
#endif | ||
|
||
|
||
static uint8_t clipping_start_pos = 0; | ||
static uint8_t clipping_num_leds = RGBLED_NUM; | ||
static uint8_t effect_start_pos = 0; | ||
|
@@ -220,6 +224,10 @@ void rgblight_init(void) { | |
rgblight_mode_noeeprom(rgblight_config.mode); | ||
} | ||
|
||
#ifdef RGBLIGHT_IDLE_ENABLE | ||
rgblight_idle_timer = timer_read32(); | ||
#endif | ||
|
||
is_rgblight_initialized = true; | ||
|
||
} | ||
|
@@ -797,6 +805,16 @@ void rgblight_task(void) { | |
// static light mode, do nothing here | ||
if ( 1 == 0 ) { //dummy | ||
} | ||
#ifdef RGBLIGHT_IDLE_ENABLE | ||
// exit early if we are timedout | ||
else if (rgblight_idle_timedout) { | ||
return; | ||
} else if (timer_elapsed32(rgblight_idle_timer) >= (RGBLIGHT_IDLE_TIMEOUT * 60000)) { | ||
drashna marked this conversation as resolved.
Show resolved
Hide resolved
|
||
rgblight_idle_timedout = true; | ||
rgblight_disable_noeeprom(); | ||
rgblight_idle_timer = timer_read32(); | ||
yanfali marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
#endif | ||
#ifdef RGBLIGHT_EFFECT_BREATHING | ||
else if (rgblight_status.base_mode == RGBLIGHT_MODE_BREATHING) { | ||
// breathing mode | ||
|
@@ -885,6 +903,21 @@ void rgblight_task(void) { | |
|
||
#endif /* RGBLIGHT_USE_TIMER */ | ||
|
||
#ifdef RGBLIGHT_USE_PROCESS | ||
bool process_rgblight(uint16_t keycode, keyrecord_t *record) { | ||
#ifdef RGBLIGHT_IDLE_ENABLE | ||
if (record->event.pressed) { | ||
if (rgblight_idle_timedout) { | ||
rgblight_idle_timedout = false; | ||
rgblight_enable_noeeprom(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't change the enable/disable state, as a user could have previously disabled the rgblight, and this would turn it back on against the users wishes. Use a similar pattern to what rgb matrix uses to turn off the LEDs without changing user state. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense. I will look at the rgb matrix code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the rgb_matrix code uses a g_suspend_state boolean locally to determine if it's suspended or not, and renders based on that. |
||
} | ||
rgblight_idle_timer = timer_read32(); | ||
} | ||
#endif | ||
return true; | ||
} | ||
#endif | ||
|
||
// Effects | ||
#ifdef RGBLIGHT_EFFECT_BREATHING | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need for multiple defines for this feature as you can just used
#if RGBLIGHT_IDLE_TIMEOUT > 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. Should I just use the rgb matrix variable or still use a separate one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep the RGB Light define for this feature separate as there has been interest in running both RGB Light & Matrix at the same time.