Skip to content

Commit

Permalink
over-egg the autocorrect indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
plodah committed Aug 16, 2024
1 parent ccd5b02 commit 75806c0
Showing 1 changed file with 48 additions and 14 deletions.
62 changes: 48 additions & 14 deletions users/plodah/functions/autocorrect_indicator.c
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();
}
}
}
}

0 comments on commit 75806c0

Please sign in to comment.