Keyboard annepro2 ble caps lock (#12)

* Move matrix_scan_kb out of board.c to annepro2.c

* add buffer clear after init and caplock polling
This commit is contained in:
tech2077
2021-09-12 09:26:27 +02:00
committed by bwisn
parent cf4ca46824
commit 758c541b13
3 changed files with 31 additions and 5 deletions
+24 -1
View File
@@ -17,6 +17,7 @@ static uint8_t ledMcuWakeup[11] = {
0x7b, 0x10, 0x43, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x02
};
ble_capslock_t BLECapsLock = {._dummy = {0}, .caps_lock = false};
uint16_t annepro2LedMatrix[MATRIX_ROWS * MATRIX_COLS] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@@ -50,7 +51,11 @@ void OVERRIDE keyboard_post_init_kb(void) {
// Give the send uart thread some time to
// send out the queue before we read back
wait_ms(5);
wait_ms(15);
// loop to clear out receive buffer from ble wakeup
while(!sdGetWouldBlock(&SD1))
sdGet(&SD1);
keyboard_post_init_user();
}
@@ -59,6 +64,24 @@ void OVERRIDE matrix_init_kb(void) {
matrix_init_user();
}
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);
// if it's capslock from ble, darken led
if (BLECapsLock.caps_lock) {
annepro2LedClearMask(MATRIX_COLS * 2);
} else {
annepro2LedSetMask(MATRIX_COLS * 2);
}
}
matrix_scan_user();
}
/*!
* @returns false processing for this keycode has been completed.
*/
+7
View File
@@ -21,8 +21,15 @@
#define OVERRIDE __attribute__ ((noinline))
typedef struct __attribute__((__packed__)) {
uint8_t _dummy[10];
bool caps_lock;
} ble_capslock_t;
extern uint16_t annepro2LedMatrix[MATRIX_ROWS * MATRIX_COLS];
extern ble_capslock_t BLECapsLock;
enum AP2KeyCodes {
KC_AP2_BT1 = SAFE_RANGE,
KC_AP2_BT2,
@@ -176,10 +176,6 @@ void __early_init(void) {
ht32_clock_init();
}
void matrix_scan_kb() {
matrix_scan_user();
}
/**
* @brief Board-specific initialization code.
* @todo Add your board-specific code, if any.