Merge remote-tracking branch 'origin/develop' into xap

This commit is contained in:
QMK Bot 2022-06-10 03:26:51 +00:00
commit 5afc776cec
5 changed files with 52 additions and 5 deletions

View File

@ -106,6 +106,7 @@ void keyboard_post_init_kb(void) {
#ifdef RGB_MATRIX_ENABLE
ap2_led_enable();
ap2_led_set_manual_control(1);
#endif
keyboard_post_init_user();
@ -129,7 +130,7 @@ void matrix_scan_kb() {
if(rgb_row_changed[current_rgb_row])
{
rgb_row_changed[current_rgb_row] = 0;
ap2_led_mask_set_row(current_rgb_row);
ap2_led_colors_set_row(current_rgb_row);
}
current_rgb_row = (current_rgb_row + 1) % NUM_ROW;
#endif

View File

@ -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);

View File

@ -40,6 +40,7 @@ typedef union {
/* Local copy of led_mask, used to override colors on the board */
extern ap2_led_t led_mask[KEY_COUNT];
extern ap2_led_t led_colors[KEY_COUNT];
extern uint8_t rgb_row_changed[NUM_ROW];
/* Handle incoming messages */
@ -66,6 +67,18 @@ void ap2_led_mask_set_all(void);
/* Set all keys to a given color */
void ap2_led_mask_set_mono(ap2_led_t color);
/* Set single key to a given color; alpha controls which is displayed */
void ap2_led_colors_set_key(uint8_t row, uint8_t col, ap2_led_t color);
/* Push a whole local row to the shine */
void ap2_led_colors_set_row(uint8_t row);
/* Synchronize all rows */
void ap2_led_colors_set_all(void);
/* Set all keys to a given color */
void ap2_led_colors_set_mono(ap2_led_t color);
void ap2_led_set_manual_control(uint8_t manual);
/* Blink given key `count` times by masking it with a `color`. Blink takes `hundredths` of a second */
void ap2_led_blink(uint8_t row, uint8_t col, ap2_led_t color, uint8_t count, uint8_t hundredths);

View File

@ -42,6 +42,12 @@ enum {
CMD_LED_KEY_UP = 0x23, /* TODO */
CMD_LED_IAP = 0x24,
/* Manual color control */
CMD_LED_SET_MANUAL = 0x30,
CMD_LED_COLOR_SET_KEY = 0x31,
CMD_LED_COLOR_SET_ROW = 0x32,
CMD_LED_COLOR_SET_MONO = 0x33,
/* LED -> Main */
/* Payload with data to send over HID */
CMD_LED_DEBUG = 0x40,

View File

@ -36,11 +36,11 @@ void init(void) {
void flush(void) {}
void set_color(int index, uint8_t r, uint8_t g, uint8_t b) {
if (r != led_mask[led_pos[index]].p.red ||
g != led_mask[led_pos[index]].p.green ||
b != led_mask[led_pos[index]].p.blue)
if (r != led_colors[led_pos[index]].p.red ||
g != led_colors[led_pos[index]].p.green ||
b != led_colors[led_pos[index]].p.blue)
{
led_mask[led_pos[index]] = (ap2_led_t){
led_colors[led_pos[index]] = (ap2_led_t){
.p.blue = b,
.p.red = r,
.p.green = g,