pull/20108/merge
9R 2024-10-15 21:51:24 +01:00 committed by GitHub
commit dfc4f66eba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 931 additions and 0 deletions

View File

@ -0,0 +1,43 @@
/* 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 <http://www.gnu.org/licenses/>.
*/
#include "leds.h"
#include <stdbool.h>
#include "gpio.h"
//////////// Status LEDs //////////////
void init_leds(void) {
// Both LEDs off, they have inverted logic
gpio_set_pin_output(STATUS_LED_A_PIN);
gpio_set_pin_output(STATUS_LED_B_PIN);
gpio_write_pin_high(STATUS_LED_A_PIN);
gpio_write_pin_high(STATUS_LED_B_PIN);
}
void set_leds(uint8_t highest_active_layer) {
// any layer other than 0-3, quit and LEDs off
if (highest_active_layer > 3) {
gpio_write_pin_high(STATUS_LED_A_PIN);
gpio_write_pin_high(STATUS_LED_B_PIN);
return;
}
// use bitwise operations to display active layer in binary
bool bit1 = !(highest_active_layer & 1);
bool bit2 = !(highest_active_layer & 2);
gpio_write_pin(STATUS_LED_A_PIN, bit1);
gpio_write_pin(STATUS_LED_B_PIN, bit2);
}

View File

@ -0,0 +1,23 @@
/* 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdint.h>
void init_leds(void);
void set_leds(uint8_t active_layer);

View File

@ -0,0 +1,96 @@
/* 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 <http://www.gnu.org/licenses/>.
*/
#include "oled.h"
#include "oled_driver.h"
#include "progmem.h"
#include "util.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 (uint8_t i = 0 ; i < ARRAY_SIZE(keystates); ++i) {
if (keystates[i]) {
char k = keys[i] ;
//bitshift char to upper case
if (wasd_state.shift) {
k &= ~shiftbits;
}
oled_write_char(k, 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);
oled_write(get_u16_str(thumbstick_polar_position.angle, ' '), false);
oled_write_P(PSTR(" Dist:"), false);
oled_write_ln(get_u16_str(thumbstick_polar_position.distance, ' '), 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.highestActiveLayer) {
case _SHOOTER:
oled_write_ln_P(PSTR("Shooter"), false);
break;
case _MISC:
oled_write_ln_P(PSTR("Misc"), false);
break;
case _SETTINGS:
oled_write_ln_P(PSTR("Settings"), false);
break;
default:
oled_write_ln_P(PSTR("Default"), false);
}
draw_mode(controller_state);
if (controller_state.highestActiveLayer == _SETTINGS ) {
draw_thumb_debug(thumbstick_polar_position);
}
else {
oled_write_ln_P(PSTR(" "), false);
}
oled_write_ln_P(PSTR(" "), false);
}

View File

@ -0,0 +1,34 @@
/* 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "replicazeron.h"
#include <stdint.h>
#include "state.h"
#include "thumbstick.h"
uint8_t shiftbits;
char stringbuffer[8];
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);

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include "state.h"
controller_state_t init_state (void) {
controller_state_t controller_state = {
.wasdMode = true,
.wasdShiftMode = false,
.autoRun = false,
.highestActiveLayer = 0,
};
return controller_state;
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdbool.h>
#include <stdint.h>
typedef struct {
bool wasdMode;
bool wasdShiftMode;
bool autoRun;
uint8_t highestActiveLayer;
} controller_state_t;
controller_state_t init_state(void);

View File

@ -0,0 +1,111 @@
/* 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 <http://www.gnu.org/licenses/>.
*/
#include "thumbstick.h"
#include <math.h>
#include "action.h"
#include "keycode.h"
#include "debug.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(int16_t x, int16_t y) {
static thumbstick_polar_position_t position;
#ifdef THUMBSTICK_DEBUG
dprintf("xN: %4d yN: %4d\n", x, y);
#endif
//transform to carthesian coordinates to polar coordinates
//get distance from center as int in range [0-600]
position.distance = (double)sqrt((double)x * (double)x + (double)y * (double)y);
//get direction as int in range [0 to 359]
position.angle = (double)atan2(y, x) * (180 /M_PI) + 180;
//apply thumbstick rotation const to modify forward direction
position.angle = (position.angle + _THUMBSTICK_ROTATION) % 360;
return position;
}
bool update_keystate(uint16_t angle_from, uint16_t angle_to, uint16_t angle) {
return (angle_from < angle && angle <= angle_to);
}
void update_keycode(uint16_t keycode, bool keystate, bool last_keystate) {
if (keystate && keystate != last_keystate) {
register_code16(keycode);
} else if (!keystate) {
unregister_code16(keycode);
}
}
void thumbstick(controller_state_t controller_state) {
xPos = joystick_state.axes[0];
yPos = joystick_state.axes[1];
thumbstick_polar_position = get_thumbstick_polar_position(xPos, yPos);
#ifdef THUMBSTICK_DEBUG
dprintf("distance: %5d angle: %5d\n", thumbstick_polar_position.distance, thumbstick_polar_position.angle);
#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( 0, 90, thumbstick_polar_position.angle);
// A angle: 45 - 180
wasd_state.a = update_keystate( 45, 181, thumbstick_polar_position.angle);
// S angle: 135 - 270
wasd_state.s = update_keystate(135, 270, thumbstick_polar_position.angle);
// D angle: 225 - 359
wasd_state.d = update_keystate(225, 359, thumbstick_polar_position.angle);
if (!wasd_state.w ) {
wasd_state.w = update_keystate(315, 360, thumbstick_polar_position.angle);
}
} else {
//reset WASD state when in _DEADZONE
init_wasd_state();
}
#ifdef THUMBSTICK_DEBUG
dprintf("w: %2d a: %2d s: %2d d: %2d\n", wasd_state.w, wasd_state.a, wasd_state.s, wasd_state.d);
#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;
}
}
}

