From 7775bb2383eeea82f93f4c984a46fb49ab23140c Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Sat, 1 Jul 2023 03:28:42 -0700 Subject: [PATCH] [Keyboard] Add micromod input and display keyboard --- .../handwired/micromod_input_display/config.h | 14 +++ .../micromod_input_display/info.json | 59 +++++++++++++ .../keymaps/default/keymap.c | 12 +++ .../micromod_input_display.c | 85 +++++++++++++++++++ .../micromod_input_display/readme.md | 27 ++++++ .../micromod_input_display/rp2040/config.h | 31 +++++++ .../micromod_input_display/rp2040/halconf.h | 10 +++ .../micromod_input_display/rp2040/info.json | 12 +++ .../micromod_input_display/rp2040/mcuconf.h | 20 +++++ .../micromod_input_display/rp2040/readme.md | 12 +++ .../micromod_input_display/rp2040/rp2040.c | 10 +++ .../micromod_input_display/rp2040/rules.mk | 0 .../handwired/micromod_input_display/rules.mk | 14 +++ .../micromod_input_display/stm32f405/config.h | 29 +++++++ .../stm32f405/halconf.h | 10 +++ .../stm32f405/info.json | 12 +++ .../stm32f405/mcuconf.h | 18 ++++ .../stm32f405/readme.md | 7 ++ .../micromod_input_display/stm32f405/rules.mk | 0 .../stm32f405/stm32f405.c | 10 +++ 20 files changed, 392 insertions(+) create mode 100644 keyboards/handwired/micromod_input_display/config.h create mode 100644 keyboards/handwired/micromod_input_display/info.json create mode 100644 keyboards/handwired/micromod_input_display/keymaps/default/keymap.c create mode 100644 keyboards/handwired/micromod_input_display/micromod_input_display.c create mode 100644 keyboards/handwired/micromod_input_display/readme.md create mode 100644 keyboards/handwired/micromod_input_display/rp2040/config.h create mode 100644 keyboards/handwired/micromod_input_display/rp2040/halconf.h create mode 100644 keyboards/handwired/micromod_input_display/rp2040/info.json create mode 100644 keyboards/handwired/micromod_input_display/rp2040/mcuconf.h create mode 100644 keyboards/handwired/micromod_input_display/rp2040/readme.md create mode 100644 keyboards/handwired/micromod_input_display/rp2040/rp2040.c create mode 100644 keyboards/handwired/micromod_input_display/rp2040/rules.mk create mode 100644 keyboards/handwired/micromod_input_display/rules.mk create mode 100644 keyboards/handwired/micromod_input_display/stm32f405/config.h create mode 100644 keyboards/handwired/micromod_input_display/stm32f405/halconf.h create mode 100644 keyboards/handwired/micromod_input_display/stm32f405/info.json create mode 100644 keyboards/handwired/micromod_input_display/stm32f405/mcuconf.h create mode 100644 keyboards/handwired/micromod_input_display/stm32f405/readme.md create mode 100644 keyboards/handwired/micromod_input_display/stm32f405/rules.mk create mode 100644 keyboards/handwired/micromod_input_display/stm32f405/stm32f405.c diff --git a/keyboards/handwired/micromod_input_display/config.h b/keyboards/handwired/micromod_input_display/config.h new file mode 100644 index 0000000000..97408d9848 --- /dev/null +++ b/keyboards/handwired/micromod_input_display/config.h @@ -0,0 +1,14 @@ +// Copyright 2023 Drashna Jael're (@Drashna Jael're) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +// custom matrix +#define MATRIX_ROWS 1 +#define MATRIX_COLS 7 + +#define AUDIO_INIT_DELAY + +#define I2C1_CLOCK_SPEED 100000 + +#define QUANTUM_PAINTER_DISPLAY_TIMEOUT 0 diff --git a/keyboards/handwired/micromod_input_display/info.json b/keyboards/handwired/micromod_input_display/info.json new file mode 100644 index 0000000000..be9b8f9ef6 --- /dev/null +++ b/keyboards/handwired/micromod_input_display/info.json @@ -0,0 +1,59 @@ +{ + "manufacturer": "QMK", + "url": "", + "maintainer": "qmk", + "usb": { + "vid": "0xFEED", + "pid": "0x6465", + "device_version": "0.0.1" + }, + "tapping": { + "term": 500 + }, + "diode_direction": "COL2ROW", + "features": { + "bootmagic": false, + "mousekey": false, + "extrakey": true, + "console": false, + "command": false, + "nkro": false, + }, + "layouts": { + "LAYOUT": { + "layout": [ + {"label": "Up", "x": 1, "y": 0, "matrix": [0, 2]}, + {"label": "Left", "x": 0, "y": 1, "matrix": [0, 4]}, + {"label": "Center", "x": 1, "y": 1, "matrix": [0, 6]}, + {"label": "Right", "x": 2, "y": 1, "matrix": [0, 5]}, + {"label": "A", "x": 5, "y": 1, "matrix": [0, 0]}, + {"label": "B", "x": 6, "y": 1, "matrix": [0, 1]}, + {"label": "Down", "x": 1, "y": 2, "matrix": [0, 3]} + ] + } + }, + "rgblight": { + "driver": "apa102", + "led_count": 6, + "animations": { + "breathing": true, + "rainbow_mood": true, + "rainbow_swirl": true, + "snake": true, + "knight": true, + "christmas": true, + "static_gradient": true, + "rgb_test": true, + "alternating": true, + "twinkle": true + }, + "default": { + "animation": "rainbow_swirl" + } + }, + "backlight": { + "driver": "pwm", + "levels": 10, + "on_state": 0 + } +} diff --git a/keyboards/handwired/micromod_input_display/keymaps/default/keymap.c b/keyboards/handwired/micromod_input_display/keymaps/default/keymap.c new file mode 100644 index 0000000000..298f66fa9d --- /dev/null +++ b/keyboards/handwired/micromod_input_display/keymaps/default/keymap.c @@ -0,0 +1,12 @@ +// Copyright 2023 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#include QMK_KEYBOARD_H + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + LAYOUT( + KC_UP, + KC_LEFT, KC_C, KC_RIGHT, KC_A, KC_B, + KC_DOWN + ) +}; diff --git a/keyboards/handwired/micromod_input_display/micromod_input_display.c b/keyboards/handwired/micromod_input_display/micromod_input_display.c new file mode 100644 index 0000000000..6c4a0e7485 --- /dev/null +++ b/keyboards/handwired/micromod_input_display/micromod_input_display.c @@ -0,0 +1,85 @@ +// Copyright 2022 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include "quantum.h" +#include "i2c_master.h" + +#define BUTTON_I2C_ADDRESS 0x71 +#ifndef BUTTON_I2C_TIMEOUT +#define BUTTON_I2C_TIMEOUT 100 +#endif + +#define BUTTON_ID 0x00 +#define BUTTON_VERSION1 0x01 +#define BUTTON_VERSION2 0x02 +#define BUTTON_PRESSED 0x03 +#define BUTTON_CLICKED 0x04 +#define BUTTON_INTERRUPT 0x05 +#define BUTTON_DEBOUNCE 0x06 +#define BUTTON_CHANGE_ADDREESS 0x1F + + +static bool is_connected = false; + +void matrix_init_custom(void) { + i2c_init(); + uint8_t data = 0; + i2c_status_t status = i2c_readReg(BUTTON_I2C_ADDRESS << 1, 0, &data, 1, BUTTON_I2C_TIMEOUT); + is_connected = (status == I2C_STATUS_SUCCESS); +} + +uint8_t button_get_pressed(void) { + uint8_t data = 0; + i2c_readReg(BUTTON_I2C_ADDRESS << 1, BUTTON_PRESSED, &data, 1, BUTTON_I2C_TIMEOUT); + return data; +} + +uint8_t button_get_clicked(void) { + uint8_t data = 0; + i2c_readReg(BUTTON_I2C_ADDRESS << 1, BUTTON_CLICKED, &data, 1, BUTTON_I2C_TIMEOUT); + return data; +} + +uint16_t button_get_debounce(void) { + uint8_t data[2] = {0}; + i2c_readReg(BUTTON_I2C_ADDRESS << 1, BUTTON_DEBOUNCE, data, 2, BUTTON_I2C_TIMEOUT); + return (data[0] << 8) | data[1]; +} + +bool button_get_pressed_interrupt(void) { + uint8_t data = 0; + i2c_status_t status = i2c_readReg(BUTTON_I2C_ADDRESS << 1, BUTTON_INTERRUPT, &data, 1, BUTTON_I2C_TIMEOUT); + return (status == I2C_STATUS_SUCCESS) && ((data & (1 << 1)) >> 1); +} + +bool button_get_clicked_interrupt(void) { + uint8_t data = 0; + i2c_status_t status = i2c_readReg(BUTTON_I2C_ADDRESS << 1, BUTTON_INTERRUPT, &data, 1, BUTTON_I2C_TIMEOUT); + return (status == I2C_STATUS_SUCCESS) && ((data & (1 << 0)) >> 0); +} + + +bool matrix_scan_custom(matrix_row_t current_matrix[]) { + bool matrix_has_changed = false; + + if (!is_connected) { + return false; + } + + uint8_t pressed = button_get_pressed(); + if (pressed) { + current_matrix[0] |= pressed; + matrix_has_changed = true; + wait_us(200); + } + + uint8_t clicked = button_get_clicked(); + if (clicked) { + current_matrix[0] &= ~(clicked); + matrix_has_changed = true; + wait_us(10); + } + + return matrix_has_changed; +} diff --git a/keyboards/handwired/micromod_input_display/readme.md b/keyboards/handwired/micromod_input_display/readme.md new file mode 100644 index 0000000000..14cec18e4f --- /dev/null +++ b/keyboards/handwired/micromod_input_display/readme.md @@ -0,0 +1,27 @@ +# handwired/micromod_input_display + +![handwired/micromod_input_display](imgur.com image replace me!) + +*A short description of the keyboard/project* + +* Keyboard Maintainer: [Drashna Jael're](https://github.com/Drashna Jael're) +* Hardware Supported: *The PCBs, controllers supported* +* Hardware Availability: *Links to where you can find this hardware* + +Make example for this keyboard (after setting up your build environment): + + make handwired/micromod_input_display:default + +Flashing example for this keyboard: + + make handwired/micromod_input_display: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 in 3 ways: + +* **Bootmagic reset**: Hold down the key at (0,0) in the matrix (usually the top left key or Escape) and plug in the keyboard +* **Physical reset button**: Briefly press the button on the back of the PCB - some may have pads you must short instead +* **Keycode in layout**: Press the key mapped to `QK_BOOT` if it is available diff --git a/keyboards/handwired/micromod_input_display/rp2040/config.h b/keyboards/handwired/micromod_input_display/rp2040/config.h new file mode 100644 index 0000000000..adfc60c68b --- /dev/null +++ b/keyboards/handwired/micromod_input_display/rp2040/config.h @@ -0,0 +1,31 @@ +// Copyright 2022 Stefan Kerkmann +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#define I2C_DRIVER I2CD0 +#define I2C1_SDA_PIN GP4 +#define I2C1_SCL_PIN GP5 + +#define AUDIO_PIN GP24 +#define AUDIO_PWM_DRIVER PWMD4 +#define AUDIO_PWM_CHANNEL RP2040_PWM_CHANNEL_A + +#define SPI_DRIVER SPID0 +#define SPI_SCK_PIN GP22 +#define SPI_MOSI_PIN GP23 +#define SPI_MISO_PIN GP20 + +#define DISPLAY_CS_PIN_ILI9341 GP6 +#define DISPLAY_DC_PIN_ILI9341 GP7 +#define DISPLAY_RST_PIN_ILI9341 GP18 + +#define BACKLIGHT_PWM_DRIVER PWMD6 +#define BACKLIGHT_PWM_CHANNEL RP2040_PWM_CHANNEL_B + +#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET +#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_LED GP25 +#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_TIMEOUT 500U +#define "SERIAL_NUMBER" "MICROMOD_INPUT_DISPLAY" + +#define APA102_NOPS (100 / (1000000000L / (CPU_CLOCK / 4))) diff --git a/keyboards/handwired/micromod_input_display/rp2040/halconf.h b/keyboards/handwired/micromod_input_display/rp2040/halconf.h new file mode 100644 index 0000000000..beb40bffef --- /dev/null +++ b/keyboards/handwired/micromod_input_display/rp2040/halconf.h @@ -0,0 +1,10 @@ +// Copyright 2022 Stefan Kerkmann +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#define HAL_USE_I2C TRUE +#define HAL_USE_PWM TRUE +#define HAL_USE_SPI TRUE + +#include_next diff --git a/keyboards/handwired/micromod_input_display/rp2040/info.json b/keyboards/handwired/micromod_input_display/rp2040/info.json new file mode 100644 index 0000000000..9e2ae971c7 --- /dev/null +++ b/keyboards/handwired/micromod_input_display/rp2040/info.json @@ -0,0 +1,12 @@ +{ + "keyboard_name": "Input and Display MicroMod RP2040", + "processor": "RP2040", + "bootloader": "rp2040", + "apa102": { + "clock_pin": "GP17", + "data_pin": "GP16" + }, + "backlight": { + "pin": "GP13" + } +} diff --git a/keyboards/handwired/micromod_input_display/rp2040/mcuconf.h b/keyboards/handwired/micromod_input_display/rp2040/mcuconf.h new file mode 100644 index 0000000000..95f762fc4c --- /dev/null +++ b/keyboards/handwired/micromod_input_display/rp2040/mcuconf.h @@ -0,0 +1,20 @@ +// Copyright 2023 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include_next + +#undef RP_I2C_USE_I2C0 +#define RP_I2C_USE_I2C0 TRUE + +#undef SRP_SPI_USE_SPI0 +#define RP_SPI_USE_SPI0 TRUE + +#undef RP_PWM_USE_PWM4 +#define RP_PWM_USE_PWM4 TRUE + +#undef RP_PWM_USE_PWM6 +#define RP_PWM_USE_PWM6 TRUE + +#define RP_IRQ_RTC_PRIORITY 3 diff --git a/keyboards/handwired/micromod_input_display/rp2040/readme.md b/keyboards/handwired/micromod_input_display/rp2040/readme.md new file mode 100644 index 0000000000..9014479f8d --- /dev/null +++ b/keyboards/handwired/micromod_input_display/rp2040/readme.md @@ -0,0 +1,12 @@ +# Raspberry Pi 2040 onekey + +To trigger keypress, short together pins *GP4* and *GP5*. + +Double-tap reset to enter bootloader mode. Copy the built uf2 file to the device by dragging the file to the new USB disk. + +## Supported Hardware + +* Raspberry Pi Pico +* SparkFun Pro Micro - RP2040 +* Adafruit KB2040 - RP2040 Kee Boar +* ...and many more RP2040 based development boards diff --git a/keyboards/handwired/micromod_input_display/rp2040/rp2040.c b/keyboards/handwired/micromod_input_display/rp2040/rp2040.c new file mode 100644 index 0000000000..5c219eed8c --- /dev/null +++ b/keyboards/handwired/micromod_input_display/rp2040/rp2040.c @@ -0,0 +1,10 @@ +// Copyright 2023 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "quantum.h" + +void keyboard_pre_init_kb(void) { + setPinOutput(GP25); + writePinLow(GP25); + keyboard_pre_init_user(); +} diff --git a/keyboards/handwired/micromod_input_display/rp2040/rules.mk b/keyboards/handwired/micromod_input_display/rp2040/rules.mk new file mode 100644 index 0000000000..e69de29bb2 diff --git a/keyboards/handwired/micromod_input_display/rules.mk b/keyboards/handwired/micromod_input_display/rules.mk new file mode 100644 index 0000000000..1374f14679 --- /dev/null +++ b/keyboards/handwired/micromod_input_display/rules.mk @@ -0,0 +1,14 @@ +DEFAULT_FOLDER = handwired/micromod_input_display/stm32f405 + +QUANTUM_PAINTER_ENABLE = yes +QUANTUM_PAINTER_DRIVERS = ili9341_spi + +RGBLIGHT_ENABLE = yes + +AUDIO_ENABLE = yes +AUDIO_DRIVER = pwm_hardware + +BACKLIGHT_ENABLE = yes + +CUSTOM_MATRIX = lite +QUANTUM_LIB_SRC += i2c_master.c diff --git a/keyboards/handwired/micromod_input_display/stm32f405/config.h b/keyboards/handwired/micromod_input_display/stm32f405/config.h new file mode 100644 index 0000000000..ad6c8f6011 --- /dev/null +++ b/keyboards/handwired/micromod_input_display/stm32f405/config.h @@ -0,0 +1,29 @@ +// Copyright 2023 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#define I2C_DRIVER I2CD2 +#define I2C1_SDA_PIN B11 +#define I2C1_SCL_PIN B10 + +#define AUDIO_PIN C7 +#define AUDIO_PWM_DRIVER PWMD3 +#define AUDIO_PWM_CHANNEL 2 +#define AUDIO_PWM_PAL_MODE 2 + +#define SPI_DRIVER SPID1 +#define SPI_SCK_PIN A5 +#define SPI_SCK_PAL_MODE 5 +#define SPI_MOSI_PIN A7 +#define SPI_MOSI_PAL_MODE 5 +#define SPI_MISO_PIN A6 +#define SPI_MISO_PAL_MODE 5 + +#define DISPLAY_CS_PIN_ILI9341 C0 +#define DISPLAY_DC_PIN_ILI9341 C1 +#define DISPLAY_RST_PIN_ILI9341 A0 + +#define BACKLIGHT_PWM_DRIVER PWMD8 +#define BACKLIGHT_PWM_CHANNEL 1 +#define BACKLIGHT_PAL_MODE 3 diff --git a/keyboards/handwired/micromod_input_display/stm32f405/halconf.h b/keyboards/handwired/micromod_input_display/stm32f405/halconf.h new file mode 100644 index 0000000000..ad73f80c04 --- /dev/null +++ b/keyboards/handwired/micromod_input_display/stm32f405/halconf.h @@ -0,0 +1,10 @@ +// Copyright 2023 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#define HAL_USE_I2C TRUE +#define HAL_USE_PWM TRUE +#define HAL_USE_SPI TRUE + +#include_next diff --git a/keyboards/handwired/micromod_input_display/stm32f405/info.json b/keyboards/handwired/micromod_input_display/stm32f405/info.json new file mode 100644 index 0000000000..a848d0e1e5 --- /dev/null +++ b/keyboards/handwired/micromod_input_display/stm32f405/info.json @@ -0,0 +1,12 @@ +{ + "keyboard_name": "Input and Display MicroMod STM32F405", + "apa102": { + "clock_pin": "D2", + "data_pin": "A8" + }, + "backlight": { + "pin": "C6" + }, + "bootloader": "tinyuf2", + "processor": "STM32F405" +} diff --git a/keyboards/handwired/micromod_input_display/stm32f405/mcuconf.h b/keyboards/handwired/micromod_input_display/stm32f405/mcuconf.h new file mode 100644 index 0000000000..669a661795 --- /dev/null +++ b/keyboards/handwired/micromod_input_display/stm32f405/mcuconf.h @@ -0,0 +1,18 @@ +// Copyright 2023 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include_next + +#undef STM32_I2C_USE_I2C2 +#define STM32_I2C_USE_I2C2 TRUE + +#undef STM32_SPI_USE_SPI1 +#define STM32_SPI_USE_SPI1 TRUE + +#undef STM32_PWM_USE_TIM3 +#define STM32_PWM_USE_TIM3 TRUE + +#undef STM32_PWM_USE_TIM8 +#define STM32_PWM_USE_TIM8 TRUE diff --git a/keyboards/handwired/micromod_input_display/stm32f405/readme.md b/keyboards/handwired/micromod_input_display/stm32f405/readme.md new file mode 100644 index 0000000000..49a05725d5 --- /dev/null +++ b/keyboards/handwired/micromod_input_display/stm32f405/readme.md @@ -0,0 +1,7 @@ +# Adafruit Feather STM32F405 Express onekey + +* Supported Hardware: [Adafruit Feather STM32F405 Express](https://www.adafruit.com/product/4382) + +To trigger keypress, short together pins *GPIO 12 / PC2* and *GPIO 11 / PC3*. + +https://learn.adafruit.com/adafruit-stm32f405-feather-express/dfu-bootloader-details#enabling-dfu-bootloader-mode-3045622-2 \ No newline at end of file diff --git a/keyboards/handwired/micromod_input_display/stm32f405/rules.mk b/keyboards/handwired/micromod_input_display/stm32f405/rules.mk new file mode 100644 index 0000000000..e69de29bb2 diff --git a/keyboards/handwired/micromod_input_display/stm32f405/stm32f405.c b/keyboards/handwired/micromod_input_display/stm32f405/stm32f405.c new file mode 100644 index 0000000000..8d7a7cf845 --- /dev/null +++ b/keyboards/handwired/micromod_input_display/stm32f405/stm32f405.c @@ -0,0 +1,10 @@ +// Copyright 2023 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "quantum.h" + +void keyboard_pre_init_kb(void) { + setPinOutput(A15); + writePinLow(A15); + keyboard_pre_init_user(); +}