Add new message type for resetting foreground color (#31)

This commit is contained in:
Darkhan
2021-09-12 09:26:28 +02:00
committed by bwisn
parent 83d7f9a984
commit 365eb5c4c2
3 changed files with 13 additions and 5 deletions
+1 -1
View File
@@ -109,7 +109,7 @@ void matrix_scan_kb() {
*/
bool OVERRIDE process_record_kb(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
if (AP2_LED_ENABLED && AP2_LED_DYNAMIC_PROFILE) {
if (AP2_LED_ENABLED && AP2_LED_DYNAMIC_PROFILE && !AP2_FOREGROUND_COLOR_SET) {
annepro2LedForwardKeypress(record->event.key.row, record->event.key.col);
}
+9 -3
View File
@@ -4,6 +4,7 @@
bool AP2_LED_ENABLED = false;
bool AP2_LED_DYNAMIC_PROFILE = false;
bool AP2_FOREGROUND_COLOR_SET = false;
void annepro2LedDisable(void)
{
@@ -76,6 +77,8 @@ void annepro2LedNextAnimationSpeed()
void annepro2LedPrevProfile()
{
sdPut(&SD0, CMD_LED_PREV_PROFILE);
uint8_t buf = sdGet(&SD0);
AP2_LED_DYNAMIC_PROFILE = buf;
}
void annepro2LedSetMask(uint8_t key)
@@ -94,13 +97,16 @@ void annepro2LedSetForegroundColor(uint8_t red, uint8_t green, uint8_t blue)
{
sdPut(&SD0, CMD_LED_SET_FOREGROUND_COLOR);
uint8_t colors[3]={red,green,blue};
sdWrite(&SD0, (uint8_t *)&colors, sizeof(uint8_t)*3);
sdWrite(&SD0, (uint8_t *)&colors, sizeof(colors));
AP2_FOREGROUND_COLOR_SET = true;
}
void annepro2LedResetForegroundColor()
{
uint8_t currentProfile = annepro2LedGetProfile();
annepro2LedSetProfile(currentProfile);
sdPut(&SD0, CMD_LED_CLEAR_FOREGROUND_COLOR);
uint8_t buf = sdGet(&SD0);
AP2_LED_DYNAMIC_PROFILE = buf;
AP2_FOREGROUND_COLOR_SET = false;
}
/*
+3 -1
View File
@@ -14,8 +14,9 @@
#define CMD_LED_NEXT_INTENSITY 0xC
#define CMD_LED_NEXT_ANIMATION_SPEED 0xD
#define CMD_LED_SET_FOREGROUND_COLOR 0xE
#define CMD_LED_KEYPRESS 0xF
#define CMD_LED_CLEAR_FOREGROUND_COLOR 0xF
#define CMD_LED_IAP 0x10
#define CMD_LED_KEYPRESS 0x11
void annepro2SetIAP(void);
void annepro2LedDisable(void);
@@ -38,3 +39,4 @@ void annepro2LedForwardKeypress(uint8_t row, uint8_t col);
extern bool AP2_LED_ENABLED;
extern bool AP2_LED_DYNAMIC_PROFILE;
extern bool AP2_FOREGROUND_COLOR_SET;