View File

@ -0,0 +1,51 @@
/* 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdint.h>
#include "state.h"
#include "quantum.h"
int16_t xPos;
int16_t yPos;
typedef struct {
uint16_t angle;
uint16_t 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(int16_t x, int16_t y);
bool update_keystate(uint16_t angle_from, uint16_t angle_to, uint16_t angle);
void update_keycode(uint16_t keycode, bool keystate, bool last_keystate);
void thumbstick(controller_state_t controller_state);

View File

@ -0,0 +1,31 @@
/* 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#define THUMBSTICK_DEBUG
/* joystick configuration */
#define JOYSTICK_BUTTON_COUNT 0
#define JOYSTICK_AXIS_COUNT 2
#define JOYSTICK_AXIS_RESOLUTION 10
#define _DEADZONE 100 // 0 to _SHIFTZONE-1
#define _SHIFTZONE 350 // _DEADZONE+1 to 600
#define _THUMBSTICK_ROTATION 100 //degrees, adjusts forward direction
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE

View File

@ -0,0 +1,47 @@
{
"manufacturer": "9R",
"keyboard_name": "Replicazeron",
"maintainer": "9R",
"diode_direction": "COL2ROW",
"url": "https://github.com/9R/replicazeron",
"usb": {
"pid": "0x2305",
"vid": "0x4142"
},
"layouts": {
"LAYOUT": {
"layout": [
{"label": "K04", "matrix": [0, 0], "x": 1.75, "y": 0.25, "w": 1.25},
{"label": "K10", "matrix": [0, 1], "x": 3, "y": 0.25, "w": 1.25},
{"label": "K16", "matrix": [0, 2], "x": 4.25, "y": 0.25, "w": 1.25},
{"label": "K22", "matrix": [0, 3], "x": 5.5, "y": 0.25, "w": 1.25},
{"label": "dwn", "matrix": [0, 4], "x": 9.5, "y": 2, "w": 1.25},
{"label": "K03", "matrix": [1, 0], "x": 1.75, "y": 1, "w": 1.25, "h": 1.25},
{"label": "K09", "matrix": [1, 1], "x": 3, "y": 1, "w": 1.25, "h": 1.25},
{"label": "K15", "matrix": [1, 2], "x": 4.25, "y": 1, "w": 1.25, "h": 1.25},
{"label": "K21", "matrix": [1, 3], "x": 5.5, "y": 1, "w": 1.25, "h": 1.25},
{"label": "lft", "matrix": [1, 4], "x": 8.25, "y": 1, "w": 1.25},
{"label": "K02", "matrix": [2, 0], "x": 1.75, "y": 2.5, "w": 1.25, "h": 1.25},
{"label": "K08", "matrix": [2, 1], "x": 3, "y": 2.5, "w": 1.25, "h": 1.25},
{"label": "K14", "matrix": [2, 2], "x": 4.25, "y": 2.5, "w": 1.25, "h": 1.25},
{"label": "K20", "matrix": [2, 3], "x": 5.5, "y": 2.5, "w": 1.25, "h": 1.25},
{"label": "ent", "matrix": [2, 4], "x": 9.5, "y": 1, "w": 1.25},
{"label": "K01", "matrix": [3, 0], "x": 1.75, "y": 3.75, "w": 1.25},
{"label": "K07", "matrix": [3, 1], "x": 3, "y": 3.75, "w": 1.25},
{"label": "K13", "matrix": [3, 2], "x": 4.25, "y": 3.75, "w": 1.25},
{"label": "K19", "matrix": [3, 3], "x": 5.5, "y": 3.75, "w": 1.25},
{"label": "rgt", "matrix": [3, 4], "x": 10.75, "y": 1, "w": 1.25},
{"label": "K00", "matrix": [4, 0], "x": 1.75, "y": 4.75, "w": 1.25},
{"label": "K06", "matrix": [4, 1], "x": 3, "y": 4.75, "w": 1.25},
{"label": "K12", "matrix": [4, 2], "x": 4.25, "y": 4.75, "w": 1.25},
{"label": "K18", "matrix": [4, 3], "x": 5.5, "y": 4.75, "w": 1.25},
{"label": "up ", "matrix": [4, 4], "x": 9.5, "y": 0, "w": 1.25},
{"label": "K05", "matrix": [5, 0], "x": 0, "y": 2.5, "w": 1.75},
{"label": "lyr", "matrix": [5, 1], "x": 7.5, "y": 4.25, "w": 1.5},
{"label": "K17", "matrix": [5, 2], "x": 10.75, "y": 4, "w": 1.5},
{"label": "K23", "matrix": [5, 3], "x": 6.75, "y": 2.5, "w": 1.5},
{"label": "spc", "matrix": [5, 4], "x": 10.75, "y": 3, "w": 1.25}
]
}
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include QMK_KEYBOARD_H
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_BASE] = 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(_SHOOTER), KC_I, KC_B, KC_P // special
// ^side_l | ^case | ^thumb | ^side_r | ^analog click <= special row mapping
),
[_SHOOTER] = LAYOUT(
KC_NO, KC_NO, KC_NO, KC_NO, KC_RIGHT,
KC_NO, KC_NO, KC_NO, KC_NO, KC_ENT,
KC_NO, KC_NO, KC_NO, KC_NO, KC_DOWN,
KC_NO, KC_NO, KC_NO, KC_NO, KC_LEFT,
KC_NO, KC_NO, KC_NO, KC_NO, KC_UP,
KC_NO, TG(_MISC), KC_NO, KC_NO, KC_P
),
[_MISC] = LAYOUT(
KC_NO, KC_NO, KC_NO, KC_NO, KC_RIGHT,
KC_NO, KC_NO, KC_NO, KC_NO, KC_ENT,
KC_NO, KC_NO, KC_NO, KC_NO, KC_DOWN,
KC_NO, KC_NO, KC_NO, KC_NO, KC_LEFT,
KC_NO, KC_NO, KC_NO, KC_NO, KC_UP,
KC_NO, TG(_SETTINGS), KC_NO, KC_NO, KC_P
),
[_SETTINGS] = LAYOUT(
RGB_M_P, RGB_M_B, RGB_M_K, RGB_M_T, KC_RIGHT,
KC_NO, RGB_SAI, RGB_VAI, RGB_HUI, KC_ENT,
RGB_TOG, KC_NO, KC_NO, KC_NO , KC_DOWN,
EE_CLR, RGB_SAD, RGB_VAD, RGB_HUD, KC_LEFT,
QK_BOOT, AUTORUN, JOYMODE, KC_V, KC_UP,
RGB_MOD, TO(_BASE), KC_NO, RGB_RMOD, KC_P
)
};

