From b84306aa3825ee1281db4e8a287c0c2a8959f056 Mon Sep 17 00:00:00 2001 From: 9R Date: Sun, 5 Mar 2023 16:45:43 +0100 Subject: [PATCH] Add handwired/replicazeron add missing license headers add more missing headers fix d-pad matrix wire mapping refactor and remove duplicate code move matrix definition to info.json combine promicro & stm32 info.json remove UNICODEMAP from rules.mk on keyboard level fix layout macro order move common code out of keymap generalize status led code and move it to common/ remove unicodekeymap cleanup keymap remove redundand config.h sync changes to via keymap use common code with promicro move conditional includes to keymap level add image to readme.md consolidate keymaps add comments add default oled_brightness --- .../handwired/replicazeron/common/leds.c | 47 +++++ .../handwired/replicazeron/common/leds.h | 21 +++ .../handwired/replicazeron/common/oled.c | 97 ++++++++++ .../handwired/replicazeron/common/oled.h | 44 +++++ .../handwired/replicazeron/common/state.c | 28 +++ .../handwired/replicazeron/common/state.h | 26 +++ .../replicazeron/common/thumbstick.c | 133 ++++++++++++++ .../replicazeron/common/thumbstick.h | 57 ++++++ keyboards/handwired/replicazeron/info.json | 52 ++++++ .../replicazeron/keymaps/default/keymap.c | 168 ++++++++++++++++++ .../replicazeron/keymaps/default/readme.md | 2 + .../replicazeron/keymaps/default/rules.mk | 15 ++ .../replicazeron/keymaps/via/keymap.c | 168 ++++++++++++++++++ .../replicazeron/keymaps/via/readme.md | 2 + .../replicazeron/keymaps/via/rules.mk | 16 ++ .../handwired/replicazeron/promicro/config.h | 55 ++++++ .../handwired/replicazeron/promicro/info.json | 9 + .../replicazeron/promicro/promicro.c | 25 +++ .../replicazeron/promicro/promicro.h | 17 ++ .../handwired/replicazeron/promicro/rules.mk | 29 +++ keyboards/handwired/replicazeron/readme.md | 69 +++++++ .../handwired/replicazeron/stm32f103/config.h | 57 ++++++ .../replicazeron/stm32f103/halconf.h | 27 +++ .../replicazeron/stm32f103/info.json | 9 + .../replicazeron/stm32f103/mcuconf.h | 31 ++++ .../handwired/replicazeron/stm32f103/rules.mk | 33 ++++ .../replicazeron/stm32f103/stm32f103.c | 25 +++ .../replicazeron/stm32f103/stm32f103.h | 17 ++ 28 files changed, 1279 insertions(+) create mode 100644 keyboards/handwired/replicazeron/common/leds.c create mode 100644 keyboards/handwired/replicazeron/common/leds.h create mode 100644 keyboards/handwired/replicazeron/common/oled.c create mode 100644 keyboards/handwired/replicazeron/common/oled.h create mode 100644 keyboards/handwired/replicazeron/common/state.c create mode 100644 keyboards/handwired/replicazeron/common/state.h create mode 100644 keyboards/handwired/replicazeron/common/thumbstick.c create mode 100644 keyboards/handwired/replicazeron/common/thumbstick.h create mode 100644 keyboards/handwired/replicazeron/info.json create mode 100644 keyboards/handwired/replicazeron/keymaps/default/keymap.c create mode 100644 keyboards/handwired/replicazeron/keymaps/default/readme.md create mode 100644 keyboards/handwired/replicazeron/keymaps/default/rules.mk create mode 100644 keyboards/handwired/replicazeron/keymaps/via/keymap.c create mode 100644 keyboards/handwired/replicazeron/keymaps/via/readme.md create mode 100644 keyboards/handwired/replicazeron/keymaps/via/rules.mk create mode 100644 keyboards/handwired/replicazeron/promicro/config.h create mode 100644 keyboards/handwired/replicazeron/promicro/info.json create mode 100644 keyboards/handwired/replicazeron/promicro/promicro.c create mode 100644 keyboards/handwired/replicazeron/promicro/promicro.h create mode 100644 keyboards/handwired/replicazeron/promicro/rules.mk create mode 100644 keyboards/handwired/replicazeron/readme.md create mode 100644 keyboards/handwired/replicazeron/stm32f103/config.h create mode 100644 keyboards/handwired/replicazeron/stm32f103/halconf.h create mode 100644 keyboards/handwired/replicazeron/stm32f103/info.json create mode 100644 keyboards/handwired/replicazeron/stm32f103/mcuconf.h create mode 100644 keyboards/handwired/replicazeron/stm32f103/rules.mk create mode 100644 keyboards/handwired/replicazeron/stm32f103/stm32f103.c create mode 100644 keyboards/handwired/replicazeron/stm32f103/stm32f103.h diff --git a/keyboards/handwired/replicazeron/common/leds.c b/keyboards/handwired/replicazeron/common/leds.c new file mode 100644 index 00000000000..ab9e2ff8b5e --- /dev/null +++ b/keyboards/handwired/replicazeron/common/leds.c @@ -0,0 +1,47 @@ +/* Copyright 2023 9R + * + * 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 "leds.h" + +//////////// Status LEDs ////////////// +void init_leds(void) { + setPinOutput(STATUS_LED_A_PIN) ; + setPinOutput(STATUS_LED_B_PIN) ; + writePinHigh(STATUS_LED_A_PIN) ; //Led0 off + writePinHigh(STATUS_LED_B_PIN) ; //Led1 off +} + +void set_leds(int active_layer) { + //display active layer in binary + switch (active_layer) { + case 1: + writePinLow(STATUS_LED_A_PIN); //Led0 on + writePinHigh(STATUS_LED_B_PIN); //Led1 off + break; + case 2: + writePinHigh(STATUS_LED_A_PIN); //Led0 off + writePinLow(STATUS_LED_B_PIN); //Led1 on + break; + case 3: + writePinLow(STATUS_LED_A_PIN); //Led0 on + writePinLow(STATUS_LED_B_PIN); //Led1 on + break; + default: + writePinHigh(STATUS_LED_A_PIN); //Led0 off + writePinHigh(STATUS_LED_B_PIN); //Led1 off + break; + } +} diff --git a/keyboards/handwired/replicazeron/common/leds.h b/keyboards/handwired/replicazeron/common/leds.h new file mode 100644 index 00000000000..fa6c66fc11e --- /dev/null +++ b/keyboards/handwired/replicazeron/common/leds.h @@ -0,0 +1,21 @@ +/* Copyright 2023 9R + * + * 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 + +void init_leds(void) ; + +void set_leds(int active_layer) ; diff --git a/keyboards/handwired/replicazeron/common/oled.c b/keyboards/handwired/replicazeron/common/oled.c new file mode 100644 index 00000000000..ef01fe10f2d --- /dev/null +++ b/keyboards/handwired/replicazeron/common/oled.c @@ -0,0 +1,97 @@ +/* Copyright 2023 9R + * + * 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 "oled.h" + +uint8_t shiftbits =32 ; + +//////////// OLED output helpers ////////////// +void draw_mode(controller_state_t controller_state) { + //draw oled row showing thumbstick mode + oled_write_P(PSTR("Mode: "), false); + if (controller_state.wasdShiftMode) { + oled_write_ln_P(PSTR("WASD + Shift"), false); + } else if (controller_state.wasdMode) { + oled_write_ln_P(PSTR("WASD"), false); + } else { + oled_write_ln_P(PSTR("JoyStick"), false); + } +} + +void draw_wasd_key(wasd_state_t wasd_state) { + //draw oled row showing active keypresses emulated from thumbstick + const char* keys = "wasd" ; + bool keystates [] = {wasd_state.w, wasd_state.a, wasd_state.s, wasd_state.d } ; + // iterate over keystates + for ( int i = 0 ; i < 4 ; i++ ){ + if ( keystates[i]) { + char k = keys[i] ; + //bitshift char to upper case + if (wasd_state.shift) { + k &= ~shiftbits; + } + sprintf (stringbuffer , "%c", k); + oled_write(stringbuffer , false); + } + else { + oled_write_P(PSTR(" "), false); + } + } +} + +void draw_thumb_debug(thumbstick_polar_position_t thumbstick_polar_position) { + //draw oled row showing thumbstick direction and distance from center + oled_write_P(PSTR("Dir: "), false); + sprintf (stringbuffer , "%d", thumbstick_polar_position.angle); + oled_write(stringbuffer , false); + oled_write_P(PSTR(" Dist: "), false); + sprintf (stringbuffer , "%d", thumbstick_polar_position.distance); + oled_write_ln(stringbuffer , false); + //print registered key codes + oled_write_P(PSTR("Keycodes: "), false); + draw_wasd_key( wasd_state ); +} + +//////////// draw OLED output ////////////// +void draw_oled(controller_state_t controller_state) { + oled_write_P(PSTR("Layer: "), false); + + switch (controller_state.activeLayer) { + case LAYER_SHOOTER: + oled_write_ln_P(PSTR("Shooter"), false); + draw_mode(controller_state); + oled_write_ln_P(PSTR(" "), false); + oled_write_ln_P(PSTR(" "), false); + break; + case LAYER_MISC: + oled_write_ln_P(PSTR("Misc"), false); + draw_mode(controller_state); + oled_write_ln_P(PSTR(" "), false); + oled_write_ln_P(PSTR(" "), false); + break; + case LAYER_SETTINGS: + oled_write_ln_P(PSTR("Settings"), false); + draw_mode(controller_state); + draw_thumb_debug(thumbstick_polar_position); + oled_write_ln_P(PSTR(" "), false); + break; + default: + oled_write_ln_P(PSTR("Default"), false); + draw_mode(controller_state); + oled_write_ln_P(PSTR(" "), false); + oled_write_ln_P(PSTR(" "), false); + } +} diff --git a/keyboards/handwired/replicazeron/common/oled.h b/keyboards/handwired/replicazeron/common/oled.h new file mode 100644 index 00000000000..ccf5182abbc --- /dev/null +++ b/keyboards/handwired/replicazeron/common/oled.h @@ -0,0 +1,44 @@ +/* Copyright 2023 9R + * + * 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 "print.h" +#include QMK_KEYBOARD_H +#include + +#include "state.h" +#include "thumbstick.h" + +uint8_t shiftbits ; + +char stringbuffer[8] ; + +enum keymap_layers { + LAYER_BASE = 0, + LAYER_SHOOTER, + LAYER_MISC, + LAYER_SETTINGS, +}; + +void draw_oled(controller_state_t controller_state) ; + +void draw_mode(controller_state_t controller_state) ; + +void draw_thumb_debug(thumbstick_polar_position_t thumbstick_polar_position) ; + +void draw_wasd_key(wasd_state_t wasd_state) ; + +void draw_settings(void) ; diff --git a/keyboards/handwired/replicazeron/common/state.c b/keyboards/handwired/replicazeron/common/state.c new file mode 100644 index 00000000000..a3ff8c60f89 --- /dev/null +++ b/keyboards/handwired/replicazeron/common/state.c @@ -0,0 +1,28 @@ +/* Copyright 2023 9R + * + * 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 "state.h" + +controller_state_t init_state (void) { + controller_state_t controller_state = { + .wasdMode = true , + .wasdShiftMode = false , + .autoRun = false , + .activeLayer = 0, + } ; + + return controller_state; +} diff --git a/keyboards/handwired/replicazeron/common/state.h b/keyboards/handwired/replicazeron/common/state.h new file mode 100644 index 00000000000..8cbe2306c07 --- /dev/null +++ b/keyboards/handwired/replicazeron/common/state.h @@ -0,0 +1,26 @@ +/* Copyright 2023 9R + * + * 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" + +typedef struct { + bool wasdMode; + bool wasdShiftMode; + bool autoRun; + int activeLayer; +}controller_state_t ; + +controller_state_t init_state (void) ; diff --git a/keyboards/handwired/replicazeron/common/thumbstick.c b/keyboards/handwired/replicazeron/common/thumbstick.c new file mode 100644 index 00000000000..c90af61b050 --- /dev/null +++ b/keyboards/handwired/replicazeron/common/thumbstick.c @@ -0,0 +1,133 @@ +/* Copyright 2023 9R + * + * 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 "thumbstick.h" + +void init_wasd_state (void) { +wasd_state.w = wasd_state.a = wasd_state.s = wasd_state.d = false ; +last_wasd_state = wasd_state ; +wasd_state.shift = false ; +} + +thumbstick_polar_position_t get_thumbstick_polar_position (int x, int y ) { + thumbstick_polar_position_t position ; + int x_centered = x - 512; + int y_centered = y - 512; + +#ifdef THUMBSTICK_DEBUG + print("xN: "); + uprintf("%4d", x_centered); + print(" yN: "); + uprintf("%4d", y_centered); +#endif + + //transform to carthesian coordinates to polar coordinates + //get distance from center as int in range [0-600] + position.distance = (double)sqrt( (double)x_centered * (double)x_centered + (double)y_centered * (double)y_centered ); + //get direction as int in range [0 to 359] + position.angle = (double) atan2( y_centered, x_centered ) * (180 /M_PI)+180; + + //apply thumbstick rotation const to modify forward direction + position.angle = ( position.angle + _THUMBSTICK_ROTATION )%360 ; + + return position; +} + +bool update_keystate( bool keystate, int angle_from, int angle_to, int angle ){ + if (angle_from < angle && angle <= angle_to ) { + keystate = true ; + } + if (angle <= angle_from || angle_to < angle ) { + keystate = false ; + } + return keystate ; +} + +void update_keycode(uint16_t keycode, bool keystate, bool last_keystate) { + if (keystate && keystate != last_keystate ) { + register_code(keycode); + } + else if (!keystate) { + unregister_code (keycode) ; + } +} + +void thumbstick(controller_state_t controller_state) { + + yPos = analogReadPin(B1); + xPos = analogReadPin(B0); + + thumbstick_polar_position = get_thumbstick_polar_position (xPos, yPos); + +#ifdef THUMBSTICK_DEBUG + print(" distance: "); + uprintf("%5d", thumbstick_polar_position.angle); + print(" angle: "); + uprintf("%5d", thumbstick_polar_position.distance); + print("\n"); +#endif + + // Update WASD state depending on thumbstick position + // if thumbstick out of of deadzone + if ( thumbstick_polar_position.distance >= _DEADZONE ) { + wasd_state.w = update_keystate (wasd_state.w, 0, 90, thumbstick_polar_position.angle); + if ( !wasd_state.w ) { + wasd_state.w = update_keystate (wasd_state.w, 315, 360, thumbstick_polar_position.angle); + } + // A angle: 45 - 180 + wasd_state.a = update_keystate (wasd_state.a, 45, 181, thumbstick_polar_position.angle); + // S angle: 135 - 270 + wasd_state.s = update_keystate (wasd_state.s, 135, 270, thumbstick_polar_position.angle); + // D angle: 225 - 359 + wasd_state.d = update_keystate (wasd_state.d, 225, 359, thumbstick_polar_position.angle); + } + //reset WASD state when in _DEADZONE + else { + init_wasd_state () ; + } + +#ifdef THUMBSTICK_DEBUG + print(" w: "); + uprintf("%2d", wasd_state.w); + print(" a: "); + uprintf("%2d", wasd_state.a); + print(" s: "); + uprintf("%2d", wasd_state.s); + print(" d: "); + uprintf("%2d", wasd_state.d); + print("\n"); +#endif + +update_keycode (KC_W, wasd_state.w, last_wasd_state.w) ; +update_keycode (KC_A, wasd_state.a, last_wasd_state.a) ; +update_keycode (KC_S, wasd_state.s, last_wasd_state.s) ; +update_keycode (KC_D, wasd_state.d, last_wasd_state.d) ; + +last_wasd_state = wasd_state ; + + // handle WASD-Shift mode + if (controller_state.wasdShiftMode) { + bool Shifted = thumbstick_polar_position.distance > _SHIFTZONE; + if (!wasd_state.shift && Shifted) { + register_code(KC_LSFT); + wasd_state.shift = true; + } + else if (wasd_state.shift && !Shifted) { + unregister_code(KC_LSFT); + wasd_state.shift = false; + } + } +} diff --git a/keyboards/handwired/replicazeron/common/thumbstick.h b/keyboards/handwired/replicazeron/common/thumbstick.h new file mode 100644 index 00000000000..f0b5b6bdaa4 --- /dev/null +++ b/keyboards/handwired/replicazeron/common/thumbstick.h @@ -0,0 +1,57 @@ +/* Copyright 2023 9R + * + * 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 + +#define _DEADZONE 100 // 0 to _SHIFTZONE-1 +#define _SHIFTZONE 350 // _DEADZONE+1 to 600 +#define _THUMBSTICK_ROTATION 100 //degrees, adjusts forward direction + +#include QMK_KEYBOARD_H +#include "analog.h" +#include + +#include "state.h" + +int xPos; +int yPos; + +typedef struct { + int angle; + int distance; +} thumbstick_polar_position_t; + +typedef struct { + bool w; + bool a; + bool s; + bool d; + bool shift; +} wasd_state_t; + +thumbstick_polar_position_t thumbstick_polar_position ; + +wasd_state_t wasd_state; +wasd_state_t last_wasd_state; + +void init_wasd_state (void) ; + +thumbstick_polar_position_t get_thumbstick_polar_position (int x, int y ) ; + +bool update_keystate(bool keyheld , int angle_from, int angle_to, int angle ) ; + +void update_keycode(uint16_t keycode, bool keystate, bool last_keystate) ; + +void thumbstick(controller_state_t controller_state) ; diff --git a/keyboards/handwired/replicazeron/info.json b/keyboards/handwired/replicazeron/info.json new file mode 100644 index 00000000000..f40e6595382 --- /dev/null +++ b/keyboards/handwired/replicazeron/info.json @@ -0,0 +1,52 @@ +{ + "keyboard_name": "Replicazeron", + "manufacturer": "9R", + "url": "", + "maintainer": "9R", + "usb": { + "vid": "0x4142", + "pid": "0x2305", + "device_version": "0.0.1" + }, + "layouts": { + "LAYOUT": { + "layout": [ + {"label":"K04", "x":1.75, "y":1, "w":1.25, "matrix": [0,0]}, + {"label":"K10", "x":3, "y":1, "w":1.25, "matrix": [0,1]}, + {"label":"K16", "x":4.25, "y":1, "w":1.25, "matrix": [0,2]}, + {"label":"K22", "x":5.5, "y":1, "w":1.25, "matrix": [0,3]}, + {"label":"dwn", "x":9.5, "y":2.75, "w":1.25, "matrix": [0,4]}, + + {"label":"K03", "x":1.75, "y":1.7, "h":1.25, "w":1.25, "matrix": [1,0]}, + {"label":"K09", "x":3, "y":1.7, "h":1.25, "w":1.25, "matrix": [1,1]}, + {"label":"K15", "x":4.25, "y":1.7, "h":1.25, "w":1.25, "matrix": [1,2]}, + {"label":"K21", "x":5.5, "y":1.7, "h":1.25, "w":1.25, "matrix": [1,3]}, + {"label":"lft", "x":8.25, "y":1.75, "w":1.25, "matrix": [1,4]}, + + {"label":"K02", "x":1.75, "y":3.25, "h":1.25, "w":1.25, "matrix": [2,0]}, + {"label":"K08", "x":3, "y":3.25, "h":1.25, "w":1.25, "matrix": [2,1]}, + {"label":"K14", "x":4.25, "y":3.25, "h":1.25, "w":1.25, "matrix": [2,2]}, + {"label":"K20", "x":5.5, "y":3.25, "h":1.25, "w":1.25, "matrix": [2,3]}, + {"label":"ent", "x":9.5, "y":1.75, "w":1.25, "matrix": [2,4]}, + + {"label":"K01", "x":1.75, "y":4.5, "w":1.25, "matrix": [3,0]}, + {"label":"K07", "x":3, "y":4.5, "w":1.25, "matrix": [3,1]}, + {"label":"K13", "x":4.25, "y":4.5, "w":1.25, "matrix": [3,2]}, + {"label":"K19", "x":5.5, "y":4.5, "w":1.25, "matrix": [3,3]}, + {"label":"rgt", "x":10.75, "y":1.75, "w":1.25, "matrix": [3,4]}, + + {"label":"K00", "x":1.75, "y":5.5, "w":1.25, "matrix": [4,0]}, + {"label":"K06", "x":3, "y":5.5, "w":1.25, "matrix": [4,1]}, + {"label":"K12", "x":4.25, "y":5.5, "w":1.25, "matrix": [4,2]}, + {"label":"K18", "x":5.5, "y":5.5, "w":1.25, "matrix": [4,3]}, + {"label":"up ", "x":9.5, "y":0.75, "w":1.25, "matrix": [4,4]}, + + {"label":"K05", "x":0, "y":3.25, "w":1.75, "matrix": [5,0]}, + {"label":"lyr", "x":7.5, "y":5, "w":1.5, "matrix": [5,1]}, + {"label":"K17", "x":10.75, "y":4.75, "w":1.5, "matrix": [5,2]}, + {"label":"K23", "x":6.75, "y":3.25, "w":1.5, "matrix": [5,3]}, + {"label":"spc", "x":10.75, "y":3.75, "w":1.25, "matrix": [5,4]} + ] + } + } +} diff --git a/keyboards/handwired/replicazeron/keymaps/default/keymap.c b/keyboards/handwired/replicazeron/keymaps/default/keymap.c new file mode 100644 index 00000000000..5a5389c82f1 --- /dev/null +++ b/keyboards/handwired/replicazeron/keymaps/default/keymap.c @@ -0,0 +1,168 @@ +/* Copyright 2023 9R + * + * 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 . + */ + +#ifdef LEDS_ENABLE +# include "../common/leds.h" +#endif + +#ifdef OLED_ENABLE +# include "../common/oled.h" +#endif + +#ifdef THUMBSTICK_ENABLE +# include "../common/thumbstick.h" +#endif + +#include "../common/state.h" + +controller_state_t controller_state ; + +#ifndef OLED_ENABLE +enum keymap_layers { + LAYER_BASE = 0, + LAYER_SHOOTER, + LAYER_MISC, + LAYER_SETTINGS, +}; +#endif + +enum custom_keycodes { + JOYMODE = SAFE_RANGE, + AUTORUN, + M_UP, + M_DWN, + M_L, + M_R, + M_SEL +}; + +//////////// Status LEDs ////////////// +#ifdef LEDS_ENABLE +void keyboard_pre_init_user(void) { + init_leds() ; +} +#endif + +//////////// WASD THUMBSTICK ////////////// +#ifdef THUMBSTICK_ENABLE +void matrix_init_user(void) { + init_wasd_state() ; + controller_state = init_state(); +} + +void matrix_scan_user(void) { + if (controller_state.wasdMode) { + thumbstick (controller_state); + } +} +#endif + +#ifdef JOYSTICK_ENABLE +//joystick config +joystick_config_t joystick_axes[JOYSTICK_AXIS_COUNT] = { + JOYSTICK_AXIS_IN(B0, 0, 512, 1023), + JOYSTICK_AXIS_IN(B1, 0, 512, 1023) +}; +#endif + +//////////// KEYMAPS ////////////// +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + [0] = LAYOUT( + // | little | ring | middle | index | 5way-dpad | -finger + KC_GRV, KC_ESC, KC_J, KC_M, KC_RIGHT, // up + KC_T, KC_3, KC_4, KC_R, KC_ENT, // forward + KC_X, KC_LCTL, KC_LCTL, KC_LALT, KC_DOWN, // down + KC_LSFT, KC_SPC, KC_C, KC_F, KC_LEFT, // back 2 + KC_LSFT, KC_6, KC_Z, KC_V, KC_UP, // back 1 + KC_TAB, TG(1), KC_I, KC_B, KC_P // special + // ^side_l | ^case | ^thumb | ^side_r | ^analog click <= special row mapping + ), + + [LAYER_SHOOTER] = LAYOUT( + // | little | ring | middle | index | 5way-dpad | -finger + KC_NO, KC_NO, KC_NO, KC_NO, KC_RIGHT, // up + KC_NO, KC_NO, KC_NO, KC_NO, KC_ENT, // forward + KC_NO, KC_NO, KC_NO, KC_NO, KC_DOWN, // down + KC_NO, KC_NO, KC_NO, KC_NO, KC_LEFT, // back 2 + KC_NO, KC_NO, KC_NO, KC_NO, KC_UP, // back 1 + KC_NO, TG(2), KC_NO, KC_NO, KC_P // special + // ^side_l | ^case | ^thumb | ^side_r | ^analog click <= special row mapping + ), + [LAYER_MISC] = LAYOUT( + // | little | ring | middle | index | 5way-dpad | -finger + KC_NO, KC_NO, KC_NO, KC_NO, KC_RIGHT, // up + KC_NO, KC_NO, KC_NO, KC_NO, KC_ENT, // forward + KC_NO, KC_NO, KC_NO, KC_NO, KC_DOWN, // down + KC_NO, KC_NO, KC_NO, KC_NO, KC_LEFT, // back 2 + KC_NO, KC_NO, KC_NO, KC_NO, KC_UP, // back 1 + KC_NO, TG(3), KC_NO, KC_NO, KC_P // special + // ^side_l | ^case | ^thumb | ^side_r | ^analog click <= special row mapping + ), + [LAYER_SETTINGS] = LAYOUT( + // | little | ring | middle | index | 5way-dpad | -finger + RGB_M_P, RGB_M_B, RGB_M_K, RGB_M_T, KC_RIGHT, // up + KC_NO, RGB_SAI, RGB_VAI, RGB_HUI, KC_ENT, // forward + RGB_TOG, KC_NO, KC_NO, KC_NO , KC_DOWN, // down + EE_CLR, RGB_SAD, RGB_VAD, RGB_HUD, KC_LEFT, // back 2 + QK_BOOT, AUTORUN, JOYMODE, KC_V, KC_UP, // back 1 + RGB_MOD, TO(0), KC_NO, RGB_RMOD, KC_P // special + // ^side_l | ^case | ^thumb | ^side_r | ^analog click <= special row mapping + ) +}; + +//////////// Change modes on keypress ////////////// +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + if (keycode == JOYMODE && record->event.pressed) { + if (!controller_state.wasdMode) { + controller_state.wasdMode = true; + } else if (controller_state.wasdMode && !controller_state.wasdShiftMode) { + controller_state.wasdShiftMode = true; + } else { + controller_state.wasdMode = false; + controller_state.wasdShiftMode = false; + } + } else if (keycode == AUTORUN && record->event.pressed) { + if (!controller_state.autoRun) { + controller_state.autoRun = true; + register_code(KC_W); + } else { + controller_state.autoRun = false; + unregister_code(KC_W); + } + } + return true; +}; + +//////////// Draw OLED menu ////////////// +#ifdef OLED_ENABLE +bool oled_task_user(void) { + draw_oled(controller_state); + + return false; +} +#endif + +//////////// Handle layer changes ////////////// +layer_state_t layer_state_set_user(layer_state_t state) { + controller_state.activeLayer = get_highest_layer(state) ; + + #ifdef LEDS_ENABLE + set_leds(controller_state.activeLayer) ; + #endif + + return state ; +} diff --git a/keyboards/handwired/replicazeron/keymaps/default/readme.md b/keyboards/handwired/replicazeron/keymaps/default/readme.md new file mode 100644 index 00000000000..29f6a29a3ac --- /dev/null +++ b/keyboards/handwired/replicazeron/keymaps/default/readme.md @@ -0,0 +1,2 @@ +# Replicazeron Gamepad +Default layout with 2 axies thumbstick diff --git a/keyboards/handwired/replicazeron/keymaps/default/rules.mk b/keyboards/handwired/replicazeron/keymaps/default/rules.mk new file mode 100644 index 00000000000..e781238a379 --- /dev/null +++ b/keyboards/handwired/replicazeron/keymaps/default/rules.mk @@ -0,0 +1,15 @@ +ifeq ($(strip $(LEDS_ENABLE)), yes) + OPT_DEFS += -DLEDS_ENABLE + SRC += ../common/leds.c +endif + +ifeq ($(strip $(OLED_ENABLE)), yes) + SRC += ../common/oled.c +endif + +ifeq ($(strip $(THUMBSTICK_ENABLE)), yes) +# POINTING_DEVICE_ENABLE = yes + OPT_DEFS += -DTHUMBSTICK_ENABLE + SRC += analog.c + SRC += ../common/thumbstick.c +endif diff --git a/keyboards/handwired/replicazeron/keymaps/via/keymap.c b/keyboards/handwired/replicazeron/keymaps/via/keymap.c new file mode 100644 index 00000000000..5a5389c82f1 --- /dev/null +++ b/keyboards/handwired/replicazeron/keymaps/via/keymap.c @@ -0,0 +1,168 @@ +/* Copyright 2023 9R + * + * 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 . + */ + +#ifdef LEDS_ENABLE +# include "../common/leds.h" +#endif + +#ifdef OLED_ENABLE +# include "../common/oled.h" +#endif + +#ifdef THUMBSTICK_ENABLE +# include "../common/thumbstick.h" +#endif + +#include "../common/state.h" + +controller_state_t controller_state ; + +#ifndef OLED_ENABLE +enum keymap_layers { + LAYER_BASE = 0, + LAYER_SHOOTER, + LAYER_MISC, + LAYER_SETTINGS, +}; +#endif + +enum custom_keycodes { + JOYMODE = SAFE_RANGE, + AUTORUN, + M_UP, + M_DWN, + M_L, + M_R, + M_SEL +}; + +//////////// Status LEDs ////////////// +#ifdef LEDS_ENABLE +void keyboard_pre_init_user(void) { + init_leds() ; +} +#endif + +//////////// WASD THUMBSTICK ////////////// +#ifdef THUMBSTICK_ENABLE +void matrix_init_user(void) { + init_wasd_state() ; + controller_state = init_state(); +} + +void matrix_scan_user(void) { + if (controller_state.wasdMode) { + thumbstick (controller_state); + } +} +#endif + +#ifdef JOYSTICK_ENABLE +//joystick config +joystick_config_t joystick_axes[JOYSTICK_AXIS_COUNT] = { + JOYSTICK_AXIS_IN(B0, 0, 512, 1023), + JOYSTICK_AXIS_IN(B1, 0, 512, 1023) +}; +#endif + +//////////// KEYMAPS ////////////// +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + [0] = LAYOUT( + // | little | ring | middle | index | 5way-dpad | -finger + KC_GRV, KC_ESC, KC_J, KC_M, KC_RIGHT, // up + KC_T, KC_3, KC_4, KC_R, KC_ENT, // forward + KC_X, KC_LCTL, KC_LCTL, KC_LALT, KC_DOWN, // down + KC_LSFT, KC_SPC, KC_C, KC_F, KC_LEFT, // back 2 + KC_LSFT, KC_6, KC_Z, KC_V, KC_UP, // back 1 + KC_TAB, TG(1), KC_I, KC_B, KC_P // special + // ^side_l | ^case | ^thumb | ^side_r | ^analog click <= special row mapping + ), + + [LAYER_SHOOTER] = LAYOUT( + // | little | ring | middle | index | 5way-dpad | -finger + KC_NO, KC_NO, KC_NO, KC_NO, KC_RIGHT, // up + KC_NO, KC_NO, KC_NO, KC_NO, KC_ENT, // forward + KC_NO, KC_NO, KC_NO, KC_NO, KC_DOWN, // down + KC_NO, KC_NO, KC_NO, KC_NO, KC_LEFT, // back 2 + KC_NO, KC_NO, KC_NO, KC_NO, KC_UP, // back 1 + KC_NO, TG(2), KC_NO, KC_NO, KC_P // special + // ^side_l | ^case | ^thumb | ^side_r | ^analog click <= special row mapping + ), + [LAYER_MISC] = LAYOUT( + // | little | ring | middle | index | 5way-dpad | -finger + KC_NO, KC_NO, KC_NO, KC_NO, KC_RIGHT, // up + KC_NO, KC_NO, KC_NO, KC_NO, KC_ENT, // forward + KC_NO, KC_NO, KC_NO, KC_NO, KC_DOWN, // down + KC_NO, KC_NO, KC_NO, KC_NO, KC_LEFT, // back 2 + KC_NO, KC_NO, KC_NO, KC_NO, KC_UP, // back 1 + KC_NO, TG(3), KC_NO, KC_NO, KC_P // special + // ^side_l | ^case | ^thumb | ^side_r | ^analog click <= special row mapping + ), + [LAYER_SETTINGS] = LAYOUT( + // | little | ring | middle | index | 5way-dpad | -finger + RGB_M_P, RGB_M_B, RGB_M_K, RGB_M_T, KC_RIGHT, // up + KC_NO, RGB_SAI, RGB_VAI, RGB_HUI, KC_ENT, // forward + RGB_TOG, KC_NO, KC_NO, KC_NO , KC_DOWN, // down + EE_CLR, RGB_SAD, RGB_VAD, RGB_HUD, KC_LEFT, // back 2 + QK_BOOT, AUTORUN, JOYMODE, KC_V, KC_UP, // back 1 + RGB_MOD, TO(0), KC_NO, RGB_RMOD, KC_P // special + // ^side_l | ^case | ^thumb | ^side_r | ^analog click <= special row mapping + ) +}; + +//////////// Change modes on keypress ////////////// +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + if (keycode == JOYMODE && record->event.pressed) { + if (!controller_state.wasdMode) { + controller_state.wasdMode = true; + } else if (controller_state.wasdMode && !controller_state.wasdShiftMode) { + controller_state.wasdShiftMode = true; + } else { + controller_state.wasdMode = false; + controller_state.wasdShiftMode = false; + } + } else if (keycode == AUTORUN && record->event.pressed) { + if (!controller_state.autoRun) { + controller_state.autoRun = true; + register_code(KC_W); + } else { + controller_state.autoRun = false; + unregister_code(KC_W); + } + } + return true; +}; + +//////////// Draw OLED menu ////////////// +#ifdef OLED_ENABLE +bool oled_task_user(void) { + draw_oled(controller_state); + + return false; +} +#endif + +//////////// Handle layer changes ////////////// +layer_state_t layer_state_set_user(layer_state_t state) { + controller_state.activeLayer = get_highest_layer(state) ; + + #ifdef LEDS_ENABLE + set_leds(controller_state.activeLayer) ; + #endif + + return state ; +} diff --git a/keyboards/handwired/replicazeron/keymaps/via/readme.md b/keyboards/handwired/replicazeron/keymaps/via/readme.md new file mode 100644 index 00000000000..fe720791ee3 --- /dev/null +++ b/keyboards/handwired/replicazeron/keymaps/via/readme.md @@ -0,0 +1,2 @@ +# Replicazeron Gamepad - via layout +VIA layout with 2 axies thumbstick diff --git a/keyboards/handwired/replicazeron/keymaps/via/rules.mk b/keyboards/handwired/replicazeron/keymaps/via/rules.mk new file mode 100644 index 00000000000..a7dae39d5c9 --- /dev/null +++ b/keyboards/handwired/replicazeron/keymaps/via/rules.mk @@ -0,0 +1,16 @@ +VIA_ENABLE = yes +ifeq ($(strip $(LEDS_ENABLE)), yes) + OPT_DEFS += -DLEDS_ENABLE + SRC += ../common/leds.c +endif + +ifeq ($(strip $(OLED_ENABLE)), yes) + SRC += ../common/oled.c +endif + +ifeq ($(strip $(THUMBSTICK_ENABLE)), yes) +# POINTING_DEVICE_ENABLE = yes + OPT_DEFS += -DTHUMBSTICK_ENABLE + SRC += analog.c + SRC += ../common/thumbstick.c +endif diff --git a/keyboards/handwired/replicazeron/promicro/config.h b/keyboards/handwired/replicazeron/promicro/config.h new file mode 100644 index 00000000000..5d343fe8d93 --- /dev/null +++ b/keyboards/handwired/replicazeron/promicro/config.h @@ -0,0 +1,55 @@ +/* Copyright 2023 9R + * + * 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 5 + +/* joystick configuration */ +#define JOYSTICK_BUTTON_COUNT 0 +#define JOYSTICK_AXIS_COUNT 2 +#define JOYSTICK_AXIS_RESOLUTION 10 + + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCE 5 + + +/* Locking resynchronize hack */ +#define LOCKING_RESYNC_ENABLE + +////////////////////////////// + +#define DYNAMIC_KEYMAP_LAYER_COUNT 4 + +#define STATUS_LED_A_PIN D2 +#define STATUS_LED_B_PIN D3 + + +#ifdef RGBLIGHT_ENABLE +#define RGB_DI_PIN B14 +#define RGBLED_NUM 6 +#define RGBLIGHT_EFFECT_BREATHING +#define RGBLIGHT_EFFECT_KNIGHT +#define RGBLIGHT_EFFECT_RAINBOW_MOOD +#define RGBLIGHT_EFFECT_RAINBOW_SWIRL +#define RGBLIGHT_EFFECT_RGB_TEST +#define RGBLIGHT_EFFECT_TWINKLE +#endif + +#define THUMBSTICK_DEBUG diff --git a/keyboards/handwired/replicazeron/promicro/info.json b/keyboards/handwired/replicazeron/promicro/info.json new file mode 100644 index 00000000000..d01cc06ae11 --- /dev/null +++ b/keyboards/handwired/replicazeron/promicro/info.json @@ -0,0 +1,9 @@ +{ + "matrix_pins": { + "cols": [ "C6", "D4", "D7", "E6", "F7" ], + "rows": [ "B1", "B3", "B2", "B6", "B5", "B4" ] + }, + "diode_direction": "COL2ROW", + "processor": "atmega32u4", + "bootloader": "qmk-dfu" +} diff --git a/keyboards/handwired/replicazeron/promicro/promicro.c b/keyboards/handwired/replicazeron/promicro/promicro.c new file mode 100644 index 00000000000..429ea3a80a2 --- /dev/null +++ b/keyboards/handwired/replicazeron/promicro/promicro.c @@ -0,0 +1,25 @@ +/* Copyright 2023 9R + * + * 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 "promicro.h" + +void keyboard_post_init_user(void) { + // Customise these values to desired behaviour + debug_enable=true; + debug_matrix=true; + //debug_keyboard=true; + //debug_mouse=true; +} diff --git a/keyboards/handwired/replicazeron/promicro/promicro.h b/keyboards/handwired/replicazeron/promicro/promicro.h new file mode 100644 index 00000000000..dbcefe90a4b --- /dev/null +++ b/keyboards/handwired/replicazeron/promicro/promicro.h @@ -0,0 +1,17 @@ +/* Copyright 2023 9R + * + * 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" diff --git a/keyboards/handwired/replicazeron/promicro/rules.mk b/keyboards/handwired/replicazeron/promicro/rules.mk new file mode 100644 index 00000000000..0cefe1db78f --- /dev/null +++ b/keyboards/handwired/replicazeron/promicro/rules.mk @@ -0,0 +1,29 @@ +# Build Options +# change yes to no to disable +# +BOOTMAGIC_ENABLE = no # Enable Bootmagic Lite +MOUSEKEY_ENABLE = no # Mouse keys +EXTRAKEY_ENABLE = no # Audio control and System control +CONSOLE_ENABLE = no # Console for debug +COMMAND_ENABLE = no # Commands for debug and configuration +NKRO_ENABLE = no # Enable N-Key Rollover +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow +AUDIO_ENABLE = no # Audio output +TAP_DANCE_ENABLE = no # Tap Dance + +JOYSTICK_ENABLE = yes +JOYSTICK_DRIVER = analog + +OLED_ENABLE = yes +OLED_DRIVER = SSD1306 +LTO_ENABLE = yes + +########## + +QMK_SETTINGS = yes + +LEDS_ENABLE = yes +THUMBSTICK_ENABLE = yes + +SRC += ../common/state.c diff --git a/keyboards/handwired/replicazeron/readme.md b/keyboards/handwired/replicazeron/readme.md new file mode 100644 index 00000000000..824019af718 --- /dev/null +++ b/keyboards/handwired/replicazeron/readme.md @@ -0,0 +1,69 @@ + +# Replicazeron + +This is a config to run a 3dprinted keyboard controller with qmk based on this project: + +https://sites.google.com/view/alvaro-rosati/azeron-keypad-diy-tutorial + +Some additional and redesigned files (i.e. for the OLED-display) can be found here: + +https://github.com/9R/replicazeron + +![Replicazeron](https://github.com/9R/replicazeron/blob/main/images/replicazeron.JPG?raw=true) + +## Features + + * 23 keys + * analog stick with WASD emulation + * 5way dpad + * 2 status LEDS + * 6x WS2812 RGB-LED lighting + +## Supported MCUs + +Currently configs for STM32F103 and atmega32U4 are available, but STM32 is recommended, since the atmega may run out of flash with all features enabled. + +With minor adjustments to Pinconfig it should be possible to use other MCUs that are supported by QMK + + +## Wirering + +Full schematics can be found in this repo: + +https://github.com/9R/replicazeron_schematics + +### Rows +|row| promiro gpios | promicro pin | stm32F103 gpios | color | +---------------------------------------------------------------- +| 0 | B1 | 15 | B15 | red | +| 1 | B3 | 14 | A8 | blue | +| 2 | B2 | 16 | A9 | yellow | +| 3 | B6 | 10 | A10 | brown | +| 4 | B5 | 9 | A15 | orange | +| 5 | B4 | 8 | B3 | green | + +### Columns +|col| promiro gpios | promicro pin | stm32F103 gpios | color | +---------------------------------------------------------------- +| 0 | C6 | 5 | A7 | white | +| 1 | D4 | 4 | A6 | grey | +| 2 | D7 | 6 | A5 | violet | +| 3 | E6 | 7 | A4 | grey | +| 4 | F7 | A0 | B4 | white | + +### Analog +| promicro gpio | stm32F103 gpio | pin | color | +------------------------------------------------ +| GND | GND | GND | white | +| VCC | VCC | VCC | red | +| F4 | B1 | VRx | brown | +| F5 | B0 | VRy | yellow| +| | | SW | blue | + +### OLED +| promicro gpio | stm32F103 gpio | pin | color | +------------------------------------------------ +| GND | GND | GND | white | +| VCC | VCC | VCC | red | +| D4 | B10 | SDA | green | +| C6 | B11 | SCL | yellow| diff --git a/keyboards/handwired/replicazeron/stm32f103/config.h b/keyboards/handwired/replicazeron/stm32f103/config.h new file mode 100644 index 00000000000..2756b6bc107 --- /dev/null +++ b/keyboards/handwired/replicazeron/stm32f103/config.h @@ -0,0 +1,57 @@ +/* Copyright 2023 9R + * + * 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 5 + +/* joystick configuration */ +#define JOYSTICK_BUTTON_COUNT 0 +#define JOYSTICK_AXIS_COUNT 2 +#define JOYSTICK_AXIS_RESOLUTION 10 + + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCE 5 + +/* Use I2C2 */ +#define I2C_DRIVER I2CD2 + +#define I2C1_SDA_PIN B11 +#define I2C1_SCL_PIN B10 + +/* Locking resynchronize hack */ +#define LOCKING_RESYNC_ENABLE + +////////////////////////////// + +#define DYNAMIC_KEYMAP_LAYER_COUNT 4 + +#define STATUS_LED_A_PIN B13 +#define STATUS_LED_B_PIN B12 + +#define RGB_DI_PIN B14 +#define RGBLED_NUM 6 +#define RGBLIGHT_EFFECT_BREATHING +#define RGBLIGHT_EFFECT_KNIGHT +#define RGBLIGHT_EFFECT_RAINBOW_MOOD +#define RGBLIGHT_EFFECT_RAINBOW_SWIRL +#define RGBLIGHT_EFFECT_RGB_TEST +#define RGBLIGHT_EFFECT_TWINKLE + +#define THUMBSTICK_DEBUG diff --git a/keyboards/handwired/replicazeron/stm32f103/halconf.h b/keyboards/handwired/replicazeron/stm32f103/halconf.h new file mode 100644 index 00000000000..c167ddaa100 --- /dev/null +++ b/keyboards/handwired/replicazeron/stm32f103/halconf.h @@ -0,0 +1,27 @@ +/* Copyright 2023 9R + * + * 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 + +//enable i2c +#define HAL_USE_I2C TRUE + +#define HAL_USE_PWM TRUE + +//enable adc +#define HAL_USE_ADC TRUE + +#include_next diff --git a/keyboards/handwired/replicazeron/stm32f103/info.json b/keyboards/handwired/replicazeron/stm32f103/info.json new file mode 100644 index 00000000000..66cb6d14b2f --- /dev/null +++ b/keyboards/handwired/replicazeron/stm32f103/info.json @@ -0,0 +1,9 @@ +{ + "matrix_pins": { + "cols": ["A7", "A6", "A5", "A4", "B4"], + "rows": [ "B15", "A8", "A9", "A10", "A15", "B3" ] + }, + "diode_direction": "COL2ROW", + "processor": "STM32F103", + "bootloader": "stm32duino" +} diff --git a/keyboards/handwired/replicazeron/stm32f103/mcuconf.h b/keyboards/handwired/replicazeron/stm32f103/mcuconf.h new file mode 100644 index 00000000000..26db5392cfc --- /dev/null +++ b/keyboards/handwired/replicazeron/stm32f103/mcuconf.h @@ -0,0 +1,31 @@ +/* Copyright 2022 9R + * + * 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_next + +//enable i2c for OLED +#undef STM32_I2C_USE_I2C2 +#define STM32_I2C_USE_I2C2 TRUE + +#undef STM32_PWM_USE_TIM1 +#define STM32_PWM_USE_TIM1 TRUE + +//enable ADC for thumbstick +#undef STM32_ADC_USE_ADC1 +#define STM32_ADC_USE_ADC1 TRUE + diff --git a/keyboards/handwired/replicazeron/stm32f103/rules.mk b/keyboards/handwired/replicazeron/stm32f103/rules.mk new file mode 100644 index 00000000000..988e0669f22 --- /dev/null +++ b/keyboards/handwired/replicazeron/stm32f103/rules.mk @@ -0,0 +1,33 @@ +# 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 = yes # 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 = yes # Enable keyboard RGB underglow +AUDIO_ENABLE = no # Audio output +TAP_DANCE_ENABLE = no # Tap Dance + +JOYSTICK_ENABLE = yes +JOYSTICK_DRIVER = analog + +OLED_ENABLE = yes +OLED_DRIVER = SSD1306 +OLED_BRIGHTNESS = 32 +LTO_ENABLE = yes + +# Enter lower-power sleep mode when on the ChibiOS idle thread +OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE + +########## + +QMK_SETTINGS = yes + +LEDS_ENABLE = yes +THUMBSTICK_ENABLE = yes + +SRC += ../common/state.c diff --git a/keyboards/handwired/replicazeron/stm32f103/stm32f103.c b/keyboards/handwired/replicazeron/stm32f103/stm32f103.c new file mode 100644 index 00000000000..2939706a353 --- /dev/null +++ b/keyboards/handwired/replicazeron/stm32f103/stm32f103.c @@ -0,0 +1,25 @@ +/* Copyright 2023 9R + * + * 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 "stm32f103.h" + +void keyboard_post_init_user(void) { + // Customise these values to desired behaviour + debug_enable=true; + debug_matrix=true; + //debug_keyboard=true; + //debug_mouse=true; +} diff --git a/keyboards/handwired/replicazeron/stm32f103/stm32f103.h b/keyboards/handwired/replicazeron/stm32f103/stm32f103.h new file mode 100644 index 00000000000..dbcefe90a4b --- /dev/null +++ b/keyboards/handwired/replicazeron/stm32f103/stm32f103.h @@ -0,0 +1,17 @@ +/* Copyright 2023 9R + * + * 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"