-
-
Notifications
You must be signed in to change notification settings - Fork 39.9k
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 all 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,15 @@ 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 * RGBLIGHT_IDLE_MULTIPLIER)) { | ||
rgblight_idle_timedout = true; | ||
rgblight_disable_noeeprom(); | ||
} | ||
#endif | ||
#ifdef RGBLIGHT_EFFECT_BREATHING | ||
else if (rgblight_status.base_mode == RGBLIGHT_MODE_BREATHING) { | ||
// breathing mode | ||
|
@@ -885,6 +902,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 | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -264,6 +264,15 @@ void rgblight_timer_enable(void); | |||
void rgblight_timer_disable(void); | ||||
void rgblight_timer_toggle(void); | ||||
|
||||
// if timeout is set, enable the rgblight idle feature | ||||
#ifdef RGBLIGHT_IDLE_TIMEOUT | ||||
#define RGBLIGHT_IDLE_ENABLE | ||||
#define RGBLIGHT_IDLE_MULTIPLIER 60000 | ||||
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. Maybe something like RGB_IDLE_MULTIPLIER_MILLIS 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. How about https://docs.qmk.fm/#/feature_rgb_matrix?id=additional-configh-options 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. I'm ok with that, is just like to know what the unit of measurement is 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. I'm ... not exactly sure, but the code is called: qmk_firmware/quantum/rgb_matrix.c Line 373 in cd7bc03
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. @XScorpion2 what is the unit in, for 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. Technically it's 1.2s units. No idea why it was coded like that. Never bothered changing it so it made sense. 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. This should be changed to seconds or minutes. Documentation says "ticks" which doesn't really mean anything 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. I just submitted a pr for RGB Matrix to clean up it's idle timeout and change it to seconds: #6480 |
||||
#endif | ||||
|
||||
#include "quantum.h" | ||||
bool process_rgblight(uint16_t keycode, keyrecord_t *record); | ||||
|
||||
#ifdef RGBLIGHT_SPLIT | ||||
#define RGBLIGHT_STATUS_CHANGE_MODE (1<<0) | ||||
#define RGBLIGHT_STATUS_CHANGE_HSVS (1<<1) | ||||
|
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.