Add duckboard with RGB Matrix/VialRGB (#134)

* enable vial with rgb matrix for duckboard

* move rgb matrix config to vial keymap
This commit is contained in:
somepin 2022-03-26 01:30:05 -04:00 committed by GitHub
parent 30c04f92bd
commit ddfe214e76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 393 additions and 1 deletions

View File

@ -14,4 +14,4 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "duckboard_r2.h"
#include "duckboard_r2.h"

View File

@ -0,0 +1,78 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#ifdef OLED_ENABLE
// Enable OLED bitmap compression selectively.
#define USE_OLED_BITMAP_COMPRESSION
#define NUM_IDLE_FRAMES 2
#define NUM_OLED_BYTES 512
#ifdef USE_OLED_BITMAP_COMPRESSION
static const char PROGMEM idle_1_block_map[] = {
0xfc, 0xff, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x7f, 0x00, 0xfe, 0xff, 0x7f, 0x00, 0xf8, 0x7f, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static const char PROGMEM idle_2_block_map[] = {
0xfc, 0xff, 0x00, 0x00, 0xfc, 0xff, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x7f, 0x00, 0xf8, 0x7f, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static const char PROGMEM idle_1_block_list[] = {
0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xf8, 0xf8, 0x1e, 0x1e, 0xfe, 0xfe, 0xf8, 0x03, 0x03,
0x03, 0x03, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff,
0x9f, 0x9f, 0x87, 0x87, 0x81, 0x81, 0x81, 0x61, 0x61, 0x19, 0x19, 0x07, 0x07, 0x01, 0x01, 0x01,
0x01, 0x61, 0x61, 0x7f, 0x01, 0x01, 0x61, 0x61, 0x7f, 0x01, 0x01
};
static const char PROGMEM idle_2_block_list[] = {
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf0, 0xf0, 0x3c, 0x3c, 0xfc, 0xfc, 0xf0, 0x01, 0x01,
0x07, 0x07, 0x07, 0x07, 0x07, 0xff, 0xff, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0x3f, 0x3f, 0x0f, 0x0f, 0x03, 0x03, 0x03, 0xc3, 0xc3, 0x33, 0x33, 0x0f, 0x0f,
0x03, 0x03, 0x03, 0x03, 0x63, 0x63, 0x7f, 0x03, 0x03, 0x63, 0x63, 0x7f, 0x03, 0x03
};
const char* idle_frames[NUM_IDLE_FRAMES] = {
idle_1_block_list,
idle_2_block_list
};
const char* idle_block_map[NUM_IDLE_FRAMES] = {
idle_1_block_map,
idle_2_block_map
};
#else
static const char PROGMEM idle_frames[NUM_IDLE_FRAMES][NUM_OLED_BYTES] = {
{
0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xf8, 0xf8, 0x1e, 0x1e, 0xfe, 0xfe, 0xf8,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff,
0x9f, 0x9f, 0x87, 0x87, 0x81, 0x81, 0x81, 0x61, 0x61, 0x19, 0x19, 0x07, 0x07, 0x01, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x61, 0x61, 0x7f,
0x01, 0x01, 0x61, 0x61, 0x7f, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
},
{
0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf0, 0xf0, 0x3c, 0x3c, 0xfc, 0xfc, 0xf0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x01, 0x07, 0x07, 0x07, 0x07, 0x07, 0xff, 0xff, 0xfe, 0xfe, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x3f, 0x3f, 0x0f, 0x0f, 0x03, 0x03, 0x03, 0xc3, 0xc3, 0x33, 0x33, 0x0f, 0x0f, 0x03, 0x03, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x63, 0x63, 0x7f,
0x03, 0x03, 0x63, 0x63, 0x7f, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
},
};
#endif //USE_BITMAP_COMPRESSION
#endif //OLED_ENABLE

View File

@ -0,0 +1,54 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#define VIAL_KEYBOARD_UID {0xB5, 0xAC, 0x43, 0xD9, 0xBD, 0x2F, 0x24, 0xA4}
#define VIAL_UNLOCK_COMBO_ROWS { 4, 4 }
#define VIAL_UNLOCK_COMBO_COLS { 0, 4 }
#define VIAL_ENCODER_DEFAULT { KC_VOLD, KC_VOLU, KC_UP, KC_DOWN, \
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS }
#undef ENCODER_RESOLUTION
#define ENCODER_RESOLUTION 4
#define DYNAMIC_KEYMAP_LAYER_COUNT 6
#ifdef RGB_MATRIX_ENABLE
# define DRIVER_LED_TOTAL 8
# define RGB_DISABLE_WHEN_USB_SUSPENDED true
// RGB Matrix Animation modes. Explicitly enabled
// For full list of effects, see:
// https://docs.qmk.fm/#/feature_rgb_matrix?id=rgb-matrix-effects
// # define ENABLE_RGB_MATRIX_ALPHAS_MODS
# define ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN
# define ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT
# define ENABLE_RGB_MATRIX_BREATHING
# define ENABLE_RGB_MATRIX_BAND_SAT
# define ENABLE_RGB_MATRIX_BAND_VAL
# define ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT
# define ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL
// # define ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT
// # define ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL
# define ENABLE_RGB_MATRIX_CYCLE_ALL
# define ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
# define ENABLE_RGB_MATRIX_CYCLE_UP_DOWN
# define ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
// # define ENABLE_RGB_MATRIX_CYCLE_OUT_IN
// # define ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL
# define ENABLE_RGB_MATRIX_CYCLE_PINWHEEL
// # define ENABLE_RGB_MATRIX_CYCLE_SPIRAL
# define ENABLE_RGB_MATRIX_DUAL_BEACON
# define ENABLE_RGB_MATRIX_RAINBOW_BEACON
# define ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS
// # define ENABLE_RGB_MATRIX_RAINDROPS
// # define ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
# define ENABLE_RGB_MATRIX_HUE_BREATHING
# define ENABLE_RGB_MATRIX_HUE_PENDULUM
# define ENABLE_RGB_MATRIX_HUE_WAVE
// # define ENABLE_RGB_MATRIX_PIXEL_RAIN
// # define ENABLE_RGB_MATRIX_PIXEL_FLOW
// # define ENABLE_RGB_MATRIX_PIXEL_FRACTAL
#endif

View File

@ -0,0 +1,93 @@
/* Copyright 2022 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 <http://www.gnu.org/licenses/>.
*/
#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),
[4] = 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),
[5] = 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),
};
bool encoder_update_user(uint8_t index, bool clockwise) {
if (index == 0) { /* First encoder */
if (clockwise) {
tap_code(KC_VOLU);
} else {
tap_code(KC_VOLD);
}
}
return true;
}
#ifdef RGB_MATRIX_ENABLE
#define XX NO_LED
led_config_t g_led_config = {
{
// Key Matrix to LED Index
{ XX, 7, XX, 6, XX },
{ 0, XX, XX, XX, 5 },
{ XX, XX, XX, XX, XX },
{ 1, XX, XX, XX, 4 },
{ XX, 2, XX, 3, XX }
}, {
// LED Index to Physical Position
{ 0, 16 }, { 0, 48 }, { 56, 64 }, { 168, 64 }, { 224, 48 }, { 224, 16 }, { 168, 0 }, { 56, 0 }
}, {
// LED Index to Flag
2, 2, 2, 2, 2, 2, 2, 2
}
};
#endif

