summaryrefslogtreecommitdiff
path: root/keyboards/winry/winry315
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/winry/winry315')
-rw-r--r--keyboards/winry/winry315/config.h11
-rw-r--r--keyboards/winry/winry315/info.json7
-rw-r--r--keyboards/winry/winry315/keymaps/via/encoder_actions.c16
3 files changed, 12 insertions, 22 deletions
diff --git a/keyboards/winry/winry315/config.h b/keyboards/winry/winry315/config.h
index f093f88b95..620a7f6e6b 100644
--- a/keyboards/winry/winry315/config.h
+++ b/keyboards/winry/winry315/config.h
@@ -3,18 +3,7 @@
#pragma once
-// Encoder pins.
-// Encoder numbering (assuming the default board orientation with encoders on
-// the top side):
-// 0 - left
-// 1 - center (with a longer shaft and a larger knob)
-// 2 - right
-#define ENCODERS_PAD_A { F1, B0, B3 }
-#define ENCODERS_PAD_B { F0, B1, B7 }
-#define ENCODER_RESOLUTION 4
-
// Encoder mappings (used for VIA).
-#define ENCODERS 3
#define ENCODERS_CW_KEY { { 22, 0 }, { 18, 0 }, { 20, 0 } }
#define ENCODERS_CCW_KEY { { 23, 0 }, { 19, 0 }, { 21, 0 } }
diff --git a/keyboards/winry/winry315/info.json b/keyboards/winry/winry315/info.json
index 1b550c3122..4039d5aaf5 100644
--- a/keyboards/winry/winry315/info.json
+++ b/keyboards/winry/winry315/info.json
@@ -8,6 +8,13 @@
"pid": "0x0315",
"vid": "0xF1F1"
},
+ "encoder": {
+ "rotary": [
+ {"pin_a": "F1", "pin_b": "F0"},
+ {"pin_a": "B0", "pin_b": "B1"},
+ {"pin_a": "B3", "pin_b": "B7"}
+ ]
+ },
"processor": "atmega32u4",
"bootloader": "atmel-dfu",
"matrix_pins": {
diff --git a/keyboards/winry/winry315/keymaps/via/encoder_actions.c b/keyboards/winry/winry315/keymaps/via/encoder_actions.c
index 96dfe74bca..9a9092effd 100644
--- a/keyboards/winry/winry315/keymaps/via/encoder_actions.c
+++ b/keyboards/winry/winry315/keymaps/via/encoder_actions.c
@@ -27,11 +27,10 @@
# define ENCODER_STATE_CW 0x01
# define ENCODER_STATE_CCW 0x02
-# ifdef ENCODERS
-static uint8_t encoder_state[ENCODERS] = {0};
-static uint16_t encoder_timer[ENCODERS] = {0};
-static keypos_t encoder_cw[ENCODERS] = ENCODERS_CW_KEY;
-static keypos_t encoder_ccw[ENCODERS] = ENCODERS_CCW_KEY;
+static uint8_t encoder_state[NUM_ENCODERS] = {0};
+static uint16_t encoder_timer[NUM_ENCODERS] = {0};
+static keypos_t encoder_cw[NUM_ENCODERS] = ENCODERS_CW_KEY;
+static keypos_t encoder_ccw[NUM_ENCODERS] = ENCODERS_CCW_KEY;
static void exec_encoder_action(uint8_t index, bool clockwise, bool pressed) {
// clang-format off
@@ -43,22 +42,18 @@ static void exec_encoder_action(uint8_t index, bool clockwise, bool pressed) {
// clang-format on
action_exec(encoder_event);
}
-# endif
void encoder_action_unregister(void) {
-# ifdef ENCODERS
- for (int index = 0; index < ENCODERS; ++index) {
+ for (int index = 0; index < NUM_ENCODERS; ++index) {
if (encoder_state[index] && (timer_elapsed(encoder_timer[index]) >= ENCODER_TAP_DURATION_MS)) {
bool clockwise = !!(encoder_state[index] & ENCODER_STATE_CW);
encoder_state[index] = 0;
exec_encoder_action(index, clockwise, false);
}
}
-# endif
}
void encoder_action_register(uint8_t index, bool clockwise) {
-# ifdef ENCODERS
if (encoder_state[index]) {
bool was_clockwise = !!(encoder_state[index] & ENCODER_STATE_CW);
encoder_state[index] = 0;
@@ -67,7 +62,6 @@ void encoder_action_register(uint8_t index, bool clockwise) {
encoder_state[index] = clockwise ? ENCODER_STATE_CW : ENCODER_STATE_CCW;
encoder_timer[index] = timer_read();
exec_encoder_action(index, clockwise, true);
-# endif
}
void matrix_scan_kb(void) {