diff --git a/keyboards/anne_pro/anne_pro.c b/keyboards/anne_pro/anne_pro.c index bae1bebd66..8be52a32ed 100644 --- a/keyboards/anne_pro/anne_pro.c +++ b/keyboards/anne_pro/anne_pro.c @@ -30,15 +30,53 @@ static UARTConfig uart_cfg = { .cr3 = 0 }; -extern volatile bool leds_enabled; +/* State of the leds on the keyboard */ +volatile bool leds_enabled = false; -void matrix_init_kb(void) { +bool process_record_kb(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case APL_RGB: + /* Toggle the RGB enabled/disabled */ + if (record->event.pressed) { + leds_enabled = !leds_enabled; + if (leds_enabled) { + uartStartSend(&UARTD3, 3, "\x09\x01\x01"); + } else { + uartStartSend(&UARTD3, 4, "\x09\x02\x01\x00"); + } + } + return false; + case APL_RAT: + /* Change the animation rate */ + if (leds_enabled && record->event.pressed) { + uartStartSend(&UARTD3, 6, "\x09\x04\x05\x00\x01\x00"); + } + return false; + case APL_BRT: + /* Change the brightness */ + if (leds_enabled && record->event.pressed) { + uartStartSend(&UARTD3, 6, "\x09\x04\x05\x00\x00\x01"); + } + return false; + case APL_MOD: + /* Change the lighting mode */ + if (leds_enabled && record->event.pressed) { + uartStartSend(&UARTD3, 6, "\x09\x04\x05\x01\x00\x00"); + } + return false; + default: + /* Handle other keycodes normally */ + return true; + } +} + +void keyboard_post_init_kb(void) { /* Turn on lighting controller */ setPinOutput(C15); writePinLow(C15); - chThdSleepMilliseconds(100); + chThdSleepMilliseconds(10); writePinHigh(C15); - chThdSleepMilliseconds(100); + chThdSleepMilliseconds(10); /* Initialize the lighting UART */ uartStart(&UARTD3, &uart_cfg); diff --git a/keyboards/anne_pro/anne_pro.h b/keyboards/anne_pro/anne_pro.h index 5557e58eca..4d3c75bd7e 100644 --- a/keyboards/anne_pro/anne_pro.h +++ b/keyboards/anne_pro/anne_pro.h @@ -17,6 +17,14 @@ #pragma once #include "quantum.h" +/* Custom keycodes for the lighting control for the Anne Pro */ +enum anne_pro_keycodes { + APL_RGB = SAFE_RANGE, + APL_RAT, + APL_BRT, + APL_MOD +}; + /* The fully-featured LAYOUT() that has every single key available in the matrix. */ #define LAYOUT(\ k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, k0c, k0d, \ diff --git a/keyboards/anne_pro/keymaps/default/keymap.c b/keyboards/anne_pro/keymaps/default/keymap.c index 54b97f81ef..2939aec519 100644 --- a/keyboards/anne_pro/keymaps/default/keymap.c +++ b/keyboards/anne_pro/keymaps/default/keymap.c @@ -16,13 +16,6 @@ #include QMK_KEYBOARD_H -/* Custom keycodes for the lighting control for the Anne Pro */ -enum my_keycodes { - ANNERGB = SAFE_RANGE, - ANNERAT, - ANNEBRT, - ANNEMOD -}; /* Default Anne Pro layout, macOS style with LALT and LWIN switched */ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { @@ -31,53 +24,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 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, 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, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, - KC_LCTL, KC_LALT, KC_LWIN, KC_SPACE, KC_RALT, MO(1), KC_NO, KC_RCTL + KC_LCTL, KC_LALT, KC_LWIN, KC_SPACE, KC_RALT, MO(1), XXXXXXX, KC_RCTL ), [1] = LAYOUT( - 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_UP, _______, ANNERGB, ANNERAT, ANNEBRT, ANNEMOD, KC_UP, KC_SLCK, KC_PAUS, KC_HOME, KC_END, KC_PSCR, - _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, KC_LEFT, KC_DOWN, KC_RGHT, KC_PGUP, KC_PGDN, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_INS, KC_DEL, _______, - _______, _______, _______, _______, _______, _______, _______, _______ + 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, XXXXXXX, + XXXXXXX, XXXXXXX, KC_UP, XXXXXXX, APL_RGB, APL_RAT, APL_BRT, APL_MOD, KC_UP, KC_SLCK, KC_PAUS, KC_HOME, KC_END, KC_PSCR, + XXXXXXX, KC_LEFT, KC_DOWN, KC_RGHT, XXXXXXX, XXXXXXX, XXXXXXX, KC_LEFT, KC_DOWN, KC_RGHT, KC_PGUP, KC_PGDN, XXXXXXX, + _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_INS, KC_DEL, _______, + _______, _______, _______, XXXXXXX, _______, _______, _______, _______ ) }; - -/* State of the leds on the keyboard */ -volatile bool leds_enabled = false; - -bool process_record_user(uint16_t keycode, keyrecord_t *record) { - switch (keycode) { - case ANNERGB: - /* Toggle the RGB enabled/disabled */ - if (record->event.pressed) { - leds_enabled = !leds_enabled; - if (leds_enabled) { - uartStartSend(&UARTD3, 3, "\x09\x01\x01"); - } else { - uartStartSend(&UARTD3, 4, "\x09\x02\x01\x00"); - } - } - return false; - case ANNERAT: - /* Change the animation rate */ - if (leds_enabled && record->event.pressed) { - uartStartSend(&UARTD3, 6, "\x09\x04\x05\x00\x01\x00"); - } - return false; - case ANNEBRT: - /* Change the brightness */ - if (leds_enabled && record->event.pressed) { - uartStartSend(&UARTD3, 6, "\x09\x04\x05\x00\x00\x01"); - } - return false; - case ANNEMOD: - /* Change the lighting mode */ - if (leds_enabled && record->event.pressed) { - uartStartSend(&UARTD3, 6, "\x09\x04\x05\x01\x00\x00"); - } - return false; - default: - /* Handle other keycodes normally */ - return true; - } -}