View File

@ -0,0 +1,87 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include QMK_KEYBOARD_H
#include "animation_frames.h"
#ifdef OLED_ENABLE
#define IDLE_FRAME_DURATION 200 // Idle animation iteration rate in ms
oled_rotation_t oled_init_user(oled_rotation_t rotation) { return OLED_ROTATION_270; }
uint32_t anim_timer = 0;
uint8_t current_idle_frame = 0;
// Decompress and write a precompressed bitmap frame to the OLED.
// Documentation and python compression script available at:
// https://github.com/nullbitsco/squeez-o
#ifdef USE_OLED_BITMAP_COMPRESSION
static void oled_write_compressed_P(const char* input_block_map, const char* input_block_list) {
uint16_t block_index = 0;
for (uint16_t i=0; i<NUM_OLED_BYTES; i++) {
uint8_t bit = i%8;
uint8_t map_index = i/8;
uint8_t _block_map = (uint8_t)pgm_read_byte_near(input_block_map + map_index);
uint8_t nonzero_byte = (_block_map & (1 << bit));
if (nonzero_byte) {
const char data = (const char)pgm_read_byte_near(input_block_list + block_index++);
oled_write_raw_byte(data, i);
} else {
const char data = (const char)0x00;
oled_write_raw_byte(data, i);
}
}
}
#endif
static void render_anim(void) {
void animation_phase(void) {
current_idle_frame = (current_idle_frame + 1) % NUM_IDLE_FRAMES;
uint8_t idx = abs((NUM_IDLE_FRAMES - 1) - current_idle_frame);
#ifdef USE_OLED_BITMAP_COMPRESSION
oled_write_compressed_P(idle_block_map[idx], idle_frames[idx]);
#else
oled_write_raw_P(idle_frames[idx], NUM_OLED_BYTES);
#endif
}
if (timer_elapsed32(anim_timer) > IDLE_FRAME_DURATION) {
anim_timer = timer_read32();
animation_phase();
}
}
bool 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\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("FUNC2\n"), false);
break;
case 3:
oled_write_P(PSTR("FUNC3\n"), false);
break;
case 4:
oled_write_P(PSTR("FUNC4\n"), false);
break;
default:
oled_write_P(PSTR("QUACK\n"), false);
break;
}
return false;
}
void suspend_power_down_user(void) {
oled_off();
}
#endif

