From 64ef57ec07f6478aa55b7074f1c9d932d48e7c88 Mon Sep 17 00:00:00 2001 From: Matthew Skolaut Date: Wed, 19 Aug 2020 00:08:22 -0500 Subject: [PATCH 1/5] Added bidirectional shine comms and moved led functionality to new file --- keyboards/annepro2/annepro2.h | 5 --- keyboards/annepro2/qmk_ap2_led.c | 55 ++++++++++++++++++++++++++++++++ keyboards/annepro2/qmk_ap2_led.h | 14 ++++++++ 3 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 keyboards/annepro2/qmk_ap2_led.c diff --git a/keyboards/annepro2/annepro2.h b/keyboards/annepro2/annepro2.h index 3e562d93af26..8c6b58fcf403 100644 --- a/keyboards/annepro2/annepro2.h +++ b/keyboards/annepro2/annepro2.h @@ -32,8 +32,3 @@ enum AP2KeyCodes { KC_AP2_USB, AP2_SAFE_RANGE, }; - -void annepro2LedDisable(void); -void annepro2LedEnable(void); -void annepro2LedUpdate(uint8_t row, uint8_t col); -void annepro2LedUpdateRow(uint8_t row); diff --git a/keyboards/annepro2/qmk_ap2_led.c b/keyboards/annepro2/qmk_ap2_led.c new file mode 100644 index 000000000000..a615f1951aeb --- /dev/null +++ b/keyboards/annepro2/qmk_ap2_led.c @@ -0,0 +1,55 @@ +#include "hal.h" +#include "annepro2.h" +#include "qmk_ap2_led.h" + +void annepro2LedDisable(void) +{ + sdPut(&SD0, CMD_LED_OFF); +} + +void annepro2LedEnable(void) +{ + sdPut(&SD0, CMD_LED_ON); +} + +void annepro2LedUpdate(uint8_t row, uint8_t col) +{ + sdPut(&SD0, CMD_LED_SET); + sdPut(&SD0, row); + sdPut(&SD0, col); + sdWrite(&SD0, (uint8_t *)&annepro2LedMatrix[row * MATRIX_COLS + col], sizeof(uint16_t)); +} + +void annepro2LedUpdateRow(uint8_t row) +{ + sdPut(&SD0, CMD_LED_SET_ROW); + sdPut(&SD0, row); + sdWrite(&SD0, (uint8_t *)&annepro2LedMatrix[row * MATRIX_COLS], sizeof(uint16_t) * MATRIX_COLS); +} + +void annepro2LedSetProfile(uint8_t prof) +{ + sdPut(&SD0, CMD_LED_SET_PROFILE); + sdPut(&SD0, prof); +} + +uint8_t annepro2LedGetProfile() +{ + uint8_t buf = 0; + sdPut(&SD0, CMD_LED_GET_PROFILE); + buf = sdGet(&SD0); + return buf; +} + +uint8_t annepro2LedGetNumProfiles() +{ + uint8_t buf = 0; + sdPut(&SD0, CMD_LED_GET_NUM_PROFILES); + buf = sdGet(&SD0); + return buf; +} + +void annepro2LedNextProfile() +{ + sdPut(&SD0, CMD_LED_NEXT_PROFILE); +} \ No newline at end of file diff --git a/keyboards/annepro2/qmk_ap2_led.h b/keyboards/annepro2/qmk_ap2_led.h index 681855b83999..b90295df18f9 100644 --- a/keyboards/annepro2/qmk_ap2_led.h +++ b/keyboards/annepro2/qmk_ap2_led.h @@ -4,3 +4,17 @@ #define CMD_LED_OFF 0x2 #define CMD_LED_SET 0x3 #define CMD_LED_SET_ROW 0x4 +#define CMD_LED_SET_PROFILE 0x5 +#define CMD_LED_NEXT_PROFILE 0x6 +#define CMD_LED_PREV_PROFILE 0x7 +#define CMD_LED_GET_PROFILE 0x8 +#define CMD_LED_GET_NUM_PROFILES 0x9 + +void annepro2LedDisable(void); +void annepro2LedEnable(void); +void annepro2LedUpdate(uint8_t row, uint8_t col); +void annepro2LedUpdateRow(uint8_t row); +void annepro2LedSetProfile(uint8_t prof); +uint8_t annepro2LedGetProfile(void); +uint8_t annepro2LedGetNumProfiles(void); +void annepro2LedNextProfile(void); From 6d628527e7ee7baebb2a49e26aa8072ef6e0f8a1 Mon Sep 17 00:00:00 2001 From: Matthew Skolaut Date: Wed, 19 Aug 2020 00:11:35 -0500 Subject: [PATCH 2/5] Added bidirectional shine comms and moved led functionality to new file --- keyboards/annepro2/annepro2.c | 39 ++++++--------------------------- keyboards/annepro2/c15/rules.mk | 3 ++- keyboards/annepro2/c18/rules.mk | 3 ++- 3 files changed, 11 insertions(+), 34 deletions(-) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index fe3819ae9dda..8fd080182f44 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -2,7 +2,6 @@ #include "hal.h" #include "annepro2.h" #include "annepro2_ble.h" -#include "qmk_ap2_led.h" static const SerialConfig ledUartConfig = { .speed = 115200, @@ -26,6 +25,9 @@ uint16_t annepro2LedMatrix[MATRIX_ROWS * MATRIX_COLS] = { }; void OVERRIDE keyboard_pre_init_kb(void) { +#if HAL_USE_SPI == TRUE + spi_init(); +#endif } void OVERRIDE keyboard_post_init_kb(void) { @@ -33,46 +35,19 @@ void OVERRIDE keyboard_post_init_kb(void) { sdStart(&SD0, &ledUartConfig); sdWrite(&SD0, ledMcuWakeup, 11); + wait_ms(75); + // Start BLE UART sdStart(&SD1, &bleUartConfig); annepro2_ble_startup(); + + keyboard_post_init_user(); } void OVERRIDE matrix_init_kb(void) { matrix_init_user(); } -void annepro2LedDisable(void) -{ - sdPut(&SD0, CMD_LED_OFF); -} - -void annepro2LedEnable(void) -{ - sdPut(&SD0, CMD_LED_ON); -} - -void annepro2LedUpdate(uint8_t row, uint8_t col) -{ - sdPut(&SD0, CMD_LED_SET); - sdPut(&SD0, row); - sdPut(&SD0, col); - sdWrite(&SD0, (uint8_t *)&annepro2LedMatrix[row * MATRIX_COLS + col], sizeof(uint16_t)); -} - -void annepro2LedUpdateRow(uint8_t row) -{ - sdPut(&SD0, CMD_LED_SET_ROW); - sdPut(&SD0, row); - sdWrite(&SD0, (uint8_t *)&annepro2LedMatrix[row * MATRIX_COLS], sizeof(uint16_t) * MATRIX_COLS); -} - -bool OVERRIDE led_update_kb(led_t status) { - annepro2LedMatrix[2 * MATRIX_COLS] = status.caps_lock ? 0x4FF : 0; - annepro2LedUpdate(2, 0); - return led_update_user(status); -} - /*! * @returns false processing for this keycode has been completed. */ diff --git a/keyboards/annepro2/c15/rules.mk b/keyboards/annepro2/c15/rules.mk index 0878c54cb36c..cbef25300e5c 100644 --- a/keyboards/annepro2/c15/rules.mk +++ b/keyboards/annepro2/c15/rules.mk @@ -2,7 +2,8 @@ SRC = \ matrix.c \ hardfault_handler.c \ - annepro2_ble.c + annepro2_ble.c \ + qmk_ap2_led.c LAYOUTS += diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk index 7df05caeb005..e042ff844a55 100644 --- a/keyboards/annepro2/c18/rules.mk +++ b/keyboards/annepro2/c18/rules.mk @@ -2,7 +2,8 @@ SRC = \ matrix.c \ hardfault_handler.c \ - annepro2_ble.c + annepro2_ble.c \ + qmk_ap2_led.c LAYOUTS += From a650cbd8c9fc7e4dbf5984e30b2c389cf27aafd4 Mon Sep 17 00:00:00 2001 From: Matthew Skolaut Date: Wed, 19 Aug 2020 00:12:17 -0500 Subject: [PATCH 3/5] Restore original functionality to existing keymaps using new shine commands --- keyboards/annepro2/keymaps/codetector/keymap.c | 2 ++ keyboards/annepro2/keymaps/default/keymap.c | 2 ++ keyboards/annepro2/qmk_ap2_led.c | 5 +++++ keyboards/annepro2/qmk_ap2_led.h | 1 + 4 files changed, 10 insertions(+) diff --git a/keyboards/annepro2/keymaps/codetector/keymap.c b/keyboards/annepro2/keymaps/codetector/keymap.c index 1d77566909bd..5b71751013b9 100644 --- a/keyboards/annepro2/keymaps/codetector/keymap.c +++ b/keyboards/annepro2/keymaps/codetector/keymap.c @@ -66,10 +66,12 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { case KC_AP_LED_OFF: if (record->event.pressed) annepro2LedDisable(); + annepro2LedPrevProfile(); return false; case KC_AP_LED_ON: if (record->event.pressed) annepro2LedEnable(); + annepro2LedNextProfile(); return false; default: break; diff --git a/keyboards/annepro2/keymaps/default/keymap.c b/keyboards/annepro2/keymaps/default/keymap.c index 6a07a94584df..2141e8235f85 100644 --- a/keyboards/annepro2/keymaps/default/keymap.c +++ b/keyboards/annepro2/keymaps/default/keymap.c @@ -111,10 +111,12 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { case KC_AP_LED_OFF: if (record->event.pressed) annepro2LedDisable(); + annepro2LedPrevProfile(); return false; case KC_AP_LED_ON: if (record->event.pressed) annepro2LedEnable(); + annepro2LedNextProfile(); return false; default: break; diff --git a/keyboards/annepro2/qmk_ap2_led.c b/keyboards/annepro2/qmk_ap2_led.c index a615f1951aeb..9ad89c465175 100644 --- a/keyboards/annepro2/qmk_ap2_led.c +++ b/keyboards/annepro2/qmk_ap2_led.c @@ -52,4 +52,9 @@ uint8_t annepro2LedGetNumProfiles() void annepro2LedNextProfile() { sdPut(&SD0, CMD_LED_NEXT_PROFILE); +} + +void annepro2LedPrevProfile() +{ + sdPut(&SD0, CMD_LED_PREV_PROFILE); } \ No newline at end of file diff --git a/keyboards/annepro2/qmk_ap2_led.h b/keyboards/annepro2/qmk_ap2_led.h index b90295df18f9..44d94784c30e 100644 --- a/keyboards/annepro2/qmk_ap2_led.h +++ b/keyboards/annepro2/qmk_ap2_led.h @@ -18,3 +18,4 @@ void annepro2LedSetProfile(uint8_t prof); uint8_t annepro2LedGetProfile(void); uint8_t annepro2LedGetNumProfiles(void); void annepro2LedNextProfile(void); +void annepro2LedPrevProfile(void); From 9e43a1766926601ecfa20f9f0586be4507a1ccc2 Mon Sep 17 00:00:00 2001 From: Matthew Skolaut Date: Thu, 20 Aug 2020 23:42:39 -0500 Subject: [PATCH 4/5] Fix dangling bracketless if statements --- keyboards/annepro2/keymaps/codetector/keymap.c | 7 +++++-- keyboards/annepro2/keymaps/default/keymap.c | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/keyboards/annepro2/keymaps/codetector/keymap.c b/keyboards/annepro2/keymaps/codetector/keymap.c index 5b71751013b9..f1af4cdcb394 100644 --- a/keyboards/annepro2/keymaps/codetector/keymap.c +++ b/keyboards/annepro2/keymaps/codetector/keymap.c @@ -1,5 +1,6 @@ #include #include "annepro2.h" +#include "qmk_ap2_led.h" enum anne_pro_layers { _BASE_LAYER, @@ -64,14 +65,16 @@ layer_state_t layer_state_set_user(layer_state_t layer) { bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case KC_AP_LED_OFF: - if (record->event.pressed) + if (record->event.pressed) { annepro2LedDisable(); annepro2LedPrevProfile(); + } return false; case KC_AP_LED_ON: - if (record->event.pressed) + if (record->event.pressed) { annepro2LedEnable(); annepro2LedNextProfile(); + } return false; default: break; diff --git a/keyboards/annepro2/keymaps/default/keymap.c b/keyboards/annepro2/keymaps/default/keymap.c index 2141e8235f85..27fa3f13f497 100644 --- a/keyboards/annepro2/keymaps/default/keymap.c +++ b/keyboards/annepro2/keymaps/default/keymap.c @@ -1,5 +1,6 @@ #include #include "annepro2.h" +#include "qmk_ap2_led.h" enum anne_pro_layers { _BASE_LAYER, @@ -109,14 +110,16 @@ layer_state_t layer_state_set_user(layer_state_t layer) { bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case KC_AP_LED_OFF: - if (record->event.pressed) + if (record->event.pressed) { annepro2LedDisable(); annepro2LedPrevProfile(); + } return false; case KC_AP_LED_ON: - if (record->event.pressed) + if (record->event.pressed) { annepro2LedEnable(); annepro2LedNextProfile(); + } return false; default: break; From 3cab6455d74aa29dbf3642484ab26564504752fe Mon Sep 17 00:00:00 2001 From: Matthew Skolaut Date: Fri, 21 Aug 2020 00:19:27 -0500 Subject: [PATCH 5/5] PR cleanup --- keyboards/annepro2/annepro2.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index 8fd080182f44..42523acae0df 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -25,9 +25,6 @@ uint16_t annepro2LedMatrix[MATRIX_ROWS * MATRIX_COLS] = { }; void OVERRIDE keyboard_pre_init_kb(void) { -#if HAL_USE_SPI == TRUE - spi_init(); -#endif } void OVERRIDE keyboard_post_init_kb(void) { @@ -35,8 +32,6 @@ void OVERRIDE keyboard_post_init_kb(void) { sdStart(&SD0, &ledUartConfig); sdWrite(&SD0, ledMcuWakeup, 11); - wait_ms(75); - // Start BLE UART sdStart(&SD1, &bleUartConfig); annepro2_ble_startup();