From 9089244db77d724f23ddfc01be370f9c029c8e6c Mon Sep 17 00:00:00 2001 From: somepin <79652090+somepin@users.noreply.github.com> Date: Wed, 10 Mar 2021 00:17:35 -0500 Subject: Add VIA support to doodboard/duckboard_r2 (#12028) * Update R1 keymap and config * Add duckboard R2 * Add VIA support for duckboard R2 * Set bootmagic lite row and column * Update config.h * Update keyboards/doodboard/duckboard/config.h Co-authored-by: Drashna Jaelre * Update config.h Co-authored-by: Drashna Jaelre --- keyboards/doodboard/duckboard/config.h | 4 +- keyboards/doodboard/duckboard/duckboard.c | 2 +- keyboards/doodboard/duckboard/duckboard.h | 3 +- keyboards/doodboard/duckboard/info.json | 40 +++---- .../doodboard/duckboard/keymaps/default/keymap.c | 40 ++++--- keyboards/doodboard/duckboard/readme.md | 10 +- keyboards/doodboard/duckboard_r2/config.h | 60 ++++++++++ keyboards/doodboard/duckboard_r2/duckboard_r2.c | 17 +++ keyboards/doodboard/duckboard_r2/duckboard_r2.h | 33 ++++++ keyboards/doodboard/duckboard_r2/info.json | 39 +++++++ .../duckboard_r2/keymaps/default/keymap.c | 120 +++++++++++++++++++ .../doodboard/duckboard_r2/keymaps/via/keymap.c | 130 +++++++++++++++++++++ .../doodboard/duckboard_r2/keymaps/via/rules.mk | 2 + keyboards/doodboard/duckboard_r2/readme.md | 17 +++ keyboards/doodboard/duckboard_r2/rules.mk | 25 ++++ 15 files changed, 493 insertions(+), 49 deletions(-) create mode 100644 keyboards/doodboard/duckboard_r2/config.h create mode 100644 keyboards/doodboard/duckboard_r2/duckboard_r2.c create mode 100644 keyboards/doodboard/duckboard_r2/duckboard_r2.h create mode 100644 keyboards/doodboard/duckboard_r2/info.json create mode 100644 keyboards/doodboard/duckboard_r2/keymaps/default/keymap.c create mode 100644 keyboards/doodboard/duckboard_r2/keymaps/via/keymap.c create mode 100644 keyboards/doodboard/duckboard_r2/keymaps/via/rules.mk create mode 100644 keyboards/doodboard/duckboard_r2/readme.md create mode 100644 keyboards/doodboard/duckboard_r2/rules.mk diff --git a/keyboards/doodboard/duckboard/config.h b/keyboards/doodboard/duckboard/config.h index ea8a8ae5dd..80c9411165 100644 --- a/keyboards/doodboard/duckboard/config.h +++ b/keyboards/doodboard/duckboard/config.h @@ -1,4 +1,4 @@ -/* Copyright 2020 doodboard +/* Copyright 2020-2021 doodboard * * 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 @@ -19,7 +19,7 @@ #include "config_common.h" /* USB Device descriptor parameter */ -#define VENDOR_ID 0xFEED +#define VENDOR_ID 0x4442 #define PRODUCT_ID 0xFF44 #define DEVICE_VER 0x0001 #define MANUFACTURER doodboard diff --git a/keyboards/doodboard/duckboard/duckboard.c b/keyboards/doodboard/duckboard/duckboard.c index af0cb24beb..853e105ceb 100644 --- a/keyboards/doodboard/duckboard/duckboard.c +++ b/keyboards/doodboard/duckboard/duckboard.c @@ -1,4 +1,4 @@ -/* Copyright 2020 doodboard +/* Copyright 2020-2021 doodboard * * 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 diff --git a/keyboards/doodboard/duckboard/duckboard.h b/keyboards/doodboard/duckboard/duckboard.h index 0e753d445e..c98c9a703a 100644 --- a/keyboards/doodboard/duckboard/duckboard.h +++ b/keyboards/doodboard/duckboard/duckboard.h @@ -1,4 +1,4 @@ -/* Copyright 2020 doodboard +/* Copyright 2020-2021 doodboard * * 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 @@ -14,7 +14,6 @@ * along with this program. If not, see . */ - #pragma once #include "quantum.h" diff --git a/keyboards/doodboard/duckboard/info.json b/keyboards/doodboard/duckboard/info.json index d5193e61eb..074f5c88ad 100644 --- a/keyboards/doodboard/duckboard/info.json +++ b/keyboards/doodboard/duckboard/info.json @@ -1,35 +1,35 @@ { "keyboard_name": "duckboard", - "url": "", + "url": "https://doodboard.xyz/", "maintainer": "doodboard", "width": 5, "height": 5, "layouts": { "LAYOUT": { "layout": [ - {"x": 1, "y": 0}, - {"x": 2, "y": 0}, - {"x": 3, "y": 0}, - {"x": 4, "y": 0}, + { "x": 1, "y": 0 }, + { "x": 2, "y": 0 }, + { "x": 3, "y": 0 }, + { "x": 4, "y": 0 }, - {"x": 1, "y": 1}, - {"x": 2, "y": 1}, - {"x": 3, "y": 1}, + { "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": 4, "y": 1, "h": 2}, + { "x": 1, "y": 2 }, + { "x": 2, "y": 2 }, + { "x": 3, "y": 2 }, + { "x": 4, "y": 1, "h": 2 }, - {"x": 1, "y": 3}, - {"x": 2, "y": 3}, - {"x": 3, "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}, - {"x": 4, "y": 3, "h": 2} + { "x": 0, "y": 4 }, + { "x": 1, "y": 4 }, + { "x": 2, "y": 4 }, + { "x": 3, "y": 4 }, + { "x": 4, "y": 3, "h": 2 } ] } } diff --git a/keyboards/doodboard/duckboard/keymaps/default/keymap.c b/keyboards/doodboard/duckboard/keymaps/default/keymap.c index 6684e98633..0dd9c40678 100644 --- a/keyboards/doodboard/duckboard/keymaps/default/keymap.c +++ b/keyboards/doodboard/duckboard/keymaps/default/keymap.c @@ -1,4 +1,4 @@ -/* Copyright 2020 doodboard +/* Copyright 2020-2021 doodboard * * 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 @@ -18,22 +18,24 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [0] = LAYOUT( TG(1), KC_PSLS, KC_PAST, KC_PMNS, - KC_P7, KC_P8, KC_P9, - KC_P4, KC_P5, KC_P6, KC_PPLS, - KC_P1, KC_P2, KC_P3, - KC_BSPC, KC_MUTE, KC_P0, KC_PDOT, KC_PENT), - [1] = LAYOUT( - TG(1), KC_TRNS, KC_TRNS, KC_TRNS, - KC_HOME, KC_UP, KC_PGUP, - KC_LEFT, KC_TRNS, KC_RGHT, KC_TRNS, - KC_END, KC_DOWN, KC_PGDN, - TG(2), KC_TRNS, KC_INS, KC_DEL, KC_TRNS), - [2] = LAYOUT( - KC_TRNS, RGB_TOG, RGB_MOD, KC_TRNS, - RGB_HUI, RGB_SAI, RGB_VAI, - RGB_HUD, RGB_SAD, RGB_VAD, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, - TG(2), RESET, KC_TRNS, KC_TRNS, KC_TRNS), + KC_7, KC_8, KC_9, + KC_4, KC_5, KC_6, KC_PPLS, + KC_1, KC_2, KC_3, + KC_BSPC, KC_0, KC_0, KC_DOT, KC_ENT), + + [1] = LAYOUT( + TG(1), KC_TRNS, KC_TRNS, KC_TRNS, + KC_HOME, KC_UP, KC_PGUP, + KC_LEFT, KC_TRNS, KC_RGHT, KC_TRNS, + KC_END, KC_DOWN, KC_PGDN, + TG(2), KC_TRNS, KC_INS, KC_DEL, KC_TRNS), + + [2] = LAYOUT( + KC_TRNS, RGB_TOG, RGB_MOD, KC_TRNS, + RGB_HUI, RGB_SAI, RGB_VAI, + RGB_HUD, RGB_SAD, RGB_VAD, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, + TG(2), RESET, KC_TRNS, KC_TRNS, KC_TRNS), }; void encoder_update_user(uint8_t index, bool clockwise) { @@ -111,8 +113,8 @@ void oled_task_user(void) { void keyboard_post_init_user(void) { //Customise these values to debug - //debug_enable=true; - //debug_matrix=true; + debug_enable=true; + debug_matrix=true; //debug_keyboard=true; //debug_mouse=true; } diff --git a/keyboards/doodboard/duckboard/readme.md b/keyboards/doodboard/duckboard/readme.md index d2b799ab61..866a7d4b9e 100644 --- a/keyboards/doodboard/duckboard/readme.md +++ b/keyboards/doodboard/duckboard/readme.md @@ -1,10 +1,10 @@ -# duckboard +# duckboard R1 -An 18-key numpad with rotary encoder and OLED support. +An 18-key numpad with rotary encoder and OLED support. -* Keyboard Maintainer: [doodboard](https://github.com/doodboard) -* Hardware Supported: duckboard PCB -* Hardware Availability: Private Group Buy +- Keyboard Maintainer: [doodboard](https://doodboard.xyz/) +- Hardware Supported: duckboard PCB +- Hardware Availability: Private Group Buy Make example for this keyboard (after setting up your build environment): diff --git a/keyboards/doodboard/duckboard_r2/config.h b/keyboards/doodboard/duckboard_r2/config.h new file mode 100644 index 0000000000..10ed3c4cab --- /dev/null +++ b/keyboards/doodboard/duckboard_r2/config.h @@ -0,0 +1,60 @@ +/* Copyright 2020-2021 doodboard + * + * 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 0x4442 +#define PRODUCT_ID 0x6462 +#define DEVICE_VER 0x0001 +#define MANUFACTURER doodboard +#define PRODUCT duckboard + +/* key matrix size */ +#define MATRIX_ROWS 5 +#define MATRIX_COLS 5 + +/* key matrix pins */ +#define MATRIX_ROW_PINS { C6, D7, E6, B4, B5 } +#define MATRIX_COL_PINS { F7, B1, B3, B2, B6 } +#define UNUSED_PINS + +#define ENCODERS_PAD_A { F6 } +#define ENCODERS_PAD_B { F5 } +#define ENCODER_RESOLUTION 2 + +/* media key slowdown for windows */ +#define TAP_CODE_DELAY 20 + +/* COL2ROW or ROW2COL */ +#define DIODE_DIRECTION COL2ROW + +/* number of backlight levels */ + +/* ws2812 RGB LED */ +#define RGB_DI_PIN D3 + +#ifdef RGBLIGHT_ENABLE +#define RGBLED_NUM 8 // Number of LEDs +#endif + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCE 5 + +#define BOOTMAGIC_LITE_ROW 0 +#define BOOTMAGIC_LITE_COLUMN 1 diff --git a/keyboards/doodboard/duckboard_r2/duckboard_r2.c b/keyboards/doodboard/duckboard_r2/duckboard_r2.c new file mode 100644 index 0000000000..095544b9e3 --- /dev/null +++ b/keyboards/doodboard/duckboard_r2/duckboard_r2.c @@ -0,0 +1,17 @@ +/* Copyright 2020-2021 doodboard + * + * 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 "duckboard_r2.h" diff --git a/keyboards/doodboard/duckboard_r2/duckboard_r2.h b/keyboards/doodboard/duckboard_r2/duckboard_r2.h new file mode 100644 index 0000000000..1f3c462da8 --- /dev/null +++ b/keyboards/doodboard/duckboard_r2/duckboard_r2.h @@ -0,0 +1,33 @@ +/* Copyright 2020-2021 doodboard + * + * 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 LAYOUT( \ + K01, K02, K03, K04, \ + K11, K12, K13, K14, \ + K21, K22, K23, K24, \ + K30, K31, K32, K33, K34, \ + K40, K41, K42, K43, K44 \ +) { \ + { KC_NO, K01, K02, K03, K04 }, \ + { KC_NO, K11, K12, K13, K14 }, \ + { KC_NO, K21, K22, K23, K24 }, \ + { K30, K31, K32, K33, K34 }, \ + { K40, K41, K42, K43, K44 } \ +} diff --git a/keyboards/doodboard/duckboard_r2/info.json b/keyboards/doodboard/duckboard_r2/info.json new file mode 100644 index 0000000000..69a1b1cd1a --- /dev/null +++ b/keyboards/doodboard/duckboard_r2/info.json @@ -0,0 +1,39 @@ +{ + "keyboard_name": "duckboard", + "url": "https://doodboard.xyz/", + "maintainer": "doodboard", + "width": 5, + "height": 5, + "layouts": { + "LAYOUT": { + "layout": [ + { "x": 1, "y": 0 }, + { "x": 2, "y": 0 }, + { "x": 3, "y": 0 }, + { "x": 4, "y": 0 }, + + { "x": 1, "y": 1 }, + { "x": 2, "y": 1 }, + { "x": 3, "y": 1 }, + { "x": 4, "y": 1 }, + + { "x": 1, "y": 2 }, + { "x": 2, "y": 2 }, + { "x": 3, "y": 2 }, + { "x": 4, "y": 2 }, + + { "x": 0, "y": 3 }, + { "x": 1, "y": 3 }, + { "x": 2, "y": 3 }, + { "x": 3, "y": 3 }, + { "x": 4, "y": 3 }, + + { "x": 0, "y": 4 }, + { "x": 1, "y": 4 }, + { "x": 2, "y": 4 }, + { "x": 3, "y": 4 }, + { "x": 4, "y": 4 } + ] + } + } +} diff --git a/keyboards/doodboard/duckboard_r2/keymaps/default/keymap.c b/keyboards/doodboard/duckboard_r2/keymaps/default/keymap.c new file mode 100644 index 0000000000..e782acba01 --- /dev/null +++ b/keyboards/doodboard/duckboard_r2/keymaps/default/keymap.c @@ -0,0 +1,120 @@ +/* Copyright 2020-2021 doodboard + * + * 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 +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [0] = LAYOUT( + TG(1), KC_PSLS, KC_PAST, KC_PMNS, + KC_7, KC_8, KC_9, KC_PPLS, + KC_4, KC_5, KC_6, KC_PPLS, + KC_MUTE, KC_1, KC_2, KC_3, KC_ENT, + KC_BSPC, KC_0, KC_0, KC_DOT, KC_ENT), + + [1] = LAYOUT( + TG(1), KC_TRNS, KC_TRNS, KC_TRNS, + KC_HOME, KC_UP, KC_PGUP, KC_TRNS, + KC_LEFT, KC_TRNS, KC_RGHT, KC_TRNS, + KC_TRNS, KC_END, KC_DOWN, KC_PGDN, KC_TRNS, + TG(2), KC_TRNS, KC_INS, KC_DEL, KC_TRNS), + + [2] = LAYOUT( + KC_TRNS, RGB_TOG, RGB_MOD, KC_TRNS, + RGB_HUI, RGB_SAI, RGB_VAI, KC_TRNS, + RGB_HUD, RGB_SAD, RGB_VAD, KC_TRNS, + RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + TG(2), RESET, KC_TRNS, KC_TRNS, KC_TRNS), +}; + +void encoder_update_user(uint8_t index, bool clockwise) { + if (index == 0) { /* First encoder */ + if (clockwise) { + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } +} +} + + +#ifdef OLED_DRIVER_ENABLE +oled_rotation_t oled_init_user(oled_rotation_t rotation) { return OLED_ROTATION_270; } + + +// WPM-responsive animation stuff here +#define IDLE_FRAMES 2 +#define IDLE_SPEED 40 // below this wpm value your animation will idle + +#define ANIM_FRAME_DURATION 200 // how long each frame lasts in ms +// #define SLEEP_TIMER 60000 // should sleep after this period of 0 wpm, needs fixing +#define ANIM_SIZE 636 // number of bytes in array, minimize for adequate firmware size, max is 1024 + +uint32_t anim_timer = 0; +uint32_t anim_sleep = 0; +uint8_t current_idle_frame = 0; + +// Credit to u/Pop-X- for the initial code. You can find his commit here https://github.com/qmk/qmk_firmware/pull/9264/files#diff-303f6e3a7a5ee54be0a9a13630842956R196-R333. +static void render_anim(void) { + static const char PROGMEM idle[IDLE_FRAMES][ANIM_SIZE] = { + { + 0, 0,192,192,192,192,192,192,192,248,248, 30, 30,254,254,248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3,255,255,255,255,255,255,255,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,127,127,255,255,255,255,255,159,159,135,135,129,129,129, 97, 97, 25, 25, 7, 7, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 97, 97,127, 1, 1, 97, 97,127, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }, + { + 0, 0,128,128,128,128,128,128,128,240,240, 60, 60,252,252,240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 7, 7, 7, 7, 7,255,255,254,254,255,255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255,255,255,255,255,255,255, 63, 63, 15, 15, 3, 3, 3,195,195, 51, 51, 15, 15, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 99, 99,127, 3, 3, 99, 99,127, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0 + } + }; + + //assumes 1 frame prep stage + void animation_phase(void) { + current_idle_frame = (current_idle_frame + 1) % IDLE_FRAMES; + oled_write_raw_P(idle[abs((IDLE_FRAMES-1)-current_idle_frame)], ANIM_SIZE); + } + + if(timer_elapsed32(anim_timer) > ANIM_FRAME_DURATION) { + anim_timer = timer_read32(); + animation_phase(); + } + } + +void oled_task_user(void) { + render_anim(); + oled_set_cursor(0,6); + oled_write_P(PSTR("DUCK\nBOARD\n"), false); + oled_write_P(PSTR("-----\n"), false); + // Host Keyboard Layer Status + oled_write_P(PSTR("MODE\n"), false); + oled_write_P(PSTR("\n"), false); + + switch (get_highest_layer(layer_state)) { + case 0: + oled_write_P(PSTR("BASE\n"), false); + break; + case 1: + oled_write_P(PSTR("FUNC\n"), false); + break; + case 2: + oled_write_P(PSTR("RGB\n"), false); + break; + } +} +#endif + +void keyboard_post_init_user(void) { + //Customise these values to debug + debug_enable=true; + debug_matrix=true; + //debug_keyboard=true; + //debug_mouse=true; +} diff --git a/keyboards/doodboard/duckboard_r2/keymaps/via/keymap.c b/keyboards/doodboard/duckboard_r2/keymaps/via/keymap.c new file mode 100644 index 0000000000..00ae8fa0d9 --- /dev/null +++ b/keyboards/doodboard/duckboard_r2/keymaps/via/keymap.c @@ -0,0 +1,130 @@ +/* Copyright 2020-2021 doodboard + * + * 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 +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [0] = LAYOUT( + TG(1), KC_PSLS, KC_PAST, KC_PMNS, + KC_7, KC_8, KC_9, KC_PPLS, + KC_4, KC_5, KC_6, KC_PPLS, + KC_MUTE, KC_1, KC_2, KC_3, KC_ENT, + KC_BSPC, KC_0, KC_0, KC_DOT, KC_ENT), + + [1] = LAYOUT( + TG(1), KC_TRNS, KC_TRNS, KC_TRNS, + KC_HOME, KC_UP, KC_PGUP, KC_TRNS, + KC_LEFT, KC_TRNS, KC_RGHT, KC_TRNS, + KC_TRNS, KC_END, KC_DOWN, KC_PGDN, KC_TRNS, + TG(2), KC_TRNS, KC_INS, KC_DEL, KC_TRNS), + + [2] = LAYOUT( + KC_TRNS, RGB_TOG, RGB_MOD, KC_TRNS, + RGB_HUI, RGB_SAI, RGB_VAI, KC_TRNS, + RGB_HUD, RGB_SAD, RGB_VAD, KC_TRNS, + RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + TG(2), RESET, KC_TRNS, KC_TRNS, KC_TRNS), + + [3] = LAYOUT( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), +}; + +void encoder_update_user(uint8_t index, bool clockwise) { + if (index == 0) { /* First encoder */ + if (clockwise) { + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } +} +} + + +#ifdef OLED_DRIVER_ENABLE +oled_rotation_t oled_init_user(oled_rotation_t rotation) { return OLED_ROTATION_270; } + + +// WPM-responsive animation stuff here +#define IDLE_FRAMES 2 +#define IDLE_SPEED 40 // below this wpm value your animation will idle + +#define ANIM_FRAME_DURATION 200 // how long each frame lasts in ms +// #define SLEEP_TIMER 60000 // should sleep after this period of 0 wpm, needs fixing +#define ANIM_SIZE 636 // number of bytes in array, minimize for adequate firmware size, max is 1024 + +uint32_t anim_timer = 0; +uint32_t anim_sleep = 0; +uint8_t current_idle_frame = 0; + +// Credit to u/Pop-X- for the initial code. You can find his commit here https://github.com/qmk/qmk_firmware/pull/9264/files#diff-303f6e3a7a5ee54be0a9a13630842956R196-R333. +static void render_anim(void) { + static const char PROGMEM idle[IDLE_FRAMES][ANIM_SIZE] = { + { + 0, 0,192,192,192,192,192,192,192,248,248, 30, 30,254,254,248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3,255,255,255,255,255,255,255,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,127,127,255,255,255,255,255,159,159,135,135,129,129,129, 97, 97, 25, 25, 7, 7, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 97, 97,127, 1, 1, 97, 97,127, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }, + { + 0, 0,128,128,128,128,128,128,128,240,240, 60, 60,252,252,240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 7, 7, 7, 7, 7,255,255,254,254,255,255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255,255,255,255,255,255,255, 63, 63, 15, 15, 3, 3, 3,195,195, 51, 51, 15, 15, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 99, 99,127, 3, 3, 99, 99,127, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0 + } + }; + + //assumes 1 frame prep stage + void animation_phase(void) { + current_idle_frame = (current_idle_frame + 1) % IDLE_FRAMES; + oled_write_raw_P(idle[abs((IDLE_FRAMES-1)-current_idle_frame)], ANIM_SIZE); + } + + if(timer_elapsed32(anim_timer) > ANIM_FRAME_DURATION) { + anim_timer = timer_read32(); + animation_phase(); + } + } + +void oled_task_user(void) { + render_anim(); + oled_set_cursor(0,6); + oled_write_P(PSTR("DUCK\nBOARD\n"), false); + oled_write_P(PSTR("-----\n"), false); + // Host Keyboard Layer Status + oled_write_P(PSTR("MODE\n"), false); + oled_write_P(PSTR("\n"), false); + + switch (get_highest_layer(layer_state)) { + case 0: + oled_write_P(PSTR("BASE\n"), false); + break; + case 1: + oled_write_P(PSTR("FUNC\n"), false); + break; + case 2: + oled_write_P(PSTR("RGB\n"), false); + break; + case 3: + oled_write_P(PSTR("FN2\n"), false); + break; + } +} +#endif + +void keyboard_post_init_user(void) { + //Customise these values to debug + debug_enable=true; + debug_matrix=true; + //debug_keyboard=true; + //debug_mouse=true; +} diff --git a/keyboards/doodboard/duckboard_r2/keymaps/via/rules.mk b/keyboards/doodboard/duckboard_r2/keymaps/via/rules.mk new file mode 100644 index 0000000000..36b7ba9cbc --- /dev/null +++ b/keyboards/doodboard/duckboard_r2/keymaps/via/rules.mk @@ -0,0 +1,2 @@ +VIA_ENABLE = yes +LTO_ENABLE = yes diff --git a/keyboards/doodboard/duckboard_r2/readme.md b/keyboards/doodboard/duckboard_r2/readme.md new file mode 100644 index 0000000000..8f9c77b6eb --- /dev/null +++ b/keyboards/doodboard/duckboard_r2/readme.md @@ -0,0 +1,17 @@ +# duckboard R2 + +A 21-key numpad with rotary encoder and OLED support. + +- Keyboard Maintainer: [doodboard](https://doodboard.xyz/) +- Hardware Supported: duckboard PCB +- Hardware Availability: Private Group Buy + +Make example for this keyboard (after setting up your build environment): + + make doodboard/duckboard_r2:default + +Flashing example for this keyboard: + + make doodboard/duckboard_r2: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). diff --git a/keyboards/doodboard/duckboard_r2/rules.mk b/keyboards/doodboard/duckboard_r2/rules.mk new file mode 100644 index 0000000000..09a60d8a79 --- /dev/null +++ b/keyboards/doodboard/duckboard_r2/rules.mk @@ -0,0 +1,25 @@ +# MCU name +MCU = atmega32u4 + +# Bootloader selection +BOOTLOADER = caterina + +# Build Options +# change yes to no to disable +# +BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration +MOUSEKEY_ENABLE = no # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +CONSOLE_ENABLE = yes # 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 = yes # 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 -- cgit v1.2.1