Move LED code from keymap to keyboard file
parent
10a40b1ff1
commit
0c35dff498
|
|
@ -30,15 +30,53 @@ static UARTConfig uart_cfg = {
|
||||||
.cr3 = 0
|
.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 */
|
/* Turn on lighting controller */
|
||||||
setPinOutput(C15);
|
setPinOutput(C15);
|
||||||
writePinLow(C15);
|
writePinLow(C15);
|
||||||
chThdSleepMilliseconds(100);
|
chThdSleepMilliseconds(10);
|
||||||
writePinHigh(C15);
|
writePinHigh(C15);
|
||||||
chThdSleepMilliseconds(100);
|
chThdSleepMilliseconds(10);
|
||||||
|
|
||||||
/* Initialize the lighting UART */
|
/* Initialize the lighting UART */
|
||||||
uartStart(&UARTD3, &uart_cfg);
|
uartStart(&UARTD3, &uart_cfg);
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,14 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "quantum.h"
|
#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. */
|
/* The fully-featured LAYOUT() that has every single key available in the matrix. */
|
||||||
#define LAYOUT(\
|
#define LAYOUT(\
|
||||||
k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, k0c, k0d, \
|
k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, k0c, k0d, \
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,6 @@
|
||||||
|
|
||||||
#include QMK_KEYBOARD_H
|
#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 */
|
/* Default Anne Pro layout, macOS style with LALT and LWIN switched */
|
||||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
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_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_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_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(
|
[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_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,
|
||||||
_______, _______, KC_UP, _______, ANNERGB, ANNERAT, ANNEBRT, ANNEMOD, KC_UP, KC_SLCK, KC_PAUS, KC_HOME, KC_END, KC_PSCR,
|
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,
|
||||||
_______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, KC_LEFT, KC_DOWN, KC_RGHT, KC_PGUP, KC_PGDN, _______,
|
XXXXXXX, KC_LEFT, KC_DOWN, KC_RGHT, XXXXXXX, XXXXXXX, XXXXXXX, KC_LEFT, KC_DOWN, KC_RGHT, KC_PGUP, KC_PGDN, XXXXXXX,
|
||||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, KC_INS, KC_DEL, _______,
|
_______, 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue