Skip to content

Commit

Permalink
repeathold_rgb more than just rgb_val
Browse files Browse the repository at this point in the history
  • Loading branch information
plodah committed Aug 23, 2024
1 parent 9a65384 commit 1e25bbc
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 15 deletions.
40 changes: 38 additions & 2 deletions users/plodah/functions/process_record_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,49 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
case RGB_VAD:
rgb_vad_pressed = record->event.pressed;
if (record->event.pressed) {
bri_timer = timer_read();
repeathold_rgb_timer = timer_read();
}
break;
case RGB_VAI:
rgb_vai_pressed = record->event.pressed;
if (record->event.pressed) {
bri_timer = timer_read();
repeathold_rgb_timer = timer_read();
}
break;
case RGB_HUD:
rgb_hud_pressed = record->event.pressed;
if (record->event.pressed) {
repeathold_rgb_timer = timer_read();
}
break;
case RGB_HUI:
rgb_hui_pressed = record->event.pressed;
if (record->event.pressed) {
repeathold_rgb_timer = timer_read();
}
break;
case RGB_SAD:
rgb_sad_pressed = record->event.pressed;
if (record->event.pressed) {
repeathold_rgb_timer = timer_read();
}
break;
case RGB_SAI:
rgb_sai_pressed = record->event.pressed;
if (record->event.pressed) {
repeathold_rgb_timer = timer_read();
}
break;
case RGB_SPD:
rgb_spd_pressed = record->event.pressed;
if (record->event.pressed) {
repeathold_rgb_timer = timer_read();
}
break;
case RGB_SPI:
rgb_spi_pressed = record->event.pressed;
if (record->event.pressed) {
repeathold_rgb_timer = timer_read();
}
break;
# endif // defined(PLODAH_REPEATHOLD_RGB) && defined(RGB_MATRIX_ENABLE)
Expand Down
39 changes: 39 additions & 0 deletions users/plodah/functions/repeathold_rgb.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
bool rgb_vad_pressed = false;
bool rgb_vai_pressed = false;
bool rgb_hud_pressed = false;
bool rgb_hui_pressed = false;
bool rgb_sad_pressed = false;
bool rgb_sai_pressed = false;
bool rgb_spd_pressed = false;
bool rgb_spi_pressed = false;
uint16_t repeathold_rgb_timer;

void repeathold_rgb_check(void){
if(timer_elapsed(repeathold_rgb_timer) > PLODAH_REPEATHOLD_RATE){
if(rgb_vai_pressed){
rgb_matrix_increase_val();
}
if(rgb_vad_pressed){
rgb_matrix_decrease_val();
}
if(rgb_sai_pressed){
rgb_matrix_increase_sat();
}
if(rgb_sad_pressed){
rgb_matrix_decrease_sat();
}
if(rgb_hui_pressed){
rgb_matrix_increase_hue();
}
if(rgb_hud_pressed){
rgb_matrix_decrease_hue();
}
if(rgb_spi_pressed){
rgb_matrix_increase_speed();
}
if(rgb_spd_pressed){
rgb_matrix_decrease_speed();
}
repeathold_rgb_timer = timer_read();
}
}
16 changes: 3 additions & 13 deletions users/plodah/plodah.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
#endif // RGB_MATRIX_ENABLE && PLODAH_DMAC_INDIC_INDEX

#if defined(PLODAH_REPEATHOLD_RGB) && defined(RGB_MATRIX_ENABLE)
bool rgb_vad_pressed = false;
bool rgb_vai_pressed = false;
uint16_t bri_timer;
# include "functions/repeathold_rgb.c"
#endif // defined(PLODAH_REPEATHOLD_RGB) && defined(RGB_MATRIX_ENABLE)

//===================//
Expand Down Expand Up @@ -108,7 +106,7 @@ layer_state_t layer_state_set_user(layer_state_t state) {
//=======================//
// MATRIX SCAN //
//=======================//
#if (defined(PLODAH_ALTTAB_ENHANCEMENTS_ENABLE)) || ( defined(AUTOCORRECT_ENABLE) && defined(RGB_MATRIX_ENABLE) ) || (defined(PLODAH_TYPINGINDICATOR_RGBINDEX))
#if (defined(PLODAH_ALTTAB_ENHANCEMENTS_ENABLE)) || ( defined(AUTOCORRECT_ENABLE) && defined(RGB_MATRIX_ENABLE) ) || (defined(PLODAH_TYPINGINDICATOR_RGBINDEX)) || (defined(PLODAH_REPEATHOLD_RGB) && defined(RGB_MATRIX_ENABLE))
void matrix_scan_user(void) {
# if defined(PLODAH_ALTTAB_ENHANCEMENTS_ENABLE)
plodah_alttab_check();
Expand All @@ -125,15 +123,7 @@ void matrix_scan_user(void) {
}
# endif // defined(DYNAMIC_MACRO_ENABLE) && defined(PLODAH_DYNAMIC_MACRO_TIMEOUT)
# if defined(PLODAH_REPEATHOLD_RGB) && defined(RGB_MATRIX_ENABLE)
if(timer_elapsed(bri_timer) > PLODAH_REPEATHOLD_RATE){
if(rgb_vai_pressed){
rgb_matrix_increase_val();
}
if(rgb_vad_pressed){
rgb_matrix_decrease_val();
}
bri_timer = timer_read();
}
repeathold_rgb_check();
# endif // defined(PLODAH_REPEATHOLD_RGB) && defined(RGB_MATRIX_ENABLE)
}
#endif // (defined(PLODAH_ALTTAB_ENHANCEMENTS_ENABLE)) || ( defined(AUTOCORRECT_ENABLE) && defined(RGB_MATRIX_ENABLE) ) || (defined(PLODAH_TYPINGINDICATOR_RGBINDEX))
Expand Down

0 comments on commit 1e25bbc

Please sign in to comment.