From 58a0c63dce053d2b096ef01f801aee84cb14236b Mon Sep 17 00:00:00 2001 From: Arthur <37627147+ArthurCyy@users.noreply.github.com> Date: Sun, 10 Sep 2023 20:28:21 +0800 Subject: [PATCH 1/7] Add MIIIW BlackIO83 --- keyboards/miiiw/blackio83/blackio83.c | 172 ++++++++++++++++++ keyboards/miiiw/blackio83/blackio83.h | 36 ++++ keyboards/miiiw/blackio83/config.h | 92 ++++++++++ keyboards/miiiw/blackio83/halconf.h | 33 ++++ keyboards/miiiw/blackio83/info.json | 112 ++++++++++++ .../miiiw/blackio83/keymaps/default/keymap.c | 71 ++++++++ .../miiiw/blackio83/keymaps/via/keymap.c | 145 +++++++++++++++ .../miiiw/blackio83/keymaps/via/rules.mk | 2 + keyboards/miiiw/blackio83/matrix.c | 139 ++++++++++++++ keyboards/miiiw/blackio83/mcuconf.h | 33 ++++ keyboards/miiiw/blackio83/readme.md | 27 +++ keyboards/miiiw/blackio83/rev_0100/config.h | 76 ++++++++ keyboards/miiiw/blackio83/rev_0100/rev_0100.c | 52 ++++++ keyboards/miiiw/blackio83/rev_0100/rules.mk | 29 +++ keyboards/miiiw/common/shift_register.c | 90 +++++++++ keyboards/miiiw/common/shift_register.h | 34 ++++ keyboards/miiiw/common/ws2812_custom.c | 142 +++++++++++++++ 17 files changed, 1285 insertions(+) create mode 100644 keyboards/miiiw/blackio83/blackio83.c create mode 100644 keyboards/miiiw/blackio83/blackio83.h create mode 100644 keyboards/miiiw/blackio83/config.h create mode 100644 keyboards/miiiw/blackio83/halconf.h create mode 100644 keyboards/miiiw/blackio83/info.json create mode 100644 keyboards/miiiw/blackio83/keymaps/default/keymap.c create mode 100644 keyboards/miiiw/blackio83/keymaps/via/keymap.c create mode 100644 keyboards/miiiw/blackio83/keymaps/via/rules.mk create mode 100644 keyboards/miiiw/blackio83/matrix.c create mode 100644 keyboards/miiiw/blackio83/mcuconf.h create mode 100644 keyboards/miiiw/blackio83/readme.md create mode 100644 keyboards/miiiw/blackio83/rev_0100/config.h create mode 100644 keyboards/miiiw/blackio83/rev_0100/rev_0100.c create mode 100644 keyboards/miiiw/blackio83/rev_0100/rules.mk create mode 100644 keyboards/miiiw/common/shift_register.c create mode 100644 keyboards/miiiw/common/shift_register.h create mode 100644 keyboards/miiiw/common/ws2812_custom.c diff --git a/keyboards/miiiw/blackio83/blackio83.c b/keyboards/miiiw/blackio83/blackio83.c new file mode 100644 index 000000000000..9912e8bc12b7 --- /dev/null +++ b/keyboards/miiiw/blackio83/blackio83.c @@ -0,0 +1,172 @@ +/* Copyright 2023 ArthurCyy + * + * 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 "blackio83.h" +#include "usb_main.h" +#include "usb_util.h" + +#define LOOP_10HZ_PERIOD 100 +deferred_token loop10hz_token = INVALID_DEFERRED_TOKEN; +uint32_t loop_10Hz(uint32_t trigger_time, void *cb_arg); + +static const SerialConfig mwproto_uart_config = { + .speed = MWPROTO_BITRATE, +}; + +static void POWER_EnterSleep(void) { + /* Clear Wake-up flag */ + PWR->CR |= PWR_CR_CWUF | PWR_CR_CSBF; + /* Select Sleep mode */ + /* PWR->CR |= PWR_CR_PDDS | PWR_CR_LPDS; */ + /* Set SLEEPDEEP bit of Cortex System Control Register */ + SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; + /* Request Wait For Interrupt */ + __WFI(); + /* Reset SLEEPDEEP bit of Cortex System Control Register */ + SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk; + NVIC_SystemReset(); +} + +extern void ws2812_poweron(void); +extern void ws2812_poweroff(void); + +void keyboard_pre_init_kb() { + keyboard_pre_init_user(); + + setPinInputLow(MWPROTO_STATUS_PIN); + setPinOutput(MWPROTO_WAKEUP_PIN); + writePinLow(MWPROTO_WAKEUP_PIN); + wait_ms(2); + writePinHigh(MWPROTO_WAKEUP_PIN); + + palSetLineMode(MWPROTO_TX_PIN, PAL_MODE_ALTERNATE(MWPROTO_TX_PAL_MODE) | PAL_OUTPUT_TYPE_OPENDRAIN); + sdStart(&MWPROTO_DRIVER, &mwproto_uart_config); +} + +void keyboard_post_init_kb(void) { + keyboard_post_init_user(); + + print(/* clang-format off */ + "\n<--QMK Keyboard-->\n" + "Vendor: " STR(MANUFACTURER) "(" STR(VENDOR_ID) ")\n" + "Product: " STR(PRODUCT) " (" STR(PRODUCT_ID) ")\n" + "Version: " STR(DEVICE_VER) "\n" + "BUILD: " __DATE__ "\n" + ); /* clang-format on */ + + writePinLow(MWPROTO_WAKEUP_PIN); + wait_ms(50); + sdPutI(&MWPROTO_DRIVER, 0xA5); + sdPutI(&MWPROTO_DRIVER, 0x12); + sdPutI(&MWPROTO_DRIVER, 0x01); + sdPutI(&MWPROTO_DRIVER, 0x02); + sdPutI(&MWPROTO_DRIVER, 0xB4); + writePinHigh(MWPROTO_WAKEUP_PIN); + + ws2812_poweron(); + loop10hz_token = defer_exec(LOOP_10HZ_PERIOD, loop_10Hz, NULL); +} + +void shutdown_user(void) { +#ifdef RGB_MATRIX_ENABLE + rgb_matrix_set_suspend_state(true); +#endif // RGB_MATRIX_ENABLE + wait_ms(10); + ws2812_poweroff(); +} + +#ifdef DIP_SWITCH_ENABLE +bool dip_switch_update_mask_kb(uint32_t state) { + if (!dip_switch_update_mask_user(state)) { return false; } + + if(state & 0x01) { + led_suspend(); + usbDisconnectBus(&USB_DRIVER); + usbStop(&USB_DRIVER); + shutdown_user(); + setPinInputHigh(POWER_SWITCH_PIN); + palEnableLineEvent(POWER_SWITCH_PIN, PAL_EVENT_MODE_RISING_EDGE); + POWER_EnterSleep(); + } + + return true; +} +#endif + +uint32_t loop_10Hz(uint32_t trigger_time, void *cb_arg) { + + if(last_input_activity_elapsed() > 1000) { + static uint32_t pmu_timer = 0; + if(timer_elapsed32(pmu_timer) > 3000) { + pmu_timer = timer_read32(); + writePinLow(MWPROTO_WAKEUP_PIN); + if(readPin(MWPROTO_STATUS_PIN)) + wait_us(500); + else + wait_us(1500); + sdPutI(&MWPROTO_DRIVER, 0xA5); + sdPutI(&MWPROTO_DRIVER, 0x28); + sdPutI(&MWPROTO_DRIVER, 0x00); + sdPutI(&MWPROTO_DRIVER, 0x8D); + writePinHigh(MWPROTO_WAKEUP_PIN); + } + } + + extern matrix_row_t matrix[MATRIX_ROWS]; + static uint32_t restore_tick = 0; + if(matrix[0] == 0x4000 && matrix[1] == 0 && + matrix[2] == 0 && matrix[3] == 0 && matrix[4] == 0 && matrix[5] == 0x201) { + if(restore_tick++ > 50) { + restore_tick = 0; + writePinLow(MWPROTO_WAKEUP_PIN); + if(readPin(MWPROTO_STATUS_PIN)) + wait_us(500); + else + wait_us(1500); + sdPutI(&MWPROTO_DRIVER, 0xA5); + sdPutI(&MWPROTO_DRIVER, 0x1F); + sdPutI(&MWPROTO_DRIVER, 0x01); + sdPutI(&MWPROTO_DRIVER, 0x0F); + sdPutI(&MWPROTO_DRIVER, 0xB4); + writePinHigh(MWPROTO_WAKEUP_PIN); + wait_ms(50); + eeconfig_init(); + #ifdef RGB_MATRIX_ENABLE + extern void rgb_matrix_update_pwm_buffers(void); + for(int i = 0; i < 5; i++) { + rgb_matrix_set_color_all(RGB_WHITE); + rgb_matrix_update_pwm_buffers(); + wait_ms(500); + rgb_matrix_set_color_all(RGB_OFF); + rgb_matrix_update_pwm_buffers(); + wait_ms(500); + } + #endif + wait_ms(500); + soft_reset_keyboard(); + } + } else { + restore_tick = 0; + } + + static uint32_t debug_tick = 0; + if (debug_tick++ > 9 ) { + dprintf("trigger %d\n", trigger_time); + debug_tick = 0; + } + + return LOOP_10HZ_PERIOD; +} diff --git a/keyboards/miiiw/blackio83/blackio83.h b/keyboards/miiiw/blackio83/blackio83.h new file mode 100644 index 000000000000..448bebc3be7d --- /dev/null +++ b/keyboards/miiiw/blackio83/blackio83.h @@ -0,0 +1,36 @@ +/* Copyright 2023 ArthurCyy + * + * 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" + +#define XXX KC_NO + +enum custom_keycodes { +#ifdef VIA_ENABLE + DEV_BT1 = SAFE_RANGE, +#endif + DEV_BT2, + DEV_BT3, + DEV_RF24, + ALT_TAB, + RGB_RST, + NEW_SAFE_RANGE +}; + +#undef SAFE_RANGE +#define SAFE_RANGE NEW_SAFE_RANGE diff --git a/keyboards/miiiw/blackio83/config.h b/keyboards/miiiw/blackio83/config.h new file mode 100644 index 000000000000..b8c9ec4b3d18 --- /dev/null +++ b/keyboards/miiiw/blackio83/config.h @@ -0,0 +1,92 @@ +/* Copyright 2023 ArthurCyy + * + * 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 + +/* key matrix size */ +#define MATRIX_ROWS 6 +#define MATRIX_COLS 16 + +// EEPROM i2c chip +#define EEPROM_I2C_24LC256 + +/* RGB Matrix */ +#ifdef RGB_MATRIX_ENABLE +# define RGB_MATRIX_KEYPRESSES // reacts to keypresses +# define RGB_MATRIX_FRAMEBUFFER_EFFECTS +# define RGB_MATRIX_LED_FLUSH_LIMIT 26 +//# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects +# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended +# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 160 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash. +# define RGB_MATRIX_HUE_STEP 36 +# define RGB_MATRIX_SAT_STEP 8 +# define RGB_MATRIX_VAL_STEP 32 +# define RGB_MATRIX_SPD_STEP 60 +# define RGB_MATRIX_DEFAULT_HUE 170 +# define RGB_MATRIX_DEFAULT_SPD (RGB_MATRIX_SPD_STEP + 15) + +/* Disable the animations you don't want/need. You will need to disable a good number of these * + * because they take up a lot of space. Disable until you can successfully compile your firmware. */ +// RGB Matrix Animation modes. Explicitly enabled +// For full list of effects, see: +// https://docs.qmk.fm/#/feature_rgb_matrix?id=rgb-matrix-effects +// # define ENABLE_RGB_MATRIX_ALPHAS_MODS +# define ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN +# define ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT +# define ENABLE_RGB_MATRIX_BREATHING +# define ENABLE_RGB_MATRIX_BAND_SAT +# define ENABLE_RGB_MATRIX_BAND_VAL +# define ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT +# define ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL +# define ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT +# define ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL +# define ENABLE_RGB_MATRIX_CYCLE_ALL +# define ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT +# define ENABLE_RGB_MATRIX_CYCLE_UP_DOWN +# define ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON +# define ENABLE_RGB_MATRIX_CYCLE_OUT_IN +# define ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL +# define ENABLE_RGB_MATRIX_CYCLE_PINWHEEL +# define ENABLE_RGB_MATRIX_CYCLE_SPIRAL +# define ENABLE_RGB_MATRIX_DUAL_BEACON +# define ENABLE_RGB_MATRIX_RAINBOW_BEACON +# define ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS +# define ENABLE_RGB_MATRIX_RAINDROPS +# define ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS +# define ENABLE_RGB_MATRIX_HUE_BREATHING +# define ENABLE_RGB_MATRIX_HUE_PENDULUM +# define ENABLE_RGB_MATRIX_HUE_WAVE +# define ENABLE_RGB_MATRIX_PIXEL_RAIN +# define ENABLE_RGB_MATRIX_PIXEL_FLOW +# define ENABLE_RGB_MATRIX_PIXEL_FRACTAL +// enabled only if RGB_MATRIX_FRAMEBUFFER_EFFECTS is defined +# define ENABLE_RGB_MATRIX_TYPING_HEATMAP +# define ENABLE_RGB_MATRIX_DIGITAL_RAIN +// enabled only of RGB_MATRIX_KEYPRESSES or RGB_MATRIX_KEYRELEASES is defined +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS +# define ENABLE_RGB_MATRIX_SPLASH +# define ENABLE_RGB_MATRIX_MULTISPLASH +# define ENABLE_RGB_MATRIX_SOLID_SPLASH +# define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH +#define RGB_MATRIX_DEFAULT_MODE RGB_MATRIX_SOLID_COLOR +#endif diff --git a/keyboards/miiiw/blackio83/halconf.h b/keyboards/miiiw/blackio83/halconf.h new file mode 100644 index 000000000000..627b861362be --- /dev/null +++ b/keyboards/miiiw/blackio83/halconf.h @@ -0,0 +1,33 @@ +/* Copyright 2020 QMK + * + * 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 . + */ + +/* + * This file was auto-generated by: + * `qmk chibios-confmigrate -i keyboards/geekboards/macropad_v2/halconf.h -r platforms/chibios/common/configs/halconf.h` + */ + +#pragma once + +#define HAL_USE_SERIAL TRUE + +#define HAL_USE_I2C TRUE + +// This enables interrupt-driven mode +#define PAL_USE_WAIT TRUE +#define USB_USE_WAIT TRUE + +#include_next + diff --git a/keyboards/miiiw/blackio83/info.json b/keyboards/miiiw/blackio83/info.json new file mode 100644 index 000000000000..9fde4d0eaf0e --- /dev/null +++ b/keyboards/miiiw/blackio83/info.json @@ -0,0 +1,112 @@ +{ + "keyboard_name": "MIIIW BlackIO 83", + "manufacturer": "MIIIW", + "url": "https://github.com/ArthurCyy", + "maintainer": "ArthurCyy", + "usb": { + "vid": "0x3044", + "pid": "0x83A1", + "device_version": "0.0.1", + "force_nkro": true + }, + "ws2812": { + "pin": "B15" + }, + "processor": "STM32F072", + "bootloader": "stm32-dfu", + "debounce": 3, + "layouts": { + "LAYOUT": { + "layout": [ + {"matrix": [0, 0], "x":0, "y":0}, + {"matrix": [0, 2], "x":1.25, "y":0}, + {"matrix": [0, 3], "x":2.25, "y":0}, + {"matrix": [0, 4], "x":3.25, "y":0}, + {"matrix": [0, 5], "x":4.25, "y":0}, + {"matrix": [0, 6], "x":5.5, "y":0}, + {"matrix": [0, 7], "x":6.5, "y":0}, + {"matrix": [0, 8], "x":7.5, "y":0}, + {"matrix": [0, 9], "x":8.5, "y":0}, + {"matrix": [0, 10], "x":9.75, "y":0}, + {"matrix": [0, 11], "x":10.75, "y":0}, + {"matrix": [0, 12], "x":11.75, "y":0}, + {"matrix": [0, 13], "x":12.75, "y":0}, + {"matrix": [0, 14], "x":14, "y":0}, + {"matrix": [0, 15], "x":15.25, "y":0}, + + {"matrix": [1, 0], "x":0, "y":1}, + {"matrix": [1, 1], "x":1, "y":1}, + {"matrix": [1, 2], "x":2, "y":1}, + {"matrix": [1, 3], "x":3, "y":1}, + {"matrix": [1, 4], "x":4, "y":1}, + {"matrix": [1, 5], "x":5, "y":1}, + {"matrix": [1, 6], "x":6, "y":1}, + {"matrix": [1, 7], "x":7, "y":1}, + {"matrix": [1, 8], "x":8, "y":1}, + {"matrix": [1, 9], "x":9, "y":1}, + {"matrix": [1, 10], "x":10, "y":1}, + {"matrix": [1, 11], "x":11, "y":1}, + {"matrix": [1, 12], "x":12, "y":1}, + {"matrix": [1, 13], "x":13, "y":1, "w":2}, + {"matrix": [1, 15], "x":15.25, "y":1}, + + {"matrix": [2, 0], "x":0, "y":2, "w":1.5}, + {"matrix": [2, 1], "x":1.5, "y":2}, + {"matrix": [2, 2], "x":2.5, "y":2}, + {"matrix": [2, 3], "x":3.5, "y":2}, + {"matrix": [2, 4], "x":4.5, "y":2}, + {"matrix": [2, 5], "x":5.5, "y":2}, + {"matrix": [2, 6], "x":6.5, "y":2}, + {"matrix": [2, 7], "x":7.5, "y":2}, + {"matrix": [2, 8], "x":8.5, "y":2}, + {"matrix": [2, 9], "x":9.5, "y":2}, + {"matrix": [2, 10], "x":10.5, "y":2}, + {"matrix": [2, 11], "x":11.5, "y":2}, + {"matrix": [2, 12], "x":12.5, "y":2}, + {"matrix": [2, 13], "x":13.5, "y":2, "w":1.5}, + {"matrix": [2, 15], "x":15.25, "y":2}, + + {"matrix": [3, 0], "x":0, "y":3, "w":1.75}, + {"matrix": [3, 1], "x":1.75, "y":3}, + {"matrix": [3, 2], "x":2.75, "y":3}, + {"matrix": [3, 3], "x":3.75, "y":3}, + {"matrix": [3, 4], "x":4.75, "y":3}, + {"matrix": [3, 5], "x":5.75, "y":3}, + {"matrix": [3, 6], "x":6.75, "y":3}, + {"matrix": [3, 7], "x":7.75, "y":3}, + {"matrix": [3, 8], "x":8.75, "y":3}, + {"matrix": [3, 9], "x":9.75, "y":3}, + {"matrix": [3, 10], "x":10.75, "y":3}, + {"matrix": [3, 11], "x":11.75, "y":3}, + {"matrix": [3, 12], "x":12.75, "y":3, "w":2.25}, + {"matrix": [3, 15], "x":15.25, "y":3}, + + {"matrix": [4, 0], "x":0, "y":4, "w":2.25}, + {"matrix": [4, 1], "x":2.25, "y":4}, + {"matrix": [4, 2], "x":3.25, "y":4}, + {"matrix": [4, 3], "x":4.25, "y":4}, + {"matrix": [4, 4], "x":5.25, "y":4}, + {"matrix": [4, 5], "x":6.25, "y":4}, + {"matrix": [4, 6], "x":7.25, "y":4}, + {"matrix": [4, 7], "x":8.25, "y":4}, + {"matrix": [4, 8], "x":9.25, "y":4}, + {"matrix": [4, 9], "x":10.25, "y":4}, + {"matrix": [4, 10], "x":11.25, "y":4}, + {"matrix": [4, 11], "x":12.25, "y":4, "w":1.75}, + {"matrix": [4, 13], "x":14.25, "y":4.5}, + {"matrix": [4, 15], "x":15.25, "y":4.25}, + + {"matrix": [5, 0], "x":0, "y":5, "w":1.25}, + {"matrix": [5, 1], "x":1.25, "y":5, "w":1.25}, + {"matrix": [5, 2], "x":2.5, "y":5, "w":1.25}, + {"matrix": [5, 5], "x":3.75, "y":5, "w":6.25}, + {"matrix": [5, 8], "x":10, "y":5}, + {"matrix": [5, 9], "x":11, "y":5}, + {"matrix": [5, 10], "x":12, "y":5}, + {"matrix": [5, 12], "x":13.25, "y":5.5}, + {"matrix": [5, 13], "x":14.25, "y":5.5}, + {"matrix": [5, 14], "x":15.25, "y":5.5} + ] + } + } +} diff --git a/keyboards/miiiw/blackio83/keymaps/default/keymap.c b/keyboards/miiiw/blackio83/keymaps/default/keymap.c new file mode 100644 index 000000000000..dc906f7e2c85 --- /dev/null +++ b/keyboards/miiiw/blackio83/keymaps/default/keymap.c @@ -0,0 +1,71 @@ +/* Copyright 2023 ArthurCyy + * + * 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 + +// Defines names for use in layer keycodes and the keymap +enum keymap_layers { + WIN_BL, + WIN_FL, + MAC_BL, + MAC_FL, +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Keymap WIN_BL: Win Base Layer (Default Layer) + */ + [WIN_BL] = LAYOUT( + KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, KC_PSCR, + KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_HOME, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_END, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGUP, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_PGDN, + KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(WIN_FL), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT + ), + + /* Keymap WIN_FL: Win Function Layer + */ + [WIN_FL] = LAYOUT( + RGB_RST, KC_BRID, KC_BRIU, ALT_TAB, G(KC_D), KC_WBAK, KC_WSCH, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, QK_BOOT, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_VAI, _______, + _______, _______, _______, _______, _______, _______, _______, RGB_RMOD, RGB_VAD, RGB_MOD + ), + + /* Keymap MAC_BL: Mac Base Layer + */ + [MAC_BL] = LAYOUT( + KC_ESC, KC_BRID, KC_BRIU,C(KC_UP),C(KC_DOWN),KC_F11,G(KC_SPC),KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, KC_DEL, KC_PSCR, + KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_HOME, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_END, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGUP, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_PGDN, + KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RGUI, MO(MAC_FL), KC_RALT, KC_LEFT, KC_DOWN, KC_RGHT + ), + + /* Keymap MAC_FL: Mac Function Layer + */ + [MAC_FL] = LAYOUT( + RGB_RST, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, QK_BOOT, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_VAI, _______, + _______, _______, _______, _______, _______, _______, _______, RGB_RMOD, RGB_VAD, RGB_MOD + ), +}; diff --git a/keyboards/miiiw/blackio83/keymaps/via/keymap.c b/keyboards/miiiw/blackio83/keymaps/via/keymap.c new file mode 100644 index 000000000000..70b79ef2af37 --- /dev/null +++ b/keyboards/miiiw/blackio83/keymaps/via/keymap.c @@ -0,0 +1,145 @@ +/* Copyright 2023 ArthurCyy + * + * 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 + +// Defines names for use in layer keycodes and the keymap +enum keymap_layers { + WIN_BL, + WIN_FL, + MAC_BL, + MAC_FL, +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Keymap WIN_BL: Win Base Layer (Default Layer) + */ + [WIN_BL] = LAYOUT( + KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, KC_PSCR, + KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_HOME, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_END, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGUP, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_PGDN, + KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(WIN_FL), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT + ), + + /* Keymap WIN_FL: Win Function Layer + */ + [WIN_FL] = LAYOUT( + RGB_RST, KC_BRID, KC_BRIU, ALT_TAB, G(KC_D), KC_WBAK, KC_WSCH, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, QK_BOOT, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_VAI, _______, + _______, _______, _______, _______, _______, _______, _______, RGB_RMOD, RGB_VAD, RGB_MOD + ), + + /* Keymap MAC_BL: Mac Base Layer + */ + [MAC_BL] = LAYOUT( + KC_ESC, KC_BRID, KC_BRIU,C(KC_UP),C(KC_DOWN),KC_F11,G(KC_SPC),KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, KC_DEL, KC_PSCR, + KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_HOME, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_END, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGUP, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_PGDN, + KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RGUI, MO(MAC_FL), KC_RALT, KC_LEFT, KC_DOWN, KC_RGHT + ), + + /* Keymap MAC_FL: Mac Function Layer + */ + [MAC_FL] = LAYOUT( + RGB_RST, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, QK_BOOT, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_VAI, _______, + _______, _______, _______, _______, _______, _______, _______, RGB_RMOD, RGB_VAD, RGB_MOD + ), +}; + +// Implement Super-alt↯tab +// See https://docs.qmk.fm/#/feature_macros?id=super-alt↯tab +static bool is_alt_tab_active = false; +static uint32_t alt_tab_timer = 0; + +#ifdef DIP_SWITCH_ENABLE +bool dip_switch_update_user(uint8_t index, bool active) { + switch (index) { + case 2: + default_layer_set(1UL << (active ? WIN_BL : MAC_BL)); + break; + } + return true; +} +#endif + +// Processing all the key pressed. +// Alt+tab. +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + uint8_t shift_mods = get_mods() & MOD_MASK_SHIFT; + switch (keycode) { // This will do most of the grunt work with the keycodes. + case ALT_TAB: + if (record->event.pressed) { + if (!is_alt_tab_active) { + is_alt_tab_active = true; + register_code(KC_LALT); + } + alt_tab_timer = timer_read32(); + register_code(KC_TAB); + } else { + unregister_code(KC_TAB); + } + return false; + case RGB_RST: + if (record->event.pressed) { + eeconfig_update_rgb_matrix_default(); + } + return false; + case RGB_VAI: + if(shift_mods) { + if (record->event.pressed) rgb_matrix_increase_speed(); + return false; + } + break; + case RGB_VAD: + if(shift_mods) { + if (record->event.pressed && rgb_matrix_get_speed() >= RGB_MATRIX_SPD_STEP) rgb_matrix_decrease_speed(); + return false; + } + break; + case RGB_MOD: + if(shift_mods) { + if (record->event.pressed) rgb_matrix_increase_hue(); + return false; + } + break; + case RGB_RMOD: + if(shift_mods) { + if (record->event.pressed) rgb_matrix_decrease_hue(); + return false; + } + break; + } + + return true; +} + +void matrix_scan_user(void) { // The very important timer. + if (is_alt_tab_active && timer_elapsed32(alt_tab_timer) > 750) { + unregister_code(KC_LALT); + is_alt_tab_active = false; + } +} diff --git a/keyboards/miiiw/blackio83/keymaps/via/rules.mk b/keyboards/miiiw/blackio83/keymaps/via/rules.mk new file mode 100644 index 000000000000..36b7ba9cbc98 --- /dev/null +++ b/keyboards/miiiw/blackio83/keymaps/via/rules.mk @@ -0,0 +1,2 @@ +VIA_ENABLE = yes +LTO_ENABLE = yes diff --git a/keyboards/miiiw/blackio83/matrix.c b/keyboards/miiiw/blackio83/matrix.c new file mode 100644 index 000000000000..841ff3c16e69 --- /dev/null +++ b/keyboards/miiiw/blackio83/matrix.c @@ -0,0 +1,139 @@ +/* Copyright 2023 ArthurCyy + * + * 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 "quantum.h" +#include "matrix.h" +#include "common/shift_register.h" + +static uint8_t read_rows(void); +static void init_cols(void); +static void select_col(uint8_t col); +static void unselect_col(uint8_t col); +static void unselect_cols(void); + +static const pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; +static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; + +#ifdef DIP_SWITCH_PINS +# define NUMBER_OF_DIP_SWITCHES (sizeof(dip_switch_pad) / sizeof(pin_t)) +static pin_t dip_switch_pad[] = DIP_SWITCH_PINS; +#endif + +void matrix_init_custom(void) { + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { + setPinInputLow(row_pins[row]); + } + + shift_init(); + init_cols(); +} + +bool matrix_scan_custom(matrix_row_t current_matrix[]) { + bool changed = false; + + for (uint8_t col = 0; col < MATRIX_COLS; col++) { + select_col(col); + waitInputPinDelay(); + uint8_t rows = read_rows(); + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { + bool prev_bit = ((uint32_t)(current_matrix[row]) & (matrix_row_t)(1UL << col)) ? 1 : 0; + bool curr_bit = ((uint32_t)rows & (uint32_t)(1UL << row)) ? 1 : 0; + if (prev_bit != curr_bit) { + current_matrix[row] = (uint32_t)(current_matrix[row]) ^ (uint32_t)(1UL << col); + changed = true; + } + } + unselect_col(col); + } + + return changed; +} + +void matrix_power_up(void) { + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { + palDisableLineEvent(row_pins[row]); + setPinInputLow(row_pins[row]); + } + init_cols(); +#ifdef DIP_SWITCH_PINS + for (uint8_t i = 1; i < NUMBER_OF_DIP_SWITCHES; i++) { + setPinInputHigh(dip_switch_pad[i]); + } +#endif +} + +void matrix_power_down(void) { + unselect_cols(); + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { + setPinInputLow(row_pins[row]); + palEnableLineEvent(row_pins[row], PAL_EVENT_MODE_RISING_EDGE); + } +#ifdef DIP_SWITCH_PINS + for (uint8_t i = 1; i < NUMBER_OF_DIP_SWITCHES; i++) { + setPinInputLow(dip_switch_pad[i]); + } +#endif +} + +static uint8_t read_rows(void) { + uint8_t row_value = 0; + for(uint8_t row = 0; row < MATRIX_ROWS; row++) { + row_value |= (readPin(row_pins[row]) << row); + } + return row_value; +} + +static void init_cols(void) { + shift_writeAll(0); + for(uint8_t col = 0; col < MATRIX_COLS; col++) { + if(col_pins[col] < H0) { + setPinOutput(col_pins[col]); + writePinLow(col_pins[col]); + } + } +} + +static void select_col(uint8_t col) { + if(col_pins[col] < H0){ + writePinHigh(col_pins[col]); + waitInputPinDelay(); + waitInputPinDelay(); + waitInputPinDelay(); + waitInputPinDelay(); + waitInputPinDelay(); + waitInputPinDelay(); + }else{ + shift_writePin(col_pins[col], 1); + } +} + +static void unselect_col(uint8_t col) { + if(col_pins[col] < H0){ + writePinLow(col_pins[col]); + }else{ + shift_writePin(col_pins[col], 0); + } +} + +static void unselect_cols(void) { + shift_writeAll(1); + for(uint8_t col = 0; col < MATRIX_COLS; col++) { + if(col_pins[col] < H0) { + setPinOutput(col_pins[col]); + writePinHigh(col_pins[col]); + } + } +} diff --git a/keyboards/miiiw/blackio83/mcuconf.h b/keyboards/miiiw/blackio83/mcuconf.h new file mode 100644 index 000000000000..89038eba8251 --- /dev/null +++ b/keyboards/miiiw/blackio83/mcuconf.h @@ -0,0 +1,33 @@ +/* Copyright 2020 QMK + * + * 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 . + */ + +/* + * This file was auto-generated by: + * `qmk chibios-confmigrate -i keyboards/geekboards/macropad_v2/mcuconf.h -r platforms/chibios/GENERIC_STM32_F072XB/configs/mcuconf.h` + */ + +#pragma once + +#include_next + +#undef STM32_SERIAL_USE_USART1 +#define STM32_SERIAL_USE_USART1 TRUE + +#undef STM32_I2C_USE_I2C1 +#define STM32_I2C_USE_I2C1 TRUE + +#undef STM32_I2C_USE_DMA +#define STM32_I2C_USE_DMA FALSE diff --git a/keyboards/miiiw/blackio83/readme.md b/keyboards/miiiw/blackio83/readme.md new file mode 100644 index 000000000000..c410eac654dc --- /dev/null +++ b/keyboards/miiiw/blackio83/readme.md @@ -0,0 +1,27 @@ +# MIIIW BlackIO83 + +![BlackIO83](https://i.imgur.com/jZ7HrTCh.jpg) +![BlackIO83](https://i.imgur.com/AnlUIfph.jpg) + +A customizable 75% keyboard. + +* Keyboard Maintainer: [ArthurCyy](https://github.com/ArthurCyy) +* Hardware Supported: BlackIO83 rev_0100 +* Hardware Availability: [MIIIW](https://www.miiiw.com/) + +Make example for this keyboard (after setting up your build environment): + + make miiiw/blackio83/rev_0100:default + +Flashing example for this keyboard: + + make miiiw/blackio83/rev_0100:default:flash + +See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). + +## Bootloader + +Enter the bootloader: + +* (Official firmware only) Press and hold the left shift+ Fn+ upper right DEL. +* (Unofficial firmware) Press the key mapped to `QK_BOOT`. diff --git a/keyboards/miiiw/blackio83/rev_0100/config.h b/keyboards/miiiw/blackio83/rev_0100/config.h new file mode 100644 index 000000000000..e66879e41fe1 --- /dev/null +++ b/keyboards/miiiw/blackio83/rev_0100/config.h @@ -0,0 +1,76 @@ +/* Copyright 2023 ArthurCyy + * + * 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 + +/* + * Keyboard Matrix Assignments + * + * Change this to how you wired your keyboard + * COLS: AVR pins used for columns, left to right + * ROWS: AVR pins used for rows, top to bottom + * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode) + * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) + * + */ +#define MATRIX_ROW_PINS { A7, A6, A5, A4, A3, A2 } +#define MATRIX_COL_PINS { H0, H1, H2, H3, H4, H5, H6, H7, H8, H9, H10, H11, H12, H13, H14, H15 } + +/* Dip Switch */ +#define POWER_SWITCH_PIN B0 +#define DIP_SWITCH_PINS { POWER_SWITCH_PIN, B1, B8, B12 } + +/* LED indicator lights */ +#define LED_CAPS_LOCK_PIN B2 +#define LED_NUM_LOCK_PIN B14 + +/* 16 with dummy columns for shift registers */ +#define SHR_SERIES_NUM 2 +#define SHR_CLOCK_PIN A0 +#define SHR_DATA_PIN A1 +#define SHR_LATCH_PIN C15 + +/* MIIIW Protocol Driver */ +#define MWPROTO_BITRATE 256000 +#define MWPROTO_DRIVER SD1 +#define MWPROTO_TX_PIN A9 +#define MWPROTO_TX_PAL_MODE 1 +#define MWPROTO_RX_PIN A10 +#define MWPROTO_RX_PAL_MODE 1 +#define MWPROTO_WAKEUP_PIN A15 +#define MWPROTO_STATUS_PIN C13 + +/* RGB Matrix config */ +#define RGB_EN_PIN A8 +#define RGBLED_NUM 83 +#define RGB_MATRIX_LED_COUNT RGBLED_NUM +#define RGB_MATRIX_CENTER { 62, 42 } + +// PWM RGB Underglow Defines +#define WS2812_BYTE_ORDER WS2812_BYTE_ORDER_GRB +#define WS2812_TRST_US 200 + +// I2C config +#define I2C_DRIVER I2CD1 +#define I2C1_SCL_PIN B6 +#define I2C1_SDA_PIN B7 +#define I2C1_SCL_PAL_MODE 1 +#define I2C1_SDA_PAL_MODE 1 +#define I2C1_TIMINGR_PRESC 0x00U +#define I2C1_TIMINGR_SCLDEL 0x03U +#define I2C1_TIMINGR_SDADEL 0x01U +#define I2C1_TIMINGR_SCLH 0x03U +#define I2C1_TIMINGR_SCLL 0x09U diff --git a/keyboards/miiiw/blackio83/rev_0100/rev_0100.c b/keyboards/miiiw/blackio83/rev_0100/rev_0100.c new file mode 100644 index 000000000000..52ec8618e043 --- /dev/null +++ b/keyboards/miiiw/blackio83/rev_0100/rev_0100.c @@ -0,0 +1,52 @@ +/* Copyright 2023 ArthurCyy + * + * 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 "blackio83.h" + +#ifdef RGB_MATRIX_ENABLE + +/* Leds on the CU80 go ltr > rtl > ltr > rlt > Ltr > rtl */ +led_config_t g_led_config = { + { /* C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 C14 C15 */ +/*R0*/ { 0, NO_LED, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }, +/*R1*/ { 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, NO_LED, 15 }, +/*R2*/ { 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, NO_LED, 44 }, +/*R3*/ { 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, NO_LED, NO_LED, 45 }, +/*R4*/ { 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, NO_LED, 71, NO_LED, 72 }, +/*R5*/ { 82, 81, 80, NO_LED, NO_LED, 79, NO_LED, NO_LED, 78, 77, 76, NO_LED, 75, 74, 73, NO_LED }, + }, + /*board layout accounting for led directions */ + { { 0, 0}, {10, 0}, {18, 0}, {26, 0}, {34, 0}, {44, 0}, {52, 0}, {60, 0}, {68, 0}, {78, 0}, {86, 0}, {94, 0}, {102, 0}, {112, 0}, {124, 0}, + // { 0, 20}, { 8, 20}, {16, 20}, {24, 20}, {32, 20}, {40, 20}, {48, 20}, {56, 20}, {64, 20}, {72, 20}, {80, 20}, {88, 20}, {96, 20}, {108,20}, {124,20}, + {124,20}, {108,20}, {96, 20}, {88, 20}, {80, 20}, {72, 20}, {64, 20}, {56, 20}, {48, 20}, {40, 20}, {32, 20}, {24, 20}, {16, 20}, { 8, 20}, { 0, 20}, + { 2, 36}, {12, 36}, {20, 36}, {28, 36}, {36, 36}, {44, 36}, {52, 36}, {60, 36}, {68, 36}, {76, 36}, {84, 36}, {92, 36}, {100,36}, {110,36}, {124,36}, + // { 3, 52}, {14, 52}, {22, 52}, {30, 52}, {38, 52}, {46, 52}, {54, 52}, {62, 52}, {70, 52}, {78, 52}, {86, 52}, {94, 52}, {107, 52}, {124,52}, + {124,52}, {107, 52}, {94, 52}, {86, 52}, {78, 52}, {70, 52}, {62, 52}, {54, 52}, {46, 52}, {38, 52}, {30, 52}, {22, 52}, {14, 52}, { 3, 52}, + { 5, 68}, {18, 68}, {26, 68}, {34, 68}, {42, 68}, {50, 68}, {58, 68}, {66, 68}, {74, 68}, {82, 68}, {90, 68}, {104,68}, {114,72}, {124,68}, + // { 1, 84}, {10, 84}, {20, 84}, {50, 84}, {80, 84}, {88, 84}, {96, 84}, {106,88}, {114,88}, {122,88}, + {122,88}, {114,88}, {106,88}, {96, 84}, {88, 84}, {80, 84}, {50, 84}, {20, 84}, {10, 84}, { 1, 84}, + }, + /* marks scroll and caps as function modifiers for led effects */ + { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, //15 + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, //15 + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, //15 + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, //14 + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, //14 + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, //10 + } +}; + +#endif diff --git a/keyboards/miiiw/blackio83/rev_0100/rules.mk b/keyboards/miiiw/blackio83/rev_0100/rules.mk new file mode 100644 index 000000000000..2259066769c4 --- /dev/null +++ b/keyboards/miiiw/blackio83/rev_0100/rules.mk @@ -0,0 +1,29 @@ +# Build Options +# change yes to no to disable +# +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite +MOUSEKEY_ENABLE = yes # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +CONSOLE_ENABLE = no # Console for debug +COMMAND_ENABLE = no # Commands for debug and configuration +NKRO_ENABLE = yes # Enable N-Key Rollover +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow +RGB_MATRIX_ENABLE = yes +RGB_MATRIX_DRIVER = custom +DIP_SWITCH_ENABLE = yes # Enable dip switches +DEBOUNCE_TYPE = sym_defer_pk # Debounce using eager_pk. +CUSTOM_MATRIX = lite +DEFERRED_EXEC_ENABLE = yes +NO_USB_STARTUP_CHECK = yes +# EEPROM_DRIVER = i2c + +# Enter lower-power sleep mode when on the ChibiOS idle thread +OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE + +OPT_DEFS += -DWS2812 + +# Project specific files +SRC += matrix.c \ + common/shift_register.c \ + common/ws2812_custom.c diff --git a/keyboards/miiiw/common/shift_register.c b/keyboards/miiiw/common/shift_register.c new file mode 100644 index 000000000000..1f21c1246836 --- /dev/null +++ b/keyboards/miiiw/common/shift_register.c @@ -0,0 +1,90 @@ +/* Copyright 2023 ArthurCyy + * + * 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 "quantum.h" +#include "shift_register.h" + +static void shift_out(void); + +static uint8_t shift_values[SHR_SERIES_NUM] = {0}; + +void shift_init(void) { +#ifdef SHR_OE_PIN + setPinOutput(SHR_OE_PIN); + writePinHigh(SHR_OE_PIN); +#endif + setPinOutput(SHR_DATA_PIN); + setPinOutput(SHR_LATCH_PIN); + setPinOutput(SHR_CLOCK_PIN); +} + +void shift_enable(void) { +#ifdef SHR_OE_PIN + writePinLow(SHR_OE_PIN); +#endif + writePinLow(SHR_DATA_PIN); + writePinLow(SHR_LATCH_PIN); + writePinLow(SHR_CLOCK_PIN); +} + +void shift_disable(void) { +#ifdef SHR_OE_PIN + writePinHigh(SHR_OE_PIN); +#endif + writePinLow(SHR_DATA_PIN); + writePinLow(SHR_LATCH_PIN); + writePinLow(SHR_CLOCK_PIN); +} + +void shift_writePin(pin_t pin, int level) { + uint8_t group = (pin - H0) >> 3; + uint8_t bit = 0x01 << ((pin - H0)&0x07); + + if(group >= SHR_SERIES_NUM) + return; + + if(level) + shift_values[group] |= bit; + else + shift_values[group] &= ~bit; + shift_out(); +} + +void shift_writeGroup(int group, uint8_t value) { + if(group >= SHR_SERIES_NUM) + return; + + shift_values[group] = value; + shift_out(); +} + +void shift_writeAll(int level) { + memset(shift_values, level ? 0xFF : 0, sizeof(shift_values)); + shift_out(); +} + +static void shift_out(void) { + uint8_t n = SHR_SERIES_NUM; + writePinLow(SHR_LATCH_PIN); + while(n--){ + for (uint8_t i = 0; i < 8; i++) { + writePinLow(SHR_CLOCK_PIN); + writePin(SHR_DATA_PIN, shift_values[n] & (0x80 >> i)); + writePinHigh(SHR_CLOCK_PIN); + } + } + writePinHigh(SHR_LATCH_PIN); +} diff --git a/keyboards/miiiw/common/shift_register.h b/keyboards/miiiw/common/shift_register.h new file mode 100644 index 000000000000..f9895e63f827 --- /dev/null +++ b/keyboards/miiiw/common/shift_register.h @@ -0,0 +1,34 @@ +/* Copyright 2023 ArthurCyy + * + * 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 "gpio.h" + +#ifndef GPIOH_BASE +# define GPIOH_BASE (0xFF595A00U) +#endif + +#ifndef SHR_SERIES_NUM +# define SHR_SERIES_NUM 1 +#endif + +extern void shift_init(void); +extern void shift_enable(void); +extern void shift_disable(void); +extern void shift_writePin(pin_t pin, int level); +extern void shift_writeGroup(int group, uint8_t value); +extern void shift_writeAll(int level); diff --git a/keyboards/miiiw/common/ws2812_custom.c b/keyboards/miiiw/common/ws2812_custom.c new file mode 100644 index 000000000000..d5a6a94327b0 --- /dev/null +++ b/keyboards/miiiw/common/ws2812_custom.c @@ -0,0 +1,142 @@ +/* Copyright 2023 ArthurCyy + * + * 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 "quantum.h" +#include "ws2812.h" +#include +#include + +/* Adapted from https://github.com/bigjosh/SimpleNeoPixelDemo/ */ + +#ifndef NOP_FUDGE +# if defined(STM32F0XX) || defined(STM32F1XX) || defined(GD32VF103) || defined(STM32F3XX) || defined(STM32F4XX) || defined(STM32L0XX) +# define NOP_FUDGE 0.4 +# else +# error("NOP_FUDGE configuration required") +# define NOP_FUDGE 1 // this just pleases the compile so the above error is easier to spot +# endif +#endif + +// Push Pull or Open Drain Configuration +// Default Push Pull +#ifndef WS2812_EXTERNAL_PULLUP +# define WS2812_OUTPUT_MODE PAL_MODE_OUTPUT_PUSHPULL +#else +# define WS2812_OUTPUT_MODE PAL_MODE_OUTPUT_OPENDRAIN +#endif + +// The reset gap can be 6000 ns, but depending on the LED strip it may have to be increased +// to values like 600000 ns. If it is too small, the pixels will show nothing most of the time. +#ifndef WS2812_RES +# define WS2812_RES (1000 * WS2812_TRST_US) // Width of the low gap between bits to cause a frame to latch +#endif + +#define NUMBER_NOPS 6 +#define CYCLES_PER_SEC (CPU_CLOCK / NUMBER_NOPS * NOP_FUDGE) +#define NS_PER_SEC (1000000000L) // Note that this has to be SIGNED since we want to be able to check for negative values of derivatives +#define NS_PER_CYCLE (NS_PER_SEC / CYCLES_PER_SEC) +#define NS_TO_CYCLES(n) ((n) / NS_PER_CYCLE) + +#define wait_ns(x) \ + do { \ + for (int i = 0; i < NS_TO_CYCLES(x); i++) { \ + __asm__ volatile("nop\n\t" \ + "nop\n\t" \ + "nop\n\t" \ + "nop\n\t" \ + "nop\n\t" \ + "nop\n\t"); \ + } \ + } while (0) + +static void sendByte(uint8_t byte) { + // WS2812 protocol wants most significant bits first + for (unsigned char bit = 0; bit < 8; bit++) { + // using something like wait_ns(is_one ? T1L : T0L) here throws off timings + if (byte & (0x80 >> bit)) { + // 1 + writePinHigh(WS2812_DI_PIN); + wait_ns(WS2812_T1H); + writePinLow(WS2812_DI_PIN); + wait_ns(WS2812_T1L); + } else { + // 0 + writePinHigh(WS2812_DI_PIN); + wait_ns(WS2812_T0H); + writePinLow(WS2812_DI_PIN); + wait_ns(WS2812_T0L); + } + } +} + +void ws2812_init(void) { + palSetLineMode(WS2812_DI_PIN, WS2812_OUTPUT_MODE); +} + +static bool p_setup = false; +static bool s_init = false; +void ws2812_poweron(void) { + if(p_setup) return; + p_setup = true; + s_init = false; + setPinOutput(RGB_EN_PIN); + writePinHigh(RGB_EN_PIN); +} + +void ws2812_poweroff(void) { + if(!p_setup) return; + p_setup = false; + setPinInputLow(WS2812_DI_PIN); + writePinLow(RGB_EN_PIN); +} + +// Setleds for standard RGB +void ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) { + if(!p_setup) return; + + if (!s_init) { + ws2812_init(); + s_init = true; + } + + // this code is very time dependent, so we need to disable interrupts + chSysLock(); + + for (uint8_t i = 0; i < leds; i++) { + // WS2812 protocol dictates grb order +#if (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_GRB) + sendByte(ledarray[i].g); + sendByte(ledarray[i].r); + sendByte(ledarray[i].b); +#elif (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_RGB) + sendByte(ledarray[i].r); + sendByte(ledarray[i].g); + sendByte(ledarray[i].b); +#elif (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_BGR) + sendByte(ledarray[i].b); + sendByte(ledarray[i].g); + sendByte(ledarray[i].r); +#endif + +#ifdef RGBW + sendByte(ledarray[i].w); +#endif + } + + wait_ns(WS2812_RES); + + chSysUnlock(); +} From 6b7030efcb0cdb2c6fe547558b8465ebd405f7fd Mon Sep 17 00:00:00 2001 From: Arthur <37627147+ArthurCyy@users.noreply.github.com> Date: Wed, 20 Sep 2023 11:49:19 +0800 Subject: [PATCH 2/7] Improve the code --- keyboards/miiiw/blackio83/blackio83.c | 19 +- keyboards/miiiw/blackio83/blackio83.h | 10 +- keyboards/miiiw/blackio83/config.h | 32 -- keyboards/miiiw/blackio83/halconf.h | 1 - keyboards/miiiw/blackio83/info.json | 308 ++++++++++++------ .../miiiw/blackio83/keymaps/via/keymap.c | 74 ----- keyboards/miiiw/blackio83/rev_0100/config.h | 6 - keyboards/miiiw/blackio83/rev_0100/rev_0100.c | 35 -- keyboards/miiiw/blackio83/rev_0100/rules.mk | 26 +- keyboards/miiiw/common/ws2812_custom.c | 142 -------- 10 files changed, 228 insertions(+), 425 deletions(-) delete mode 100644 keyboards/miiiw/common/ws2812_custom.c diff --git a/keyboards/miiiw/blackio83/blackio83.c b/keyboards/miiiw/blackio83/blackio83.c index 9912e8bc12b7..0d8412624e2d 100644 --- a/keyboards/miiiw/blackio83/blackio83.c +++ b/keyboards/miiiw/blackio83/blackio83.c @@ -43,6 +43,23 @@ static void POWER_EnterSleep(void) { extern void ws2812_poweron(void); extern void ws2812_poweroff(void); +static bool p_setup = false; +static bool s_init = false; +void ws2812_poweron(void) { + if(p_setup) return; + p_setup = true; + s_init = false; + setPinOutput(RGB_EN_PIN); + writePinHigh(RGB_EN_PIN); +} + +void ws2812_poweroff(void) { + if(!p_setup) return; + p_setup = false; + setPinInputLow(WS2812_DI_PIN); + writePinLow(RGB_EN_PIN); +} + void keyboard_pre_init_kb() { keyboard_pre_init_user(); @@ -80,7 +97,7 @@ void keyboard_post_init_kb(void) { loop10hz_token = defer_exec(LOOP_10HZ_PERIOD, loop_10Hz, NULL); } -void shutdown_user(void) { +__attribute__((weak)) void shutdown_user(void) { #ifdef RGB_MATRIX_ENABLE rgb_matrix_set_suspend_state(true); #endif // RGB_MATRIX_ENABLE diff --git a/keyboards/miiiw/blackio83/blackio83.h b/keyboards/miiiw/blackio83/blackio83.h index 448bebc3be7d..ea371443e30e 100644 --- a/keyboards/miiiw/blackio83/blackio83.h +++ b/keyboards/miiiw/blackio83/blackio83.h @@ -21,16 +21,10 @@ #define XXX KC_NO enum custom_keycodes { -#ifdef VIA_ENABLE - DEV_BT1 = SAFE_RANGE, -#endif + DEV_BT1 = QK_KB, DEV_BT2, DEV_BT3, DEV_RF24, ALT_TAB, RGB_RST, - NEW_SAFE_RANGE -}; - -#undef SAFE_RANGE -#define SAFE_RANGE NEW_SAFE_RANGE +}; \ No newline at end of file diff --git a/keyboards/miiiw/blackio83/config.h b/keyboards/miiiw/blackio83/config.h index b8c9ec4b3d18..b9a699e137e0 100644 --- a/keyboards/miiiw/blackio83/config.h +++ b/keyboards/miiiw/blackio83/config.h @@ -23,21 +23,6 @@ // EEPROM i2c chip #define EEPROM_I2C_24LC256 -/* RGB Matrix */ -#ifdef RGB_MATRIX_ENABLE -# define RGB_MATRIX_KEYPRESSES // reacts to keypresses -# define RGB_MATRIX_FRAMEBUFFER_EFFECTS -# define RGB_MATRIX_LED_FLUSH_LIMIT 26 -//# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects -# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended -# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 160 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash. -# define RGB_MATRIX_HUE_STEP 36 -# define RGB_MATRIX_SAT_STEP 8 -# define RGB_MATRIX_VAL_STEP 32 -# define RGB_MATRIX_SPD_STEP 60 -# define RGB_MATRIX_DEFAULT_HUE 170 -# define RGB_MATRIX_DEFAULT_SPD (RGB_MATRIX_SPD_STEP + 15) - /* Disable the animations you don't want/need. You will need to disable a good number of these * * because they take up a lot of space. Disable until you can successfully compile your firmware. */ // RGB Matrix Animation modes. Explicitly enabled @@ -72,21 +57,4 @@ # define ENABLE_RGB_MATRIX_PIXEL_RAIN # define ENABLE_RGB_MATRIX_PIXEL_FLOW # define ENABLE_RGB_MATRIX_PIXEL_FRACTAL -// enabled only if RGB_MATRIX_FRAMEBUFFER_EFFECTS is defined -# define ENABLE_RGB_MATRIX_TYPING_HEATMAP -# define ENABLE_RGB_MATRIX_DIGITAL_RAIN -// enabled only of RGB_MATRIX_KEYPRESSES or RGB_MATRIX_KEYRELEASES is defined -# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE -# define ENABLE_RGB_MATRIX_SOLID_REACTIVE -# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE -# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE -# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS -# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS -# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS -# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS -# define ENABLE_RGB_MATRIX_SPLASH -# define ENABLE_RGB_MATRIX_MULTISPLASH -# define ENABLE_RGB_MATRIX_SOLID_SPLASH -# define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH #define RGB_MATRIX_DEFAULT_MODE RGB_MATRIX_SOLID_COLOR -#endif diff --git a/keyboards/miiiw/blackio83/halconf.h b/keyboards/miiiw/blackio83/halconf.h index 627b861362be..037108a3923b 100644 --- a/keyboards/miiiw/blackio83/halconf.h +++ b/keyboards/miiiw/blackio83/halconf.h @@ -30,4 +30,3 @@ #define USB_USE_WAIT TRUE #include_next - diff --git a/keyboards/miiiw/blackio83/info.json b/keyboards/miiiw/blackio83/info.json index 9fde4d0eaf0e..40fc6b7d8937 100644 --- a/keyboards/miiiw/blackio83/info.json +++ b/keyboards/miiiw/blackio83/info.json @@ -1,112 +1,216 @@ { - "keyboard_name": "MIIIW BlackIO 83", - "manufacturer": "MIIIW", - "url": "https://github.com/ArthurCyy", - "maintainer": "ArthurCyy", + "manufacturer": "MIIIW", + "keyboard_name": "MIIIW BlackIO 83", + "maintainer": "ArthurCyy", + "bootloader": "stm32-dfu", + "debounce": 3, + "diode_direction": "COL2ROW", + "features": { + "backlight": false, + "bootmagic": true, + "command": false, + "console": false, + "deferred_exec": true, + "dip_switch": true, + "extrakey": true, + "mousekey": true, + "nkro": true, + "rgb_matrix": true, + "rgblight": false + }, + "indicators": { + "caps_lock": "B2", + "num_lock": "B14" + }, + "matrix_pins": { + "cols": ["H0", "H1", "H2", "H3", "H4", "H5", "H6", "H7", "H8", "H9", "H10", "H11", "H12", "H13", "H14", "H15"], + "rows": ["A7", "A6", "A5", "A4", "A3", "A2"] + }, + "processor": "STM32F072", + "rgb_matrix": { + "driver": "ws2812", + "layout": [ + {"matrix": [0, 0], "x": 0, "y": 0, "flags": 4}, + {"matrix": [0, 2], "x": 10, "y": 0, "flags": 4}, + {"matrix": [0, 3], "x": 18, "y": 0, "flags": 4}, + {"matrix": [0, 4], "x": 26, "y": 0, "flags": 4}, + {"matrix": [0, 5], "x": 34, "y": 0, "flags": 4}, + {"matrix": [0, 6], "x": 44, "y": 0, "flags": 4}, + {"matrix": [0, 7], "x": 52, "y": 0, "flags": 4}, + {"matrix": [0, 8], "x": 60, "y": 0, "flags": 4}, + {"matrix": [0, 9], "x": 68, "y": 0, "flags": 4}, + {"matrix": [0, 10], "x": 78, "y": 0, "flags": 4}, + {"matrix": [0, 11], "x": 86, "y": 0, "flags": 4}, + {"matrix": [0, 12], "x": 94, "y": 0, "flags": 4}, + {"matrix": [0, 13], "x": 102, "y": 0, "flags": 4}, + {"matrix": [0, 14], "x": 112, "y": 0, "flags": 4}, + {"matrix": [0, 15], "x": 124, "y": 0, "flags": 4}, + {"matrix": [1, 0], "x": 124, "y": 20, "flags": 4}, + {"matrix": [1, 1], "x": 108, "y": 20, "flags": 4}, + {"matrix": [1, 2], "x": 96, "y": 20, "flags": 4}, + {"matrix": [1, 3], "x": 88, "y": 20, "flags": 4}, + {"matrix": [1, 4], "x": 80, "y": 20, "flags": 4}, + {"matrix": [1, 5], "x": 72, "y": 20, "flags": 4}, + {"matrix": [1, 6], "x": 64, "y": 20, "flags": 4}, + {"matrix": [1, 7], "x": 56, "y": 20, "flags": 4}, + {"matrix": [1, 8], "x": 48, "y": 20, "flags": 4}, + {"matrix": [1, 9], "x": 40, "y": 20, "flags": 4}, + {"matrix": [1, 10], "x": 32, "y": 20, "flags": 4}, + {"matrix": [1, 11], "x": 24, "y": 20, "flags": 4}, + {"matrix": [1, 12], "x": 16, "y": 20, "flags": 4}, + {"matrix": [1, 13], "x": 8, "y": 20, "flags": 4}, + {"matrix": [1, 15], "x": 0, "y": 20, "flags": 4}, + {"matrix": [2, 0], "x": 2, "y": 36, "flags": 4}, + {"matrix": [2, 1], "x": 12, "y": 36, "flags": 4}, + {"matrix": [2, 2], "x": 20, "y": 36, "flags": 4}, + {"matrix": [2, 3], "x": 28, "y": 36, "flags": 4}, + {"matrix": [2, 4], "x": 36, "y": 36, "flags": 4}, + {"matrix": [2, 5], "x": 44, "y": 36, "flags": 4}, + {"matrix": [2, 6], "x": 52, "y": 36, "flags": 4}, + {"matrix": [2, 7], "x": 60, "y": 36, "flags": 4}, + {"matrix": [2, 8], "x": 68, "y": 36, "flags": 4}, + {"matrix": [2, 9], "x": 76, "y": 36, "flags": 4}, + {"matrix": [2, 10], "x": 84, "y": 36, "flags": 4}, + {"matrix": [2, 11], "x": 92, "y": 36, "flags": 4}, + {"matrix": [2, 12], "x": 100, "y": 36, "flags": 4}, + {"matrix": [2, 13], "x": 110, "y": 36, "flags": 4}, + {"matrix": [2, 15], "x": 124, "y": 36, "flags": 4}, + {"matrix": [3, 0], "x": 124, "y": 52, "flags": 4}, + {"matrix": [3, 1], "x": 107, "y": 52, "flags": 4}, + {"matrix": [3, 2], "x": 94, "y": 52, "flags": 4}, + {"matrix": [3, 3], "x": 86, "y": 52, "flags": 4}, + {"matrix": [3, 4], "x": 78, "y": 52, "flags": 4}, + {"matrix": [3, 5], "x": 70, "y": 52, "flags": 4}, + {"matrix": [3, 6], "x": 62, "y": 52, "flags": 4}, + {"matrix": [3, 7], "x": 54, "y": 52, "flags": 4}, + {"matrix": [3, 8], "x": 46, "y": 52, "flags": 4}, + {"matrix": [3, 9], "x": 38, "y": 52, "flags": 4}, + {"matrix": [3, 10], "x": 30, "y": 52, "flags": 4}, + {"matrix": [3, 11], "x": 22, "y": 52, "flags": 4}, + {"matrix": [3, 12], "x": 14, "y": 52, "flags": 4}, + {"matrix": [3, 15], "x": 3, "y": 52, "flags": 4}, + {"matrix": [4, 0], "x": 5, "y": 68, "flags": 4}, + {"matrix": [4, 1], "x": 18, "y": 68, "flags": 4}, + {"matrix": [4, 2], "x": 26, "y": 68, "flags": 4}, + {"matrix": [4, 3], "x": 34, "y": 68, "flags": 4}, + {"matrix": [4, 4], "x": 42, "y": 68, "flags": 4}, + {"matrix": [4, 5], "x": 50, "y": 68, "flags": 4}, + {"matrix": [4, 6], "x": 58, "y": 68, "flags": 4}, + {"matrix": [4, 7], "x": 66, "y": 68, "flags": 4}, + {"matrix": [4, 8], "x": 74, "y": 68, "flags": 4}, + {"matrix": [4, 9], "x": 82, "y": 68, "flags": 4}, + {"matrix": [4, 10], "x": 90, "y": 68, "flags": 4}, + {"matrix": [4, 11], "x": 104, "y": 68, "flags": 4}, + {"matrix": [4, 13], "x": 114, "y": 68, "flags": 4}, + {"matrix": [4, 15], "x": 124, "y": 68, "flags": 4}, + {"matrix": [5, 0], "x": 122, "y": 84, "flags": 4}, + {"matrix": [5, 1], "x": 114, "y": 84, "flags": 4}, + {"matrix": [5, 2], "x": 106, "y": 84, "flags": 4}, + {"matrix": [5, 5], "x": 96, "y": 84, "flags": 4}, + {"matrix": [5, 8], "x": 88, "y": 84, "flags": 4}, + {"matrix": [5, 9], "x": 80, "y": 84, "flags": 4}, + {"matrix": [5, 10], "x": 50, "y": 84, "flags": 4}, + {"matrix": [5, 12], "x": 20, "y": 88, "flags": 4}, + {"matrix": [5, 13], "x": 10, "y": 88, "flags": 4}, + {"matrix": [5, 14], "x": 1, "y": 88, "flags": 4} + ] + }, + "url": "https://github.com/ArthurCyy", "usb": { - "vid": "0x3044", - "pid": "0x83A1", "device_version": "0.0.1", - "force_nkro": true + "pid": "0x83A1", + "vid": "0x3044" }, - "ws2812": { + "ws2812": { "pin": "B15" }, - "processor": "STM32F072", - "bootloader": "stm32-dfu", - "debounce": 3, "layouts": { "LAYOUT": { - "layout": [ - {"matrix": [0, 0], "x":0, "y":0}, - {"matrix": [0, 2], "x":1.25, "y":0}, - {"matrix": [0, 3], "x":2.25, "y":0}, - {"matrix": [0, 4], "x":3.25, "y":0}, - {"matrix": [0, 5], "x":4.25, "y":0}, - {"matrix": [0, 6], "x":5.5, "y":0}, - {"matrix": [0, 7], "x":6.5, "y":0}, - {"matrix": [0, 8], "x":7.5, "y":0}, - {"matrix": [0, 9], "x":8.5, "y":0}, - {"matrix": [0, 10], "x":9.75, "y":0}, - {"matrix": [0, 11], "x":10.75, "y":0}, - {"matrix": [0, 12], "x":11.75, "y":0}, - {"matrix": [0, 13], "x":12.75, "y":0}, - {"matrix": [0, 14], "x":14, "y":0}, - {"matrix": [0, 15], "x":15.25, "y":0}, - - {"matrix": [1, 0], "x":0, "y":1}, - {"matrix": [1, 1], "x":1, "y":1}, - {"matrix": [1, 2], "x":2, "y":1}, - {"matrix": [1, 3], "x":3, "y":1}, - {"matrix": [1, 4], "x":4, "y":1}, - {"matrix": [1, 5], "x":5, "y":1}, - {"matrix": [1, 6], "x":6, "y":1}, - {"matrix": [1, 7], "x":7, "y":1}, - {"matrix": [1, 8], "x":8, "y":1}, - {"matrix": [1, 9], "x":9, "y":1}, - {"matrix": [1, 10], "x":10, "y":1}, - {"matrix": [1, 11], "x":11, "y":1}, - {"matrix": [1, 12], "x":12, "y":1}, - {"matrix": [1, 13], "x":13, "y":1, "w":2}, - {"matrix": [1, 15], "x":15.25, "y":1}, - - {"matrix": [2, 0], "x":0, "y":2, "w":1.5}, - {"matrix": [2, 1], "x":1.5, "y":2}, - {"matrix": [2, 2], "x":2.5, "y":2}, - {"matrix": [2, 3], "x":3.5, "y":2}, - {"matrix": [2, 4], "x":4.5, "y":2}, - {"matrix": [2, 5], "x":5.5, "y":2}, - {"matrix": [2, 6], "x":6.5, "y":2}, - {"matrix": [2, 7], "x":7.5, "y":2}, - {"matrix": [2, 8], "x":8.5, "y":2}, - {"matrix": [2, 9], "x":9.5, "y":2}, - {"matrix": [2, 10], "x":10.5, "y":2}, - {"matrix": [2, 11], "x":11.5, "y":2}, - {"matrix": [2, 12], "x":12.5, "y":2}, - {"matrix": [2, 13], "x":13.5, "y":2, "w":1.5}, - {"matrix": [2, 15], "x":15.25, "y":2}, - - {"matrix": [3, 0], "x":0, "y":3, "w":1.75}, - {"matrix": [3, 1], "x":1.75, "y":3}, - {"matrix": [3, 2], "x":2.75, "y":3}, - {"matrix": [3, 3], "x":3.75, "y":3}, - {"matrix": [3, 4], "x":4.75, "y":3}, - {"matrix": [3, 5], "x":5.75, "y":3}, - {"matrix": [3, 6], "x":6.75, "y":3}, - {"matrix": [3, 7], "x":7.75, "y":3}, - {"matrix": [3, 8], "x":8.75, "y":3}, - {"matrix": [3, 9], "x":9.75, "y":3}, - {"matrix": [3, 10], "x":10.75, "y":3}, - {"matrix": [3, 11], "x":11.75, "y":3}, - {"matrix": [3, 12], "x":12.75, "y":3, "w":2.25}, - {"matrix": [3, 15], "x":15.25, "y":3}, - - {"matrix": [4, 0], "x":0, "y":4, "w":2.25}, - {"matrix": [4, 1], "x":2.25, "y":4}, - {"matrix": [4, 2], "x":3.25, "y":4}, - {"matrix": [4, 3], "x":4.25, "y":4}, - {"matrix": [4, 4], "x":5.25, "y":4}, - {"matrix": [4, 5], "x":6.25, "y":4}, - {"matrix": [4, 6], "x":7.25, "y":4}, - {"matrix": [4, 7], "x":8.25, "y":4}, - {"matrix": [4, 8], "x":9.25, "y":4}, - {"matrix": [4, 9], "x":10.25, "y":4}, - {"matrix": [4, 10], "x":11.25, "y":4}, - {"matrix": [4, 11], "x":12.25, "y":4, "w":1.75}, - {"matrix": [4, 13], "x":14.25, "y":4.5}, - {"matrix": [4, 15], "x":15.25, "y":4.25}, - - {"matrix": [5, 0], "x":0, "y":5, "w":1.25}, - {"matrix": [5, 1], "x":1.25, "y":5, "w":1.25}, - {"matrix": [5, 2], "x":2.5, "y":5, "w":1.25}, - {"matrix": [5, 5], "x":3.75, "y":5, "w":6.25}, - {"matrix": [5, 8], "x":10, "y":5}, - {"matrix": [5, 9], "x":11, "y":5}, - {"matrix": [5, 10], "x":12, "y":5}, - {"matrix": [5, 12], "x":13.25, "y":5.5}, - {"matrix": [5, 13], "x":14.25, "y":5.5}, - {"matrix": [5, 14], "x":15.25, "y":5.5} - ] + "layout": [ + {"matrix": [0, 0], "x": 0, "y": 0}, + {"matrix": [0, 2], "x": 1.25, "y": 0}, + {"matrix": [0, 3], "x": 2.25, "y": 0}, + {"matrix": [0, 4], "x": 3.25, "y": 0}, + {"matrix": [0, 5], "x": 4.25, "y": 0}, + {"matrix": [0, 6], "x": 5.5, "y": 0}, + {"matrix": [0, 7], "x": 6.5, "y": 0}, + {"matrix": [0, 8], "x": 7.5, "y": 0}, + {"matrix": [0, 9], "x": 8.5, "y": 0}, + {"matrix": [0, 10], "x": 9.75, "y": 0}, + {"matrix": [0, 11], "x": 10.75, "y": 0}, + {"matrix": [0, 12], "x": 11.75, "y": 0}, + {"matrix": [0, 13], "x": 12.75, "y": 0}, + {"matrix": [0, 14], "x": 14, "y": 0}, + {"matrix": [0, 15], "x": 15.25, "y": 0}, + {"matrix": [1, 0], "x": 0, "y": 1}, + {"matrix": [1, 1], "x": 1, "y": 1}, + {"matrix": [1, 2], "x": 2, "y": 1}, + {"matrix": [1, 3], "x": 3, "y": 1}, + {"matrix": [1, 4], "x": 4, "y": 1}, + {"matrix": [1, 5], "x": 5, "y": 1}, + {"matrix": [1, 6], "x": 6, "y": 1}, + {"matrix": [1, 7], "x": 7, "y": 1}, + {"matrix": [1, 8], "x": 8, "y": 1}, + {"matrix": [1, 9], "x": 9, "y": 1}, + {"matrix": [1, 10], "x": 10, "y": 1}, + {"matrix": [1, 11], "x": 11, "y": 1}, + {"matrix": [1, 12], "x": 12, "y": 1}, + {"matrix": [1, 13], "x": 13, "y": 1, "w": 2}, + {"matrix": [1, 15], "x": 15.25, "y": 1}, + {"matrix": [2, 0], "x": 0, "y": 2, "w": 1.5}, + {"matrix": [2, 1], "x": 1.5, "y": 2}, + {"matrix": [2, 2], "x": 2.5, "y": 2}, + {"matrix": [2, 3], "x": 3.5, "y": 2}, + {"matrix": [2, 4], "x": 4.5, "y": 2}, + {"matrix": [2, 5], "x": 5.5, "y": 2}, + {"matrix": [2, 6], "x": 6.5, "y": 2}, + {"matrix": [2, 7], "x": 7.5, "y": 2}, + {"matrix": [2, 8], "x": 8.5, "y": 2}, + {"matrix": [2, 9], "x": 9.5, "y": 2}, + {"matrix": [2, 10], "x": 10.5, "y": 2}, + {"matrix": [2, 11], "x": 11.5, "y": 2}, + {"matrix": [2, 12], "x": 12.5, "y": 2}, + {"matrix": [2, 13], "x": 13.5, "y": 2, "w": 1.5}, + {"matrix": [2, 15], "x": 15.25, "y": 2}, + {"matrix": [3, 0], "x": 0, "y": 3, "w": 1.75}, + {"matrix": [3, 1], "x": 1.75, "y": 3}, + {"matrix": [3, 2], "x": 2.75, "y": 3}, + {"matrix": [3, 3], "x": 3.75, "y": 3}, + {"matrix": [3, 4], "x": 4.75, "y": 3}, + {"matrix": [3, 5], "x": 5.75, "y": 3}, + {"matrix": [3, 6], "x": 6.75, "y": 3}, + {"matrix": [3, 7], "x": 7.75, "y": 3}, + {"matrix": [3, 8], "x": 8.75, "y": 3}, + {"matrix": [3, 9], "x": 9.75, "y": 3}, + {"matrix": [3, 10], "x": 10.75, "y": 3}, + {"matrix": [3, 11], "x": 11.75, "y": 3}, + {"matrix": [3, 12], "x": 12.75, "y": 3, "w": 2.25}, + {"matrix": [3, 15], "x": 15.25, "y": 3}, + {"matrix": [4, 0], "x": 0, "y": 4, "w": 2.25}, + {"matrix": [4, 1], "x": 2.25, "y": 4}, + {"matrix": [4, 2], "x": 3.25, "y": 4}, + {"matrix": [4, 3], "x": 4.25, "y": 4}, + {"matrix": [4, 4], "x": 5.25, "y": 4}, + {"matrix": [4, 5], "x": 6.25, "y": 4}, + {"matrix": [4, 6], "x": 7.25, "y": 4}, + {"matrix": [4, 7], "x": 8.25, "y": 4}, + {"matrix": [4, 8], "x": 9.25, "y": 4}, + {"matrix": [4, 9], "x": 10.25, "y": 4}, + {"matrix": [4, 10], "x": 11.25, "y": 4}, + {"matrix": [4, 11], "x": 12.25, "y": 4, "w": 1.75}, + {"matrix": [4, 13], "x": 14.25, "y": 4.5}, + {"matrix": [4, 15], "x": 15.25, "y": 4.25}, + {"matrix": [5, 0], "x": 0, "y": 5, "w": 1.25}, + {"matrix": [5, 1], "x": 1.25, "y": 5, "w": 1.25}, + {"matrix": [5, 2], "x": 2.5, "y": 5, "w": 1.25}, + {"matrix": [5, 5], "x": 3.75, "y": 5, "w": 6.25}, + {"matrix": [5, 8], "x": 10, "y": 5}, + {"matrix": [5, 9], "x": 11, "y": 5}, + {"matrix": [5, 10], "x": 12, "y": 5}, + {"matrix": [5, 12], "x": 13.25, "y": 5.5}, + {"matrix": [5, 13], "x": 14.25, "y": 5.5}, + {"matrix": [5, 14], "x": 15.25, "y": 5.5} + ] } } -} +} \ No newline at end of file diff --git a/keyboards/miiiw/blackio83/keymaps/via/keymap.c b/keyboards/miiiw/blackio83/keymaps/via/keymap.c index 70b79ef2af37..dc906f7e2c85 100644 --- a/keyboards/miiiw/blackio83/keymaps/via/keymap.c +++ b/keyboards/miiiw/blackio83/keymaps/via/keymap.c @@ -69,77 +69,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______, _______, _______, _______, _______, _______, RGB_RMOD, RGB_VAD, RGB_MOD ), }; - -// Implement Super-alt↯tab -// See https://docs.qmk.fm/#/feature_macros?id=super-alt↯tab -static bool is_alt_tab_active = false; -static uint32_t alt_tab_timer = 0; - -#ifdef DIP_SWITCH_ENABLE -bool dip_switch_update_user(uint8_t index, bool active) { - switch (index) { - case 2: - default_layer_set(1UL << (active ? WIN_BL : MAC_BL)); - break; - } - return true; -} -#endif - -// Processing all the key pressed. -// Alt+tab. -bool process_record_user(uint16_t keycode, keyrecord_t *record) { - uint8_t shift_mods = get_mods() & MOD_MASK_SHIFT; - switch (keycode) { // This will do most of the grunt work with the keycodes. - case ALT_TAB: - if (record->event.pressed) { - if (!is_alt_tab_active) { - is_alt_tab_active = true; - register_code(KC_LALT); - } - alt_tab_timer = timer_read32(); - register_code(KC_TAB); - } else { - unregister_code(KC_TAB); - } - return false; - case RGB_RST: - if (record->event.pressed) { - eeconfig_update_rgb_matrix_default(); - } - return false; - case RGB_VAI: - if(shift_mods) { - if (record->event.pressed) rgb_matrix_increase_speed(); - return false; - } - break; - case RGB_VAD: - if(shift_mods) { - if (record->event.pressed && rgb_matrix_get_speed() >= RGB_MATRIX_SPD_STEP) rgb_matrix_decrease_speed(); - return false; - } - break; - case RGB_MOD: - if(shift_mods) { - if (record->event.pressed) rgb_matrix_increase_hue(); - return false; - } - break; - case RGB_RMOD: - if(shift_mods) { - if (record->event.pressed) rgb_matrix_decrease_hue(); - return false; - } - break; - } - - return true; -} - -void matrix_scan_user(void) { // The very important timer. - if (is_alt_tab_active && timer_elapsed32(alt_tab_timer) > 750) { - unregister_code(KC_LALT); - is_alt_tab_active = false; - } -} diff --git a/keyboards/miiiw/blackio83/rev_0100/config.h b/keyboards/miiiw/blackio83/rev_0100/config.h index e66879e41fe1..ca719752cb13 100644 --- a/keyboards/miiiw/blackio83/rev_0100/config.h +++ b/keyboards/miiiw/blackio83/rev_0100/config.h @@ -26,17 +26,11 @@ * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) * */ -#define MATRIX_ROW_PINS { A7, A6, A5, A4, A3, A2 } -#define MATRIX_COL_PINS { H0, H1, H2, H3, H4, H5, H6, H7, H8, H9, H10, H11, H12, H13, H14, H15 } /* Dip Switch */ #define POWER_SWITCH_PIN B0 #define DIP_SWITCH_PINS { POWER_SWITCH_PIN, B1, B8, B12 } -/* LED indicator lights */ -#define LED_CAPS_LOCK_PIN B2 -#define LED_NUM_LOCK_PIN B14 - /* 16 with dummy columns for shift registers */ #define SHR_SERIES_NUM 2 #define SHR_CLOCK_PIN A0 diff --git a/keyboards/miiiw/blackio83/rev_0100/rev_0100.c b/keyboards/miiiw/blackio83/rev_0100/rev_0100.c index 52ec8618e043..b28ac84acb41 100644 --- a/keyboards/miiiw/blackio83/rev_0100/rev_0100.c +++ b/keyboards/miiiw/blackio83/rev_0100/rev_0100.c @@ -15,38 +15,3 @@ */ #include "blackio83.h" - -#ifdef RGB_MATRIX_ENABLE - -/* Leds on the CU80 go ltr > rtl > ltr > rlt > Ltr > rtl */ -led_config_t g_led_config = { - { /* C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 C14 C15 */ -/*R0*/ { 0, NO_LED, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }, -/*R1*/ { 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, NO_LED, 15 }, -/*R2*/ { 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, NO_LED, 44 }, -/*R3*/ { 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, NO_LED, NO_LED, 45 }, -/*R4*/ { 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, NO_LED, 71, NO_LED, 72 }, -/*R5*/ { 82, 81, 80, NO_LED, NO_LED, 79, NO_LED, NO_LED, 78, 77, 76, NO_LED, 75, 74, 73, NO_LED }, - }, - /*board layout accounting for led directions */ - { { 0, 0}, {10, 0}, {18, 0}, {26, 0}, {34, 0}, {44, 0}, {52, 0}, {60, 0}, {68, 0}, {78, 0}, {86, 0}, {94, 0}, {102, 0}, {112, 0}, {124, 0}, - // { 0, 20}, { 8, 20}, {16, 20}, {24, 20}, {32, 20}, {40, 20}, {48, 20}, {56, 20}, {64, 20}, {72, 20}, {80, 20}, {88, 20}, {96, 20}, {108,20}, {124,20}, - {124,20}, {108,20}, {96, 20}, {88, 20}, {80, 20}, {72, 20}, {64, 20}, {56, 20}, {48, 20}, {40, 20}, {32, 20}, {24, 20}, {16, 20}, { 8, 20}, { 0, 20}, - { 2, 36}, {12, 36}, {20, 36}, {28, 36}, {36, 36}, {44, 36}, {52, 36}, {60, 36}, {68, 36}, {76, 36}, {84, 36}, {92, 36}, {100,36}, {110,36}, {124,36}, - // { 3, 52}, {14, 52}, {22, 52}, {30, 52}, {38, 52}, {46, 52}, {54, 52}, {62, 52}, {70, 52}, {78, 52}, {86, 52}, {94, 52}, {107, 52}, {124,52}, - {124,52}, {107, 52}, {94, 52}, {86, 52}, {78, 52}, {70, 52}, {62, 52}, {54, 52}, {46, 52}, {38, 52}, {30, 52}, {22, 52}, {14, 52}, { 3, 52}, - { 5, 68}, {18, 68}, {26, 68}, {34, 68}, {42, 68}, {50, 68}, {58, 68}, {66, 68}, {74, 68}, {82, 68}, {90, 68}, {104,68}, {114,72}, {124,68}, - // { 1, 84}, {10, 84}, {20, 84}, {50, 84}, {80, 84}, {88, 84}, {96, 84}, {106,88}, {114,88}, {122,88}, - {122,88}, {114,88}, {106,88}, {96, 84}, {88, 84}, {80, 84}, {50, 84}, {20, 84}, {10, 84}, { 1, 84}, - }, - /* marks scroll and caps as function modifiers for led effects */ - { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, //15 - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, //15 - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, //15 - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, //14 - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, //14 - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, //10 - } -}; - -#endif diff --git a/keyboards/miiiw/blackio83/rev_0100/rules.mk b/keyboards/miiiw/blackio83/rev_0100/rules.mk index 2259066769c4..5558efa95d72 100644 --- a/keyboards/miiiw/blackio83/rev_0100/rules.mk +++ b/keyboards/miiiw/blackio83/rev_0100/rules.mk @@ -1,29 +1,7 @@ -# Build Options -# change yes to no to disable -# -BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite -MOUSEKEY_ENABLE = yes # Mouse keys -EXTRAKEY_ENABLE = yes # Audio control and System control -CONSOLE_ENABLE = no # Console for debug -COMMAND_ENABLE = no # Commands for debug and configuration -NKRO_ENABLE = yes # Enable N-Key Rollover -BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality -RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow -RGB_MATRIX_ENABLE = yes -RGB_MATRIX_DRIVER = custom -DIP_SWITCH_ENABLE = yes # Enable dip switches -DEBOUNCE_TYPE = sym_defer_pk # Debounce using eager_pk. CUSTOM_MATRIX = lite -DEFERRED_EXEC_ENABLE = yes -NO_USB_STARTUP_CHECK = yes -# EEPROM_DRIVER = i2c -# Enter lower-power sleep mode when on the ChibiOS idle thread -OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE - -OPT_DEFS += -DWS2812 +WS2812_DRIVER_REQUIRED := yes # Project specific files SRC += matrix.c \ - common/shift_register.c \ - common/ws2812_custom.c + common/shift_register.c diff --git a/keyboards/miiiw/common/ws2812_custom.c b/keyboards/miiiw/common/ws2812_custom.c deleted file mode 100644 index d5a6a94327b0..000000000000 --- a/keyboards/miiiw/common/ws2812_custom.c +++ /dev/null @@ -1,142 +0,0 @@ -/* Copyright 2023 ArthurCyy - * - * 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 "quantum.h" -#include "ws2812.h" -#include -#include - -/* Adapted from https://github.com/bigjosh/SimpleNeoPixelDemo/ */ - -#ifndef NOP_FUDGE -# if defined(STM32F0XX) || defined(STM32F1XX) || defined(GD32VF103) || defined(STM32F3XX) || defined(STM32F4XX) || defined(STM32L0XX) -# define NOP_FUDGE 0.4 -# else -# error("NOP_FUDGE configuration required") -# define NOP_FUDGE 1 // this just pleases the compile so the above error is easier to spot -# endif -#endif - -// Push Pull or Open Drain Configuration -// Default Push Pull -#ifndef WS2812_EXTERNAL_PULLUP -# define WS2812_OUTPUT_MODE PAL_MODE_OUTPUT_PUSHPULL -#else -# define WS2812_OUTPUT_MODE PAL_MODE_OUTPUT_OPENDRAIN -#endif - -// The reset gap can be 6000 ns, but depending on the LED strip it may have to be increased -// to values like 600000 ns. If it is too small, the pixels will show nothing most of the time. -#ifndef WS2812_RES -# define WS2812_RES (1000 * WS2812_TRST_US) // Width of the low gap between bits to cause a frame to latch -#endif - -#define NUMBER_NOPS 6 -#define CYCLES_PER_SEC (CPU_CLOCK / NUMBER_NOPS * NOP_FUDGE) -#define NS_PER_SEC (1000000000L) // Note that this has to be SIGNED since we want to be able to check for negative values of derivatives -#define NS_PER_CYCLE (NS_PER_SEC / CYCLES_PER_SEC) -#define NS_TO_CYCLES(n) ((n) / NS_PER_CYCLE) - -#define wait_ns(x) \ - do { \ - for (int i = 0; i < NS_TO_CYCLES(x); i++) { \ - __asm__ volatile("nop\n\t" \ - "nop\n\t" \ - "nop\n\t" \ - "nop\n\t" \ - "nop\n\t" \ - "nop\n\t"); \ - } \ - } while (0) - -static void sendByte(uint8_t byte) { - // WS2812 protocol wants most significant bits first - for (unsigned char bit = 0; bit < 8; bit++) { - // using something like wait_ns(is_one ? T1L : T0L) here throws off timings - if (byte & (0x80 >> bit)) { - // 1 - writePinHigh(WS2812_DI_PIN); - wait_ns(WS2812_T1H); - writePinLow(WS2812_DI_PIN); - wait_ns(WS2812_T1L); - } else { - // 0 - writePinHigh(WS2812_DI_PIN); - wait_ns(WS2812_T0H); - writePinLow(WS2812_DI_PIN); - wait_ns(WS2812_T0L); - } - } -} - -void ws2812_init(void) { - palSetLineMode(WS2812_DI_PIN, WS2812_OUTPUT_MODE); -} - -static bool p_setup = false; -static bool s_init = false; -void ws2812_poweron(void) { - if(p_setup) return; - p_setup = true; - s_init = false; - setPinOutput(RGB_EN_PIN); - writePinHigh(RGB_EN_PIN); -} - -void ws2812_poweroff(void) { - if(!p_setup) return; - p_setup = false; - setPinInputLow(WS2812_DI_PIN); - writePinLow(RGB_EN_PIN); -} - -// Setleds for standard RGB -void ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) { - if(!p_setup) return; - - if (!s_init) { - ws2812_init(); - s_init = true; - } - - // this code is very time dependent, so we need to disable interrupts - chSysLock(); - - for (uint8_t i = 0; i < leds; i++) { - // WS2812 protocol dictates grb order -#if (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_GRB) - sendByte(ledarray[i].g); - sendByte(ledarray[i].r); - sendByte(ledarray[i].b); -#elif (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_RGB) - sendByte(ledarray[i].r); - sendByte(ledarray[i].g); - sendByte(ledarray[i].b); -#elif (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_BGR) - sendByte(ledarray[i].b); - sendByte(ledarray[i].g); - sendByte(ledarray[i].r); -#endif - -#ifdef RGBW - sendByte(ledarray[i].w); -#endif - } - - wait_ns(WS2812_RES); - - chSysUnlock(); -} From 1162385eebf0a0badf9f63f3a305874b4fe095fe Mon Sep 17 00:00:00 2001 From: Arthur <37627147+ArthurCyy@users.noreply.github.com> Date: Fri, 22 Sep 2023 15:24:02 +0800 Subject: [PATCH 3/7] Updated instructions for entering the bootloader --- keyboards/miiiw/blackio83/readme.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/keyboards/miiiw/blackio83/readme.md b/keyboards/miiiw/blackio83/readme.md index c410eac654dc..ecb42fac261b 100644 --- a/keyboards/miiiw/blackio83/readme.md +++ b/keyboards/miiiw/blackio83/readme.md @@ -21,7 +21,10 @@ See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_to ## Bootloader -Enter the bootloader: +Enter the bootloader in 3 ways: -* (Official firmware only) Press and hold the left shift+ Fn+ upper right DEL. -* (Unofficial firmware) Press the key mapped to `QK_BOOT`. +* **Bootmagic reset**: With the power switch off, hold down the key at (0,0) in the matrix (Escape) and plug in the keyboard. +* **Physical button**: With the power switch off, hold the small metal button on the right side under the spacebar keycap and plug in the keyboard. +* **Keycode in layout**: + * (Official firmware only) With the power switch on, press and hold the left Shift+ Fn+ upper right DEL. + * (Unofficial firmware) With the power switch on, press the key mapped to `QK_BOOT` if it is available. From 0c80e2694301a8ca7a5efe5a1e651546a7f51f65 Mon Sep 17 00:00:00 2001 From: Arthur <37627147+ArthurCyy@users.noreply.github.com> Date: Sat, 23 Sep 2023 22:08:46 +0800 Subject: [PATCH 4/7] Update keyboards/miiiw/blackio83/rev_0100/config.h Co-authored-by: Drashna Jaelre --- keyboards/miiiw/blackio83/rev_0100/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/miiiw/blackio83/rev_0100/config.h b/keyboards/miiiw/blackio83/rev_0100/config.h index ca719752cb13..25dc73c48646 100644 --- a/keyboards/miiiw/blackio83/rev_0100/config.h +++ b/keyboards/miiiw/blackio83/rev_0100/config.h @@ -50,7 +50,7 @@ /* RGB Matrix config */ #define RGB_EN_PIN A8 #define RGBLED_NUM 83 -#define RGB_MATRIX_LED_COUNT RGBLED_NUM +#define RGB_MATRIX_LED_COUNT 83 #define RGB_MATRIX_CENTER { 62, 42 } // PWM RGB Underglow Defines From 7ae0273d2c7adfab0ec3b2f835c877cdd3542c9f Mon Sep 17 00:00:00 2001 From: Arthur <37627147+ArthurCyy@users.noreply.github.com> Date: Sat, 23 Sep 2023 22:08:58 +0800 Subject: [PATCH 5/7] Update keyboards/miiiw/blackio83/rev_0100/config.h Co-authored-by: Drashna Jaelre --- keyboards/miiiw/blackio83/rev_0100/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/miiiw/blackio83/rev_0100/config.h b/keyboards/miiiw/blackio83/rev_0100/config.h index 25dc73c48646..803c8a8a3b2d 100644 --- a/keyboards/miiiw/blackio83/rev_0100/config.h +++ b/keyboards/miiiw/blackio83/rev_0100/config.h @@ -29,7 +29,7 @@ /* Dip Switch */ #define POWER_SWITCH_PIN B0 -#define DIP_SWITCH_PINS { POWER_SWITCH_PIN, B1, B8, B12 } +#define DIP_SWITCH_PINS { B0, B1, B8, B12 } /* 16 with dummy columns for shift registers */ #define SHR_SERIES_NUM 2 From 470cd373565ee6dc832cf82f51dd524114e091ea Mon Sep 17 00:00:00 2001 From: Arthur <37627147+ArthurCyy@users.noreply.github.com> Date: Sat, 23 Sep 2023 22:09:07 +0800 Subject: [PATCH 6/7] Update keyboards/miiiw/blackio83/config.h Co-authored-by: Drashna Jaelre --- keyboards/miiiw/blackio83/config.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/keyboards/miiiw/blackio83/config.h b/keyboards/miiiw/blackio83/config.h index b9a699e137e0..a53cbaf3dc4f 100644 --- a/keyboards/miiiw/blackio83/config.h +++ b/keyboards/miiiw/blackio83/config.h @@ -16,9 +16,6 @@ #pragma once -/* key matrix size */ -#define MATRIX_ROWS 6 -#define MATRIX_COLS 16 // EEPROM i2c chip #define EEPROM_I2C_24LC256 From 920814e93b5518dd8b91dd1fd0da98daf1a66c8a Mon Sep 17 00:00:00 2001 From: Arthur <37627147+ArthurCyy@users.noreply.github.com> Date: Sat, 23 Sep 2023 22:11:53 +0800 Subject: [PATCH 7/7] Update config.h --- keyboards/miiiw/blackio83/config.h | 1 - 1 file changed, 1 deletion(-) diff --git a/keyboards/miiiw/blackio83/config.h b/keyboards/miiiw/blackio83/config.h index a53cbaf3dc4f..73c98722e9d4 100644 --- a/keyboards/miiiw/blackio83/config.h +++ b/keyboards/miiiw/blackio83/config.h @@ -16,7 +16,6 @@ #pragma once - // EEPROM i2c chip #define EEPROM_I2C_24LC256