forked from qmk/qmk_userspace
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
48 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,64 @@ | ||
bool is_autocorrect_indicator_active = false; | ||
bool autocorrect_indicator_on = false; | ||
uint8_t autocorrect_indicator_count = 255; | ||
uint16_t autocorrect_indicator_timer = 0; | ||
HSV curhsv; | ||
HSV indhsv; | ||
uint8_t useval; | ||
|
||
|
||
#ifndef PLODAH_AUTOCORRECT_INDICATOR_DURATION | ||
# define PLODAH_AUTOCORRECT_INDICATOR_DURATION 600 | ||
# define PLODAH_AUTOCORRECT_INDICATOR_DURATION 200 | ||
#endif //PLODAH_AUTOCORRECT_INDICATOR_DURATION | ||
|
||
#ifndef PLODAH_AUTOCORRECT_INDICATOR_BLINKCOUNT | ||
# define PLODAH_AUTOCORRECT_INDICATOR_BLINKCOUNT 3 | ||
#endif // PLODAH_AUTOCORRECT_INDICATOR_BLINKCOUNT | ||
|
||
#ifndef PLODAH_AUTOCORRECT_INDICATOR_COLOUR | ||
# define PLODAH_AUTOCORRECT_INDICATOR_COLOUR HSV_RED | ||
#endif //PLODAH_AUTOCORRECT_INDICATOR_COLOUR | ||
|
||
void plodah_autocorrect_indicator_start(void) { | ||
if (!is_autocorrect_indicator_active) { | ||
is_autocorrect_indicator_active = true; | ||
HSV curhsv = rgb_matrix_get_hsv(); | ||
HSV indhsv = { PLODAH_AUTOCORRECT_INDICATOR_COLOUR }; | ||
rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_COLOR); | ||
rgb_matrix_sethsv_noeeprom(indhsv.h, indhsv.s, curhsv.v); | ||
#ifndef PLODAH_AUTOCORRECT_INDICATOR_MINVAL | ||
# define PLODAH_AUTOCORRECT_INDICATOR_MINVAL 85 | ||
#endif // PLODAH_AUTOCORRECT_INDICATOR_MINVAL | ||
|
||
void plodah_autocorrect_indicator_on(void){ | ||
HSV indhsv = { PLODAH_AUTOCORRECT_INDICATOR_COLOUR }; | ||
if(PLODAH_AUTOCORRECT_INDICATOR_MINVAL > curhsv.v){ | ||
useval = PLODAH_AUTOCORRECT_INDICATOR_MINVAL; | ||
} | ||
else{ | ||
useval = curhsv.v; | ||
} | ||
autocorrect_indicator_on = true; | ||
rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_COLOR); | ||
rgb_matrix_sethsv_noeeprom(indhsv.s, indhsv.s, useval); | ||
autocorrect_indicator_timer = timer_read(); | ||
} | ||
|
||
void plodah_autocorrect_indicator_off(void){ | ||
autocorrect_indicator_count ++; | ||
autocorrect_indicator_on = false; | ||
rgb_matrix_reload_from_eeprom(); | ||
autocorrect_indicator_timer = timer_read(); | ||
} | ||
|
||
void plodah_autocorrect_indicator_check(void) { | ||
if (is_autocorrect_indicator_active) { | ||
if (timer_elapsed(autocorrect_indicator_timer) > PLODAH_AUTOCORRECT_INDICATOR_DURATION) { | ||
rgb_matrix_reload_from_eeprom(); | ||
is_autocorrect_indicator_active = false; | ||
void plodah_autocorrect_indicator_start(void){ | ||
autocorrect_indicator_count = 0; | ||
if (autocorrect_indicator_count == 0){ | ||
curhsv = rgb_matrix_get_hsv(); | ||
} | ||
} | ||
|
||
void plodah_autocorrect_indicator_check(void){ | ||
if (autocorrect_indicator_count < PLODAH_AUTOCORRECT_INDICATOR_BLINKCOUNT){ | ||
if (timer_elapsed(autocorrect_indicator_timer) > PLODAH_AUTOCORRECT_INDICATOR_DURATION){ | ||
if (autocorrect_indicator_on){ | ||
plodah_autocorrect_indicator_off(); | ||
} | ||
else{ | ||
plodah_autocorrect_indicator_on(); | ||
} | ||
} | ||
} | ||
} |