mirror of
https://github.com/qmk/qmk_firmware.git
synced 2024-11-22 03:19:24 +00:00
Merge remote-tracking branch 'origin/master' into develop
This commit is contained in:
commit
7121a228eb
@ -24,7 +24,7 @@
|
||||
#define RAM_MAGIC_LOCATION 0x20001ffc
|
||||
#define IAP_MAGIC_VALUE 0x0000fab2
|
||||
|
||||
static const SerialConfig ledUartInitConfig = {
|
||||
static const SerialConfig led_uart_init_config = {
|
||||
.speed = 115200,
|
||||
};
|
||||
|
||||
@ -32,21 +32,25 @@ static const SerialConfig ledUartInitConfig = {
|
||||
# define LED_UART_BAUD_RATE 115200
|
||||
#endif // LED_UART_BAUD_RATE
|
||||
|
||||
static const SerialConfig ledUartRuntimeConfig = {
|
||||
static const SerialConfig led_uart_runtine_config = {
|
||||
.speed = LED_UART_BAUD_RATE,
|
||||
};
|
||||
|
||||
static const SerialConfig bleUartConfig = {
|
||||
static const SerialConfig ble_uart_config = {
|
||||
.speed = 115200,
|
||||
};
|
||||
|
||||
static uint8_t ledMcuWakeup[11] = {0x7b, 0x10, 0x43, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x02};
|
||||
static uint8_t led_mcu_wakeup[11] = {0x7b, 0x10, 0x43, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x02};
|
||||
|
||||
ble_capslock_t BLECapsLock = {._dummy = {0}, .caps_lock = false};
|
||||
ble_capslock_t ble_capslock = {._dummy = {0}, .caps_lock = false};
|
||||
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
static uint8_t current_rgb_row = 0;
|
||||
#endif
|
||||
|
||||
void bootloader_jump(void) {
|
||||
// Send msg to shine to boot into IAP
|
||||
annepro2SetIAP();
|
||||
ap2_set_IAP();
|
||||
|
||||
// wait for shine to boot into IAP
|
||||
wait_ms(15);
|
||||
@ -67,27 +71,27 @@ void bootloader_jump(void) {
|
||||
|
||||
void keyboard_pre_init_kb(void) {
|
||||
// Start LED UART
|
||||
sdStart(&SD0, &ledUartInitConfig);
|
||||
sdStart(&SD0, &led_uart_init_config);
|
||||
/* Let the LED chip settle a bit before switching the mode.
|
||||
* That helped at least one person. */
|
||||
wait_ms(15);
|
||||
sdWrite(&SD0, ledMcuWakeup, sizeof(ledMcuWakeup));
|
||||
sdWrite(&SD0, led_mcu_wakeup, sizeof(led_mcu_wakeup));
|
||||
|
||||
// wait to receive response from wakeup
|
||||
wait_ms(15);
|
||||
|
||||
protoInit(&proto, ledCommandCallback);
|
||||
proto_init(&proto, led_command_callback);
|
||||
|
||||
// loop to clear out receive buffer from shine wakeup
|
||||
while (!sdGetWouldBlock(&SD0)) sdGet(&SD0);
|
||||
|
||||
sdStart(&SD0, &ledUartRuntimeConfig);
|
||||
sdStart(&SD0, &led_uart_runtine_config);
|
||||
keyboard_pre_init_user();
|
||||
}
|
||||
|
||||
void keyboard_post_init_kb(void) {
|
||||
// Start BLE UART
|
||||
sdStart(&SD1, &bleUartConfig);
|
||||
sdStart(&SD1, &ble_uart_config);
|
||||
annepro2_ble_startup();
|
||||
|
||||
// Give the send uart thread some time to
|
||||
@ -97,7 +101,11 @@ void keyboard_post_init_kb(void) {
|
||||
// loop to clear out receive buffer from ble wakeup
|
||||
while (!sdGetWouldBlock(&SD1)) sdGet(&SD1);
|
||||
|
||||
annepro2LedGetStatus();
|
||||
ap2_led_get_status();
|
||||
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
ap2_led_enable();
|
||||
#endif
|
||||
|
||||
keyboard_post_init_user();
|
||||
}
|
||||
@ -106,25 +114,35 @@ 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);
|
||||
sdReadTimeout(&SD1, (uint8_t *)&ble_capslock, sizeof(ble_capslock_t), 10);
|
||||
}
|
||||
|
||||
/* While there's data from LED keyboard sent - read it. */
|
||||
while (!sdGetWouldBlock(&SD0)) {
|
||||
uint8_t byte = sdGet(&SD0);
|
||||
protoConsume(&proto, byte);
|
||||
proto_consume(&proto, byte);
|
||||
}
|
||||
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
/* If there's data ready to be sent to LED MCU - send it. */
|
||||
if(rgb_row_changed[current_rgb_row])
|
||||
{
|
||||
rgb_row_changed[current_rgb_row] = 0;
|
||||
ap2_led_mask_set_row(current_rgb_row);
|
||||
}
|
||||
current_rgb_row = (current_rgb_row + 1) % NUM_ROW;
|
||||
#endif
|
||||
|
||||
matrix_scan_user();
|
||||
}
|
||||
|
||||
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
||||
if (record->event.pressed) {
|
||||
if (annepro2LedStatus.matrixEnabled && annepro2LedStatus.isReactive) {
|
||||
annepro2LedForwardKeypress(record->event.key.row, record->event.key.col);
|
||||
if (ap2_led_status.matrix_enabled && ap2_led_status.is_reactive) {
|
||||
ap2_led_forward_keypress(record->event.key.row, record->event.key.col);
|
||||
}
|
||||
|
||||
const annepro2Led_t blue = {
|
||||
const ap2_led_t blue = {
|
||||
.p.blue = 0xff,
|
||||
.p.red = 0x00,
|
||||
.p.green = 0x00,
|
||||
@ -135,22 +153,22 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
||||
case KC_AP2_BT1:
|
||||
annepro2_ble_broadcast(0);
|
||||
/* FIXME: This hardcodes col/row position */
|
||||
annepro2LedBlink(0, 1, blue, 8, 50);
|
||||
ap2_led_blink(0, 1, blue, 8, 50);
|
||||
return false;
|
||||
|
||||
case KC_AP2_BT2:
|
||||
annepro2_ble_broadcast(1);
|
||||
annepro2LedBlink(0, 2, blue, 8, 50);
|
||||
ap2_led_blink(0, 2, blue, 8, 50);
|
||||
return false;
|
||||
|
||||
case KC_AP2_BT3:
|
||||
annepro2_ble_broadcast(2);
|
||||
annepro2LedBlink(0, 3, blue, 8, 50);
|
||||
ap2_led_blink(0, 3, blue, 8, 50);
|
||||
return false;
|
||||
|
||||
case KC_AP2_BT4:
|
||||
annepro2_ble_broadcast(3);
|
||||
annepro2LedBlink(0, 4, blue, 8, 50);
|
||||
ap2_led_blink(0, 4, blue, 8, 50);
|
||||
return false;
|
||||
|
||||
case KC_AP2_USB:
|
||||
@ -162,37 +180,43 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
||||
return false;
|
||||
|
||||
case KC_AP_LED_OFF:
|
||||
annepro2LedDisable();
|
||||
ap2_led_disable();
|
||||
break;
|
||||
|
||||
case KC_AP_LED_ON:
|
||||
if (annepro2LedStatus.matrixEnabled) {
|
||||
annepro2LedNextProfile();
|
||||
if (ap2_led_status.matrix_enabled) {
|
||||
ap2_led_next_profile();
|
||||
} else {
|
||||
annepro2LedEnable();
|
||||
ap2_led_enable();
|
||||
}
|
||||
annepro2LedResetForegroundColor();
|
||||
ap2_led_reset_foreground_color();
|
||||
break;
|
||||
|
||||
case KC_AP_LED_NEXT_PROFILE:
|
||||
annepro2LedNextProfile();
|
||||
annepro2LedResetForegroundColor();
|
||||
ap2_led_next_profile();
|
||||
ap2_led_reset_foreground_color();
|
||||
break;
|
||||
|
||||
case KC_AP_LED_PREV_PROFILE:
|
||||
annepro2LedPrevProfile();
|
||||
annepro2LedResetForegroundColor();
|
||||
ap2_led_prev_profile();
|
||||
ap2_led_reset_foreground_color();
|
||||
break;
|
||||
|
||||
case KC_AP_LED_NEXT_INTENSITY:
|
||||
annepro2LedNextIntensity();
|
||||
annepro2LedResetForegroundColor();
|
||||
ap2_led_next_intensity();
|
||||
ap2_led_reset_foreground_color();
|
||||
return false;
|
||||
|
||||
case KC_AP_LED_SPEED:
|
||||
annepro2LedNextAnimationSpeed();
|
||||
annepro2LedResetForegroundColor();
|
||||
ap2_led_next_animation_speed();
|
||||
ap2_led_reset_foreground_color();
|
||||
return false;
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
case RGB_TOG:
|
||||
if(rgb_matrix_is_enabled()) ap2_led_disable();
|
||||
else ap2_led_enable();
|
||||
return true;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
|
@ -24,16 +24,16 @@ typedef struct __attribute__((__packed__)) {
|
||||
uint8_t _dummy[10];
|
||||
bool caps_lock;
|
||||
} ble_capslock_t;
|
||||
extern ble_capslock_t BLECapsLock;
|
||||
extern ble_capslock_t ble_capslock;
|
||||
|
||||
// Matrix keymap
|
||||
// clang-format off
|
||||
#define LAYOUT( \
|
||||
#define LAYOUT_60_ansi( \
|
||||
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \
|
||||
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
|
||||
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, \
|
||||
K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, \
|
||||
K40, K42, K43, K46, K49, K4A, K4B, K4C \
|
||||
K40, K42, K43, K46, K49, K4A, K4B, K4C \
|
||||
) { \
|
||||
/* COL1 COL2 COL3 COL4 COL5 COL6 COL7 COL8 COL9 COL10 COL11 COL12 COL13 COL14*/ \
|
||||
/* ROW1 */ { K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D }, \
|
||||
|
@ -35,47 +35,47 @@ static host_driver_t ap2_ble_driver = {
|
||||
ap2_ble_leds, ap2_ble_keyboard, ap2_ble_mouse, ap2_ble_system, ap2_ble_consumer,
|
||||
};
|
||||
|
||||
static uint8_t bleMcuWakeup[11] = {0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x01, 0x7d, 0x02, 0x01, 0x02};
|
||||
static uint8_t ble_mcu_wakeup[11] = {0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x01, 0x7d, 0x02, 0x01, 0x02};
|
||||
|
||||
static uint8_t bleMcuStartBroadcast[11] = {
|
||||
static uint8_t ble_mcu_start_broadcast[11] = {
|
||||
0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x01, 0x00 // Broadcast ID[0-3]
|
||||
};
|
||||
|
||||
static uint8_t bleMcuConnect[11] = {
|
||||
static uint8_t ble_mcu_connect[11] = {
|
||||
0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x04, 0x00 // Connect ID [0-3]
|
||||
};
|
||||
|
||||
static uint8_t bleMcuSendReport[10] = {
|
||||
static uint8_t ble_mcu_send_report[10] = {
|
||||
0x7b, 0x12, 0x53, 0x00, 0x0A, 0x00, 0x00, 0x7d, 0x10, 0x04,
|
||||
};
|
||||
|
||||
static uint8_t bleMcuSendConsumerReport[10] = {
|
||||
static uint8_t ble_mcu_send_consumer_report[10] = {
|
||||
0x7b, 0x12, 0x53, 0x00, 0x06, 0x00, 0x00, 0x7d, 0x10, 0x08,
|
||||
};
|
||||
|
||||
static uint8_t bleMcuUnpair[10] = {
|
||||
static uint8_t ble_mcu_unpair[10] = {
|
||||
0x7b, 0x12, 0x53, 0x00, 0x02, 0x00, 0x00, 0x7d, 0x40, 0x05,
|
||||
};
|
||||
|
||||
static uint8_t bleMcuBootload[11] = {0x7b, 0x10, 0x51, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x01};
|
||||
static uint8_t ble_mcu_bootload[11] = {0x7b, 0x10, 0x51, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x01};
|
||||
|
||||
static host_driver_t *lastHostDriver = NULL;
|
||||
static host_driver_t *last_host_driver = NULL;
|
||||
#ifdef NKRO_ENABLE
|
||||
static bool lastNkroStatus = false;
|
||||
#endif // NKRO_ENABLE
|
||||
|
||||
/* -------------------- Public Function Implementation ---------------------- */
|
||||
|
||||
void annepro2_ble_bootload(void) { sdWrite(&SD1, bleMcuBootload, sizeof(bleMcuBootload)); }
|
||||
void annepro2_ble_bootload(void) { sdWrite(&SD1, ble_mcu_bootload, sizeof(ble_mcu_bootload)); }
|
||||
|
||||
void annepro2_ble_startup(void) { sdWrite(&SD1, bleMcuWakeup, sizeof(bleMcuWakeup)); }
|
||||
void annepro2_ble_startup(void) { sdWrite(&SD1, ble_mcu_wakeup, sizeof(ble_mcu_wakeup)); }
|
||||
|
||||
void annepro2_ble_broadcast(uint8_t port) {
|
||||
if (port > 3) {
|
||||
port = 3;
|
||||
}
|
||||
// sdPut(&SD1, 0x00);
|
||||
sdWrite(&SD1, bleMcuStartBroadcast, sizeof(bleMcuStartBroadcast));
|
||||
sdWrite(&SD1, ble_mcu_start_broadcast, sizeof(ble_mcu_start_broadcast));
|
||||
sdPut(&SD1, port);
|
||||
static int lastBroadcast = -1;
|
||||
if (lastBroadcast == port) {
|
||||
@ -88,7 +88,7 @@ void annepro2_ble_connect(uint8_t port) {
|
||||
if (port > 3) {
|
||||
port = 3;
|
||||
}
|
||||
sdWrite(&SD1, bleMcuConnect, sizeof(bleMcuConnect));
|
||||
sdWrite(&SD1, ble_mcu_connect, sizeof(ble_mcu_connect));
|
||||
sdPut(&SD1, port);
|
||||
ap2_ble_swtich_ble_driver();
|
||||
}
|
||||
@ -103,12 +103,12 @@ void annepro2_ble_disconnect(void) {
|
||||
#ifdef NKRO_ENABLE
|
||||
keymap_config.nkro = lastNkroStatus;
|
||||
#endif
|
||||
host_set_driver(lastHostDriver);
|
||||
host_set_driver(last_host_driver);
|
||||
}
|
||||
|
||||
void annepro2_ble_unpair(void) {
|
||||
// sdPut(&SD1, 0x0);
|
||||
sdWrite(&SD1, bleMcuUnpair, sizeof(bleMcuUnpair));
|
||||
sdWrite(&SD1, ble_mcu_unpair, sizeof(ble_mcu_unpair));
|
||||
}
|
||||
|
||||
/* ------------------- Static Function Implementation ----------------------- */
|
||||
@ -117,7 +117,7 @@ static void ap2_ble_swtich_ble_driver(void) {
|
||||
return;
|
||||
}
|
||||
clear_keyboard();
|
||||
lastHostDriver = host_get_driver();
|
||||
last_host_driver = host_get_driver();
|
||||
#ifdef NKRO_ENABLE
|
||||
lastNkroStatus = keymap_config.nkro;
|
||||
#endif
|
||||
@ -154,7 +154,7 @@ static inline uint16_t CONSUMER2AP2(uint16_t usage) {
|
||||
|
||||
static void ap2_ble_consumer(uint16_t data) {
|
||||
sdPut(&SD1, 0x0);
|
||||
sdWrite(&SD1, bleMcuSendConsumerReport, sizeof(bleMcuSendConsumerReport));
|
||||
sdWrite(&SD1, ble_mcu_send_consumer_report, sizeof(ble_mcu_send_consumer_report));
|
||||
sdPut(&SD1, CONSUMER2AP2(data));
|
||||
static const uint8_t dummy[3] = {0};
|
||||
sdWrite(&SD1, dummy, sizeof(dummy));
|
||||
@ -165,6 +165,6 @@ static void ap2_ble_consumer(uint16_t data) {
|
||||
*/
|
||||
static void ap2_ble_keyboard(report_keyboard_t *report) {
|
||||
sdPut(&SD1, 0x0);
|
||||
sdWrite(&SD1, bleMcuSendReport, sizeof(bleMcuSendReport));
|
||||
sdWrite(&SD1, ble_mcu_send_report, sizeof(ble_mcu_send_report));
|
||||
sdWrite(&SD1, &report->raw[0], KEYBOARD_REPORT_SIZE);
|
||||
}
|
||||
|
@ -21,28 +21,29 @@
|
||||
#include "ap2_led.h"
|
||||
#include "protocol.h"
|
||||
|
||||
annepro2Led_t ledMask[KEY_COUNT];
|
||||
annepro2LedStatus_t annepro2LedStatus;
|
||||
ap2_led_t led_mask[KEY_COUNT];
|
||||
ap2_led_status_t ap2_led_status;
|
||||
uint8_t rgb_row_changed[NUM_ROW];
|
||||
|
||||
void ledCommandCallback(const message_t *msg) {
|
||||
void led_command_callback(const message_t *msg) {
|
||||
switch (msg->command) {
|
||||
case CMD_LED_STATUS:
|
||||
annepro2LedStatus.amountOfProfiles = msg->payload[0];
|
||||
annepro2LedStatus.currentProfile = msg->payload[1];
|
||||
annepro2LedStatus.matrixEnabled = msg->payload[2];
|
||||
annepro2LedStatus.isReactive = msg->payload[3];
|
||||
annepro2LedStatus.ledIntensity = msg->payload[4];
|
||||
annepro2LedStatus.errors = msg->payload[5];
|
||||
ap2_led_status.amount_of_profiles = msg->payload[0];
|
||||
ap2_led_status.current_profile = msg->payload[1];
|
||||
ap2_led_status.matrix_enabled = msg->payload[2];
|
||||
ap2_led_status.is_reactive = msg->payload[3];
|
||||
ap2_led_status.led_intensity = msg->payload[4];
|
||||
ap2_led_status.errors = msg->payload[5];
|
||||
break;
|
||||
|
||||
#ifdef CONSOLE_ENABLE
|
||||
case CMD_LED_DEBUG:
|
||||
/* TODO: Don't use printf. */
|
||||
printf("LED:");
|
||||
for (int i = 0; i < msg->payloadSize; i++) {
|
||||
for (int i = 0; i < msg->payload_size; i++) {
|
||||
printf("%02x ", msg->payload[i]);
|
||||
}
|
||||
for (int i = 0; i < msg->payloadSize; i++) {
|
||||
for (int i = 0; i < msg->payload_size; i++) {
|
||||
printf("%c", msg->payload[i]);
|
||||
}
|
||||
printf("\n");
|
||||
@ -51,63 +52,63 @@ void ledCommandCallback(const message_t *msg) {
|
||||
}
|
||||
}
|
||||
|
||||
void annepro2SetIAP(void) { protoTx(CMD_LED_IAP, NULL, 0, 3); }
|
||||
void ap2_set_IAP(void) { proto_tx(CMD_LED_IAP, NULL, 0, 3); }
|
||||
|
||||
void annepro2LedDisable(void) { protoTx(CMD_LED_OFF, NULL, 0, 3); }
|
||||
void ap2_led_disable(void) { proto_tx(CMD_LED_OFF, NULL, 0, 3); }
|
||||
|
||||
void annepro2LedEnable(void) { protoTx(CMD_LED_ON, NULL, 0, 3); }
|
||||
void ap2_led_enable(void) { proto_tx(CMD_LED_ON, NULL, 0, 3); }
|
||||
|
||||
void annepro2LedSetProfile(uint8_t prof) { protoTx(CMD_LED_SET_PROFILE, &prof, sizeof(prof), 3); }
|
||||
void ap2_led_set_profile(uint8_t prof) { proto_tx(CMD_LED_SET_PROFILE, &prof, sizeof(prof), 3); }
|
||||
|
||||
void annepro2LedGetStatus() { protoTx(CMD_LED_GET_STATUS, NULL, 0, 3); }
|
||||
void ap2_led_get_status() { proto_tx(CMD_LED_GET_STATUS, NULL, 0, 3); }
|
||||
|
||||
void annepro2LedNextProfile() { protoTx(CMD_LED_NEXT_PROFILE, NULL, 0, 3); }
|
||||
void ap2_led_next_profile() { proto_tx(CMD_LED_NEXT_PROFILE, NULL, 0, 3); }
|
||||
|
||||
void annepro2LedNextIntensity() { protoTx(CMD_LED_NEXT_INTENSITY, NULL, 0, 3); }
|
||||
void ap2_led_next_intensity() { proto_tx(CMD_LED_NEXT_INTENSITY, NULL, 0, 3); }
|
||||
|
||||
void annepro2LedNextAnimationSpeed() { protoTx(CMD_LED_NEXT_ANIMATION_SPEED, NULL, 0, 3); }
|
||||
void ap2_led_next_animation_speed() { proto_tx(CMD_LED_NEXT_ANIMATION_SPEED, NULL, 0, 3); }
|
||||
|
||||
void annepro2LedPrevProfile() { protoTx(CMD_LED_PREV_PROFILE, NULL, 0, 3); }
|
||||
void ap2_led_prev_profile() { proto_tx(CMD_LED_PREV_PROFILE, NULL, 0, 3); }
|
||||
|
||||
void annepro2LedMaskSetKey(uint8_t row, uint8_t col, annepro2Led_t color) {
|
||||
void ap2_led_mask_set_key(uint8_t row, uint8_t col, ap2_led_t color) {
|
||||
uint8_t payload[] = {row, col, color.p.blue, color.p.green, color.p.red, color.p.alpha};
|
||||
protoTx(CMD_LED_MASK_SET_KEY, payload, sizeof(payload), 1);
|
||||
proto_tx(CMD_LED_MASK_SET_KEY, payload, sizeof(payload), 1);
|
||||
}
|
||||
|
||||
/* Push a whole local row to the shine */
|
||||
void annepro2LedMaskSetRow(uint8_t row) {
|
||||
uint8_t payload[NUM_COLUMN * sizeof(annepro2Led_t) + 1];
|
||||
void ap2_led_mask_set_row(uint8_t row) {
|
||||
uint8_t payload[NUM_COLUMN * sizeof(ap2_led_t) + 1];
|
||||
payload[0] = row;
|
||||
memcpy(payload + 1, &ledMask[ROWCOL2IDX(row, 0)], sizeof(*ledMask) * NUM_COLUMN);
|
||||
protoTx(CMD_LED_MASK_SET_ROW, payload, sizeof(payload), 1);
|
||||
memcpy(payload + 1, &led_mask[ROWCOL2IDX(row, 0)], sizeof(*led_mask) * NUM_COLUMN);
|
||||
proto_tx(CMD_LED_MASK_SET_ROW, payload, sizeof(payload), 1);
|
||||
}
|
||||
|
||||
/* Synchronize all rows */
|
||||
void annepro2LedMaskSetAll(void) {
|
||||
for (int row = 0; row < 5; row++) annepro2LedMaskSetRow(row);
|
||||
void ap2_led_mask_set_all(void) {
|
||||
for (int row = 0; row < 5; row++) ap2_led_mask_set_row(row);
|
||||
}
|
||||
|
||||
/* Set all keys to a given color */
|
||||
void annepro2LedMaskSetMono(const annepro2Led_t color) { protoTx(CMD_LED_MASK_SET_MONO, (uint8_t *)&color, sizeof(color), 1); }
|
||||
void ap2_led_mask_set_mono(const ap2_led_t color) { proto_tx(CMD_LED_MASK_SET_MONO, (uint8_t *)&color, sizeof(color), 1); }
|
||||
|
||||
void annepro2LedBlink(uint8_t row, uint8_t col, annepro2Led_t color, uint8_t count, uint8_t hundredths) {
|
||||
void ap2_led_blink(uint8_t row, uint8_t col, ap2_led_t color, uint8_t count, uint8_t hundredths) {
|
||||
uint8_t payload[] = {row, col, color.p.blue, color.p.green, color.p.red, color.p.alpha, count, hundredths};
|
||||
protoTx(CMD_LED_KEY_BLINK, payload, sizeof(payload), 1);
|
||||
proto_tx(CMD_LED_KEY_BLINK, payload, sizeof(payload), 1);
|
||||
}
|
||||
|
||||
void annepro2LedSetForegroundColor(uint8_t red, uint8_t green, uint8_t blue) {
|
||||
annepro2Led_t color = {.p.red = red, .p.green = green, .p.blue = blue, .p.alpha = 0xff};
|
||||
annepro2LedMaskSetMono(color);
|
||||
void ap2_led_set_foreground_color(uint8_t red, uint8_t green, uint8_t blue) {
|
||||
ap2_led_t color = {.p.red = red, .p.green = green, .p.blue = blue, .p.alpha = 0xff};
|
||||
ap2_led_mask_set_mono(color);
|
||||
}
|
||||
|
||||
void annepro2LedResetForegroundColor() {
|
||||
annepro2Led_t color = {
|
||||
void ap2_led_reset_foreground_color() {
|
||||
ap2_led_t color = {
|
||||
.p.red = 0,
|
||||
.p.green = 0,
|
||||
.p.blue = 0,
|
||||
.p.alpha = 0,
|
||||
};
|
||||
annepro2LedMaskSetMono(color);
|
||||
ap2_led_mask_set_mono(color);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -128,7 +129,7 @@ void annepro2LedResetForegroundColor() {
|
||||
* Following it are 3 bits of row and 4 bits of col.
|
||||
* 1 + 3 + 4 = 8 bits - only a single byte is sent for every keypress.
|
||||
*/
|
||||
void annepro2LedForwardKeypress(uint8_t row, uint8_t col) {
|
||||
void ap2_led_forward_keypress(uint8_t row, uint8_t col) {
|
||||
const uint8_t payload = row << 4 | col;
|
||||
protoTx(CMD_LED_KEY_DOWN, &payload, 1, 1);
|
||||
proto_tx(CMD_LED_KEY_DOWN, &payload, 1, 1);
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
/* Copyright 2021 OpenAnnePro community
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
@ -31,54 +31,63 @@ typedef union {
|
||||
uint8_t pv[4];
|
||||
/* 0xrgb in mem is b g r a */
|
||||
uint32_t rgb;
|
||||
} annepro2Led_t;
|
||||
} ap2_led_t;
|
||||
|
||||
#define ROWCOL2IDX(row, col) (NUM_COLUMN * (row) + (col))
|
||||
#define NUM_COLUMN 14
|
||||
#define NUM_ROW 5
|
||||
#define KEY_COUNT 70
|
||||
|
||||
/* Local copy of ledMask, used to override colors on the board */
|
||||
extern annepro2Led_t ledMask[KEY_COUNT];
|
||||
/* Local copy of led_mask, used to override colors on the board */
|
||||
extern ap2_led_t led_mask[KEY_COUNT];
|
||||
extern uint8_t rgb_row_changed[NUM_ROW];
|
||||
|
||||
/* Handle incoming messages */
|
||||
extern void ledCommandCallback(const message_t *msg);
|
||||
extern void led_command_callback(const message_t *msg);
|
||||
|
||||
void annepro2SetIAP(void);
|
||||
void annepro2LedDisable(void);
|
||||
void annepro2LedEnable(void);
|
||||
void annepro2LedSetProfile(uint8_t prof);
|
||||
void annepro2LedGetStatus(void);
|
||||
void annepro2LedNextProfile(void);
|
||||
void annepro2LedPrevProfile(void);
|
||||
void annepro2LedNextIntensity(void);
|
||||
void annepro2LedNextAnimationSpeed(void);
|
||||
void annepro2LedForwardKeypress(uint8_t row, uint8_t col);
|
||||
void ap2_set_IAP(void);
|
||||
void ap2_led_disable(void);
|
||||
void ap2_led_enable(void);
|
||||
void ap2_led_set_profile(uint8_t prof);
|
||||
void ap2_led_get_status(void);
|
||||
void ap2_led_next_profile(void);
|
||||
void ap2_led_prev_profile(void);
|
||||
void ap2_led_next_intensity(void);
|
||||
void ap2_led_next_animation_speed(void);
|
||||
void ap2_led_forward_keypress(uint8_t row, uint8_t col);
|
||||
|
||||
/* Set single key to a given color; alpha controls which is displayed */
|
||||
void annepro2LedMaskSetKey(uint8_t row, uint8_t col, annepro2Led_t color);
|
||||
void ap2_led_mask_set_key(uint8_t row, uint8_t col, ap2_led_t color);
|
||||
/* Push a whole local row to the shine */
|
||||
void annepro2LedMaskSetRow(uint8_t row);
|
||||
void ap2_led_mask_set_row(uint8_t row);
|
||||
/* Synchronize all rows */
|
||||
void annepro2LedMaskSetAll(void);
|
||||
void ap2_led_mask_set_all(void);
|
||||
|
||||
/* Set all keys to a given color */
|
||||
void annepro2LedMaskSetMono(annepro2Led_t color);
|
||||
void ap2_led_mask_set_mono(ap2_led_t color);
|
||||
|
||||
/* Blink given key `count` times by masking it with a `color`. Blink takes `hundredths` of a second */
|
||||
void annepro2LedBlink(uint8_t row, uint8_t col, annepro2Led_t color, uint8_t count, uint8_t hundredths);
|
||||
void ap2_led_blink(uint8_t row, uint8_t col, ap2_led_t color, uint8_t count, uint8_t hundredths);
|
||||
|
||||
/* Kept for compatibility, but implemented using masks */
|
||||
void annepro2LedSetForegroundColor(uint8_t red, uint8_t green, uint8_t blue);
|
||||
void annepro2LedResetForegroundColor(void);
|
||||
void ap2_led_set_foreground_color(uint8_t red, uint8_t green, uint8_t blue);
|
||||
void ap2_led_reset_foreground_color(void);
|
||||
|
||||
typedef struct {
|
||||
uint8_t amountOfProfiles;
|
||||
uint8_t currentProfile;
|
||||
uint8_t matrixEnabled;
|
||||
uint8_t isReactive;
|
||||
uint8_t ledIntensity;
|
||||
uint8_t amount_of_profiles;
|
||||
uint8_t current_profile;
|
||||
uint8_t matrix_enabled;
|
||||
uint8_t is_reactive;
|
||||
uint8_t led_intensity;
|
||||
uint8_t errors;
|
||||
} annepro2LedStatus_t;
|
||||
} ap2_led_status_t;
|
||||
|
||||
extern annepro2LedStatus_t annepro2LedStatus;
|
||||
extern ap2_led_status_t ap2_led_status;
|
||||
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
/* RGB driver functions */
|
||||
void init(void);
|
||||
void flush(void);
|
||||
void set_color(int index, uint8_t r, uint8_t g, uint8_t b);
|
||||
void set_color_all(uint8_t r, uint8_t g, uint8_t b);
|
||||
#endif
|
||||
|
@ -18,6 +18,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "pin_defs.h"
|
||||
#include "config_led.h"
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xfeed
|
||||
|
@ -3,7 +3,9 @@ SRC = \
|
||||
matrix.c \
|
||||
annepro2_ble.c \
|
||||
ap2_led.c \
|
||||
protocol.c
|
||||
protocol.c \
|
||||
rgb_driver.c \
|
||||
config_led.c
|
||||
|
||||
# MCU
|
||||
MCU = cortex-m0plus
|
||||
@ -24,6 +26,7 @@ NKRO_ENABLE = no
|
||||
MOUSEKEY_ENABLE = no
|
||||
EXTRAKEY_ENABLE = yes
|
||||
KEY_LOCK_ENABLE = no
|
||||
LAYOUTS = 60_ansi
|
||||
|
||||
# Other featues
|
||||
BOOTMAGIC_ENABLE = no
|
||||
|
@ -18,6 +18,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "pin_defs.h"
|
||||
#include "config_led.h"
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xfeed
|
||||
|
@ -3,7 +3,9 @@ SRC = \
|
||||
matrix.c \
|
||||
annepro2_ble.c \
|
||||
ap2_led.c \
|
||||
protocol.c
|
||||
protocol.c \
|
||||
rgb_driver.c \
|
||||
config_led.c
|
||||
|
||||
# MCU
|
||||
MCU = cortex-m0plus
|
||||
@ -24,6 +26,7 @@ NKRO_ENABLE = no
|
||||
MOUSEKEY_ENABLE = no
|
||||
EXTRAKEY_ENABLE = yes
|
||||
KEY_LOCK_ENABLE = no
|
||||
LAYOUTS = 60_ansi
|
||||
|
||||
# Other featues
|
||||
BOOTMAGIC_ENABLE = yes
|
||||
|
43
keyboards/annepro2/config_led.c
Normal file
43
keyboards/annepro2/config_led.c
Normal file
@ -0,0 +1,43 @@
|
||||
/* Copyright 2022 Jose Pablo Ramirez <jp.ramangulo@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
|
||||
#include "rgb_matrix.h"
|
||||
#include "config_led.h"
|
||||
|
||||
#define NA NO_LED
|
||||
|
||||
led_config_t g_led_config = { {
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 },
|
||||
{ 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 },
|
||||
{ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, NA },
|
||||
{ 41, NA, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, NA },
|
||||
{ 53, NA, 54, 55, NA, NA, 56, NA, NA, 57, 58, 59, 60, NA }
|
||||
}, {
|
||||
{ 0 , 0 }, { 16, 0 }, { 32, 0 }, { 48, 0 }, { 65, 0 }, { 81, 0 }, { 97 , 0 }, { 113, 0 }, { 129, 0 }, { 145, 0 }, { 161, 0 }, { 178, 0 }, { 194, 0 }, { 218, 0 },
|
||||
{ 4 , 16 }, { 24, 16 }, { 40, 16 }, { 57, 16 }, { 73, 16 }, { 89, 16 }, { 105, 16 }, { 121, 16 }, { 137, 16 }, { 153, 16 }, { 170, 16 }, { 186, 16 }, { 202, 16 }, { 222, 16 },
|
||||
{ 6 , 32 }, { 28, 32 }, { 44, 32 }, { 61, 32 }, { 77, 32 }, { 93, 32 }, { 109, 32 }, { 125, 32 }, { 141, 32 }, { 157, 32 }, { 174, 32 }, { 190, 32 }, { 216, 32 },
|
||||
{ 10, 48 }, { 36, 48 }, { 52, 48 }, { 69, 48 }, { 85, 48 }, { 101, 48 }, { 117, 48 }, { 133, 48 }, { 149, 48 }, { 165, 48 }, { 182, 48 }, { 212, 48 },
|
||||
{ 2 , 64 }, { 22, 64 }, { 42, 64 }, { 103, 64 }, { 163, 64 }, { 184, 64 }, { 204, 64 }, { 224, 64 },
|
||||
}, {
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
|
||||
1, 1, 1, 4, 1, 1, 1, 1,
|
||||
} };
|
||||
#endif
|
72
keyboards/annepro2/config_led.h
Normal file
72
keyboards/annepro2/config_led.h
Normal file
@ -0,0 +1,72 @@
|
||||
/* Copyright 2022 Jose Pablo Ramirez <jp.ramangulo@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
|
||||
#define DRIVER_LED_TOTAL 61
|
||||
|
||||
/* Limit animations to 62.5 FPS to avoid tearing. (1/.016 = 62.5 FPS). */
|
||||
#define RGB_MATRIX_LED_FLUSH_LIMIT 16
|
||||
|
||||
#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
|
||||
#define RGB_MATRIX_KEYPRESSES
|
||||
#define ENABLE_RGB_MATRIX_ALPHAS_MODS
|
||||
#define ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN
|
||||
#define ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT
|
||||
#define ENABLE_RGB_MATRIX_BREATHING
|
||||
#define ENABLE_RGB_MATRIX_BAND_SAT
|
||||
#define ENABLE_RGB_MATRIX_BAND_VAL
|
||||
#define ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT
|
||||
#define ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL
|
||||
#define ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT
|
||||
#define ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL
|
||||
#define ENABLE_RGB_MATRIX_CYCLE_ALL
|
||||
#define ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
|
||||
#define ENABLE_RGB_MATRIX_CYCLE_UP_DOWN
|
||||
#define ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
|
||||
#define ENABLE_RGB_MATRIX_CYCLE_OUT_IN
|
||||
#define ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL
|
||||
#define ENABLE_RGB_MATRIX_CYCLE_PINWHEEL
|
||||
#define ENABLE_RGB_MATRIX_CYCLE_SPIRAL
|
||||
#define ENABLE_RGB_MATRIX_DUAL_BEACON
|
||||
#define ENABLE_RGB_MATRIX_RAINBOW_BEACON
|
||||
#define ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS
|
||||
#define ENABLE_RGB_MATRIX_RAINDROPS
|
||||
#define ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
|
||||
#define ENABLE_RGB_MATRIX_HUE_BREATHING
|
||||
#define ENABLE_RGB_MATRIX_HUE_PENDULUM
|
||||
#define ENABLE_RGB_MATRIX_HUE_WAVE
|
||||
#define ENABLE_RGB_MATRIX_PIXEL_FRACTAL
|
||||
#define ENABLE_RGB_MATRIX_PIXEL_FLOW
|
||||
#define ENABLE_RGB_MATRIX_PIXEL_RAIN
|
||||
#define ENABLE_RGB_MATRIX_TYPING_HEATMAP
|
||||
#define ENABLE_RGB_MATRIX_DIGITAL_RAIN
|
||||
#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
|
||||
#define ENABLE_RGB_MATRIX_SOLID_REACTIVE
|
||||
#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE
|
||||
#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE
|
||||
#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS
|
||||
#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS
|
||||
#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS
|
||||
#define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS
|
||||
#define ENABLE_RGB_MATRIX_SPLASH
|
||||
#define ENABLE_RGB_MATRIX_MULTISPLASH
|
||||
#define ENABLE_RGB_MATRIX_SOLID_SPLASH
|
||||
#define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH
|
||||
|
||||
#endif
|
@ -3,7 +3,7 @@
|
||||
"url": "https://openannepro.github.io/",
|
||||
"maintainer": "community",
|
||||
"layouts": {
|
||||
"LAYOUT": {
|
||||
"LAYOUT_60_ansi": {
|
||||
"layout": [
|
||||
{
|
||||
"label": "~",
|
||||
|
@ -1,32 +1,31 @@
|
||||
/* Copyright 2021 OpenAnnePro community
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
|
||||
enum anne_pro_layers {
|
||||
_BASE_LAYER,
|
||||
_FN1_LAYER,
|
||||
_FN2_LAYER,
|
||||
BASE,
|
||||
FN1,
|
||||
FN2,
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
|
||||
// Key symbols are based on QMK. Use them to remap your keyboard
|
||||
/*
|
||||
* Layer _BASE_LAYER
|
||||
* Layer BASE
|
||||
* ,-----------------------------------------------------------------------------------------.
|
||||
* | esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bksp |
|
||||
* |-----------------------------------------------------------------------------------------+
|
||||
@ -38,7 +37,7 @@ enum anne_pro_layers {
|
||||
* |-----------------------------------------------------------------------------------------+
|
||||
* | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl |
|
||||
* \-----------------------------------------------------------------------------------------/
|
||||
* Layer TAP in _BASE_LAYER
|
||||
* Layer TAP in BASE
|
||||
* ,-----------------------------------------------------------------------------------------.
|
||||
* | | | | | | | | | | | | | | |
|
||||
* |-----------------------------------------------------------------------------------------+
|
||||
@ -52,15 +51,15 @@ enum anne_pro_layers {
|
||||
* \-----------------------------------------------------------------------------------------/
|
||||
*/
|
||||
const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[_BASE_LAYER] = LAYOUT( /* Base */
|
||||
KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC,
|
||||
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,
|
||||
LT(_FN1_LAYER,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, RSFT_T(KC_UP),
|
||||
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LT(_FN1_LAYER,KC_LEFT), LT(_FN2_LAYER,KC_DOWN), RCTL_T(KC_RGHT)
|
||||
[BASE] = LAYOUT_60_ansi( /* Base */
|
||||
KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC,
|
||||
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,
|
||||
LT(FN1, 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, RSFT_T(KC_UP),
|
||||
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LT(FN1, KC_LEFT), LT(FN2, KC_DOWN), RCTL_T(KC_RGHT)
|
||||
),
|
||||
/*
|
||||
* Layer _FN1_LAYER
|
||||
* Layer FN1
|
||||
* ,-----------------------------------------------------------------------------------------.
|
||||
* | ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE |
|
||||
* |-----------------------------------------------------------------------------------------+
|
||||
@ -74,15 +73,15 @@ enum anne_pro_layers {
|
||||
* \-----------------------------------------------------------------------------------------/
|
||||
*
|
||||
*/
|
||||
[_FN1_LAYER] = LAYOUT( /* Base */
|
||||
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_DEL,
|
||||
KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS,
|
||||
KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS,
|
||||
KC_TRNS, KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN2_LAYER), KC_TRNS
|
||||
[FN1] = LAYOUT_60_ansi( /* FN1 */
|
||||
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_DEL,
|
||||
_______, _______, KC_UP, _______, _______, _______, _______, _______, _______, _______, KC_PSCR, KC_HOME, KC_END, _______,
|
||||
_______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, _______, KC_PGUP, KC_PGDN, _______,
|
||||
_______, KC_VOLU, KC_VOLD, KC_MUTE, _______, _______, _______, _______, _______, KC_INS, KC_DEL, _______,
|
||||
_______, _______, _______, _______, _______, _______, MO(FN2), _______
|
||||
),
|
||||
/*
|
||||
* Layer _FN2_LAYER
|
||||
* Layer FN2
|
||||
* ,-----------------------------------------------------------------------------------------.
|
||||
* | ~ | BT1 | BT2 | BT3 | BT4 | F5 | F6 | F7 |LEDOF|LEDON| F10 | F11 | F12 | Bksp |
|
||||
* |-----------------------------------------------------------------------------------------+
|
||||
@ -96,24 +95,23 @@ enum anne_pro_layers {
|
||||
* \-----------------------------------------------------------------------------------------/
|
||||
*
|
||||
*/
|
||||
[_FN2_LAYER] = LAYOUT( /* Base */
|
||||
KC_TRNS, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_AP_LED_NEXT_INTENSITY, KC_AP_LED_SPEED, KC_TRNS, KC_TRNS,
|
||||
MO(_FN2_LAYER), KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS,
|
||||
KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN1_LAYER), MO(_FN2_LAYER), KC_TRNS
|
||||
[FN2] = LAYOUT_60_ansi( /* FN2 */
|
||||
_______, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, _______, _______, _______, KC_AP_LED_OFF, KC_AP_LED_ON, _______, _______, _______, _______,
|
||||
MO(FN2), _______, KC_UP, _______, _______, _______, _______, _______, _______, _______, KC_PSCR, KC_HOME, KC_END, _______,
|
||||
_______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, _______, KC_PGUP, KC_PGDN, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, KC_INS, KC_DEL, _______,
|
||||
_______, _______, _______, _______, _______, MO(FN1), MO(FN2), _______
|
||||
),
|
||||
};
|
||||
|
||||
// clang-format on
|
||||
|
||||
// The function to handle the caps lock logic
|
||||
bool led_update_user(led_t leds) {
|
||||
if (leds.caps_lock) {
|
||||
// Set the leds to red
|
||||
annepro2LedSetForegroundColor(0xFF, 0x00, 0x00);
|
||||
ap2_led_set_foreground_color(0xFF, 0x00, 0x00);
|
||||
} else {
|
||||
annepro2LedResetForegroundColor();
|
||||
ap2_led_reset_foreground_color();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1,32 +1,31 @@
|
||||
/* Copyright 2021 OpenAnnePro community
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
|
||||
enum anne_pro_layers {
|
||||
_BASE_LAYER,
|
||||
_FN1_LAYER,
|
||||
_FN2_LAYER,
|
||||
BASE,
|
||||
FN1,
|
||||
FN2,
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
|
||||
// Key symbols are based on QMK. Use them to remap your keyboard
|
||||
/*
|
||||
* Layer _BASE_LAYER
|
||||
* Layer BASE
|
||||
* ,-----------------------------------------------------------------------------------------.
|
||||
* | esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bksp |
|
||||
* |-----------------------------------------------------------------------------------------+
|
||||
@ -38,7 +37,7 @@ enum anne_pro_layers {
|
||||
* |-----------------------------------------------------------------------------------------+
|
||||
* | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl |
|
||||
* \-----------------------------------------------------------------------------------------/
|
||||
* Layer TAP in _BASE_LAYER
|
||||
* Layer TAP in BASE
|
||||
* ,-----------------------------------------------------------------------------------------.
|
||||
* | | | | | | | | | | | | | | |
|
||||
* |-----------------------------------------------------------------------------------------+
|
||||
@ -52,15 +51,15 @@ enum anne_pro_layers {
|
||||
* \-----------------------------------------------------------------------------------------/
|
||||
*/
|
||||
const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[_BASE_LAYER] = LAYOUT( /* Base */
|
||||
KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC,
|
||||
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,
|
||||
LT(_FN1_LAYER,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, RSFT_T(KC_UP),
|
||||
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LT(_FN1_LAYER,KC_LEFT), LT(_FN2_LAYER,KC_DOWN), RCTL_T(KC_RGHT)
|
||||
[BASE] = LAYOUT_60_ansi( /* Base */
|
||||
KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC,
|
||||
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,
|
||||
LT(FN1, 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, RSFT_T(KC_UP),
|
||||
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LT(FN1, KC_LEFT), LT(FN2, KC_DOWN), RCTL_T(KC_RGHT)
|
||||
),
|
||||
/*
|
||||
* Layer _FN1_LAYER
|
||||
* Layer FN1
|
||||
* ,-----------------------------------------------------------------------------------------.
|
||||
* | ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE |
|
||||
* |-----------------------------------------------------------------------------------------+
|
||||
@ -74,15 +73,15 @@ enum anne_pro_layers {
|
||||
* \-----------------------------------------------------------------------------------------/
|
||||
*
|
||||
*/
|
||||
[_FN1_LAYER] = LAYOUT( /* Base */
|
||||
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_DEL,
|
||||
KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS,
|
||||
KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS,
|
||||
KC_TRNS, KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN2_LAYER), KC_TRNS
|
||||
[FN1] = LAYOUT_60_ansi( /* FN1 */
|
||||
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_DEL,
|
||||
_______, _______, KC_UP, _______, _______, _______, _______, _______, _______, _______, KC_PSCR, KC_HOME, KC_END, _______,
|
||||
_______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, _______, KC_PGUP, KC_PGDN, _______,
|
||||
_______, KC_VOLU, KC_VOLD, KC_MUTE, _______, _______, _______, _______, _______, KC_INS, KC_DEL, _______,
|
||||
_______, _______, _______, _______, _______, _______, MO(FN2), _______
|
||||
),
|
||||
/*
|
||||
* Layer _FN2_LAYER
|
||||
* Layer FN2
|
||||
* ,-----------------------------------------------------------------------------------------.
|
||||
* | ~ | BT1 | BT2 | BT3 | BT4 | F5 | F6 | F7 |LEDOF|LEDON| F10 | F11 | F12 | Bksp |
|
||||
* |-----------------------------------------------------------------------------------------+
|
||||
@ -96,30 +95,29 @@ enum anne_pro_layers {
|
||||
* \-----------------------------------------------------------------------------------------/
|
||||
*
|
||||
*/
|
||||
[_FN2_LAYER] = LAYOUT( /* Base */
|
||||
KC_TRNS, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_AP_LED_NEXT_INTENSITY, KC_AP_LED_SPEED, KC_TRNS, KC_TRNS,
|
||||
MO(_FN2_LAYER), KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS,
|
||||
KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN1_LAYER), MO(_FN2_LAYER), KC_TRNS
|
||||
[FN2] = LAYOUT_60_ansi( /* FN2 */
|
||||
_______, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, _______, _______, _______, KC_AP_LED_OFF, KC_AP_LED_ON, _______, _______, _______, _______,
|
||||
MO(FN2), _______, KC_UP, _______, _______, _______, _______, _______, _______, _______, KC_PSCR, KC_HOME, KC_END, _______,
|
||||
_______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, _______, KC_PGUP, KC_PGDN, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, KC_INS, KC_DEL, _______,
|
||||
_______, _______, _______, _______, _______, MO(FN1), MO(FN2), _______
|
||||
),
|
||||
};
|
||||
|
||||
// clang-format on
|
||||
|
||||
layer_state_t layer_state_set_user(layer_state_t state) {
|
||||
switch (get_highest_layer(state)) {
|
||||
case _FN1_LAYER:
|
||||
case FN1:
|
||||
// Set the leds to green
|
||||
annepro2LedSetForegroundColor(0x00, 0xFF, 0x00);
|
||||
ap2_led_set_foreground_color(0x00, 0xFF, 0x00);
|
||||
break;
|
||||
case _FN2_LAYER:
|
||||
case FN2:
|
||||
// Set the leds to blue
|
||||
annepro2LedSetForegroundColor(0x00, 0x00, 0xFF);
|
||||
ap2_led_set_foreground_color(0x00, 0x00, 0xFF);
|
||||
break;
|
||||
default:
|
||||
// Reset back to the current profile
|
||||
annepro2LedResetForegroundColor();
|
||||
ap2_led_reset_foreground_color();
|
||||
break;
|
||||
}
|
||||
return state;
|
||||
@ -130,16 +128,16 @@ layer_state_t layer_state_set_user(layer_state_t state) {
|
||||
bool led_update_user(led_t leds) {
|
||||
if (leds.caps_lock) {
|
||||
// Set the caps-lock to red
|
||||
const annepro2Led_t color = {.p.red = 0xff, .p.green = 0x00, .p.blue = 0x00, .p.alpha = 0xff};
|
||||
const ap2_led_t color = {.p.red = 0xff, .p.green = 0x00, .p.blue = 0x00, .p.alpha = 0xff};
|
||||
|
||||
annepro2LedMaskSetKey(2, 0, color);
|
||||
ap2_led_mask_set_key(2, 0, color);
|
||||
/* NOTE: Instead of colouring the capslock only, you can change the whole
|
||||
keyboard with annepro2LedSetForegroundColor */
|
||||
keyboard with ap2_led_set_foreground_color */
|
||||
} else {
|
||||
// Reset the capslock if there is no layer active
|
||||
if (!layer_state_is(_FN1_LAYER) && !layer_state_is(_FN2_LAYER)) {
|
||||
const annepro2Led_t color = {.p.red = 0xff, .p.green = 0x00, .p.blue = 0x00, .p.alpha = 0x00};
|
||||
annepro2LedMaskSetKey(2, 0, color);
|
||||
if (!layer_state_is(FN1) && !layer_state_is(FN2)) {
|
||||
const ap2_led_t color = {.p.red = 0xff, .p.green = 0x00, .p.blue = 0x00, .p.alpha = 0x00};
|
||||
ap2_led_mask_set_key(2, 0, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,31 +1,31 @@
|
||||
/* Copyright 2021 OpenAnnePro community
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
|
||||
enum anne_pro_layers {
|
||||
_BASE_LAYER,
|
||||
_FN1_LAYER,
|
||||
_FN2_LAYER,
|
||||
BASE,
|
||||
FN1,
|
||||
FN2,
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
// Key symbols are based on QMK. Use them to remap your keyboard
|
||||
/*
|
||||
* Layer _BASE_LAYER
|
||||
* Layer BASE
|
||||
* ,-----------------------------------------------------------------------------------------.
|
||||
* | esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bksp |
|
||||
* |-----------------------------------------------------------------------------------------+
|
||||
@ -37,7 +37,7 @@ enum anne_pro_layers {
|
||||
* |-----------------------------------------------------------------------------------------+
|
||||
* | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl |
|
||||
* \-----------------------------------------------------------------------------------------/
|
||||
* Layer TAP in _BASE_LAYER
|
||||
* Layer TAP in BASE
|
||||
* ,-----------------------------------------------------------------------------------------.
|
||||
* | | | | | | | | | | | | | | |
|
||||
* |-----------------------------------------------------------------------------------------+
|
||||
@ -51,15 +51,15 @@ enum anne_pro_layers {
|
||||
* \-----------------------------------------------------------------------------------------/
|
||||
*/
|
||||
const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[_BASE_LAYER] = LAYOUT( /* Base */
|
||||
KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC,
|
||||
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,
|
||||
LT(_FN1_LAYER,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, RSFT_T(KC_UP),
|
||||
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LT(_FN1_LAYER,KC_LEFT), LT(_FN2_LAYER,KC_DOWN), RCTL_T(KC_RGHT)
|
||||
[BASE] = LAYOUT_60_ansi( /* Base */
|
||||
KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC,
|
||||
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,
|
||||
LT(FN1, 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, RSFT_T(KC_UP),
|
||||
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LT(FN1, KC_LEFT), LT(FN2, KC_DOWN), RCTL_T(KC_RGHT)
|
||||
),
|
||||
/*
|
||||
* Layer _FN1_LAYER
|
||||
* Layer FN1
|
||||
* ,-----------------------------------------------------------------------------------------.
|
||||
* | ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE |
|
||||
* |-----------------------------------------------------------------------------------------+
|
||||
@ -73,17 +73,17 @@ enum anne_pro_layers {
|
||||
* \-----------------------------------------------------------------------------------------/
|
||||
*
|
||||
*/
|
||||
[_FN1_LAYER] = LAYOUT( /* Base */
|
||||
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_DEL,
|
||||
KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS,
|
||||
KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS,
|
||||
KC_TRNS, KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN2_LAYER), KC_TRNS
|
||||
[FN1] = LAYOUT_60_ansi( /* FN1 */
|
||||
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_DEL,
|
||||
_______, _______, KC_UP, _______, _______, _______, _______, _______, _______, _______, KC_PSCR, KC_HOME, KC_END, _______,
|
||||
_______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, _______, KC_PGUP, KC_PGDN, _______,
|
||||
_______, KC_VOLU, KC_VOLD, KC_MUTE, _______, _______, _______, _______, _______, KC_INS, KC_DEL, _______,
|
||||
_______, _______, _______, _______, _______, _______, MO(FN2), _______
|
||||
),
|
||||
/*
|
||||
* Layer _FN2_LAYER
|
||||
* Layer FN2
|
||||
* ,-----------------------------------------------------------------------------------------.
|
||||
* | ~ | BT1 | BT2 | BT3 | BT4 | F5 | F6 | F7 |LEDOF|LEDON| F10 | F11 | F12 | Bksp |
|
||||
* | ~ | BT1 | BT2 | BT3 | BT4 | F5 | F6 | HUE | SAT | BRI | SPD | MOD | TOG | Bksp |
|
||||
* |-----------------------------------------------------------------------------------------+
|
||||
* | Tab | q | UP | e | r | t | y | u | i | o | PS | HOME | END | \ |
|
||||
* |-----------------------------------------------------------------------------------------+
|
||||
@ -95,12 +95,12 @@ enum anne_pro_layers {
|
||||
* \-----------------------------------------------------------------------------------------/
|
||||
*
|
||||
*/
|
||||
[_FN2_LAYER] = LAYOUT( /* Base */
|
||||
KC_TRNS, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_AP_LED_NEXT_INTENSITY, KC_AP_LED_SPEED, KC_TRNS, KC_TRNS,
|
||||
MO(_FN2_LAYER), KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS,
|
||||
KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN1_LAYER), MO(_FN2_LAYER), KC_TRNS
|
||||
[FN2] = LAYOUT_60_ansi( /* FN2 */
|
||||
_______, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, _______, _______, RGB_HUI, RGB_SAI, RGB_VAI, RGB_SPI, RGB_MOD, RGB_TOG, _______,
|
||||
MO(FN2), _______, KC_UP, _______, _______, _______, _______, _______, _______, _______, KC_PSCR, KC_HOME, KC_END, _______,
|
||||
_______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, _______, KC_PGUP, KC_PGDN, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, KC_INS, KC_DEL, _______,
|
||||
_______, _______, _______, _______, _______, MO(FN1), MO(FN2), _______
|
||||
),
|
||||
};
|
||||
// clang-format on
|
||||
|
3
keyboards/annepro2/keymaps/default/rules.mk
Normal file
3
keyboards/annepro2/keymaps/default/rules.mk
Normal file
@ -0,0 +1,3 @@
|
||||
# Custom RGB matrix handling
|
||||
RGB_MATRIX_ENABLE = yes
|
||||
RGB_MATRIX_DRIVER = custom
|
@ -20,38 +20,38 @@
|
||||
/* UART communication protocol state */
|
||||
protocol_t proto;
|
||||
|
||||
void protoInit(protocol_t *proto, void (*callback)(const message_t *)) {
|
||||
proto->previousId = 0;
|
||||
void proto_init(protocol_t *proto, void (*callback)(const message_t *)) {
|
||||
proto->previous_id = 0;
|
||||
proto->callback = callback;
|
||||
proto->state = STATE_SYNC_1;
|
||||
proto->errors = 0;
|
||||
}
|
||||
|
||||
static uint8_t msgId = 0;
|
||||
void protoTx(uint8_t cmd, const unsigned char *buf, int payloadSize, int retries) {
|
||||
chDbgCheck(payloadSize <= MAX_PAYLOAD_SIZE);
|
||||
static uint8_t msg_id = 0;
|
||||
void proto_tx(uint8_t cmd, const unsigned char *buf, int payload_size, int retries) {
|
||||
chDbgCheck(payload_size <= MAX_PAYLOAD_SIZE);
|
||||
|
||||
const uint8_t header[5] = {
|
||||
0x7A, 0x1D, cmd, ++msgId, payloadSize,
|
||||
0x7A, 0x1D, cmd, ++msg_id, payload_size,
|
||||
};
|
||||
|
||||
/* We don't implement ACKs, yet some messages should not be lost. */
|
||||
for (int i = 0; i < retries; i++) {
|
||||
sdWrite(&PROTOCOL_SD, header, sizeof(header));
|
||||
if (payloadSize) sdWrite(&PROTOCOL_SD, buf, payloadSize);
|
||||
if (payload_size) sdWrite(&PROTOCOL_SD, buf, payload_size);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void messageReceived(protocol_t *proto) {
|
||||
if (proto->buffer.msgId != proto->previousId) {
|
||||
if (proto->buffer.msg_id != proto->previous_id) {
|
||||
/* It's not a resend / duplicate */
|
||||
proto->callback(&proto->buffer);
|
||||
proto->previousId = proto->buffer.msgId;
|
||||
proto->previous_id = proto->buffer.msg_id;
|
||||
}
|
||||
proto->state = STATE_SYNC_1;
|
||||
}
|
||||
|
||||
void protoConsume(protocol_t *proto, uint8_t byte) {
|
||||
void proto_consume(protocol_t *proto, uint8_t byte) {
|
||||
switch (proto->state) {
|
||||
case STATE_SYNC_1:
|
||||
if (byte == 0x7A) {
|
||||
@ -76,18 +76,18 @@ void protoConsume(protocol_t *proto, uint8_t byte) {
|
||||
return;
|
||||
|
||||
case STATE_ID:
|
||||
proto->buffer.msgId = byte;
|
||||
proto->buffer.msg_id = byte;
|
||||
proto->state = STATE_PAYLOAD_SIZE;
|
||||
return;
|
||||
|
||||
case STATE_PAYLOAD_SIZE:
|
||||
proto->buffer.payloadSize = byte;
|
||||
if (proto->buffer.payloadSize > MAX_PAYLOAD_SIZE) {
|
||||
proto->buffer.payloadSize = MAX_PAYLOAD_SIZE;
|
||||
proto->buffer.payload_size = byte;
|
||||
if (proto->buffer.payload_size > MAX_PAYLOAD_SIZE) {
|
||||
proto->buffer.payload_size = MAX_PAYLOAD_SIZE;
|
||||
proto->errors++;
|
||||
}
|
||||
proto->payloadPosition = 0;
|
||||
if (proto->buffer.payloadSize == 0) {
|
||||
proto->payload_position = 0;
|
||||
if (proto->buffer.payload_size == 0) {
|
||||
/* No payload - whole message received */
|
||||
messageReceived(proto);
|
||||
} else {
|
||||
@ -98,9 +98,9 @@ void protoConsume(protocol_t *proto, uint8_t byte) {
|
||||
case STATE_PAYLOAD:
|
||||
/* NOTE: This could be read with sdReadTimeout probably, but that breaks
|
||||
* abstraction */
|
||||
proto->buffer.payload[proto->payloadPosition] = byte;
|
||||
proto->payloadPosition++;
|
||||
if (proto->payloadPosition == proto->buffer.payloadSize) {
|
||||
proto->buffer.payload[proto->payload_position] = byte;
|
||||
proto->payload_position++;
|
||||
if (proto->payload_position == proto->buffer.payload_size) {
|
||||
/* Payload read - message received */
|
||||
messageReceived(proto);
|
||||
}
|
||||
@ -108,7 +108,7 @@ void protoConsume(protocol_t *proto, uint8_t byte) {
|
||||
}
|
||||
}
|
||||
|
||||
void protoSilence(protocol_t *proto) {
|
||||
void proto_silence(protocol_t *proto) {
|
||||
if (proto->state != STATE_SYNC_1) {
|
||||
proto->state = STATE_SYNC_1;
|
||||
proto->errors++;
|
||||
|
@ -55,7 +55,7 @@ enum {
|
||||
#define MAX_PAYLOAD_SIZE 64
|
||||
|
||||
/** Enum of the states used for the serial protocol finite-state automaton */
|
||||
enum protoState {
|
||||
enum proto_state {
|
||||
/* 2-byte initial start-of-message sync */
|
||||
STATE_SYNC_1,
|
||||
STATE_SYNC_2,
|
||||
@ -65,15 +65,15 @@ enum protoState {
|
||||
STATE_ID,
|
||||
/* Waiting for payload size */
|
||||
STATE_PAYLOAD_SIZE,
|
||||
/* Reading payload until payloadPosition == payloadSize */
|
||||
/* Reading payload until payload_position == payload_size */
|
||||
STATE_PAYLOAD,
|
||||
};
|
||||
|
||||
/* Buffer holding a single message */
|
||||
typedef struct {
|
||||
uint8_t command;
|
||||
uint8_t msgId;
|
||||
uint8_t payloadSize;
|
||||
uint8_t msg_id;
|
||||
uint8_t payload_size;
|
||||
uint8_t payload[MAX_PAYLOAD_SIZE];
|
||||
} message_t;
|
||||
|
||||
@ -83,12 +83,12 @@ typedef struct {
|
||||
void (*callback)(const message_t *);
|
||||
|
||||
/* Number of read payload bytes */
|
||||
uint8_t payloadPosition;
|
||||
uint8_t payload_position;
|
||||
|
||||
/* Current finite-state-automata state */
|
||||
enum protoState state;
|
||||
enum proto_state state;
|
||||
|
||||
uint8_t previousId;
|
||||
uint8_t previous_id;
|
||||
uint8_t errors;
|
||||
|
||||
/* Currently received message */
|
||||
@ -99,13 +99,13 @@ typedef struct {
|
||||
extern protocol_t proto;
|
||||
|
||||
/* Init state */
|
||||
extern void protoInit(protocol_t *proto, void (*callback)(const message_t *));
|
||||
extern void proto_init(protocol_t *proto, void (*callback)(const message_t *));
|
||||
|
||||
/* Consume one byte and push state forward - might call the callback */
|
||||
extern void protoConsume(protocol_t *proto, uint8_t byte);
|
||||
extern void proto_consume(protocol_t *proto, uint8_t byte);
|
||||
|
||||
/* Prolonged silence - reset state */
|
||||
extern void protoSilence(protocol_t *proto);
|
||||
extern void proto_silence(protocol_t *proto);
|
||||
|
||||
/* Transmit message */
|
||||
extern void protoTx(uint8_t cmd, const unsigned char *buf, int payloadSize, int retries);
|
||||
extern void proto_tx(uint8_t cmd, const unsigned char *buf, int payload_size, int retries);
|
||||
|
66
keyboards/annepro2/rgb_driver.c
Normal file
66
keyboards/annepro2/rgb_driver.c
Normal file
@ -0,0 +1,66 @@
|
||||
/* Copyright 2022 Jose Pablo Ramirez <jp.ramangulo@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
|
||||
#include "rgb_matrix.h"
|
||||
#include "ap2_led.h"
|
||||
|
||||
uint8_t led_pos[DRIVER_LED_TOTAL];
|
||||
|
||||
void init(void) {
|
||||
unsigned int i = 0;
|
||||
for (unsigned int y = 0; y < NUM_ROW; y++) {
|
||||
for (unsigned int x = 0; x < NUM_COLUMN; x++) {
|
||||
if (g_led_config.matrix_co[y][x] != NO_LED) {
|
||||
led_pos[g_led_config.matrix_co[y][x]] = i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void flush(void) {}
|
||||
|
||||
void set_color(int index, uint8_t r, uint8_t g, uint8_t b) {
|
||||
if (r != led_mask[led_pos[index]].p.red ||
|
||||
g != led_mask[led_pos[index]].p.green ||
|
||||
b != led_mask[led_pos[index]].p.blue)
|
||||
{
|
||||
led_mask[led_pos[index]] = (ap2_led_t){
|
||||
.p.blue = b,
|
||||
.p.red = r,
|
||||
.p.green = g,
|
||||
.p.alpha = 0xff,
|
||||
};
|
||||
int row = led_pos[index] / NUM_COLUMN;
|
||||
rgb_row_changed[row] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void set_color_all(uint8_t r, uint8_t g, uint8_t b) {
|
||||
for (int i=0; i<DRIVER_LED_TOTAL; i++)
|
||||
set_color(i, r, g, b);
|
||||
}
|
||||
|
||||
const rgb_matrix_driver_t rgb_matrix_driver = {
|
||||
.init = init,
|
||||
.flush = flush,
|
||||
.set_color = set_color,
|
||||
.set_color_all = set_color_all,
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user