View File

@ -0,0 +1,14 @@
ifeq ($(strip $(LEDS_ENABLE)), yes)
OPT_DEFS += -DLEDS_ENABLE
SRC += leds.c
endif
ifeq ($(strip $(OLED_ENABLE)), yes)
SRC += oled.c
endif
ifeq ($(strip $(THUMBSTICK_ENABLE)), yes)
OPT_DEFS += -DTHUMBSTICK_ENABLE
SRC += thumbstick.c
ANALOG_DRIVER_REQUIRED = yes
endif

View File

@ -0,0 +1,23 @@
/* 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#define STATUS_LED_A_PIN D2
#define STATUS_LED_B_PIN D3
#define ANALOG_AXIS_PIN_X F4
#define ANALOG_AXIS_PIN_Y F5

View File

@ -0,0 +1,18 @@
{
"usb": {
"device_version": "0.0.1"
},
"matrix_pins": {
"cols": ["C6", "D4", "D7", "E6", "F7"],
"rows": ["B1", "B3", "B2", "B6", "B5", "B4"]
},
"development_board": "promicro",
"features": {
"bootmagic": false,
"console": false,
"extrakey": false,
"mousekey": false,
"nkro": false,
"rgblight": false,
}
}

View File

@ -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 in [this repo](https://github.com/9R/replicazeron).
![Replicazeron](https://i.imgur.com/WTys4SM.jpg)
[Gallery](https://imgur.com/a/2qlEPVl)
## 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|

View File

@ -0,0 +1,103 @@
/* 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 <http://www.gnu.org/licenses/>.
*/
#include "replicazeron.h"
controller_state_t controller_state;
#ifdef JOYSTICK_ENABLE
joystick_config_t joystick_axes[JOYSTICK_AXIS_COUNT] = {
JOYSTICK_AXIS_IN(ANALOG_AXIS_PIN_X , 0, 512, 1023),
JOYSTICK_AXIS_IN(ANALOG_AXIS_PIN_Y , 0, 512, 1023)
};
#endif
#ifdef THUMBSTICK_ENABLE
void housekeeping_task_kb(void) {
if (controller_state.wasdMode) {
thumbstick(controller_state);
}
}
#endif
void keyboard_post_init_kb(void) {
// Customise these values to desired behaviour
debug_enable = true;
debug_matrix = true;
// debug_keyboard = true;
// debug_mouse = true;
#ifdef LEDS_ENABLE
init_leds();
#endif // LEDS_ENABLE
#ifdef THUMBSTICK_ENABLE
init_wasd_state();
#endif // THUMBSTICK_ENABLE
controller_state = init_state();
keyboard_post_init_user();
}
#ifdef OLED_ENABLE
bool oled_task_kb(void) {
if (!oled_task_user()) {
return false;
}
draw_oled(controller_state);
return false;
}
#endif
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
if (!process_record_user(keycode, record)) {
return false;
}
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;
};
layer_state_t layer_state_set_kb(layer_state_t state) {
state = layer_state_set_user(state);
controller_state.highestActiveLayer = get_highest_layer(state) ;
#ifdef LEDS_ENABLE
set_leds(controller_state.highestActiveLayer) ;
#endif // LEDS_ENABLE
return state;
}

