From 9fc2810eff57ad97bac7fa259ac275f0c6f48ccb Mon Sep 17 00:00:00 2001 From: Thomas Haukland Date: Sat, 23 Mar 2024 21:52:01 +0100 Subject: [PATCH] Support ENCODER_RESOLUTION and update to latest qmk Note: my qmk 1.1.2 didnt compile, but went fine after updating to 1.1.5 --- keyboards/cheapino/config.h | 26 +++++--------------- keyboards/cheapino/encoder.c | 25 +++++++++++++++---- keyboards/cheapino/keymaps/tompi/keymap.json | 6 ++--- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/keyboards/cheapino/config.h b/keyboards/cheapino/config.h index 16280659f2b..b7568aa16e5 100644 --- a/keyboards/cheapino/config.h +++ b/keyboards/cheapino/config.h @@ -3,35 +3,21 @@ #pragma once -/* - * Feature disable options - * These options are also useful to firmware size reduction. - */ - -/* disable debug print */ -//#define NO_DEBUG - -/* disable print */ -//#define NO_PRINT - -/* disable action features */ -//#define NO_ACTION_LAYER -//#define NO_ACTION_TAPPING -//#define NO_ACTION_ONESHOT #define BOTH_SHIFTS_TURNS_ON_CAPS_WORD + #define WS2812_PIO_USE_PIO1 // Force the usage of PIO1 peripheral, by default the WS2812 implementation uses the PIO0 peripheral -//#define WS2812_TRST_US 80 #define WS2812_BYTE_ORDER WS2812_BYTE_ORDER_RGB #define RGB_MATRIX_DEFAULT_VAL 32 - -// Pick good defaults for enabling homerow modifiers +// Pick good defaults for enabling home-row modifiers #define TAPPING_TERM 230 #define WS2812_DI_PIN GP16 // The pin connected to the data pin of the LEDs - #define RGBLED_NUM 1 // The number of LEDs connected - +#define RGBLIGHT_LED_COUNT 1 // The number of LEDs connected #define MAX_DEFERRED_EXECUTORS 32 + +// How many "tents" should you turn per action +#define ENCODER_RESOLUTION 1 diff --git a/keyboards/cheapino/encoder.c b/keyboards/cheapino/encoder.c index bcaa86010ef..00f059c49f8 100644 --- a/keyboards/cheapino/encoder.c +++ b/keyboards/cheapino/encoder.c @@ -1,24 +1,39 @@ #include "matrix.h" +#include "rgblight.h" #include "quantum.h" #define COL_SHIFTER ((uint16_t)1) static bool colABpressed = false; static bool encoderPressed = false; +static uint16_t turns = 0; +static bool last_turn_clockwise; void clicked(void) { tap_code(KC_MPLY); } void turned(bool clockwise) { - if (IS_LAYER_ON(6)) { - tap_code(clockwise ? KC_VOLU : KC_VOLD); + if (clockwise != last_turn_clockwise) { + // Switched way, reset counter + last_turn_clockwise = clockwise; + turns = 0; + } + turns++; + if (!(turns%ENCODER_RESOLUTION == 0)) { + return; + } + + if (IS_LAYER_ON(4)) { + // clockwise ? rgb_matrix_decrease() : rgb_matrix_increase(); } else if (IS_LAYER_ON(3)) { + tap_code(clockwise ? KC_VOLU : KC_VOLD); + } else if (IS_LAYER_ON(2)) { tap_code16(clockwise ? LCTL(KC_TAB) : LCTL(LSFT(KC_TAB))); - } else if (IS_LAYER_ON(5)) { - tap_code(clockwise ? KC_MS_WH_DOWN : KC_MS_WH_UP); + } else if (IS_LAYER_ON(1)) { + tap_code(clockwise ? KC_PGDN : KC_PGUP); } else { - tap_code16(clockwise ? LGUI(KC_Y) : LGUI(KC_Z)); + tap_code(clockwise ? KC_WH_D : KC_WH_U); } } diff --git a/keyboards/cheapino/keymaps/tompi/keymap.json b/keyboards/cheapino/keymaps/tompi/keymap.json index 4dcd3c7f266..d9803dbf244 100644 --- a/keyboards/cheapino/keymaps/tompi/keymap.json +++ b/keyboards/cheapino/keymaps/tompi/keymap.json @@ -39,8 +39,8 @@ "KC_SLSH", "LT(6,KC_ESC)", "LT(3,KC_SPC)", - "LT(3,KC_TAB)", - "LT(2,KC_NO)", + "LT(5,KC_TAB)", + "LT(1,KC_DEL)", "LT(2,KC_BSPC)", "LT(4,KC_ENT)" ], @@ -274,4 +274,4 @@ ] ], "author": "thomas.haukland@gmail.com" -} \ No newline at end of file +}