Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keyboards/anavi: Add ANAVI Knob 1 #18623

Merged
merged 1 commit into from Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 34 additions & 0 deletions keyboards/anavi/knob1/config.h
@@ -0,0 +1,34 @@
// Copyright 2022 Leon Anavi <leon@anavi.org>
// 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
60 changes: 60 additions & 0 deletions 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"
}
}
16 changes: 16 additions & 0 deletions keyboards/anavi/knob1/keymaps/default/keymap.c
@@ -0,0 +1,16 @@
// Copyright 2022 Leon Anavi <leon@anavi.org>
// SPDX-License-Identifier: GPL-2.0-or-later

#include QMK_KEYBOARD_H

//#include <stdio.h>

enum layer_names {
_BASE
};

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_BASE] = LAYOUT_k1(
KC_MUTE
)
};
59 changes: 59 additions & 0 deletions keyboards/anavi/knob1/knob1.c
@@ -0,0 +1,59 @@
// Copyright 2022 Leon Anavi <leon@anavi.org>
// SPDX-License-Identifier: GPL-2.0-or-later

#include "encoder.h"
#include <stdio.h>

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
leon-anavi marked this conversation as resolved.
Show resolved Hide resolved
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
30 changes: 30 additions & 0 deletions keyboards/anavi/knob1/knob1.h
@@ -0,0 +1,30 @@
/* Copyright 2022 Leon Anavi <leon@anavi.org>
*
* 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 "quantum.h"

#define ___ KC_NO

// clang-format off
#define LAYOUT_k1( \
K02 \
) \
{ \
{ K02 } \
}
// clang-format on
12 changes: 12 additions & 0 deletions 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
leon-anavi marked this conversation as resolved.
Show resolved Hide resolved

#include_next <mcuconf.h>

#undef RP_I2C_USE_I2C0
#define RP_I2C_USE_I2C0 FALSE

#undef RP_I2C_USE_I2C1
#define RP_I2C_USE_I2C1 TRUE
21 changes: 21 additions & 0 deletions 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.
6 changes: 6 additions & 0 deletions 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