Skip to content

Commit

Permalink
Further separate autocorrect indicator into sepeate c
Browse files Browse the repository at this point in the history
  • Loading branch information
plodah committed Aug 17, 2024
1 parent 291fcfe commit 58cd0fd
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 66 deletions.
112 changes: 63 additions & 49 deletions users/plodah/functions/autocorrect_indicator.c
Original file line number Diff line number Diff line change
@@ -1,64 +1,78 @@
bool autocorrect_indicator_on = false;
uint8_t autocorrect_indicator_count = 255;
uint16_t autocorrect_indicator_timer = 0;
HSV curhsv;
HSV indhsv;
uint8_t useval;
#if defined(RGB_MATRIX_ENABLE)

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 200
#endif //PLODAH_AUTOCORRECT_INDICATOR_DURATION
#ifndef PLODAH_AUTOCORRECT_INDICATOR_DURATION
# 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_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
#ifndef PLODAH_AUTOCORRECT_INDICATOR_COLOUR
# define PLODAH_AUTOCORRECT_INDICATOR_COLOUR HSV_RED
#endif //PLODAH_AUTOCORRECT_INDICATOR_COLOUR

#ifndef PLODAH_AUTOCORRECT_INDICATOR_MINVAL
# define PLODAH_AUTOCORRECT_INDICATOR_MINVAL 85
#endif // PLODAH_AUTOCORRECT_INDICATOR_MINVAL
#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;
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();
}
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_off(void){
autocorrect_indicator_count ++;
autocorrect_indicator_on = false;
rgb_matrix_reload_from_eeprom();
autocorrect_indicator_timer = timer_read();
}

void plodah_autocorrect_indicator_start(void){
autocorrect_indicator_count = 0;
if (autocorrect_indicator_count == 0){
curhsv = rgb_matrix_get_hsv();
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();
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();
}
}
}
}

#endif // RGB_MATRIX_ENABLE

bool apply_autocorrect(uint8_t backspaces, const char *str, char *typo, char *correct) {
# if defined(RGB_MATRIX_ENABLE)
for (uint8_t i = 0; i < backspaces; ++i) {
tap_code(KC_BSPC);
}
send_string_P(str);
plodah_autocorrect_indicator_start();
# endif // RGB_MATRIX_ENABLE
return false;
}
18 changes: 1 addition & 17 deletions users/plodah/plodah.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
// AUTOCORRECT //
//=======================//
#if defined(AUTOCORRECT_ENABLE)
# if defined(RGB_MATRIX_ENABLE)
# include "functions/autocorrect_indicator.c"
# endif // RGB_MATRIX_ENABLE
# include "functions/autocorrect_indicator.c"
#endif // AUTOCORRECT_ENABLE

//====================//
Expand Down Expand Up @@ -133,20 +131,6 @@ void matrix_scan_user(void) {
}
#endif // CAPS_WORD_ENABLE

//=======================//
// AUTOCORRECT //
//=======================//
#if defined(AUTOCORRECT_ENABLE) && defined(RGB_MATRIX_ENABLE)
bool apply_autocorrect(uint8_t backspaces, const char *str, char *typo, char *correct) {
for (uint8_t i = 0; i < backspaces; ++i) {
tap_code(KC_BSPC);
}
send_string_P(str);
plodah_autocorrect_indicator_start();
return false;
}
#endif // AUTOCORRECT_ENABLE && RGB_MATRIX_ENABLE

//==========================//
// DYNAMIC MACROS //
//==========================//
Expand Down

0 comments on commit 58cd0fd

Please sign in to comment.