From 8b059088ba9c310d3790d2839027e966f1082393 Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Sat, 26 Jun 2021 00:00:21 -0500 Subject: [PATCH] =?UTF-8?q?Keyboards/RGBKB/M=C3=BCn=20(#13239)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- keyboards/rgbkb/common/common_oled.c | 101 ++++++ keyboards/rgbkb/common/common_oled.h | 21 ++ keyboards/rgbkb/common/glcdfont.c | 240 ++++++++++++++ keyboards/rgbkb/common/touch_encoder.c | 310 ++++++++++++++++++ keyboards/rgbkb/common/touch_encoder.h | 54 +++ keyboards/rgbkb/mun/.noci | 0 keyboards/rgbkb/mun/config.h | 106 ++++++ keyboards/rgbkb/mun/halconf.h | 24 ++ keyboards/rgbkb/mun/keymaps/default/config.h | 32 ++ keyboards/rgbkb/mun/keymaps/default/keymap.c | 252 ++++++++++++++ keyboards/rgbkb/mun/keymaps/default/rules.mk | 1 + keyboards/rgbkb/mun/keymaps/xulkal2/config.h | 42 +++ keyboards/rgbkb/mun/keymaps/xulkal2/keymap.c | 246 ++++++++++++++ keyboards/rgbkb/mun/keymaps/xulkal2/rules.mk | 4 + keyboards/rgbkb/mun/matrix.c | 156 +++++++++ keyboards/rgbkb/mun/mcuconf.h | 42 +++ keyboards/rgbkb/mun/mun.c | 35 ++ keyboards/rgbkb/mun/mun.h | 16 + keyboards/rgbkb/mun/readme.md | 15 + keyboards/rgbkb/mun/rev1/config.h | 12 + keyboards/rgbkb/mun/rev1/info.json | 101 ++++++ keyboards/rgbkb/mun/rev1/readme.md | 15 + keyboards/rgbkb/mun/rev1/rev1.c | 122 +++++++ keyboards/rgbkb/mun/rev1/rev1.h | 43 +++ .../mun/rev1/rgbkb_mun_rev1_default.json | 13 + keyboards/rgbkb/mun/rev1/rules.mk | 0 keyboards/rgbkb/mun/rules.mk | 46 +++ 27 files changed, 2049 insertions(+) create mode 100644 keyboards/rgbkb/common/common_oled.c create mode 100644 keyboards/rgbkb/common/common_oled.h create mode 100644 keyboards/rgbkb/common/glcdfont.c create mode 100644 keyboards/rgbkb/common/touch_encoder.c create mode 100644 keyboards/rgbkb/common/touch_encoder.h create mode 100644 keyboards/rgbkb/mun/.noci create mode 100644 keyboards/rgbkb/mun/config.h create mode 100644 keyboards/rgbkb/mun/halconf.h create mode 100644 keyboards/rgbkb/mun/keymaps/default/config.h create mode 100644 keyboards/rgbkb/mun/keymaps/default/keymap.c create mode 100644 keyboards/rgbkb/mun/keymaps/default/rules.mk create mode 100644 keyboards/rgbkb/mun/keymaps/xulkal2/config.h create mode 100644 keyboards/rgbkb/mun/keymaps/xulkal2/keymap.c create mode 100644 keyboards/rgbkb/mun/keymaps/xulkal2/rules.mk create mode 100644 keyboards/rgbkb/mun/matrix.c create mode 100644 keyboards/rgbkb/mun/mcuconf.h create mode 100644 keyboards/rgbkb/mun/mun.c create mode 100644 keyboards/rgbkb/mun/mun.h create mode 100644 keyboards/rgbkb/mun/readme.md create mode 100644 keyboards/rgbkb/mun/rev1/config.h create mode 100644 keyboards/rgbkb/mun/rev1/info.json create mode 100644 keyboards/rgbkb/mun/rev1/readme.md create mode 100644 keyboards/rgbkb/mun/rev1/rev1.c create mode 100644 keyboards/rgbkb/mun/rev1/rev1.h create mode 100644 keyboards/rgbkb/mun/rev1/rgbkb_mun_rev1_default.json create mode 100644 keyboards/rgbkb/mun/rev1/rules.mk create mode 100644 keyboards/rgbkb/mun/rules.mk diff --git a/keyboards/rgbkb/common/common_oled.c b/keyboards/rgbkb/common/common_oled.c new file mode 100644 index 000000000..b6ea6b20a --- /dev/null +++ b/keyboards/rgbkb/common/common_oled.c @@ -0,0 +1,101 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this + * notice you can do whatever you want with this stuff. If we meet some day, and + * you think this stuff is worth it, you can buy me a beer in return. David Rauseo + * ---------------------------------------------------------------------------- + */ + +#include "common_oled.h" +#include "oled_driver.h" +#include "rgb_matrix.h" + +// for memcpy +#include +#include + +typedef struct { + bool selecting; + uint8_t selection; +} kb_menu_status_t; + +static kb_menu_status_t rgb_menu = { false, 4 }; +static bool rgb_menu_changed = false; + +void render_logo(void) { + static const char PROGMEM font_logo[] = { + 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94, + 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4, + 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0}; + oled_write_P(font_logo, false); +} + +void render_icon(void) { + static const char PROGMEM font_icon[] = { + 0x9b,0x9c,0x9d,0x9e,0x9f, + 0xbb,0xbc,0xbd,0xbe,0xbf, + 0xdb,0xdc,0xdd,0xde,0xdf,0 + }; + oled_write_P(font_icon, false); +} + +#define RGB_FUNCTION_COUNT 6 +typedef void (*rgb_matrix_f)(void); +const rgb_matrix_f rgb_matrix_functions[RGB_FUNCTION_COUNT][2] = { + { rgb_matrix_increase_hue, rgb_matrix_decrease_hue }, + { rgb_matrix_increase_sat, rgb_matrix_decrease_sat }, + { rgb_matrix_increase_val, rgb_matrix_decrease_val }, + { rgb_matrix_increase_speed, rgb_matrix_decrease_speed }, + { rgb_matrix_step, rgb_matrix_step_reverse }, + { rgb_matrix_toggle, rgb_matrix_toggle } +}; + +void render_rgb_menu(void) { + static char buffer[63] = {0}; + snprintf(buffer, sizeof(buffer), "Hue %3dSatrn %3dValue %3dSpeed %3dMode %3dEnbld %3d", + rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, rgb_matrix_config.speed, rgb_matrix_config.mode, rgb_matrix_config.enable); + + if (rgb_menu.selecting) { + buffer[5 + rgb_menu.selection * 10] = '*'; + } + else { + buffer[5 + rgb_menu.selection * 10] = '>'; + } + oled_write(buffer, false); +} + +void rgb_menu_selection(void) { + if (!is_keyboard_master()) return; + rgb_menu.selecting = !rgb_menu.selecting; + rgb_menu_changed = true; +} + +void rgb_menu_action(bool clockwise) { + if (!is_keyboard_master()) return; + if (rgb_menu.selecting) { + if (!clockwise) { + rgb_menu.selection = (rgb_menu.selection - 1); + if (rgb_menu.selection >= RGB_FUNCTION_COUNT) + rgb_menu.selection = RGB_FUNCTION_COUNT - 1; + } + else { + rgb_menu.selection = (rgb_menu.selection + 1) % RGB_FUNCTION_COUNT; + } + } + else { + (*rgb_matrix_functions[rgb_menu.selection][clockwise])(); + } + rgb_menu_changed = true; +} + +void rgb_menu_update(int8_t transaction_id) { + if (!is_keyboard_master()) return; + if (!rgb_menu_changed) return; + rgb_menu_changed = false; + transaction_rpc_send(transaction_id, sizeof(kb_menu_status_t), &rgb_menu); +} + +void rgb_menu_slave_sync(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer) { + memcpy(&rgb_menu, initiator2target_buffer, sizeof(kb_menu_status_t)); +} \ No newline at end of file diff --git a/keyboards/rgbkb/common/common_oled.h b/keyboards/rgbkb/common/common_oled.h new file mode 100644 index 000000000..a99988b2a --- /dev/null +++ b/keyboards/rgbkb/common/common_oled.h @@ -0,0 +1,21 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this + * notice you can do whatever you want with this stuff. If we meet some day, and + * you think this stuff is worth it, you can buy me a beer in return. David Rauseo + * ---------------------------------------------------------------------------- + */ + +#pragma once + +#include +#include + +void render_logo(void); +void render_icon(void); +void render_rgb_menu(void); +void rgb_menu_selection(void); +void rgb_menu_action(bool clockwise); +void rgb_menu_update(int8_t transaction_id); +void rgb_menu_slave_sync(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer); \ No newline at end of file diff --git a/keyboards/rgbkb/common/glcdfont.c b/keyboards/rgbkb/common/glcdfont.c new file mode 100644 index 000000000..320925a8f --- /dev/null +++ b/keyboards/rgbkb/common/glcdfont.c @@ -0,0 +1,240 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this + * notice you can do whatever you want with this stuff. If we meet some day, and + * you think this stuff is worth it, you can buy me a beer in return. David Rauseo + * ---------------------------------------------------------------------------- + */ + +#include "progmem.h" + +// Helidox 8x6 font with RGBKB SOL Logo +// Online editor: http://teripom.x0.com/ + +static const unsigned char font[] PROGMEM = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00, + 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x00, + 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00, + 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x00, + 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x00, + 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, + 0x00, 0x18, 0x3C, 0x18, 0x00, 0x00, + 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, + 0x00, 0x18, 0x24, 0x18, 0x00, 0x00, + 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x00, + 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x00, + 0x26, 0x29, 0x79, 0x29, 0x26, 0x00, + 0x40, 0x7F, 0x05, 0x05, 0x07, 0x00, + 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x00, + 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x00, + 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x00, + 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x00, + 0x14, 0x22, 0x7F, 0x22, 0x14, 0x00, + 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x00, + 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, + 0x00, 0x66, 0x89, 0x95, 0x6A, 0x00, + 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, + 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x00, + 0x08, 0x04, 0x7E, 0x04, 0x08, 0x00, + 0x10, 0x20, 0x7E, 0x20, 0x10, 0x00, + 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x00, + 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x00, + 0x1E, 0x10, 0x10, 0x10, 0x10, 0x00, + 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x00, + 0x30, 0x38, 0x3E, 0x38, 0x30, 0x00, + 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, + 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, + 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00, + 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00, + 0x23, 0x13, 0x08, 0x64, 0x62, 0x00, + 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, + 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, + 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, + 0x00, 0x41, 0x22, 0x1C, 0x00, 0x00, + 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x00, + 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, + 0x00, 0x80, 0x70, 0x30, 0x00, 0x00, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, + 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, + 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, + 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, + 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00, + 0x72, 0x49, 0x49, 0x49, 0x46, 0x00, + 0x21, 0x41, 0x49, 0x4D, 0x33, 0x00, + 0x18, 0x14, 0x12, 0x7F, 0x10, 0x00, + 0x27, 0x45, 0x45, 0x45, 0x39, 0x00, + 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x00, + 0x41, 0x21, 0x11, 0x09, 0x07, 0x00, + 0x36, 0x49, 0x49, 0x49, 0x36, 0x00, + 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00, + 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x00, 0x40, 0x34, 0x00, 0x00, 0x00, + 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, + 0x00, 0x41, 0x22, 0x14, 0x08, 0x00, + 0x02, 0x01, 0x59, 0x09, 0x06, 0x00, + 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x00, + 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x00, + 0x7F, 0x49, 0x49, 0x49, 0x36, 0x00, + 0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, + 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x00, + 0x7F, 0x49, 0x49, 0x49, 0x41, 0x00, + 0x7F, 0x09, 0x09, 0x09, 0x01, 0x00, + 0x3E, 0x41, 0x41, 0x51, 0x73, 0x00, + 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, + 0x00, 0x41, 0x7F, 0x41, 0x00, 0x00, + 0x20, 0x40, 0x41, 0x3F, 0x01, 0x00, + 0x7F, 0x08, 0x14, 0x22, 0x41, 0x00, + 0x7F, 0x40, 0x40, 0x40, 0x40, 0x00, + 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x00, + 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, + 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, + 0x7F, 0x09, 0x09, 0x09, 0x06, 0x00, + 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00, + 0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, + 0x26, 0x49, 0x49, 0x49, 0x32, 0x00, + 0x03, 0x01, 0x7F, 0x01, 0x03, 0x00, + 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, + 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00, + 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00, + 0x63, 0x14, 0x08, 0x14, 0x63, 0x00, + 0x03, 0x04, 0x78, 0x04, 0x03, 0x00, + 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00, + 0x00, 0x7F, 0x41, 0x41, 0x41, 0x00, + 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, + 0x00, 0x41, 0x41, 0x41, 0x7F, 0x00, + 0x04, 0x02, 0x01, 0x02, 0x04, 0x00, + 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, + 0x00, 0x03, 0x07, 0x08, 0x00, 0x00, + 0x20, 0x54, 0x54, 0x78, 0x40, 0x00, + 0x7F, 0x28, 0x44, 0x44, 0x38, 0x00, + 0x38, 0x44, 0x44, 0x44, 0x28, 0x00, + 0x38, 0x44, 0x44, 0x28, 0x7F, 0x00, + 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, + 0x00, 0x08, 0x7E, 0x09, 0x02, 0x00, + 0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x00, + 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, + 0x00, 0x44, 0x7D, 0x40, 0x00, 0x00, + 0x20, 0x40, 0x40, 0x3D, 0x00, 0x00, + 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, + 0x00, 0x41, 0x7F, 0x40, 0x00, 0x00, + 0x7C, 0x04, 0x78, 0x04, 0x78, 0x00, + 0x7C, 0x08, 0x04, 0x04, 0x78, 0x00, + 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, + 0xFC, 0x18, 0x24, 0x24, 0x18, 0x00, + 0x18, 0x24, 0x24, 0x18, 0xFC, 0x00, + 0x7C, 0x08, 0x04, 0x04, 0x08, 0x00, + 0x48, 0x54, 0x54, 0x54, 0x24, 0x00, + 0x04, 0x04, 0x3F, 0x44, 0x24, 0x00, + 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00, + 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00, + 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00, + 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, + 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x00, + 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, + 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, + 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, + 0x00, 0x41, 0x36, 0x08, 0x00, 0x00, + 0x02, 0x01, 0x02, 0x04, 0x02, 0x00, + 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, + 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, + 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x0C, 0x90, + 0xB0, 0xE0, 0x72, 0x31, 0x9B, 0xDE, + 0xCE, 0xEC, 0xEE, 0xE9, 0xE9, 0xEC, + 0xCF, 0xDA, 0x99, 0x3E, 0x62, 0xE4, + 0xC4, 0x70, 0x10, 0x10, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, + 0xC0, 0xC0, 0x80, 0x80, 0x02, 0x85, + 0x85, 0x87, 0x85, 0x89, 0x89, 0x92, + 0xEA, 0xC6, 0xC4, 0x48, 0x50, 0x60, + 0x40, 0x40, 0x40, 0x40, 0xC0, 0xE0, + 0x50, 0x28, 0x10, 0x10, 0x60, 0xC0, + 0x40, 0x40, 0x40, 0x40, 0x80, 0x80, + 0x80, 0x80, 0x80, 0xE0, 0xF8, 0xFC, + 0xF8, 0xF0, 0x00, 0x00, 0x00, 0x00, + 0xE0, 0xF0, 0xF0, 0xF0, 0xE0, 0xEC, + 0xEE, 0xF7, 0xF3, 0x70, 0x20, 0x00, + 0x7C, 0x7C, 0x7C, 0x7E, 0x00, 0x7E, + 0x7E, 0x7E, 0x7F, 0x7F, 0x7F, 0x00, + 0x00, 0x80, 0xC0, 0xE0, 0x7E, 0x5B, + 0x4F, 0x5B, 0xFE, 0xC0, 0x00, 0x00, + 0x00, 0x00, 0xF0, 0xF4, 0xEC, 0xDE, + 0xDE, 0xBE, 0x3E, 0x3E, 0x3F, 0x3F, + 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x3F, + 0x3F, 0x3E, 0x3E, 0xBE, 0xDE, 0xDE, + 0xEC, 0xF4, 0xF0, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x7F, 0x80, 0x80, + 0x80, 0x70, 0x0F, 0x00, 0x00, 0x80, + 0x7F, 0x00, 0x00, 0x7F, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x7F, + 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0xFF, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x40, 0x21, 0x33, 0x3B, 0x7B, + 0xFF, 0x00, 0x7C, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x7C, 0x01, + 0xFF, 0xDE, 0x8C, 0x04, 0x0C, 0x08, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x7F, 0x80, + 0x80, 0xBE, 0xBE, 0x80, 0x80, 0x80, + 0xC1, 0xFF, 0x80, 0x04, 0x32, 0x5E, + 0x1C, 0x3D, 0x26, 0x10, 0xC1, 0xFF, + 0x3E, 0x00, 0x00, 0x08, 0x36, 0xC1, + 0x08, 0x08, 0x14, 0x77, 0x94, 0x94, + 0x94, 0xF7, 0x94, 0xF7, 0x9C, 0x9C, + 0xFF, 0xFF, 0x1E, 0x00, 0x00, 0x00, + 0x0F, 0x1F, 0x3F, 0x7F, 0x7F, 0x7F, + 0x7F, 0x7F, 0x3F, 0x1E, 0x0C, 0x00, + 0x1F, 0x1F, 0x1F, 0x3F, 0x00, 0x3F, + 0x3F, 0x3F, 0x7F, 0x7F, 0x7F, 0x00, + 0x30, 0x7B, 0x7F, 0x78, 0x30, 0x20, + 0x20, 0x30, 0x78, 0x7F, 0x3B, 0x00, + 0x00, 0x00, 0x01, 0x0F, 0x3F, 0xFF, + 0xFF, 0xFF, 0xFC, 0xE0, 0x80, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x80, 0xE0, 0xFC, 0xFF, 0xFF, 0xFF, + 0x3F, 0x0F, 0x01, 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, 0x06, 0x02, 0x06, + 0x4D, 0x4F, 0x8C, 0xF9, 0x73, 0x37, + 0x27, 0x2F, 0x2F, 0xAF, 0xEF, 0x6F, + 0x77, 0x17, 0x33, 0x79, 0xCC, 0x1F, + 0x31, 0x20, 0x21, 0x02, 0x02, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x40, 0xE0, + 0xA0, 0xA0, 0xD0, 0x90, 0x48, 0x48, + 0x25, 0x2B, 0x11, 0x09, 0x05, 0x03, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x03, 0x02, 0x04, 0x03, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x03, 0x0F, 0x1F, + 0x0F, 0x03, 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, + 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, + 0xFE, 0xFC, 0x00, 0xFC, 0xFE, 0x7F, + 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; diff --git a/keyboards/rgbkb/common/touch_encoder.c b/keyboards/rgbkb/common/touch_encoder.c new file mode 100644 index 000000000..6293739ec --- /dev/null +++ b/keyboards/rgbkb/common/touch_encoder.c @@ -0,0 +1,310 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this + * notice you can do whatever you want with this stuff. If we meet some day, and + * you think this stuff is worth it, you can buy me a beer in return. Ryan Caltabiano + * ---------------------------------------------------------------------------- + */ + +#include "i2c_master.h" +#include "keyboard.h" +#include "touch_encoder.h" +#include "print.h" +#include "wait.h" +#include "timer.h" + +// for memcpy +#include +#include + +#define I2C_ADDRESS 0x1C +#define CALIBRATION_BIT 0x80 +#define OVERFLOW_BIT 0x40 +#define SLIDER_BIT 0x02 + +#ifndef TOUCH_UPDATE_INTERVAL +# define TOUCH_UPDATE_INTERVAL 33 +#endif + +enum { // QT2120 registers + QT_CHIP_ID = 0, + QT_FIRMWARE_VERSION, + QT_DETECTION_STATUS, + QT_KEY_STATUS, + QT_SLIDER_POSITION = 5, + QT_CALIBRATE, + QT_RESET, + QT_LP, + QT_TTD, + QT_ATD, + QT_DI, + QT_TRD, + QT_DHT, + QT_SLIDER_OPTION, + QT_CHARDE_TIME, + QT_KEY0_DTHR, + QT_KEY1_DTHR, + QT_KEY2_DTHR, + QT_KEY3_DTHR, + QT_KEY4_DTHR, + QT_KEY5_DTHR, + QT_KEY6_DTHR, + QT_KEY7_DTHR, + QT_KEY8_DTHR, + QT_KEY9_DTHR, + QT_KEY10_DTHR, + QT_KEY11_DTHR, + QT_KEY0_CTRL, + QT_KEY1_CTRL, + QT_KEY2_CTRL, + QT_KEY3_CTRL, + QT_KEY4_CTRL, + QT_KEY5_CTRL, + QT_KEY6_CTRL, + QT_KEY7_CTRL, + QT_KEY8_CTRL, + QT_KEY9_CTRL, + QT_KEY10_CTRL, + QT_KEY11_CTRL, + QT_KEY0_PULSE_SCALE, + QT_KEY1_PULSE_SCALE, + QT_KEY2_PULSE_SCALE, + QT_KEY3_PULSE_SCALE, + QT_KEY4_PULSE_SCALE, + QT_KEY5_PULSE_SCALE, + QT_KEY6_PULSE_SCALE, + QT_KEY7_PULSE_SCALE, + QT_KEY8_PULSE_SCALE, + QT_KEY9_PULSE_SCALE, + QT_KEY10_PULSE_SCALE, + QT_KEY11_PULSE_SCALE, + QT_KEY0_SIGNAL, + QT_KEY1_SIGNAL = 54, + QT_KEY2_SIGNAL = 56, + QT_KEY3_SIGNAL = 58, + QT_KEY4_SIGNAL = 60, + QT_KEY5_SIGNAL = 62, + QT_KEY6_SIGNAL = 64, + QT_KEY7_SIGNAL = 66, + QT_KEY8_SIGNAL = 68, + QT_KEY9_SIGNAL = 70, + QT_KEY10_SIGNAL = 72, + QT_KEY11_SIGNAL = 74, + QT_KEY0_REFERENCE = 76, + QT_KEY1_REFERENCE = 78, + QT_KEY2_REFERENCE = 80, + QT_KEY3_REFERENCE = 82, + QT_KEY4_REFERENCE = 84, + QT_KEY5_REFERENCE = 86, + QT_KEY6_REFERENCE = 88, + QT_KEY7_REFERENCE = 90, + QT_KEY8_REFERENCE = 92, + QT_KEY9_REFERENCE = 94, + QT_KEY10_REFERENCE = 96, + QT_KEY11_REFERENCE = 98, +}; + +bool touch_initialized = false; +bool touch_disabled = false; +uint8_t touch_handness = 0; +// touch_raw & touch_processed store the Detection Status, Key Status (x2), and Slider Position values +uint8_t touch_raw[4] = { 0 }; +uint8_t touch_processed[4] = { 0 }; + +uint16_t touch_timer = 0; +uint16_t touch_update_timer = 0; + +// For split transport only +typedef struct { + uint8_t position; + uint8_t taps; +} slave_touch_status_t; + +bool touch_slave_init = false; +slave_touch_status_t touch_slave_state = { 0, 0 }; + +static bool write_register8(uint8_t address, uint8_t data) { + i2c_status_t status = i2c_writeReg((I2C_ADDRESS << 1), address, &data, sizeof(data), I2C_TIMEOUT); + if (status != I2C_STATUS_SUCCESS) { + xprintf("write_register8 %d failed %d\n", address, status); + } + return status == I2C_STATUS_SUCCESS; +} + +static bool read_register(uint8_t address, uint8_t* data, uint16_t length) { + i2c_status_t status = i2c_readReg((I2C_ADDRESS << 1), address, data, length, I2C_TIMEOUT); + if (status != I2C_STATUS_SUCCESS) { + xprintf("read_register %d failed %d\n", address, status); + return false; + } + return true; +} + +void touch_encoder_init(void) { + i2c_init(); + + touch_handness = is_keyboard_left() ? 0 : 1; + + // Set QT to slider mode + touch_initialized = write_register8(QT_SLIDER_OPTION, 0x80); + touch_initialized &= write_register8(QT_TTD, 4); // Toward Drift - 20 @ 3.2s + touch_initialized &= write_register8(QT_ATD, 1); // Away Drift - 5 @ 0.8s + touch_initialized &= write_register8(QT_DI, 4); // Detection Integrator - 4 + touch_initialized &= write_register8(QT_TRD, 0); // Touch Recall - 48 + touch_encoder_calibrate(); +} + +__attribute__((weak)) bool touch_encoder_tapped_kb(uint8_t index, uint8_t section) { return touch_encoder_tapped_user(index, section); } +__attribute__((weak)) bool touch_encoder_update_kb(uint8_t index, bool clockwise) { return touch_encoder_update_user(index, clockwise); } + +__attribute__((weak)) bool touch_encoder_tapped_user(uint8_t index, uint8_t section) { return true; } +__attribute__((weak)) bool touch_encoder_update_user(uint8_t index, bool clockwise) { return true; } + +static void touch_encoder_update_tapped(void) { + // Started touching, being counter for TOUCH_TERM + if (touch_processed[0] & SLIDER_BIT) { + touch_timer = timer_read() + TOUCH_TERM; + return; + } + + // Touch held too long, bail + if (timer_expired(timer_read(), touch_timer)) return; + + uint8_t section = touch_processed[3] / (UINT8_MAX / TOUCH_SEGMENTS + 1); + xprintf("tap %d %d\n", touch_handness, section); + if (is_keyboard_master()) { + if (!touch_disabled) { + touch_encoder_tapped_kb(touch_handness, section); + } + } + else { + touch_slave_state.taps ^= (1 << section); + } +} + +static void touch_encoder_update_position_common(uint8_t* position, uint8_t raw, uint8_t index) { + int8_t delta = (*position - raw) / TOUCH_RESOLUTION; + bool clockwise = raw > *position; + if (delta == 0) return; + + // Don't store raw directly, as we want to ensure any remainder is kept and used next time this is called + *position -= delta * TOUCH_RESOLUTION; + xprintf("pos %d %d\n", index, raw); + //uint8_t u_delta = delta < 0 ? -delta : delta; + if (!touch_disabled) { + //for (uint8_t i = 0; i < u_delta; i++) + touch_encoder_update_kb(index, clockwise); + } +} + +static void touch_encoder_update_position(void) { + // If the user touchs and moves enough, expire touch_timer faster and do encoder position logic instead + if (!timer_expired(timer_read(), touch_timer)) { + if ((uint8_t)(touch_raw[3] - touch_processed[3]) <= TOUCH_DEADZONE) return; + touch_timer = timer_read(); + } + + if (is_keyboard_master()) { + touch_encoder_update_position_common(&touch_processed[3], touch_raw[3], touch_handness); + } + else { + touch_slave_state.position = touch_raw[3]; + } +} + +void touch_encoder_update_slave(slave_touch_status_t slave_state) { + if (!touch_slave_init) { + touch_slave_state = slave_state; + touch_slave_init = true; + return; + } + + if (touch_slave_state.position != slave_state.position) { + // Did a new slide event start? + uint8_t mask = (1 << 7); + if ((touch_slave_state.taps & mask) != (slave_state.taps & mask)) { + touch_slave_state.position = slave_state.position; + } + touch_encoder_update_position_common(&touch_slave_state.position, slave_state.position, !touch_handness); + } + + if (touch_slave_state.taps != slave_state.taps) { + if (!touch_disabled) { + for (uint8_t section = 0; section < TOUCH_SEGMENTS; section++) { + uint8_t mask = (1 << section); + if ((touch_slave_state.taps & mask) != (slave_state.taps & mask)) { + xprintf("tap %d %d\n", !touch_handness, section); + touch_encoder_tapped_kb(!touch_handness, section); + } + } + } + touch_slave_state.taps = slave_state.taps; + } +} + +void touch_encoder_update(int8_t transaction_id) { + if (!touch_initialized) return; +#if TOUCH_UPDATE_INTERVAL > 0 + if (!timer_expired(timer_read(), touch_update_timer)) return; + touch_update_timer = timer_read() + TOUCH_UPDATE_INTERVAL; +#endif + + read_register(QT_DETECTION_STATUS, &touch_raw[0], sizeof(touch_raw)); + touch_processed[1] = touch_raw[1]; + touch_processed[2] = touch_raw[2]; + + if (touch_raw[0] != touch_processed[0]) { + uint8_t delta = touch_raw[0] ^ touch_processed[0]; + touch_processed[0] = touch_raw[0]; + // When calibrating, normal sensor behavior is supended + if (delta & CALIBRATION_BIT) { + xprintf("calibration %d\n", touch_processed[0] >> 7 & 1); + } + if (delta & OVERFLOW_BIT) { + xprintf("overflow %d\n", touch_processed[0] >> 6 & 1); + } + if (delta & SLIDER_BIT) { + touch_processed[3] = touch_raw[3]; + if (!is_keyboard_master()) { + touch_slave_state.position = touch_raw[3]; + touch_slave_state.taps ^= (1 << 7); + } + touch_encoder_update_tapped(); + } + } + + if ((touch_raw[0] & SLIDER_BIT) && touch_processed[3] != touch_raw[3]) { + touch_encoder_update_position(); + } + + if (is_keyboard_master()) { + slave_touch_status_t slave_state; + if (transaction_rpc_exec(transaction_id, sizeof(bool), &touch_disabled, sizeof(slave_touch_status_t), &slave_state)) { + if (memcmp(&touch_slave_state, &slave_state, sizeof(slave_touch_status_t))) + touch_encoder_update_slave(slave_state); + } + } +} + +void touch_encoder_calibrate(void) { + if (!touch_initialized) return; + write_register8(QT_CALIBRATE, 0x01); +} + +bool touch_encoder_calibrating(void) { + return touch_raw[0] & CALIBRATION_BIT; +} + +void touch_encoder_toggle(void) { + touch_disabled = !touch_disabled; +} + +bool touch_encoder_toggled(void) { + return touch_disabled; +} + +void touch_encoder_slave_sync(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer) { + touch_disabled = *(bool*)initiator2target_buffer; + memcpy(target2initiator_buffer, &touch_slave_state, sizeof(slave_touch_status_t)); +} diff --git a/keyboards/rgbkb/common/touch_encoder.h b/keyboards/rgbkb/common/touch_encoder.h new file mode 100644 index 000000000..022f61906 --- /dev/null +++ b/keyboards/rgbkb/common/touch_encoder.h @@ -0,0 +1,54 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this + * notice you can do whatever you want with this stuff. If we meet some day, and + * you think this stuff is worth it, you can buy me a beer in return. Ryan Caltabiano + * ---------------------------------------------------------------------------- + */ + +#pragma once + +#include +#include + +#ifndef TOUCH_TERM +# define TOUCH_TERM 350 +#endif + +#ifndef TOUCH_SEGMENTS +# define TOUCH_SEGMENTS 3 +#elif TOUCH_SEGMENTS < 1 || TOUCH_SEGMENTS > 5 +# error TOUCH_SEGMENTS must be between 1 and 5. +#endif + +#ifndef TOUCH_DEADZONE +# define TOUCH_DEADZONE 50 +#endif + +#ifndef TOUCH_RESOLUTION +# define TOUCH_RESOLUTION 25 +#endif + +void touch_encoder_init(void); +void touch_encoder_update(int8_t transaction_id); + +void touch_encoder_calibrate(void); +bool touch_encoder_calibrating(void); + +void touch_encoder_toggle(void); +bool touch_encoder_toggled(void); + +// Called when touch encoder is tapped, weak function overridable by the kb +bool touch_encoder_tapped_kb(uint8_t index, uint8_t section); + +// Called when touch encoder is slid, weak function overridable by the kb +bool touch_encoder_update_kb(uint8_t index, bool clockwise); + +// Called when touch encoder is tapped, weak function overridable by the user +bool touch_encoder_tapped_user(uint8_t index, uint8_t section); + +// Called when touch encoder is slid, weak function overridable by the user +bool touch_encoder_update_user(uint8_t index, bool clockwise); + +void touch_encoder_slave_sync(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer); diff --git a/keyboards/rgbkb/mun/.noci b/keyboards/rgbkb/mun/.noci new file mode 100644 index 000000000..e69de29bb diff --git a/keyboards/rgbkb/mun/config.h b/keyboards/rgbkb/mun/config.h new file mode 100644 index 000000000..802672e14 --- /dev/null +++ b/keyboards/rgbkb/mun/config.h @@ -0,0 +1,106 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this + * notice you can do whatever you want with this stuff. If we meet some day, and + * you think this stuff is worth it, you can buy me a beer in return. David Rauseo + * ---------------------------------------------------------------------------- + */ + +#pragma once + +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0x3535 +#define PRODUCT_ID 0x3505 +#define MANUFACTURER RGBKB +#define PRODUCT Mün + +#define USB_POLLING_INTERVAL_MS 1 + +/* Matrix Configuration - Rows are doubled up */ +#define MATRIX_ROWS 14 +// B1, A2 reserved for encoder / touch encoder support +#define MATRIX_ROW_PINS { A1, A3, B3, A13, B15, B1, A2 } +#define MATRIX_COLS 7 +#define MATRIX_COL_PINS { A0, B11, B0, B10, B12, B2, A8 } +#define MATRIX_IO_DELAY 5 + +#define BUSY_WAIT +#define BUSY_WAIT_INSTRUCTIONS 35 // Increase if two rows are pressed at the same time. +#define GPIO_INPUT_PIN_DELAY 10 + +/* Touchbar adjustments */ +#define TOUCH_DEADZONE 50 // width of a "button", wider inputs will be interpreted as a swipe +#define TOUCH_TERM 350 // time of a "button" touch, longer inputs will be a swipe +#define TOUCH_RESOLUTION 25 // sensitivity of swipes, lower=faster + +/* Encoder Configuration */ +#define ENCODERS_PAD_A { B8, B9 } +#define ENCODERS_PAD_B { A14, A15 } +#define TOUCH_SEGMENTS 3 + +/* COL2ROW or ROW2COL */ +#define DIODE_DIRECTION COL2ROW + +/* CRC Configuration */ +#define CRC8_OPTIMIZE_SPEED +#define CRC8_USE_TABLE + +/* Split Keyboard Configuration */ +#define EE_HANDS +#define SPLIT_USB_DETECT +// also handles the SERIAL_USART_TX_PIN define +#define SOFT_SERIAL_PIN A9 +#define SERIAL_USART_TX_PAL_MODE 7 +#define SERIAL_USART_TIMEOUT 5 +#define SERIAL_USART_DRIVER SD1 +//#define SERIAL_USART_FULL_DUPLEX - Waiting on reunification pr +#if SERIAL_USART_FULL_DUPLEX + #define SERIAL_USART_RX_PIN A10 + #define SERIAL_USART_RX_PAL_MODE 7 + // Mun connects TX to TX and RX to RX as we were planning on i2c split, so we need pin swap for full duplex + #define SERIAL_USART_PIN_SWAP + #define SERIAL_USART_SPEED (2 * 1024 * 1024) +#else + #define SERIAL_USART_SPEED (1 * 1024 * 1024) +#endif + +/* Split Transport Features */ +#define SPLIT_TRANSPORT_MIRROR +#define SPLIT_LAYER_STATE_ENABLE +#define SPLIT_LED_STATE_ENABLE +#define SPLIT_TRANSACTION_IDS_KB TOUCH_ENCODER_SYNC, RGB_MENU_SYNC + +/* RGB LED Configuration */ +#define RGB_DI_PIN B5 +#define RGBLED_NUM 98 +#define RGBLED_SPLIT { 49, 49 } +#define RGBLIGHT_ANIMATIONS + +#define DRIVER_LED_TOTAL RGBLED_NUM +#define RGB_MATRIX_SPLIT RGBLED_SPLIT +#define RGB_MATRIX_CENTER { 128, 34 } +#define RGB_MATRIX_LED_FLUSH_LIMIT 33 +#define RGB_MATRIX_LED_PROCESS_LIMIT 10 +#define RGB_MATRIX_KEYPRESSES +#define RGB_MATRIX_FRAMEBUFFER_EFFECTS +#define RGB_DISABLE_WHEN_USB_SUSPENDED true + +#if RGB_UNLIMITED_POWER + #define RGBLIGHT_LIMIT_VAL 255 +#else + #define RGBLIGHT_LIMIT_VAL 127 +#endif +#define RGB_MATRIX_MAXIMUM_BRIGHTNESS RGBLIGHT_LIMIT_VAL + +#define WS2812_PWM_DRIVER PWMD3 +#define WS2812_PWM_CHANNEL 2 +#define WS2812_PWM_PAL_MODE 2 +#define WS2812_DMA_STREAM STM32_DMA1_STREAM3 +#define WS2812_DMA_CHANNEL 3 + +#define TOUCH_UPDATE_INTERVAL 33 +#define OLED_UPDATE_INTERVAL 33 +#define TAP_CODE_DELAY 5 diff --git a/keyboards/rgbkb/mun/halconf.h b/keyboards/rgbkb/mun/halconf.h new file mode 100644 index 000000000..c8d832a81 --- /dev/null +++ b/keyboards/rgbkb/mun/halconf.h @@ -0,0 +1,24 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this + * notice you can do whatever you want with this stuff. If we meet some day, and + * you think this stuff is worth it, you can buy me a beer in return. David Rauseo + * ---------------------------------------------------------------------------- + */ + +#pragma once + +//#define HAL_USE_DAC TRUE + +//#define HAL_USE_GPT TRUE + +#define HAL_USE_I2C TRUE + +#define HAL_USE_PWM TRUE + +#define HAL_USE_SERIAL TRUE + +#define HAL_USE_SERIAL_USB TRUE + +#include_next diff --git a/keyboards/rgbkb/mun/keymaps/default/config.h b/keyboards/rgbkb/mun/keymaps/default/config.h new file mode 100644 index 000000000..3d9aff94a --- /dev/null +++ b/keyboards/rgbkb/mun/keymaps/default/config.h @@ -0,0 +1,32 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this + * notice you can do whatever you want with this stuff. If we meet some day, and + * you think this stuff is worth it, you can buy me a beer in return. David Rauseo + * ---------------------------------------------------------------------------- + */ + +#pragma once + +// No need for the single versions when multi performance isn't a problem =D +#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE +#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS +#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS +#define DISABLE_RGB_MATRIX_SPLASH +#define DISABLE_RGB_MATRIX_SOLID_SPLASH + +// 20m timeout (20m * 60s * 1000mil) +// #define RGB_DISABLE_TIMEOUT 1200000 +#define RGB_DISABLE_WHEN_USB_SUSPENDED true + + +#define VIA_EEPROM_LAYOUT_OPTIONS_SIZE 2 +// 224B per layer right now +#define DYNAMIC_KEYMAP_LAYER_COUNT 8 +#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 2047 + +#define VIA_QMK_RGBLIGHT_ENABLE + +#define STM32_ONBOARD_EEPROM_SIZE 2048 + diff --git a/keyboards/rgbkb/mun/keymaps/default/keymap.c b/keyboards/rgbkb/mun/keymaps/default/keymap.c new file mode 100644 index 000000000..b120c3a37 --- /dev/null +++ b/keyboards/rgbkb/mun/keymaps/default/keymap.c @@ -0,0 +1,252 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this + * notice you can do whatever you want with this stuff. If we meet some day, and + * you think this stuff is worth it, you can buy me a beer in return. David Rauseo + * ---------------------------------------------------------------------------- + */ + +#include QMK_KEYBOARD_H +#include "common_oled.h" + +enum keymap_layers { + _QWERTY, + _COLEMAK, + _GAME, + _FN, + _ADJUST, + _VIA1, + _VIA2, + _VIA3 +}; + +enum keymap_keycodes { + // Disables touch processing + TCH_TOG = SAFE_RANGE, + MENU_BTN, + MENU_UP, + MENU_DN +}; + +// Default Layers +#define QWERTY DF(_QWERTY) +#define COLEMAK DF(_COLEMAK) +#define GAME DF(_GAME) + +// Momentary Layers +#define FN MO(_FN) +#define ADJUST MO(_ADJUST) + +#define FN_CAPS LT(_FN, KC_CAPS) +#define FN_ESC LT(_FN, KC_ESC) + +/* This keyboard is enabled with an RGB Menu Control system. +This functionality is enabled, but still requires a little configuration based on your exact setup. +The RGB Menu will appear on the Right Half's OLED and can be controlled by the MENU keycodes: +MENU_BTN - Triggers a button action for the menu +MENU_UP - Triggers an increase action for the menu +MENU_DN - Triggers a decrease action for the menu + +To finish configuration for your board, you will want to change the default keycodes for an encoder on the right half. +Encoder press keycode should be set to MENU_BTN, Clockwise should be MENU_UP, and Counter Clockwise should be MENU_DN. +Depending on where you add an encoder to the right half will determin in the default keymap where you should put those keycodes. +*/ + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* QWERTY + * .--------------------------------------------------------------. .--------------------------------------------------------------. + * | `~/ESC | 1 | 2 | 3 | 4 | 5 | - | | = | 6 | 7 | 8 | 9 | 0 | Bckspc | + * |--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| + * | Tab | Q | W | E | R | T | [ | | ] | Y | U | I | O | P | \ | + * |--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| + * | FN/Caps| A | S | D | F | G | ( | | ) | H | J | K | L | : | ' | + * |--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| + * | Shift | Z | X | C | V | B | { | | } | N | M | , | . | / |Shft/Ent| + * |--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| + * | Ctrl | Win | Alt | RGBTOG | Adjust | Space | Bksp | | Enter | Space | Left | Down | Up | Right | Ctrl | + * '--------+--------+--------+--------+--------+--------+--------' '--------+--------+--------+--------+--------+--------+--------' + * Encoder 1 Encoder 2 Encoder 3 Encoder 4 + * .-----------------------------------. .-----------------------------------. + * | VolUp | VolDn | VolUp | VolDn | | PgUp | PgDn | PgUp | PgDn | + * |--------+--------+--------+--------+--------. .--------+--------+--------+--------+--------| + * | VolDn | VolUp | Next | Play | Prev | Touch Encoder Touch Encoder | RgbHuI | RgbHuD | RgbMdD | RgbTog | RgbMdI | + * '--------+--------+--------+--------+--------' '--------+--------+--------+--------+--------' + */ + [_QWERTY] = LAYOUT( + KC_GESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_MINS, KC_EQL, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_LBRC, KC_RBRC, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLASH, + FN_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_LPRN, KC_RPRN, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_LCBR, KC_RCBR, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_SFTENT, + KC_LCTL, KC_LGUI, KC_LALT, RGB_TOG, ADJUST, KC_SPC, KC_DEL, KC_ENT, KC_SPC, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT,KC_RCTL, + + KC_VOLU, KC_VOLD, KC_VOLU, KC_VOLD, KC_PGDN, KC_PGUP, KC_PGDN, KC_PGUP, + KC_VOLD, KC_VOLU, KC_MNXT, KC_MPLY, KC_MPRV, RGB_HUI, RGB_HUD, RGB_RMOD,RGB_TOG, RGB_MOD + ), + + [_COLEMAK] = LAYOUT( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, KC_Q, KC_W, KC_F, KC_P, KC_G, _______, _______, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, _______, + _______, KC_A, KC_R, KC_S, KC_T, KC_D, _______, _______, KC_H, KC_N, KC_E, KC_I, KC_O, _______, + _______, KC_Z, KC_X, KC_C, KC_V, KC_B, _______, _______, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + + _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ + ), + + [_GAME] = LAYOUT( + _______, _______, _______, _______, _______, _______, KC_F1, KC_F5, _______, _______, _______, _______, _______, _______, + _______, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_F2, KC_F6, KC_Y, KC_U, KC_I, KC_O, KC_P, _______, + _______, KC_A, KC_S, KC_D, KC_F, KC_G, KC_F3, KC_F7, KC_H, KC_J, KC_K, KC_L, KC_SCLN, _______, + _______, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_F4, KC_F8, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, _______, + _______, KC_NO, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + + _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ + ), + + [_FN] = LAYOUT( + _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F11, KC_F12, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, _______, + _______, KC_HOME, KC_UP, KC_END, _______, _______, _______, _______, _______, KC_HOME, KC_UP, KC_END, KC_PSCR, KC_PGUP, + _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_RGHT, KC_INS, KC_PGDN, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, TCH_TOG, _______, _______, _______, _______, _______, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, + + _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ + ), + + [_ADJUST] = LAYOUT( + _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F11, KC_F12, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, _______, + _______, RGB_SAD, RGB_VAI, RGB_SAI, RESET, _______, _______, _______, _______, KC_P7, KC_P8, KC_P9, _______, _______, + _______, RGB_HUD, RGB_VAD, RGB_HUI, _______, _______, _______, _______, _______, KC_P4, KC_P5, KC_P6, _______, _______, + _______, RGB_SPD, _______, RGB_SPI, _______, _______, _______, _______, _______, KC_P1, KC_P2, KC_P3, _______, GAME, + _______, RGB_RMOD,_______, RGB_MOD, _______, _______, _______, _______, _______, KC_P0, KC_PDOT, KC_NLCK, QWERTY, COLEMAK, + + _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ + ), + + [_VIA1] = LAYOUT( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + + _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ + ), + + [_VIA2] = LAYOUT( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + + _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ + ), + + [_VIA3] = LAYOUT( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + + _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ + ), +}; + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) + { + case MENU_BTN: + if (record->event.pressed) { + rgb_menu_selection(); + } + return false; + case MENU_UP: + if (record->event.pressed) { + rgb_menu_action(true); + } + return false; + case MENU_DN: + if (record->event.pressed) { + rgb_menu_action(false); + } + return false; + case TCH_TOG: + if (record->event.pressed) { + touch_encoder_toggle(); + } + return false; // Skip all further processing of this key + default: + return true; + } +} + +static void render_layer(void) { + // Host Keyboard Layer Status + oled_write_P(PSTR("Layer"), false); + switch (get_highest_layer(layer_state)) { + case _QWERTY: + oled_write_ln_P(PSTR("QWRTY"), false); + break; + case _COLEMAK: + oled_write_ln_P(PSTR("Colemk"), false); + break; + case _GAME: + oled_write_ln_P(PSTR("Game "), false); + break; + case _FN: + oled_write_ln_P(PSTR("FN "), false); + break; + case _ADJUST: + oled_write_ln_P(PSTR("Adjst"), false); + break; + default: + oled_write_ln_P(PSTR("Undef"), false); + } +} + +static void render_leds(void) +{ + // Host Keyboard LED Status + led_t led_state = host_keyboard_led_state(); + oled_write_P(led_state.num_lock ? PSTR("NUMLK") : PSTR(" "), false); + oled_write_P(led_state.caps_lock ? PSTR("CAPLK") : PSTR(" "), false); + oled_write_P(led_state.scroll_lock ? PSTR("SCRLK") : PSTR(" "), false); +} + +static void render_touch(void) +{ + // Host Touch LED Status + oled_write_P(!touch_encoder_toggled() ? PSTR("TOUCH") : PSTR(" "), false); + oled_write_P(touch_encoder_calibrating() ? PSTR("CLBRT") : PSTR(" "), false); +} + +void oled_task_user(void) { + if (is_keyboard_left()) { + render_icon(); + oled_write_P(PSTR(" "), false); + render_layer(); + oled_write_P(PSTR(" "), false); + render_leds(); + oled_write_P(PSTR(" "), false); + render_touch(); + } + else { + render_icon(); + oled_write_P(PSTR(" "), false); + render_rgb_menu(); + } +} + +oled_rotation_t oled_init_user(oled_rotation_t rotation) { + return OLED_ROTATION_270; +} diff --git a/keyboards/rgbkb/mun/keymaps/default/rules.mk b/keyboards/rgbkb/mun/keymaps/default/rules.mk new file mode 100644 index 000000000..1e5b99807 --- /dev/null +++ b/keyboards/rgbkb/mun/keymaps/default/rules.mk @@ -0,0 +1 @@ +VIA_ENABLE = yes diff --git a/keyboards/rgbkb/mun/keymaps/xulkal2/config.h b/keyboards/rgbkb/mun/keymaps/xulkal2/config.h new file mode 100644 index 000000000..f78d0103c --- /dev/null +++ b/keyboards/rgbkb/mun/keymaps/xulkal2/config.h @@ -0,0 +1,42 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this + * notice you can do whatever you want with this stuff. If we meet some day, and + * you think this stuff is worth it, you can buy me a beer in return. David Rauseo + * ---------------------------------------------------------------------------- + */ + +#pragma once + +// Xulkal custom stuff +#undef TAPPING_FORCE_HOLD + +#undef TAPPING_TERM +#define TAPPING_TERM 175 + +#define SPACE_CADET_MODIFIER_CARRYOVER +#define LSPO_KEYS KC_LSFT, KC_TRNS, KC_LBRC +#define RSPC_KEYS KC_RSFT, KC_TRNS, KC_RBRC +#define LCPO_KEYS KC_LCTL, KC_TRNS, KC_MINS +#define RCPC_KEYS KC_RCTL, KC_TRNS, KC_EQL + +// No need for the single versions when multi performance isn't a problem =D +#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE +#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS +#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS +#define DISABLE_RGB_MATRIX_SPLASH +#define DISABLE_RGB_MATRIX_SOLID_SPLASH + +// 20m timeout (20m * 60s * 1000mil) +// #define RGB_DISABLE_TIMEOUT 1200000 +#define RGB_DISABLE_WHEN_USB_SUSPENDED true +#define OLED_SCROLL_TIMEOUT 20000 +#define ONESHOT_TAP_TOGGLE 2 + +#define RGB_MATRIX_HUE_STEP 8 +#define RGB_MATRIX_SAT_STEP 8 +#define RGB_MATRIX_VAL_STEP 8 +#define RGB_MATRIX_SPD_STEP 8 + +#define ENCODER_RESOLUTION 2 \ No newline at end of file diff --git a/keyboards/rgbkb/mun/keymaps/xulkal2/keymap.c b/keyboards/rgbkb/mun/keymaps/xulkal2/keymap.c new file mode 100644 index 000000000..2de5888f1 --- /dev/null +++ b/keyboards/rgbkb/mun/keymaps/xulkal2/keymap.c @@ -0,0 +1,246 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this + * notice you can do whatever you want with this stuff. If we meet some day, and + * you think this stuff is worth it, you can buy me a beer in return. David Rauseo + * ---------------------------------------------------------------------------- + */ + +#include QMK_KEYBOARD_H +#include "common_oled.h" + +enum keymap_layers { + _QWERTY, + _FUNCTION, + _ADJUST +}; + +enum keymap_keycodes { + // Disables touch processing + TCH_TOG = SAFE_RANGE, + MENU_BTN, + MENU_UP, + MENU_DN, + RGB_RST +}; + +// Default Layers +#define QWERTY DF(_QWERTY) + +// Momentary Layers +#define FN OSL(_FUNCTION) +#define ADJ OSL(_ADJUST) + +// clang-format off +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* QWERTY + * .--------------------------------------------------------------. .--------------------------------------------------------------. + * | `~/ESC | 1 | 2 | 3 | 4 | 5 | | | | 6 | 7 | 8 | 9 | 0 | Bckspc | + * |--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| + * | Tab | Q | W | E | R | T | | | | Y | U | I | O | P | \ | + * |--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| + * | Caps | A | S | D | F | G | Play | | MN BTN | H | J | K | L | : | Enter | + * |--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| + * | Shft[ | Z | X | C | V | B | { | | } | N | M | , | . | / | Shft] | + * |--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| + * | Ctrl- | Win | Alt | Del | Space | | ADJ | | FN | | Space | '" | Alt | App | Ctrl= | + * '--------+--------+--------+--------|--------+--------+--------' '--------+--------+--------+--------+--------+--------+--------' + * Encoder 1 Encoder 2 Encoder 3 Encoder 4 + * .-----------------------------------. .-----------------------------------. + * | VolUp | VolDn | VolUp | VolDn | | PgUp | PgDn | PgUp | PgDn | + * |--------+--------+--------+--------+--------. .--------+--------+--------+--------+--------| + * | VolDn | VolUp | Next | Play | Prev | Touch Encoder Touch Encoder | RgbHuI | RgbHuD | RgbMdD | RgbTog | RgbMdI | + * '--------+--------+--------+--------+--------' '--------+--------+--------+--------+--------' + */ + [_QWERTY] = LAYOUT( + KC_GESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_NO, KC_NO, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_NO, KC_NO, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_MPLY, MENU_BTN,KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_ENT, + KC_LSPO, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_LCBR, KC_RCBR, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSPC, + KC_LCPO, KC_LGUI, KC_LALT, KC_DEL, KC_SPC, KC_NO, ADJ, FN, KC_NO, KC_SPC, KC_QUOTE,KC_RALT, KC_APP, KC_RCPC, + + KC_VOLU, KC_VOLD, KC_VOLU, KC_VOLD, MENU_DN, MENU_UP, MENU_DN, MENU_UP, + KC_VOLD, KC_VOLU, KC_MNXT, KC_MPLY, KC_MPRV, RGB_HUI, RGB_HUD, RGB_RMOD,RGB_TOG, RGB_MOD + ), + + /* Function + * .--------------------------------------------------------------. .--------------------------------------------------------------. + * | F12 | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | F11 | + * |--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| + * | | SPDI | SAI | VAI | HUI | RGBMD | | | | | | PrtScr | ScrLck | PseBrk | | + * |--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| + * | | SPDD | SAD | VAD | HUD | RGBRMD | | | | | | Ins | Home | PgUp | | + * |--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| + * | | RGBRST | | | | RGBTOG | | | | | | Del | End | PgDn | | + * |--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| + * | | | | | | | | | | | Play | Prev | Next | VolUp | VolDn | + * '--------+--------+--------+--------+--------+--------+--------' '--------+--------+--------+--------+--------+--------+--------' + * Encoder 1 Encoder 2 Encoder 3 Encoder 4 + * .-----------------------------------. .-----------------------------------. + * | | | | | | | | | | + * |--------+--------+--------+--------+--------. .--------+--------+--------+--------+--------| + * | | | | | | Touch Encoder Touch Encoder | | | | | | + * '--------+--------+--------+--------+--------' '--------+--------+--------+--------+--------' + */ + [_FUNCTION] = LAYOUT( + KC_F12, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, _______, _______, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, + _______, RGB_SPI, RGB_SAI, RGB_VAI, RGB_HUI, RGB_MOD, _______, _______, _______, _______, KC_PSCR, KC_SLCK, KC_PAUS, _______, + _______, RGB_SPD, RGB_SAD, RGB_VAD, RGB_HUD, RGB_RMOD,_______, _______, _______, _______, KC_INS, KC_HOME, KC_PGUP, _______, + _______, RGB_RST, _______, _______, _______, RGB_TOG, _______, _______, _______, _______, KC_DEL, KC_END, KC_PGDN, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPLY, KC_MPRV, KC_MNXT, KC_VOLU, KC_VOLD, + + _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ + ), + + /* Adjust + * .--------------------------------------------------------------. .--------------------------------------------------------------. + * | | | | | | | | | | | NumLck | / | * | - | Del | + * |--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| + * | | Home | Up | End | Reset | T_TOG | | | | | 7 | 8 | 9 | + | | + * |--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| + * | | Left | Down | Right | | | | | | | 4 | 5 | 6 | + | | + * |--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| + * | | | | | | EepRst | | | | | 1 | 2 | 3 | Enter | | + * |--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| + * | | | | | | | | | | | | 0 | . | Enter | | + * '--------+--------+--------+--------+--------+--------+--------' '--------+--------+--------+--------+--------+--------+--------' + * Encoder 1 Encoder 2 Encoder 3 Encoder 4 + * .-----------------------------------. .-----------------------------------. + * | | | | | | | | | | + * |--------+--------+--------+--------+--------. .--------+--------+--------+--------+--------| + * | | | | | | Touch Encoder Touch Encoder | | | | | | + * '--------+--------+--------+--------+--------' '--------+--------+--------+--------+--------' + */ + [_ADJUST] = LAYOUT( + KC_GRV, _______, _______, _______, _______, _______, _______, _______, _______, KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, KC_DEL, + _______, KC_HOME, KC_UP, KC_END, RESET, TCH_TOG, _______, _______, _______, KC_KP_7, KC_KP_8, KC_KP_9, KC_PPLS, _______, + _______, KC_LEFT, KC_DOWN, KC_RIGHT,_______, _______, _______, _______, _______, KC_KP_4, KC_KP_5, KC_KP_6, KC_PPLS, _______, + _______, _______, _______, _______, _______, EEP_RST, _______, _______, _______, KC_KP_1, KC_KP_2, KC_KP_3, KC_PENT, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_KP_0, KC_PDOT, KC_PENT, _______, + + _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ + ) +}; +// clang-format on + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) + { + case MENU_BTN: + if (record->event.pressed) { + rgb_menu_selection(); + } + return false; + case MENU_UP: + if (record->event.pressed) { + rgb_menu_action(true); + } + return false; + case MENU_DN: + if (record->event.pressed) { + rgb_menu_action(false); + } + return false; + case RGB_RST: + if (record->event.pressed) { + eeconfig_update_rgb_matrix_default(); + } + return false; + case TCH_TOG: + if (record->event.pressed) { + touch_encoder_toggle(); + } + return false; // Skip all further processing of this key + default: + return true; + } +} + +static void render_layer(void) { + // Host Keyboard Layer Status + oled_write_P(PSTR("Layer"), false); + switch (get_highest_layer(layer_state)) { + case _QWERTY: + oled_write_ln_P(PSTR("BASE "), false); + break; + case _FUNCTION: + oled_write_ln_P(PSTR("FUNC "), false); + break; + case _ADJUST: + oled_write_ln_P(PSTR("ADJS "), false); + break; + } +} + +static void render_leds(void) +{ + // Host Keyboard LED Status + led_t led_state = host_keyboard_led_state(); + oled_write_P(led_state.num_lock ? PSTR("NUMLK") : PSTR(" "), false); + oled_write_P(led_state.caps_lock ? PSTR("CAPLK") : PSTR(" "), false); + oled_write_P(led_state.scroll_lock ? PSTR("SCRLK") : PSTR(" "), false); +} + +static void render_touch(void) +{ + // Host Touch LED Status + oled_write_P(!touch_encoder_toggled() ? PSTR("TOUCH") : PSTR(" "), false); + oled_write_P(touch_encoder_calibrating() ? PSTR("CLBRT") : PSTR(" "), false); +} + +/*static uint32_t scan_counter = 0; +static uint32_t scan_value = 0; +static uint16_t scan_timer = 1000; + +void do_counters(void) { + scan_counter++; + uint16_t now = sync_timer_read(); + if (timer_expired(now, scan_timer)) + { + scan_timer += 1000; + scan_value = (scan_value + scan_counter) / 2; + scan_counter = 0; + } +} + +void matrix_scan_user(void) { + do_counters(); +} + +void matrix_slave_scan_user(void) { + do_counters(); +} + +void render_debug_scan(void) { + static char buffer[6] = {0}; + snprintf(buffer, sizeof(buffer), "%5d", scan_value); + oled_write_ln_P(buffer, false); +}*/ + +void oled_task_user(void) { + if (is_keyboard_left()) { + render_layer(); + oled_write_P(PSTR(" "), false); + render_leds(); + oled_write_P(PSTR(" "), false); + render_touch(); + //oled_write_P(PSTR(" "), false); + //render_debug_scan(); + oled_set_cursor(0, 12); + render_icon(); + } + else { + render_rgb_menu(); + //oled_write_P(PSTR(" "), false); + //render_debug_scan(); + oled_set_cursor(0, 12); + render_icon(); + } +} + +oled_rotation_t oled_init_user(oled_rotation_t rotation) { + return OLED_ROTATION_270; +} \ No newline at end of file diff --git a/keyboards/rgbkb/mun/keymaps/xulkal2/rules.mk b/keyboards/rgbkb/mun/keymaps/xulkal2/rules.mk new file mode 100644 index 000000000..b62630516 --- /dev/null +++ b/keyboards/rgbkb/mun/keymaps/xulkal2/rules.mk @@ -0,0 +1,4 @@ +MOUSEKEY_ENABLE = yes # using for mouse wheel up and down, more granular than page up/down + +OPT_DEFS += -DRGB_UNLIMITED_POWER +DEBOUNCE_TYPE = sym_eager_pk \ No newline at end of file diff --git a/keyboards/rgbkb/mun/matrix.c b/keyboards/rgbkb/mun/matrix.c new file mode 100644 index 000000000..a0cb7df51 --- /dev/null +++ b/keyboards/rgbkb/mun/matrix.c @@ -0,0 +1,156 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this + * notice you can do whatever you want with this stuff. If we meet some day, and + * you think this stuff is worth it, you can buy me a beer in return. KarlK90 + * ---------------------------------------------------------------------------- + */ + +#include +#include +#include +#include "util.h" +#include "matrix.h" +#include "debounce.h" +#include "quantum.h" +#include "split_util.h" +#include "config.h" +#include "transactions.h" + +#define ERROR_DISCONNECT_COUNT 5 +#define ROWS_PER_HAND (MATRIX_ROWS / 2) + +static const pin_t row_pins[ROWS_PER_HAND] = MATRIX_ROW_PINS; +static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; + +/* matrix state(1:on, 0:off) */ +extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values +extern matrix_row_t matrix[MATRIX_ROWS]; // debounced values + +// row offsets for each hand +uint8_t thisHand, thatHand; + +// user-defined overridable functions +__attribute__((weak)) void matrix_slave_scan_kb(void) { matrix_slave_scan_user(); } +__attribute__((weak)) void matrix_slave_scan_user(void) {} + +static void init_pins(void) { + for (size_t i = 0; i < MATRIX_COLS; i++) { + setPinInputHigh(col_pins[i]); + } + for (size_t i = 0; i < ROWS_PER_HAND; i++) { + setPinOutput(row_pins[i]); + writePinHigh(row_pins[i]); + } +} + +void matrix_init(void) { + split_pre_init(); + + thisHand = isLeftHand ? 0 : (ROWS_PER_HAND); + thatHand = ROWS_PER_HAND - thisHand; + + // initialize key pins + init_pins(); + + // initialize matrix state: all keys off + memset(raw_matrix, 0, sizeof(raw_matrix)); + memset(matrix, 0, sizeof(matrix)); + + debounce_init(ROWS_PER_HAND); + + matrix_init_quantum(); + + split_post_init(); +} + +bool matrix_post_scan(void) { + bool changed = false; + if (is_keyboard_master()) { + static uint8_t error_count; + + matrix_row_t slave_matrix[ROWS_PER_HAND] = {0}; + if (!transport_master(matrix + thisHand, slave_matrix)) { + error_count++; + + if (error_count > ERROR_DISCONNECT_COUNT) { + // reset other half if disconnected + memset(&matrix[thatHand], 0, sizeof(slave_matrix)); + memset(slave_matrix, 0, sizeof(slave_matrix)); + + changed = true; + } + } else { + error_count = 0; + + if (memcmp(&matrix[thatHand], slave_matrix, sizeof(slave_matrix)) != 0) { + memcpy(&matrix[thatHand], slave_matrix, sizeof(slave_matrix)); + changed = true; + } + } + + matrix_scan_quantum(); + } else { + transport_slave(matrix + thatHand, matrix + thisHand); + + matrix_slave_scan_kb(); + } + + return changed; +} + +uint8_t matrix_scan(void) { + bool local_changed = false; + matrix_row_t current_matrix[ROWS_PER_HAND]; + + for (size_t row_idx = 0; row_idx < ROWS_PER_HAND; row_idx++) { + /* Drive row pin low. */ + ATOMIC_BLOCK_FORCEON { writePinLow(row_pins[row_idx]); } + matrix_output_select_delay(); + + /* Read all columns in one go, aka port scanning. */ + uint16_t porta = palReadPort(GPIOA); + uint16_t portb = palReadPort(GPIOB); + + /* Order of pins on the mun is: A0, B11, B0, B10, B12, B2, A8 + Pin is active low, therefore we have to invert the result. */ + matrix_row_t cols = ~(((porta & (0x1 << 0)) >> 0) // A0 (0) + | ((portb & (0x1 << 11)) >> 10) // B11 (1) + | ((portb & (0x1 << 0)) << 2) // B0 (2) + | ((portb & (0x1 << 10)) >> 7) // B10 (3) + | ((portb & (0x1 << 12)) >> 8) // B12 (4) + | ((portb & (0x1 << 2)) << 3) // B2 (5) + | ((porta & (0x1 << 8)) >> 2)); // A8 (6) + + /* Reverse the order of columns for left hand as the board is flipped. */ + // if (isLeftHand) { + // #if defined(__arm__) + // /* rbit assembly reverses bit order of 32bit registers. */ + // uint32_t temp = cols; + // __asm__("rbit %0, %1" : "=r"(temp) : "r"(temp)); + // cols = temp >> 24; + // #else + // /* RISC-V bit manipulation extension not present. Use bit-hack. + // https://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith32Bits */ + // cols = (matrix_row_t)(((cols * 0x0802LU & 0x22110LU) | (cols * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16); + // #endif + // } + + current_matrix[row_idx] = cols; + + /* Drive row pin high again. */ + ATOMIC_BLOCK_FORCEON { writePinHigh(row_pins[row_idx]); } + matrix_output_unselect_delay(); + } + + if (memcmp(raw_matrix, current_matrix, sizeof(current_matrix)) != 0) { + memcpy(raw_matrix, current_matrix, sizeof(current_matrix)); + local_changed = true; + } + + debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, local_changed); + + bool remote_changed = matrix_post_scan(); + return (uint8_t)(local_changed || remote_changed); +} \ No newline at end of file diff --git a/keyboards/rgbkb/mun/mcuconf.h b/keyboards/rgbkb/mun/mcuconf.h new file mode 100644 index 000000000..acc083d8a --- /dev/null +++ b/keyboards/rgbkb/mun/mcuconf.h @@ -0,0 +1,42 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this + * notice you can do whatever you want with this stuff. If we meet some day, and + * you think this stuff is worth it, you can buy me a beer in return. David Rauseo + * ---------------------------------------------------------------------------- + */ + +#pragma once + +#include_next + +#undef STM32_DAC_USE_DAC1_CH1 +#define STM32_DAC_USE_DAC1_CH1 TRUE + +#undef STM32_DAC_USE_DAC1_CH2 +#define STM32_DAC_USE_DAC1_CH2 TRUE + +#undef STM32_GPT_USE_TIM6 +#define STM32_GPT_USE_TIM6 TRUE + +#undef STM32_GPT_USE_TIM7 +#define STM32_GPT_USE_TIM7 TRUE + +#undef STM32_GPT_USE_TIM8 +#define STM32_GPT_USE_TIM8 TRUE + +#undef STM32_GPT_USE_TIM15 +#define STM32_GPT_USE_TIM15 TRUE + +#undef STM32_I2C_USE_I2C1 +#define STM32_I2C_USE_I2C1 TRUE + +#undef STM32_PWM_USE_TIM3 +#define STM32_PWM_USE_TIM3 TRUE + +#undef STM32_PWM_USE_TIM4 +#define STM32_PWM_USE_TIM4 TRUE + +#undef STM32_SERIAL_USE_USART1 +#define STM32_SERIAL_USE_USART1 TRUE \ No newline at end of file diff --git a/keyboards/rgbkb/mun/mun.c b/keyboards/rgbkb/mun/mun.c new file mode 100644 index 000000000..5dabecc13 --- /dev/null +++ b/keyboards/rgbkb/mun/mun.c @@ -0,0 +1,35 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this + * notice you can do whatever you want with this stuff. If we meet some day, and + * you think this stuff is worth it, you can buy me a beer in return. David Rauseo + * ---------------------------------------------------------------------------- + */ + +#include "mun.h" +#include "touch_encoder.h" +#include "common_oled.h" +#include + +void keyboard_post_init_kb(void) +{ + touch_encoder_init(); + transaction_register_rpc(TOUCH_ENCODER_SYNC, touch_encoder_slave_sync); + transaction_register_rpc(RGB_MENU_SYNC, rgb_menu_slave_sync); + keyboard_post_init_user(); +} + +void housekeeping_task_kb(void) +{ + touch_encoder_update(TOUCH_ENCODER_SYNC); + rgb_menu_update(RGB_MENU_SYNC); +} + +#if defined(BUSY_WAIT) +void matrix_output_unselect_delay(void) { + for (int32_t i = 0; i < BUSY_WAIT_INSTRUCTIONS; i++) { + __asm__ volatile("nop" ::: "memory"); + } +} +#endif \ No newline at end of file diff --git a/keyboards/rgbkb/mun/mun.h b/keyboards/rgbkb/mun/mun.h new file mode 100644 index 000000000..beb132f0e --- /dev/null +++ b/keyboards/rgbkb/mun/mun.h @@ -0,0 +1,16 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this + * notice you can do whatever you want with this stuff. If we meet some day, and + * you think this stuff is worth it, you can buy me a beer in return. David Rauseo + * ---------------------------------------------------------------------------- + */ + +#pragma once + +#if defined(KEYBOARD_rgbkb_mun_rev1) +# include "rev1.h" +#endif + +#include "quantum.h" \ No newline at end of file diff --git a/keyboards/rgbkb/mun/readme.md b/keyboards/rgbkb/mun/readme.md new file mode 100644 index 000000000..6a1861153 --- /dev/null +++ b/keyboards/rgbkb/mun/readme.md @@ -0,0 +1,15 @@ +# Mün + +![Mün](https://i.redd.it/zw534js2o5861.jpg) + +Mün is powered by STM32 with full QMK support. Each key has super-bright RGB backlighting and MX Kailh hotswap sockets. No soldering is required to get a fully functioning keyboard. There are an additional 14 rear-facing RGB LEDs on each side. Each half can be configured to run as master or slave with the two USB-C ports. They also support up to two rotary encoders and one OLED panel per half. + +Keyboard Maintainer: [Legonut](https://github.com/Legonut) +Hardware Supported: Mün PCB R1.0, R1.1, R1.2 +Hardware Availability: [RGBKB](https://www.rgbkb.net) + +Make example for this keyboard (after setting up your build environment): + + make rgbkb/mun: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/rgbkb/mun/rev1/config.h b/keyboards/rgbkb/mun/rev1/config.h new file mode 100644 index 000000000..7ff0b5490 --- /dev/null +++ b/keyboards/rgbkb/mun/rev1/config.h @@ -0,0 +1,12 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this + * notice you can do whatever you want with this stuff. If we meet some day, and + * you think this stuff is worth it, you can buy me a beer in return. David Rauseo + * ---------------------------------------------------------------------------- + */ + +#pragma once + +#define DEVICE_VER 0x0001 diff --git a/keyboards/rgbkb/mun/rev1/info.json b/keyboards/rgbkb/mun/rev1/info.json new file mode 100644 index 000000000..c644b9bdc --- /dev/null +++ b/keyboards/rgbkb/mun/rev1/info.json @@ -0,0 +1,101 @@ +{ + "keyboard_name": "Mun", + "url": "https://www.rgbkb.net/products/mun", + "maintainer": "Legonut", + "width": 13.5, + "height": 6.5, + "layouts": { + "LAYOUT": { + "layout": [ + {"label":"L00", "x":0, "y":0}, + {"label":"L01", "x":1, "y":0}, + {"label":"L02", "x":2, "y":0}, + {"label":"L03", "x":3, "y":0}, + {"label":"L04", "x":4, "y":0}, + {"label":"L05", "x":5, "y":0}, + {"label":"L06", "x":6, "y":0}, + {"label":"R00", "x":7.5, "y":0}, + {"label":"R01", "x":8.5, "y":0}, + {"label":"R02", "x":9.5, "y":0}, + {"label":"R03", "x":10.5, "y":0}, + {"label":"R04", "x":11.5, "y":0}, + {"label":"R05", "x":12.5, "y":0}, + {"label":"R06", "x":13.5, "y":0}, + {"label":"L10", "x":0, "y":1}, + {"label":"L11", "x":1, "y":1}, + {"label":"L12", "x":2, "y":1}, + {"label":"L13", "x":3, "y":1}, + {"label":"L14", "x":4, "y":1}, + {"label":"L15", "x":5, "y":1}, + {"label":"L16", "x":6, "y":1}, + {"label":"R10", "x":7.5, "y":1}, + {"label":"R11", "x":8.5, "y":1}, + {"label":"R12", "x":9.5, "y":1}, + {"label":"R13", "x":10.5, "y":1}, + {"label":"R14", "x":11.5, "y":1}, + {"label":"R15", "x":12.5, "y":1}, + {"label":"R16", "x":13.5, "y":1}, + {"label":"L20", "x":0, "y":2}, + {"label":"L21", "x":1, "y":2}, + {"label":"L22", "x":2, "y":2}, + {"label":"L23", "x":3, "y":2}, + {"label":"L24", "x":4, "y":2}, + {"label":"L25", "x":5, "y":2}, + {"label":"L26", "x":6, "y":2}, + {"label":"R20", "x":7.5, "y":2}, + {"label":"R21", "x":8.5, "y":2}, + {"label":"R22", "x":9.5, "y":2}, + {"label":"R23", "x":10.5, "y":2}, + {"label":"R24", "x":11.5, "y":2}, + {"label":"R25", "x":12.5, "y":2}, + {"label":"R26", "x":13.5, "y":2}, + {"label":"L30", "x":0, "y":3}, + {"label":"L31", "x":1, "y":3}, + {"label":"L32", "x":2, "y":3}, + {"label":"L33", "x":3, "y":3}, + {"label":"L34", "x":4, "y":3}, + {"label":"L35", "x":5, "y":3}, + {"label":"L36", "x":6, "y":3}, + {"label":"R30", "x":7.5, "y":3}, + {"label":"R21", "x":8.5, "y":3}, + {"label":"R32", "x":9.5, "y":3}, + {"label":"R33", "x":10.5, "y":3}, + {"label":"R34", "x":11.5, "y":3}, + {"label":"R35", "x":12.5, "y":3}, + {"label":"R36", "x":13.5, "y":3}, + {"label":"L40", "x":0, "y":4}, + {"label":"L41", "x":1, "y":4}, + {"label":"L42", "x":2, "y":4}, + {"label":"L43", "x":3, "y":4}, + {"label":"L44", "x":4, "y":4}, + {"label":"L45", "x":5, "y":4}, + {"label":"L46", "x":6, "y":4}, + {"label":"R40", "x":7.5, "y":4}, + {"label":"R41", "x":8.5, "y":4}, + {"label":"R42", "x":9.5, "y":4}, + {"label":"R43", "x":10.5, "y":4}, + {"label":"R44", "x":11.5, "y":4}, + {"label":"R45", "x":12.5, "y":4}, + {"label":"R46", "x":13.5, "y":4}, + {"label":"E00", "x":0, "y":5.5}, + {"label":"E01", "x":1, "y":5.5}, + {"label":"E10", "x":2, "y":5.5}, + {"label":"E11", "x":3, "y":5.5}, + {"label":"E20", "x":10.5, "y":5.5}, + {"label":"E21", "x":11.5, "y":5.5}, + {"label":"E30", "x":12.5, "y":5.5}, + {"label":"E31", "x":13.5, "y":5.5}, + {"label":"T00", "x":0, "y":6.5}, + {"label":"T01", "x":1, "y":6.5}, + {"label":"T02", "x":2, "y":6.5}, + {"label":"T03", "x":3, "y":6.5}, + {"label":"T04", "x":4, "y":6.5}, + {"label":"T10", "x":9.5, "y":6.5}, + {"label":"T11", "x":10.5, "y":6.5}, + {"label":"T12", "x":11.5, "y":6.5}, + {"label":"T13", "x":12.5, "y":6.5}, + {"label":"T14", "x":13.5, "y":6.5} + ] + } + } +} diff --git a/keyboards/rgbkb/mun/rev1/readme.md b/keyboards/rgbkb/mun/rev1/readme.md new file mode 100644 index 000000000..6a1861153 --- /dev/null +++ b/keyboards/rgbkb/mun/rev1/readme.md @@ -0,0 +1,15 @@ +# Mün + +![Mün](https://i.redd.it/zw534js2o5861.jpg) + +Mün is powered by STM32 with full QMK support. Each key has super-bright RGB backlighting and MX Kailh hotswap sockets. No soldering is required to get a fully functioning keyboard. There are an additional 14 rear-facing RGB LEDs on each side. Each half can be configured to run as master or slave with the two USB-C ports. They also support up to two rotary encoders and one OLED panel per half. + +Keyboard Maintainer: [Legonut](https://github.com/Legonut) +Hardware Supported: Mün PCB R1.0, R1.1, R1.2 +Hardware Availability: [RGBKB](https://www.rgbkb.net) + +Make example for this keyboard (after setting up your build environment): + + make rgbkb/mun: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/rgbkb/mun/rev1/rev1.c b/keyboards/rgbkb/mun/rev1/rev1.c new file mode 100644 index 000000000..28ad843b5 --- /dev/null +++ b/keyboards/rgbkb/mun/rev1/rev1.c @@ -0,0 +1,122 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this + * notice you can do whatever you want with this stuff. If we meet some day, and + * you think this stuff is worth it, you can buy me a beer in return. David Rauseo + * ---------------------------------------------------------------------------- + */ + +#include "rev1.h" + +#define NUMBER_OF_TOUCH_ENCODERS 2 +#define TOUCH_ENCODER_OPTIONS TOUCH_SEGMENTS + 2 + +#define NUMBER_OF_ENCODERS 4 +#define ENCODER_OPTIONS 2 + +typedef struct PACKED { + uint8_t r; + uint8_t c; +} encodermap_t; + +// this maps encoders and then touch encoders to their respective electrical matrix entry +// mapping is row (y) then column (x) when looking at the electrical layout +const encodermap_t encoder_map[NUMBER_OF_ENCODERS][ENCODER_OPTIONS] = +{ + { { 5, 0 }, { 5, 1 } }, // Encoder 1 matrix entries + { { 5, 2 }, { 5, 3 } }, // Encoder 2 matrix entries + { { 12, 0 }, { 12, 1 } }, // Encoder 3 matrix entries + { { 12, 2 }, { 12, 3 } }, // Encoder 4 matrix entries +}; + +const encodermap_t touch_encoder_map[NUMBER_OF_TOUCH_ENCODERS][TOUCH_ENCODER_OPTIONS] = +{ + { { 6, 0 }, { 6, 1 }, { 6, 2 }, { 6, 3 }, { 6, 4 } }, // Touch Encoder 1 matrix entries + { { 13, 0 }, { 13, 1 }, { 13, 2 }, { 13, 3 }, { 13, 4 } } // Touch Encoder 2 matrix entries +}; + +static void process_encoder_matrix(encodermap_t pos) { + action_exec((keyevent_t){ + .key = (keypos_t){.row = pos.r, .col = pos.c}, .pressed = true, .time = (timer_read() | 1) /* time should not be 0 */ + }); +#if TAP_CODE_DELAY > 0 + wait_ms(TAP_CODE_DELAY); +#endif + action_exec((keyevent_t){ + .key = (keypos_t){.row = pos.r, .col = pos.c}, .pressed = false, .time = (timer_read() | 1) /* time should not be 0 */ + }); +} + +bool encoder_update_kb(uint8_t index, bool clockwise) { + if (!encoder_update_user(index, clockwise)) + return false; + + // Mapping clockwise (typically increase) to zero, and counter clockwise (decrease) to 1 + process_encoder_matrix(encoder_map[index][clockwise ? 0 : 1]); + return false; +} + +bool touch_encoder_update_kb(uint8_t index, bool clockwise) { + if (!touch_encoder_update_user(index, clockwise)) + return false; + + // Mapping clockwise (typically increase) to zero, and counter clockwise (decrease) to 1 + process_encoder_matrix(touch_encoder_map[index][clockwise ? 0 : 1]); + return false; +} + +bool touch_encoder_tapped_kb(uint8_t index, uint8_t section) { + if (!touch_encoder_tapped_user(index, section)) + return false; + + process_encoder_matrix(touch_encoder_map[index][section + 2]); + return false; +} + +#ifdef RGB_MATRIX_ENABLE +// clang-format off +led_config_t g_led_config = { { + { 0, 1, 2, 3, 4, 5, 6 }, + { 13, 12, 11, 10, 9, 8, 7 }, + { 14, 15, 16, 17, 18, 19, 20 }, + { 27, 26, 25, 24, 23, 22, 21 }, + { 28, 29, 30, 31, 32, 33, 34 }, + { NO_LED, NO_LED, NO_LED, NO_LED, NO_LED }, + { NO_LED, NO_LED, NO_LED, NO_LED, NO_LED }, + { 49, 50, 51, 52, 53, 54, 55 }, + { 62, 61, 60, 59, 58, 57, 56 }, + { 63, 64, 65, 66, 67, 68, 69 }, + { 76, 75, 74, 73, 72, 71, 70 }, + { 77, 78, 79, 80, 81, 82, 83 }, + { NO_LED, NO_LED, NO_LED, NO_LED, NO_LED }, + { NO_LED, NO_LED, NO_LED, NO_LED, NO_LED } +}, { + { 16, 16},{ 34, 16},{ 49, 16},{ 64, 16},{ 79, 16},{ 94, 16},{ 109, 16}, + { 109, 31},{ 94, 31},{ 79, 31},{ 64, 31},{ 49, 31},{ 34, 31},{ 16, 31}, + { 16, 46},{ 34, 46},{ 49, 46},{ 64, 46},{ 79, 46},{ 94, 46},{ 109, 46}, + { 109, 61},{ 94, 61},{ 79, 61},{ 64, 61},{ 49, 61},{ 34, 61},{ 16, 61}, + { 16, 76},{ 34, 76},{ 49, 76},{ 64, 76},{ 83, 72},{ 98, 72},{ 113, 72}, + { 97, 5},{ 91, 5},{ 86, 5},{ 80, 5},{ 75, 5},{ 69, 5},{ 63, 5},{ 58, 5},{ 52, 5},{ 46, 5},{ 41, 5},{ 35, 5},{ 30, 5},{ 24, 5}, + { 240, 16},{ 222, 16},{ 207, 16},{ 192, 16},{ 177, 16},{ 162, 16},{ 147, 16}, + { 147, 31},{ 162, 31},{ 177, 31},{ 192, 31},{ 207, 31},{ 222, 31},{ 240, 31}, + { 240, 46},{ 222, 46},{ 207, 46},{ 192, 46},{ 177, 46},{ 162, 46},{ 147, 46}, + { 147, 61},{ 162, 61},{ 177, 61},{ 192, 61},{ 207, 61},{ 222, 61},{ 240, 61}, + { 240, 76},{ 222, 76},{ 207, 76},{ 192, 76},{ 180, 72},{ 165, 72},{ 150, 72}, + { 159, 5},{ 164, 5},{ 170, 5},{ 176, 5},{ 181, 5},{ 187, 5},{ 192, 5},{ 198, 5},{ 204, 5},{ 209, 5},{ 215, 5},{ 221, 5},{ 226, 5},{ 232, 5}, +}, { + 1, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 1, + 1, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 1, + 1, 1, 1, 1, 1, 1, 1, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 1, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 1, + 1, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 1, + 1, 1, 1, 1, 1, 1, 1, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 +} }; +// clang-format on +#endif diff --git a/keyboards/rgbkb/mun/rev1/rev1.h b/keyboards/rgbkb/mun/rev1/rev1.h new file mode 100644 index 000000000..8e7b65f45 --- /dev/null +++ b/keyboards/rgbkb/mun/rev1/rev1.h @@ -0,0 +1,43 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this + * notice you can do whatever you want with this stuff. If we meet some day, and + * you think this stuff is worth it, you can buy me a beer in return. David Rauseo + * ---------------------------------------------------------------------------- + */ + +#pragma once + +#include "mun.h" +#include "touch_encoder.h" + +// clang-format off +#define LAYOUT( \ + L00, L01, L02, L03, L04, L05, L06, R00, R01, R02, R03, R04, R05, R06, \ + L10, L11, L12, L13, L14, L15, L16, R10, R11, R12, R13, R14, R15, R16, \ + L20, L21, L22, L23, L24, L25, L26, R20, R21, R22, R23, R24, R25, R26, \ + L30, L31, L32, L33, L34, L35, L36, R30, R31, R32, R33, R34, R35, R36, \ + L40, L41, L42, L43, L44, L45, L46, R40, R41, R42, R43, R44, R45, R46, \ + E00, E01, E10, E11, E20, E21, E30, E31, \ + T00, T01, T02, T03, T04, T10, T11, T12, T13, T14 \ +) \ +{ \ + /* Left Half */ \ + { L00, L01, L02, L03, L04, L05, L06 }, \ + { L10, L11, L12, L13, L14, L15, L16 }, \ + { L20, L21, L22, L23, L24, L25, L26 }, \ + { L30, L31, L32, L33, L34, L35, L36 }, \ + { L40, L41, L42, L43, L44, L45, L46 }, \ + { E00, E01, E10, E11, KC_NO, KC_NO, KC_NO }, \ + { T00, T01, T02, T03, T04, KC_NO, KC_NO }, \ + /* Right Half */ \ + { R06, R05, R04, R03, R02, R01, R00 }, \ + { R16, R15, R14, R13, R12, R11, R10 }, \ + { R26, R25, R24, R23, R22, R21, R20 }, \ + { R36, R35, R34, R33, R32, R31, R30 }, \ + { R46, R45, R44, R43, R42, R41, R40 }, \ + { E20, E21, E30, E31, KC_NO, KC_NO, KC_NO }, \ + { T10, T11, T12, T13, T14, KC_NO, KC_NO } \ +} +// clang-format on diff --git a/keyboards/rgbkb/mun/rev1/rgbkb_mun_rev1_default.json b/keyboards/rgbkb/mun/rev1/rgbkb_mun_rev1_default.json new file mode 100644 index 000000000..ccf70ef5f --- /dev/null +++ b/keyboards/rgbkb/mun/rev1/rgbkb_mun_rev1_default.json @@ -0,0 +1,13 @@ +{ + "keyboard": "rgbkb/mun/rev1", + "keymap": "default", + "commit": "xxxxxxxxxxxxxxxxxxxxx", + "layout": "LAYOUT", + "layers": [ + ["KC_GESC","KC_1","KC_2","KC_3","KC_4","KC_5","KC_MINS","KC_EQL","KC_6","KC_7","KC_8","KC_9","KC_0","KC_BSPC","KC_TAB","KC_Q","KC_W","KC_E","KC_R","KC_T","KC_LBRC","KC_RBRC","KC_Y","KC_U","KC_I","KC_O","KC_P","KC_BSLS","LT(3,KC_CAPS)","KC_A","KC_S","KC_D","KC_F","KC_G","KC_LPRN","KC_RPRN","KC_H","KC_J","KC_K","KC_L","KC_SCLN","KC_QUOT","KC_LSFT","KC_Z","KC_X","KC_C","KC_V","KC_B","KC_LCBR","KC_RCBR","KC_N","KC_M","KC_COMM","KC_DOT","KC_SLSH","KC_SFTENT","KC_LCTL","KC_LGUI","KC_LALT","RGB_TOG","MO(4)","KC_SPC","KC_BSPC","KC_ENT","KC_SPC","KC_LEFT","KC_DOWN","KC_UP","KC_RGHT","KC_RCTL","KC_VOLU","KC_VOLD","KC_VOLU","KC_VOLD","KC_PGUP","KC_PGDN","KC_PGUP","KC_PGDN","KC_VOLD","KC_VOLU","KC_MRWD","KC_MPLY","KC_MFFD","RGB_HUI","RGB_HUD","RGB_RMOD","RGB_TOG","RGB_MOD"], + ["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_Q","KC_W","KC_F","KC_P","KC_G","KC_TRNS","KC_TRNS","KC_J","KC_L","KC_U","KC_Y","KC_SCLN","KC_TRNS","KC_TRNS","KC_A","KC_R","KC_S","KC_T","KC_D","KC_TRNS","KC_TRNS","KC_H","KC_N","KC_E","KC_I","KC_O","KC_TRNS","KC_TRNS","KC_Z","KC_X","KC_C","KC_V","KC_B","KC_TRNS","KC_TRNS","KC_K","KC_M","KC_COMM","KC_DOT","KC_SLSH","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","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_F1","KC_F5","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_Q","KC_W","KC_E","KC_R","KC_T","KC_F2","KC_F6","KC_Y","KC_U","KC_I","KC_O","KC_P","KC_TRNS","KC_TRNS","KC_A","KC_S","KC_D","KC_F","KC_G","KC_F3","KC_F7","KC_H","KC_J","KC_K","KC_L","KC_SCLN","KC_TRNS","KC_TRNS","KC_Z","KC_X","KC_C","KC_V","KC_B","KC_F4","KC_F8","KC_N","KC_M","KC_COMM","KC_DOT","KC_SLSH","KC_TRNS","KC_TRNS","KC_NO","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","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS"], + ["KC_TRNS","KC_F1","KC_F2","KC_F3","KC_F4","KC_F5","KC_F11","KC_F12","KC_F6","KC_F7","KC_F8","KC_F9","KC_F10","KC_TRNS","KC_TRNS","KC_HOME","KC_UP","KC_END","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_HOME","KC_UP","KC_END","KC_PSCR","KC_PGUP","KC_TRNS","KC_LEFT","KC_DOWN","KC_RGHT","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_LEFT","KC_DOWN","KC_RGHT","KC_INS","KC_PGDN","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","ANY(TCH_TOG)","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_MPLY","KC_MNXT","KC_MUTE","KC_VOLD","KC_VOLU","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_F1","KC_F2","KC_F3","KC_F4","KC_F5","KC_F11","KC_F12","KC_F6","KC_F7","KC_F8","KC_F9","KC_F10","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_P7","KC_P8","KC_P9","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_P4","KC_P5","KC_P6","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_P1","KC_P2","KC_P3","KC_TRNS","DF(2)","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_P0","KC_PDOT","KC_NLCK","DF(0)","DF(1)","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"] + ] +} \ No newline at end of file diff --git a/keyboards/rgbkb/mun/rev1/rules.mk b/keyboards/rgbkb/mun/rev1/rules.mk new file mode 100644 index 000000000..e69de29bb diff --git a/keyboards/rgbkb/mun/rules.mk b/keyboards/rgbkb/mun/rules.mk new file mode 100644 index 000000000..f016c6c71 --- /dev/null +++ b/keyboards/rgbkb/mun/rules.mk @@ -0,0 +1,46 @@ +# MCU name +MCU = STM32F303 + +# Touch encoder needs +SRC += ../common/touch_encoder.c +SRC += ../common/common_oled.c +QUANTUM_LIB_SRC += i2c_master.c + +# Build Options +# change to "no" to disable the options, or define them in the Makefile in +# the appropriate keymap folder that will get included automatically +# +BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration +## (Note that for BOOTMAGIC on Teensy LC you have to use a custom .ld script.) +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 +NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +MIDI_ENABLE = no # MIDI controls +AUDIO_ENABLE = no # Audio output +UNICODE_ENABLE = no # Unicode +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID + +WS2812_DRIVER = pwm +RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. +RGB_MATRIX_ENABLE = yes +RGB_MATRIX_DRIVER = WS2812 +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend + +OLED_DRIVER_ENABLE = yes # Enable the OLED Driver + +ENCODER_ENABLE = yes + +SPLIT_KEYBOARD = yes +SERIAL_DRIVER = usart +LTO_ENABLE = yes +OPT = 3 + +OPT_DEFS += -DOLED_FONT_H=\"../common/glcdfont.c\" +OPT_DEFS += -Ikeyboards/rgbkb/common + +CUSTOM_MATRIX = yes +SRC += matrix.c matrix_common.c + +DEFAULT_FOLDER = rgbkb/mun/rev1 \ No newline at end of file