Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/vial' into elora
Browse files Browse the repository at this point in the history
  • Loading branch information
VeyPatch committed Dec 17, 2024
2 parents 7be3e4b + d2e952e commit 98f6bf3
Show file tree
Hide file tree
Showing 99 changed files with 5,716 additions and 68 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

steps:
- name: (actions) Checkout Vial repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
persist-credentials: false

Expand All @@ -28,13 +28,13 @@ jobs:
build-default:
name: Build default keymaps for Vial
runs-on: ubuntu-latest
container: ghcr.io/qmk/qmk_cli
container: ghcr.io/qmk/qmk_cli@sha256:16c4916e95b99bf88d27b15aec8db409ee17265d1710287fde248c6666508966
env:
KEYMAP: default

steps:
- name: (actions) Checkout Vial repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
persist-credentials: false
submodules: recursive
Expand Down Expand Up @@ -66,13 +66,13 @@ jobs:
build-vial:
name: Build Vial keymaps
runs-on: ubuntu-latest
container: ghcr.io/qmk/qmk_cli
container: ghcr.io/qmk/qmk_cli@sha256:16c4916e95b99bf88d27b15aec8db409ee17265d1710287fde248c6666508966
env:
KEYMAP: vial

steps:
- name: (actions) Checkout Vial repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
persist-credentials: false
submodules: recursive
Expand Down
43 changes: 43 additions & 0 deletions keyboards/handwired/replicazeron/common/leds.c
Original file line number Diff line number Diff line change
@@ -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);
}
23 changes: 23 additions & 0 deletions keyboards/handwired/replicazeron/common/leds.h
Original file line number Diff line number Diff line change
@@ -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);
96 changes: 96 additions & 0 deletions keyboards/handwired/replicazeron/common/oled.c
Original file line number Diff line number Diff line change
@@ -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);
}
34 changes: 34 additions & 0 deletions keyboards/handwired/replicazeron/common/oled.h
Original file line number Diff line number Diff line change
@@ -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);
28 changes: 28 additions & 0 deletions keyboards/handwired/replicazeron/common/state.c
Original file line number Diff line number Diff line change
@@ -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;
}
28 changes: 28 additions & 0 deletions keyboards/handwired/replicazeron/common/state.h
Original file line number Diff line number Diff line change
@@ -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);
Loading

0 comments on commit 98f6bf3

Please sign in to comment.