summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjpe230 <pablin.123.ra@gmail.com>2022-03-08 23:49:29 -0600
committerGitHub <noreply@github.com>2022-03-09 16:49:29 +1100
commitdc67fd9b87b0e86cea8d176d8b9bbce3e8a8676d (patch)
tree89a1dce5d6b2c1add1f1e7ba8d02ce0881f686f4
parent6ab5a7d048358f261d7068c56ef73dd3da4319aa (diff)
Various improvements for the AnnePro2 (#16579)
-rw-r--r--keyboards/annepro2/annepro2.c92
-rw-r--r--keyboards/annepro2/annepro2.h6
-rw-r--r--keyboards/annepro2/annepro2_ble.c34
-rw-r--r--keyboards/annepro2/ap2_led.c79
-rw-r--r--keyboards/annepro2/ap2_led.h93
-rw-r--r--keyboards/annepro2/c15/config.h1
-rw-r--r--keyboards/annepro2/c15/rules.mk5
-rw-r--r--keyboards/annepro2/c18/config.h1
-rw-r--r--keyboards/annepro2/c18/rules.mk5
-rw-r--r--keyboards/annepro2/config_led.c43
-rw-r--r--keyboards/annepro2/config_led.h72
-rw-r--r--keyboards/annepro2/info.json2
-rw-r--r--keyboards/annepro2/keymaps/default-full-caps/keymap.c84
-rw-r--r--keyboards/annepro2/keymaps/default-layer-indicators/keymap.c102
-rw-r--r--keyboards/annepro2/keymaps/default/keymap.c80
-rw-r--r--keyboards/annepro2/keymaps/default/rules.mk3
-rw-r--r--keyboards/annepro2/protocol.c40
-rw-r--r--keyboards/annepro2/protocol.h22
-rw-r--r--keyboards/annepro2/rgb_driver.c66
19 files changed, 526 insertions, 304 deletions
diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c
index 37489defff..8767265315 100644
--- a/keyboards/annepro2/annepro2.c
+++ b/keyboards/annepro2/annepro2.c
@@ -24,7 +24,7 @@
24#define RAM_MAGIC_LOCATION 0x20001ffc 24#define RAM_MAGIC_LOCATION 0x20001ffc
25#define IAP_MAGIC_VALUE 0x0000fab2 25#define IAP_MAGIC_VALUE 0x0000fab2
26 26
27static const SerialConfig ledUartInitConfig = { 27static const SerialConfig led_uart_init_config = {
28 .speed = 115200, 28 .speed = 115200,
29}; 29};
30 30
@@ -32,21 +32,25 @@ static const SerialConfig ledUartInitConfig = {
32# define LED_UART_BAUD_RATE 115200 32# define LED_UART_BAUD_RATE 115200
33#endif // LED_UART_BAUD_RATE 33#endif // LED_UART_BAUD_RATE
34 34
35static const SerialConfig ledUartRuntimeConfig = { 35static const SerialConfig led_uart_runtine_config = {
36 .speed = LED_UART_BAUD_RATE, 36 .speed = LED_UART_BAUD_RATE,
37}; 37};
38 38
39static const SerialConfig bleUartConfig = { 39static const SerialConfig ble_uart_config = {
40 .speed = 115200, 40 .speed = 115200,
41}; 41};
42 42
43static uint8_t ledMcuWakeup[11] = {0x7b, 0x10, 0x43, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x02}; 43static uint8_t led_mcu_wakeup[11] = {0x7b, 0x10, 0x43, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x02};
44 44
45ble_capslock_t BLECapsLock = {._dummy = {0}, .caps_lock = false}; 45ble_capslock_t ble_capslock = {._dummy = {0}, .caps_lock = false};
46
47#ifdef RGB_MATRIX_ENABLE
48static uint8_t current_rgb_row = 0;
49#endif
46 50
47void bootloader_jump(void) { 51void bootloader_jump(void) {
48 // Send msg to shine to boot into IAP 52 // Send msg to shine to boot into IAP
49 annepro2SetIAP(); 53 ap2_set_IAP();
50 54
51 // wait for shine to boot into IAP 55 // wait for shine to boot into IAP
52 wait_ms(15); 56 wait_ms(15);
@@ -67,27 +71,27 @@ void bootloader_jump(void) {
67 71
68void keyboard_pre_init_kb(void) { 72void keyboard_pre_init_kb(void) {
69 // Start LED UART 73 // Start LED UART
70 sdStart(&SD0, &ledUartInitConfig); 74 sdStart(&SD0, &led_uart_init_config);
71 /* Let the LED chip settle a bit before switching the mode. 75 /* Let the LED chip settle a bit before switching the mode.
72 * That helped at least one person. */ 76 * That helped at least one person. */
73 wait_ms(15); 77 wait_ms(15);
74 sdWrite(&SD0, ledMcuWakeup, sizeof(ledMcuWakeup)); 78 sdWrite(&SD0, led_mcu_wakeup, sizeof(led_mcu_wakeup));
75 79
76 // wait to receive response from wakeup 80 // wait to receive response from wakeup
77 wait_ms(15); 81 wait_ms(15);
78 82
79 protoInit(&proto, ledCommandCallback); 83 proto_init(&proto, led_command_callback);
80 84
81 // loop to clear out receive buffer from shine wakeup 85 // loop to clear out receive buffer from shine wakeup
82 while (!sdGetWouldBlock(&SD0)) sdGet(&SD0); 86 while (!sdGetWouldBlock(&SD0)) sdGet(&SD0);
83 87
84 sdStart(&SD0, &ledUartRuntimeConfig); 88 sdStart(&SD0, &led_uart_runtine_config);
85 keyboard_pre_init_user(); 89 keyboard_pre_init_user();
86} 90}
87 91
88void keyboard_post_init_kb(void) { 92void keyboard_post_init_kb(void) {
89 // Start BLE UART 93 // Start BLE UART
90 sdStart(&SD1, &bleUartConfig); 94 sdStart(&SD1, &ble_uart_config);
91 annepro2_ble_startup(); 95 annepro2_ble_startup();
92 96
93 // Give the send uart thread some time to 97 // Give the send uart thread some time to
@@ -97,7 +101,11 @@ void keyboard_post_init_kb(void) {
97 // loop to clear out receive buffer from ble wakeup 101 // loop to clear out receive buffer from ble wakeup
98 while (!sdGetWouldBlock(&SD1)) sdGet(&SD1); 102 while (!sdGetWouldBlock(&SD1)) sdGet(&SD1);
99 103
100 annepro2LedGetStatus(); 104 ap2_led_get_status();
105
106 #ifdef RGB_MATRIX_ENABLE
107 ap2_led_enable();
108 #endif
101 109
102 keyboard_post_init_user(); 110 keyboard_post_init_user();
103} 111}
@@ -106,25 +114,35 @@ void matrix_scan_kb() {
106 // if there's stuff on the ble serial buffer 114 // if there's stuff on the ble serial buffer
107 // read it into the capslock struct 115 // read it into the capslock struct
108 while (!sdGetWouldBlock(&SD1)) { 116 while (!sdGetWouldBlock(&SD1)) {
109 sdReadTimeout(&SD1, (uint8_t *)&BLECapsLock, sizeof(ble_capslock_t), 10); 117 sdReadTimeout(&SD1, (uint8_t *)&ble_capslock, sizeof(ble_capslock_t), 10);
110 } 118 }
111 119
112 /* While there's data from LED keyboard sent - read it. */ 120 /* While there's data from LED keyboard sent - read it. */
113 while (!sdGetWouldBlock(&SD0)) { 121 while (!sdGetWouldBlock(&SD0)) {
114 uint8_t byte = sdGet(&SD0); 122 uint8_t byte = sdGet(&SD0);
115 protoConsume(&proto, byte); 123 proto_consume(&proto, byte);
124 }
125
126 #ifdef RGB_MATRIX_ENABLE
127 /* If there's data ready to be sent to LED MCU - send it. */
128 if(rgb_row_changed[current_rgb_row])
129 {
130 rgb_row_changed[current_rgb_row] = 0;
131 ap2_led_mask_set_row(current_rgb_row);
116 } 132 }
133 current_rgb_row = (current_rgb_row + 1) % NUM_ROW;
134 #endif
117 135
118 matrix_scan_user(); 136 matrix_scan_user();
119} 137}
120 138
121bool process_record_kb(uint16_t keycode, keyrecord_t *record) { 139bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
122 if (record->event.pressed) { 140 if (record->event.pressed) {
123 if (annepro2LedStatus.matrixEnabled && annepro2LedStatus.isReactive) { 141 if (ap2_led_status.matrix_enabled && ap2_led_status.is_reactive) {
124 annepro2LedForwardKeypress(record->event.key.row, record->event.key.col); 142 ap2_led_forward_keypress(record->event.key.row, record->event.key.col);
125 } 143 }
126 144
127 const annepro2Led_t blue = { 145 const ap2_led_t blue = {
128 .p.blue = 0xff, 146 .p.blue = 0xff,
129 .p.red = 0x00, 147 .p.red = 0x00,
130 .p.green = 0x00, 148 .p.green = 0x00,
@@ -135,22 +153,22 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
135 case KC_AP2_BT1: 153 case KC_AP2_BT1:
136 annepro2_ble_broadcast(0); 154 annepro2_ble_broadcast(0);
137 /* FIXME: This hardcodes col/row position */ 155 /* FIXME: This hardcodes col/row position */
138 annepro2LedBlink(0, 1, blue, 8, 50); 156 ap2_led_blink(0, 1, blue, 8, 50);
139 return false; 157 return false;
140 158
141 case KC_AP2_BT2: 159 case KC_AP2_BT2:
142 annepro2_ble_broadcast(1); 160 annepro2_ble_broadcast(1);
143 annepro2LedBlink(0, 2, blue, 8, 50); 161 ap2_led_blink(0, 2, blue, 8, 50);
144 return false; 162 return false;
145 163
146 case KC_AP2_BT3: 164 case KC_AP2_BT3:
147 annepro2_ble_broadcast(2); 165 annepro2_ble_broadcast(2);
148 annepro2LedBlink(0, 3, blue, 8, 50); 166 ap2_led_blink(0, 3, blue, 8, 50);
149 return false; 167 return false;
150 168
151 case KC_AP2_BT4: 169 case KC_AP2_BT4:
152 annepro2_ble_broadcast(3); 170 annepro2_ble_broadcast(3);
153 annepro2LedBlink(0, 4, blue, 8, 50); 171 ap2_led_blink(0, 4, blue, 8, 50);
154 return false; 172 return false;
155 173
156 case KC_AP2_USB: 174 case KC_AP2_USB:
@@ -162,37 +180,43 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
162 return false; 180 return false;
163 181
164 case KC_AP_LED_OFF: 182 case KC_AP_LED_OFF:
165 annepro2LedDisable(); 183 ap2_led_disable();
166 break; 184 break;
167 185
168 case KC_AP_LED_ON: 186 case KC_AP_LED_ON:
169 if (annepro2LedStatus.matrixEnabled) { 187 if (ap2_led_status.matrix_enabled) {
170 annepro2LedNextProfile(); 188 ap2_led_next_profile();
171 } else { 189 } else {
172 annepro2LedEnable(); 190 ap2_led_enable();
173 } 191 }
174 annepro2LedResetForegroundColor(); 192 ap2_led_reset_foreground_color();
175 break; 193 break;
176 194
177 case KC_AP_LED_NEXT_PROFILE: 195 case KC_AP_LED_NEXT_PROFILE:
178 annepro2LedNextProfile(); 196 ap2_led_next_profile();
179 annepro2LedResetForegroundColor(); 197 ap2_led_reset_foreground_color();
180 break; 198 break;
181 199
182 case KC_AP_LED_PREV_PROFILE: 200 case KC_AP_LED_PREV_PROFILE:
183 annepro2LedPrevProfile(); 201 ap2_led_prev_profile();
184 annepro2LedResetForegroundColor(); 202 ap2_led_reset_foreground_color();
185 break; 203 break;
186 204
187 case KC_AP_LED_NEXT_INTENSITY: 205 case KC_AP_LED_NEXT_INTENSITY:
188 annepro2LedNextIntensity(); 206 ap2_led_next_intensity();
189 annepro2LedResetForegroundColor(); 207 ap2_led_reset_foreground_color();
190 return false; 208 return false;
191 209
192 case KC_AP_LED_SPEED: 210 case KC_AP_LED_SPEED:
193 annepro2LedNextAnimationSpeed(); 211 ap2_led_next_animation_speed();
194 annepro2LedResetForegroundColor(); 212 ap2_led_reset_foreground_color();
195 return false; 213 return false;
214 #ifdef RGB_MATRIX_ENABLE
215 case RGB_TOG:
216 if(rgb_matrix_is_enabled()) ap2_led_disable();
217 else ap2_led_enable();
218 return true;
219 #endif
196 220
197 default: 221 default:
198 break; 222 break;
diff --git a/keyboards/annepro2/annepro2.h b/keyboards/annepro2/annepro2.h
index b08f8c5352..1b5933f577 100644
--- a/keyboards/annepro2/annepro2.h
+++ b/keyboards/annepro2/annepro2.h
@@ -24,16 +24,16 @@ typedef struct __attribute__((__packed__)) {
24 uint8_t _dummy[10]; 24 uint8_t _dummy[10];
25 bool caps_lock; 25 bool caps_lock;
26} ble_capslock_t; 26} ble_capslock_t;
27extern ble_capslock_t BLECapsLock; 27extern ble_capslock_t ble_capslock;
28 28
29// Matrix keymap 29// Matrix keymap
30// clang-format off 30// clang-format off
31#define LAYOUT( \ 31#define LAYOUT_60_ansi( \
32 K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ 32 K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \
33 K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ 33 K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
34 K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, \ 34 K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, \
35 K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, \ 35 K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, \
36 K40, K42, K43, K46, K49, K4A, K4B, K4C \ 36 K40, K42, K43, K46, K49, K4A, K4B, K4C \
37) { \ 37) { \
38 /* COL1 COL2 COL3 COL4 COL5 COL6 COL7 COL8 COL9 COL10 COL11 COL12 COL13 COL14*/ \ 38 /* COL1 COL2 COL3 COL4 COL5 COL6 COL7 COL8 COL9 COL10 COL11 COL12 COL13 COL14*/ \
39 /* ROW1 */ { K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D }, \ 39 /* ROW1 */ { K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D }, \
diff --git a/keyboards/annepro2/annepro2_ble.c b/keyboards/annepro2/annepro2_ble.c
index 72cbb68016..0336d6a76c 100644
--- a/keyboards/annepro2/annepro2_ble.c
+++ b/keyboards/annepro2/annepro2_ble.c
@@ -35,47 +35,47 @@ static host_driver_t ap2_ble_driver = {
35 ap2_ble_leds, ap2_ble_keyboard, ap2_ble_mouse, ap2_ble_system, ap2_ble_consumer, 35 ap2_ble_leds, ap2_ble_keyboard, ap2_ble_mouse, ap2_ble_system, ap2_ble_consumer,
36}; 36};
37 37
38static uint8_t bleMcuWakeup[11] = {0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x01, 0x7d, 0x02, 0x01, 0x02}; 38static uint8_t ble_mcu_wakeup[11] = {0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x01, 0x7d, 0x02, 0x01, 0x02};
39 39
40static uint8_t bleMcuStartBroadcast[11] = { 40static uint8_t ble_mcu_start_broadcast[11] = {
41 0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x01, 0x00 // Broadcast ID[0-3] 41 0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x01, 0x00 // Broadcast ID[0-3]
42}; 42};
43 43
44static uint8_t bleMcuConnect[11] = { 44static uint8_t ble_mcu_connect[11] = {
45 0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x04, 0x00 // Connect ID [0-3] 45 0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x04, 0x00 // Connect ID [0-3]
46}; 46};
47 47
48static uint8_t bleMcuSendReport[10] = { 48static uint8_t ble_mcu_send_report[10] = {
49 0x7b, 0x12, 0x53, 0x00, 0x0A, 0x00, 0x00, 0x7d, 0x10, 0x04, 49 0x7b, 0x12, 0x53, 0x00, 0x0A, 0x00, 0x00, 0x7d, 0x10, 0x04,
50}; 50};
51 51
52static uint8_t bleMcuSendConsumerReport[10] = { 52static uint8_t ble_mcu_send_consumer_report[10] = {
53 0x7b, 0x12, 0x53, 0x00, 0x06, 0x00, 0x00, 0x7d, 0x10, 0x08, 53 0x7b, 0x12, 0x53, 0x00, 0x06, 0x00, 0x00, 0x7d, 0x10, 0x08,
54}; 54};
55 55
56static uint8_t bleMcuUnpair[10] = { 56static uint8_t ble_mcu_unpair[10] = {
57 0x7b, 0x12, 0x53, 0x00, 0x02, 0x00, 0x00, 0x7d, 0x40, 0x05, 57 0x7b, 0x12, 0x53, 0x00, 0x02, 0x00, 0x00, 0x7d, 0x40, 0x05,
58}; 58};
59 59
60static uint8_t bleMcuBootload[11] = {0x7b, 0x10, 0x51, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x01}; 60static uint8_t ble_mcu_bootload[11] = {0x7b, 0x10, 0x51, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x01};
61 61
62static host_driver_t *lastHostDriver = NULL; 62static host_driver_t *last_host_driver = NULL;
63#ifdef NKRO_ENABLE 63#ifdef NKRO_ENABLE
64static bool lastNkroStatus = false; 64static bool lastNkroStatus = false;
65#endif // NKRO_ENABLE 65#endif // NKRO_ENABLE
66 66
67/* -------------------- Public Function Implementation ---------------------- */ 67/* -------------------- Public Function Implementation ---------------------- */
68 68
69void annepro2_ble_bootload(void) { sdWrite(&SD1, bleMcuBootload, sizeof(bleMcuBootload)); } 69void annepro2_ble_bootload(void) { sdWrite(&SD1, ble_mcu_bootload, sizeof(ble_mcu_bootload)); }
70 70
71void annepro2_ble_startup(void) { sdWrite(&SD1, bleMcuWakeup, sizeof(bleMcuWakeup)); } 71void annepro2_ble_startup(void) { sdWrite(&SD1, ble_mcu_wakeup, sizeof(ble_mcu_wakeup)); }
72 72
73void annepro2_ble_broadcast(uint8_t port) { 73void annepro2_ble_broadcast(uint8_t port) {
74 if (port > 3) { 74 if (port > 3) {
75 port = 3; 75 port = 3;
76 } 76 }
77 // sdPut(&SD1, 0x00); 77 // sdPut(&SD1, 0x00);
78 sdWrite(&SD1, bleMcuStartBroadcast, sizeof(bleMcuStartBroadcast)); 78 sdWrite(&SD1, ble_mcu_start_broadcast, sizeof(ble_mcu_start_broadcast));
79 sdPut(&SD1, port); 79 sdPut(&SD1, port);
80 static int lastBroadcast = -1; 80 static int lastBroadcast = -1;
81 if (lastBroadcast == port) { 81 if (lastBroadcast == port) {
@@ -88,7 +88,7 @@ void annepro2_ble_connect(uint8_t port) {
88 if (port > 3) { 88 if (port > 3) {
89 port = 3; 89 port = 3;
90 } 90 }
91 sdWrite(&SD1, bleMcuConnect, sizeof(bleMcuConnect)); 91 sdWrite(&SD1, ble_mcu_connect, sizeof(ble_mcu_connect));
92 sdPut(&SD1, port); 92 sdPut(&SD1, port);
93 ap2_ble_swtich_ble_driver(); 93 ap2_ble_swtich_ble_driver();
94} 94}
@@ -103,12 +103,12 @@ void annepro2_ble_disconnect(void) {
103#ifdef NKRO_ENABLE 103#ifdef NKRO_ENABLE
104 keymap_config.nkro = lastNkroStatus; 104 keymap_config.nkro = lastNkroStatus;
105#endif 105#endif
106 host_set_driver(lastHostDriver); 106 host_set_driver(last_host_driver);
107} 107}
108 108
109void annepro2_ble_unpair(void) { 109void annepro2_ble_unpair(void) {
110 // sdPut(&SD1, 0x0); 110 // sdPut(&SD1, 0x0);
111 sdWrite(&SD1, bleMcuUnpair, sizeof(bleMcuUnpair)); 111 sdWrite(&SD1, ble_mcu_unpair, sizeof(ble_mcu_unpair));
112} 112}
113 113
114/* ------------------- Static Function Implementation ----------------------- */ 114/* ------------------- Static Function Implementation ----------------------- */
@@ -117,7 +117,7 @@ static void ap2_ble_swtich_ble_driver(void) {
117 return; 117 return;
118 } 118 }
119 clear_keyboard(); 119 clear_keyboard();
120 lastHostDriver = host_get_driver(); 120 last_host_driver = host_get_driver();
121#ifdef NKRO_ENABLE 121#ifdef NKRO_ENABLE
122 lastNkroStatus = keymap_config.nkro; 122 lastNkroStatus = keymap_config.nkro;
123#endif 123#endif
@@ -154,7 +154,7 @@ static inline uint16_t CONSUMER2AP2(uint16_t usage) {
154 154
155static void ap2_ble_consumer(uint16_t data) { 155static void ap2_ble_consumer(uint16_t data) {
156 sdPut(&SD1, 0x0); 156 sdPut(&SD1, 0x0);
157 sdWrite(&SD1, bleMcuSendConsumerReport, sizeof(bleMcuSendConsumerReport)); 157 sdWrite(&SD1, ble_mcu_send_consumer_report, sizeof(ble_mcu_send_consumer_report));
158 sdPut(&SD1, CONSUMER2AP2(data)); 158 sdPut(&SD1, CONSUMER2AP2(data));
159 static const uint8_t dummy[3] = {0}; 159 static const uint8_t dummy[3] = {0};
160 sdWrite(&SD1, dummy, sizeof(dummy)); 160 sdWrite(&SD1, dummy, sizeof(dummy));
@@ -165,6 +165,6 @@ static void ap2_ble_consumer(uint16_t data) {
165 */ 165 */
166static void ap2_ble_keyboard(report_keyboard_t *report) { 166static void ap2_ble_keyboard(report_keyboard_t *report) {
167 sdPut(&SD1, 0x0); 167 sdPut(&SD1, 0x0);
168 sdWrite(&SD1, bleMcuSendReport, sizeof(bleMcuSendReport)); 168 sdWrite(&SD1, ble_mcu_send_report, sizeof(ble_mcu_send_report));
169 sdWrite(&SD1, &report->raw[0], KEYBOARD_REPORT_SIZE); 169 sdWrite(&SD1, &report->raw[0], KEYBOARD_REPORT_SIZE);
170} 170}
diff --git a/keyboards/annepro2/ap2_led.c b/keyboards/annepro2/ap2_led.c
index 9969fcd02a..73b21f6eb1 100644
--- a/keyboards/annepro2/ap2_led.c
+++ b/keyboards/annepro2/ap2_led.c
@@ -21,28 +21,29 @@
21#include "ap2_led.h" 21#include "ap2_led.h"
22#include "protocol.h" 22#include "protocol.h"
23 23
24annepro2Led_t ledMask[KEY_COUNT]; 24ap2_led_t led_mask[KEY_COUNT];
25annepro2LedStatus_t annepro2LedStatus; 25ap2_led_status_t ap2_led_status;
26uint8_t rgb_row_changed[NUM_ROW];
26 27
27void ledCommandCallback(const message_t *msg) { 28void led_command_callback(const message_t *msg) {
28 switch (msg->command) { 29 switch (msg->command) {
29 case CMD_LED_STATUS: 30 case CMD_LED_STATUS:
30 annepro2LedStatus.amountOfProfiles = msg->payload[0]; 31 ap2_led_status.amount_of_profiles = msg->payload[0];
31 annepro2LedStatus.currentProfile = msg->payload[1]; 32 ap2_led_status.current_profile = msg->payload[1];
32 annepro2LedStatus.matrixEnabled = msg->payload[2]; 33 ap2_led_status.matrix_enabled = msg->payload[2];
33 annepro2LedStatus.isReactive = msg->payload[3]; 34 ap2_led_status.is_reactive = msg->payload[3];
34 annepro2LedStatus.ledIntensity = msg->payload[4]; 35 ap2_led_status.led_intensity = msg->payload[4];
35 annepro2LedStatus.errors = msg->payload[5]; 36 ap2_led_status.errors = msg->payload[5];
36 break; 37 break;
37 38
38#ifdef CONSOLE_ENABLE 39#ifdef CONSOLE_ENABLE
39 case CMD_LED_DEBUG: 40 case CMD_LED_DEBUG:
40 /* TODO: Don't use printf. */ 41 /* TODO: Don't use printf. */
41 printf("LED:"); 42 printf("LED:");
42 for (int i = 0; i < msg->payloadSize; i++) { 43 for (int i = 0; i < msg->payload_size; i++) {
43 printf("%02x ", msg->payload[i]); 44 printf("%02x ", msg->payload[i]);
44 } 45 }
45 for (int i = 0; i < msg->payloadSize; i++) { 46 for (int i = 0; i < msg->payload_size; i++) {
46 printf("%c", msg->payload[i]); 47 printf("%c", msg->payload[i]);
47 } 48 }
48 printf("\n"); 49 printf("\n");
@@ -51,63 +52,63 @@ void ledCommandCallback(const message_t *msg) {
51 } 52 }
52} 53}
53 54
54void annepro2SetIAP(void) { protoTx(CMD_LED_IAP, NULL, 0, 3); } 55void ap2_set_IAP(void) { proto_tx(CMD_LED_IAP, NULL, 0, 3); }
55 56
56void annepro2LedDisable(void) { protoTx(CMD_LED_OFF, NULL, 0, 3); } 57void ap2_led_disable(void) { proto_tx(CMD_LED_OFF, NULL, 0, 3); }
57 58
58void annepro2LedEnable(void) { protoTx(CMD_LED_ON, NULL, 0, 3); } 59void ap2_led_enable(void) { proto_tx(CMD_LED_ON, NULL, 0, 3); }
59 60
60void annepro2LedSetProfile(uint8_t prof) { protoTx(CMD_LED_SET_PROFILE, &prof, sizeof(prof), 3); } 61void ap2_led_set_profile(uint8_t prof) { proto_tx(CMD_LED_SET_PROFILE, &prof, sizeof(prof), 3); }
61 62
62void annepro2LedGetStatus() { protoTx(CMD_LED_GET_STATUS, NULL, 0, 3); } 63void ap2_led_get_status() { proto_tx(CMD_LED_GET_STATUS, NULL, 0, 3); }
63 64
64void annepro2LedNextProfile() { protoTx(CMD_LED_NEXT_PROFILE, NULL, 0, 3); } 65void ap2_led_next_profile() { proto_tx(CMD_LED_NEXT_PROFILE, NULL, 0, 3); }
65 66
66void annepro2LedNextIntensity() { protoTx(CMD_LED_NEXT_INTENSITY, NULL, 0, 3); } 67void ap2_led_next_intensity() { proto_tx(CMD_LED_NEXT_INTENSITY, NULL, 0, 3); }
67 68
68void annepro2LedNextAnimationSpeed() { protoTx(CMD_LED_NEXT_ANIMATION_SPEED, NULL, 0, 3); } 69void ap2_led_next_animation_speed() { proto_tx(CMD_LED_NEXT_ANIMATION_SPEED, NULL, 0, 3); }
69 70
70void annepro2LedPrevProfile() { protoTx(CMD_LED_PREV_PROFILE, NULL, 0, 3); } 71void ap2_led_prev_profile() { proto_tx(CMD_LED_PREV_PROFILE, NULL, 0, 3); }
71 72
72void annepro2LedMaskSetKey(uint8_t row, uint8_t col, annepro2Led_t color) { 73void ap2_led_mask_set_key(uint8_t row, uint8_t col, ap2_led_t color) {
73 uint8_t payload[] = {row, col, color.p.blue, color.p.green, color.p.red, color.p.alpha}; 74 uint8_t payload[] = {row, col, color.p.blue, color.p.green, color.p.red, color.p.alpha};
74 protoTx(CMD_LED_MASK_SET_KEY, payload, sizeof(payload), 1); 75 proto_tx(CMD_LED_MASK_SET_KEY, payload, sizeof(payload), 1);
75} 76}
76 77
77/* Push a whole local row to the shine */ 78/* Push a whole local row to the shine */
78void annepro2LedMaskSetRow(uint8_t row) { 79void ap2_led_mask_set_row(uint8_t row) {
79 uint8_t payload[NUM_COLUMN * sizeof(annepro2Led_t) + 1]; 80 uint8_t payload[NUM_COLUMN * sizeof(ap2_led_t) + 1];
80 payload[0] = row; 81 payload[0] = row;
81 memcpy(payload + 1, &ledMask[ROWCOL2IDX(row, 0)], sizeof(*ledMask) * NUM_COLUMN); 82 memcpy(payload + 1, &led_mask[ROWCOL2IDX(row, 0)], sizeof(*led_mask) * NUM_COLUMN);
82 protoTx(CMD_LED_MASK_SET_ROW, payload, sizeof(payload), 1); 83 proto_tx(CMD_LED_MASK_SET_ROW, payload, sizeof(payload), 1);
83} 84}
84 85
85/* Synchronize all rows */ 86/* Synchronize all rows */
86void annepro2LedMaskSetAll(void) { 87void ap2_led_mask_set_all(void) {
87 for (int row = 0; row < 5; row++) annepro2LedMaskSetRow(row); 88 for (int row = 0; row < 5; row++) ap2_led_mask_set_row(row);
88} 89}
89 90
90/* Set all keys to a given color */ 91/* Set all keys to a given color */
91void annepro2LedMaskSetMono(const annepro2Led_t color) { protoTx(CMD_LED_MASK_SET_MONO, (uint8_t *)&color, sizeof(color), 1); } 92void ap2_led_mask_set_mono(const ap2_led_t color) { proto_tx(CMD_LED_MASK_SET_MONO, (uint8_t *)&color, sizeof(color), 1); }
92 93
93void annepro2LedBlink(uint8_t row, uint8_t col, annepro2Led_t color, uint8_t count, uint8_t hundredths) { 94void ap2_led_blink(uint8_t row, uint8_t col, ap2_led_t color, uint8_t count, uint8_t hundredths) {
94 uint8_t payload[] = {row, col, color.p.blue, color.p.green, color.p.red, color.p.alpha, count, hundredths}; 95 uint8_t payload[] = {row, col, color.p.blue, color.p.green, color.p.red, color.p.alpha, count, hundredths};
95 protoTx(CMD_LED_KEY_BLINK, payload, sizeof(payload), 1); 96 proto_tx(CMD_LED_KEY_BLINK, payload, sizeof(payload), 1);
96} 97}
97 98
98void annepro2LedSetForegroundColor(uint8_t red, uint8_t green, uint8_t blue) { 99void ap2_led_set_foreground_color(uint8_t red, uint8_t green, uint8_t blue) {
99 annepro2Led_t color = {.p.red = red, .p.green = green, .p.blue = blue, .p.alpha = 0xff}; 100 ap2_led_t color = {.p.red = red, .p.green = green, .p.blue = blue, .p.alpha = 0xff};
100 annepro2LedMaskSetMono(color); 101 ap2_led_mask_set_mono(color);
101} 102}
102 103
103void annepro2LedResetForegroundColor() { 104void ap2_led_reset_foreground_color() {
104 annepro2Led_t color = { 105 ap2_led_t color = {
105 .p.red = 0, 106 .p.red = 0,
106 .p.green = 0, 107 .p.green = 0,
107 .p.blue = 0, 108 .p.blue = 0,
108 .p.alpha = 0, 109 .p.alpha = 0,
109 }; 110 };
110 annepro2LedMaskSetMono(color); 111 ap2_led_mask_set_mono(color);
111} 112}
112 113
113/* 114/*
@@ -128,7 +129,7 @@ void annepro2LedResetForegroundColor() {
128 * Following it are 3 bits of row and 4 bits of col. 129 * Following it are 3 bits of row and 4 bits of col.
129 * 1 + 3 + 4 = 8 bits - only a single byte is sent for every keypress. 130 * 1 + 3 + 4 = 8 bits - only a single byte is sent for every keypress.
130 */ 131 */
131void annepro2LedForwardKeypress(uint8_t row, uint8_t col) { 132void ap2_led_forward_keypress(uint8_t row, uint8_t col) {
132 const uint8_t payload = row << 4 | col; 133 const uint8_t payload = row << 4 | col;
133 protoTx(CMD_LED_KEY_DOWN, &payload, 1, 1); 134 proto_tx(CMD_LED_KEY_DOWN, &payload, 1, 1);
134} 135}
diff --git a/keyboards/annepro2/ap2_led.h b/keyboards/annepro2/ap2_led.h
index 23712a2555..b68589d204 100644
--- a/keyboards/annepro2/ap2_led.h
+++ b/keyboards/annepro2/ap2_led.h
@@ -1,18 +1,18 @@
1 /* Copyright 2021 OpenAnnePro community 1 /* Copyright 2021 OpenAnnePro community
2 * 2 *
3 * This program is free software: you can redistribute it and/or modify 3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by 4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or 5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version. 6 * (at your option) any later version.
7 * 7 *
8 * This program is distributed in the hope that it will be useful, 8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 * 12 *
13 * You should have received a copy of the GNU General Public License 13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */ 15 */
16 16
17#pragma once 17#pragma once
18 18
@@ -31,54 +31,63 @@ typedef union {
31 uint8_t pv[4]; 31 uint8_t pv[4];
32 /* 0xrgb in mem is b g r a */ 32 /* 0xrgb in mem is b g r a */
33 uint32_t rgb; 33 uint32_t rgb;
34} annepro2Led_t; 34} ap2_led_t;
35 35
36#define ROWCOL2IDX(row, col) (NUM_COLUMN * (row) + (col)) 36#define ROWCOL2IDX(row, col) (NUM_COLUMN * (row) + (col))
37#define NUM_COLUMN 14 37#define NUM_COLUMN 14
38#define NUM_ROW 5 38#define NUM_ROW 5
39#define KEY_COUNT 70 39#define KEY_COUNT 70
40 40
41/* Local copy of ledMask, used to override colors on the board */ 41/* Local copy of led_mask, used to override colors on the board */
42extern annepro2Led_t ledMask[KEY_COUNT]; 42extern ap2_led_t led_mask[KEY_COUNT];
43extern uint8_t rgb_row_changed[NUM_ROW];
43 44
44/* Handle incoming messages */ 45/* Handle incoming messages */
45extern void ledCommandCallback(const message_t *msg); 46extern void led_command_callback(const message_t *msg);
46 47
47void annepro2SetIAP(void); 48void ap2_set_IAP(void);
48void annepro2LedDisable(void); 49void ap2_led_disable(void);
49void annepro2LedEnable(void); 50void ap2_led_enable(void);
50void annepro2LedSetProfile(uint8_t prof); 51void ap2_led_set_profile(uint8_t prof);
51void annepro2LedGetStatus(void); 52void ap2_led_get_status(void);
52void annepro2LedNextProfile(void); 53void ap2_led_next_profile(void);
53void annepro2LedPrevProfile(void); 54void ap2_led_prev_profile(void);
54void annepro2LedNextIntensity(void); 55void ap2_led_next_intensity(void);
55void annepro2LedNextAnimationSpeed(void); 56void ap2_led_next_animation_speed(void);
56void annepro2LedForwardKeypress(uint8_t row, uint8_t col); 57void ap2_led_forward_keypress(uint8_t row, uint8_t col);
57 58
58/* Set single key to a given color; alpha controls which is displayed */ 59/* Set single key to a given color; alpha controls which is displayed */
59void annepro2LedMaskSetKey(uint8_t row, uint8_t col, annepro2Led_t color); 60void ap2_led_mask_set_key(uint8_t row, uint8_t col, ap2_led_t color);
60/* Push a whole local row to the shine */ 61/* Push a whole local row to the shine */
61void annepro2LedMaskSetRow(uint8_t row); 62void ap2_led_mask_set_row(uint8_t row);
62/* Synchronize all rows */ 63/* Synchronize all rows */
63void annepro2LedMaskSetAll(void); 64void ap2_led_mask_set_all(void);
64 65
65/* Set all keys to a given color */ 66/* Set all keys to a given color */
66void annepro2LedMaskSetMono(annepro2Led_t color); 67void ap2_led_mask_set_mono(ap2_led_t color);
67 68
68/* Blink given key `count` times by masking it with a `color`. Blink takes `hundredths` of a second */ 69/* Blink given key `count` times by masking it with a `color`. Blink takes `hundredths` of a second */
69void annepro2LedBlink(uint8_t row, uint8_t col, annepro2Led_t color, uint8_t count, uint8_t hundredths); 70void ap2_led_blink(uint8_t row, uint8_t col, ap2_led_t color, uint8_t count, uint8_t hundredths);
70 71
71/* Kept for compatibility, but implemented using masks */ 72/* Kept for compatibility, but implemented using masks */
72void annepro2LedSetForegroundColor(uint8_t red, uint8_t green, uint8_t blue); 73void ap2_led_set_foreground_color(uint8_t red, uint8_t green, uint8_t blue);
73void annepro2LedResetForegroundColor(void); 74void ap2_led_reset_foreground_color(void);
74 75
75typedef struct { 76typedef struct {
76 uint8_t amountOfProfiles; 77 uint8_t amount_of_profiles;
77 uint8_t currentProfile; 78 uint8_t current_profile;
78 uint8_t matrixEnabled; 79 uint8_t matrix_enabled;
79 uint8_t isReactive; 80 uint8_t is_reactive;
80 uint8_t ledIntensity; 81 uint8_t led_intensity;
81 uint8_t errors; 82 uint8_t errors;
82} annepro2LedStatus_t; 83} ap2_led_status_t;
83 84
84extern annepro2LedStatus_t annepro2LedStatus; 85extern ap2_led_status_t ap2_led_status;
86
87#ifdef RGB_MATRIX_ENABLE
88/* RGB driver functions */
89void init(void);
90void flush(void);
91void set_color(int index, uint8_t r, uint8_t g, uint8_t b);
92void set_color_all(uint8_t r, uint8_t g, uint8_t b);
93#endif
diff --git a/keyboards/annepro2/c15/config.h b/keyboards/annepro2/c15/config.h
index f28a6a1b53..012b412dc9 100644
--- a/keyboards/annepro2/c15/config.h
+++ b/keyboards/annepro2/c15/config.h
@@ -18,6 +18,7 @@
18#pragma once 18#pragma once
19 19
20#include "pin_defs.h" 20#include "pin_defs.h"
21#include "config_led.h"
21 22
22/* USB Device descriptor parameter */ 23/* USB Device descriptor parameter */
23#define VENDOR_ID 0xfeed 24#define VENDOR_ID 0xfeed
diff --git a/keyboards/annepro2/c15/rules.mk b/keyboards/annepro2/c15/rules.mk
index 554ddc28ce..5cef8b8a87 100644
--- a/keyboards/annepro2/c15/rules.mk
+++ b/keyboards/annepro2/c15/rules.mk
@@ -3,7 +3,9 @@ SRC = \
3 matrix.c \ 3 matrix.c \
4 annepro2_ble.c \ 4 annepro2_ble.c \
5 ap2_led.c \ 5 ap2_led.c \
6 protocol.c 6 protocol.c \
7 rgb_driver.c \
8 config_led.c
7 9
8# MCU 10# MCU
9MCU = cortex-m0plus 11MCU = cortex-m0plus
@@ -24,6 +26,7 @@ NKRO_ENABLE = no
24MOUSEKEY_ENABLE = no 26MOUSEKEY_ENABLE = no
25EXTRAKEY_ENABLE = yes 27EXTRAKEY_ENABLE = yes
26KEY_LOCK_ENABLE = no 28KEY_LOCK_ENABLE = no
29LAYOUTS = 60_ansi
27 30
28# Other featues 31# Other featues
29BOOTMAGIC_ENABLE = no 32BOOTMAGIC_ENABLE = no
diff --git a/keyboards/annepro2/c18/config.h b/keyboards/annepro2/c18/config.h
index f610ef76e4..5887333f2e 100644
--- a/keyboards/annepro2/c18/config.h
+++ b/keyboards/annepro2/c18/config.h
@@ -18,6 +18,7 @@
18#pragma once 18#pragma once
19 19
20#include "pin_defs.h" 20#include "pin_defs.h"
21#include "config_led.h"
21 22
22/* USB Device descriptor parameter */ 23/* USB Device descriptor parameter */
23#define VENDOR_ID 0xfeed 24#define VENDOR_ID 0xfeed
diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk
index b2e16cc35f..afc248dafa 100644
--- a/keyboards/annepro2/c18/rules.mk
+++ b/keyboards/annepro2/c18/rules.mk
@@ -3,7 +3,9 @@ SRC = \
3 matrix.c \ 3 matrix.c \
4 annepro2_ble.c \ 4 annepro2_ble.c \
5 ap2_led.c \ 5 ap2_led.c \
6 protocol.c 6 protocol.c \
7 rgb_driver.c \
8 config_led.c
7 9
8# MCU 10# MCU
9MCU = cortex-m0plus 11MCU = cortex-m0plus
@@ -24,6 +26,7 @@ NKRO_ENABLE = no
24MOUSEKEY_ENABLE = no 26MOUSEKEY_ENABLE = no
25EXTRAKEY_ENABLE = yes 27EXTRAKEY_ENABLE = yes
26KEY_LOCK_ENABLE = no 28KEY_LOCK_ENABLE = no
29LAYOUTS = 60_ansi
27 30
28# Other featues 31# Other featues
29BOOTMAGIC_ENABLE = yes 32BOOTMAGIC_ENABLE = yes
diff --git a/keyboards/annepro2/config_led.c b/keyboards/annepro2/config_led.c
new file mode 100644
index 0000000000..efa68dff3d
--- /dev/null
+++ b/keyboards/annepro2/config_led.c
@@ -0,0 +1,43 @@
1/* Copyright 2022 Jose Pablo Ramirez <jp.ramangulo@gmail.com>
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifdef RGB_MATRIX_ENABLE
18
19#include "rgb_matrix.h"
20#include "config_led.h"
21
22#define NA NO_LED
23
24led_config_t g_led_config = { {
25 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 },
26 { 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 },
27 { 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, NA },
28 { 41, NA, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, NA },
29 { 53, NA, 54, 55, NA, NA, 56, NA, NA, 57, 58, 59, 60, NA }
30}, {
31 { 0 , 0 }, { 16, 0 }, { 32, 0 }, { 48, 0 }, { 65, 0 }, { 81, 0 }, { 97 , 0 }, { 113, 0 }, { 129, 0 }, { 145, 0 }, { 161, 0 }, { 178, 0 }, { 194, 0 }, { 218, 0 },
32 { 4 , 16 }, { 24, 16 }, { 40, 16 }, { 57, 16 }, { 73, 16 }, { 89, 16 }, { 105, 16 }, { 121, 16 }, { 137, 16 }, { 153, 16 }, { 170, 16 }, { 186, 16 }, { 202, 16 }, { 222, 16 },
33 { 6 , 32 }, { 28, 32 }, { 44, 32 }, { 61, 32 }, { 77, 32 }, { 93, 32 }, { 109, 32 }, { 125, 32 }, { 141, 32 }, { 157, 32 }, { 174, 32 }, { 190, 32 }, { 216, 32 },
34 { 10, 48 }, { 36, 48 }, { 52, 48 }, { 69, 48 }, { 85, 48 }, { 101, 48 }, { 117, 48 }, { 133, 48 }, { 149, 48 }, { 165, 48 }, { 182, 48 }, { 212, 48 },
35 { 2 , 64 }, { 22, 64 }, { 42, 64 }, { 103, 64 }, { 163, 64 }, { 184, 64 }, { 204, 64 }, { 224, 64 },
36}, {
37 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
38 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
39 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
40 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
41 1, 1, 1, 4, 1, 1, 1, 1,
42} };
43#endif
diff --git a/keyboards/annepro2/config_led.h b/keyboards/annepro2/config_led.h
new file mode 100644
index 0000000000..19a1dd4baa
--- /dev/null
+++ b/keyboards/annepro2/config_led.h
@@ -0,0 +1,72 @@
1/* Copyright 2022 Jose Pablo Ramirez <jp.ramangulo@gmail.com>
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#pragma once
18
19#ifdef RGB_MATRIX_ENABLE
20
21#define DRIVER_LED_TOTAL 61
22
23/* Limit animations to 62.5 FPS to avoid tearing. (1/.016 = 62.5 FPS). */
24#define RGB_MATRIX_LED_FLUSH_LIMIT 16
25
26#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
27#define RGB_MATRIX_KEYPRESSES
28#define ENABLE_RGB_MATRIX_ALPHAS_MODS
29#define ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN
30#define ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT
31#define ENABLE_RGB_MATRIX_BREATHING
32#define ENABLE_RGB_MATRIX_BAND_SAT
33#define ENABLE_RGB_MATRIX_BAND_VAL
34#define ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT
35#define ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL
36#define ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT
37#define ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL
38#define ENABLE_RGB_MATRIX_CYCLE_ALL
39#define ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
40#define ENABLE_RGB_MATRIX_CYCLE_UP_DOWN
41#define ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
42#define ENABLE_RGB_MATRIX_CYCLE_OUT_IN
43#define ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL
44#define ENABLE_RGB_MATRIX_CYCLE_PINWHEEL
45#define ENABLE_RGB_MATRIX_CYCLE_SPIRAL
46#define ENABLE_RGB_MATRIX_DUAL_BEACON
47#define ENABLE_RGB_MATRIX_RAINBOW_BEACON
48#define ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS
49#define ENABLE_RGB_MATRIX_RAINDROPS
50#define ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
51#define ENABLE_RGB_MATRIX_HUE_BREATHING
52#define ENABLE_RGB_MATRIX_HUE_PENDULUM
53#define ENABLE_RGB_MATRIX_HUE_WAVE
54#define ENABLE_RGB_MATRIX_PIXEL_FRACTAL
55#define ENABLE_RGB_MATRIX_PIXEL_FLOW
56#define ENABLE_RGB_MATRIX_PIXEL_RAIN
57#define ENABLE_RGB_MATRIX_TYPING_HEATMAP
58#define ENABLE_RGB_MATRIX_DIGITAL_RAIN
59#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
60#define ENABLE_RGB_MATRIX_SOLID_REACTIVE
61#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE
62#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE
63#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS
64#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS
65#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS
66#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS
67#define ENABLE_RGB_MATRIX_SPLASH
68#define ENABLE_RGB_MATRIX_MULTISPLASH
69#define ENABLE_RGB_MATRIX_SOLID_SPLASH
70#define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH
71
72#endif
diff --git a/keyboards/annepro2/info.json b/keyboards/annepro2/info.json
index 8fd515bd10..8d6c85b5d1 100644
--- a/keyboards/annepro2/info.json
+++ b/keyboards/annepro2/info.json
@@ -3,7 +3,7 @@
3 "url": "https://openannepro.github.io/", 3 "url": "https://openannepro.github.io/",
4 "maintainer": "community", 4 "maintainer": "community",
5 "layouts": { 5 "layouts": {
6 "LAYOUT": { 6 "LAYOUT_60_ansi": {
7 "layout": [ 7 "layout": [
8 { 8 {
9 "label": "~", 9 "label": "~",
diff --git a/keyboards/annepro2/keymaps/default-full-caps/keymap.c b/keyboards/annepro2/keymaps/default-full-caps/keymap.c
index 8ac9211ac4..c87447d311 100644
--- a/keyboards/annepro2/keymaps/default-full-caps/keymap.c
+++ b/keyboards/annepro2/keymaps/default-full-caps/keymap.c
@@ -1,32 +1,31 @@
1 /* Copyright 2021 OpenAnnePro community 1 /* Copyright 2021 OpenAnnePro community
2 * 2 *
3 * This program is free software: you can redistribute it and/or modify 3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by 4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or 5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version. 6 * (at your option) any later version.
7 * 7 *
8 * This program is distributed in the hope that it will be useful, 8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 * 12 *
13 * You should have received a copy of the GNU General Public License 13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */ 15 */
16 16
17#include QMK_KEYBOARD_H 17#include QMK_KEYBOARD_H
18 18
19enum anne_pro_layers { 19enum anne_pro_layers {
20 _BASE_LAYER, 20 BASE,
21 _FN1_LAYER, 21 FN1,
22 _FN2_LAYER, 22 FN2,
23}; 23};
24 24
25// clang-format off 25// clang-format off
26
27// Key symbols are based on QMK. Use them to remap your keyboard 26// Key symbols are based on QMK. Use them to remap your keyboard
28/* 27/*
29* Layer _BASE_LAYER 28* Layer BASE
30* ,-----------------------------------------------------------------------------------------. 29* ,-----------------------------------------------------------------------------------------.
31* | esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bksp | 30* | esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bksp |
32* |-----------------------------------------------------------------------------------------+ 31* |-----------------------------------------------------------------------------------------+
@@ -38,7 +37,7 @@ enum anne_pro_layers {
38* |-----------------------------------------------------------------------------------------+ 37* |-----------------------------------------------------------------------------------------+
39* | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl | 38* | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl |
40* \-----------------------------------------------------------------------------------------/ 39* \-----------------------------------------------------------------------------------------/
41* Layer TAP in _BASE_LAYER 40* Layer TAP in BASE
42* ,-----------------------------------------------------------------------------------------. 41* ,-----------------------------------------------------------------------------------------.
43* | | | | | | | | | | | | | | | 42* | | | | | | | | | | | | | | |
44* |-----------------------------------------------------------------------------------------+ 43* |-----------------------------------------------------------------------------------------+
@@ -52,15 +51,15 @@ enum anne_pro_layers {
52* \-----------------------------------------------------------------------------------------/ 51* \-----------------------------------------------------------------------------------------/
53*/ 52*/
54 const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 53 const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
55 [_BASE_LAYER] = LAYOUT( /* Base */ 54 [BASE] = LAYOUT_60_ansi( /* Base */
56 KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, 55 KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC,
57 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, 56 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS,
58 LT(_FN1_LAYER,KC_CAPS), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, 57 LT(FN1, KC_CAPS), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT,
59 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_UP), 58 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_UP),
60 KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LT(_FN1_LAYER,KC_LEFT), LT(_FN2_LAYER,KC_DOWN), RCTL_T(KC_RGHT) 59 KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LT(FN1, KC_LEFT), LT(FN2, KC_DOWN), RCTL_T(KC_RGHT)
61), 60),
62 /* 61 /*
63 * Layer _FN1_LAYER 62 * Layer FN1
64 * ,-----------------------------------------------------------------------------------------. 63 * ,-----------------------------------------------------------------------------------------.
65 * | ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE | 64 * | ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE |
66 * |-----------------------------------------------------------------------------------------+ 65 * |-----------------------------------------------------------------------------------------+
@@ -74,15 +73,15 @@ enum anne_pro_layers {
74 * \-----------------------------------------------------------------------------------------/ 73 * \-----------------------------------------------------------------------------------------/
75 * 74 *
76 */ 75 */
77 [_FN1_LAYER] = LAYOUT( /* Base */ 76 [FN1] = LAYOUT_60_ansi( /* FN1 */
78 KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, 77 KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL,
79 KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, 78 _______, _______, KC_UP, _______, _______, _______, _______, _______, _______, _______, KC_PSCR, KC_HOME, KC_END, _______,
80 KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, 79 _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, _______, KC_PGUP, KC_PGDN, _______,
81 KC_TRNS, KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, 80 _______, KC_VOLU, KC_VOLD, KC_MUTE, _______, _______, _______, _______, _______, KC_INS, KC_DEL, _______,
82 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN2_LAYER), KC_TRNS 81 _______, _______, _______, _______, _______, _______, MO(FN2), _______
83), 82),
84 /* 83 /*
85 * Layer _FN2_LAYER 84 * Layer FN2
86 * ,-----------------------------------------------------------------------------------------. 85 * ,-----------------------------------------------------------------------------------------.
87 * | ~ | BT1 | BT2 | BT3 | BT4 | F5 | F6 | F7 |LEDOF|LEDON| F10 | F11 | F12 | Bksp | 86 * | ~ | BT1 | BT2 | BT3 | BT4 | F5 | F6 | F7 |LEDOF|LEDON| F10 | F11 | F12 | Bksp |
88 * |-----------------------------------------------------------------------------------------+ 87 * |-----------------------------------------------------------------------------------------+
@@ -96,24 +95,23 @@ enum anne_pro_layers {
96 * \-----------------------------------------------------------------------------------------/ 95 * \-----------------------------------------------------------------------------------------/
97 * 96 *
98 */ 97 */
99 [_FN2_LAYER] = LAYOUT( /* Base */ 98 [FN2] = LAYOUT_60_ansi( /* FN2 */
100 KC_TRNS, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_AP_LED_NEXT_INTENSITY, KC_AP_LED_SPEED, KC_TRNS, KC_TRNS, 99 _______, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, _______, _______, _______, KC_AP_LED_OFF, KC_AP_LED_ON, _______, _______, _______, _______,
101 MO(_FN2_LAYER), KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, 100 MO(FN2), _______, KC_UP, _______, _______, _______, _______, _______, _______, _______, KC_PSCR, KC_HOME, KC_END, _______,
102 KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, 101 _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, _______, KC_PGUP, KC_PGDN, _______,
103 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, 102 _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_INS, KC_DEL, _______,
104 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN1_LAYER), MO(_FN2_LAYER), KC_TRNS 103 _______, _______, _______, _______, _______, MO(FN1), MO(FN2), _______
105 ), 104 ),
106}; 105};
107
108// clang-format on 106// clang-format on
109 107
110// The function to handle the caps lock logic 108// The function to handle the caps lock logic
111bool led_update_user(led_t leds) { 109bool led_update_user(led_t leds) {
112 if (leds.caps_lock) { 110 if (leds.caps_lock) {
113 // Set the leds to red 111 // Set the leds to red
114 annepro2LedSetForegroundColor(0xFF, 0x00, 0x00); 112 ap2_led_set_foreground_color(0xFF, 0x00, 0x00);
115 } else { 113 } else {
116 annepro2LedResetForegroundColor(); 114 ap2_led_reset_foreground_color();
117 } 115 }
118 116
119 return true; 117 return true;
diff --git a/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c b/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c
index ac2b421d06..405769466a 100644
--- a/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c
+++ b/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c
@@ -1,32 +1,31 @@
1 /* Copyright 2021 OpenAnnePro community 1 /* Copyright 2021 OpenAnnePro community
2 * 2 *
3 * This program is free software: you can redistribute it and/or modify 3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by 4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or 5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version. 6 * (at your option) any later version.
7 * 7 *
8 * This program is distributed in the hope that it will be useful, 8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 * 12 *
13 * You should have received a copy of the GNU General Public License 13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */ 15 */
16 16
17#include QMK_KEYBOARD_H 17#include QMK_KEYBOARD_H
18 18
19enum anne_pro_layers { 19enum anne_pro_layers {
20 _BASE_LAYER, 20 BASE,
21 _FN1_LAYER, 21 FN1,
22 _FN2_LAYER, 22 FN2,
23}; 23};
24 24
25// clang-format off 25// clang-format off
26
27// Key symbols are based on QMK. Use them to remap your keyboard 26// Key symbols are based on QMK. Use them to remap your keyboard
28/* 27/*
29* Layer _BASE_LAYER 28* Layer BASE
30* ,-----------------------------------------------------------------------------------------. 29* ,-----------------------------------------------------------------------------------------.
31* | esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bksp | 30* | esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bksp |
32* |-----------------------------------------------------------------------------------------+ 31* |-----------------------------------------------------------------------------------------+
@@ -38,7 +37,7 @@ enum anne_pro_layers {
38* |-----------------------------------------------------------------------------------------+ 37* |-----------------------------------------------------------------------------------------+
39* | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl | 38* | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl |
40* \-----------------------------------------------------------------------------------------/ 39* \-----------------------------------------------------------------------------------------/
41* Layer TAP in _BASE_LAYER 40* Layer TAP in BASE
42* ,-----------------------------------------------------------------------------------------. 41* ,-----------------------------------------------------------------------------------------.
43* | | | | | | | | | | | | | | | 42* | | | | | | | | | | | | | | |
44* |-----------------------------------------------------------------------------------------+ 43* |-----------------------------------------------------------------------------------------+
@@ -52,15 +51,15 @@ enum anne_pro_layers {
52* \-----------------------------------------------------------------------------------------/ 51* \-----------------------------------------------------------------------------------------/
53*/ 52*/
54 const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 53 const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
55 [_BASE_LAYER] = LAYOUT( /* Base */ 54 [BASE] = LAYOUT_60_ansi( /* Base */
56 KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, 55 KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC,
57 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, 56 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS,
58 LT(_FN1_LAYER,KC_CAPS), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, 57 LT(FN1, KC_CAPS), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT,
59 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_UP), 58 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_UP),
60 KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LT(_FN1_LAYER,KC_LEFT), LT(_FN2_LAYER,KC_DOWN), RCTL_T(KC_RGHT) 59 KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LT(FN1, KC_LEFT), LT(FN2, KC_DOWN), RCTL_T(KC_RGHT)
61), 60),
62 /* 61 /*
63 * Layer _FN1_LAYER 62 * Layer FN1
64 * ,-----------------------------------------------------------------------------------------. 63 * ,-----------------------------------------------------------------------------------------.
65 * | ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE | 64 * | ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE |
66 * |-----------------------------------------------------------------------------------------+ 65 * |-----------------------------------------------------------------------------------------+
@@ -74,15 +73,15 @@ enum anne_pro_layers {
74 * \-----------------------------------------------------------------------------------------/ 73 * \-----------------------------------------------------------------------------------------/
75 * 74 *
76 */ 75 */
77 [_FN1_LAYER] = LAYOUT( /* Base */ 76 [FN1] = LAYOUT_60_ansi( /* FN1 */
78 KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, 77 KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL,
79 KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, 78 _______, _______, KC_UP, _______, _______, _______, _______, _______, _______, _______, KC_PSCR, KC_HOME, KC_END, _______,
80 KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, 79 _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, _______, KC_PGUP, KC_PGDN, _______,
81 KC_TRNS, KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, 80 _______, KC_VOLU, KC_VOLD, KC_MUTE, _______, _______, _______, _______, _______, KC_INS, KC_DEL, _______,
82 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN2_LAYER), KC_TRNS 81 _______, _______, _______, _______, _______, _______, MO(FN2), _______
83), 82),
84 /* 83 /*
85 * Layer _FN2_LAYER 84 * Layer FN2
86 * ,-----------------------------------------------------------------------------------------. 85 * ,-----------------------------------------------------------------------------------------.
87 * | ~ | BT1 | BT2 | BT3 | BT4 | F5 | F6 | F7 |LEDOF|LEDON| F10 | F11 | F12 | Bksp | 86 * | ~ | BT1 | BT2 | BT3 | BT4 | F5 | F6 | F7 |LEDOF|LEDON| F10 | F11 | F12 | Bksp |
88 * |-----------------------------------------------------------------------------------------+ 87 * |-----------------------------------------------------------------------------------------+
@@ -96,30 +95,29 @@ enum anne_pro_layers {
96 * \-----------------------------------------------------------------------------------------/ 95 * \-----------------------------------------------------------------------------------------/
97 * 96 *
98 */ 97 */
99 [_FN2_LAYER] = LAYOUT( /* Base */ 98 [FN2] = LAYOUT_60_ansi( /* FN2 */
100 KC_TRNS, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_AP_LED_NEXT_INTENSITY, KC_AP_LED_SPEED, KC_TRNS, KC_TRNS, 99 _______, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, _______, _______, _______, KC_AP_LED_OFF, KC_AP_LED_ON, _______, _______, _______, _______,
101 MO(_FN2_LAYER), KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, 100 MO(FN2), _______, KC_UP, _______, _______, _______, _______, _______, _______, _______, KC_PSCR, KC_HOME, KC_END, _______,
102 KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, 101 _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, _______, KC_PGUP, KC_PGDN, _______,
103 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, 102 _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_INS, KC_DEL, _______,
104 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN1_LAYER), MO(_FN2_LAYER), KC_TRNS 103 _______, _______, _______, _______, _______, MO(FN1), MO(FN2), _______
105 ), 104 ),
106}; 105};
107
108// clang-format on 106// clang-format on
109 107
110layer_state_t layer_state_set_user(layer_state_t state) { 108layer_state_t layer_state_set_user(layer_state_t state) {
111 switch (get_highest_layer(state)) { 109 switch (get_highest_layer(state)) {
112 case _FN1_LAYER: 110 case FN1:
113 // Set the leds to green 111 // Set the leds to green
114 annepro2LedSetForegroundColor(0x00, 0xFF, 0x00); 112 ap2_led_set_foreground_color(0x00, 0xFF, 0x00);
115 break; 113 break;
116 case _FN2_LAYER: 114 case FN2:
117 // Set the leds to blue 115 // Set the leds to blue
118 annepro2LedSetForegroundColor(0x00, 0x00, 0xFF); 116 ap2_led_set_foreground_color(0x00, 0x00, 0xFF);
119 break; 117 break;
120 default: 118 default:
121 // Reset back to the current profile 119 // Reset back to the current profile
122 annepro2LedResetForegroundColor(); 120 ap2_led_reset_foreground_color();
123 break; 121 break;
124 } 122 }
125 return state; 123 return state;
@@ -130,16 +128,16 @@ layer_state_t layer_state_set_user(layer_state_t state) {
130bool led_update_user(led_t leds) { 128bool led_update_user(led_t leds) {
131 if (leds.caps_lock) { 129 if (leds.caps_lock) {
132 // Set the caps-lock to red 130 // Set the caps-lock to red
133 const annepro2Led_t color = {.p.red = 0xff, .p.green = 0x00, .p.blue = 0x00, .p.alpha = 0xff}; 131 const ap2_led_t color = {.p.red = 0xff, .p.green = 0x00, .p.blue = 0x00, .p.alpha = 0xff};
134 132
135 annepro2LedMaskSetKey(2, 0, color); 133 ap2_led_mask_set_key(2, 0, color);
136 /* NOTE: Instead of colouring the capslock only, you can change the whole 134 /* NOTE: Instead of colouring the capslock only, you can change the whole
137 keyboard with annepro2LedSetForegroundColor */ 135 keyboard with ap2_led_set_foreground_color */
138 } else { 136 } else {
139 // Reset the capslock if there is no layer active 137 // Reset the capslock if there is no layer active
140 if (!layer_state_is(_FN1_LAYER) && !layer_state_is(_FN2_LAYER)) { 138 if (!layer_state_is(FN1) && !layer_state_is(FN2)) {
141 const annepro2Led_t color = {.p.red = 0xff, .p.green = 0x00, .p.blue = 0x00, .p.alpha = 0x00}; 139 const ap2_led_t color = {.p.red = 0xff, .p.green = 0x00, .p.blue = 0x00, .p.alpha = 0x00};
142 annepro2LedMaskSetKey(2, 0, color); 140 ap2_led_mask_set_key(2, 0, color);
143 } 141 }
144 } 142 }
145 143
diff --git a/keyboards/annepro2/keymaps/default/keymap.c b/keyboards/annepro2/keymaps/default/keymap.c
index a984b05830..8f5b639bb8 100644
--- a/keyboards/annepro2/keymaps/default/keymap.c
+++ b/keyboards/annepro2/keymaps/default/keymap.c
@@ -1,31 +1,31 @@
1 /* Copyright 2021 OpenAnnePro community 1 /* Copyright 2021 OpenAnnePro community
2 * 2 *
3 * This program is free software: you can redistribute it and/or modify 3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by 4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or 5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version. 6 * (at your option) any later version.
7 * 7 *
8 * This program is distributed in the hope that it will be useful, 8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 * 12 *
13 * You should have received a copy of the GNU General Public License 13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */ 15 */
16 16
17#include QMK_KEYBOARD_H 17#include QMK_KEYBOARD_H
18 18
19enum anne_pro_layers { 19enum anne_pro_layers {
20 _BASE_LAYER, 20 BASE,
21 _FN1_LAYER, 21 FN1,
22 _FN2_LAYER, 22 FN2,
23}; 23};
24 24
25// clang-format off 25// clang-format off
26// Key symbols are based on QMK. Use them to remap your keyboard 26// Key symbols are based on QMK. Use them to remap your keyboard
27/* 27/*
28* Layer _BASE_LAYER 28* Layer BASE
29* ,-----------------------------------------------------------------------------------------. 29* ,-----------------------------------------------------------------------------------------.
30* | esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bksp | 30* | esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bksp |
31* |-----------------------------------------------------------------------------------------+ 31* |-----------------------------------------------------------------------------------------+
@@ -37,7 +37,7 @@ enum anne_pro_layers {
37* |-----------------------------------------------------------------------------------------+ 37* |-----------------------------------------------------------------------------------------+
38* | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl | 38* | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl |
39* \-----------------------------------------------------------------------------------------/ 39* \-----------------------------------------------------------------------------------------/
40* Layer TAP in _BASE_LAYER 40* Layer TAP in BASE
41* ,-----------------------------------------------------------------------------------------. 41* ,-----------------------------------------------------------------------------------------.
42* | | | | | | | | | | | | | | | 42* | | | | | | | | | | | | | | |
43* |-----------------------------------------------------------------------------------------+ 43* |-----------------------------------------------------------------------------------------+
@@ -51,15 +51,15 @@ enum anne_pro_layers {
51* \-----------------------------------------------------------------------------------------/ 51* \-----------------------------------------------------------------------------------------/
52*/ 52*/
53 const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 53 const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
54 [_BASE_LAYER] = LAYOUT( /* Base */ 54 [BASE] = LAYOUT_60_ansi( /* Base */
55 KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, 55 KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC,
56 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, 56 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS,
57 LT(_FN1_LAYER,KC_CAPS), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, 57 LT(FN1, KC_CAPS), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT,
58 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_UP), 58 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_UP),
59 KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LT(_FN1_LAYER,KC_LEFT), LT(_FN2_LAYER,KC_DOWN), RCTL_T(KC_RGHT) 59 KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LT(FN1, KC_LEFT), LT(FN2, KC_DOWN), RCTL_T(KC_RGHT)
60), 60),
61 /* 61 /*
62 * Layer _FN1_LAYER 62 * Layer FN1
63 * ,-----------------------------------------------------------------------------------------. 63 * ,-----------------------------------------------------------------------------------------.
64 * | ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE | 64 * | ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE |
65 * |-----------------------------------------------------------------------------------------+ 65 * |-----------------------------------------------------------------------------------------+
@@ -73,17 +73,17 @@ enum anne_pro_layers {
73 * \-----------------------------------------------------------------------------------------/ 73 * \-----------------------------------------------------------------------------------------/
74 * 74 *
75 */ 75 */
76 [_FN1_LAYER] = LAYOUT( /* Base */ 76 [FN1] = LAYOUT_60_ansi( /* FN1 */
77 KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, 77 KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL,
78 KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, 78 _______, _______, KC_UP, _______, _______, _______, _______, _______, _______, _______, KC_PSCR, KC_HOME, KC_END, _______,
79 KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, 79 _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, _______, KC_PGUP, KC_PGDN, _______,
80 KC_TRNS, KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, 80 _______, KC_VOLU, KC_VOLD, KC_MUTE, _______, _______, _______, _______, _______, KC_INS, KC_DEL, _______,
81 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN2_LAYER), KC_TRNS 81 _______, _______, _______, _______, _______, _______, MO(FN2), _______
82), 82),
83 /* 83 /*
84 * Layer _FN2_LAYER 84 * Layer FN2
85 * ,-----------------------------------------------------------------------------------------. 85 * ,-----------------------------------------------------------------------------------------.
86 * | ~ | BT1 | BT2 | BT3 | BT4 | F5 | F6 | F7 |LEDOF|LEDON| F10 | F11 | F12 | Bksp | 86 * | ~ | BT1 | BT2 | BT3 | BT4 | F5 | F6 | HUE | SAT | BRI | SPD | MOD | TOG | Bksp |
87 * |-----------------------------------------------------------------------------------------+ 87 * |-----------------------------------------------------------------------------------------+
88 * | Tab | q | UP | e | r | t | y | u | i | o | PS | HOME | END | \ | 88 * | Tab | q | UP | e | r | t | y | u | i | o | PS | HOME | END | \ |
89 * |-----------------------------------------------------------------------------------------+ 89 * |-----------------------------------------------------------------------------------------+
@@ -95,12 +95,12 @@ enum anne_pro_layers {
95 * \-----------------------------------------------------------------------------------------/ 95 * \-----------------------------------------------------------------------------------------/
96 * 96 *
97 */ 97 */
98 [_FN2_LAYER] = LAYOUT( /* Base */ 98 [FN2] = LAYOUT_60_ansi( /* FN2 */
99 KC_TRNS, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_AP_LED_NEXT_INTENSITY, KC_AP_LED_SPEED, KC_TRNS, KC_TRNS, 99 _______, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, _______, _______, RGB_HUI, RGB_SAI, RGB_VAI, RGB_SPI, RGB_MOD, RGB_TOG, _______,
100 MO(_FN2_LAYER), KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, 100 MO(FN2), _______, KC_UP, _______, _______, _______, _______, _______, _______, _______, KC_PSCR, KC_HOME, KC_END, _______,
101 KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, 101 _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, _______, KC_PGUP, KC_PGDN, _______,
102 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, 102 _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_INS, KC_DEL, _______,
103 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN1_LAYER), MO(_FN2_LAYER), KC_TRNS 103 _______, _______, _______, _______, _______, MO(FN1), MO(FN2), _______
104 ), 104 ),
105}; 105};
106// clang-format on 106// clang-format on
diff --git a/keyboards/annepro2/keymaps/default/rules.mk b/keyboards/annepro2/keymaps/default/rules.mk
new file mode 100644
index 0000000000..ca1110b835
--- /dev/null
+++ b/keyboards/annepro2/keymaps/default/rules.mk
@@ -0,0 +1,3 @@
1# Custom RGB matrix handling
2RGB_MATRIX_ENABLE = yes
3RGB_MATRIX_DRIVER = custom
diff --git a/keyboards/annepro2/protocol.c b/keyboards/annepro2/protocol.c
index 171ac5c239..ff30658cd7 100644
--- a/keyboards/annepro2/protocol.c
+++ b/keyboards/annepro2/protocol.c
@@ -20,38 +20,38 @@
20/* UART communication protocol state */ 20/* UART communication protocol state */
21protocol_t proto; 21protocol_t proto;
22 22
23void protoInit(protocol_t *proto, void (*callback)(const message_t *)) { 23void proto_init(protocol_t *proto, void (*callback)(const message_t *)) {
24 proto->previousId = 0; 24 proto->previous_id = 0;
25 proto->callback = callback; 25 proto->callback = callback;
26 proto->state = STATE_SYNC_1; 26 proto->state = STATE_SYNC_1;
27 proto->errors = 0; 27 proto->errors = 0;
28} 28}
29 29
30static uint8_t msgId = 0; 30static uint8_t msg_id = 0;
31void protoTx(uint8_t cmd, const unsigned char *buf, int payloadSize, int retries) { 31void proto_tx(uint8_t cmd, const unsigned char *buf, int payload_size, int retries) {
32 chDbgCheck(payloadSize <= MAX_PAYLOAD_SIZE); 32 chDbgCheck(payload_size <= MAX_PAYLOAD_SIZE);
33 33
34 const uint8_t header[5] = { 34 const uint8_t header[5] = {
35 0x7A, 0x1D, cmd, ++msgId, payloadSize, 35 0x7A, 0x1D, cmd, ++msg_id, payload_size,
36 }; 36 };
37 37
38 /* We don't implement ACKs, yet some messages should not be lost. */ 38 /* We don't implement ACKs, yet some messages should not be lost. */
39 for (int i = 0; i < retries; i++) { 39 for (int i = 0; i < retries; i++) {
40 sdWrite(&PROTOCOL_SD, header, sizeof(header)); 40 sdWrite(&PROTOCOL_SD, header, sizeof(header));
41 if (payloadSize) sdWrite(&PROTOCOL_SD, buf, payloadSize); 41 if (payload_size) sdWrite(&PROTOCOL_SD, buf, payload_size);
42 } 42 }
43} 43}
44 44
45static inline void messageReceived(protocol_t *proto) { 45static inline void messageReceived(protocol_t *proto) {
46 if (proto->buffer.msgId != proto->previousId) { 46 if (proto->buffer.msg_id != proto->previous_id) {
47 /* It's not a resend / duplicate */ 47 /* It's not a resend / duplicate */
48 proto->callback(&proto->buffer); 48 proto->callback(&proto->buffer);
49 proto->previousId = proto->buffer.msgId; 49 proto->previous_id = proto->buffer.msg_id;
50 } 50 }
51 proto->state = STATE_SYNC_1; 51 proto->state = STATE_SYNC_1;
52} 52}
53 53
54void protoConsume(protocol_t *proto, uint8_t byte) { 54void proto_consume(protocol_t *proto, uint8_t byte) {
55 switch (proto->state) { 55 switch (proto->state) {
56 case STATE_SYNC_1: 56 case STATE_SYNC_1:
57 if (byte == 0x7A) { 57 if (byte == 0x7A) {
@@ -76,18 +76,18 @@ void protoConsume(protocol_t *proto, uint8_t byte) {
76 return; 76 return;
77 77
78 case STATE_ID: 78 case STATE_ID:
79 proto->buffer.msgId = byte; 79 proto->buffer.msg_id = byte;
80 proto->state = STATE_PAYLOAD_SIZE; 80 proto->state = STATE_PAYLOAD_SIZE;
81 return; 81 return;
82 82
83 case STATE_PAYLOAD_SIZE: 83 case STATE_PAYLOAD_SIZE:
84 proto->buffer.payloadSize = byte; 84 proto->buffer.payload_size = byte;
85 if (proto->buffer.payloadSize > MAX_PAYLOAD_SIZE) { 85 if (proto->buffer.payload_size > MAX_PAYLOAD_SIZE) {
86 proto->buffer.payloadSize = MAX_PAYLOAD_SIZE; 86 proto->buffer.payload_size = MAX_PAYLOAD_SIZE;
87 proto->errors++; 87 proto->errors++;
88 } 88 }
89 proto->payloadPosition = 0; 89 proto->payload_position = 0;
90 if (proto->buffer.payloadSize == 0) { 90 if (proto->buffer.payload_size == 0) {
91 /* No payload - whole message received */ 91 /* No payload - whole message received */
92 messageReceived(proto); 92 messageReceived(proto);
93 } else { 93 } else {
@@ -98,9 +98,9 @@ void protoConsume(protocol_t *proto, uint8_t byte) {
98 case STATE_PAYLOAD: 98 case STATE_PAYLOAD:
99 /* NOTE: This could be read with sdReadTimeout probably, but that breaks 99 /* NOTE: This could be read with sdReadTimeout probably, but that breaks
100 * abstraction */ 100 * abstraction */
101 proto->buffer.payload[proto->payloadPosition] = byte; 101 proto->buffer.payload[proto->payload_position] = byte;
102 proto->payloadPosition++; 102 proto->payload_position++;
103 if (proto->payloadPosition == proto->buffer.payloadSize) { 103 if (proto->payload_position == proto->buffer.payload_size) {
104 /* Payload read - message received */ 104 /* Payload read - message received */
105 messageReceived(proto); 105 messageReceived(proto);
106 } 106 }
@@ -108,7 +108,7 @@ void protoConsume(protocol_t *proto, uint8_t byte) {
108 } 108 }
109} 109}
110 110
111void protoSilence(protocol_t *proto) { 111void proto_silence(protocol_t *proto) {
112 if (proto->state != STATE_SYNC_1) { 112 if (proto->state != STATE_SYNC_1) {
113 proto->state = STATE_SYNC_1; 113 proto->state = STATE_SYNC_1;
114 proto->errors++; 114 proto->errors++;
diff --git a/keyboards/annepro2/protocol.h b/keyboards/annepro2/protocol.h
index d1a05683c8..208fcd806c 100644
--- a/keyboards/annepro2/protocol.h
+++ b/keyboards/annepro2/protocol.h
@@ -55,7 +55,7 @@ enum {
55#define MAX_PAYLOAD_SIZE 64 55#define MAX_PAYLOAD_SIZE 64
56 56
57/** Enum of the states used for the serial protocol finite-state automaton */ 57/** Enum of the states used for the serial protocol finite-state automaton */
58enum protoState { 58enum proto_state {
59 /* 2-byte initial start-of-message sync */ 59 /* 2-byte initial start-of-message sync */
60 STATE_SYNC_1, 60 STATE_SYNC_1,
61 STATE_SYNC_2, 61 STATE_SYNC_2,
@@ -65,15 +65,15 @@ enum protoState {
65 STATE_ID, 65 STATE_ID,
66 /* Waiting for payload size */ 66 /* Waiting for payload size */
67 STATE_PAYLOAD_SIZE, 67 STATE_PAYLOAD_SIZE,
68 /* Reading payload until payloadPosition == payloadSize */ 68 /* Reading payload until payload_position == payload_size */
69 STATE_PAYLOAD, 69 STATE_PAYLOAD,
70}; 70};
71 71
72/* Buffer holding a single message */ 72/* Buffer holding a single message */
73typedef struct { 73typedef struct {
74 uint8_t command; 74 uint8_t command;
75 uint8_t msgId; 75 uint8_t msg_id;
76 uint8_t payloadSize; 76 uint8_t payload_size;
77 uint8_t payload[MAX_PAYLOAD_SIZE]; 77 uint8_t payload[MAX_PAYLOAD_SIZE];
78} message_t; 78} message_t;
79 79
@@ -83,12 +83,12 @@ typedef struct {
83 void (*callback)(const message_t *); 83 void (*callback)(const message_t *);
84 84
85 /* Number of read payload bytes */ 85 /* Number of read payload bytes */
86 uint8_t payloadPosition; 86 uint8_t payload_position;
87 87
88 /* Current finite-state-automata state */ 88 /* Current finite-state-automata state */
89 enum protoState state; 89 enum proto_state state;
90 90
91 uint8_t previousId; 91 uint8_t previous_id;
92 uint8_t errors; 92 uint8_t errors;
93 93
94 /* Currently received message */ 94 /* Currently received message */
@@ -99,13 +99,13 @@ typedef struct {
99extern protocol_t proto; 99extern protocol_t proto;
100 100
101/* Init state */ 101/* Init state */
102extern void protoInit(protocol_t *proto, void (*callback)(const message_t *)); 102extern void proto_init(protocol_t *proto, void (*callback)(const message_t *));
103 103
104/* Consume one byte and push state forward - might call the callback */ 104/* Consume one byte and push state forward - might call the callback */
105extern void protoConsume(protocol_t *proto, uint8_t byte); 105extern void proto_consume(protocol_t *proto, uint8_t byte);
106 106
107/* Prolonged silence - reset state */ 107/* Prolonged silence - reset state */
108extern void protoSilence(protocol_t *proto); 108extern void proto_silence(protocol_t *proto);
109 109
110/* Transmit message */ 110/* Transmit message */
111extern void protoTx(uint8_t cmd, const unsigned char *buf, int payloadSize, int retries); 111extern void proto_tx(uint8_t cmd, const unsigned char *buf, int payload_size, int retries);
diff --git a/keyboards/annepro2/rgb_driver.c b/keyboards/annepro2/rgb_driver.c
new file mode 100644
index 0000000000..240a5f4e5b
--- /dev/null
+++ b/keyboards/annepro2/rgb_driver.c
@@ -0,0 +1,66 @@
1/* Copyright 2022 Jose Pablo Ramirez <jp.ramangulo@gmail.com>
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifdef RGB_MATRIX_ENABLE
18
19#include "rgb_matrix.h"
20#include "ap2_led.h"
21
22uint8_t led_pos[DRIVER_LED_TOTAL];
23
24void init(void) {
25 unsigned int i = 0;
26 for (unsigned int y = 0; y < NUM_ROW; y++) {
27 for (unsigned int x = 0; x < NUM_COLUMN; x++) {
28 if (g_led_config.matrix_co[y][x] != NO_LED) {
29 led_pos[g_led_config.matrix_co[y][x]] = i;
30 }
31 i++;
32 }
33 }
34}
35
36void flush(void) {}
37
38void set_color(int index, uint8_t r, uint8_t g, uint8_t b) {
39 if (r != led_mask[led_pos[index]].p.red ||
40 g != led_mask[led_pos[index]].p.green ||
41 b != led_mask[led_pos[index]].p.blue)
42 {
43 led_mask[led_pos[index]] = (ap2_led_t){
44 .p.blue = b,
45 .p.red = r,
46 .p.green = g,
47 .p.alpha = 0xff,
48 };
49 int row = led_pos[index] / NUM_COLUMN;
50 rgb_row_changed[row] = 1;
51 }
52}
53
54void set_color_all(uint8_t r, uint8_t g, uint8_t b) {
55 for (int i=0; i<DRIVER_LED_TOTAL; i++)
56 set_color(i, r, g, b);
57}
58
59const rgb_matrix_driver_t rgb_matrix_driver = {
60 .init = init,
61 .flush = flush,
62 .set_color = set_color,
63 .set_color_all = set_color_all,
64};
65
66#endif