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.
Move RGB query guff out of process_record
- Loading branch information
Showing
2 changed files
with
100 additions
and
39 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
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,12 +1,99 @@ | ||
#pragma once | ||
|
||
HSV plodah_rgblimit(HSV currenthsv, HSV targethsv, uint8_t minval){ | ||
HSV output = targethsv; | ||
if(minval > currenthsv.v){ | ||
output.v = minval; | ||
} | ||
else if(targethsv.v > currenthsv.v ){ | ||
output.v = currenthsv.v; | ||
} | ||
return output; | ||
#ifdef RGB_MATRIX_ENABLE | ||
HSV plodah_rgblimit(HSV currenthsv, HSV targethsv, uint8_t minval){ | ||
HSV output = targethsv; | ||
if(minval > currenthsv.v){ | ||
output.v = minval; | ||
} | ||
else if(targethsv.v > currenthsv.v ){ | ||
output.v = currenthsv.v; | ||
} | ||
return output; | ||
} | ||
#endif // RGB_MATRIX_ENABLE | ||
|
||
char* rgbQuery(void){ | ||
//may take 80 bytes more than sending string directly | ||
char * str; | ||
str = malloc(sizeof(char)*50); | ||
#ifdef RGB_MATRIX_ENABLE | ||
strcpy (str, "\\ RGB_MATRIX:"); | ||
strcat (str, get_u8_str(rgb_matrix_get_mode(), '0')); | ||
strcat (str, " H:"); | ||
strcat (str, get_u8_str(rgb_matrix_get_hue(), '0')); | ||
strcat (str, " S:"); | ||
strcat (str, get_u8_str(rgb_matrix_get_sat(), '0')); | ||
strcat (str, " V:"); | ||
strcat (str, get_u8_str(rgb_matrix_get_val(), '0')); | ||
strcat (str, " SP:"); | ||
strcat (str, get_u8_str(rgb_matrix_get_speed(), '0')); | ||
strcat (str, " \n"); | ||
#endif // RGB_MATRIX_ENABLE | ||
#ifdef RGBLIGHT_ENABLE | ||
strcpy (str, "\\ RGBLIGHT:"); | ||
strcat (str, get_u8_str(rgblight_get_mode(), '0')); | ||
strcat (str, " H:"); | ||
strcat (str, get_u8_str(rgblight_get_hue(), '0')); | ||
strcat (str, " S:"); | ||
strcat (str, get_u8_str(rgblight_get_sat(), '0')); | ||
strcat (str, " V:"); | ||
strcat (str, get_u8_str(rgblight_get_val(), '0')); | ||
strcat (str, " SP:"); | ||
strcat (str, get_u8_str(rgblight_get_speed(), '0')); | ||
strcat (str, " \n"); | ||
#endif // RGBLIGHT_ENABLE | ||
#if ( ! (defined RGB_MATRIX_ENABLE ) || ( defined RGBLIGHT_ENABLE ) ) | ||
strcpy (str, "\\ No RGB! \n"); | ||
#endif // NO RGB_MATRIX_ENABLE OR RGBLIGHT_ENABLE | ||
return str; | ||
} | ||
|
||
char * rgbQuerySmert(void) | ||
{ | ||
char * str; | ||
str = malloc(sizeof(char)*50); | ||
#ifdef RGB_MATRIX_ENABLE | ||
snprintf (str, 50, "\\ RGB_MATRIX:%d H:%d S:%d V:%d SP:%d \n", rgb_matrix_get_mode(), rgb_matrix_get_hue(), rgb_matrix_get_sat(), rgb_matrix_get_val(), rgb_matrix_get_speed()); | ||
#endif // RGB_MATRIX_ENABLE | ||
#ifdef RGBLIGHT_ENABLE | ||
snprintf (str, 50, "\\ RGBLIGHT:%d H:%d S:%d V:%d SP:%d \n", rgblight_get_mode(), rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val(), rgblight_get_speed()); | ||
#endif // RGBLIGHT_ENABLE | ||
#if ( ! (defined RGB_MATRIX_ENABLE ) || ( defined RGBLIGHT_ENABLE ) ) | ||
strcpy (str, "\\ No RGB! \n"); | ||
#endif // NO RGB_MATRIX_ENABLE OR RGBLIGHT_ENABLE | ||
return str; | ||
} | ||
|
||
void rgbQuerySs(void) | ||
{ | ||
#ifdef RGB_MATRIX_ENABLE | ||
send_string_with_delay ( "\\ RGB_MATRIX:", TAP_CODE_DELAY ); | ||
send_string_with_delay ( get_u8_str(rgb_matrix_get_mode(),'0'), TAP_CODE_DELAY ); | ||
send_string_with_delay ( " H:", TAP_CODE_DELAY ); | ||
send_string_with_delay ( get_u8_str(rgb_matrix_get_hue(),'0'), TAP_CODE_DELAY ); | ||
send_string_with_delay ( " S:", TAP_CODE_DELAY ); | ||
send_string_with_delay ( get_u8_str(rgb_matrix_get_sat(),'0'), TAP_CODE_DELAY ); | ||
send_string_with_delay ( " V:", TAP_CODE_DELAY ); | ||
send_string_with_delay ( get_u8_str(rgb_matrix_get_val(),'0'), TAP_CODE_DELAY ); | ||
send_string_with_delay ( " SP:", TAP_CODE_DELAY ); | ||
send_string_with_delay ( get_u8_str(rgb_matrix_get_speed(),'0'), TAP_CODE_DELAY ); | ||
send_string_with_delay ( " \n", TAP_CODE_DELAY ); | ||
#endif // RGB_MATRIX_ENABLE | ||
#ifdef RGBLIGHT_ENABLE | ||
send_string_with_delay ( "\\ RGBLIGHT:", TAP_CODE_DELAY ); | ||
send_string_with_delay ( get_u8_str(rgblight_get_mode(),'0'), TAP_CODE_DELAY ); | ||
send_string_with_delay ( " H:", TAP_CODE_DELAY ); | ||
send_string_with_delay ( get_u8_str(rgblight_get_hue(),'0'), TAP_CODE_DELAY ); | ||
send_string_with_delay ( " S:", TAP_CODE_DELAY ); | ||
send_string_with_delay ( get_u8_str(rgblight_get_sat(),'0'), TAP_CODE_DELAY ); | ||
send_string_with_delay ( " V:", TAP_CODE_DELAY ); | ||
send_string_with_delay ( get_u8_str(rgblight_get_val(),'0'), TAP_CODE_DELAY ); | ||
send_string_with_delay ( " SP:", TAP_CODE_DELAY ); | ||
send_string_with_delay ( get_u8_str(rgblight_get_speed(),'0'), TAP_CODE_DELAY ); | ||
send_string_with_delay ( " \n", TAP_CODE_DELAY ); | ||
#endif // RGBLIGHT_ENABLE | ||
#if ( ! (defined RGB_MATRIX_ENABLE ) || ( defined RGBLIGHT_ENABLE ) ) | ||
send_string_with_delay ( "\\ No RGB! \n", TAP_CODE_DELAY ); | ||
#endif // NO RGB_MATRIX_ENABLE OR RGBLIGHT_ENABLE | ||
} |