diff options
author | lokher <lokher@gmail.com> | 2022-12-06 17:10:48 +0800 |
---|---|---|
committer | lokher <lokher@gmail.com> | 2022-12-07 15:50:49 +0800 |
commit | a336c2c5005251e4cb0f3a62ccabdb4cfccad915 (patch) | |
tree | 3c948b631a5e3b6f940dabe02fad3c7487e6f350 /keyboards/annepro2 | |
parent | 27fc28fd2ff52e079a5bc58d6aaea4c752420615 (diff) |
Merge upstream master to 2022 Q4 breaking change
Diffstat (limited to 'keyboards/annepro2')
-rw-r--r-- | keyboards/annepro2/annepro2.c | 289 | ||||
-rw-r--r-- | keyboards/annepro2/annepro2.h | 84 | ||||
-rw-r--r-- | keyboards/annepro2/annepro2_ble.c | 171 | ||||
-rw-r--r-- | keyboards/annepro2/ap2_led.c | 179 | ||||
-rw-r--r-- | keyboards/annepro2/ap2_led.h | 110 | ||||
-rw-r--r-- | keyboards/annepro2/c18/rules.mk | 56 | ||||
-rw-r--r-- | keyboards/annepro2/config_led.h | 72 | ||||
-rw-r--r-- | keyboards/annepro2/info.json | 150 | ||||
-rw-r--r-- | keyboards/annepro2/keymaps/iso_default/keymap.c | 106 | ||||
-rw-r--r-- | keyboards/annepro2/rgb_driver.c | 62 |
10 files changed, 0 insertions, 1279 deletions
diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c deleted file mode 100644 index f4ced65436..0000000000 --- a/keyboards/annepro2/annepro2.c +++ /dev/null @@ -1,289 +0,0 @@ -/* 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/>. - */ - -#include "hal.h" -#include "annepro2.h" -#include "annepro2_ble.h" -#include "spi_master.h" -#include "ap2_led.h" -#include "protocol.h" - -#define RAM_MAGIC_LOCATION 0x20001ffc -#define IAP_MAGIC_VALUE 0x0000fab2 - -static const SerialConfig led_uart_init_config = { - .speed = 115200, -}; - -#ifndef LED_UART_BAUD_RATE -# define LED_UART_BAUD_RATE 115200 -#endif // LED_UART_BAUD_RATE - -static const SerialConfig led_uart_runtine_config = { - .speed = LED_UART_BAUD_RATE, -}; - -static const SerialConfig ble_uart_config = { - .speed = 115200, -}; - -static uint8_t led_mcu_wakeup[11] = {0x7b, 0x10, 0x43, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x02}; - -ble_capslock_t ble_capslock = {._dummy = {0}, .caps_lock = false}; - -#ifdef RGB_MATRIX_ENABLE -static uint8_t led_enabled = 1; -#endif - -void bootloader_jump(void) { - // Send msg to shine to boot into IAP - ap2_set_IAP(); - - // wait for shine to boot into IAP - wait_ms(15); - - // Load ble into IAP - annepro2_ble_bootload(); - wait_ms(15); - - // Magic key to set keyboard to IAP - // It’s from reversing original boot loader - // If value is that it stays in boot loader aka IAP - *((uint32_t *)RAM_MAGIC_LOCATION) = IAP_MAGIC_VALUE; - - // Load the main MCU into IAP - __disable_irq(); - NVIC_SystemReset(); -} - -void keyboard_pre_init_kb(void) { - // Start LED UART - 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, led_mcu_wakeup, sizeof(led_mcu_wakeup)); - - // wait to receive response from wakeup - wait_ms(15); - - proto_init(&proto, led_command_callback); - - // loop to clear out receive buffer from shine wakeup - while (!sdGetWouldBlock(&SD0)) sdGet(&SD0); - - sdStart(&SD0, &led_uart_runtine_config); - keyboard_pre_init_user(); -} - -void keyboard_post_init_kb(void) { - // Start BLE UART - sdStart(&SD1, &ble_uart_config); - annepro2_ble_startup(); - - // Give the send uart thread some time to - // send out the queue before we read back - wait_ms(100); - - // loop to clear out receive buffer from ble wakeup - while (!sdGetWouldBlock(&SD1)) sdGet(&SD1); - - ap2_led_get_status(); - - #ifdef RGB_MATRIX_ENABLE - ap2_led_enable(); - ap2_led_set_manual_control(1); - #endif - - keyboard_post_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 *)&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); - proto_consume(&proto, byte); - } - - - matrix_scan_user(); -} - -bool process_record_kb(uint16_t keycode, keyrecord_t *record) { - if (record->event.pressed) { - if (ap2_led_status.matrix_enabled && ap2_led_status.is_reactive) { - ap2_led_forward_keypress(record->event.key.row, record->event.key.col); - } - - const ap2_led_t blue = { - .p.blue = 0xff, - .p.red = 0x00, - .p.green = 0x00, - .p.alpha = 0xff, - }; - - switch (keycode) { - case KC_AP2_BT1: - annepro2_ble_broadcast(0); - /* FIXME: This hardcodes col/row position */ - ap2_led_blink(record->event.key.row, record->event.key.col, blue, 8, 50); - return false; - - case KC_AP2_BT2: - annepro2_ble_broadcast(1); - ap2_led_blink(record->event.key.row, record->event.key.col, blue, 8, 50); - return false; - - case KC_AP2_BT3: - annepro2_ble_broadcast(2); - ap2_led_blink(record->event.key.row, record->event.key.col, blue, 8, 50); - return false; - - case KC_AP2_BT4: - annepro2_ble_broadcast(3); - ap2_led_blink(record->event.key.row, record->event.key.col, blue, 8, 50); - return false; - - case KC_AP2_USB: - annepro2_ble_disconnect(); - return false; - - case KC_AP2_BT_UNPAIR: - annepro2_ble_unpair(); - return false; - - case KC_AP_LED_OFF: - ap2_led_disable(); - break; - - case KC_AP_LED_ON: - if (ap2_led_status.matrix_enabled) { - ap2_led_next_profile(); - } else { - ap2_led_enable(); - } - ap2_led_reset_foreground_color(); - break; - - case KC_AP_LED_TOG: - if (ap2_led_status.matrix_enabled) { - ap2_led_disable(); - } else { - ap2_led_enable(); - ap2_led_reset_foreground_color(); - } - break; - - case KC_AP_LED_NEXT_PROFILE: - ap2_led_next_profile(); - ap2_led_reset_foreground_color(); - break; - - case KC_AP_LED_PREV_PROFILE: - ap2_led_prev_profile(); - ap2_led_reset_foreground_color(); - break; - - case KC_AP_LED_NEXT_INTENSITY: - ap2_led_next_intensity(); - ap2_led_reset_foreground_color(); - return false; - - case KC_AP_LED_SPEED: - 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; - - case KC_AP_RGB_VAI: - if (record->event.pressed) { - if (get_mods() & MOD_MASK_SHIFT) { - rgb_matrix_increase_hue(); - return false; - } else if (get_mods() & MOD_MASK_CTRL) { - rgb_matrix_decrease_hue(); - return false; - } else { - rgb_matrix_increase_val(); - } - } - return true; - - case KC_AP_RGB_VAD: - if (record->event.pressed) { - if (get_mods() & MOD_MASK_SHIFT) { - rgb_matrix_increase_sat(); - return false; - } else if (get_mods() & MOD_MASK_CTRL) { - rgb_matrix_decrease_sat(); - return false; - } else { - rgb_matrix_decrease_val(); - } - } - return true; - - case KC_AP_RGB_TOG: - if (record->event.pressed) { - if (get_mods() & MOD_MASK_SHIFT) { - rgb_matrix_increase_speed(); - return false; - } else if (get_mods() & MOD_MASK_CTRL) { - rgb_matrix_decrease_speed(); - return false; - } else { - if (led_enabled) { - ap2_led_disable(); - rgb_matrix_disable(); - led_enabled = 0; - } else { - ap2_led_enable(); - rgb_matrix_enable(); - led_enabled = 1; - } - return true; - } - } - return true; - - case KC_AP_RGB_MOD: - if (record->event.pressed) { - if (get_mods() & MOD_MASK_CTRL) { - rgb_matrix_step_reverse(); - return false; - } else { - rgb_matrix_step(); - } - } - return true; - #endif - - default: - break; - } - } - return process_record_user(keycode, record); -} diff --git a/keyboards/annepro2/annepro2.h b/keyboards/annepro2/annepro2.h deleted file mode 100644 index 617c6414d2..0000000000 --- a/keyboards/annepro2/annepro2.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2018 Yaotian Feng - * - * 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 -#include "quantum.h" -#include <stdint.h> -#include "ap2_led.h" - -typedef struct __attribute__((__packed__)) { - uint8_t _dummy[10]; - bool caps_lock; -} ble_capslock_t; -extern ble_capslock_t ble_capslock; - -// Matrix keymap -// clang-format off -#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 \ -) { \ - /* 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 }, \ - /* ROW2 */ { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D }, \ - /* ROW3 */ { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, KC_NO}, \ - /* ROW4 */ { K30, KC_NO, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, KC_NO}, \ - /* ROW5 */ { K40, KC_NO, K42, K43, KC_NO, KC_NO, K46, KC_NO, KC_NO, K49, K4A, K4B, K4C, KC_NO}, \ -} -#define LAYOUT_60_iso( \ - 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, \ - K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, \ - K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, \ - 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 }, \ - /* ROW2 */ { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K2D }, \ - /* ROW3 */ { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, KC_NO}, \ - /* ROW4 */ { K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, KC_NO}, \ - /* ROW5 */ { K40, KC_NO, K42, K43, KC_NO, KC_NO, K46, KC_NO, KC_NO, K49, K4A, K4B, K4C, KC_NO}, \ -} -// clang-format on - -enum AP2KeyCodes { - KC_AP2_BT1 = SAFE_RANGE, - KC_AP2_BT2, - KC_AP2_BT3, - KC_AP2_BT4, - KC_AP2_BT_UNPAIR, - KC_AP2_USB, - KC_AP_LED_ON, - KC_AP_LED_OFF, - KC_AP_LED_TOG, - KC_AP_LED_NEXT_PROFILE, - KC_AP_LED_PREV_PROFILE, - KC_AP_LED_NEXT_INTENSITY, - KC_AP_LED_SPEED, - KC_AP_RGB_VAI, - KC_AP_RGB_VAD, - KC_AP_RGB_TOG, - KC_AP_RGB_MOD, - AP2_SAFE_RANGE, -}; - -#undef SAFE_RANGE -#define SAFE_RANGE AP2_SAFE_RANGE - diff --git a/keyboards/annepro2/annepro2_ble.c b/keyboards/annepro2/annepro2_ble.c deleted file mode 100644 index 375f551cc2..0000000000 --- a/keyboards/annepro2/annepro2_ble.c +++ /dev/null @@ -1,171 +0,0 @@ -/* - Copyright (C) 2020 Yaotian Feng, Codetector<codetector@codetector.cn> - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#include "annepro2_ble.h" -#include "ch.h" -#include "hal.h" -#include "host.h" -#include "host_driver.h" -#include "report.h" - -/* -------------------- Static Function Prototypes -------------------------- */ -static uint8_t ap2_ble_leds(void); -static void ap2_ble_mouse(report_mouse_t *report); -static void ap2_ble_extra(report_extra_t *report); -static void ap2_ble_keyboard(report_keyboard_t *report); - -static void ap2_ble_swtich_ble_driver(void); - -/* -------------------- Static Local Variables ------------------------------ */ -static host_driver_t ap2_ble_driver = { - ap2_ble_leds, ap2_ble_keyboard, ap2_ble_mouse, ap2_ble_extra -}; - -static uint8_t ble_mcu_wakeup[11] = {0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x01, 0x7d, 0x02, 0x01, 0x02}; - -static uint8_t ble_mcu_start_broadcast[10] = { - 0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x01, // Broadcast ID[0-3] -}; - -static uint8_t ble_mcu_connect[10] = { - 0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x04, // Connect ID [0-3] -}; - -static uint8_t ble_mcu_send_report[10] = { - 0x7b, 0x12, 0x53, 0x00, 0x0A, 0x00, 0x00, 0x7d, 0x10, 0x04, -}; - -static uint8_t ble_mcu_send_consumer_report[10] = { - 0x7b, 0x12, 0x53, 0x00, 0x06, 0x00, 0x00, 0x7d, 0x10, 0x08, -}; - -static uint8_t ble_mcu_unpair[10] = { - 0x7b, 0x12, 0x53, 0x00, 0x02, 0x00, 0x00, 0x7d, 0x40, 0x05, -}; - -static uint8_t ble_mcu_bootload[11] = {0x7b, 0x10, 0x51, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x01}; - -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, ble_mcu_bootload, sizeof(ble_mcu_bootload)); } - -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, ble_mcu_start_broadcast, sizeof(ble_mcu_start_broadcast)); - sdPut(&SD1, port); - sdPut(&SD1, 0x00); - static int lastBroadcast = -1; - if (lastBroadcast == port) { - annepro2_ble_connect(port); - } - lastBroadcast = port; -} - -void annepro2_ble_connect(uint8_t port) { - if (port > 3) { - port = 3; - } - sdWrite(&SD1, ble_mcu_connect, sizeof(ble_mcu_connect)); - sdPut(&SD1, port); - sdPut(&SD1, 0x00); - ap2_ble_swtich_ble_driver(); -} - -void annepro2_ble_disconnect(void) { - /* Skip if the driver is already enabled */ - if (host_get_driver() != &ap2_ble_driver) { - return; - } - - clear_keyboard(); -#ifdef NKRO_ENABLE - keymap_config.nkro = lastNkroStatus; -#endif - host_set_driver(last_host_driver); -} - -void annepro2_ble_unpair(void) { - // sdPut(&SD1, 0x0); - sdWrite(&SD1, ble_mcu_unpair, sizeof(ble_mcu_unpair)); -} - -/* ------------------- Static Function Implementation ----------------------- */ -static void ap2_ble_swtich_ble_driver(void) { - if (host_get_driver() == &ap2_ble_driver) { - return; - } - clear_keyboard(); - last_host_driver = host_get_driver(); -#ifdef NKRO_ENABLE - lastNkroStatus = keymap_config.nkro; -#endif - keymap_config.nkro = false; - host_set_driver(&ap2_ble_driver); -} - -static uint8_t ap2_ble_leds(void) { - return 0; // TODO: Figure out how to obtain LED status -} - -static void ap2_ble_mouse(report_mouse_t *report) {} - -static inline uint16_t CONSUMER2AP2(uint16_t usage) { - switch (usage) { - case AUDIO_VOL_DOWN: - return 0x04; - case AUDIO_VOL_UP: - return 0x02; - case AUDIO_MUTE: - return 0x01; - case TRANSPORT_PLAY_PAUSE: - return 0x08; - case TRANSPORT_NEXT_TRACK: - return 0x10; - case TRANSPORT_PREV_TRACK: - return 0x20; - default: - return 0x00; - } -} - -static void ap2_ble_extra(report_extra_t *report) { - if (report->report_id == REPORT_ID_CONSUMER) { - sdPut(&SD1, 0x0); - sdWrite(&SD1, ble_mcu_send_consumer_report, sizeof(ble_mcu_send_consumer_report)); - sdPut(&SD1, CONSUMER2AP2(report->usage)); - static const uint8_t dummy[3] = {0}; - sdWrite(&SD1, dummy, sizeof(dummy)); - } -} - -/*! - * @brief Send keyboard HID report for Bluetooth driver - */ -static void ap2_ble_keyboard(report_keyboard_t *report) { - sdPut(&SD1, 0x0); - sdWrite(&SD1, ble_mcu_send_report, sizeof(ble_mcu_send_report)); - sdWrite(&SD1, &report->raw[0], KEYBOARD_REPORT_SIZE); -} diff --git a/keyboards/annepro2/ap2_led.c b/keyboards/annepro2/ap2_led.c deleted file mode 100644 index 339df103bf..0000000000 --- a/keyboards/annepro2/ap2_led.c +++ /dev/null @@ -1,179 +0,0 @@ -/* 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/>. - */ - -#include <string.h> -#include <stdio.h> -#include "hal.h" -#include "annepro2.h" -#include "ap2_led.h" -#include "protocol.h" - -ap2_led_t led_mask[KEY_COUNT]; -ap2_led_t led_colors[KEY_COUNT]; -ap2_led_status_t ap2_led_status; - -void led_command_callback(const message_t *msg) { - switch (msg->command) { - case CMD_LED_STATUS: - 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->payload_size; i++) { - printf("%02x ", msg->payload[i]); - } - for (int i = 0; i < msg->payload_size; i++) { - printf("%c", msg->payload[i]); - } - printf("\n"); - break; -#endif - } -} - -void ap2_set_IAP(void) { proto_tx(CMD_LED_IAP, NULL, 0, 3); } - -void ap2_led_disable(void) { proto_tx(CMD_LED_OFF, NULL, 0, 3); } - -void ap2_led_enable(void) { proto_tx(CMD_LED_ON, NULL, 0, 3); } - -void ap2_led_set_profile(uint8_t prof) { proto_tx(CMD_LED_SET_PROFILE, &prof, sizeof(prof), 3); } - -void ap2_led_get_status() { proto_tx(CMD_LED_GET_STATUS, NULL, 0, 3); } - -void ap2_led_next_profile() { proto_tx(CMD_LED_NEXT_PROFILE, NULL, 0, 3); } - -void ap2_led_next_intensity() { proto_tx(CMD_LED_NEXT_INTENSITY, NULL, 0, 3); } - -void ap2_led_next_animation_speed() { proto_tx(CMD_LED_NEXT_ANIMATION_SPEED, NULL, 0, 3); } - -void ap2_led_prev_profile() { proto_tx(CMD_LED_PREV_PROFILE, NULL, 0, 3); } - -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}; - proto_tx(CMD_LED_MASK_SET_KEY, payload, sizeof(payload), 1); -} - -/* Push a whole local row to the shine */ -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, &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 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 ap2_led_mask_set_mono(const ap2_led_t color) { proto_tx(CMD_LED_MASK_SET_MONO, (uint8_t *)&color, sizeof(color), 1); } - -void ap2_led_colors_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}; - proto_tx(CMD_LED_COLOR_SET_KEY, payload, sizeof(payload), 1); -} - -/* Push a whole local row to the shine */ -void ap2_led_colors_set_row(uint8_t row) { - uint8_t payload[NUM_COLUMN * sizeof(ap2_led_t) + 1]; - payload[0] = row; - memcpy(payload + 1, &led_colors[ROWCOL2IDX(row, 0)], sizeof(*led_colors) * NUM_COLUMN); - proto_tx(CMD_LED_COLOR_SET_ROW, payload, sizeof(payload), 1); -} - -/* Synchronize all rows */ -void ap2_led_colors_set_all(void) { - for (int row = 0; row < 5; row++) ap2_led_colors_set_row(row); -} - -/* Set all keys to a given color */ -void ap2_led_colors_set_mono(const ap2_led_t color) { proto_tx(CMD_LED_COLOR_SET_MONO, (uint8_t *)&color, sizeof(color), 1); } - -void ap2_led_set_manual_control(uint8_t manual) { - uint8_t payload[] = {manual}; - proto_tx(CMD_LED_SET_MANUAL, payload, sizeof(payload), 1); -} - -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}; - proto_tx(CMD_LED_KEY_BLINK, payload, sizeof(payload), 1); -} - -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 ap2_led_reset_foreground_color() { - ap2_led_t color = { - .p.red = 0, - .p.green = 0, - .p.blue = 0, - .p.alpha = 0, - }; - ap2_led_mask_set_mono(color); -} - -void ap2_led_sticky_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}; - proto_tx(CMD_LED_STICKY_SET_KEY, payload, sizeof(payload), 1); -} - -void ap2_led_unset_sticky_key(uint8_t row, uint8_t col) { - uint8_t payload[] = {row, col}; - proto_tx(CMD_LED_STICKY_UNSET_KEY, payload, sizeof(payload), 1); -} - -void ap2_led_unset_sticky_row(uint8_t row) { - uint8_t payload[] = {row}; - proto_tx(CMD_LED_STICKY_UNSET_ROW, payload, sizeof(payload), 1); -} -void ap2_led_unset_sticky_all(void) { - proto_tx(CMD_LED_STICKY_UNSET_ALL, NULL, 0, 1); -} - -/* - * Currently keypresses are unified with other messages, still with single 1 - * byte payload. Transfer is normally fast enough for that to not be a problem - - * especially with asynchronous message reading. - * - * - * Previous description: - * If enabled, this data is sent to LED MCU on every keypress. - * In order to improve performance, both row and column values - * are packed into a single byte. - * Row range is [0, 4] and requires only 3 bits. - * Column range is [0, 13] and requires 4 bits. - * - * In order to differentiate this command from regular commands, - * the leftmost bit is set to 1 (0b10000000). - * 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 ap2_led_forward_keypress(uint8_t row, uint8_t col) { - const uint8_t payload = row << 4 | col; - proto_tx(CMD_LED_KEY_DOWN, &payload, 1, 1); -} diff --git a/keyboards/annepro2/ap2_led.h b/keyboards/annepro2/ap2_led.h deleted file mode 100644 index ff2a05aff5..0000000000 --- a/keyboards/annepro2/ap2_led.h +++ /dev/null @@ -1,110 +0,0 @@ - /* 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/>. - */ - -#pragma once - -#include "protocol.h" - -// Struct defining an LED and its RGB color components -// Compatible with Shine firmware. -typedef union { - struct { - /* Little endian ordering to match uint32_t */ - uint8_t blue, green, red; - /* Used in mask; nonzero means - use color from mask. */ - uint8_t alpha; - } p; /* parts */ - /* Parts vector access: 0 - blue, 1 - green, 2 - red */ - uint8_t pv[4]; - /* 0xrgb in mem is b g r a */ - uint32_t rgb; -} 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 led_mask, used to override colors on the board */ -extern ap2_led_t led_mask[KEY_COUNT]; -extern ap2_led_t led_colors[KEY_COUNT]; - -/* Handle incoming messages */ -extern void led_command_callback(const message_t *msg); - -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 ap2_led_mask_set_key(uint8_t row, uint8_t col, ap2_led_t color); -/* Push a whole local row to the shine */ -void ap2_led_mask_set_row(uint8_t row); -/* Synchronize all rows */ -void ap2_led_mask_set_all(void); - -/* Set all keys to a given color */ -void ap2_led_mask_set_mono(ap2_led_t color); - -/* Set single key to a given color; alpha controls which is displayed */ -void ap2_led_colors_set_key(uint8_t row, uint8_t col, ap2_led_t color); -/* Push a whole local row to the shine */ -void ap2_led_colors_set_row(uint8_t row); -/* Synchronize all rows */ -void ap2_led_colors_set_all(void); - -/* Set all keys to a given color */ -void ap2_led_colors_set_mono(ap2_led_t color); - -void ap2_led_set_manual_control(uint8_t manual); - -/* Blink given key `count` times by masking it with a `color`. Blink takes `hundredths` of a second */ -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 ap2_led_set_foreground_color(uint8_t red, uint8_t green, uint8_t blue); -void ap2_led_reset_foreground_color(void); - -void ap2_led_sticky_set_key(uint8_t row, uint8_t col, ap2_led_t color); -void ap2_led_unset_sticky_key(uint8_t row, uint8_t col); -void ap2_led_unset_sticky_row(uint8_t row); -void ap2_led_unset_sticky_all(void); - -typedef struct { - uint8_t amount_of_profiles; - uint8_t current_profile; - uint8_t matrix_enabled; - uint8_t is_reactive; - uint8_t led_intensity; - uint8_t errors; -} ap2_led_status_t; - -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 diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk deleted file mode 100644 index 752324fc2c..0000000000 --- a/keyboards/annepro2/c18/rules.mk +++ /dev/null @@ -1,56 +0,0 @@ -# MCU -MCU = cortex-m0plus -ARMV = 6 -USE_FPU = no -MCU_FAMILY = HT32 -MCU_SERIES = HT32F523xx -MCU_LDSCRIPT = HT32F52342_ANNEPRO2 -MCU_STARTUP = ht32f523xx - -BOARD = ANNEPRO2_C18 - -# Bootloader selection -BOOTLOADER = custom -PROGRAM_CMD = annepro2_tools --boot $(BUILD_DIR)/$(TARGET).bin - -# Build Options -# change yes to no to disable -# -BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite -MOUSEKEY_ENABLE = no # Mouse keys -EXTRAKEY_ENABLE = yes # Audio control and System control -CONSOLE_ENABLE = no # Console for debug -COMMAND_ENABLE = no # Commands for debug and configuration -NKRO_ENABLE = no # Enable N-Key Rollover -BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality -RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow -AUDIO_ENABLE = no # Audio output - -# Wear-levelling driver -EEPROM_DRIVER = wear_leveling -WEAR_LEVELING_DRIVER = spi_flash - -# Custom RGB matrix handling -RGB_MATRIX_ENABLE = yes -RGB_MATRIX_DRIVER = custom - -# Keys -CUSTOM_MATRIX = lite -KEY_LOCK_ENABLE = no - -# Other features -RAW_ENABLE = no -MIDI_ENABLE = no -VIRTSER_ENABLE = no -COMBO_ENABLE = no - -LAYOUTS = 60_ansi 60_iso - -# Anne Pro 2 -SRC = \ - matrix.c \ - annepro2_ble.c \ - ap2_led.c \ - protocol.c \ - rgb_driver.c \ - config_led.c diff --git a/keyboards/annepro2/config_led.h b/keyboards/annepro2/config_led.h deleted file mode 100644 index e6d4dc35fb..0000000000 --- a/keyboards/annepro2/config_led.h +++ /dev/null @@ -1,72 +0,0 @@ -/* 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 RGB_MATRIX_LED_COUNT 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 < |