From 022825736e6cbb5e22256fc5670846bd61f48757 Mon Sep 17 00:00:00 2001 From: Leon Anavi Date: Tue, 15 Nov 2022 18:54:45 +0200 Subject: [PATCH] keyboards/anavi: Add ANAVI Knob 1 (#18623) ANAVI Knob 1 is a mini mechanical keyboard with a clickable rotary encoder, USB-C, RP2040 microcontroller and I2C slot for a display. Signed-off-by: Leon Anavi Signed-off-by: Leon Anavi --- keyboards/anavi/knob1/config.h | 34 +++++++++++ keyboards/anavi/knob1/info.json | 60 +++++++++++++++++++ .../anavi/knob1/keymaps/default/keymap.c | 16 +++++ keyboards/anavi/knob1/knob1.c | 59 ++++++++++++++++++ keyboards/anavi/knob1/knob1.h | 30 ++++++++++ keyboards/anavi/knob1/mcuconf.h | 12 ++++ keyboards/anavi/knob1/readme.md | 21 +++++++ keyboards/anavi/knob1/rules.mk | 6 ++ 8 files changed, 238 insertions(+) create mode 100644 keyboards/anavi/knob1/config.h create mode 100644 keyboards/anavi/knob1/info.json create mode 100644 keyboards/anavi/knob1/keymaps/default/keymap.c create mode 100644 keyboards/anavi/knob1/knob1.c create mode 100644 keyboards/anavi/knob1/knob1.h create mode 100644 keyboards/anavi/knob1/mcuconf.h create mode 100644 keyboards/anavi/knob1/readme.md create mode 100644 keyboards/anavi/knob1/rules.mk diff --git a/keyboards/anavi/knob1/config.h b/keyboards/anavi/knob1/config.h new file mode 100644 index 000000000000..f677aa9b2331 --- /dev/null +++ b/keyboards/anavi/knob1/config.h @@ -0,0 +1,34 @@ +// Copyright 2022 Leon Anavi +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "config_common.h" + +/* key matrix size */ +#define MATRIX_ROWS 1 +#define MATRIX_COLS 1 + +/* Keyboard Matrix Assignments */ +// clang-format off +#define DIRECT_PINS { \ + { GP26 } \ +} + +#define RGBLIGHT_DEFAULT_MODE 9 + +/* Double tap reset button to enter bootloader */ +#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET +#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_LED GP17 +#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_TIMEOUT 500U + + +#define I2C_DRIVER I2CD2 +#define I2C1_SDA_PIN GP6 +#define I2C1_SCL_PIN GP7 + +#ifdef OLED_ENABLE +# define OLED_DISPLAY_128X64 +# define OLED_TIMEOUT 60000 +# define OLED_BRIGHTNESS 128 +#endif diff --git a/keyboards/anavi/knob1/info.json b/keyboards/anavi/knob1/info.json new file mode 100644 index 000000000000..7ed1767a2435 --- /dev/null +++ b/keyboards/anavi/knob1/info.json @@ -0,0 +1,60 @@ +{ + "keyboard_name": "Knob 1", + "manufacturer": "ANAVI", + "url": "https://github.com/AnaviTechnology/anavi-knob-1", + "maintainer": "leon-anavi", + "processor": "RP2040", + "bootloader": "rp2040", + "debounce": 5, + "features": { + "bootmagic": false, + "command": false, + "console": false, + "extrakey": true, + "mousekey": false, + "nkro": true, + "rgblight": true + }, + "rgblight": { + "pin": "GP12", + "led_count": 1, + "hue_steps": 10, + "saturation_steps": 17, + "brightness_steps": 17, + "max_brightness": 255, + "animations": { + "alternating": true, + "breathing": true, + "christmas": true, + "knight": true, + "rainbow_mood": true, + "rainbow_swirl": true, + "rgb_test": true, + "snake": true, + "static_gradient": true, + "twinkle": true + } + }, + "encoder": { + "enabled": true, + "rotary": [ + { + "pin_a": "GP27", + "pin_b": "GP28", + "resolution": 2 + } + ] + }, + "layouts": { + "LAYOUT_k1": { + "layout": [ + { "label":"Mute", "x": 0, "y": 0 } + ] + } + }, + "usb": { + "device_version": "1.0.0", + "pid": "0x9A25", + "vid": "0xFEED" + } +} diff --git a/keyboards/anavi/knob1/keymaps/default/keymap.c b/keyboards/anavi/knob1/keymaps/default/keymap.c new file mode 100644 index 000000000000..a17be455e4cc --- /dev/null +++ b/keyboards/anavi/knob1/keymaps/default/keymap.c @@ -0,0 +1,16 @@ +// Copyright 2022 Leon Anavi +// SPDX-License-Identifier: GPL-2.0-or-later + +#include QMK_KEYBOARD_H + +//#include + +enum layer_names { + _BASE +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE] = LAYOUT_k1( + KC_MUTE + ) +}; diff --git a/keyboards/anavi/knob1/knob1.c b/keyboards/anavi/knob1/knob1.c new file mode 100644 index 000000000000..cfc3ac8a6524 --- /dev/null +++ b/keyboards/anavi/knob1/knob1.c @@ -0,0 +1,59 @@ +// Copyright 2022 Leon Anavi +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "encoder.h" +#include + +void keyboard_post_init_kb(void) { + // Enable RGB LED + setPinOutput(GP11); + writePinHigh(GP11); + rgblight_enable(); + + // Offload to the user func + keyboard_post_init_user(); +} + +#ifdef ENCODER_ENABLE +bool encoder_update_kb(uint8_t index, bool clockwise) { + if (!encoder_update_user(index, clockwise)) { return false; } + if (clockwise) { + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } + return true; +} +#endif + +#ifdef OLED_ENABLE + +bool oled_task_kb(void) { + + if (!oled_task_user()) { + return false; + } + + // Host Keyboard Layer Status + oled_write_ln_P(PSTR("ANAVI Knob 1"), false); + oled_write_ln_P(PSTR("Keymap: Default"), false); + + // Host Keyboard LED Status + led_t led_state = host_keyboard_led_state(); + oled_write_P(PSTR("Num Lock: "), false); + oled_write_ln_P(led_state.num_lock ? PSTR("On") : PSTR("Off"), false); + oled_write_P(PSTR("Caps Lock: "), false); + oled_write_ln_P(led_state.caps_lock ? PSTR("On") : PSTR("Off"), false); + oled_write_P(PSTR("Scroll Lock: "), false); + oled_write_ln_P(led_state.scroll_lock ? PSTR("On") : PSTR("Off"), false); +#ifdef RGBLIGHT_ENABLE + static char rgbStatusLine1[26] = {0}; + snprintf(rgbStatusLine1, sizeof(rgbStatusLine1), "RGB Mode: %d", rgblight_get_mode()); + oled_write_ln(rgbStatusLine1, false); + static char rgbStatusLine2[26] = {0}; + snprintf(rgbStatusLine2, sizeof(rgbStatusLine2), "h:%d s:%d v:%d", rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val()); + oled_write_ln(rgbStatusLine2, false); +#endif + return false; +} +#endif diff --git a/keyboards/anavi/knob1/knob1.h b/keyboards/anavi/knob1/knob1.h new file mode 100644 index 000000000000..c48170928cad --- /dev/null +++ b/keyboards/anavi/knob1/knob1.h @@ -0,0 +1,30 @@ +/* Copyright 2022 Leon Anavi + * + * 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 . + */ + +#pragma once + +#include "quantum.h" + +#define ___ KC_NO + +// clang-format off + #define LAYOUT_k1( \ + K02 \ + ) \ + { \ + { K02 } \ + } +// clang-format on diff --git a/keyboards/anavi/knob1/mcuconf.h b/keyboards/anavi/knob1/mcuconf.h new file mode 100644 index 000000000000..eb1c98372fba --- /dev/null +++ b/keyboards/anavi/knob1/mcuconf.h @@ -0,0 +1,12 @@ +// Copyright 2022 Leon Anavi (@leon-anavi) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include_next + +#undef RP_I2C_USE_I2C0 +#define RP_I2C_USE_I2C0 FALSE + +#undef RP_I2C_USE_I2C1 +#define RP_I2C_USE_I2C1 TRUE diff --git a/keyboards/anavi/knob1/readme.md b/keyboards/anavi/knob1/readme.md new file mode 100644 index 000000000000..08f8f921976e --- /dev/null +++ b/keyboards/anavi/knob1/readme.md @@ -0,0 +1,21 @@ +# ANAVI Knob 1 + +Mini mechanical keyboard with a clickable rotary encoder, USB-C, RP2040 microcontroller and I2C slot. + +* Keyboard Maintainer: [Leon Anavi](https://github.com/leon-anavi) +* Hardware Supported: ANAVI Knob 1 +* Hardware Availability: [Crowd Supply](https://www.crowdsupply.com/anavi-technology/anavi-macro-pad-10), [GitHub repository](https://github.com/AnaviTechnology/anavi-knob-1) + +Make example for this keyboard (after setting up your build environment): + + qmk compile -kb anavi/knob1 -km default + +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 3 ways: + +* **Bootmagic reset**: Hold down the top left key on the left half, or top right key on the right half, and then plug in the USB cable on that keyboard half. +* **Physical reset button**: Double tap the reset button on the XIAO RP2040. +* **Keycode in layout**: Press the key mapped to `QK_BOOT` if it is available. diff --git a/keyboards/anavi/knob1/rules.mk b/keyboards/anavi/knob1/rules.mk new file mode 100644 index 000000000000..ed8acbe4ac10 --- /dev/null +++ b/keyboards/anavi/knob1/rules.mk @@ -0,0 +1,6 @@ +WS2812_DRIVER = vendor + +OLED_ENABLE = yes +OLED_DRIVER = SSD1306 # Enable Support for SSD1306 or SH1106 OLED Displays; Communicating over I2C + +OPT_DEFS += -DHAL_USE_I2C=TRUE