View File

@ -0,0 +1,50 @@
/* 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "quantum.h"
#include "state.h"
#ifdef LEDS_ENABLE
# include "leds.h"
#endif
#ifdef OLED_ENABLE
# include "oled.h"
#endif
#ifdef THUMBSTICK_ENABLE
# include "thumbstick.h"
#endif
enum kb_layers {
_BASE,
_SHOOTER,
_MISC,
_SETTINGS,
};
enum kb_keycodes {
JOYMODE = QK_USER,
AUTORUN,
M_UP,
M_DWN,
M_L,
M_R,
M_SEL
};

View File

@ -0,0 +1,14 @@
JOYSTICK_ENABLE = yes
OLED_ENABLE = yes
LEDS_ENABLE = yes
THUMBSTICK_ENABLE = yes
LTO_ENABLE = yes
SRC += state.c
VPATH += keyboards/handwired/replicazeron/common
# redirect compilation against "handwired/replicazeron" to the stm32 variant
DEFAULT_FOLDER = handwired/replicazeron/stm32f103

View File

@ -0,0 +1,29 @@
/* 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
/* I2C Config */
#define I2C_DRIVER I2CD2
#define I2C1_SDA_PIN B11
#define I2C1_SCL_PIN B10
#define STATUS_LED_A_PIN B13
#define STATUS_LED_B_PIN B12
#define ANALOG_AXIS_PIN_X B0
#define ANALOG_AXIS_PIN_Y B1

View File

@ -0,0 +1,31 @@
{
"development_board": "bluepill",
"features": {
"bootmagic": true,
"console": true,
"extrakey": true,
"mousekey": true,
"nkro": true,
"rgblight": true
},
"matrix_pins": {
"cols": ["A7", "A6", "A5", "A4", "B4"],
"rows": ["B15", "A8", "A9", "A10", "A15", "B3"]
},
"rgblight": {
"led_count": 6
"animations": {
"breathing": true,
"knight": true,
"rainbow_mood": true,
"rainbow_swirl": true,
"twinkle": true
}
},
"usb": {
"device_version": "0.0.2"
},
"ws2812": {
"pin": "B14"
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include_next <mcuconf.h>
//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