Browse Source

[Keyboard] Add Binepad KnobX1 (#25222)

Co-authored-by: Drashna Jaelre <drashna@live.com>
Silvino R. 1 year ago
parent
commit
bb2b7ce7e4

+ 69 - 0
keyboards/binepad/knobx1/keyboard.json

@@ -0,0 +1,69 @@
+{
+    "manufacturer": "Binepad",
+    "keyboard_name": "KnobX1",
+    "maintainer": "binepad",
+    "bootloader": "stm32duino",
+    "bootloader_instructions": "Hold down the layer button (small button on the bottom left) and plug in the keyboard.",
+    "diode_direction": "COL2ROW",
+    "eeprom": {
+        "wear_leveling": {
+            "backing_size": 1024
+        }
+    },
+    "encoder": {
+        "rotary": [
+            {"pin_a": "B12", "pin_b": "B13", "resolution": 2}
+        ]
+    },
+    "features": {
+        "bootmagic": true,
+        "encoder": true,
+        "extrakey": true,
+        "mousekey": true,
+        "rgblight": true
+    },
+    "matrix_pins": {
+        "direct": [
+            ["A7", "A15"]
+        ]
+    },
+    "processor": "STM32F103",
+    "rgblight": {
+        "animations": {
+            "alternating": true,
+            "breathing": true,
+            "christmas": true,
+            "gradient": true,
+            "knight": true,
+            "rainbow_mood": true,
+            "rainbow_swirl": true,
+            "snake": true,
+            "twinkle": true
+        },
+        "default": {
+            "hue": 198,
+            "speed": 2,
+            "val": 204
+        },
+        "driver": "ws2812",
+        "led_count": 2,
+        "sleep": true
+    },
+    "url": "https://binepad.com/products/knobx1",
+    "usb": {
+        "device_version": "1.0.0",
+        "pid": "0x4249",
+        "vid": "0x5831"
+    },
+    "ws2812": {
+        "pin": "C13"
+    },
+    "layouts": {
+        "LAYOUT": {
+            "layout": [
+                {"matrix": [0, 0], "x": 0, "y": 0},
+                {"matrix": [0, 1], "x": 1, "y": 0, "w": 3, "h": 3}
+            ]
+        }
+    }
+}

+ 22 - 0
keyboards/binepad/knobx1/keymaps/default/keymap.json

@@ -0,0 +1,22 @@
+{
+    "config": {
+        "features": {
+            "encoder_map": true
+        }
+    },
+    "encoders": [
+        [
+            {
+                "ccw": "KC_VOLD",
+                "cw": "KC_VOLU"
+            }
+        ]
+    ],
+    "keyboard": "binepad/knobx1",
+    "keymap": "default",
+    "layers": [
+        ["X1_LYRU", "KC_MUTE"]
+    ],
+    "layout": "LAYOUT",
+    "version": 1
+}

+ 76 - 0
keyboards/binepad/knobx1/knobx1.c

@@ -0,0 +1,76 @@
+// (c) 2025 Binepad (@binpad)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "knobx1.h"
+
+#ifdef DYNAMIC_KEYMAP_LAYER_COUNT
+#    define X1_KEYMAP_LAYER_COUNT DYNAMIC_KEYMAP_LAYER_COUNT
+#else
+#    define X1_KEYMAP_LAYER_COUNT 4
+#endif
+
+void keyboard_pre_init_kb(void) {
+    const pin_t indicator_leds[4] = {IND1_LED, IND2_LED, IND3_LED, IND4_LED};
+    for (int i = 0; i < 4; i++) {
+        gpio_set_pin_output(indicator_leds[i]); // Set Indicators as output
+        gpio_write_pin_low(indicator_leds[i]);  // Set initial indicator low / OFF
+    }
+
+    // Call the user pre-init function if needed
+    // Do it after ._kb incase the user wants to change pin stuff
+    keyboard_pre_init_user();
+}
+
+layer_state_t layer_state_set_kb(layer_state_t state) {
+    state         = layer_state_set_user(state);
+    uint8_t layer = get_highest_layer(state);
+    x1_layer_led(layer);
+    return state;
+}
+
+void matrix_init_kb(void) {
+    // Direct PINS use; gpio -> switch -> ground.
+    // Setting Row 0 to ground makes it work like a direct pin
+    gpio_set_pin_output(ROW0_PIN); // Set Col0 as an output
+    gpio_write_pin_low(ROW0_PIN);  // Set Col0 to low / ground
+
+    matrix_init_user();
+}
+
+bool process_x1_layer_up(keyrecord_t *record) {
+    if (record->event.pressed) {
+        uint8_t current_layer = get_highest_layer(layer_state);
+        // Cycle through layers
+        uint8_t next_layer    = (current_layer + 1) % X1_KEYMAP_LAYER_COUNT;
+        layer_move(next_layer);
+        x1_layer_led(next_layer); // Update LED indicators
+    }
+    return false;
+}
+
+bool process_x1_layer_down(keyrecord_t *record) {
+    if (record->event.pressed) {
+        uint8_t current_layer = get_highest_layer(layer_state);
+        // Reverse through layers
+        uint8_t prev_layer = (current_layer == 0) ? (X1_KEYMAP_LAYER_COUNT - 1) : (current_layer - 1);
+        layer_move(prev_layer);
+        x1_layer_led(prev_layer);
+    }
+    return false;
+}
+
+bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
+    if (!process_record_user(keycode, record)) {
+        return false;
+    }
+    switch (keycode) {
+        case X1_LAYER_SELECTOR_UP:
+            return process_x1_layer_up(record);
+
+        case X1_LAYER_SELECTOR_DOWN:
+            return process_x1_layer_down(record);
+
+        default:
+            return true;
+    }
+}

