From a6a13f96262ef1e8c91546f24cff5067f8026c23 Mon Sep 17 00:00:00 2001 From: Brandon Schlack Date: Sun, 26 Jul 2020 14:32:04 -0700 Subject: [PATCH] [Keyboard] Add Keybage folder for RadPad (#9745) * [Keyboard] Initial Keybage/RadPad firmware * [Keyboard] RadPad apply pull request feedback - Change `LAYOUT_***_Encoders` to `LAYOUT_***_encoders` in .h - Remove bootloader comments and unnecessary build options from rules.mk - Use `LTO_ENABLE` - Remove empty config.h from default keymap - Remove trailing ` \` from keymap * [Keyboard] RadPad fix info.json - Change `LAYOUT_***_Encoders` to `LAYOUT_***_encoders` in info.json * [Keyboard] Add host LED status to OLED display * [Keyboard] Use LAYOUT_4x4_encoders, not LAYOUT * [Keyboard] Use LAYOUT_4x4_encoders, not LAYOUT * [Keyboard] Remove DESCRIPTION from config.h --- keyboards/keybage/radpad/config.h | 67 +++++++++ keyboards/keybage/radpad/info.json | 82 ++++++++++ .../keybage/radpad/keymaps/default/keymap.c | 141 ++++++++++++++++++ .../keybage/radpad/keymaps/default/readme.md | 1 + keyboards/keybage/radpad/radpad.c | 17 +++ keyboards/keybage/radpad/radpad.h | 87 +++++++++++ keyboards/keybage/radpad/readme.md | 15 ++ keyboards/keybage/radpad/rules.mk | 25 ++++ 8 files changed, 435 insertions(+) create mode 100644 keyboards/keybage/radpad/config.h create mode 100644 keyboards/keybage/radpad/info.json create mode 100644 keyboards/keybage/radpad/keymaps/default/keymap.c create mode 100644 keyboards/keybage/radpad/keymaps/default/readme.md create mode 100644 keyboards/keybage/radpad/radpad.c create mode 100644 keyboards/keybage/radpad/radpad.h create mode 100644 keyboards/keybage/radpad/readme.md create mode 100644 keyboards/keybage/radpad/rules.mk diff --git a/keyboards/keybage/radpad/config.h b/keyboards/keybage/radpad/config.h new file mode 100644 index 0000000000..4692b38180 --- /dev/null +++ b/keyboards/keybage/radpad/config.h @@ -0,0 +1,67 @@ +/* +Copyright 2020 Keybage + +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 "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0x4253 // "BS" +#define PRODUCT_ID 0x5250 // "RP" +#define DEVICE_VER 0x0001 +#define MANUFACTURER Keybage +#define PRODUCT RadPad + +/* key matrix size */ +#define MATRIX_ROWS 5 +#define MATRIX_COLS 4 + +#define MATRIX_ROW_PINS { F5, B5, B6, B2, B3 } +#define MATRIX_COL_PINS { E6, B4, D7, B1 } +#define UNUSED_PINS { B0, B7, C7, D2, D3, D5, F0 } + +#define DIODE_DIRECTION COL2ROW + +#define ENCODERS_PAD_A { D4, F6 } +#define ENCODERS_PAD_B { C6, F7 } + +#define ENCODER_RESOLUTION 2 + +#define RGB_DI_PIN F4 +#ifdef RGB_DI_PIN + #define RGBLED_NUM 16 + #define RGBLIGHT_SLEEP +/*== all animations disable ==*/ + #undef RGBLIGHT_ANIMATIONS +#endif + +/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ +#define DEBOUNCE 5 + +/* disable these deprecated features by default */ +#define NO_ACTION_MACRO +#define NO_ACTION_FUNCTION + +/* Bootmagic Lite key configuration */ +#define BOOTMAGIC_LITE_ROW 1 +#define BOOTMAGIC_LITE_COLUMN 3 + +/* OLED Configuration */ +#ifdef OLED_DRIVER_ENABLE + #define OLED_TIMEOUT 60000 + #define OLED_LOGO_TIMEOUT 3000 // How long (in ms) the logo appears at start up +#endif diff --git a/keyboards/keybage/radpad/info.json b/keyboards/keybage/radpad/info.json new file mode 100644 index 0000000000..b8f2306e18 --- /dev/null +++ b/keyboards/keybage/radpad/info.json @@ -0,0 +1,82 @@ +{ + "keyboard_name": "radpad", + "url": "", + "maintainer": "Brandon Schlack", + "width": 4, + "height": 5, + "layouts": { + "LAYOUT_4x4_encoders": { + "layout": [ + {"x":0, "y":0}, + {"x":3, "y":0}, + {"x":0, "y":1}, + {"x":1, "y":1}, + {"x":2, "y":1}, + {"x":3, "y":1}, + {"x":0, "y":2}, + {"x":1, "y":2}, + {"x":2, "y":2}, + {"x":3, "y":2}, + {"x":0, "y":3}, + {"x":1, "y":3}, + {"x":2, "y":3}, + {"x":3, "y":3}, + {"x":0, "y":4}, + {"x":1, "y":4}, + {"x":2, "y":4}, + {"x":3, "y":4} + ] + }, + "LAYOUT_4x3_encoders": { + "layout": [ + {"x":0, "y":0}, + {"x":3, "y":0}, + {"x":0, "y":1}, + {"x":1, "y":1}, + {"x":2, "y":1}, + {"x":3, "y":1}, + {"x":0, "y":2}, + {"x":1, "y":2}, + {"x":2, "y":2}, + {"x":3, "y":2}, + {"x":0, "y":3}, + {"x":1, "y":3}, + {"x":2, "y":3}, + {"x":3, "y":3} + ] + }, + "LAYOUT_3x4_encoders": { + "layout": [ + {"x":1, "y":0}, + {"x":3, "y":0}, + {"x":1, "y":1}, + {"x":2, "y":1}, + {"x":3, "y":1}, + {"x":1, "y":2}, + {"x":2, "y":2}, + {"x":3, "y":2}, + {"x":1, "y":3}, + {"x":2, "y":3}, + {"x":3, "y":3}, + {"x":1, "y":4}, + {"x":2, "y":4}, + {"x":3, "y":4} + ] + }, + "LAYOUT_3x3_encoders": { + "layout": [ + {"x":1, "y":0}, + {"x":3, "y":0}, + {"x":1, "y":1}, + {"x":2, "y":1}, + {"x":3, "y":1}, + {"x":1, "y":2}, + {"x":2, "y":2}, + {"x":3, "y":2}, + {"x":1, "y":3}, + {"x":2, "y":3}, + {"x":3, "y":3} + ] + } + } +} diff --git a/keyboards/keybage/radpad/keymaps/default/keymap.c b/keyboards/keybage/radpad/keymaps/default/keymap.c new file mode 100644 index 0000000000..f5904150e6 --- /dev/null +++ b/keyboards/keybage/radpad/keymaps/default/keymap.c @@ -0,0 +1,141 @@ +/* Copyright 2020 Brandon Schlack + * + * 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 . + */ +#include QMK_KEYBOARD_H + +enum layer_names { + _BASE = 0, + _FN +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE] = LAYOUT_4x4_encoders( + KC_MUTE, KC_MPLY, + KC_PMNS, KC_P7, KC_P8, KC_P9, + KC_PPLS, KC_P4, KC_P5, KC_P6, + KC_BSPC, KC_P1, KC_P2, KC_P3, + KC_PENT, MO(_FN), KC_P0, KC_PDOT + ), + [_FN] = LAYOUT_4x4_encoders( + _______, _______, + KC_PSLS, KC_F21, KC_F22, KC_F23, + KC_PAST, KC_F18, KC_F19, KC_F20, + KC_NLCK, KC_F15, KC_F16, KC_F17, + RESET, _______, KC_F13, KC_F14 + ) +}; + +void encoder_update_user(uint8_t index, bool clockwise) { + if (index == 0) { /* Left encoder */ + if (clockwise) { + tap_code16(KC_VOLU); + } else { + tap_code16(KC_VOLD); + } + } else if (index == 1) { /* Right encoder */ + if (clockwise) { + tap_code16(KC_MNXT); + } else { + tap_code16(KC_MPRV); + } + } +} + +#ifdef OLED_DRIVER_ENABLE +static uint32_t oled_logo_timer = 0; +bool oled_logo_cleared = false; // Set to true if you don't want a logo at all + +static void render_status(void) { + // Host Keyboard Layer Status + oled_write_P(PSTR("Layer: "), false); + + switch (get_highest_layer(layer_state)) { + case _BASE: + oled_write_P(PSTR("Numpad\n"), false); + break; + case _FN: + oled_write_P(PSTR("Macropad\n"), false); + break; + default: + // Or use the write_ln shortcut over adding '\n' to the end of your string + oled_write_ln_P(PSTR("Some Other Layer"), false); + } + + // Empty Line + oled_write_ln_P(PSTR(" "), false); + + // Host Keyboard LED Status + led_t led_state = host_keyboard_led_state(); + oled_write_P(led_state.num_lock ? PSTR(" NUM ") : PSTR(" "), led_state.num_lock); + oled_write_P(led_state.caps_lock ? PSTR(" CAP ") : PSTR(" "), led_state.caps_lock); + oled_write_P(led_state.scroll_lock ? PSTR(" SCR ") : PSTR(" "), led_state.scroll_lock); +} + +/* + How to convert your own image: + https://docs.splitkb.com/hc/en-us/articles/360013811280 +*/ +static void render_logo(void) { + static const char radpad_logo [] PROGMEM = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xe0, 0xe0, 0xf0, 0xf0, 0xf0, 0xf8, 0xf8, + 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf0, 0xf0, 0xf0, 0xe0, 0xc0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xe0, 0xf0, 0xf0, 0xf0, 0xe0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x60, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xe0, 0xe0, 0xe0, 0xe0, 0xc0, + 0xc0, 0xc0, 0xe0, 0xe0, 0xe0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf8, 0xf8, 0xf8, 0xf8, + 0xf8, 0xf0, 0xf0, 0xe0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xf0, 0xf0, 0xf0, 0xe0, + 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xf0, 0xf0, + 0xf0, 0xf0, 0xf0, 0xe0, 0xe0, 0xe0, 0xe0, 0xc0, 0xc0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xf9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, + 0xf1, 0xf8, 0xf8, 0xfc, 0xfc, 0xfe, 0x7f, 0x3f, 0x1f, 0x1f, 0x0f, 0x0f, 0x07, 0x00, 0x80, 0xe0, + 0xf8, 0xfc, 0xff, 0xff, 0xff, 0xbf, 0xff, 0xff, 0xff, 0xfe, 0xc0, 0xc0, 0xe0, 0xe0, 0xe0, 0xc0, + 0xc0, 0xf0, 0xfd, 0xff, 0xff, 0xff, 0x3f, 0x0f, 0x01, 0x00, 0x00, 0x81, 0xc1, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xf9, 0xf8, 0xfc, 0x7e, 0x7e, 0x3f, + 0x3f, 0x1f, 0x1f, 0x0f, 0x07, 0x03, 0x80, 0xc0, 0xf0, 0xfc, 0xff, 0xff, 0xff, 0xbf, 0xff, 0xff, + 0xff, 0xff, 0xe0, 0xc0, 0xc0, 0xe0, 0xe0, 0xc0, 0x80, 0xe0, 0xfd, 0xff, 0xff, 0xff, 0x7f, 0x0f, + 0x03, 0x00, 0x00, 0x81, 0xc1, 0xf3, 0xff, 0xff, 0xff, 0x7f, 0x3f, 0x0f, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x80, 0xf0, 0xfc, 0xff, 0xff, 0x7f, 0x1f, 0x0f, 0x03, 0x03, 0x03, 0x01, + 0x01, 0x01, 0x0f, 0x7f, 0xff, 0xff, 0xfe, 0x80, 0x00, 0xe0, 0xf0, 0xf8, 0xfc, 0xff, 0xff, 0x3f, + 0x3f, 0x1f, 0x1f, 0x0f, 0x0f, 0x0f, 0x07, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xc3, 0xe3, 0xf9, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xfc, 0xfc, 0x7e, 0x3e, 0x3f, 0x1f, 0x1f, 0x8f, 0xe7, 0xff, + 0xff, 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x07, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xc0, 0xf0, 0xf8, 0xfc, 0xff, 0xff, 0x7f, 0x3f, 0x1f, 0x1f, 0x0f, 0x0f, 0x0f, 0x07, 0x1f, + 0xff, 0xff, 0xff, 0xff, 0xc3, 0xe3, 0xf9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xf8, 0xfc, + 0x7e, 0x3e, 0x3f, 0x1f, 0x1f, 0x0f, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x07, 0x07, 0x00, 0x01, 0x01, 0x03, 0x03, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x03, 0x07, 0x07, 0x07, 0x07, 0x03, + 0x07, 0x03, 0x03, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x1f, 0x1f, 0x0f, + 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x03, 0x03, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + oled_write_raw_P(radpad_logo, sizeof(radpad_logo)); +} + +void oled_task_user(void) { + if (oled_logo_cleared) { + render_status(); + } else { + if (timer_elapsed32(oled_logo_timer) > OLED_LOGO_TIMEOUT) { + oled_clear(); + oled_logo_cleared = true; + render_status(); + } else { + render_logo(); + } + } +} +#endif diff --git a/keyboards/keybage/radpad/keymaps/default/readme.md b/keyboards/keybage/radpad/keymaps/default/readme.md new file mode 100644 index 0000000000..053bf297b7 --- /dev/null +++ b/keyboards/keybage/radpad/keymaps/default/readme.md @@ -0,0 +1 @@ +# The default keymap for radpad diff --git a/keyboards/keybage/radpad/radpad.c b/keyboards/keybage/radpad/radpad.c new file mode 100644 index 0000000000..4a31d8f573 --- /dev/null +++ b/keyboards/keybage/radpad/radpad.c @@ -0,0 +1,17 @@ +/* Copyright 2020 Brandon Schlack + * + * 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 . + */ + +#include "radpad.h" diff --git a/keyboards/keybage/radpad/radpad.h b/keyboards/keybage/radpad/radpad.h new file mode 100644 index 0000000000..be6583bb8e --- /dev/null +++ b/keyboards/keybage/radpad/radpad.h @@ -0,0 +1,87 @@ +/* Copyright 2020 Brandon Schlack + * + * 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 XXX KC_NO + +/* This is a shortcut to help you visually see your layout. + * + * The first section contains all of the arguments representing the physical + * layout of the board and position of the keys. + * + * The second converts the arguments into a two-dimensional array which + * represents the switch matrix. + */ +#define LAYOUT_4x4_encoders( \ + k00, k03, \ + k10, k11, k12, k13, \ + k20, k21, k22, k23, \ + k30, k31, k32, k33, \ + k40, k41, k42, k43 \ +) \ +{ \ + { k00, XXX, XXX, k03 }, \ + { k10, k11, k12, k13 }, \ + { k20, k21, k22, k23 }, \ + { k30, k31, k32, k33 }, \ + { k40, k41, k42, k43 } \ +} + +#define LAYOUT_4x3_encoders( \ + k00, k03, \ + k10, k11, k12, k13, \ + k20, k21, k22, k23, \ + k30, k31, k32, k33 \ +) \ +{ \ + { k00, XXX, XXX, k03 }, \ + { k10, k11, k12, k13 }, \ + { k20, k21, k22, k23 }, \ + { k30, k31, k32, k33 }, \ + { XXX, XXX, XXX, XXX } \ +} + +#define LAYOUT_3x4_encoders( \ + k01, k03, \ + k11, k12, k13, \ + k21, k22, k23, \ + k31, k32, k33, \ + k41, k42, k43 \ +) \ +{ \ + { XXX, k01, XXX, k03 }, \ + { XXX, k11, k12, k13 }, \ + { XXX, k21, k22, k23 }, \ + { XXX, k31, k32, k33 }, \ + { XXX, k41, k42, k43 } \ +} + +#define LAYOUT_3x3_encoders( \ + k01, k03, \ + k11, k12, k13, \ + k21, k22, k23, \ + k31, k32, k33 \ +) \ +{ \ + { XXX, k01, XXX, k03 }, \ + { XXX, k11, k12, k13 }, \ + { XXX, k21, k22, k23 }, \ + { XXX, k31, k32, k33 }, \ + { XXX, XXX, XXX, XXX } \ +} diff --git a/keyboards/keybage/radpad/readme.md b/keyboards/keybage/radpad/readme.md new file mode 100644 index 0000000000..d414578c08 --- /dev/null +++ b/keyboards/keybage/radpad/readme.md @@ -0,0 +1,15 @@ +# RadPad + +![RadPad](https://i.imgur.com/a4UmOuW.jpg) + +A DIY-focused 4x4 numpad that supports up to 2 Rotary Encoders and an OLED screen. + +* Keyboard Maintainer: [Brandon Schlack](https://github.com/brandonschlack) +* Hardware Supported: Pro Micro, Elite-C, Proton C +* Hardware Availability: TBD, awaiting final protos + +Make example for this keyboard (after setting up your build environment): + + make keybage/radpad: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). diff --git a/keyboards/keybage/radpad/rules.mk b/keyboards/keybage/radpad/rules.mk new file mode 100644 index 0000000000..74f4c48748 --- /dev/null +++ b/keyboards/keybage/radpad/rules.mk @@ -0,0 +1,25 @@ +# MCU name +MCU = atmega32u4 + +# Bootloader selection +BOOTLOADER = caterina + +# Build Options +# change yes to no to disable +# +BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration +MOUSEKEY_ENABLE = yes # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +CONSOLE_ENABLE = no # Console for debug +COMMAND_ENABLE = no # Commands for debug and configuration +# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend +# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +NKRO_ENABLE = no # USB Nkey Rollover +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow +BLUETOOTH_ENABLE = no # Enable Bluetooth +AUDIO_ENABLE = no # Audio output +ENCODER_ENABLE = yes +OLED_DRIVER_ENABLE = yes +LTO_ENABLE = yes