diff options
author | zv0n <tom.zvon@gmail.com> | 2022-06-10 05:25:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-10 13:25:48 +1000 |
commit | 9da1b86d71204ff0a1867730faf97cc88da28baf (patch) | |
tree | 7e86ac6e9d7e5dbc3ed4948155af1f67ca0d9f8c /keyboards/annepro2/ap2_led.c | |
parent | 9316023290148f6d0a736aedbda2ec66f04e9523 (diff) |
[keyboard] annepro2 Add and use functions to directly control led colors (#17196)
Diffstat (limited to 'keyboards/annepro2/ap2_led.c')
-rw-r--r-- | keyboards/annepro2/ap2_led.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/keyboards/annepro2/ap2_led.c b/keyboards/annepro2/ap2_led.c index 73b21f6eb1..f12269f93d 100644 --- a/keyboards/annepro2/ap2_led.c +++ b/keyboards/annepro2/ap2_led.c @@ -22,6 +22,7 @@ #include "protocol.h" ap2_led_t led_mask[KEY_COUNT]; +ap2_led_t led_colors[KEY_COUNT]; ap2_led_status_t ap2_led_status; uint8_t rgb_row_changed[NUM_ROW]; @@ -91,6 +92,32 @@ void ap2_led_mask_set_all(void) { /* Set all keys to a given color */ void ap2_led_mask_set_mono(const ap2_led_t color) { proto_tx(CMD_LED_MASK_SET_MONO, (uint8_t *)&color, sizeof(color), 1); } +void ap2_led_colors_set_key(uint8_t row, uint8_t col, ap2_led_t color) { + uint8_t payload[] = {row, col, color.p.blue, color.p.green, color.p.red, color.p.alpha}; + proto_tx(CMD_LED_COLOR_SET_KEY, payload, sizeof(payload), 1); +} + +/* Push a whole local row to the shine */ +void ap2_led_colors_set_row(uint8_t row) { + uint8_t payload[NUM_COLUMN * sizeof(ap2_led_t) + 1]; + payload[0] = row; + memcpy(payload + 1, &led_colors[ROWCOL2IDX(row, 0)], sizeof(*led_colors) * NUM_COLUMN); + proto_tx(CMD_LED_COLOR_SET_ROW, payload, sizeof(payload), 1); +} + +/* Synchronize all rows */ +void ap2_led_colors_set_all(void) { + for (int row = 0; row < 5; row++) ap2_led_colors_set_row(row); +} + +/* Set all keys to a given color */ +void ap2_led_colors_set_mono(const ap2_led_t color) { proto_tx(CMD_LED_COLOR_SET_MONO, (uint8_t *)&color, sizeof(color), 1); } + +void ap2_led_set_manual_control(uint8_t manual) { + uint8_t payload[] = {manual}; + proto_tx(CMD_LED_SET_MANUAL, payload, sizeof(payload), 1); +} + void ap2_led_blink(uint8_t row, uint8_t col, ap2_led_t color, uint8_t count, uint8_t hundredths) { uint8_t payload[] = {row, col, color.p.blue, color.p.green, color.p.red, color.p.alpha, count, hundredths}; proto_tx(CMD_LED_KEY_BLINK, payload, sizeof(payload), 1); |