+ 49 - 0
keyboards/binepad/knobx1/knobx1.h

@@ -0,0 +1,49 @@
+// (c) 2025 Binepad (@binpad)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "quantum.h"
+
+// PCB has a 1x2 matrix. Set the ROW0 to ground for faster direct pin access.
+#define ROW0_PIN B8
+
+#define IND1_LED A6
+#define IND2_LED A5
+#define IND3_LED A4
+#define IND4_LED A3
+
+// clang-format off
+enum x1_keycodes {
+    X1_LAYER_SELECTOR_UP = QK_USER,
+    X1_LAYER_SELECTOR_DOWN
+};
+// clang-format on
+
+#define X1_LYRU X1_LAYER_SELECTOR_UP
+#define X1_LYRD X1_LAYER_SELECTOR_DOWN
+
+// clang-format off
+static inline void x1_led_1(bool on) { gpio_write_pin(IND1_LED, on); }
+static inline void x1_led_2(bool on) { gpio_write_pin(IND2_LED, on); }
+static inline void x1_led_3(bool on) { gpio_write_pin(IND3_LED, on); }
+static inline void x1_led_4(bool on) { gpio_write_pin(IND4_LED, on); }
+static inline void x1_led_1_on(void) { gpio_write_pin_high(IND1_LED); }
+static inline void x1_led_2_on(void) { gpio_write_pin_high(IND2_LED); }
+static inline void x1_led_3_on(void) { gpio_write_pin_high(IND3_LED); }
+static inline void x1_led_4_on(void) { gpio_write_pin_high(IND4_LED); }
+static inline void x1_led_1_off(void) { gpio_write_pin_low(IND1_LED); }
+static inline void x1_led_2_off(void) { gpio_write_pin_low(IND2_LED); }
+static inline void x1_led_3_off(void) { gpio_write_pin_low(IND3_LED); }
+static inline void x1_led_4_off(void) { gpio_write_pin_low(IND4_LED); }
+// clang-format on
+
+static inline void x1_layer_led(uint8_t lyr) {
+    gpio_write_pin(IND1_LED, lyr >= 0);
+    gpio_write_pin(IND2_LED, lyr >= 1);
+    gpio_write_pin(IND3_LED, lyr >= 2);
+    gpio_write_pin(IND4_LED, lyr >= 3);
+}
+
+bool process_x1_layer_up(keyrecord_t *record);
+bool process_x1_layer_down(keyrecord_t *record);

+ 26 - 0
keyboards/binepad/knobx1/readme.md

@@ -0,0 +1,26 @@
+# Binepad KnobX1
+
+![Binepad KnobX1](https://i.imgur.com/9HeFQXP.png)
+
+*A fully customizable knob designed to enhance your PC experience*
+
+* Keyboard Maintainer: [binepad](https://github.com/binepad)
+* Hardware Supported: *Binepad knobX1*
+* Hardware Availability: [binepad.com](https://binepad.com/products/knobx1)
+
+Make example for this keyboard (after setting up your build environment):
+
+    make binepad/knobx1:default
+
+Flashing example for this keyboard:
+
+    make binepad/knobx1:default:flash
+
+See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
+
+## Bootloader
+
+Enter the bootloader in 2 ways:
+
+* **Bootmagic reset**: Hold down the layer button (small button on the bottom left) and plug in the keyboard.
+* **Keycode in layout**: Press the key mapped to `QK_BOOT` if it is available