summaryrefslogtreecommitdiffstats
path: root/keyboards/annepro2
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/annepro2')
-rw-r--r--keyboards/annepro2/annepro2.c10
-rw-r--r--keyboards/annepro2/annepro2_ble.c21
-rw-r--r--keyboards/annepro2/ap2_led.c1
-rw-r--r--keyboards/annepro2/ap2_led.h1
-rw-r--r--keyboards/annepro2/config_led.h2
-rw-r--r--keyboards/annepro2/rgb_driver.c32
6 files changed, 25 insertions, 42 deletions
diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c
index 4edafe0702..9e17cbcf77 100644
--- a/keyboards/annepro2/annepro2.c
+++ b/keyboards/annepro2/annepro2.c
@@ -46,7 +46,6 @@ ble_capslock_t ble_capslock = {._dummy = {0}, .caps_lock = false};
#ifdef RGB_MATRIX_ENABLE
static uint8_t led_enabled = 1;
-static uint8_t current_rgb_row = 0;
#endif
void bootloader_jump(void) {
@@ -125,15 +124,6 @@ void matrix_scan_kb() {
proto_consume(&proto, byte);
}
- #ifdef RGB_MATRIX_ENABLE
- /* If there's data ready to be sent to LED MCU - send it. */
- if(rgb_row_changed[current_rgb_row])
- {
- rgb_row_changed[current_rgb_row] = 0;
- ap2_led_colors_set_row(current_rgb_row);
- }
- current_rgb_row = (current_rgb_row + 1) % NUM_ROW;
- #endif
matrix_scan_user();
}
diff --git a/keyboards/annepro2/annepro2_ble.c b/keyboards/annepro2/annepro2_ble.c
index 0336d6a76c..64364a6c8e 100644
--- a/keyboards/annepro2/annepro2_ble.c
+++ b/keyboards/annepro2/annepro2_ble.c
@@ -24,15 +24,14 @@
/* -------------------- Static Function Prototypes -------------------------- */
static uint8_t ap2_ble_leds(void);
static void ap2_ble_mouse(report_mouse_t *report);
-static void ap2_ble_system(uint16_t data);
-static void ap2_ble_consumer(uint16_t data);
+static void ap2_ble_extra(report_extra_t *report);
static void ap2_ble_keyboard(report_keyboard_t *report);
static void ap2_ble_swtich_ble_driver(void);
/* -------------------- Static Local Variables ------------------------------ */
static host_driver_t ap2_ble_driver = {
- ap2_ble_leds, ap2_ble_keyboard, ap2_ble_mouse, ap2_ble_system, ap2_ble_consumer,
+ ap2_ble_leds, ap2_ble_keyboard, ap2_ble_mouse, ap2_ble_extra
};
static uint8_t ble_mcu_wakeup[11] = {0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x01, 0x7d, 0x02, 0x01, 0x02};
@@ -131,8 +130,6 @@ static uint8_t ap2_ble_leds(void) {
static void ap2_ble_mouse(report_mouse_t *report) {}
-static void ap2_ble_system(uint16_t data) {}
-
static inline uint16_t CONSUMER2AP2(uint16_t usage) {
switch (usage) {
case AUDIO_VOL_DOWN:
@@ -152,12 +149,14 @@ static inline uint16_t CONSUMER2AP2(uint16_t usage) {
}
}
-static void ap2_ble_consumer(uint16_t data) {
- sdPut(&SD1, 0x0);
- sdWrite(&SD1, ble_mcu_send_consumer_report, sizeof(ble_mcu_send_consumer_report));
- sdPut(&SD1, CONSUMER2AP2(data));
- static const uint8_t dummy[3] = {0};
- sdWrite(&SD1, dummy, sizeof(dummy));
+static void ap2_ble_extra(report_extra_t *report) {
+ if (report->report_id == REPORT_ID_CONSUMER) {
+ sdPut(&SD1, 0x0);
+ sdWrite(&SD1, ble_mcu_send_consumer_report, sizeof(ble_mcu_send_consumer_report));
+ sdPut(&SD1, CONSUMER2AP2(report->usage));
+ static const uint8_t dummy[3] = {0};
+ sdWrite(&SD1, dummy, sizeof(dummy));
+ }
}
/*!
diff --git a/keyboards/annepro2/ap2_led.c b/keyboards/annepro2/ap2_led.c
index 8b42e470c2..339df103bf 100644
--- a/keyboards/annepro2/ap2_led.c
+++ b/keyboards/annepro2/ap2_led.c
@@ -24,7 +24,6 @@
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];
void led_command_callback(const message_t *msg) {
switch (msg->command) {
diff --git a/keyboards/annepro2/ap2_led.h b/keyboards/annepro2/ap2_led.h
index 9d9a3aca7e..ff2a05aff5 100644
--- a/keyboards/annepro2/ap2_led.h
+++ b/keyboards/annepro2/ap2_led.h
@@ -41,7 +41,6 @@ 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 */
extern void led_command_callback(const message_t *msg);
diff --git a/keyboards/annepro2/config_led.h b/keyboards/annepro2/config_led.h
index 19a1dd4baa..e6d4dc35fb 100644
--- a/keyboards/annepro2/config_led.h
+++ b/keyboards/annepro2/config_led.h
@@ -18,7 +18,7 @@
#ifdef RGB_MATRIX_ENABLE
-#define DRIVER_LED_TOTAL 61
+#define RGB_MATRIX_LED_COUNT 61
/* Limit animations to 62.5 FPS to avoid tearing. (1/.016 = 62.5 FPS). */
#define RGB_MATRIX_LED_FLUSH_LIMIT 16
diff --git a/keyboards/annepro2/rgb_driver.c b/keyboards/annepro2/rgb_driver.c
index 1040e89f98..d12fcea90a 100644
--- a/keyboards/annepro2/rgb_driver.c
+++ b/keyboards/annepro2/rgb_driver.c
@@ -16,10 +16,10 @@
#ifdef RGB_MATRIX_ENABLE
-#include "rgb_matrix.h"
-#include "ap2_led.h"
+# include "rgb_matrix.h"
+# include "ap2_led.h"
-uint8_t led_pos[DRIVER_LED_TOTAL];
+uint8_t led_pos[RGB_MATRIX_LED_COUNT];
void init(void) {
unsigned int i = 0;
@@ -33,26 +33,22 @@ void init(void) {
}
}
-void flush(void) {}
+void flush(void) {
+ for (uint8_t row = 0; row < NUM_ROW; row++)
+ ap2_led_colors_set_row(row);
+}
void set_color(int index, uint8_t r, uint8_t g, uint8_t b) {
- 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_colors[led_pos[index]] = (ap2_led_t){
- .p.blue = b,
- .p.red = r,
- .p.green = g,
- .p.alpha = 0xff,
- };
- int row = led_pos[index] / NUM_COLUMN;
- rgb_row_changed[row] = 1;
- }
+ led_colors[led_pos[index]] = (ap2_led_t){
+ .p.blue = b,
+ .p.red = r,
+ .p.green = g,
+ .p.alpha = 0xff,
+ };
}
void set_color_all(uint8_t r, uint8_t g, uint8_t b) {
- for (int i=0; i<DRIVER_LED_TOTAL; i++)
+ for (int i = 0; i < RGB_MATRIX_LED_COUNT; i++)
set_color(i, r, g, b);
}