From eb91c962886b1bb52c2d457a574cba09e2a8b0f0 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Wed, 20 Nov 2019 12:37:24 -0800 Subject: [Keymap] All about (ARM) RGB and OLEDs (drashna keymaps) (#7354) * Add Kyria Keymap * Enable all RGBLIGHT Animations for ARM and high capacity AVR * Reduce GNUC version for __has_include * Cleanup Ortho 4x12 Community layout * Update Collide 39 keymap * Cleanup Keymaps * Enable full 30 LEDs for Ergodox * Change EEPROM Load timing * Use RGB Matrix on Planck Rev6 * Use correct keymap swap * Enable everything for ARM * Only enable rgb sleep on avr until crash is fixed * Add additional Kyria keymap config * Overhaul Kyria OLED display * Improve kyria keymap based on usage * Minor tweaks to rules * Update OLED code to truncate properly * Fix RGB Light layer indication * Switch all of biton32 to get_highest_layer function * Fix OLED Keylogger display * Run qmk cformat over all of my user files * Slight tweak to kyria based on usage * Move around LALT_T config * Add comments about base wrappers to keymaps * Another cformat pass * Temp fix for VUSB boards and NKRO * Convert tabs to spaces in rules.mk files * Only enable RGBLight if it's enabled * Add Encoder Flip setting * Update OLED font file --- keyboards/crkbd/keymaps/drashna/glcdfont.c | 9 +++--- keyboards/crkbd/keymaps/drashna/keymap.c | 49 ++++++++++++++++-------------- 2 files changed, 32 insertions(+), 26 deletions(-) (limited to 'keyboards/crkbd/keymaps') diff --git a/keyboards/crkbd/keymaps/drashna/glcdfont.c b/keyboards/crkbd/keymaps/drashna/glcdfont.c index 998b5c408a..2bfc3fac6d 100644 --- a/keyboards/crkbd/keymaps/drashna/glcdfont.c +++ b/keyboards/crkbd/keymaps/drashna/glcdfont.c @@ -1,17 +1,18 @@ #pragma once #ifdef __AVR__ - #include - #include +# include +# include #elif defined(ESP8266) - #include +# include #else - #define PROGMEM +# define PROGMEM #endif // Corne 8x6 font with QMK Firmware Logo // Online editor: https://helixfonteditor.netlify.com/ +// clang-format off const unsigned char font[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00, diff --git a/keyboards/crkbd/keymaps/drashna/keymap.c b/keyboards/crkbd/keymaps/drashna/keymap.c index cd84f0d919..9a1beeb74b 100644 --- a/keyboards/crkbd/keymaps/drashna/keymap.c +++ b/keyboards/crkbd/keymaps/drashna/keymap.c @@ -1,17 +1,17 @@ -#include QMK_KEYBOARD_H #include "drashna.h" -extern keymap_config_t keymap_config; -extern uint8_t is_master; +extern uint8_t is_master; #ifdef RGBLIGHT_ENABLE // Following line allows macro to read current RGB settings extern rgblight_config_t rgblight_config; #endif #ifdef OLED_DRIVER_ENABLE -static uint32_t oled_timer = 0; -static char keylog_str[6] = {}; -static uint16_t log_timer = 0; +# define KEYLOGGER_LENGTH 5 +static uint32_t oled_timer = 0; +static char keylog_str[KEYLOGGER_LENGTH + 1] = {"\n"}; +static uint16_t log_timer = 0; +// clang-format off static const char PROGMEM code_to_name[0xFF] = { // 0 1 2 3 4 5 6 7 8 9 A B c D E F ' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', // 0x @@ -37,7 +37,14 @@ void add_keylog(uint16_t keycode); enum crkbd_keycodes { RGBRST = NEW_SAFE_RANGE }; -// clang-format off +/* + * The `LAYOUT_crkbd_base` macro is a template to allow the use of identical + * modifiers for the default layouts (eg QWERTY, Colemak, Dvorak, etc), so + * that there is no need to set them up for each layout, and modify all of + * them if I want to change them. This helps to keep consistency and ease + * of use. K## is a placeholder to pass through the individual keycodes + */ + #define LAYOUT_crkbd_base( \ K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, \ K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, \ @@ -155,7 +162,7 @@ void add_keylog(uint16_t keycode) { keycode = 0; } - for (uint8_t i = 4; i > 0; --i) { + for (uint8_t i = (KEYLOGGER_LENGTH - 1); i > 0; --i) { keylog_str[i] = keylog_str[i - 1]; } @@ -168,7 +175,7 @@ void add_keylog(uint16_t keycode) { void update_log(void) { if (timer_elapsed(log_timer) > 750) { - //add_keylog(0); + // add_keylog(0); } } @@ -179,7 +186,7 @@ void render_keylogger_status(void) { void render_default_layer_state(void) { oled_write_P(PSTR("Lyout"), false); - switch (biton32(default_layer_state)) { + switch (get_highest_layer(default_layer_state)) { case _QWERTY: oled_write_P(PSTR(" QRTY"), false); break; @@ -268,7 +275,7 @@ void render_status_secondary(void) { /* Show Keyboard Layout */ render_default_layer_state(); render_layer_state(); - render_mod_status(get_mods()|get_oneshot_mods()); + render_mod_status(get_mods() | get_oneshot_mods()); render_keylogger_status(); } @@ -278,9 +285,11 @@ void oled_task_user(void) { oled_off(); return; } -#ifndef SPLIT_KEYBOARD - else { oled_on(); } -#endif +# ifndef SPLIT_KEYBOARD + else { + oled_on(); + } +# endif update_log(); if (is_master) { @@ -303,16 +312,12 @@ uint16_t get_tapping_term(uint16_t keycode) { #ifdef RGB_MATRIX_ENABLE -void suspend_power_down_keymap(void) { - rgb_matrix_set_suspend_state(true); -} +void suspend_power_down_keymap(void) { rgb_matrix_set_suspend_state(true); } -void suspend_wakeup_init_keymap(void) { - rgb_matrix_set_suspend_state(false); -} +void suspend_wakeup_init_keymap(void) { rgb_matrix_set_suspend_state(false); } void check_default_layer(uint8_t mode, uint8_t type) { - switch (biton32(default_layer_state)) { + switch (get_highest_layer(default_layer_state)) { case _QWERTY: rgb_matrix_layer_helper(HSV_CYAN, mode, rgb_matrix_config.speed, type); break; @@ -351,7 +356,7 @@ void rgb_matrix_indicators_user(void) { rgb_matrix_config.enable # endif ) { - switch (biton32(layer_state)) { + switch (get_highest_layer(layer_state)) { case _GAMEPAD: rgb_matrix_layer_helper(HSV_ORANGE, 0, rgb_matrix_config.speed, LED_FLAG_UNDERGLOW); break; -- cgit v1.2.3