View File

@ -0,0 +1 @@
# Default Vial keymap for Duckboard R2 and future rounds

View File

@ -0,0 +1,21 @@
# Root overrides
BOOTMAGIC_ENABLE = yes
MOUSEKEY_ENABLE = yes
CONSOLE_ENABLE = no
RGBLIGHT_ENABLE = no
RGB_MATRIX_ENABLE = yes
RGB_MATRIX_DRIVER = WS2812
LTO_ENABLE = yes
# Vial settings
VIA_ENABLE = yes
VIAL_ENABLE = yes
VIAL_ENCODERS_ENABLE = yes
VIALRGB_ENABLE = yes
# Reduce firmware size
QMK_SETTINGS = no
TAP_DANCE_ENABLE = no
COMBO_ENABLE = no
SRC += oled.c

View File

@ -0,0 +1,58 @@
{
"name": "doodboard duckboard",
"vendorId": "0x4442",
"productId": "0x6462",
"lighting": "vialrgb",
"matrix": { "rows": 5, "cols": 5 },
"layouts": {
"labels": ["Split Plus", "Split Enter", "Split Zero"],
"keymap": [
[{ "y": 1, "x": 1, "c": "#aaaaaa" }, "0,1", "0,2", "0,3", "0,4"],
[{ "y": -0.75, "c": "#cccccc" }, "0,1\n\n\n\n\n\n\n\n\ne"],
[
{ "y": -0.25, "x": 1 },
"1,1",
"1,2",
"1,3",
{ "c": "#aaaaaa", "h": 2 },
"2,4\n\n\n0,0",
{ "x": 0.5 },
"1,4\n\n\n0,1"
],
[{ "y": -0.75, "c": "#cccccc" }, "0,0\n\n\n\n\n\n\n\n\ne"],
[
{ "y": -0.25, "x": 1 },
"2,1",
"2,2",
"2,3",
{ "x": 1.5, "c": "#aaaaaa" },
"2,4\n\n\n0,1"
],
[{ "y": -0.5, "c": "#cccccc" }, "3,0"],
[
{ "y": -0.5, "x": 1 },
"3,1",
"3,2",
"3,3",
{ "c": "#aaaaaa", "h": 2 },
"4,4\n\n\n1,0",
{ "x": 0.5 },
"3,4\n\n\n1,1"
],
[
{ "c": "#cccccc" },
"4,0",
{ "w": 2 },
"4,2\n\n\n2,0",
"4,3",
{ "x": 1.5, "c": "#aaaaaa" },
"4,4\n\n\n1,1"
],
[
{ "y": 0.5, "x": 1, "c": "#cccccc" },
"4,1\n\n\n2,1",
"4,2\n\n\n2,1"
]
]
}
}