diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index fe3819ae9dda..42523acae0df 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, @@ -36,43 +35,14 @@ void OVERRIDE keyboard_post_init_kb(void) { // 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/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/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 += diff --git a/keyboards/annepro2/keymaps/codetector/keymap.c b/keyboards/annepro2/keymaps/codetector/keymap.c index 1d77566909bd..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,12 +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 6a07a94584df..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,12 +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; diff --git a/keyboards/annepro2/qmk_ap2_led.c b/keyboards/annepro2/qmk_ap2_led.c new file mode 100644 index 000000000000..9ad89c465175 --- /dev/null +++ b/keyboards/annepro2/qmk_ap2_led.c @@ -0,0 +1,60 @@ +#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); +} + +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 681855b83999..44d94784c30e 100644 --- a/keyboards/annepro2/qmk_ap2_led.h +++ b/keyboards/annepro2/qmk_ap2_led.h @@ -4,3 +4,18 @@ #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); +void annepro2LedPrevProfile(void);