skeletyl: use built-in function for rgb timeout
This commit is contained in:
parent
82fe93b8d1
commit
2685b4daeb
2 changed files with 2 additions and 47 deletions
|
@ -15,6 +15,5 @@
|
|||
#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 255
|
||||
#define SPLIT_LAYER_STATE_ENABLE // for layer indicators
|
||||
#define RGB_TRIGGER_ON_KEYDOWN // Triggers RGB keypress events on key down. This makes RGB control feel more responsive. This may cause RGB to not function properly on some boards
|
||||
// rgb timeout; https://gist.github.com/aashreys/01cb34605a290a7cfb94a856bdabc94c
|
||||
#define RGBLIGHT_SLEEP // allows us to use rgblight_suspend() and rgblight_wakeup() in keymap.c
|
||||
#define RGBLIGHT_TIMEOUT 10000 // 10 seconds
|
||||
// rgb timeout; https://gist.github.com/aashreys/01cb34605a290a7cfb94a856bdabc94c?permalink_comment_id=4520204#gistcomment-4520204
|
||||
#define RGB_MATRIX_TIMEOUT 0 // number of milliseconds to wait until rgb automatically turns off
|
||||
|
|
|
@ -162,47 +162,3 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// rgb timeout; https://gist.github.com/aashreys/01cb34605a290a7cfb94a856bdabc94c
|
||||
static uint16_t key_timer; // timer to track the last keyboard activity
|
||||
static void refresh_rgb(void); // refreshes the activity timer and RGB, invoke whenever activity happens
|
||||
static void check_rgb_timeout(void); // checks if enough time has passed for RGB to timeout
|
||||
bool is_rgb_timeout = false; // store if RGB has timed out or not in a boolean
|
||||
|
||||
void refresh_rgb() {
|
||||
key_timer = timer_read(); // store time of last refresh
|
||||
if (is_rgb_timeout) { // only do something if rgb has timed out
|
||||
print("Activity detected, removing timeout\n");
|
||||
is_rgb_timeout = false;
|
||||
rgb_matrix_enable_noeeprom();
|
||||
}
|
||||
}
|
||||
|
||||
void check_rgb_timeout() {
|
||||
if (!is_rgb_timeout && timer_elapsed(key_timer) > RGBLIGHT_TIMEOUT) {
|
||||
rgb_matrix_disable_noeeprom();
|
||||
is_rgb_timeout = true;
|
||||
}
|
||||
}
|
||||
/* Then, call the above functions from QMK's built in post processing functions like so */
|
||||
/* Runs at the end of each scan loop, check if RGB timeout has occured */
|
||||
void housekeeping_task_user(void) {
|
||||
#ifdef RGBLIGHT_TIMEOUT
|
||||
check_rgb_timeout();
|
||||
#endif
|
||||
/* rest of the function code here */
|
||||
}
|
||||
/* Runs after each key press, check if activity occurred */
|
||||
void post_process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
#ifdef RGBLIGHT_TIMEOUT
|
||||
if (record->event.pressed) refresh_rgb();
|
||||
#endif
|
||||
/* rest of the function code here */
|
||||
}
|
||||
/* Runs after each encoder tick, check if activity occurred */
|
||||
void post_encoder_update_user(uint8_t index, bool clockwise) {
|
||||
#ifdef RGBLIGHT_TIMEOUT
|
||||
refresh_rgb();
|
||||
#endif
|
||||
/* rest of the function code here */
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue