diff options
-rw-r--r-- | keyboards/annepro2/annepro2.c | 92 | ||||
-rw-r--r-- | keyboards/annepro2/annepro2.h | 6 | ||||
-rw-r--r-- | keyboards/annepro2/annepro2_ble.c | 34 | ||||
-rw-r--r-- | keyboards/annepro2/ap2_led.c | 79 | ||||
-rw-r--r-- | keyboards/annepro2/ap2_led.h | 93 | ||||
-rw-r--r-- | keyboards/annepro2/c15/config.h | 1 | ||||
-rw-r--r-- | keyboards/annepro2/c15/rules.mk | 5 | ||||
-rw-r--r-- | keyboards/annepro2/c18/config.h | 1 | ||||
-rw-r--r-- | keyboards/annepro2/c18/rules.mk | 5 | ||||
-rw-r--r-- | keyboards/annepro2/config_led.c | 43 | ||||
-rw-r--r-- | keyboards/annepro2/config_led.h | 72 | ||||
-rw-r--r-- | keyboards/annepro2/info.json | 2 | ||||
-rw-r--r-- | keyboards/annepro2/keymaps/default-full-caps/keymap.c | 84 | ||||
-rw-r--r-- | keyboards/annepro2/keymaps/default-layer-indicators/keymap.c | 102 | ||||
-rw-r--r-- | keyboards/annepro2/keymaps/default/keymap.c | 80 | ||||
-rw-r--r-- | keyboards/annepro2/keymaps/default/rules.mk | 3 | ||||
-rw-r--r-- | keyboards/annepro2/protocol.c | 40 | ||||
-rw-r--r-- | keyboards/annepro2/protocol.h | 22 | ||||
-rw-r--r-- | keyboards/annepro2/rgb_driver.c | 66 |
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 @@ #define RAM_MAGIC_LOCATION 0x20001ffc #define IAP_MAGIC_VALUE 0x0000fab2 -static const SerialConfig ledUartInitConfig = { +static const SerialConfig led_uart_init_config = { .speed = 115200, }; @@ -32,21 +32,25 @@ static const SerialConfig ledUartInitConfig = { # define LED_UART_BAUD_RATE 115200 #endif // LED_UART_BAUD_RATE -static const SerialConfig ledUartRuntimeConfig = { +static const SerialConfig led_uart_runtine_config = { .speed = LED_UART_BAUD_RATE, }; -static const SerialConfig bleUartConfig = { +static const SerialConfig ble_uart_config = { .speed = 115200, }; -static uint8_t ledMcuWakeup[11] = {0x7b, 0x10, 0x43, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x02}; +static uint8_t led_mcu_wakeup[11] = {0x7b, 0x10, 0x43, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x02}; -ble_capslock_t BLECapsLock = {._dummy = {0}, .caps_lock = false}; +ble_capslock_t ble_capslock = {._dummy = {0}, .caps_lock = false}; + +#ifdef RGB_MATRIX_ENABLE +static uint8_t current_rgb_row = 0; +#endif void bootloader_jump(void) { // Send msg to shine to boot into IAP - annepro2SetIAP(); + ap2_set_IAP(); // wait for shine to boot into IAP wait_ms(15); @@ -67,27 +71,27 @@ void bootloader_jump(void) { void keyboard_pre_init_kb(void) { // Start LED UART - sdStart(&SD0, &ledUartInitConfig); + sdStart(&SD0, &led_uart_init_config); /* Let the LED chip settle a bit before switching the mode. * That helped at least one person. */ wait_ms(15); - sdWrite(&SD0, ledMcuWakeup, sizeof(ledMcuWakeup)); + sdWrite(&SD0, led_mcu_wakeup, sizeof(led_mcu_wakeup)); // wait to receive response from wakeup wait_ms(15); - protoInit(&proto, ledCommandCallback); + proto_init(&proto, led_command_callback); // loop to clear out receive buffer from shine wakeup while (!sdGetWouldBlock(&SD0)) sdGet(&SD0); - sdStart(&SD0, &ledUartRuntimeConfig); + sdStart(&SD0, &led_uart_runtine_config); keyboard_pre_init_user(); } void keyboard_post_init_kb(void) { // Start BLE UART - sdStart(&SD1, &bleUartConfig); + sdStart(&SD1, &ble_uart_config); annepro2_ble_startup(); // Give the send uart thread some time to @@ -97,7 +101,11 @@ void keyboard_post_init_kb(void) { // loop to clear out receive buffer from ble wakeup while (!sdGetWouldBlock(&SD1)) sdGet(&SD1); - annepro2LedGetStatus(); + ap2_led_get_status(); + + #ifdef RGB_MATRIX_ENABLE + ap2_led_enable(); + #endif keyboard_post_init_user(); } @@ -106,25 +114,35 @@ void matrix_scan_kb() { // if there's stuff on the ble serial buffer // read it into the capslock struct while (!sdGetWouldBlock(&SD1)) { - sdReadTimeout(&SD1, (uint8_t *)&BLECapsLock, sizeof(ble_capslock_t), 10); + sdReadTimeout(&SD1, (uint8_t *)&ble_capslock, sizeof(ble_capslock_t), 10); } /* While there's data from LED keyboard sent - read it. */ while (!sdGetWouldBlock(&SD0)) { uint8_t byte = sdGet(&SD0); - protoConsume(&proto, byte); + 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_mask_set_row(current_rgb_row); } + current_rgb_row = (current_rgb_row + 1) % NUM_ROW; + #endif matrix_scan_user(); } bool process_record_kb(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { - if (annepro2LedStatus.matrixEnabled && annepro2LedStatus.isReactive) { - annepro2LedForwardKeypress(record->event.key.row, record->event.key.col); + if (ap2_led_status.matrix_enabled && ap2_led_status.is_reactive) { + ap2_led_forward_keypress(record->event.key.row, record->event.key.col); } - const annepro2Led_t blue = { + const ap2_led_t blue = { .p.blue = 0xff, .p.red = 0x00, .p.green = 0x00, @@ -135,22 +153,22 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { case KC_AP2_BT1: annepro2_ble_broadcast(0); /* FIXME: This hardcodes col/row position */ - annepro2LedBlink(0, 1, blue, 8, 50); + ap2_led_blink(0, 1, blue, 8, 50); return false; case KC_AP2_BT2: annepro2_ble_broadcast(1); - annepro2LedBlink(0, 2, blue, 8, 50); + ap2_led_blink(0, 2, blue, 8, 50); return false; case KC_AP2_BT3: annepro2_ble_broadcast(2); - annepro2LedBlink(0, 3, blue, 8, 50); + ap2_led_blink(0, 3, blue, 8, 50); return false; case KC_AP2_BT4: annepro2_ble_broadcast(3); - annepro2LedBlink(0, 4, blue, 8, 50); + ap2_led_blink(0, 4, blue, 8, 50); return false; case KC_AP2_USB: @@ -162,37 +180,43 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { return false; case KC_AP_LED_OFF: - annepro2LedDisable(); + ap2_led_disable(); break; case KC_AP_LED_ON: - if (annepro2LedStatus.matrixEnabled) { - annepro2LedNextProfile(); + if (ap2_led_status.matrix_enabled) { + ap2_led_next_profile(); } else { - annepro2LedEnable(); + ap2_led_enable(); } - annepro2LedResetForegroundColor(); + ap2_led_reset_foreground_color(); break; case KC_AP_LED_NEXT_PROFILE: - annepro2LedNextProfile(); - annepro2LedResetForegroundColor(); + ap2_led_next_profile(); + ap2_led_reset_foreground_color(); break; case KC_AP_LED_PREV_PROFILE: - annepro2LedPrevProfile(); - annepro2LedResetForegroundColor(); + ap2_led_prev_profile(); + ap2_led_reset_foreground_color(); break; case KC_AP_LED_NEXT_INTENSITY: - annepro2LedNextIntensity(); - annepro2LedResetForegroundColor(); + ap2_led_next_intensity(); + ap2_led_reset_foreground_color(); return false; case KC_AP_LED_SPEED: - annepro2LedNextAnimationSpeed(); - annepro2LedResetForegroundColor(); + ap2_led_next_animation_speed(); + ap2_led_reset_foreground_color(); return false; + #ifdef RGB_MATRIX_ENABLE + case RGB_TOG: + if(rgb_matrix_is_enabled()) ap2_led_disable(); + else ap2_led_enable(); + return true; + #endif default: 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__)) { uint8_t _dummy[10]; bool caps_lock; } ble_capslock_t; -extern ble_capslock_t BLECapsLock; +extern ble_capslock_t ble_capslock; // Matrix keymap // clang-format off -#define LAYOUT( \ +#define LAYOUT_60_ansi( \ K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, \ K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, \ - K40, K42, K43, K46, K49, K4A, K4B, K4C \ + K40, K42, K43, K46, K49, K4A, K4B, K4C \ ) { \ /* COL1 COL2 COL3 COL4 COL5 COL6 COL7 COL8 COL9 COL10 COL11 COL12 COL13 COL14*/ \ /* 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 = { ap2_ble_leds, ap2_ble_keyboard, ap2_ble_mouse, ap2_ble_system, ap2_ble_consumer, }; -static uint8_t bleMcuWakeup[11] = {0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x01, 0x7d, 0x02, 0x01, 0x02}; +static uint8_t ble_mcu_wakeup[11] = {0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x01, 0x7d, 0x02, 0x01, 0x02}; -static uint8_t bleMcuStartBroadcast[11] = { +static uint8_t ble_mcu_start_broadcast[11] = { 0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x01, 0x00 // Broadcast ID[0-3] }; -static uint8_t bleMcuConnect[11] = { +static uint8_t ble_mcu_connect[11] = { 0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x04, 0x00 // Connect ID [0-3] }; -static uint8_t bleMcuSendReport[10] = { +static uint8_t ble_mcu_send_report[10] = { 0x7b, 0x12, 0x53, 0x00, 0x0A, 0x00, 0x00, 0x7d, 0x10, 0x04, }; -static uint8_t bleMcuSendConsumerReport[10] = { +static uint8_t ble_mcu_send_consumer_report[10] = { 0x7b, 0x12, 0x53, 0x00, 0x06, 0x00, 0x00, 0x7d, 0x10, 0x08, }; -static uint8_t bleMcuUnpair[10] = { +static uint8_t ble_mcu_unpair[10] = { 0x7b, 0x12, 0x53, 0x00, 0x02, 0x00, 0x00, 0x7d, 0x40, 0x05, }; -static uint8_t bleMcuBootload[11] = {0x7b, 0x10, 0x51, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x01}; +static uint8_t ble_mcu_bootload[11] = {0x7b, 0x10, 0x51, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x01}; -static host_driver_t *lastHostDriver = NULL; +static host_driver_t *last_host_driver = NULL; #ifdef NKRO_ENABLE static bool lastNkroStatus = false; #endif // NKRO_ENABLE /* -------------------- Public Function Implementation ---------------------- */ -void annepro2_ble_bootload(void) { sdWrite(&SD1, bleMcuBootload, sizeof(bleMcuBootload)); } +void annepro2_ble_bootload(void) { sdWrite(&SD1, ble_mcu_bootload, sizeof(ble_mcu_bootload)); } -void annepro2_ble_startup(void) { sdWrite(&SD1, bleMcuWakeup, sizeof(bleMcuWakeup)); } +void annepro2_ble_startup(void) { sdWrite(&SD1, ble_mcu_wakeup, sizeof(ble_mcu_wakeup)); } void annepro2_ble_broadcast(uint8_t port) { if (port > 3) { port = 3; } // sdPut(&SD1, 0x00); - sdWrite(&SD1, bleMcuStartBroadcast, sizeof(bleMcuStartBroadcast)); + sdWrite(&SD1, ble_mcu_start_broadcast, sizeof(ble_mcu_start_broadcast)); sdPut(&SD1, port); static int lastBroadcast = -1; if (lastBroadcast == port) { @@ -88,7 +88,7 @@ void annepro2_ble_connect(uint8_t port) { if (port > 3) { port = 3; } - sdWrite(&SD1, bleMcuConnect, sizeof(bleMcuConnect)); + sdWrite(&SD1, ble_mcu_connect, sizeof(ble_mcu_connect)); sdPut(&SD1, port); ap2_ble_swtich_ble_driver(); } @@ -103,12 +103,12 @@ void annepro2_ble_disconnect(void) { #ifdef NKRO_ENABLE keymap_config.nkro = lastNkroStatus; #endif - host_set_driver(lastHostDriver); + host_set_driver(last_host_driver); } void annepro2_ble_unpair(void) { // sdPut(&SD1, 0x0); - sdWrite(&SD1, bleMcuUnpair, sizeof(bleMcuUnpair)); + sdWrite(&SD1, ble_mcu_unpair, sizeof(ble_mcu_unpair)); } /* ------------------- Static Function Implementation ----------------------- */ @@ -117,7 +117,7 @@ static void ap2_ble_swtich_ble_driver(void) { return; } clear_keyboard(); - lastHostDriver = host_get_driver(); + last_host_driver = host_get_driver(); #ifdef NKRO_ENABLE lastNkroStatus = keymap_config.nkro; #endif @@ -154,7 +154,7 @@ static inline uint16_t CONSUMER2AP2(uint16_t usage) { static void ap2_ble_consumer(uint16_t data) { sdPut(&SD1, 0x0); - sdWrite(&SD1, bleMcuSendConsumerReport, sizeof(bleMcuSendConsumerReport)); + 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)); @@ -165,6 +165,6 @@ static void ap2_ble_consumer(uint16_t data) { */ static void ap2_ble_keyboard(report_keyboard_t *report) { sdPut(&SD1, 0x0); - sdWrite(&SD1, bleMcuSendReport, sizeof(bleMcuSendReport)); + sdWrite(&SD1, ble_mcu_send_report, sizeof(ble_mcu_send_report)); sdWrite(&SD1, &report->raw[0], KEYBOARD_REPORT_SIZE); } 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 @@ #include "ap2_led.h" #include "protocol.h" -annepro2Led_t ledMask[KEY_COUNT]; -annepro2LedStatus_t annepro2LedStatus; +ap2_led_t led_mask[KEY_COUNT]; +ap2_led_status_t ap2_led_status; +uint8_t rgb_row_changed[NUM_ROW]; -void ledCommandCallback(const message_t *msg) { +void led_command_callback(const message_t *msg) { switch (msg->command) { case CMD_LED_STATUS: - annepro2LedStatus.amountOfProfiles = msg->payload[0]; - annepro2LedStatus.currentProfile = msg->payload[1]; - annepro2LedStatus.matrixEnabled = msg->payload[2]; - annepro2LedStatus.isReactive = msg->payload[3]; - annepro2LedStatus.ledIntensity = msg->payload[4]; - annepro2LedStatus.errors = msg->payload[5]; + ap2_led_status.amount_of_profiles = msg->payload[0]; + ap2_led_status.current_profile = msg->payload[1]; + ap2_led_status.matrix_enabled = msg->payload[2]; + ap2_led_status.is_reactive = msg->payload[3]; + ap2_led_status.led_intensity = msg->payload[4]; + ap2_led_status.errors = msg->payload[5]; break; #ifdef CONSOLE_ENABLE case CMD_LED_DEBUG: /* TODO: Don't use printf. */ printf("LED:"); - for (int i = 0; i < msg->payloadSize; i++) { + for (int i = 0; i < msg->payload_size; i++) { printf("%02x ", msg->payload[i]); } - for (int i = 0; i < msg->payloadSize; i++) { + for (int i = 0; i < msg->payload_size; i++) { printf("%c", msg->payload[i]); } printf("\n"); @@ -51,63 +52,63 @@ void ledCommandCallback(const message_t *msg) { } } -void annepro2SetIAP(void) { protoTx(CMD_LED_IAP, NULL, 0, 3); } +void ap2_set_IAP(void) { proto_tx(CMD_LED_IAP, NULL, 0, 3); } -void annepro2LedDisable(void) { protoTx(CMD_LED_OFF, NULL, 0, 3); } +void ap2_led_disable(void) { proto_tx(CMD_LED_OFF, NULL, 0, 3); } -void annepro2LedEnable(void) { protoTx(CMD_LED_ON, NULL, 0, 3); } +void ap2_led_enable(void) { proto_tx(CMD_LED_ON, NULL, 0, 3); } -void annepro2LedSetProfile(uint8_t prof) { protoTx(CMD_LED_SET_PROFILE, &prof, sizeof(prof), 3); } +void ap2_led_set_profile(uint8_t prof) { proto_tx(CMD_LED_SET_PROFILE, &prof, sizeof(prof), 3); } -void annepro2LedGetStatus() { protoTx(CMD_LED_GET_STATUS, NULL, 0, 3); } +void ap2_led_get_status() { proto_tx(CMD_LED_GET_STATUS, NULL, 0, 3); } -void annepro2LedNextProfile() { protoTx(CMD_LED_NEXT_PROFILE, NULL, 0, 3); } +void ap2_led_next_profile() { proto_tx(CMD_LED_NEXT_PROFILE, NULL, 0, 3); } -void annepro2LedNextIntensity() { protoTx(CMD_LED_NEXT_INTENSITY, NULL, 0, 3); } +void ap2_led_next_intensity() { proto_tx(CMD_LED_NEXT_INTENSITY, NULL, 0, 3); } -void annepro2LedNextAnimationSpeed() { protoTx(CMD_LED_NEXT_ANIMATION_SPEED, NULL, 0, 3); } +void ap2_led_next_animation_speed() { proto_tx(CMD_LED_NEXT_ANIMATION_SPEED, NULL, 0, 3); } -void annepro2LedPrevProfile() { protoTx(CMD_LED_PREV_PROFILE, NULL, 0, 3); } +void ap2_led_prev_profile() { proto_tx(CMD_LED_PREV_PROFILE, NULL, 0, 3); } -void annepro2LedMaskSetKey(uint8_t row, uint8_t col, annepro2Led_t color) { +void ap2_led_mask_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}; - protoTx(CMD_LED_MASK_SET_KEY, payload, sizeof(payload), 1); + proto_tx(CMD_LED_MASK_SET_KEY, payload, sizeof(payload), 1); } /* Push a whole local row to the shine */ -void annepro2LedMaskSetRow(uint8_t row) { - uint8_t payload[NUM_COLUMN * sizeof(annepro2Led_t) + 1]; +void ap2_led_mask_set_row(uint8_t row) { + uint8_t payload[NUM_COLUMN * sizeof(ap2_led_t) + 1]; payload[0] = row; - memcpy(payload + 1, &ledMask[ROWCOL2IDX(row, 0)], sizeof(*ledMask) * NUM_COLUMN); - protoTx(CMD_LED_MASK_SET_ROW, payload, sizeof(payload), 1); + memcpy(payload + 1, &led_mask[ROWCOL2IDX(row, 0)], sizeof(*led_mask) * NUM_COLUMN); + proto_tx(CMD_LED_MASK_SET_ROW, payload, sizeof(payload), 1); } /* Synchronize all rows */ -void annepro2LedMaskSetAll(void) { - for (int row = 0; row < 5; row++) annepro2LedMaskSetRow(row); +void ap2_led_mask_set_all(void) { + for (int row = 0; row < 5; row++) ap2_led_mask_set_row(row); } /* Set all keys to a given color */ -void annepro2LedMaskSetMono(const annepro2Led_t color) { protoTx(CMD_LED_MASK_SET_MONO, (uint8_t *)&color, sizeof(color), 1); } +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 annepro2LedBlink(uint8_t row, uint8_t col, annepro2Led_t color, uint8_t count, uint8_t hundredths) { +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}; - protoTx(CMD_LED_KEY_BLINK, payload, sizeof(payload), 1); + proto_tx(CMD_LED_KEY_BLINK, payload, sizeof(payload), 1); } -void annepro2LedSetForegroundColor(uint8_t red, uint8_t green, uint8_t blue) { - annepro2Led_t color = {.p.red = red, .p.green = green, .p.blue = blue, .p.alpha = 0xff}; - annepro2LedMaskSetMono(color); +void ap2_led_set_foreground_color(uint8_t red, uint8_t green, uint8_t blue) { + ap2_led_t color = {.p.red = red, .p.green = green, .p.blue = blue, .p.alpha = 0xff}; + ap2_led_mask_set_mono(color); } -void annepro2LedResetForegroundColor() { - annepro2Led_t color = { +void ap2_led_reset_foreground_color() { + ap2_led_t color = { .p.red = 0, .p.green = 0, .p.blue = 0, .p.alpha = 0, }; - annepro2LedMaskSetMono(color); + ap2_led_mask_set_mono(color); } /* @@ -128,7 +129,7 @@ void annepro2LedResetForegroundColor() { * Following it are 3 bits of row and 4 bits of col. * 1 + 3 + 4 = 8 bits - only a single byte is sent for every keypress. */ -void annepro2LedForwardKeypress(uint8_t row, uint8_t col) { +void ap2_led_forward_keypress(uint8_t row, uint8_t col) { const uint8_t payload = row << 4 | col; - protoTx(CMD_LED_KEY_DOWN, &payload, 1, 1); + proto_tx(CMD_LED_KEY_DOWN, &payload, 1, 1); } 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 @@ /* Copyright 2021 OpenAnnePro community - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ #pragma once @@ -31,54 +31,63 @@ typedef union { uint8_t pv[4]; /* 0xrgb in mem is b g r a */ uint32_t rgb; -} annepro2Led_t; +} ap2_led_t; #define ROWCOL2IDX(row, col) (NUM_COLUMN * (row) + (col)) #define NUM_COLUMN 14 #define NUM_ROW 5 #define KEY_COUNT 70 -/* Local copy of ledMask, used to override colors on the board */ -extern annepro2Led_t ledMask[KEY_COUNT]; +/* Local copy of led_mask, used to override colors on the board */ +extern ap2_led_t led_mask[KEY_COUNT]; +extern uint8_t rgb_row_changed[NUM_ROW]; /* Handle incoming messages */ -extern void ledCommandCallback(const message_t *msg); +extern void led_command_callback(const message_t *msg); -void annepro2SetIAP(void); -void annepro2LedDisable(void); -void annepro2LedEnable(void); -void annepro2LedSetProfile(uint8_t prof); -void annepro2LedGetStatus(void); -void annepro2LedNextProfile(void); -void annepro2LedPrevProfile(void); -void annepro2LedNextIntensity(void); -void annepro2LedNextAnimationSpeed(void); -void annepro2LedForwardKeypress(uint8_t row, uint8_t col); +void ap2_set_IAP(void); +void ap2_led_disable(void); +void ap2_led_enable(void); +void ap2_led_set_profile(uint8_t prof); +void ap2_led_get_status(void); +void ap2_led_next_profile(void); +void ap2_led_prev_profile(void); +void ap2_led_next_intensity(void); +void ap2_led_next_animation_speed(void); +void ap2_led_forward_keypress(uint8_t row, uint8_t col); /* Set single key to a given color; alpha controls which is displayed */ -void annepro2LedMaskSetKey(uint8_t row, uint8_t col, annepro2Led_t color); +void ap2_led_mask_set_key(uint8_t row, uint8_t col, ap2_led_t color); /* Push a whole local row to the shine */ -void annepro2LedMaskSetRow(uint8_t row); +void ap2_led_mask_set_row(uint8_t row); /* Synchronize all rows */ -void annepro2LedMaskSetAll(void); +void ap2_led_mask_set_all(void); /* Set all keys to a given color */ -void annepro2LedMaskSetMono(annepro2Led_t color); +void ap2_led_mask_set_mono(ap2_led_t color); /* Blink given key `count` times by masking it with a `color`. Blink takes `hundredths` of a second */ -void annepro2LedBlink(uint8_t row, uint8_t col, annepro2Led_t color, uint8_t count, uint8_t hundredths); +void ap2_led_blink(uint8_t row, uint8_t col, ap2_led_t color, uint8_t count, uint8_t hundredths); /* Kept for compatibility, but implemented using masks */ -void annepro2LedSetForegroundColor(uint8_t red, uint8_t green, uint8_t blue); -void annepro2LedResetForegroundColor(void); +void ap2_led_set_foreground_color(uint8_t red, uint8_t green, uint8_t blue); +void ap2_led_reset_foreground_color(void); typedef struct { - uint8_t amountOfProfiles; - uint8_t currentProfile; - uint8_t matrixEnabled; - uint8_t isReactive; - uint8_t ledIntensity; + uint8_t amount_of_profiles; + uint8_t current_profile; + uint8_t matrix_enabled; + uint8_t is_reactive; + uint8_t led_intensity; uint8_t errors; -} annepro2LedStatus_t; +} ap2_led_status_t; -extern annepro2LedStatus_t annepro2LedStatus; +extern ap2_led_status_t ap2_led_status; + +#ifdef RGB_MATRIX_ENABLE +/* RGB driver functions */ +void init(void); +void flush(void); +void set_color(int index, uint8_t r, uint8_t g, uint8_t b); +void set_color_all(uint8_t r, uint8_t g, uint8_t b); +#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 @@ #pragma once #include "pin_defs.h" +#include "config_led.h" /* USB Device descriptor parameter */ #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 = \ matrix.c \ annepro2_ble.c \ ap2_led.c \ - protocol.c + protocol.c \ + rgb_driver.c \ + config_led.c # MCU MCU = cortex-m0plus @@ -24,6 +26,7 @@ NKRO_ENABLE = no MOUSEKEY_ENABLE = no EXTRAKEY_ENABLE = yes KEY_LOCK_ENABLE = no +LAYOUTS = 60_ansi # Other featues BOOTMAGIC_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 @@ #pragma once #include "pin_defs.h" +#include "config_led.h" /* USB Device descriptor parameter */ #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 = \ matrix.c \ annepro2_ble.c \ ap2_led.c \ - protocol.c + protocol.c \ + rgb_driver.c \ + config_led.c # MCU MCU = cortex-m0plus @@ -24,6 +26,7 @@ NKRO_ENABLE = no MOUSEKEY_ENABLE = no EXTRAKEY_ENABLE = yes KEY_LOCK_ENABLE = no +LAYOUTS = 60_ansi # Other featues BOOTMAGIC_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 @@ +/* Copyright 2022 Jose Pablo Ramirez <jp.ramangulo@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifdef RGB_MATRIX_ENABLE + +#include "rgb_matrix.h" +#include "config_led.h" + +#define NA NO_LED + +led_config_t g_led_config = { { + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }, + { 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 }, + { 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, NA }, + { 41, NA, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, NA }, + { 53, NA, 54, 55, NA, NA, 56, NA, NA, 57, 58, 59, 60, NA } +}, { + { 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 }, + { 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 }, + { 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 }, + { 10, 48 }, { 36, 48 }, { 52, 48 }, { 69, 48 }, { 85, 48 }, { 101, 48 }, { 117, 48 }, { 133, 48 }, { 149, 48 }, { 165, 48 }, { 182, 48 }, { 212, 48 }, + { 2 , 64 }, { 22, 64 }, { 42, 64 }, { 103, 64 }, { 163, 64 }, { 184, 64 }, { 204, 64 }, { 224, 64 }, +}, { + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, + 1, 1, 1, 4, 1, 1, 1, 1, +} }; +#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 @@ +/* Copyright 2022 Jose Pablo Ramirez <jp.ramangulo@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#pragma once + +#ifdef RGB_MATRIX_ENABLE + +#define DRIVER_LED_TOTAL 61 + +/* Limit animations to 62.5 FPS to avoid tearing. (1/.016 = 62.5 FPS). */ +#define RGB_MATRIX_LED_FLUSH_LIMIT 16 + +#define RGB_MATRIX_FRAMEBUFFER_EFFECTS +#define RGB_MATRIX_KEYPRESSES +#define ENABLE_RGB_MATRIX_ALPHAS_MODS +#define ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN +#define ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT +#define ENABLE_RGB_MATRIX_BREATHING +#define ENABLE_RGB_MATRIX_BAND_SAT +#define ENABLE_RGB_MATRIX_BAND_VAL +#define ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT +#define ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL +#define ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT +#define ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL +#define ENABLE_RGB_MATRIX_CYCLE_ALL +#define ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT +#define ENABLE_RGB_MATRIX_CYCLE_UP_DOWN +#define ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON +#define ENABLE_RGB_MATRIX_CYCLE_OUT_IN +#define ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL +#define ENABLE_RGB_MATRIX_CYCLE_PINWHEEL +#define ENABLE_RGB_MATRIX_CYCLE_SPIRAL +#define ENABLE_RGB_MATRIX_DUAL_BEACON +#define ENABLE_RGB_MATRIX_RAINBOW_BEACON +#define ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS +#define ENABLE_RGB_MATRIX_RAINDROPS +#define ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS +#define ENABLE_RGB_MATRIX_HUE_BREATHING +#define ENABLE_RGB_MATRIX_HUE_PENDULUM +#define ENABLE_RGB_MATRIX_HUE_WAVE +#define ENABLE_RGB_MATRIX_PIXEL_FRACTAL +#define ENABLE_RGB_MATRIX_PIXEL_FLOW +#define ENABLE_RGB_MATRIX_PIXEL_RAIN +#define ENABLE_RGB_MATRIX_TYPING_HEATMAP +#define ENABLE_RGB_MATRIX_DIGITAL_RAIN +#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE +#define ENABLE_RGB_MATRIX_SOLID_REACTIVE +#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE +#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE +#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS +#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS +#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS +#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS +#define ENABLE_RGB_MATRIX_SPLASH +#define ENABLE_RGB_MATRIX_MULTISPLASH +#define ENABLE_RGB_MATRIX_SOLID_SPLASH +#define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH + +#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 @@ "url": "https://openannepro.github.io/", "maintainer": "community", "layouts": { - "LAYOUT": { + "LAYOUT_60_ansi": { "layout": [ { "label": "~", diff --git a/keyboards/annepro2/keymaps/defaul |