From 559220f8c8bde5adb8bcc26bb2328fd47ae03650 Mon Sep 17 00:00:00 2001 From: James Ooi Date: Wed, 4 Mar 2020 23:21:04 +0900 Subject: [PATCH 01/21] Enable battery BLE GATT service and introduced linear li-ion battery percentage calculation --- tmk_core/protocol/lufa/adafruit_ble.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/tmk_core/protocol/lufa/adafruit_ble.cpp b/tmk_core/protocol/lufa/adafruit_ble.cpp index 7b3ffdef7a75..a421a9437ef2 100644 --- a/tmk_core/protocol/lufa/adafruit_ble.cpp +++ b/tmk_core/protocol/lufa/adafruit_ble.cpp @@ -537,14 +537,17 @@ bool adafruit_ble_enable_keyboard(void) { // processing time on my macbook. Keeping it constrained to that // feels reasonable to type to. static const char kGapIntervals[] PROGMEM = "AT+GAPINTERVALS=10,30,,"; - + + // Enable GATT Battery Service + static const char kBattEnOn[] PROGMEM = "AT+BLEBATTEN=1"; + // Reset the device so that it picks up the above changes static const char kATZ[] PROGMEM = "ATZ"; // Turn down the power level a bit static const char kPower[] PROGMEM = "AT+BLEPOWERLEVEL=-12"; static PGM_P const configure_commands[] PROGMEM = { - kEcho, kGapIntervals, kGapDevName, kHidEnOn, kPower, kATZ, + kEcho, kGapIntervals, kGapDevName, kHidEnOn, kPower, kBattEnOn, kATZ, }; uint8_t i; @@ -589,7 +592,8 @@ static void set_connected(bool connected) { void adafruit_ble_task(void) { char resbuf[48]; - + char cmdbuf[48]; + if (!state.configured && !adafruit_ble_enable_keyboard()) { return; } @@ -642,7 +646,17 @@ void adafruit_ble_task(void) { if (timer_elapsed(state.last_battery_update) > BatteryUpdateInterval && resp_buf.empty()) { state.last_battery_update = timer_read(); - state.vbat = analogRead(BATTERY_LEVEL_PIN); + state.vbat = analogReadPin(BATTERY_LEVEL_PIN); + + if (state.vbat >= 862) // around 4.17V, li-ion can charge usually to max of 4.19V + state.vbat = 100; + else if (state.vbat < 820) // around 3.55V, anything below cannot be trusted as 3.5v=816, 3.35v=814, 3.3v=815, 3.2v=816, 3v=817 + state.vbat = 0; + else + state.vbat = (state.vbat - 820) * 99 / 41; + snprintf(cmdbuf, sizeof(cmdbuf), "AT+BLEBATTVAL=%d", state.vbat); + at_command(cmdbuf, NULL, 0, false); + } #endif } From 14ff77f8d947e066e70e1d57018632f9dc1e89aa Mon Sep 17 00:00:00 2001 From: quadcube <13719009+quadcube@users.noreply.github.com> Date: Wed, 3 Feb 2021 17:30:31 +0800 Subject: [PATCH 02/21] Updated with alix40 source code. Rearranged into tokyokeyboard/ --- keyboards/tokyokeyboard/alix40/alix40.c | 22 +++++++ keyboards/tokyokeyboard/alix40/alix40.h | 18 +++++ keyboards/tokyokeyboard/alix40/config.h | 65 +++++++++++++++++++ keyboards/tokyokeyboard/alix40/info.json | 12 ++++ .../alix40}/keymaps/default/config.h | 0 .../alix40/keymaps/default/keymap.bak.c | 59 +++++++++++++++++ .../alix40/keymaps/default/keymap.c | 59 +++++++++++++++++ .../alix40}/keymaps/swappedBottomRow/config.h | 0 .../alix40}/keymaps/swappedBottomRow/keymap.c | 0 keyboards/tokyokeyboard/alix40/readme.md | 15 +++++ keyboards/tokyokeyboard/alix40/rules.mk | 35 ++++++++++ .../{ => tokyokeyboard}/tokyo60/config.h | 0 .../{ => tokyokeyboard}/tokyo60/info.json | 0 .../tokyo60/keymaps/default/config.h | 3 + .../tokyo60/keymaps/default/keymap.c | 0 .../tokyo60/keymaps/swappedBottomRow/config.h | 3 + .../tokyo60/keymaps/swappedBottomRow/keymap.c | 47 ++++++++++++++ .../tokyo60/keymaps/via/keymap.c | 0 .../tokyo60/keymaps/via/rules.mk | 0 .../{ => tokyokeyboard}/tokyo60/readme.md | 0 .../{ => tokyokeyboard}/tokyo60/rules.mk | 0 .../{ => tokyokeyboard}/tokyo60/tokyo60.c | 0 .../{ => tokyokeyboard}/tokyo60/tokyo60.h | 0 tmk_core/protocol/lufa/adafruit_ble.cpp | 4 +- 24 files changed, 339 insertions(+), 3 deletions(-) create mode 100644 keyboards/tokyokeyboard/alix40/alix40.c create mode 100644 keyboards/tokyokeyboard/alix40/alix40.h create mode 100644 keyboards/tokyokeyboard/alix40/config.h create mode 100644 keyboards/tokyokeyboard/alix40/info.json rename keyboards/{tokyo60 => tokyokeyboard/alix40}/keymaps/default/config.h (100%) create mode 100644 keyboards/tokyokeyboard/alix40/keymaps/default/keymap.bak.c create mode 100644 keyboards/tokyokeyboard/alix40/keymaps/default/keymap.c rename keyboards/{tokyo60 => tokyokeyboard/alix40}/keymaps/swappedBottomRow/config.h (100%) rename keyboards/{tokyo60 => tokyokeyboard/alix40}/keymaps/swappedBottomRow/keymap.c (100%) create mode 100644 keyboards/tokyokeyboard/alix40/readme.md create mode 100644 keyboards/tokyokeyboard/alix40/rules.mk rename keyboards/{ => tokyokeyboard}/tokyo60/config.h (100%) rename keyboards/{ => tokyokeyboard}/tokyo60/info.json (100%) create mode 100644 keyboards/tokyokeyboard/tokyo60/keymaps/default/config.h rename keyboards/{ => tokyokeyboard}/tokyo60/keymaps/default/keymap.c (100%) create mode 100644 keyboards/tokyokeyboard/tokyo60/keymaps/swappedBottomRow/config.h create mode 100644 keyboards/tokyokeyboard/tokyo60/keymaps/swappedBottomRow/keymap.c rename keyboards/{ => tokyokeyboard}/tokyo60/keymaps/via/keymap.c (100%) rename keyboards/{ => tokyokeyboard}/tokyo60/keymaps/via/rules.mk (100%) rename keyboards/{ => tokyokeyboard}/tokyo60/readme.md (100%) rename keyboards/{ => tokyokeyboard}/tokyo60/rules.mk (100%) rename keyboards/{ => tokyokeyboard}/tokyo60/tokyo60.c (100%) rename keyboards/{ => tokyokeyboard}/tokyo60/tokyo60.h (100%) diff --git a/keyboards/tokyokeyboard/alix40/alix40.c b/keyboards/tokyokeyboard/alix40/alix40.c new file mode 100644 index 000000000000..96d1a0571400 --- /dev/null +++ b/keyboards/tokyokeyboard/alix40/alix40.c @@ -0,0 +1,22 @@ +#include "alix40.h" + +void matrix_init_kb(void) { + // Keyboard start-up code goes here + // Runs once when the firmware starts up + matrix_init_user(); + led_init_ports(); +}; + +void matrix_scan_kb(void) { + // Looping keyboard code goes here + // This runs every cycle (a lot) + matrix_scan_user(); +}; + +void led_init_ports(void) { + /* LEDs on */ + rgblight_enable(); + rgblight_sethsv(0,0,255); + backlight_enable(); + breathing_enable(); +} diff --git a/keyboards/tokyokeyboard/alix40/alix40.h b/keyboards/tokyokeyboard/alix40/alix40.h new file mode 100644 index 000000000000..f0923dd36faa --- /dev/null +++ b/keyboards/tokyokeyboard/alix40/alix40.h @@ -0,0 +1,18 @@ +#ifndef ALIX_H +#define ALIX_H + +#include "quantum.h" + +#define LAYOUT_40_alix( \ + K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \ + K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \ + K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, \ + K30, K31, K33, K34, K35, K36, K37, K38, K3A, K3B \ +) { \ + { K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B }, \ + { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B }, \ + { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B }, \ + { K30, K31, KC_NO, K33, K34, K35, K36, K37, K38, KC_NO, K3A, K3B } \ +} + +#endif diff --git a/keyboards/tokyokeyboard/alix40/config.h b/keyboards/tokyokeyboard/alix40/config.h new file mode 100644 index 000000000000..52e5f6eedcec --- /dev/null +++ b/keyboards/tokyokeyboard/alix40/config.h @@ -0,0 +1,65 @@ +#ifndef CONFIG_H +#define CONFIG_H + +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x6060 +#define DEVICE_VER 0x0001 +#define MANUFACTURER Tokyo Keyboard +#define PRODUCT alix +#define DESCRIPTION q.m.k. keyboard firmware for alix + +/* key matrix size */ +#define MATRIX_ROWS 4 +#define MATRIX_COLS 12 + +/* number of backlight levels */ +#define BACKLIGHT_PIN B7 +#ifdef BACKLIGHT_PIN +#define BACKLIGHT_LEVELS 31 +#define BACKLIGHT_ON_STATE 1 +#define BACKLIGHT_BREATHING +#endif + +/* COL2ROW or ROW2COL */ +#define DIODE_DIRECTION ROW2COL + +/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ +#define DEBOUNCE 5 + +/* Set power consumption to work with mobile devices */ +#define USB_MAX_POWER_CONSUMPTION 500 + +/* key matrix pins */ +#define MATRIX_ROW_PINS { D7, C6, C7, B5 } +#define MATRIX_COL_PINS { F7, F6, F5, F4, F1, F0, D0, D1, D2, D3, D5, D6 } +#define UNUSED_PINS + +/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ +#define LOCKING_SUPPORT_ENABLE + +/* Locking resynchronize hack */ +#define LOCKING_RESYNC_ENABLE + +#define RGB_DI_PIN B0 +#ifdef RGB_DI_PIN +#define RGBLIGHT_ANIMATIONS +#define RGBLED_NUM 12 +#define RGBLIGHT_HUE_STEP 10 +#define RGBLIGHT_SAT_STEP 10 +#define RGBLIGHT_VAL_STEP 10 +#endif + +/* For Production */ +#define QMK_ESC_OUTPUT F7 // usually COL +#define QMK_ESC_INPUT D7 // usually ROW + +/* Bluetooth */ +#define AdafruitBleResetPin D4 +#define AdafruitBleCSPin B4 +#define AdafruitBleIRQPin E6 + + +#endif diff --git a/keyboards/tokyokeyboard/alix40/info.json b/keyboards/tokyokeyboard/alix40/info.json new file mode 100644 index 000000000000..b8d2033d931f --- /dev/null +++ b/keyboards/tokyokeyboard/alix40/info.json @@ -0,0 +1,12 @@ +{ + "keyboard_name": "alix60", + "url": "", + "maintainer": "qmk", + "width": 12, + "height": 4, + "layouts": { + "LAYOUT_40_alix": { + "layout": [{"label":"Tab", "x":0, "y":0}, {"label":"Q", "x":1, "y":0}, {"label":"W", "x":2, "y":0}, {"label":"E", "x":3, "y":0}, {"label":"R", "x":4, "y":0}, {"label":"T", "x":5, "y":0}, {"label":"Y", "x":6, "y":0}, {"label":"U", "x":7, "y":0}] + } + } +} diff --git a/keyboards/tokyo60/keymaps/default/config.h b/keyboards/tokyokeyboard/alix40/keymaps/default/config.h similarity index 100% rename from keyboards/tokyo60/keymaps/default/config.h rename to keyboards/tokyokeyboard/alix40/keymaps/default/config.h diff --git a/keyboards/tokyokeyboard/alix40/keymaps/default/keymap.bak.c b/keyboards/tokyokeyboard/alix40/keymaps/default/keymap.bak.c new file mode 100644 index 000000000000..028e511b724d --- /dev/null +++ b/keyboards/tokyokeyboard/alix40/keymaps/default/keymap.bak.c @@ -0,0 +1,59 @@ +#include QMK_KEYBOARD_H + +/* + * Default Alix Layout + */ +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: Default layer +┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ +│ Tab │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ ` │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│ Esc │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ' │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│Shift│ Z │ X │ C │ V │ B │Enter│ N │ M │ , │ . │ / │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│Ctrl │ Alt │ │ Gui │█████│Bksp │Space│█████│ Gui │ │ [ │ ] │ +└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ + */ +[0] = LAYOUT_40_alix( + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_GRV, \ + KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \ + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_ENT, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, \ + KC_LCTL, KC_RALT, KC_LGUI,KC_NO, LT(1, KC_BSPC), LT(2, KC_SPC), KC_NO, KC_RGUI, KC_LBRC, KC_RBRC +), +/* 1: Lower Layer +┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ +│ Tab │ ! │ @ │ # │ $ │ % │ ^ │ & │ * │ ( │ ) │ | │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│ Esc | F1 | F2 | F3 | F4 | F5 │Left │Down │ Up │Right│ ; │ ' │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│Shift│ F6 │ F7 │ F8 │ F9 │ F10 │Enter|Next |Vol- |Vol+ | Play│ / │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│Ctrl │ Alt │ │ Gui │█████│Bksp │Space│█████│ Gui │ │ _ │ + │ +└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ + */ +[1]= LAYOUT_40_alix( + KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_PIPE, \ + KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_SCLN, KC_QUOT, \ + KC_LSFT, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_ENT, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, KC_SLSH, \ + KC_LCTL, KC_RALT, KC_LGUI, KC_NO, LT(1, KC_BSPC), LT(2, KC_SPC), KC_NO, KC_RGUI, KC_UNDS, KC_PLUS +), + +/* 2: Raise Layer +┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ +│ Tab │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ \ │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│ Esc │ A │ S │ D │ F │ G │Left │Down │ Up │Right│ ; │ ' │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│Shift│ Z │ X │ C │ V │ B │Enter│PgDn │PgUp │Home │ End │ / │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│Ctrl │ Alt │ │ Gui │█████│Bksp │Space│█████│ Gui │ │ - │ = │ +└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ + */ +[2]= LAYOUT_40_alix( + KC_TILD, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSLS, \ + KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_SCLN, KC_QUOT, \ + KC_LSFT, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_ENT, KC_MNXT, KC_PGDN, KC_PGUP, KC_HOME, KC_END, \ + KC_LCTL, KC_RALT, KC_LGUI, KC_NO, LT(1, KC_BSPC), LT(2, KC_SPC), KC_NO, KC_RGUI, KC_MINS, KC_EQL +), +}; diff --git a/keyboards/tokyokeyboard/alix40/keymaps/default/keymap.c b/keyboards/tokyokeyboard/alix40/keymaps/default/keymap.c new file mode 100644 index 000000000000..a909c0d0c0aa --- /dev/null +++ b/keyboards/tokyokeyboard/alix40/keymaps/default/keymap.c @@ -0,0 +1,59 @@ +#include QMK_KEYBOARD_H + +/* + * Default Alix Layout + */ +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: Default layer +┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ +│ Tab │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ ` │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│ Esc │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ' │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│Shift│ Z │ X │ C │ V │ B │Enter│ N │ M │ , │ . │ / │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│Ctrl │ Alt │ │ Gui │█████│Bksp │Space│█████│ Gui │ │ [ │ ] │ +└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ + */ +[0] = LAYOUT_40_alix( + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_GRV, \ + KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \ + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_ENT, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, \ + KC_LCTL, KC_RALT, KC_LGUI,KC_NO, LT(1, KC_BSPC), LT(2, KC_SPC), KC_NO, KC_RGUI, KC_LBRC, KC_RBRC +), +/* 1: Lower Layer +┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ +│ ~ │ ! │ @ │ # │ $ │ % │ ^ │ & │ * │ ( │ ) │ | │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│ DEL | F1 | F2 | F3 | F4 | F5 │Left │Down │ Up │Right│ ; │ ' │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│Shift│ F6 │ F7 │ F8 │ F9 │ F10 │Enter|Next |Vol- |Vol+ | Play│ / │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│Ctrl │ Alt │ │ Gui │█████│Bksp │Space│█████│ Gui │ │ _ │ + │ +└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ + */ +[1]= LAYOUT_40_alix( + KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_PIPE, \ + KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_SCLN, KC_QUOT, \ + KC_LSFT, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_ENT, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, KC_SLSH, \ + KC_LCTL, KC_RALT, KC_LGUI, KC_NO, LT(1, KC_BSPC), LT(2, KC_SPC), KC_NO, KC_RGUI, KC_UNDS, KC_PLUS +), + +/* 2: Raise Layer +┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ +│ ~ │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ \ │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│ DEL │ F1 │ F2 │ F3 │ F4 │ F5 │Left │Down │ Up │Right│ ; │ ' │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│Shift│ F6 │ F7 │ F8 │ F9 │ F10 │Enter│Next │PgDn │PgUp │Home │ End │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│Ctrl │ Alt │ │ Gui │█████│Bksp │Space│█████│ Gui │ │ - │ = │ +└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ + */ +[2]= LAYOUT_40_alix( + KC_TILD, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSLS, \ + KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_SCLN, KC_QUOT, \ + KC_LSFT, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_ENT, KC_MNXT, KC_PGDN, KC_PGUP, KC_HOME, KC_END, \ + KC_LCTL, KC_RALT, KC_LGUI, KC_NO, LT(1, KC_BSPC), LT(2, KC_SPC), KC_NO, KC_RGUI, KC_MINS, KC_EQL +), +}; diff --git a/keyboards/tokyo60/keymaps/swappedBottomRow/config.h b/keyboards/tokyokeyboard/alix40/keymaps/swappedBottomRow/config.h similarity index 100% rename from keyboards/tokyo60/keymaps/swappedBottomRow/config.h rename to keyboards/tokyokeyboard/alix40/keymaps/swappedBottomRow/config.h diff --git a/keyboards/tokyo60/keymaps/swappedBottomRow/keymap.c b/keyboards/tokyokeyboard/alix40/keymaps/swappedBottomRow/keymap.c similarity index 100% rename from keyboards/tokyo60/keymaps/swappedBottomRow/keymap.c rename to keyboards/tokyokeyboard/alix40/keymaps/swappedBottomRow/keymap.c diff --git a/keyboards/tokyokeyboard/alix40/readme.md b/keyboards/tokyokeyboard/alix40/readme.md new file mode 100644 index 000000000000..bc01b3b22273 --- /dev/null +++ b/keyboards/tokyokeyboard/alix40/readme.md @@ -0,0 +1,15 @@ +# alix40 +​ +![alix40](https://i2.wp.com/tokyokeyboard.com/wp-content/uploads/2020/08/hello-alix.png) +​ +Minimal hacker style mechanical keyboard designed in Tokyo. Cherry MX compatible. More Info at [Tokyo Keyboard](http://tokyokeyboard.com). +​ +Keyboard Maintainer: [Tokyo Keyboard](http://tokyokeyboard.com) +Hardware Supported: alix40 rev1 +Hardware Availability: [Tokyo Keyboard](http://tokyokeyboard.com) +​ +Make example for this keyboard (after setting up your build environment): +​ + make tokyokeyboard/alix40:default +​ +See [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) then the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. diff --git a/keyboards/tokyokeyboard/alix40/rules.mk b/keyboards/tokyokeyboard/alix40/rules.mk new file mode 100644 index 000000000000..bdb5613f22d0 --- /dev/null +++ b/keyboards/tokyokeyboard/alix40/rules.mk @@ -0,0 +1,35 @@ +# MCU name +MCU = atmega32u4 +F_CPU = 8000000 + +# Bootloader selection +# Teensy halfkay +# Pro Micro caterina +# Atmel DFU atmel-dfu +# LUFA DFU lufa-dfu +# QMK DFU qmk-dfu +# ATmega32A bootloadHID +# ATmega328P USBasp +BOOTLOADER = atmel-dfu + +# Build Options +# change yes to no to disable +# +BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration +MOUSEKEY_ENABLE = no # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend +# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +MIDI_ENABLE = no # MIDI controls +UNICODE_ENABLE = no # Unicode +BLUETOOTH = AdafruitBLE # Enable Bluetooth with the MDBT40 HID (AdafruitBLE) +BLUETOOTH_ENABLE = OUT_AUTO +AUDIO_ENABLE = no # Audio output on port C6 +CONSOLE_ENABLE = no # Console for debug +COMMAND_ENABLE = yes # Commands for debug and configuration +NKRO_ENABLE = no # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality +RGBLIGHT_ENABLE = yes # Enable RGB light + +LAYOUTS = LAYOUT_40_alix diff --git a/keyboards/tokyo60/config.h b/keyboards/tokyokeyboard/tokyo60/config.h similarity index 100% rename from keyboards/tokyo60/config.h rename to keyboards/tokyokeyboard/tokyo60/config.h diff --git a/keyboards/tokyo60/info.json b/keyboards/tokyokeyboard/tokyo60/info.json similarity index 100% rename from keyboards/tokyo60/info.json rename to keyboards/tokyokeyboard/tokyo60/info.json diff --git a/keyboards/tokyokeyboard/tokyo60/keymaps/default/config.h b/keyboards/tokyokeyboard/tokyo60/keymaps/default/config.h new file mode 100644 index 000000000000..271f48d0011b --- /dev/null +++ b/keyboards/tokyokeyboard/tokyo60/keymaps/default/config.h @@ -0,0 +1,3 @@ +#pragma once + +// place overrides here diff --git a/keyboards/tokyo60/keymaps/default/keymap.c b/keyboards/tokyokeyboard/tokyo60/keymaps/default/keymap.c similarity index 100% rename from keyboards/tokyo60/keymaps/default/keymap.c rename to keyboards/tokyokeyboard/tokyo60/keymaps/default/keymap.c diff --git a/keyboards/tokyokeyboard/tokyo60/keymaps/swappedBottomRow/config.h b/keyboards/tokyokeyboard/tokyo60/keymaps/swappedBottomRow/config.h new file mode 100644 index 000000000000..271f48d0011b --- /dev/null +++ b/keyboards/tokyokeyboard/tokyo60/keymaps/swappedBottomRow/config.h @@ -0,0 +1,3 @@ +#pragma once + +// place overrides here diff --git a/keyboards/tokyokeyboard/tokyo60/keymaps/swappedBottomRow/keymap.c b/keyboards/tokyokeyboard/tokyo60/keymaps/swappedBottomRow/keymap.c new file mode 100644 index 000000000000..54b68f5825e8 --- /dev/null +++ b/keyboards/tokyokeyboard/tokyo60/keymaps/swappedBottomRow/keymap.c @@ -0,0 +1,47 @@ +#include QMK_KEYBOARD_H + +#define BL 0 +#define FN 1 +/* + * Default HHKB Layout + */ +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: Default layer +┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ +│ Esc │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │ \ │ ` │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│ Tab │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ [ │ ] │BkSpc│█████│ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│Ctrl │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ' │█████│Enter│█████│ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│Shift│█████│ Z │ X │ C │ V │ B │ N │ M │ , │ . │ / │█████│Shift│ Fn │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│█████│ Gui │ Alt │█████│█████│Space│█████│█████│█████│█████│█████│ Alt │ Gui │█████│█████│ +└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ + */ +[BL] = LAYOUT_60_hhkb( + 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_BSLS, KC_GRV, \ + 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_BSPC, \ + KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, \ + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, MO(FN), \ + KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI ), + /* 1: HHKB Fn layer +┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ +│ │ F1 │ F2 │ F3 │ F4 │ F5 │ F6 │ F7 │ F8 │ F9 │ F10 │ F11 │ F12 │ Ins │ Del │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│Caps │ RGB │RGBfw│RGBrv│BLtog│BLstp│ │ │ Psc │ Slk │ Pus │ Up │ │ │█████│ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│ │ VoD │ VoU │ Mut │ │ │NP_* │NP_/ │Home │PgUp │Left │Right│█████│NPEnt│█████│ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│ │█████│ │ │Calc │ │ │NP_+ │NP_- │ End │PgDwn│Down │█████│ │ │ +├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ +│█████│ │ │█████│█████│█████│ │█████│█████│█████│█████│ │ │█████│█████│ +└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ + */ +[FN]= LAYOUT_60_hhkb( + KC_TRNS, 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_INS, KC_DEL, \ + KC_CAPS, RGB_TOG, RGB_MOD, RGB_RMOD, BL_TOGG, BL_STEP, KC_TRNS, KC_TRNS, KC_PSCR, KC_SLCK, KC_PAUS, KC_UP, KC_TRNS, KC_TRNS, \ + KC_TRNS, KC_VOLD, KC_VOLU, KC_MUTE, KC_TRNS, KC_TRNS, KC_PAST, KC_PSLS, KC_HOME, KC_PGUP, KC_LEFT, KC_RGHT, KC_PENT, \ + KC_TRNS, KC_TRNS, KC_TRNS, KC_CALC, KC_TRNS, KC_TRNS, KC_PPLS, KC_PMNS, KC_END, KC_PGDN, KC_DOWN, KC_TRNS, KC_TRNS, \ + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS ), +}; diff --git a/keyboards/tokyo60/keymaps/via/keymap.c b/keyboards/tokyokeyboard/tokyo60/keymaps/via/keymap.c similarity index 100% rename from keyboards/tokyo60/keymaps/via/keymap.c rename to keyboards/tokyokeyboard/tokyo60/keymaps/via/keymap.c diff --git a/keyboards/tokyo60/keymaps/via/rules.mk b/keyboards/tokyokeyboard/tokyo60/keymaps/via/rules.mk similarity index 100% rename from keyboards/tokyo60/keymaps/via/rules.mk rename to keyboards/tokyokeyboard/tokyo60/keymaps/via/rules.mk diff --git a/keyboards/tokyo60/readme.md b/keyboards/tokyokeyboard/tokyo60/readme.md similarity index 100% rename from keyboards/tokyo60/readme.md rename to keyboards/tokyokeyboard/tokyo60/readme.md diff --git a/keyboards/tokyo60/rules.mk b/keyboards/tokyokeyboard/tokyo60/rules.mk similarity index 100% rename from keyboards/tokyo60/rules.mk rename to keyboards/tokyokeyboard/tokyo60/rules.mk diff --git a/keyboards/tokyo60/tokyo60.c b/keyboards/tokyokeyboard/tokyo60/tokyo60.c similarity index 100% rename from keyboards/tokyo60/tokyo60.c rename to keyboards/tokyokeyboard/tokyo60/tokyo60.c diff --git a/keyboards/tokyo60/tokyo60.h b/keyboards/tokyokeyboard/tokyo60/tokyo60.h similarity index 100% rename from keyboards/tokyo60/tokyo60.h rename to keyboards/tokyokeyboard/tokyo60/tokyo60.h diff --git a/tmk_core/protocol/lufa/adafruit_ble.cpp b/tmk_core/protocol/lufa/adafruit_ble.cpp index 8248e3ae4c3e..8ef10ec39e39 100644 --- a/tmk_core/protocol/lufa/adafruit_ble.cpp +++ b/tmk_core/protocol/lufa/adafruit_ble.cpp @@ -560,7 +560,7 @@ void adafruit_ble_task(void) { state.last_battery_update = timer_read(); state.vbat = analogReadPin(BATTERY_LEVEL_PIN); -<<<<<<< HEAD + if (state.vbat >= 862) // around 4.17V, li-ion can charge usually to max of 4.19V state.vbat = 100; @@ -571,8 +571,6 @@ void adafruit_ble_task(void) { snprintf(cmdbuf, sizeof(cmdbuf), "AT+BLEBATTVAL=%d", state.vbat); at_command(cmdbuf, NULL, 0, false); -======= ->>>>>>> c0de49e393cf481f60f2bbd6c18ecb13d37c6254 } #endif } From bf3566fef8b28965c5843a48c2c9bd22c580c633 Mon Sep 17 00:00:00 2001 From: James <13719009+quadcube@users.noreply.github.com> Date: Wed, 3 Feb 2021 18:03:24 +0800 Subject: [PATCH 03/21] Updated readme with more info. --- keyboards/tokyokeyboard/alix40/readme.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/keyboards/tokyokeyboard/alix40/readme.md b/keyboards/tokyokeyboard/alix40/readme.md index bc01b3b22273..acaaf3dfcd95 100644 --- a/keyboards/tokyokeyboard/alix40/readme.md +++ b/keyboards/tokyokeyboard/alix40/readme.md @@ -13,3 +13,10 @@ Make example for this keyboard (after setting up your build environment): make tokyokeyboard/alix40:default ​ See [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) then the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. + +Note: +i) Be very careful and gentle when disassembling the PCB from the bottom case +ii) alix40 battery power switch (shown in the image below) is used to toggle battery usage (on: battery will be charged when USB is connected, keyboard will be on when USB is disconnected/off:battery will not be charged when USB is connected, keyboard will be off when USB is disconnected) +![alix40pwrtoggle](https://i.imgur.com/YPX6R2T.jpg) +iii) Install the slider on the battery power switch (bundled together with the 3M feets) +iv) Underglow RGBs are switched off when alix40 is running on battery power (hardware feature to extend battery usage time) From 3822ab0f24e4996b01d8b7e5115574a1f4c3bc7b Mon Sep 17 00:00:00 2001 From: quadcube <13719009+quadcube@users.noreply.github.com> Date: Thu, 4 Feb 2021 01:04:40 +0800 Subject: [PATCH 04/21] Added support for VIA. --- .../tokyokeyboard/alix40/keymaps/via/keymap.c | 33 +++++++++++++++++++ .../tokyokeyboard/alix40/keymaps/via/rules.mk | 1 + 2 files changed, 34 insertions(+) create mode 100644 keyboards/tokyokeyboard/alix40/keymaps/via/keymap.c create mode 100644 keyboards/tokyokeyboard/alix40/keymaps/via/rules.mk diff --git a/keyboards/tokyokeyboard/alix40/keymaps/via/keymap.c b/keyboards/tokyokeyboard/alix40/keymaps/via/keymap.c new file mode 100644 index 000000000000..b7e077697f46 --- /dev/null +++ b/keyboards/tokyokeyboard/alix40/keymaps/via/keymap.c @@ -0,0 +1,33 @@ +#include QMK_KEYBOARD_H + +#define BL 0 +#define FN 1 +/* + * Default alix40 Layout + */ +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + +[BL] = LAYOUT_40_alix( + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_GRV, \ + KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \ + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_ENT, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, \ + KC_LCTL, KC_RALT, KC_LGUI,KC_NO, LT(1, KC_BSPC), LT(2, KC_SPC), KC_NO, KC_RGUI, KC_LBRC, KC_RBRC), + +[FN]= LAYOUT_40_alix( + KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_PIPE, \ + KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_SCLN, KC_QUOT, \ + KC_LSFT, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_ENT, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, KC_SLSH, \ + KC_LCTL, KC_RALT, KC_LGUI, KC_NO, LT(1, KC_BSPC), LT(2, KC_SPC), KC_NO, KC_RGUI, KC_UNDS, KC_PLUS), + +[2]= LAYOUT_40_alix( + KC_TILD, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSLS, \ + KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_SCLN, KC_QUOT, \ + KC_LSFT, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_ENT, KC_MNXT, KC_PGDN, KC_PGUP, KC_HOME, KC_END, \ + KC_LCTL, KC_RALT, KC_LGUI, KC_NO, LT(1, KC_BSPC), LT(2, KC_SPC), KC_NO, KC_RGUI, KC_MINS, KC_EQL), + +[3]= LAYOUT_40_alix( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______), +}; diff --git a/keyboards/tokyokeyboard/alix40/keymaps/via/rules.mk b/keyboards/tokyokeyboard/alix40/keymaps/via/rules.mk new file mode 100644 index 000000000000..1e5b99807cb7 --- /dev/null +++ b/keyboards/tokyokeyboard/alix40/keymaps/via/rules.mk @@ -0,0 +1 @@ +VIA_ENABLE = yes From 1f2744b169c91183e1e164a6460c3dc4e69f188f Mon Sep 17 00:00:00 2001 From: James <13719009+quadcube@users.noreply.github.com> Date: Wed, 10 Feb 2021 14:39:09 +0800 Subject: [PATCH 05/21] Updated readme with battery toggle switch indication --- keyboards/tokyokeyboard/alix40/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/tokyokeyboard/alix40/readme.md b/keyboards/tokyokeyboard/alix40/readme.md index acaaf3dfcd95..f4ef94345eda 100644 --- a/keyboards/tokyokeyboard/alix40/readme.md +++ b/keyboards/tokyokeyboard/alix40/readme.md @@ -17,6 +17,6 @@ See [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) Note: i) Be very careful and gentle when disassembling the PCB from the bottom case ii) alix40 battery power switch (shown in the image below) is used to toggle battery usage (on: battery will be charged when USB is connected, keyboard will be on when USB is disconnected/off:battery will not be charged when USB is connected, keyboard will be off when USB is disconnected) -![alix40pwrtoggle](https://i.imgur.com/YPX6R2T.jpg) +![alix40pwrtoggle](https://i.imgur.com/zr0DODl.jpg) iii) Install the slider on the battery power switch (bundled together with the 3M feets) iv) Underglow RGBs are switched off when alix40 is running on battery power (hardware feature to extend battery usage time) From b64d812e482f82cb5e90f990adbe126faf373649 Mon Sep 17 00:00:00 2001 From: quadcube <13719009+quadcube@users.noreply.github.com> Date: Mon, 15 Feb 2021 14:10:10 +0800 Subject: [PATCH 06/21] Added VIA support for alix40 --- keyboards/tokyokeyboard/alix40/config.h | 8 +- keyboards/tokyokeyboard/alix40/info.json | 150 +++++++++++++++++- .../tokyokeyboard/alix40/keymaps/via/rules.mk | 1 + keyboards/tokyokeyboard/alix40/readme.md | 8 +- keyboards/tokyokeyboard/alix40/rules.mk | 4 +- 5 files changed, 160 insertions(+), 11 deletions(-) diff --git a/keyboards/tokyokeyboard/alix40/config.h b/keyboards/tokyokeyboard/alix40/config.h index 52e5f6eedcec..3e9de22267d4 100644 --- a/keyboards/tokyokeyboard/alix40/config.h +++ b/keyboards/tokyokeyboard/alix40/config.h @@ -4,11 +4,11 @@ #include "config_common.h" /* USB Device descriptor parameter */ -#define VENDOR_ID 0xFEED -#define PRODUCT_ID 0x6060 +#define VENDOR_ID 0x5143 // QC +#define PRODUCT_ID 0x4134 // A4 #define DEVICE_VER 0x0001 -#define MANUFACTURER Tokyo Keyboard -#define PRODUCT alix +#define MANUFACTURER quadcube +#define PRODUCT alix40 #define DESCRIPTION q.m.k. keyboard firmware for alix /* key matrix size */ diff --git a/keyboards/tokyokeyboard/alix40/info.json b/keyboards/tokyokeyboard/alix40/info.json index b8d2033d931f..2578f56cb22c 100644 --- a/keyboards/tokyokeyboard/alix40/info.json +++ b/keyboards/tokyokeyboard/alix40/info.json @@ -1,12 +1,158 @@ { - "keyboard_name": "alix60", + "keyboard_name": "alix40", "url": "", "maintainer": "qmk", "width": 12, "height": 4, "layouts": { "LAYOUT_40_alix": { - "layout": [{"label":"Tab", "x":0, "y":0}, {"label":"Q", "x":1, "y":0}, {"label":"W", "x":2, "y":0}, {"label":"E", "x":3, "y":0}, {"label":"R", "x":4, "y":0}, {"label":"T", "x":5, "y":0}, {"label":"Y", "x":6, "y":0}, {"label":"U", "x":7, "y":0}] + "layout": [ + [ + { + "y": 0.05, + "f": 1 + }, + "0,0", + "0,1", + { + "x": 10 + }, + "0,10", + "0,11" + ], + [ + { + "x": 0.15 + }, + "1,0", + "1,1", + { + "x": 10.2 + }, + "1,10", + "1,11" + ], + [ + { + "x": 0.5 + }, + "2,0", + "2,1", + { + "x": 9.5 + }, + "2,10", + "2,11" + ], + [ + { + "x": 0.25 + }, + "3,0", + "3,1", + { + "x": 10 + }, + "3,10", + "3,11" + ], + [ + { + "r": 10, + "rx": 3, + "y": 4.5, + "x": 2.5 + }, + "3,4\n\n\n0,1", + "3,5\n\n\n0,1" + ], + [ + { + "ry": 4.25, + "y": -4, + "x": -1 + }, + "0,2", + "0,3", + "0,4", + "0,5" + ], + [ + { + "x": -0.75 + }, + "1,2", + "1,3", + "1,4", + "1,5" + ], + [ + { + "x": -0.25 + }, + "2,2", + "2,3", + "2,4", + "2,5" + ], + [ + { + "x": 0.75 + }, + "3,3", + { + "w": 2 + }, + "3,5\n\n\n0,0" + ], + [ + { + "r": -10, + "rx": 12.5, + "y": -4.25, + "x": -4.5 + }, + "0,6", + "0,7", + "0,8", + "0,9" + ], + [ + { + "x": -4.25 + }, + "1,6", + "1,7", + "1,8", + "1,9" + ], + [ + { + "x": -4.75 + }, + "2,6", + "2,7", + "2,8", + "2,9" + ], + [ + { + "x": -4.75, + "w": 2 + }, + "3,6\n\n\n1,0", + "3,8" + ], + [ + { + "y": 0.25, + "x": -4.75 + }, + "3,6\n\n\n1,1", + "3,7\n\n\n1,1" + ] + ] + } } } diff --git a/keyboards/tokyokeyboard/alix40/keymaps/via/rules.mk b/keyboards/tokyokeyboard/alix40/keymaps/via/rules.mk index 1e5b99807cb7..36b7ba9cbc98 100644 --- a/keyboards/tokyokeyboard/alix40/keymaps/via/rules.mk +++ b/keyboards/tokyokeyboard/alix40/keymaps/via/rules.mk @@ -1 +1,2 @@ VIA_ENABLE = yes +LTO_ENABLE = yes diff --git a/keyboards/tokyokeyboard/alix40/readme.md b/keyboards/tokyokeyboard/alix40/readme.md index acaaf3dfcd95..3d5a34553b7d 100644 --- a/keyboards/tokyokeyboard/alix40/readme.md +++ b/keyboards/tokyokeyboard/alix40/readme.md @@ -15,8 +15,8 @@ Make example for this keyboard (after setting up your build environment): See [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) then the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Note: -i) Be very careful and gentle when disassembling the PCB from the bottom case -ii) alix40 battery power switch (shown in the image below) is used to toggle battery usage (on: battery will be charged when USB is connected, keyboard will be on when USB is disconnected/off:battery will not be charged when USB is connected, keyboard will be off when USB is disconnected) +1. Be very careful and gentle when disassembling the PCB from the bottom case +2. alix40 battery power switch (shown in the image below) is used to toggle battery usage (on: battery will be charged when USB is connected, keyboard will be on when USB is disconnected/off:battery will not be charged when USB is connected, keyboard will be off when USB is disconnected) ![alix40pwrtoggle](https://i.imgur.com/YPX6R2T.jpg) -iii) Install the slider on the battery power switch (bundled together with the 3M feets) -iv) Underglow RGBs are switched off when alix40 is running on battery power (hardware feature to extend battery usage time) +3. Install the slider on the battery power switch (bundled together with the 3M feets) +4. Underglow RGBs are switched off when alix40 is running on battery power (hardware feature to extend battery usage time) diff --git a/keyboards/tokyokeyboard/alix40/rules.mk b/keyboards/tokyokeyboard/alix40/rules.mk index bdb5613f22d0..b0cc984eb9aa 100644 --- a/keyboards/tokyokeyboard/alix40/rules.mk +++ b/keyboards/tokyokeyboard/alix40/rules.mk @@ -24,7 +24,7 @@ SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend MIDI_ENABLE = no # MIDI controls UNICODE_ENABLE = no # Unicode BLUETOOTH = AdafruitBLE # Enable Bluetooth with the MDBT40 HID (AdafruitBLE) -BLUETOOTH_ENABLE = OUT_AUTO +BLUETOOTH_ENABLE = OUT_AUTO # AUDIO_ENABLE = no # Audio output on port C6 CONSOLE_ENABLE = no # Console for debug COMMAND_ENABLE = yes # Commands for debug and configuration @@ -33,3 +33,5 @@ BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality RGBLIGHT_ENABLE = yes # Enable RGB light LAYOUTS = LAYOUT_40_alix + +EXTRAFLAGS += -flto From 5b8c41d275ecc9904bbf9674c6d106e87223e50e Mon Sep 17 00:00:00 2001 From: quadcube <13719009+quadcube@users.noreply.github.com> Date: Mon, 15 Feb 2021 14:17:57 +0800 Subject: [PATCH 07/21] Removed modification for adafruit_ble.cpp --- tmk_core/protocol/lufa/adafruit_ble.cpp | 716 ------------------------ 1 file changed, 716 deletions(-) delete mode 100644 tmk_core/protocol/lufa/adafruit_ble.cpp diff --git a/tmk_core/protocol/lufa/adafruit_ble.cpp b/tmk_core/protocol/lufa/adafruit_ble.cpp deleted file mode 100644 index 8ef10ec39e39..000000000000 --- a/tmk_core/protocol/lufa/adafruit_ble.cpp +++ /dev/null @@ -1,716 +0,0 @@ -#include "adafruit_ble.h" - -#include -#include -#include -#include "debug.h" -#include "timer.h" -#include "action_util.h" -#include "ringbuffer.hpp" -#include -#include "spi_master.h" -#include "wait.h" -#include "analog.h" -#include "progmem.h" - -// These are the pin assignments for the 32u4 boards. -// You may define them to something else in your config.h -// if yours is wired up differently. -#ifndef AdafruitBleResetPin -# define AdafruitBleResetPin D4 -#endif - -#ifndef AdafruitBleCSPin -# define AdafruitBleCSPin B4 -#endif - -#ifndef AdafruitBleIRQPin -# define AdafruitBleIRQPin E6 -#endif - -#ifndef AdafruitBleSpiClockSpeed -# define AdafruitBleSpiClockSpeed 4000000UL // SCK frequency -#endif - -#define SCK_DIVISOR (F_CPU / AdafruitBleSpiClockSpeed) - -#define SAMPLE_BATTERY -#define ConnectionUpdateInterval 1000 /* milliseconds */ - -#ifndef BATTERY_LEVEL_PIN -# define BATTERY_LEVEL_PIN B5 -#endif - -static struct { - bool is_connected; - bool initialized; - bool configured; - -#define ProbedEvents 1 -#define UsingEvents 2 - bool event_flags; - -#ifdef SAMPLE_BATTERY - uint16_t last_battery_update; - uint32_t vbat; -#endif - uint16_t last_connection_update; -} state; - -// Commands are encoded using SDEP and sent via SPI -// https://github.com/adafruit/Adafruit_BluefruitLE_nRF51/blob/master/SDEP.md - -#define SdepMaxPayload 16 -struct sdep_msg { - uint8_t type; - uint8_t cmd_low; - uint8_t cmd_high; - struct __attribute__((packed)) { - uint8_t len : 7; - uint8_t more : 1; - }; - uint8_t payload[SdepMaxPayload]; -} __attribute__((packed)); - -// The recv latency is relatively high, so when we're hammering keys quickly, -// we want to avoid waiting for the responses in the matrix loop. We maintain -// a short queue for that. Since there is quite a lot of space overhead for -// the AT command representation wrapped up in SDEP, we queue the minimal -// information here. - -enum queue_type { - QTKeyReport, // 1-byte modifier + 6-byte key report - QTConsumer, // 16-bit key code -#ifdef MOUSE_ENABLE - QTMouseMove, // 4-byte mouse report -#endif -}; - -struct queue_item { - enum queue_type queue_type; - uint16_t added; - union __attribute__((packed)) { - struct __attribute__((packed)) { - uint8_t modifier; - uint8_t keys[6]; - } key; - - uint16_t consumer; - struct __attribute__((packed)) { - int8_t x, y, scroll, pan; - uint8_t buttons; - } mousemove; - }; -}; - -// Items that we wish to send -static RingBuffer send_buf; -// Pending response; while pending, we can't send any more requests. -// This records the time at which we sent the command for which we -// are expecting a response. -static RingBuffer resp_buf; - -static bool process_queue_item(struct queue_item *item, uint16_t timeout); - -enum sdep_type { - SdepCommand = 0x10, - SdepResponse = 0x20, - SdepAlert = 0x40, - SdepError = 0x80, - SdepSlaveNotReady = 0xFE, // Try again later - SdepSlaveOverflow = 0xFF, // You read more data than is available -}; - -enum ble_cmd { - BleInitialize = 0xBEEF, - BleAtWrapper = 0x0A00, - BleUartTx = 0x0A01, - BleUartRx = 0x0A02, -}; - -enum ble_system_event_bits { - BleSystemConnected = 0, - BleSystemDisconnected = 1, - BleSystemUartRx = 8, - BleSystemMidiRx = 10, -}; - -#define SdepTimeout 150 /* milliseconds */ -#define SdepShortTimeout 10 /* milliseconds */ -#define SdepBackOff 25 /* microseconds */ -#define BatteryUpdateInterval 10000 /* milliseconds */ - -static bool at_command(const char *cmd, char *resp, uint16_t resplen, bool verbose, uint16_t timeout = SdepTimeout); -static bool at_command_P(const char *cmd, char *resp, uint16_t resplen, bool verbose = false); - -// Send a single SDEP packet -static bool sdep_send_pkt(const struct sdep_msg *msg, uint16_t timeout) { - spi_start(AdafruitBleCSPin, false, 0, SCK_DIVISOR); - uint16_t timerStart = timer_read(); - bool success = false; - bool ready = false; - - do { - ready = spi_write(msg->type) != SdepSlaveNotReady; - if (ready) { - break; - } - - // Release it and let it initialize - spi_stop(); - wait_us(SdepBackOff); - spi_start(AdafruitBleCSPin, false, 0, SCK_DIVISOR); - } while (timer_elapsed(timerStart) < timeout); - - if (ready) { - // Slave is ready; send the rest of the packet - spi_transmit(&msg->cmd_low, sizeof(*msg) - (1 + sizeof(msg->payload)) + msg->len); - success = true; - } - - spi_stop(); - - return success; -} - -static inline void sdep_build_pkt(struct sdep_msg *msg, uint16_t command, const uint8_t *payload, uint8_t len, bool moredata) { - msg->type = SdepCommand; - msg->cmd_low = command & 0xFF; - msg->cmd_high = command >> 8; - msg->len = len; - msg->more = (moredata && len == SdepMaxPayload) ? 1 : 0; - - static_assert(sizeof(*msg) == 20, "msg is correctly packed"); - - memcpy(msg->payload, payload, len); -} - -// Read a single SDEP packet -static bool sdep_recv_pkt(struct sdep_msg *msg, uint16_t timeout) { - bool success = false; - uint16_t timerStart = timer_read(); - bool ready = false; - - do { - ready = readPin(AdafruitBleIRQPin); - if (ready) { - break; - } - wait_us(1); - } while (timer_elapsed(timerStart) < timeout); - - if (ready) { - spi_start(AdafruitBleCSPin, false, 0, SCK_DIVISOR); - - do { - // Read the command type, waiting for the data to be ready - msg->type = spi_read(); - if (msg->type == SdepSlaveNotReady || msg->type == SdepSlaveOverflow) { - // Release it and let it initialize - spi_stop(); - wait_us(SdepBackOff); - spi_start(AdafruitBleCSPin, false, 0, SCK_DIVISOR); - continue; - } - - // Read the rest of the header - spi_receive(&msg->cmd_low, sizeof(*msg) - (1 + sizeof(msg->payload))); - - // and get the payload if there is any - if (msg->len <= SdepMaxPayload) { - spi_receive(msg->payload, msg->len); - } - success = true; - break; - } while (timer_elapsed(timerStart) < timeout); - - spi_stop(); - } - return success; -} - -static void resp_buf_read_one(bool greedy) { - uint16_t last_send; - if (!resp_buf.peek(last_send)) { - return; - } - - if (readPin(AdafruitBleIRQPin)) { - struct sdep_msg msg; - - again: - if (sdep_recv_pkt(&msg, SdepTimeout)) { - if (!msg.more) { - // We got it; consume this entry - resp_buf.get(last_send); - dprintf("recv latency %dms\n", TIMER_DIFF_16(timer_read(), last_send)); - } - - if (greedy && resp_buf.peek(last_send) && readPin(AdafruitBleIRQPin)) { - goto again; - } - } - - } else if (timer_elapsed(last_send) > SdepTimeout * 2) { - dprintf("waiting_for_result: timeout, resp_buf size %d\n", (int)resp_buf.size()); - - // Timed out: consume this entry - resp_buf.get(last_send); - } -} - -static void send_buf_send_one(uint16_t timeout = SdepTimeout) { - struct queue_item item; - - // Don't send anything more until we get an ACK - if (!resp_buf.empty()) { - return; - } - - if (!send_buf.peek(item)) { - return; - } - if (process_queue_item(&item, timeout)) { - // commit that peek - send_buf.get(item); - dprintf("send_buf_send_one: have %d remaining\n", (int)send_buf.size()); - } else { - dprint("failed to send, will retry\n"); - wait_ms(SdepTimeout); - resp_buf_read_one(true); - } -} - -static void resp_buf_wait(const char *cmd) { - bool didPrint = false; - while (!resp_buf.empty()) { - if (!didPrint) { - dprintf("wait on buf for %s\n", cmd); - didPrint = true; - } - resp_buf_read_one(true); - } -} - -static bool ble_init(void) { - state.initialized = false; - state.configured = false; - state.is_connected = false; - - setPinInput(AdafruitBleIRQPin); - - spi_init(); - - // Perform a hardware reset - setPinOutput(AdafruitBleResetPin); - writePinHigh(AdafruitBleResetPin); - writePinLow(AdafruitBleResetPin); - wait_ms(10); - writePinHigh(AdafruitBleResetPin); - - wait_ms(1000); // Give it a second to initialize - - state.initialized = true; - return state.initialized; -} - -static inline uint8_t min(uint8_t a, uint8_t b) { return a < b ? a : b; } - -static bool read_response(char *resp, uint16_t resplen, bool verbose) { - char *dest = resp; - char *end = dest + resplen; - - while (true) { - struct sdep_msg msg; - - if (!sdep_recv_pkt(&msg, 2 * SdepTimeout)) { - dprint("sdep_recv_pkt failed\n"); - return false; - } - - if (msg.type != SdepResponse) { - *resp = 0; - return false; - } - - uint8_t len = min(msg.len, end - dest); - if (len > 0) { - memcpy(dest, msg.payload, len); - dest += len; - } - - if (!msg.more) { - // No more data is expected! - break; - } - } - - // Ensure the response is NUL terminated - *dest = 0; - - // "Parse" the result text; we want to snip off the trailing OK or ERROR line - // Rewind past the possible trailing CRLF so that we can strip it - --dest; - while (dest > resp && (dest[0] == '\n' || dest[0] == '\r')) { - *dest = 0; - --dest; - } - - // Look back for start of preceeding line - char *last_line = strrchr(resp, '\n'); - if (last_line) { - ++last_line; - } else { - last_line = resp; - } - - bool success = false; - static const char kOK[] PROGMEM = "OK"; - - success = !strcmp_P(last_line, kOK); - - if (verbose || !success) { - dprintf("result: %s\n", resp); - } - return success; -} - -static bool at_command(const char *cmd, char *resp, uint16_t resplen, bool verbose, uint16_t timeout) { - const char * end = cmd + strlen(cmd); - struct sdep_msg msg; - - if (verbose) { - dprintf("ble send: %s\n", cmd); - } - - if (resp) { - // They want to decode the response, so we need to flush and wait - // for all pending I/O to finish before we start this one, so - // that we don't confuse the results - resp_buf_wait(cmd); - *resp = 0; - } - - // Fragment the command into a series of SDEP packets - while (end - cmd > SdepMaxPayload) { - sdep_build_pkt(&msg, BleAtWrapper, (uint8_t *)cmd, SdepMaxPayload, true); - if (!sdep_send_pkt(&msg, timeout)) { - return false; - } - cmd += SdepMaxPayload; - } - - sdep_build_pkt(&msg, BleAtWrapper, (uint8_t *)cmd, end - cmd, false); - if (!sdep_send_pkt(&msg, timeout)) { - return false; - } - - if (resp == NULL) { - uint16_t now = timer_read(); - while (!resp_buf.enqueue(now)) { - resp_buf_read_one(false); - } - uint16_t later = timer_read(); - if (TIMER_DIFF_16(later, now) > 0) { - dprintf("waited %dms for resp_buf\n", TIMER_DIFF_16(later, now)); - } - return true; - } - - return read_response(resp, resplen, verbose); -} - -bool at_command_P(const char *cmd, char *resp, uint16_t resplen, bool verbose) { - char *cmdbuf = (char *)alloca(strlen_P(cmd) + 1); - strcpy_P(cmdbuf, cmd); - return at_command(cmdbuf, resp, resplen, verbose); -} - -bool adafruit_ble_is_connected(void) { return state.is_connected; } - -bool adafruit_ble_enable_keyboard(void) { - char resbuf[128]; - - if (!state.initialized && !ble_init()) { - return false; - } - - state.configured = false; - - // Disable command echo - static const char kEcho[] PROGMEM = "ATE=0"; - // Make the advertised name match the keyboard - static const char kGapDevName[] PROGMEM = "AT+GAPDEVNAME=" STR(PRODUCT); - // Turn on keyboard support - static const char kHidEnOn[] PROGMEM = "AT+BLEHIDEN=1"; - - // Adjust intervals to improve latency. This causes the "central" - // system (computer/tablet) to poll us every 10-30 ms. We can't - // set a smaller value than 10ms, and 30ms seems to be the natural - // processing time on my macbook. Keeping it constrained to that - // feels reasonable to type to. - static const char kGapIntervals[] PROGMEM = "AT+GAPINTERVALS=10,30,,"; - - // Enable GATT Battery Service - static const char kBattEnOn[] PROGMEM = "AT+BLEBATTEN=1"; - - // Reset the device so that it picks up the above changes - static const char kATZ[] PROGMEM = "ATZ"; - - // Turn down the power level a bit - static const char kPower[] PROGMEM = "AT+BLEPOWERLEVEL=-12"; - static PGM_P const configure_commands[] PROGMEM = { - kEcho, kGapIntervals, kGapDevName, kHidEnOn, kPower, kBattEnOn, kATZ, - }; - - uint8_t i; - for (i = 0; i < sizeof(configure_commands) / sizeof(configure_commands[0]); ++i) { - PGM_P cmd; - memcpy_P(&cmd, configure_commands + i, sizeof(cmd)); - - if (!at_command_P(cmd, resbuf, sizeof(resbuf))) { - dprintf("failed BLE command: %S: %s\n", cmd, resbuf); - goto fail; - } - } - - state.configured = true; - - // Check connection status in a little while; allow the ATZ time - // to kick in. - state.last_connection_update = timer_read(); -fail: - return state.configured; -} - -static void set_connected(bool connected) { - if (connected != state.is_connected) { - if (connected) { - dprint("BLE connected\n"); - } else { - dprint("BLE disconnected\n"); - } - state.is_connected = connected; - - // TODO: if modifiers are down on the USB interface and - // we cut over to BLE or vice versa, they will remain stuck. - // This feels like a good point to do something like clearing - // the keyboard and/or generating a fake all keys up message. - // However, I've noticed that it takes a couple of seconds - // for macOS to to start recognizing key presses after BLE - // is in the connected state, so I worry that doing that - // here may not be good enough. - } -} - -void adafruit_ble_task(void) { - char resbuf[48]; - char cmdbuf[48]; - - if (!state.configured && !adafruit_ble_enable_keyboard()) { - return; - } - resp_buf_read_one(true); - send_buf_send_one(SdepShortTimeout); - - if (resp_buf.empty() && (state.event_flags & UsingEvents) && readPin(AdafruitBleIRQPin)) { - // Must be an event update - if (at_command_P(PSTR("AT+EVENTSTATUS"), resbuf, sizeof(resbuf))) { - uint32_t mask = strtoul(resbuf, NULL, 16); - - if (mask & BleSystemConnected) { - set_connected(true); - } else if (mask & BleSystemDisconnected) { - set_connected(false); - } - } - } - - if (timer_elapsed(state.last_connection_update) > ConnectionUpdateInterval) { - bool shouldPoll = true; - if (!(state.event_flags & ProbedEvents)) { - // Request notifications about connection status changes. - // This only works in SPIFRIEND firmware > 0.6.7, which is why - // we check for this conditionally here. - // Note that at the time of writing, HID reports only work correctly - // with Apple products on firmware version 0.6.7! - // https://forums.adafruit.com/viewtopic.php?f=8&t=104052 - if (at_command_P(PSTR("AT+EVENTENABLE=0x1"), resbuf, sizeof(resbuf))) { - at_command_P(PSTR("AT+EVENTENABLE=0x2"), resbuf, sizeof(resbuf)); - state.event_flags |= UsingEvents; - } - state.event_flags |= ProbedEvents; - - // leave shouldPoll == true so that we check at least once - // before relying solely on events - } else { - shouldPoll = false; - } - - static const char kGetConn[] PROGMEM = "AT+GAPGETCONN"; - state.last_connection_update = timer_read(); - - if (at_command_P(kGetConn, resbuf, sizeof(resbuf))) { - set_connected(atoi(resbuf)); - } - } - -#ifdef SAMPLE_BATTERY - if (timer_elapsed(state.last_battery_update) > BatteryUpdateInterval && resp_buf.empty()) { - state.last_battery_update = timer_read(); - - state.vbat = analogReadPin(BATTERY_LEVEL_PIN); - - - if (state.vbat >= 862) // around 4.17V, li-ion can charge usually to max of 4.19V - state.vbat = 100; - else if (state.vbat < 820) // around 3.55V, anything below cannot be trusted as 3.5v=816, 3.35v=814, 3.3v=815, 3.2v=816, 3v=817 - state.vbat = 0; - else - state.vbat = (state.vbat - 820) * 99 / 41; - snprintf(cmdbuf, sizeof(cmdbuf), "AT+BLEBATTVAL=%d", state.vbat); - at_command(cmdbuf, NULL, 0, false); - - } -#endif -} - -static bool process_queue_item(struct queue_item *item, uint16_t timeout) { - char cmdbuf[48]; - char fmtbuf[64]; - - // Arrange to re-check connection after keys have settled - state.last_connection_update = timer_read(); - -#if 1 - if (TIMER_DIFF_16(state.last_connection_update, item->added) > 0) { - dprintf("send latency %dms\n", TIMER_DIFF_16(state.last_connection_update, item->added)); - } -#endif - - switch (item->queue_type) { - case QTKeyReport: - strcpy_P(fmtbuf, PSTR("AT+BLEKEYBOARDCODE=%02x-00-%02x-%02x-%02x-%02x-%02x-%02x")); - snprintf(cmdbuf, sizeof(cmdbuf), fmtbuf, item->key.modifier, item->key.keys[0], item->key.keys[1], item->key.keys[2], item->key.keys[3], item->key.keys[4], item->key.keys[5]); - return at_command(cmdbuf, NULL, 0, true, timeout); - - case QTConsumer: - strcpy_P(fmtbuf, PSTR("AT+BLEHIDCONTROLKEY=0x%04x")); - snprintf(cmdbuf, sizeof(cmdbuf), fmtbuf, item->consumer); - return at_command(cmdbuf, NULL, 0, true, timeout); - -#ifdef MOUSE_ENABLE - case QTMouseMove: - strcpy_P(fmtbuf, PSTR("AT+BLEHIDMOUSEMOVE=%d,%d,%d,%d")); - snprintf(cmdbuf, sizeof(cmdbuf), fmtbuf, item->mousemove.x, item->mousemove.y, item->mousemove.scroll, item->mousemove.pan); - if (!at_command(cmdbuf, NULL, 0, true, timeout)) { - return false; - } - strcpy_P(cmdbuf, PSTR("AT+BLEHIDMOUSEBUTTON=")); - if (item->mousemove.buttons & MOUSE_BTN1) { - strcat(cmdbuf, "L"); - } - if (item->mousemove.buttons & MOUSE_BTN2) { - strcat(cmdbuf, "R"); - } - if (item->mousemove.buttons & MOUSE_BTN3) { - strcat(cmdbuf, "M"); - } - if (item->mousemove.buttons == 0) { - strcat(cmdbuf, "0"); - } - return at_command(cmdbuf, NULL, 0, true, timeout); -#endif - default: - return true; - } -} - -void adafruit_ble_send_keys(uint8_t hid_modifier_mask, uint8_t *keys, uint8_t nkeys) { - struct queue_item item; - bool didWait = false; - - item.queue_type = QTKeyReport; - item.key.modifier = hid_modifier_mask; - item.added = timer_read(); - - while (nkeys >= 0) { - item.key.keys[0] = keys[0]; - item.key.keys[1] = nkeys >= 1 ? keys[1] : 0; - item.key.keys[2] = nkeys >= 2 ? keys[2] : 0; - item.key.keys[3] = nkeys >= 3 ? keys[3] : 0; - item.key.keys[4] = nkeys >= 4 ? keys[4] : 0; - item.key.keys[5] = nkeys >= 5 ? keys[5] : 0; - - if (!send_buf.enqueue(item)) { - if (!didWait) { - dprint("wait for buf space\n"); - didWait = true; - } - send_buf_send_one(); - continue; - } - - if (nkeys <= 6) { - return; - } - - nkeys -= 6; - keys += 6; - } -} - -void adafruit_ble_send_consumer_key(uint16_t usage) { - struct queue_item item; - - item.queue_type = QTConsumer; - item.consumer = usage; - - while (!send_buf.enqueue(item)) { - send_buf_send_one(); - } -} - -#ifdef MOUSE_ENABLE -void adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan, uint8_t buttons) { - struct queue_item item; - - item.queue_type = QTMouseMove; - item.mousemove.x = x; - item.mousemove.y = y; - item.mousemove.scroll = scroll; - item.mousemove.pan = pan; - item.mousemove.buttons = buttons; - - while (!send_buf.enqueue(item)) { - send_buf_send_one(); - } -} -#endif - -uint32_t adafruit_ble_read_battery_voltage(void) { return state.vbat; } - -bool adafruit_ble_set_mode_leds(bool on) { - if (!state.configured) { - return false; - } - - // The "mode" led is the red blinky one - at_command_P(on ? PSTR("AT+HWMODELED=1") : PSTR("AT+HWMODELED=0"), NULL, 0); - - // Pin 19 is the blue "connected" LED; turn that off too. - // When turning LEDs back on, don't turn that LED on if we're - // not connected, as that would be confusing. - at_command_P(on && state.is_connected ? PSTR("AT+HWGPIO=19,1") : PSTR("AT+HWGPIO=19,0"), NULL, 0); - return true; -} - -// https://learn.adafruit.com/adafruit-feather-32u4-bluefruit-le/ble-generic#at-plus-blepowerlevel -bool adafruit_ble_set_power_level(int8_t level) { - char cmd[46]; - if (!state.configured) { - return false; - } - snprintf(cmd, sizeof(cmd), "AT+BLEPOWERLEVEL=%d", level); - return at_command(cmd, NULL, 0, false); -} From 4924ba3a08387097ee7fdb665c9ca7d3b243213e Mon Sep 17 00:00:00 2001 From: quadcube <13719009+quadcube@users.noreply.github.com> Date: Mon, 15 Feb 2021 14:22:18 +0800 Subject: [PATCH 08/21] Revert "Removed modification for adafruit_ble.cpp" This reverts commit 5b8c41d275ecc9904bbf9674c6d106e87223e50e. --- tmk_core/protocol/lufa/adafruit_ble.cpp | 716 ++++++++++++++++++++++++ 1 file changed, 716 insertions(+) create mode 100644 tmk_core/protocol/lufa/adafruit_ble.cpp diff --git a/tmk_core/protocol/lufa/adafruit_ble.cpp b/tmk_core/protocol/lufa/adafruit_ble.cpp new file mode 100644 index 000000000000..8ef10ec39e39 --- /dev/null +++ b/tmk_core/protocol/lufa/adafruit_ble.cpp @@ -0,0 +1,716 @@ +#include "adafruit_ble.h" + +#include +#include +#include +#include "debug.h" +#include "timer.h" +#include "action_util.h" +#include "ringbuffer.hpp" +#include +#include "spi_master.h" +#include "wait.h" +#include "analog.h" +#include "progmem.h" + +// These are the pin assignments for the 32u4 boards. +// You may define them to something else in your config.h +// if yours is wired up differently. +#ifndef AdafruitBleResetPin +# define AdafruitBleResetPin D4 +#endif + +#ifndef AdafruitBleCSPin +# define AdafruitBleCSPin B4 +#endif + +#ifndef AdafruitBleIRQPin +# define AdafruitBleIRQPin E6 +#endif + +#ifndef AdafruitBleSpiClockSpeed +# define AdafruitBleSpiClockSpeed 4000000UL // SCK frequency +#endif + +#define SCK_DIVISOR (F_CPU / AdafruitBleSpiClockSpeed) + +#define SAMPLE_BATTERY +#define ConnectionUpdateInterval 1000 /* milliseconds */ + +#ifndef BATTERY_LEVEL_PIN +# define BATTERY_LEVEL_PIN B5 +#endif + +static struct { + bool is_connected; + bool initialized; + bool configured; + +#define ProbedEvents 1 +#define UsingEvents 2 + bool event_flags; + +#ifdef SAMPLE_BATTERY + uint16_t last_battery_update; + uint32_t vbat; +#endif + uint16_t last_connection_update; +} state; + +// Commands are encoded using SDEP and sent via SPI +// https://github.com/adafruit/Adafruit_BluefruitLE_nRF51/blob/master/SDEP.md + +#define SdepMaxPayload 16 +struct sdep_msg { + uint8_t type; + uint8_t cmd_low; + uint8_t cmd_high; + struct __attribute__((packed)) { + uint8_t len : 7; + uint8_t more : 1; + }; + uint8_t payload[SdepMaxPayload]; +} __attribute__((packed)); + +// The recv latency is relatively high, so when we're hammering keys quickly, +// we want to avoid waiting for the responses in the matrix loop. We maintain +// a short queue for that. Since there is quite a lot of space overhead for +// the AT command representation wrapped up in SDEP, we queue the minimal +// information here. + +enum queue_type { + QTKeyReport, // 1-byte modifier + 6-byte key report + QTConsumer, // 16-bit key code +#ifdef MOUSE_ENABLE + QTMouseMove, // 4-byte mouse report +#endif +}; + +struct queue_item { + enum queue_type queue_type; + uint16_t added; + union __attribute__((packed)) { + struct __attribute__((packed)) { + uint8_t modifier; + uint8_t keys[6]; + } key; + + uint16_t consumer; + struct __attribute__((packed)) { + int8_t x, y, scroll, pan; + uint8_t buttons; + } mousemove; + }; +}; + +// Items that we wish to send +static RingBuffer send_buf; +// Pending response; while pending, we can't send any more requests. +// This records the time at which we sent the command for which we +// are expecting a response. +static RingBuffer resp_buf; + +static bool process_queue_item(struct queue_item *item, uint16_t timeout); + +enum sdep_type { + SdepCommand = 0x10, + SdepResponse = 0x20, + SdepAlert = 0x40, + SdepError = 0x80, + SdepSlaveNotReady = 0xFE, // Try again later + SdepSlaveOverflow = 0xFF, // You read more data than is available +}; + +enum ble_cmd { + BleInitialize = 0xBEEF, + BleAtWrapper = 0x0A00, + BleUartTx = 0x0A01, + BleUartRx = 0x0A02, +}; + +enum ble_system_event_bits { + BleSystemConnected = 0, + BleSystemDisconnected = 1, + BleSystemUartRx = 8, + BleSystemMidiRx = 10, +}; + +#define SdepTimeout 150 /* milliseconds */ +#define SdepShortTimeout 10 /* milliseconds */ +#define SdepBackOff 25 /* microseconds */ +#define BatteryUpdateInterval 10000 /* milliseconds */ + +static bool at_command(const char *cmd, char *resp, uint16_t resplen, bool verbose, uint16_t timeout = SdepTimeout); +static bool at_command_P(const char *cmd, char *resp, uint16_t resplen, bool verbose = false); + +// Send a single SDEP packet +static bool sdep_send_pkt(const struct sdep_msg *msg, uint16_t timeout) { + spi_start(AdafruitBleCSPin, false, 0, SCK_DIVISOR); + uint16_t timerStart = timer_read(); + bool success = false; + bool ready = false; + + do { + ready = spi_write(msg->type) != SdepSlaveNotReady; + if (ready) { + break; + } + + // Release it and let it initialize + spi_stop(); + wait_us(SdepBackOff); + spi_start(AdafruitBleCSPin, false, 0, SCK_DIVISOR); + } while (timer_elapsed(timerStart) < timeout); + + if (ready) { + // Slave is ready; send the rest of the packet + spi_transmit(&msg->cmd_low, sizeof(*msg) - (1 + sizeof(msg->payload)) + msg->len); + success = true; + } + + spi_stop(); + + return success; +} + +static inline void sdep_build_pkt(struct sdep_msg *msg, uint16_t command, const uint8_t *payload, uint8_t len, bool moredata) { + msg->type = SdepCommand; + msg->cmd_low = command & 0xFF; + msg->cmd_high = command >> 8; + msg->len = len; + msg->more = (moredata && len == SdepMaxPayload) ? 1 : 0; + + static_assert(sizeof(*msg) == 20, "msg is correctly packed"); + + memcpy(msg->payload, payload, len); +} + +// Read a single SDEP packet +static bool sdep_recv_pkt(struct sdep_msg *msg, uint16_t timeout) { + bool success = false; + uint16_t timerStart = timer_read(); + bool ready = false; + + do { + ready = readPin(AdafruitBleIRQPin); + if (ready) { + break; + } + wait_us(1); + } while (timer_elapsed(timerStart) < timeout); + + if (ready) { + spi_start(AdafruitBleCSPin, false, 0, SCK_DIVISOR); + + do { + // Read the command type, waiting for the data to be ready + msg->type = spi_read(); + if (msg->type == SdepSlaveNotReady || msg->type == SdepSlaveOverflow) { + // Release it and let it initialize + spi_stop(); + wait_us(SdepBackOff); + spi_start(AdafruitBleCSPin, false, 0, SCK_DIVISOR); + continue; + } + + // Read the rest of the header + spi_receive(&msg->cmd_low, sizeof(*msg) - (1 + sizeof(msg->payload))); + + // and get the payload if there is any + if (msg->len <= SdepMaxPayload) { + spi_receive(msg->payload, msg->len); + } + success = true; + break; + } while (timer_elapsed(timerStart) < timeout); + + spi_stop(); + } + return success; +} + +static void resp_buf_read_one(bool greedy) { + uint16_t last_send; + if (!resp_buf.peek(last_send)) { + return; + } + + if (readPin(AdafruitBleIRQPin)) { + struct sdep_msg msg; + + again: + if (sdep_recv_pkt(&msg, SdepTimeout)) { + if (!msg.more) { + // We got it; consume this entry + resp_buf.get(last_send); + dprintf("recv latency %dms\n", TIMER_DIFF_16(timer_read(), last_send)); + } + + if (greedy && resp_buf.peek(last_send) && readPin(AdafruitBleIRQPin)) { + goto again; + } + } + + } else if (timer_elapsed(last_send) > SdepTimeout * 2) { + dprintf("waiting_for_result: timeout, resp_buf size %d\n", (int)resp_buf.size()); + + // Timed out: consume this entry + resp_buf.get(last_send); + } +} + +static void send_buf_send_one(uint16_t timeout = SdepTimeout) { + struct queue_item item; + + // Don't send anything more until we get an ACK + if (!resp_buf.empty()) { + return; + } + + if (!send_buf.peek(item)) { + return; + } + if (process_queue_item(&item, timeout)) { + // commit that peek + send_buf.get(item); + dprintf("send_buf_send_one: have %d remaining\n", (int)send_buf.size()); + } else { + dprint("failed to send, will retry\n"); + wait_ms(SdepTimeout); + resp_buf_read_one(true); + } +} + +static void resp_buf_wait(const char *cmd) { + bool didPrint = false; + while (!resp_buf.empty()) { + if (!didPrint) { + dprintf("wait on buf for %s\n", cmd); + didPrint = true; + } + resp_buf_read_one(true); + } +} + +static bool ble_init(void) { + state.initialized = false; + state.configured = false; + state.is_connected = false; + + setPinInput(AdafruitBleIRQPin); + + spi_init(); + + // Perform a hardware reset + setPinOutput(AdafruitBleResetPin); + writePinHigh(AdafruitBleResetPin); + writePinLow(AdafruitBleResetPin); + wait_ms(10); + writePinHigh(AdafruitBleResetPin); + + wait_ms(1000); // Give it a second to initialize + + state.initialized = true; + return state.initialized; +} + +static inline uint8_t min(uint8_t a, uint8_t b) { return a < b ? a : b; } + +static bool read_response(char *resp, uint16_t resplen, bool verbose) { + char *dest = resp; + char *end = dest + resplen; + + while (true) { + struct sdep_msg msg; + + if (!sdep_recv_pkt(&msg, 2 * SdepTimeout)) { + dprint("sdep_recv_pkt failed\n"); + return false; + } + + if (msg.type != SdepResponse) { + *resp = 0; + return false; + } + + uint8_t len = min(msg.len, end - dest); + if (len > 0) { + memcpy(dest, msg.payload, len); + dest += len; + } + + if (!msg.more) { + // No more data is expected! + break; + } + } + + // Ensure the response is NUL terminated + *dest = 0; + + // "Parse" the result text; we want to snip off the trailing OK or ERROR line + // Rewind past the possible trailing CRLF so that we can strip it + --dest; + while (dest > resp && (dest[0] == '\n' || dest[0] == '\r')) { + *dest = 0; + --dest; + } + + // Look back for start of preceeding line + char *last_line = strrchr(resp, '\n'); + if (last_line) { + ++last_line; + } else { + last_line = resp; + } + + bool success = false; + static const char kOK[] PROGMEM = "OK"; + + success = !strcmp_P(last_line, kOK); + + if (verbose || !success) { + dprintf("result: %s\n", resp); + } + return success; +} + +static bool at_command(const char *cmd, char *resp, uint16_t resplen, bool verbose, uint16_t timeout) { + const char * end = cmd + strlen(cmd); + struct sdep_msg msg; + + if (verbose) { + dprintf("ble send: %s\n", cmd); + } + + if (resp) { + // They want to decode the response, so we need to flush and wait + // for all pending I/O to finish before we start this one, so + // that we don't confuse the results + resp_buf_wait(cmd); + *resp = 0; + } + + // Fragment the command into a series of SDEP packets + while (end - cmd > SdepMaxPayload) { + sdep_build_pkt(&msg, BleAtWrapper, (uint8_t *)cmd, SdepMaxPayload, true); + if (!sdep_send_pkt(&msg, timeout)) { + return false; + } + cmd += SdepMaxPayload; + } + + sdep_build_pkt(&msg, BleAtWrapper, (uint8_t *)cmd, end - cmd, false); + if (!sdep_send_pkt(&msg, timeout)) { + return false; + } + + if (resp == NULL) { + uint16_t now = timer_read(); + while (!resp_buf.enqueue(now)) { + resp_buf_read_one(false); + } + uint16_t later = timer_read(); + if (TIMER_DIFF_16(later, now) > 0) { + dprintf("waited %dms for resp_buf\n", TIMER_DIFF_16(later, now)); + } + return true; + } + + return read_response(resp, resplen, verbose); +} + +bool at_command_P(const char *cmd, char *resp, uint16_t resplen, bool verbose) { + char *cmdbuf = (char *)alloca(strlen_P(cmd) + 1); + strcpy_P(cmdbuf, cmd); + return at_command(cmdbuf, resp, resplen, verbose); +} + +bool adafruit_ble_is_connected(void) { return state.is_connected; } + +bool adafruit_ble_enable_keyboard(void) { + char resbuf[128]; + + if (!state.initialized && !ble_init()) { + return false; + } + + state.configured = false; + + // Disable command echo + static const char kEcho[] PROGMEM = "ATE=0"; + // Make the advertised name match the keyboard + static const char kGapDevName[] PROGMEM = "AT+GAPDEVNAME=" STR(PRODUCT); + // Turn on keyboard support + static const char kHidEnOn[] PROGMEM = "AT+BLEHIDEN=1"; + + // Adjust intervals to improve latency. This causes the "central" + // system (computer/tablet) to poll us every 10-30 ms. We can't + // set a smaller value than 10ms, and 30ms seems to be the natural + // processing time on my macbook. Keeping it constrained to that + // feels reasonable to type to. + static const char kGapIntervals[] PROGMEM = "AT+GAPINTERVALS=10,30,,"; + + // Enable GATT Battery Service + static const char kBattEnOn[] PROGMEM = "AT+BLEBATTEN=1"; + + // Reset the device so that it picks up the above changes + static const char kATZ[] PROGMEM = "ATZ"; + + // Turn down the power level a bit + static const char kPower[] PROGMEM = "AT+BLEPOWERLEVEL=-12"; + static PGM_P const configure_commands[] PROGMEM = { + kEcho, kGapIntervals, kGapDevName, kHidEnOn, kPower, kBattEnOn, kATZ, + }; + + uint8_t i; + for (i = 0; i < sizeof(configure_commands) / sizeof(configure_commands[0]); ++i) { + PGM_P cmd; + memcpy_P(&cmd, configure_commands + i, sizeof(cmd)); + + if (!at_command_P(cmd, resbuf, sizeof(resbuf))) { + dprintf("failed BLE command: %S: %s\n", cmd, resbuf); + goto fail; + } + } + + state.configured = true; + + // Check connection status in a little while; allow the ATZ time + // to kick in. + state.last_connection_update = timer_read(); +fail: + return state.configured; +} + +static void set_connected(bool connected) { + if (connected != state.is_connected) { + if (connected) { + dprint("BLE connected\n"); + } else { + dprint("BLE disconnected\n"); + } + state.is_connected = connected; + + // TODO: if modifiers are down on the USB interface and + // we cut over to BLE or vice versa, they will remain stuck. + // This feels like a good point to do something like clearing + // the keyboard and/or generating a fake all keys up message. + // However, I've noticed that it takes a couple of seconds + // for macOS to to start recognizing key presses after BLE + // is in the connected state, so I worry that doing that + // here may not be good enough. + } +} + +void adafruit_ble_task(void) { + char resbuf[48]; + char cmdbuf[48]; + + if (!state.configured && !adafruit_ble_enable_keyboard()) { + return; + } + resp_buf_read_one(true); + send_buf_send_one(SdepShortTimeout); + + if (resp_buf.empty() && (state.event_flags & UsingEvents) && readPin(AdafruitBleIRQPin)) { + // Must be an event update + if (at_command_P(PSTR("AT+EVENTSTATUS"), resbuf, sizeof(resbuf))) { + uint32_t mask = strtoul(resbuf, NULL, 16); + + if (mask & BleSystemConnected) { + set_connected(true); + } else if (mask & BleSystemDisconnected) { + set_connected(false); + } + } + } + + if (timer_elapsed(state.last_connection_update) > ConnectionUpdateInterval) { + bool shouldPoll = true; + if (!(state.event_flags & ProbedEvents)) { + // Request notifications about connection status changes. + // This only works in SPIFRIEND firmware > 0.6.7, which is why + // we check for this conditionally here. + // Note that at the time of writing, HID reports only work correctly + // with Apple products on firmware version 0.6.7! + // https://forums.adafruit.com/viewtopic.php?f=8&t=104052 + if (at_command_P(PSTR("AT+EVENTENABLE=0x1"), resbuf, sizeof(resbuf))) { + at_command_P(PSTR("AT+EVENTENABLE=0x2"), resbuf, sizeof(resbuf)); + state.event_flags |= UsingEvents; + } + state.event_flags |= ProbedEvents; + + // leave shouldPoll == true so that we check at least once + // before relying solely on events + } else { + shouldPoll = false; + } + + static const char kGetConn[] PROGMEM = "AT+GAPGETCONN"; + state.last_connection_update = timer_read(); + + if (at_command_P(kGetConn, resbuf, sizeof(resbuf))) { + set_connected(atoi(resbuf)); + } + } + +#ifdef SAMPLE_BATTERY + if (timer_elapsed(state.last_battery_update) > BatteryUpdateInterval && resp_buf.empty()) { + state.last_battery_update = timer_read(); + + state.vbat = analogReadPin(BATTERY_LEVEL_PIN); + + + if (state.vbat >= 862) // around 4.17V, li-ion can charge usually to max of 4.19V + state.vbat = 100; + else if (state.vbat < 820) // around 3.55V, anything below cannot be trusted as 3.5v=816, 3.35v=814, 3.3v=815, 3.2v=816, 3v=817 + state.vbat = 0; + else + state.vbat = (state.vbat - 820) * 99 / 41; + snprintf(cmdbuf, sizeof(cmdbuf), "AT+BLEBATTVAL=%d", state.vbat); + at_command(cmdbuf, NULL, 0, false); + + } +#endif +} + +static bool process_queue_item(struct queue_item *item, uint16_t timeout) { + char cmdbuf[48]; + char fmtbuf[64]; + + // Arrange to re-check connection after keys have settled + state.last_connection_update = timer_read(); + +#if 1 + if (TIMER_DIFF_16(state.last_connection_update, item->added) > 0) { + dprintf("send latency %dms\n", TIMER_DIFF_16(state.last_connection_update, item->added)); + } +#endif + + switch (item->queue_type) { + case QTKeyReport: + strcpy_P(fmtbuf, PSTR("AT+BLEKEYBOARDCODE=%02x-00-%02x-%02x-%02x-%02x-%02x-%02x")); + snprintf(cmdbuf, sizeof(cmdbuf), fmtbuf, item->key.modifier, item->key.keys[0], item->key.keys[1], item->key.keys[2], item->key.keys[3], item->key.keys[4], item->key.keys[5]); + return at_command(cmdbuf, NULL, 0, true, timeout); + + case QTConsumer: + strcpy_P(fmtbuf, PSTR("AT+BLEHIDCONTROLKEY=0x%04x")); + snprintf(cmdbuf, sizeof(cmdbuf), fmtbuf, item->consumer); + return at_command(cmdbuf, NULL, 0, true, timeout); + +#ifdef MOUSE_ENABLE + case QTMouseMove: + strcpy_P(fmtbuf, PSTR("AT+BLEHIDMOUSEMOVE=%d,%d,%d,%d")); + snprintf(cmdbuf, sizeof(cmdbuf), fmtbuf, item->mousemove.x, item->mousemove.y, item->mousemove.scroll, item->mousemove.pan); + if (!at_command(cmdbuf, NULL, 0, true, timeout)) { + return false; + } + strcpy_P(cmdbuf, PSTR("AT+BLEHIDMOUSEBUTTON=")); + if (item->mousemove.buttons & MOUSE_BTN1) { + strcat(cmdbuf, "L"); + } + if (item->mousemove.buttons & MOUSE_BTN2) { + strcat(cmdbuf, "R"); + } + if (item->mousemove.buttons & MOUSE_BTN3) { + strcat(cmdbuf, "M"); + } + if (item->mousemove.buttons == 0) { + strcat(cmdbuf, "0"); + } + return at_command(cmdbuf, NULL, 0, true, timeout); +#endif + default: + return true; + } +} + +void adafruit_ble_send_keys(uint8_t hid_modifier_mask, uint8_t *keys, uint8_t nkeys) { + struct queue_item item; + bool didWait = false; + + item.queue_type = QTKeyReport; + item.key.modifier = hid_modifier_mask; + item.added = timer_read(); + + while (nkeys >= 0) { + item.key.keys[0] = keys[0]; + item.key.keys[1] = nkeys >= 1 ? keys[1] : 0; + item.key.keys[2] = nkeys >= 2 ? keys[2] : 0; + item.key.keys[3] = nkeys >= 3 ? keys[3] : 0; + item.key.keys[4] = nkeys >= 4 ? keys[4] : 0; + item.key.keys[5] = nkeys >= 5 ? keys[5] : 0; + + if (!send_buf.enqueue(item)) { + if (!didWait) { + dprint("wait for buf space\n"); + didWait = true; + } + send_buf_send_one(); + continue; + } + + if (nkeys <= 6) { + return; + } + + nkeys -= 6; + keys += 6; + } +} + +void adafruit_ble_send_consumer_key(uint16_t usage) { + struct queue_item item; + + item.queue_type = QTConsumer; + item.consumer = usage; + + while (!send_buf.enqueue(item)) { + send_buf_send_one(); + } +} + +#ifdef MOUSE_ENABLE +void adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan, uint8_t buttons) { + struct queue_item item; + + item.queue_type = QTMouseMove; + item.mousemove.x = x; + item.mousemove.y = y; + item.mousemove.scroll = scroll; + item.mousemove.pan = pan; + item.mousemove.buttons = buttons; + + while (!send_buf.enqueue(item)) { + send_buf_send_one(); + } +} +#endif + +uint32_t adafruit_ble_read_battery_voltage(void) { return state.vbat; } + +bool adafruit_ble_set_mode_leds(bool on) { + if (!state.configured) { + return false; + } + + // The "mode" led is the red blinky one + at_command_P(on ? PSTR("AT+HWMODELED=1") : PSTR("AT+HWMODELED=0"), NULL, 0); + + // Pin 19 is the blue "connected" LED; turn that off too. + // When turning LEDs back on, don't turn that LED on if we're + // not connected, as that would be confusing. + at_command_P(on && state.is_connected ? PSTR("AT+HWGPIO=19,1") : PSTR("AT+HWGPIO=19,0"), NULL, 0); + return true; +} + +// https://learn.adafruit.com/adafruit-feather-32u4-bluefruit-le/ble-generic#at-plus-blepowerlevel +bool adafruit_ble_set_power_level(int8_t level) { + char cmd[46]; + if (!state.configured) { + return false; + } + snprintf(cmd, sizeof(cmd), "AT+BLEPOWERLEVEL=%d", level); + return at_command(cmd, NULL, 0, false); +} From a4f543e456154236fe1830b862722d1539f37355 Mon Sep 17 00:00:00 2001 From: quadcube <13719009+quadcube@users.noreply.github.com> Date: Mon, 15 Feb 2021 14:55:23 +0800 Subject: [PATCH 09/21] Revert tmk_core/protocol/lufa/adafruit_ble.cpp back to qmk:master --- tmk_core/protocol/lufa/adafruit_ble.cpp | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/tmk_core/protocol/lufa/adafruit_ble.cpp b/tmk_core/protocol/lufa/adafruit_ble.cpp index 8ef10ec39e39..3f2cc35734a9 100644 --- a/tmk_core/protocol/lufa/adafruit_ble.cpp +++ b/tmk_core/protocol/lufa/adafruit_ble.cpp @@ -450,17 +450,14 @@ bool adafruit_ble_enable_keyboard(void) { // processing time on my macbook. Keeping it constrained to that // feels reasonable to type to. static const char kGapIntervals[] PROGMEM = "AT+GAPINTERVALS=10,30,,"; - - // Enable GATT Battery Service - static const char kBattEnOn[] PROGMEM = "AT+BLEBATTEN=1"; - + // Reset the device so that it picks up the above changes static const char kATZ[] PROGMEM = "ATZ"; // Turn down the power level a bit static const char kPower[] PROGMEM = "AT+BLEPOWERLEVEL=-12"; static PGM_P const configure_commands[] PROGMEM = { - kEcho, kGapIntervals, kGapDevName, kHidEnOn, kPower, kBattEnOn, kATZ, + kEcho, kGapIntervals, kGapDevName, kHidEnOn, kPower, kATZ, }; uint8_t i; @@ -505,8 +502,7 @@ static void set_connected(bool connected) { void adafruit_ble_task(void) { char resbuf[48]; - char cmdbuf[48]; - + if (!state.configured && !adafruit_ble_enable_keyboard()) { return; } @@ -560,17 +556,6 @@ void adafruit_ble_task(void) { state.last_battery_update = timer_read(); state.vbat = analogReadPin(BATTERY_LEVEL_PIN); - - - if (state.vbat >= 862) // around 4.17V, li-ion can charge usually to max of 4.19V - state.vbat = 100; - else if (state.vbat < 820) // around 3.55V, anything below cannot be trusted as 3.5v=816, 3.35v=814, 3.3v=815, 3.2v=816, 3v=817 - state.vbat = 0; - else - state.vbat = (state.vbat - 820) * 99 / 41; - snprintf(cmdbuf, sizeof(cmdbuf), "AT+BLEBATTVAL=%d", state.vbat); - at_command(cmdbuf, NULL, 0, false); - } #endif } From e929e30354b58e026be8c44e9538841fface0fd5 Mon Sep 17 00:00:00 2001 From: quadcube <13719009+quadcube@users.noreply.github.com> Date: Mon, 15 Feb 2021 15:01:35 +0800 Subject: [PATCH 10/21] Removed not related keymap folder. --- .../alix40/keymaps/swappedBottomRow/config.h | 3 -- .../alix40/keymaps/swappedBottomRow/keymap.c | 47 ------------------- 2 files changed, 50 deletions(-) delete mode 100644 keyboards/tokyokeyboard/alix40/keymaps/swappedBottomRow/config.h delete mode 100644 keyboards/tokyokeyboard/alix40/keymaps/swappedBottomRow/keymap.c diff --git a/keyboards/tokyokeyboard/alix40/keymaps/swappedBottomRow/config.h b/keyboards/tokyokeyboard/alix40/keymaps/swappedBottomRow/config.h deleted file mode 100644 index 271f48d0011b..000000000000 --- a/keyboards/tokyokeyboard/alix40/keymaps/swappedBottomRow/config.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -// place overrides here diff --git a/keyboards/tokyokeyboard/alix40/keymaps/swappedBottomRow/keymap.c b/keyboards/tokyokeyboard/alix40/keymaps/swappedBottomRow/keymap.c deleted file mode 100644 index 54b68f5825e8..000000000000 --- a/keyboards/tokyokeyboard/alix40/keymaps/swappedBottomRow/keymap.c +++ /dev/null @@ -1,47 +0,0 @@ -#include QMK_KEYBOARD_H - -#define BL 0 -#define FN 1 -/* - * Default HHKB Layout - */ -const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - /* 0: Default layer -┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ -│ Esc │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │ \ │ ` │ -├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ -│ Tab │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ [ │ ] │BkSpc│█████│ -├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ -│Ctrl │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ' │█████│Enter│█████│ -├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ -│Shift│█████│ Z │ X │ C │ V │ B │ N │ M │ , │ . │ / │█████│Shift│ Fn │ -├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ -│█████│ Gui │ Alt │█████│█████│Space│█████│█████│█████│█████│█████│ Alt │ Gui │█████│█████│ -└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ - */ -[BL] = LAYOUT_60_hhkb( - 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_BSLS, KC_GRV, \ - 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_BSPC, \ - KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, \ - KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, MO(FN), \ - KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI ), - /* 1: HHKB Fn layer -┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ -│ │ F1 │ F2 │ F3 │ F4 │ F5 │ F6 │ F7 │ F8 │ F9 │ F10 │ F11 │ F12 │ Ins │ Del │ -├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ -│Caps │ RGB │RGBfw│RGBrv│BLtog│BLstp│ │ │ Psc │ Slk │ Pus │ Up │ │ │█████│ -├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ -│ │ VoD │ VoU │ Mut │ │ │NP_* │NP_/ │Home │PgUp │Left │Right│█████│NPEnt│█████│ -├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ -│ │█████│ │ │Calc │ │ │NP_+ │NP_- │ End │PgDwn│Down │█████│ │ │ -├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ -│█████│ │ │█████│█████│█████│ │█████│█████│█████│█████│ │ │█████│█████│ -└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ - */ -[FN]= LAYOUT_60_hhkb( - KC_TRNS, 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_INS, KC_DEL, \ - KC_CAPS, RGB_TOG, RGB_MOD, RGB_RMOD, BL_TOGG, BL_STEP, KC_TRNS, KC_TRNS, KC_PSCR, KC_SLCK, KC_PAUS, KC_UP, KC_TRNS, KC_TRNS, \ - KC_TRNS, KC_VOLD, KC_VOLU, KC_MUTE, KC_TRNS, KC_TRNS, KC_PAST, KC_PSLS, KC_HOME, KC_PGUP, KC_LEFT, KC_RGHT, KC_PENT, \ - KC_TRNS, KC_TRNS, KC_TRNS, KC_CALC, KC_TRNS, KC_TRNS, KC_PPLS, KC_PMNS, KC_END, KC_PGDN, KC_DOWN, KC_TRNS, KC_TRNS, \ - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS ), -}; From ebfacda776d370c0cc16c2a8a012a506ea59192e Mon Sep 17 00:00:00 2001 From: quadcube <13719009+quadcube@users.noreply.github.com> Date: Mon, 15 Feb 2021 21:17:05 +0800 Subject: [PATCH 11/21] Updated info.json with correct keymap --- keyboards/tokyokeyboard/alix40/info.json | 380 ++++++++++++++--------- 1 file changed, 232 insertions(+), 148 deletions(-) diff --git a/keyboards/tokyokeyboard/alix40/info.json b/keyboards/tokyokeyboard/alix40/info.json index 2578f56cb22c..f0351c455a24 100644 --- a/keyboards/tokyokeyboard/alix40/info.json +++ b/keyboards/tokyokeyboard/alix40/info.json @@ -1,158 +1,242 @@ { "keyboard_name": "alix40", - "url": "", + "url": "https://tokyokeyboard.com/", "maintainer": "qmk", "width": 12, "height": 4, "layouts": { "LAYOUT_40_alix": { - "layout": [ - [ - { - "y": 0.05, - "f": 1 - }, - "0,0", - "0,1", - { - "x": 10 - }, - "0,10", - "0,11" - ], - [ - { - "x": 0.15 - }, - "1,0", - "1,1", - { - "x": 10.2 - }, - "1,10", - "1,11" - ], - [ - { - "x": 0.5 - }, - "2,0", - "2,1", - { - "x": 9.5 - }, - "2,10", - "2,11" - ], - [ - { - "x": 0.25 - }, - "3,0", - "3,1", - { - "x": 10 - }, - "3,10", - "3,11" - ], - [ - { - "r": 10, - "rx": 3, - "y": 4.5, - "x": 2.5 - }, - "3,4\n\n\n0,1", - "3,5\n\n\n0,1" - ], - [ - { - "ry": 4.25, - "y": -4, - "x": -1 - }, - "0,2", - "0,3", - "0,4", - "0,5" - ], - [ - { - "x": -0.75 - }, - "1,2", - "1,3", - "1,4", - "1,5" - ], - [ - { - "x": -0.25 - }, - "2,2", - "2,3", - "2,4", - "2,5" - ], - [ - { - "x": 0.75 - }, - "3,3", - { - "w": 2 - }, - "3,5\n\n\n0,0" - ], - [ - { - "r": -10, - "rx": 12.5, - "y": -4.25, - "x": -4.5 - }, - "0,6", - "0,7", - "0,8", - "0,9" - ], - [ - { - "x": -4.25 - }, - "1,6", - "1,7", - "1,8", - "1,9" - ], - [ - { - "x": -4.75 - }, - "2,6", - "2,7", - "2,8", - "2,9" - ], - [ - { - "x": -4.75, - "w": 2 - }, - "3,6\n\n\n1,0", - "3,8" - ], - [ - { - "y": 0.25, - "x": -4.75 - }, - "3,6\n\n\n1,1", - "3,7\n\n\n1,1" - ] - ] - + "layout":[{ + "label": "Tab", + "x": 0, + "y": 0 + }, + { + "label": "Q", + "x": 1, + "y": 0 + }, + { + "label": "W", + "x": 2, + "y": 0 + }, + { + "label": "E", + "x": 3, + "y": 0 + }, + { + "label": "R", + "x": 4, + "y": 0 + }, + { + "label": "T", + "x": 5, + "y": 0 + }, + { + "label": "Y", + "x": 7.5, + "y": 0 + }, + { + "label": "U", + "x": 8.5, + "y": 0 + }, + { + "label": "I", + "x": 9.5, + "y": 0 + }, + { + "label": "O", + "x": 10.5, + "y": 0 + }, + { + "label": "P", + "x": 11.5, + "y": 0 + }, + { + "label": "`", + "x": 12.5, + "y": 0 + }, + { + "label": "Esc", + "x": 0.25, + "y": 1 + }, + { + "label": "A", + "x": 1.25, + "y": 1 + }, + { + "label": "S", + "x": 2.25, + "y": 1 + }, + { + "label": "D", + "x": 3.25, + "y": 1 + }, + { + "label": "F", + "x": 4.25, + "y": 1 + }, + { + "label": "G", + "x": 5.25, + "y": 1 + }, + { + "label": "H", + "x": 7.75, + "y": 1 + }, + { + "label": "J", + "x": 8.75, + "y": 1 + }, + { + "label": "K", + "x": 9.75, + "y": 1 + }, + { + "label": "L", + "x": 10.75, + "y": 1 + }, + { + "label": ";", + "x": 11.75, + "y": 1 + }, + { + "label": "'", + "x": 12.75, + "y": 1 + }, + { + "label": "Shift", + "x": 0.75, + "y": 2 + }, + { + "label": "Z", + "x": 1.75, + "y": 2 + }, + { + "label": "X", + "x": 2.75, + "y": 2 + }, + { + "label": "C", + "x": 3.75, + "y": 2 + }, + { + "label": "V", + "x": 4.75, + "y": 2 + }, + { + "label": "B", + "x": 5.75, + "y": 2 + }, + { + "label": "Enter", + "x": 7.25, + "y": 2 + }, + { + "label": "N", + "x": 7.25, + "y": 2 + }, + { + "label": "M", + "x": 7.25, + "y": 2 + }, + { + "label": ",", + "x": 7.25, + "y": 2 + }, + { + "label": ".", + "x": 7.25, + "y": 2 + }, + { + "label": "/", + "x": 7.25, + "y": 2 + }, + { + "label": "Ctrl", + "x": 0.5, + "y": 3 + }, + { + "label": "Alt", + "x": 1.5, + "y": 3 + }, + { + "label": "Gui", + "x": 3.75, + "y": 3 + }, + { + "label": "NO", + "x": 4.75, + "y": 3 + }, + { + "label": "Bksp", + "x": 5.75, + "y": 3 + }, + { + "label": "Space", + "x": 7.25, + "y": 3 + }, + { + "label": "NO", + "x": 8.25, + "y": 3 + }, + { + "label": "Gui", + "x": 9.25, + "y": 3 + }, + { + "label": "[", + "x": 11.5, + "y": 3 + }, + { + "label": "]", + "x": 12.5, + "y": 3 + } + ] } } } From 551ab4fc4ef9f7c1331a1962077368c97264ce07 Mon Sep 17 00:00:00 2001 From: quadcube <13719009+quadcube@users.noreply.github.com> Date: Mon, 15 Feb 2021 21:36:50 +0800 Subject: [PATCH 12/21] Fixed lint check regarding missing layout issue --- keyboards/tokyokeyboard/alix40/alix40.h | 5 +---- keyboards/tokyokeyboard/alix40/config.h | 6 +----- keyboards/tokyokeyboard/alix40/info.json | 2 +- keyboards/tokyokeyboard/alix40/rules.mk | 2 +- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/keyboards/tokyokeyboard/alix40/alix40.h b/keyboards/tokyokeyboard/alix40/alix40.h index f0923dd36faa..90625048167a 100644 --- a/keyboards/tokyokeyboard/alix40/alix40.h +++ b/keyboards/tokyokeyboard/alix40/alix40.h @@ -1,5 +1,4 @@ -#ifndef ALIX_H -#define ALIX_H +#pragma once #include "quantum.h" @@ -14,5 +13,3 @@ { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B }, \ { K30, K31, KC_NO, K33, K34, K35, K36, K37, K38, KC_NO, K3A, K3B } \ } - -#endif diff --git a/keyboards/tokyokeyboard/alix40/config.h b/keyboards/tokyokeyboard/alix40/config.h index 3e9de22267d4..a2312ac50332 100644 --- a/keyboards/tokyokeyboard/alix40/config.h +++ b/keyboards/tokyokeyboard/alix40/config.h @@ -1,5 +1,4 @@ -#ifndef CONFIG_H -#define CONFIG_H +#pragma once #include "config_common.h" @@ -60,6 +59,3 @@ #define AdafruitBleResetPin D4 #define AdafruitBleCSPin B4 #define AdafruitBleIRQPin E6 - - -#endif diff --git a/keyboards/tokyokeyboard/alix40/info.json b/keyboards/tokyokeyboard/alix40/info.json index f0351c455a24..dbc0f5cbfd5c 100644 --- a/keyboards/tokyokeyboard/alix40/info.json +++ b/keyboards/tokyokeyboard/alix40/info.json @@ -6,7 +6,7 @@ "height": 4, "layouts": { "LAYOUT_40_alix": { - "layout":[{ + "layout": [{ "label": "Tab", "x": 0, "y": 0 diff --git a/keyboards/tokyokeyboard/alix40/rules.mk b/keyboards/tokyokeyboard/alix40/rules.mk index b0cc984eb9aa..d9dbc1f92c98 100644 --- a/keyboards/tokyokeyboard/alix40/rules.mk +++ b/keyboards/tokyokeyboard/alix40/rules.mk @@ -32,6 +32,6 @@ NKRO_ENABLE = no # USB Nkey Rollover - if this doesn't work, see here: ht BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality RGBLIGHT_ENABLE = yes # Enable RGB light -LAYOUTS = LAYOUT_40_alix +LAYOUTS = 40_alix EXTRAFLAGS += -flto From ae790b5fd7c51a724e3ca7f89486058a8636bddf Mon Sep 17 00:00:00 2001 From: quadcube <13719009+quadcube@users.noreply.github.com> Date: Wed, 17 Feb 2021 12:29:57 +0800 Subject: [PATCH 13/21] Added missing BATTERY_LEVEL_PIN declaration --- keyboards/tokyokeyboard/alix40/config.h | 1 + 1 file changed, 1 insertion(+) diff --git a/keyboards/tokyokeyboard/alix40/config.h b/keyboards/tokyokeyboard/alix40/config.h index a2312ac50332..0e9652e5f429 100644 --- a/keyboards/tokyokeyboard/alix40/config.h +++ b/keyboards/tokyokeyboard/alix40/config.h @@ -59,3 +59,4 @@ #define AdafruitBleResetPin D4 #define AdafruitBleCSPin B4 #define AdafruitBleIRQPin E6 +#define BATTERY_LEVEL_PIN B6 From 85a985266909e8760f9eb452347d0fb23d9bdd12 Mon Sep 17 00:00:00 2001 From: quadcube <13719009+quadcube@users.noreply.github.com> Date: Sat, 20 Feb 2021 00:50:23 +0800 Subject: [PATCH 14/21] Resolved all requested change. --- .../{tokyokeyboard => }/tokyo60/config.h | 2 +- .../{tokyokeyboard => }/tokyo60/info.json | 0 .../tokyo60/keymaps/default/config.h | 0 .../tokyo60/keymaps/default/keymap.c | 0 .../tokyo60/keymaps/swappedBottomRow/config.h | 0 .../tokyo60/keymaps/swappedBottomRow/keymap.c | 0 .../tokyo60/keymaps/via/keymap.c | 0 .../tokyo60/keymaps/via/rules.mk | 0 .../{tokyokeyboard => }/tokyo60/readme.md | 0 .../{tokyokeyboard => }/tokyo60/rules.mk | 0 .../{tokyokeyboard => }/tokyo60/tokyo60.c | 0 .../{tokyokeyboard => }/tokyo60/tokyo60.h | 0 keyboards/tokyokeyboard/alix40/alix40.c | 20 +++++++++++++------ keyboards/tokyokeyboard/alix40/alix40.h | 14 +++++++++++++ keyboards/tokyokeyboard/alix40/config.h | 3 --- keyboards/tokyokeyboard/alix40/readme.md | 12 ++--------- keyboards/tokyokeyboard/alix40/rules.mk | 7 +------ 17 files changed, 32 insertions(+), 26 deletions(-) rename keyboards/{tokyokeyboard => }/tokyo60/config.h (97%) rename keyboards/{tokyokeyboard => }/tokyo60/info.json (100%) rename keyboards/{tokyokeyboard => }/tokyo60/keymaps/default/config.h (100%) rename keyboards/{tokyokeyboard => }/tokyo60/keymaps/default/keymap.c (100%) rename keyboards/{tokyokeyboard => }/tokyo60/keymaps/swappedBottomRow/config.h (100%) rename keyboards/{tokyokeyboard => }/tokyo60/keymaps/swappedBottomRow/keymap.c (100%) rename keyboards/{tokyokeyboard => }/tokyo60/keymaps/via/keymap.c (100%) rename keyboards/{tokyokeyboard => }/tokyo60/keymaps/via/rules.mk (100%) rename keyboards/{tokyokeyboard => }/tokyo60/readme.md (100%) rename keyboards/{tokyokeyboard => }/tokyo60/rules.mk (100%) rename keyboards/{tokyokeyboard => }/tokyo60/tokyo60.c (100%) rename keyboards/{tokyokeyboard => }/tokyo60/tokyo60.h (100%) diff --git a/keyboards/tokyokeyboard/tokyo60/config.h b/keyboards/tokyo60/config.h similarity index 97% rename from keyboards/tokyokeyboard/tokyo60/config.h rename to keyboards/tokyo60/config.h index 03dee74e9b26..37b633927774 100644 --- a/keyboards/tokyokeyboard/tokyo60/config.h +++ b/keyboards/tokyo60/config.h @@ -41,7 +41,7 @@ #define RGB_DI_PIN F7 #ifdef RGB_DI_PIN -#define RGBLIGHT_ANIMATIONS +//#define RGBLIGHT_ANIMATIONS #define RGBLED_NUM 10 #define RGBLIGHT_HUE_STEP 12 #define RGBLIGHT_SAT_STEP 12 diff --git a/keyboards/tokyokeyboard/tokyo60/info.json b/keyboards/tokyo60/info.json similarity index 100% rename from keyboards/tokyokeyboard/tokyo60/info.json rename to keyboards/tokyo60/info.json diff --git a/keyboards/tokyokeyboard/tokyo60/keymaps/default/config.h b/keyboards/tokyo60/keymaps/default/config.h similarity index 100% rename from keyboards/tokyokeyboard/tokyo60/keymaps/default/config.h rename to keyboards/tokyo60/keymaps/default/config.h diff --git a/keyboards/tokyokeyboard/tokyo60/keymaps/default/keymap.c b/keyboards/tokyo60/keymaps/default/keymap.c similarity index 100% rename from keyboards/tokyokeyboard/tokyo60/keymaps/default/keymap.c rename to keyboards/tokyo60/keymaps/default/keymap.c diff --git a/keyboards/tokyokeyboard/tokyo60/keymaps/swappedBottomRow/config.h b/keyboards/tokyo60/keymaps/swappedBottomRow/config.h similarity index 100% rename from keyboards/tokyokeyboard/tokyo60/keymaps/swappedBottomRow/config.h rename to keyboards/tokyo60/keymaps/swappedBottomRow/config.h diff --git a/keyboards/tokyokeyboard/tokyo60/keymaps/swappedBottomRow/keymap.c b/keyboards/tokyo60/keymaps/swappedBottomRow/keymap.c similarity index 100% rename from keyboards/tokyokeyboard/tokyo60/keymaps/swappedBottomRow/keymap.c rename to keyboards/tokyo60/keymaps/swappedBottomRow/keymap.c diff --git a/keyboards/tokyokeyboard/tokyo60/keymaps/via/keymap.c b/keyboards/tokyo60/keymaps/via/keymap.c similarity index 100% rename from keyboards/tokyokeyboard/tokyo60/keymaps/via/keymap.c rename to keyboards/tokyo60/keymaps/via/keymap.c diff --git a/keyboards/tokyokeyboard/tokyo60/keymaps/via/rules.mk b/keyboards/tokyo60/keymaps/via/rules.mk similarity index 100% rename from keyboards/tokyokeyboard/tokyo60/keymaps/via/rules.mk rename to keyboards/tokyo60/keymaps/via/rules.mk diff --git a/keyboards/tokyokeyboard/tokyo60/readme.md b/keyboards/tokyo60/readme.md similarity index 100% rename from keyboards/tokyokeyboard/tokyo60/readme.md rename to keyboards/tokyo60/readme.md diff --git a/keyboards/tokyokeyboard/tokyo60/rules.mk b/keyboards/tokyo60/rules.mk similarity index 100% rename from keyboards/tokyokeyboard/tokyo60/rules.mk rename to keyboards/tokyo60/rules.mk diff --git a/keyboards/tokyokeyboard/tokyo60/tokyo60.c b/keyboards/tokyo60/tokyo60.c similarity index 100% rename from keyboards/tokyokeyboard/tokyo60/tokyo60.c rename to keyboards/tokyo60/tokyo60.c diff --git a/keyboards/tokyokeyboard/tokyo60/tokyo60.h b/keyboards/tokyo60/tokyo60.h similarity index 100% rename from keyboards/tokyokeyboard/tokyo60/tokyo60.h rename to keyboards/tokyo60/tokyo60.h diff --git a/keyboards/tokyokeyboard/alix40/alix40.c b/keyboards/tokyokeyboard/alix40/alix40.c index 96d1a0571400..ce05a9b12aaf 100644 --- a/keyboards/tokyokeyboard/alix40/alix40.c +++ b/keyboards/tokyokeyboard/alix40/alix40.c @@ -1,3 +1,17 @@ +/* +Copyright 2021 quadcube +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 . +*/ + #include "alix40.h" void matrix_init_kb(void) { @@ -7,12 +21,6 @@ void matrix_init_kb(void) { led_init_ports(); }; -void matrix_scan_kb(void) { - // Looping keyboard code goes here - // This runs every cycle (a lot) - matrix_scan_user(); -}; - void led_init_ports(void) { /* LEDs on */ rgblight_enable(); diff --git a/keyboards/tokyokeyboard/alix40/alix40.h b/keyboards/tokyokeyboard/alix40/alix40.h index 90625048167a..4a322a10b4e0 100644 --- a/keyboards/tokyokeyboard/alix40/alix40.h +++ b/keyboards/tokyokeyboard/alix40/alix40.h @@ -1,3 +1,17 @@ +/* +Copyright 2021 quadcube +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 . +*/ + #pragma once #include "quantum.h" diff --git a/keyboards/tokyokeyboard/alix40/config.h b/keyboards/tokyokeyboard/alix40/config.h index 0e9652e5f429..e492da7fc066 100644 --- a/keyboards/tokyokeyboard/alix40/config.h +++ b/keyboards/tokyokeyboard/alix40/config.h @@ -28,9 +28,6 @@ /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ #define DEBOUNCE 5 -/* Set power consumption to work with mobile devices */ -#define USB_MAX_POWER_CONSUMPTION 500 - /* key matrix pins */ #define MATRIX_ROW_PINS { D7, C6, C7, B5 } #define MATRIX_COL_PINS { F7, F6, F5, F4, F1, F0, D0, D1, D2, D3, D5, D6 } diff --git a/keyboards/tokyokeyboard/alix40/readme.md b/keyboards/tokyokeyboard/alix40/readme.md index 09b63360f639..cc1b5612b49d 100644 --- a/keyboards/tokyokeyboard/alix40/readme.md +++ b/keyboards/tokyokeyboard/alix40/readme.md @@ -4,7 +4,7 @@ ​ Minimal hacker style mechanical keyboard designed in Tokyo. Cherry MX compatible. More Info at [Tokyo Keyboard](http://tokyokeyboard.com). ​ -Keyboard Maintainer: [Tokyo Keyboard](http://tokyokeyboard.com) +Keyboard Maintainer: [quadcube](https://github.com/quadcube) Hardware Supported: alix40 rev1 Hardware Availability: [Tokyo Keyboard](http://tokyokeyboard.com) ​ @@ -15,16 +15,8 @@ Make example for this keyboard (after setting up your build environment): See [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) then the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Note: -<<<<<<< HEAD 1. Be very careful and gentle when disassembling the PCB from the bottom case 2. alix40 battery power switch (shown in the image below) is used to toggle battery usage (on: battery will be charged when USB is connected, keyboard will be on when USB is disconnected/off:battery will not be charged when USB is connected, keyboard will be off when USB is disconnected) -![alix40pwrtoggle](https://i.imgur.com/YPX6R2T.jpg) +![alix40pwrtoggle](https://i.imgur.com/zr0DODl.jpg) 3. Install the slider on the battery power switch (bundled together with the 3M feets) 4. Underglow RGBs are switched off when alix40 is running on battery power (hardware feature to extend battery usage time) -======= -i) Be very careful and gentle when disassembling the PCB from the bottom case -ii) alix40 battery power switch (shown in the image below) is used to toggle battery usage (on: battery will be charged when USB is connected, keyboard will be on when USB is disconnected/off:battery will not be charged when USB is connected, keyboard will be off when USB is disconnected) -![alix40pwrtoggle](https://i.imgur.com/zr0DODl.jpg) -iii) Install the slider on the battery power switch (bundled together with the 3M feets) -iv) Underglow RGBs are switched off when alix40 is running on battery power (hardware feature to extend battery usage time) ->>>>>>> 1f2744b169c91183e1e164a6460c3dc4e69f188f diff --git a/keyboards/tokyokeyboard/alix40/rules.mk b/keyboards/tokyokeyboard/alix40/rules.mk index d9dbc1f92c98..07aee243e7fe 100644 --- a/keyboards/tokyokeyboard/alix40/rules.mk +++ b/keyboards/tokyokeyboard/alix40/rules.mk @@ -24,14 +24,9 @@ SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend MIDI_ENABLE = no # MIDI controls UNICODE_ENABLE = no # Unicode BLUETOOTH = AdafruitBLE # Enable Bluetooth with the MDBT40 HID (AdafruitBLE) -BLUETOOTH_ENABLE = OUT_AUTO # AUDIO_ENABLE = no # Audio output on port C6 -CONSOLE_ENABLE = no # Console for debug +CONSOLE_ENABLE = no # Console for debug COMMAND_ENABLE = yes # Commands for debug and configuration NKRO_ENABLE = no # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality RGBLIGHT_ENABLE = yes # Enable RGB light - -LAYOUTS = 40_alix - -EXTRAFLAGS += -flto From f311b8c0b0413aeeffed4cb011d4ba8b0934d4af Mon Sep 17 00:00:00 2001 From: quadcube <13719009+quadcube@users.noreply.github.com> Date: Sat, 20 Feb 2021 01:01:01 +0800 Subject: [PATCH 15/21] Revert tokyo60 files to ori. --- keyboards/tokyo60/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/tokyo60/config.h b/keyboards/tokyo60/config.h index 37b633927774..03dee74e9b26 100644 --- a/keyboards/tokyo60/config.h +++ b/keyboards/tokyo60/config.h @@ -41,7 +41,7 @@ #define RGB_DI_PIN F7 #ifdef RGB_DI_PIN -//#define RGBLIGHT_ANIMATIONS +#define RGBLIGHT_ANIMATIONS #define RGBLED_NUM 10 #define RGBLIGHT_HUE_STEP 12 #define RGBLIGHT_SAT_STEP 12 From 5763e491e744aca71cf48b9f223aa278e8eca442 Mon Sep 17 00:00:00 2001 From: quadcube <13719009+quadcube@users.noreply.github.com> Date: Sat, 20 Feb 2021 13:23:18 +0800 Subject: [PATCH 16/21] Added GPL2+ compatible license headers in all .h, .c files. --- keyboards/tokyokeyboard/alix40/config.h | 14 ++++++++++++++ .../tokyokeyboard/alix40/keymaps/default/config.h | 14 ++++++++++++++ .../alix40/keymaps/default/keymap.bak.c | 14 ++++++++++++++ .../tokyokeyboard/alix40/keymaps/default/keymap.c | 14 ++++++++++++++ .../tokyokeyboard/alix40/keymaps/via/keymap.c | 14 ++++++++++++++ 5 files changed, 70 insertions(+) diff --git a/keyboards/tokyokeyboard/alix40/config.h b/keyboards/tokyokeyboard/alix40/config.h index e492da7fc066..f18c6c250bcb 100644 --- a/keyboards/tokyokeyboard/alix40/config.h +++ b/keyboards/tokyokeyboard/alix40/config.h @@ -1,3 +1,17 @@ +/* +Copyright 2021 quadcube +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 . +*/ + #pragma once #include "config_common.h" diff --git a/keyboards/tokyokeyboard/alix40/keymaps/default/config.h b/keyboards/tokyokeyboard/alix40/keymaps/default/config.h index 271f48d0011b..78b0cdbce502 100644 --- a/keyboards/tokyokeyboard/alix40/keymaps/default/config.h +++ b/keyboards/tokyokeyboard/alix40/keymaps/default/config.h @@ -1,3 +1,17 @@ +/* +Copyright 2021 quadcube +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 . +*/ + #pragma once // place overrides here diff --git a/keyboards/tokyokeyboard/alix40/keymaps/default/keymap.bak.c b/keyboards/tokyokeyboard/alix40/keymaps/default/keymap.bak.c index 028e511b724d..e68ec11d7d9e 100644 --- a/keyboards/tokyokeyboard/alix40/keymaps/default/keymap.bak.c +++ b/keyboards/tokyokeyboard/alix40/keymaps/default/keymap.bak.c @@ -1,3 +1,17 @@ +/* +Copyright 2021 quadcube +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 . +*/ + #include QMK_KEYBOARD_H /* diff --git a/keyboards/tokyokeyboard/alix40/keymaps/default/keymap.c b/keyboards/tokyokeyboard/alix40/keymaps/default/keymap.c index a909c0d0c0aa..39e689a28832 100644 --- a/keyboards/tokyokeyboard/alix40/keymaps/default/keymap.c +++ b/keyboards/tokyokeyboard/alix40/keymaps/default/keymap.c @@ -1,3 +1,17 @@ +/* +Copyright 2021 quadcube +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 . +*/ + #include QMK_KEYBOARD_H /* diff --git a/keyboards/tokyokeyboard/alix40/keymaps/via/keymap.c b/keyboards/tokyokeyboard/alix40/keymaps/via/keymap.c index b7e077697f46..d4fd90cb1194 100644 --- a/keyboards/tokyokeyboard/alix40/keymaps/via/keymap.c +++ b/keyboards/tokyokeyboard/alix40/keymaps/via/keymap.c @@ -1,3 +1,17 @@ +/* +Copyright 2021 quadcube +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 . +*/ + #include QMK_KEYBOARD_H #define BL 0 From a380b2504380c570087bff11c96a841c752c1081 Mon Sep 17 00:00:00 2001 From: James <13719009+quadcube@users.noreply.github.com> Date: Sat, 20 Feb 2021 13:27:43 +0800 Subject: [PATCH 17/21] Removed unused backup files. --- .../alix40/keymaps/default/keymap.bak.c | 73 ------------------- 1 file changed, 73 deletions(-) delete mode 100644 keyboards/tokyokeyboard/alix40/keymaps/default/keymap.bak.c diff --git a/keyboards/tokyokeyboard/alix40/keymaps/default/keymap.bak.c b/keyboards/tokyokeyboard/alix40/keymaps/default/keymap.bak.c deleted file mode 100644 index e68ec11d7d9e..000000000000 --- a/keyboards/tokyokeyboard/alix40/keymaps/default/keymap.bak.c +++ /dev/null @@ -1,73 +0,0 @@ -/* -Copyright 2021 quadcube -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 . -*/ - -#include QMK_KEYBOARD_H - -/* - * Default Alix Layout - */ -const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - /* 0: Default layer -┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ -│ Tab │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ ` │ -├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ -│ Esc │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ' │ -├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ -│Shift│ Z │ X │ C │ V │ B │Enter│ N │ M │ , │ . │ / │ -├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ -│Ctrl │ Alt │ │ Gui │█████│Bksp │Space│█████│ Gui │ │ [ │ ] │ -└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ - */ -[0] = LAYOUT_40_alix( - KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_GRV, \ - KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \ - KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_ENT, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, \ - KC_LCTL, KC_RALT, KC_LGUI,KC_NO, LT(1, KC_BSPC), LT(2, KC_SPC), KC_NO, KC_RGUI, KC_LBRC, KC_RBRC -), -/* 1: Lower Layer -┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ -│ Tab │ ! │ @ │ # │ $ │ % │ ^ │ & │ * │ ( │ ) │ | │ -├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ -│ Esc | F1 | F2 | F3 | F4 | F5 │Left │Down │ Up │Right│ ; │ ' │ -├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ -│Shift│ F6 │ F7 │ F8 │ F9 │ F10 │Enter|Next |Vol- |Vol+ | Play│ / │ -├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ -│Ctrl │ Alt │ │ Gui │█████│Bksp │Space│█████│ Gui │ │ _ │ + │ -└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ - */ -[1]= LAYOUT_40_alix( - KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_PIPE, \ - KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_SCLN, KC_QUOT, \ - KC_LSFT, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_ENT, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, KC_SLSH, \ - KC_LCTL, KC_RALT, KC_LGUI, KC_NO, LT(1, KC_BSPC), LT(2, KC_SPC), KC_NO, KC_RGUI, KC_UNDS, KC_PLUS -), - -/* 2: Raise Layer -┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ -│ Tab │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ \ │ -├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ -│ Esc │ A │ S │ D │ F │ G │Left │Down │ Up │Right│ ; │ ' │ -├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ -│Shift│ Z │ X │ C │ V │ B │Enter│PgDn │PgUp │Home │ End │ / │ -├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ -│Ctrl │ Alt │ │ Gui │█████│Bksp │Space│█████│ Gui │ │ - │ = │ -└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ - */ -[2]= LAYOUT_40_alix( - KC_TILD, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSLS, \ - KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_SCLN, KC_QUOT, \ - KC_LSFT, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_ENT, KC_MNXT, KC_PGDN, KC_PGUP, KC_HOME, KC_END, \ - KC_LCTL, KC_RALT, KC_LGUI, KC_NO, LT(1, KC_BSPC), LT(2, KC_SPC), KC_NO, KC_RGUI, KC_MINS, KC_EQL -), -}; From 72cb64adef0f175fca4564baa8a022fb9e9a8eb3 Mon Sep 17 00:00:00 2001 From: quadcube <13719009+quadcube@users.noreply.github.com> Date: Sat, 20 Feb 2021 15:57:34 +0800 Subject: [PATCH 18/21] Remove "/" from keymap files, clean up rules.mk, removed unused config.h. --- keyboards/tokyokeyboard/alix40/alix40.c | 4 --- .../alix40/keymaps/default/config.h | 17 --------- .../alix40/keymaps/default/keymap.c | 18 +++++----- .../tokyokeyboard/alix40/keymaps/via/keymap.c | 24 ++++++------- keyboards/tokyokeyboard/alix40/readme.md | 6 ++-- keyboards/tokyokeyboard/alix40/rules.mk | 36 +++++++++---------- 6 files changed, 42 insertions(+), 63 deletions(-) delete mode 100644 keyboards/tokyokeyboard/alix40/keymaps/default/config.h diff --git a/keyboards/tokyokeyboard/alix40/alix40.c b/keyboards/tokyokeyboard/alix40/alix40.c index ce05a9b12aaf..d03ab72551a7 100644 --- a/keyboards/tokyokeyboard/alix40/alix40.c +++ b/keyboards/tokyokeyboard/alix40/alix40.c @@ -23,8 +23,4 @@ void matrix_init_kb(void) { void led_init_ports(void) { /* LEDs on */ - rgblight_enable(); - rgblight_sethsv(0,0,255); - backlight_enable(); - breathing_enable(); } diff --git a/keyboards/tokyokeyboard/alix40/keymaps/default/config.h b/keyboards/tokyokeyboard/alix40/keymaps/default/config.h deleted file mode 100644 index 78b0cdbce502..000000000000 --- a/keyboards/tokyokeyboard/alix40/keymaps/default/config.h +++ /dev/null @@ -1,17 +0,0 @@ -/* -Copyright 2021 quadcube -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 . -*/ - -#pragma once - -// place overrides here diff --git a/keyboards/tokyokeyboard/alix40/keymaps/default/keymap.c b/keyboards/tokyokeyboard/alix40/keymaps/default/keymap.c index 39e689a28832..ae8f1d0ad097 100644 --- a/keyboards/tokyokeyboard/alix40/keymaps/default/keymap.c +++ b/keyboards/tokyokeyboard/alix40/keymaps/default/keymap.c @@ -30,9 +30,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { └─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ */ [0] = LAYOUT_40_alix( - KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_GRV, \ - KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \ - KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_ENT, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, \ + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_GRV, + KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_ENT, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_LCTL, KC_RALT, KC_LGUI,KC_NO, LT(1, KC_BSPC), LT(2, KC_SPC), KC_NO, KC_RGUI, KC_LBRC, KC_RBRC ), /* 1: Lower Layer @@ -47,9 +47,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { └─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ */ [1]= LAYOUT_40_alix( - KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_PIPE, \ - KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_SCLN, KC_QUOT, \ - KC_LSFT, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_ENT, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, KC_SLSH, \ + KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_PIPE, + KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_SCLN, KC_QUOT, + KC_LSFT, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_ENT, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, KC_SLSH, KC_LCTL, KC_RALT, KC_LGUI, KC_NO, LT(1, KC_BSPC), LT(2, KC_SPC), KC_NO, KC_RGUI, KC_UNDS, KC_PLUS ), @@ -65,9 +65,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { └─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ */ [2]= LAYOUT_40_alix( - KC_TILD, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSLS, \ - KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_SCLN, KC_QUOT, \ - KC_LSFT, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_ENT, KC_MNXT, KC_PGDN, KC_PGUP, KC_HOME, KC_END, \ + KC_TILD, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSLS, + KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_SCLN, KC_QUOT, + KC_LSFT, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_ENT, KC_MNXT, KC_PGDN, KC_PGUP, KC_HOME, KC_END, KC_LCTL, KC_RALT, KC_LGUI, KC_NO, LT(1, KC_BSPC), LT(2, KC_SPC), KC_NO, KC_RGUI, KC_MINS, KC_EQL ), }; diff --git a/keyboards/tokyokeyboard/alix40/keymaps/via/keymap.c b/keyboards/tokyokeyboard/alix40/keymaps/via/keymap.c index d4fd90cb1194..7bd091591340 100644 --- a/keyboards/tokyokeyboard/alix40/keymaps/via/keymap.c +++ b/keyboards/tokyokeyboard/alix40/keymaps/via/keymap.c @@ -22,26 +22,26 @@ along with this program. If not, see . const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [BL] = LAYOUT_40_alix( - KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_GRV, \ - KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \ - KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_ENT, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, \ + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_GRV, + KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_ENT, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_LCTL, KC_RALT, KC_LGUI,KC_NO, LT(1, KC_BSPC), LT(2, KC_SPC), KC_NO, KC_RGUI, KC_LBRC, KC_RBRC), [FN]= LAYOUT_40_alix( - KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_PIPE, \ - KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_SCLN, KC_QUOT, \ - KC_LSFT, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_ENT, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, KC_SLSH, \ + KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_PIPE, + KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_SCLN, KC_QUOT, + KC_LSFT, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_ENT, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, KC_SLSH, KC_LCTL, KC_RALT, KC_LGUI, KC_NO, LT(1, KC_BSPC), LT(2, KC_SPC), KC_NO, KC_RGUI, KC_UNDS, KC_PLUS), [2]= LAYOUT_40_alix( - KC_TILD, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSLS, \ - KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_SCLN, KC_QUOT, \ - KC_LSFT, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_ENT, KC_MNXT, KC_PGDN, KC_PGUP, KC_HOME, KC_END, \ + KC_TILD, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSLS, + KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_SCLN, KC_QUOT, + KC_LSFT, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_ENT, KC_MNXT, KC_PGDN, KC_PGUP, KC_HOME, KC_END, KC_LCTL, KC_RALT, KC_LGUI, KC_NO, LT(1, KC_BSPC), LT(2, KC_SPC), KC_NO, KC_RGUI, KC_MINS, KC_EQL), [3]= LAYOUT_40_alix( - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______), }; diff --git a/keyboards/tokyokeyboard/alix40/readme.md b/keyboards/tokyokeyboard/alix40/readme.md index cc1b5612b49d..b3db0c210700 100644 --- a/keyboards/tokyokeyboard/alix40/readme.md +++ b/keyboards/tokyokeyboard/alix40/readme.md @@ -4,9 +4,9 @@ ​ Minimal hacker style mechanical keyboard designed in Tokyo. Cherry MX compatible. More Info at [Tokyo Keyboard](http://tokyokeyboard.com). ​ -Keyboard Maintainer: [quadcube](https://github.com/quadcube) -Hardware Supported: alix40 rev1 -Hardware Availability: [Tokyo Keyboard](http://tokyokeyboard.com) +* Keyboard Maintainer: [quadcube](https://github.com/quadcube) +* Hardware Supported: alix40 rev1 +* Hardware Availability: [Tokyo Keyboard](http://tokyokeyboard.com) ​ Make example for this keyboard (after setting up your build environment): ​ diff --git a/keyboards/tokyokeyboard/alix40/rules.mk b/keyboards/tokyokeyboard/alix40/rules.mk index 07aee243e7fe..1b331ffb55a6 100644 --- a/keyboards/tokyokeyboard/alix40/rules.mk +++ b/keyboards/tokyokeyboard/alix40/rules.mk @@ -1,32 +1,32 @@ # MCU name MCU = atmega32u4 + +# Processor frequency F_CPU = 8000000 # Bootloader selection -# Teensy halfkay -# Pro Micro caterina -# Atmel DFU atmel-dfu -# LUFA DFU lufa-dfu -# QMK DFU qmk-dfu -# ATmega32A bootloadHID -# ATmega328P USBasp BOOTLOADER = atmel-dfu # Build Options # change yes to no to disable # -BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration -MOUSEKEY_ENABLE = no # Mouse keys +BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration +MOUSEKEY_ENABLE = no # Mouse keys EXTRAKEY_ENABLE = yes # Audio control and System control +CONSOLE_ENABLE = no # Console for debug +COMMAND_ENABLE = yes # Commands for debug and configuration # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -MIDI_ENABLE = no # MIDI controls -UNICODE_ENABLE = no # Unicode -BLUETOOTH = AdafruitBLE # Enable Bluetooth with the MDBT40 HID (AdafruitBLE) -AUDIO_ENABLE = no # Audio output on port C6 -CONSOLE_ENABLE = no # Console for debug -COMMAND_ENABLE = yes # Commands for debug and configuration -NKRO_ENABLE = no # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality -RGBLIGHT_ENABLE = yes # Enable RGB light +NKRO_ENABLE = no # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +RGBLIGHT_ENABLE = no # Enable RGB light +BLUETOOTH_ENABLE = no # Enable Bluetooth +AUDIO_ENABLE = no # Audio output +BLUETOOTH = AdafruitBLE + + + + + + From 7f6121e32c72675bdf1ab36f8a438da7b1023ed9 Mon Sep 17 00:00:00 2001 From: quadcube <13719009+quadcube@users.noreply.github.com> Date: Sat, 20 Feb 2021 16:35:26 +0800 Subject: [PATCH 19/21] Removed redundant code in alix40,c, clean up rules.mk --- keyboards/tokyokeyboard/alix40/alix40.c | 11 ----------- keyboards/tokyokeyboard/alix40/rules.mk | 10 ++-------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/keyboards/tokyokeyboard/alix40/alix40.c b/keyboards/tokyokeyboard/alix40/alix40.c index d03ab72551a7..af0f36119991 100644 --- a/keyboards/tokyokeyboard/alix40/alix40.c +++ b/keyboards/tokyokeyboard/alix40/alix40.c @@ -13,14 +13,3 @@ along with this program. If not, see . */ #include "alix40.h" - -void matrix_init_kb(void) { - // Keyboard start-up code goes here - // Runs once when the firmware starts up - matrix_init_user(); - led_init_ports(); -}; - -void led_init_ports(void) { - /* LEDs on */ -} diff --git a/keyboards/tokyokeyboard/alix40/rules.mk b/keyboards/tokyokeyboard/alix40/rules.mk index 1b331ffb55a6..66097b63e72a 100644 --- a/keyboards/tokyokeyboard/alix40/rules.mk +++ b/keyboards/tokyokeyboard/alix40/rules.mk @@ -18,15 +18,9 @@ COMMAND_ENABLE = yes # Commands for debug and configuration # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -NKRO_ENABLE = no # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +NKRO_ENABLE = no # USB Nkey Rollover BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality -RGBLIGHT_ENABLE = no # Enable RGB light +RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow BLUETOOTH_ENABLE = no # Enable Bluetooth AUDIO_ENABLE = no # Audio output BLUETOOTH = AdafruitBLE - - - - - - From 60161f10a0484088a682222c4d8ca4ae5963d827 Mon Sep 17 00:00:00 2001 From: James <13719009+quadcube@users.noreply.github.com> Date: Sat, 20 Feb 2021 18:12:48 +0800 Subject: [PATCH 20/21] Update keyboards/tokyokeyboard/alix40/config.h Co-authored-by: Ryan --- keyboards/tokyokeyboard/alix40/config.h | 1 - 1 file changed, 1 deletion(-) diff --git a/keyboards/tokyokeyboard/alix40/config.h b/keyboards/tokyokeyboard/alix40/config.h index f18c6c250bcb..593628d3cc74 100644 --- a/keyboards/tokyokeyboard/alix40/config.h +++ b/keyboards/tokyokeyboard/alix40/config.h @@ -32,7 +32,6 @@ along with this program. If not, see . #define BACKLIGHT_PIN B7 #ifdef BACKLIGHT_PIN #define BACKLIGHT_LEVELS 31 -#define BACKLIGHT_ON_STATE 1 #define BACKLIGHT_BREATHING #endif From a14dc81da4f8580c05d2e6a177d3dac08380cbab Mon Sep 17 00:00:00 2001 From: James <13719009+quadcube@users.noreply.github.com> Date: Sat, 20 Feb 2021 22:56:34 +0800 Subject: [PATCH 21/21] Remove description in config.h Co-authored-by: Drashna Jaelre --- keyboards/tokyokeyboard/alix40/config.h | 1 - 1 file changed, 1 deletion(-) diff --git a/keyboards/tokyokeyboard/alix40/config.h b/keyboards/tokyokeyboard/alix40/config.h index 593628d3cc74..ec6f98d5497a 100644 --- a/keyboards/tokyokeyboard/alix40/config.h +++ b/keyboards/tokyokeyboard/alix40/config.h @@ -22,7 +22,6 @@ along with this program. If not, see . #define DEVICE_VER 0x0001 #define MANUFACTURER quadcube #define PRODUCT alix40 -#define DESCRIPTION q.m.k. keyboard firmware for alix /* key matrix size */ #define MATRIX_ROWS 4