1
0
Fork 0

[Keymap] Drashna's Cleanup and RGB Divide (#8506)

* Enable External EEPROM on Planck Rev6

* Update KC_MAKE macro to use qmk cli util

* Disable additional gradients for rgb matrix

* Update analog code for newer methods

* Update ergodox layout

* Disable Grave Escape

* Cleanup OLED code a bit

* Remove old unicode code

* Seperate RGB Matrix code from RGB Light code in userspace

* Massive overhaul an generalization of personal OLED code

Now lets hope I NEVER get a keyboard using a 128x32 in a normal orientation.

* Super tiny cleanup

* Enable Diablo layer on kyria

* clang format pass

* Additional OLED cleanup
This commit is contained in:
Drashna Jaelre 2020-03-31 16:26:43 -07:00 committed by GitHub
parent 8c80475fcc
commit c67e304593
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 890 additions and 869 deletions

View file

@ -1,5 +1,5 @@
#include "drashna.h"
#include "analog.c"
#include "analog.h"
#include "pointing_device.h"
#include "pincontrol.h"
@ -17,8 +17,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
// Joystick
// Set Pins
uint8_t xPin = 8; // VRx / /B4
uint8_t yPin = 7; // VRy // B5
// uint8_t xPin = 8; // VRx / /B4
// uint8_t yPin = 7; // VRy // B5
uint8_t swPin = E6; // SW
// Set Parameters
@ -43,7 +43,7 @@ int16_t axisCoordinate(uint8_t pin, uint16_t origin) {
int16_t distanceFromOrigin;
int16_t range;
int16_t position = analogRead(pin);
int16_t position = analogReadPin(pin);
if (origin == position) {
return 0;
@ -88,11 +88,11 @@ void pointing_device_task(void) {
// todo read as one vector
if (timer_elapsed(lastCursor) > cursorTimeout) {
lastCursor = timer_read();
report.x = axisToMouseComponent(xPin, xOrigin, maxCursorSpeed, xPolarity);
report.y = axisToMouseComponent(yPin, yOrigin, maxCursorSpeed, yPolarity);
report.x = axisToMouseComponent(B4, xOrigin, maxCursorSpeed, xPolarity);
report.y = axisToMouseComponent(B5, yOrigin, maxCursorSpeed, yPolarity);
}
//
if (!readPin(swPin)) {
if (!readPin(E6)) {
report.buttons |= MOUSE_BTN1;
} else {
report.buttons &= ~MOUSE_BTN1;
@ -104,8 +104,8 @@ void pointing_device_task(void) {
void matrix_init_keymap(void) {
// init pin? Is needed?
setPinInputHigh(swPin);
setPinInputHigh(E6);
// Account for drift
xOrigin = analogRead(xPin);
yOrigin = analogRead(yPin);
xOrigin = analogReadPin(B4);
yOrigin = analogReadPin(B5);
}

View file

@ -3,3 +3,5 @@ RGBLIGHT_ENABLE = no
CONSOLE_ENABLE = no
BOOTLOADER = qmk-dfu
SRC += analog.c

View file

@ -6,34 +6,6 @@ extern uint8_t is_master;
// Following line allows macro to read current RGB settings
extern rgblight_config_t rgblight_config;
#endif
#ifdef OLED_DRIVER_ENABLE
# 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
'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', // 1x
'3', '4', '5', '6', '7', '8', '9', '0', 20, 19, 27, 26, 22, '-', '=', '[', // 2x
']','\\', '#', ';','\'', '`', ',', '.', '/', 128, ' ', ' ', ' ', ' ', ' ', ' ', // 3x
' ', ' ', ' ', ' ', ' ', ' ', 'P', 'S', ' ', ' ', ' ', ' ', 16, ' ', ' ', ' ', // 4x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 5x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 6x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 7x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 8x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 9x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Ax
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Bx
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Cx
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Dx
'C', 'S', 'A', 'C', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Ex
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' // Fx
};
void add_keylog(uint16_t keycode);
#endif
enum crkbd_keycodes { RGBRST = NEW_SAFE_RANGE };
@ -139,10 +111,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
#ifdef OLED_DRIVER_ENABLE
oled_timer = timer_read32();
add_keylog(keycode);
#endif
#ifndef SPLIT_KEYBOARD
if (keycode == RESET && !is_master) {
return false;
@ -154,151 +122,6 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
#ifdef OLED_DRIVER_ENABLE
oled_rotation_t oled_init_user(oled_rotation_t rotation) { return OLED_ROTATION_270; }
void add_keylog(uint16_t keycode) {
if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX) || (keycode >= QK_MODS && keycode <= QK_MODS_MAX)) {
keycode = keycode & 0xFF;
} else if (keycode > 0xFF) {
keycode = 0;
}
for (uint8_t i = (KEYLOGGER_LENGTH - 1); i > 0; --i) {
keylog_str[i] = keylog_str[i - 1];
}
if (keycode < (sizeof(code_to_name) / sizeof(char))) {
keylog_str[0] = pgm_read_byte(&code_to_name[keycode]);
}
log_timer = timer_read();
}
void update_log(void) {
if (timer_elapsed(log_timer) > 750) {
// add_keylog(0);
}
}
void render_keylogger_status(void) {
oled_write_P(PSTR("KLogr"), false);
oled_write(keylog_str, false);
}
void render_default_layer_state(void) {
oled_write_P(PSTR("Lyout"), false);
switch (get_highest_layer(default_layer_state)) {
case _QWERTY:
oled_write_P(PSTR(" QRTY"), false);
break;
case _COLEMAK:
oled_write_P(PSTR(" COLE"), false);
break;
case _DVORAK:
oled_write_P(PSTR(" DVRK"), false);
break;
case _WORKMAN:
oled_write_P(PSTR(" WKMN"), false);
break;
case _NORMAN:
oled_write_P(PSTR(" NORM"), false);
break;
case _MALTRON:
oled_write_P(PSTR(" MLTN"), false);
break;
case _EUCALYN:
oled_write_P(PSTR(" ECLN"), false);
break;
case _CARPLAX:
oled_write_P(PSTR(" CRPX"), false);
break;
}
}
void render_layer_state(void) {
oled_write_P(PSTR("LAYER"), false);
oled_write_P(PSTR("Lower"), layer_state_is(_LOWER));
oled_write_P(PSTR("Raise"), layer_state_is(_RAISE));
oled_write_P(PSTR(" Mods"), layer_state_is(_MODS));
}
void render_keylock_status(uint8_t led_usb_state) {
oled_write_P(PSTR("Lock:"), false);
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR("N"), led_usb_state & (1 << USB_LED_NUM_LOCK));
oled_write_P(PSTR("C"), led_usb_state & (1 << USB_LED_CAPS_LOCK));
oled_write_ln_P(PSTR("S"), led_usb_state & (1 << USB_LED_SCROLL_LOCK));
}
void render_mod_status(uint8_t modifiers) {
oled_write_P(PSTR("Mods:"), false);
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR("S"), (modifiers & MOD_MASK_SHIFT));
oled_write_P(PSTR("C"), (modifiers & MOD_MASK_CTRL));
oled_write_P(PSTR("A"), (modifiers & MOD_MASK_ALT));
oled_write_P(PSTR("G"), (modifiers & MOD_MASK_GUI));
}
void render_bootmagic_status(void) {
/* Show Ctrl-Gui Swap options */
static const char PROGMEM logo[][2][3] = {
{{0x97, 0x98, 0}, {0xb7, 0xb8, 0}},
{{0x95, 0x96, 0}, {0xb5, 0xb6, 0}},
};
oled_write_P(PSTR("BTMGK"), false);
oled_write_P(PSTR(" "), false);
oled_write_P(logo[0][0], !keymap_config.swap_lctl_lgui);
oled_write_P(logo[1][0], keymap_config.swap_lctl_lgui);
oled_write_P(PSTR(" "), false);
oled_write_P(logo[0][1], !keymap_config.swap_lctl_lgui);
oled_write_P(logo[1][1], keymap_config.swap_lctl_lgui);
oled_write_P(PSTR(" NKRO"), keymap_config.nkro);
}
void render_user_status(void) {
oled_write_P(PSTR("USER:"), false);
oled_write_P(PSTR(" Anim"), userspace_config.rgb_matrix_idle_anim);
oled_write_P(PSTR(" Layr"), userspace_config.rgb_layer_change);
oled_write_P(PSTR(" Nuke"), userspace_config.nuke_switch);
}
void render_status_main(void) {
/* Show Keyboard Layout */
render_default_layer_state();
render_keylock_status(host_keyboard_leds());
render_bootmagic_status();
render_user_status();
render_keylogger_status();
}
void render_status_secondary(void) {
/* Show Keyboard Layout */
render_default_layer_state();
render_layer_state();
render_mod_status(get_mods() | get_oneshot_mods());
render_keylogger_status();
}
void oled_task_user(void) {
if (timer_elapsed32(oled_timer) > 30000) {
oled_off();
return;
}
# ifndef SPLIT_KEYBOARD
else {
oled_on();
}
# endif
update_log();
if (is_master) {
render_status_main(); // Renders the current keyboard state (layer, lock, caps, scroll, etc)
} else {
render_status_secondary();
}
}
#endif
uint16_t get_tapping_term(uint16_t keycode) {

View file

@ -37,3 +37,5 @@
// If you are using an Elite C rev3 on the slave side, uncomment the lines below:
#define SPLIT_USB_DETECT
#define SPLIT_USB_TIMEOUT 1000
#define KEYLOGGER_LENGTH 10

View file

@ -2,35 +2,6 @@
uint8_t is_master;
#ifdef OLED_DRIVER_ENABLE
# define KEYLOGGER_LENGTH 10
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
'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', // 1x
'3', '4', '5', '6', '7', '8', '9', '0', 20, 19, 27, 26, 22, '-', '=', '[', // 2x
']','\\', '#', ';','\'', '`', ',', '.', '/', 128, ' ', ' ', ' ', ' ', ' ', ' ', // 3x
' ', ' ', ' ', ' ', ' ', ' ', 'P', 'S', ' ', ' ', ' ', ' ', 16, ' ', ' ', ' ', // 4x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 5x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 6x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 7x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 8x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 9x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Ax
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Bx
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Cx
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Dx
'C', 'S', 'A', 'C', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Ex
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' // Fx
};
void add_keylog(uint16_t keycode);
#endif
#ifndef UNICODE_ENABLE
# define UC(x) KC_NO
#endif
@ -52,7 +23,7 @@ void add_keylog(uint16_t keycode);
LAYOUT_wrapper( \
KC_ESC, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, KC_MINS, \
LALT_T(KC_TAB), K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, RALT_T(KC_QUOT), \
OS_LSFT, CTL_T(K21), K22, K23, K24, K25, KC_NO, KC_NO, MEH(KC_MINS), KC_NO, K26, K27, K28, K29, RCTL_T(K2A), OS_RSFT, \
OS_LSFT, CTL_T(K21), K22, K23, K24, K25, KC_NO, MEH(KC_MINS), TG(_DIABLO), KC_NO, K26, K27, K28, K29, RCTL_T(K2A), OS_RSFT, \
KC_MUTE, OS_LALT, KC_GRV, KC_SPC, BK_LWER, DL_RAIS, KC_ENT, OS_RGUI, UC(0x03A8), UC(0x2E2E) \
)
/* Re-pass though to allow templates to be used */
@ -107,12 +78,19 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
_____________CARPLAX_QFMLWY_L2_____________, _____________CARPLAX_QFMLWY_R2_____________,
_____________CARPLAX_QFMLWY_L3_____________, _____________CARPLAX_QFMLWY_R3_____________
),
[_MODS] = LAYOUT_wrapper(
_______, ___________________BLANK___________________, ___________________BLANK___________________, _______,
_______, ___________________BLANK___________________, ___________________BLANK___________________, _______,
KC_LSFT, ___________________BLANK___________________, _______, _______, _______, _______, ___________________BLANK___________________, KC_RSFT,
_______, _______, KC_LALT, _______, _______, _______, _______, KC_RGUI, _______, _______
),
[_DIABLO] = LAYOUT_wrapper(
KC_ESC, KC_S, KC_I, KC_F, KC_M, KC_T, KC_F9, KC_F10, KC_F11, KC_F12, KC_NO, KC_NO,
KC_TAB, KC_1, KC_2, KC_3, KC_4, KC_G, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
KC_LCTL, KC_D3_1, KC_D3_2, KC_D3_3, KC_D3_4, KC_Z, KC_J, KC_L, TG(_DIABLO), KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
KC_DIABLO_CLEAR, KC_J, KC_NO, SFT_T(KC_SPACE), ALT_T(KC_Q), KC_NO, KC_NO, KC_NO, KC_NO, KC_NO
),
[_LOWER] = LAYOUT_wrapper(
KC_F12, _________________LOWER_L1__________________, _________________LOWER_R1__________________, KC_F11,
_______, _________________LOWER_L2__________________, _________________LOWER_R2__________________, KC_PIPE,
@ -142,10 +120,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
#ifdef OLED_DRIVER_ENABLE
oled_timer = timer_read32();
add_keylog(keycode);
#endif
#ifndef SPLIT_KEYBOARD
if (keycode == RESET && !is_master) {
return false;
@ -154,133 +128,16 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
}
return true;
}
void matrix_init_keymap(void) { is_master = (uint8_t)is_keyboard_master(); }
#ifdef OLED_DRIVER_ENABLE
oled_rotation_t oled_init_user(oled_rotation_t rotation) { return OLED_ROTATION_180; }
void add_keylog(uint16_t keycode) {
if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX) || (keycode >= QK_MODS && keycode <= QK_MODS_MAX)) {
keycode = keycode & 0xFF;
} else if (keycode > 0xFF) {
keycode = 0;
}
for (uint8_t i = (KEYLOGGER_LENGTH - 1); i > 0; --i) {
keylog_str[i] = keylog_str[i - 1];
}
if (keycode < (sizeof(code_to_name) / sizeof(char))) {
keylog_str[0] = pgm_read_byte(&code_to_name[keycode]);
}
log_timer = timer_read();
}
void update_log(void) {
if (timer_elapsed(log_timer) > 750) {
// add_keylog(0);
}
}
void render_keylogger_status(void) {
oled_write_P(PSTR("Keylogger: "), false);
oled_write(keylog_str, false);
}
void render_default_layer_state(void) {
oled_write_P(PSTR("Layout: "), false);
switch (get_highest_layer(default_layer_state)) {
case _QWERTY: oled_write_ln_P(PSTR("Qwerty"), false); break;
case _COLEMAK: oled_write_ln_P(PSTR("Colemak"), false); break;
case _DVORAK: oled_write_ln_P(PSTR("Dvorak"), false); break;
case _WORKMAN: oled_write_ln_P(PSTR("Workman"), false); break;
case _NORMAN: oled_write_ln_P(PSTR("Norman"), false); break;
case _MALTRON: oled_write_ln_P(PSTR("Maltron"), false); break;
case _EUCALYN: oled_write_ln_P(PSTR("Eucalyn"), false); break;
case _CARPLAX: oled_write_ln_P(PSTR("Carplax"), false); break;
}
}
void render_layer_state(void) {
oled_write_ln_P(PSTR("Layer:"), false);
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR("Lower"), layer_state_is(_LOWER));
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR("Raise"), layer_state_is(_RAISE));
oled_write_P(PSTR(" "), false);
oled_write_ln_P(PSTR("Mods"), layer_state_is(_MODS));
}
void render_keylock_status(uint8_t led_usb_state) {
oled_write_P(PSTR("Lock: "), false);
oled_write_P(PSTR("NUML"), led_usb_state & (1 << USB_LED_NUM_LOCK));
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR("CAPS"), led_usb_state & (1 << USB_LED_CAPS_LOCK));
oled_write_P(PSTR(" "), false);
oled_write_ln_P(PSTR("SCLK"), led_usb_state & (1 << USB_LED_SCROLL_LOCK));
}
void render_mod_status(uint8_t modifiers) {
oled_write_P(PSTR("Mods: "), false);
oled_write_P(PSTR("Sft"), (modifiers & MOD_MASK_SHIFT));
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR("Ctl"), (modifiers & MOD_MASK_CTRL));
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR("Alt"), (modifiers & MOD_MASK_ALT));
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR("GUI"), (modifiers & MOD_MASK_GUI));
}
void render_bootmagic_status(void) {
/* Show Ctrl-Gui Swap options */
static const char PROGMEM logo[][2][3] = {
{{0x97, 0x98, 0}, {0xb7, 0xb8, 0}},
{{0x95, 0x96, 0}, {0xb5, 0xb6, 0}},
};
oled_write_P(PSTR("Boot "), false);
if (keymap_config.swap_lctl_lgui) {
oled_write_P(logo[1][0], false);
} else {
oled_write_P(logo[0][0], false);
}
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR("NKRO"), keymap_config.nkro);
oled_write_P(PSTR(" "), false);
oled_write_ln_P(PSTR("GUI"), !keymap_config.no_gui);
oled_write_P(PSTR("Magic "), false);
if (keymap_config.swap_lctl_lgui) {
oled_write_P(logo[1][1], false);
} else {
oled_write_P(logo[0][1], false);
}
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR("GRV"), keymap_config.swap_grave_esc);
oled_write_P(PSTR(" "), false);
oled_write_ln_P(PSTR("CAPS"), keymap_config.swap_control_capslock);
}
void render_user_status(void) {
oled_write_P(PSTR("USER: "), false);
oled_write_P(PSTR("Anim"), userspace_config.rgb_matrix_idle_anim);
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR("Layr"), userspace_config.rgb_layer_change);
oled_write_P(PSTR(" "), false);
oled_write_ln_P(PSTR("Nuke"), userspace_config.nuke_switch);
}
// clang-format off
void render_logo(void) {
static const char PROGMEM qmk_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(qmk_logo, false);
}
# ifndef SPLIT_TRANSPORT_MIRROR
void render_kyria_logo(void) {
void oled_driver_render_logo(void) {
static const char PROGMEM kyria_logo[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128,128,192,224,240,112,120, 56, 60, 28, 30, 14, 14, 14, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 14, 14, 14, 30, 28, 60, 56,120,112,240,224,192,128,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,192,224,240,124, 62, 31, 15, 7, 3, 1,128,192,224,240,120, 56, 60, 28, 30, 14, 14, 7, 7,135,231,127, 31,255,255, 31,127,231,135, 7, 7, 14, 14, 30, 28, 60, 56,120,240,224,192,128, 1, 3, 7, 15, 31, 62,124,240,224,192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -294,51 +151,6 @@ void render_kyria_logo(void) {
oled_write_raw_P(kyria_logo, sizeof(kyria_logo));
}
# endif
// clang-format on
void render_status_main(void) {
/* Show Keyboard Layout */
render_default_layer_state();
render_keylock_status(host_keyboard_leds());
render_bootmagic_status();
render_user_status();
render_keylogger_status();
}
void render_status_secondary(void) {
/* Show Keyboard Layout */
render_logo();
render_default_layer_state();
render_layer_state();
render_mod_status(get_mods() | get_oneshot_mods());
render_keylogger_status();
}
void oled_task_user(void) {
if (timer_elapsed32(oled_timer) > 30000) {
oled_off();
return;
}
# ifndef SPLIT_KEYBOARD
else {
oled_on();
}
# endif
update_log();
if (is_master) {
render_status_main(); // Renders the current keyboard state (layer, lock, caps, scroll, etc)
} else {
# ifdef SPLIT_TRANSPORT_MIRROR
render_status_secondary();
# else
render_kyria_logo();
# endif
}
}
#endif
#ifdef ENCODER_ENABLE

View file

@ -20,3 +20,5 @@ HD44780_ENABLE = no # Enable support for HD44780 based LCDs
BOOTLOADER = atmel-dfu
SPLIT_TRANSPORT = mirror
TAP_DANCE_ENABLE = yes

View file

@ -15,7 +15,7 @@
#define PRODUCT DrashnaDox - Hacked ErgoDox EZ Hybrid Monstrosity
#undef DEBOUNCE
#define DEBOUNCE 30
#define DEBOUNCE 60
#define TAPPING_TERM_PER_KEY

View file

@ -1,8 +1,7 @@
BOOTMAGIC_ENABLE = lite
TAP_DANCE_ENABLE = no
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
TAP_DANCE_ENABLE = yes
COMMAND_ENABLE = no # Commands for debug and configuration
CONSOLE_ENABLE = no
CONSOLE_ENABLE =
SPACE_CADET_ENABLE = no
ifeq ($(strip $(KEYBOARD)), ergodox_ez)
@ -10,7 +9,7 @@ ifeq ($(strip $(KEYBOARD)), ergodox_ez)
RGB_MATRIX_ENABLE = yes
RGBLIGHT_TWINKLE = no
INDICATOR_LIGHTS = no
RGBLIGHT_STARTUP_ANIMATION = no
RGBLIGHT_STARTUP_ANIMATION = yes
endif
UNICODE_ENABLE = yes

View file

@ -62,6 +62,8 @@
# endif
#endif
#define EEPROM_I2C_RM24C512C
#define ENCODER_DIRECTION_FLIP
/*
* MIDI options

View file

@ -18,8 +18,10 @@ else
CONSOLE_ENABLE = yes
COMMAND_ENABLE = yes
RGBLIGHT_ENABLE = yes
RGBLIGHT_STARTUP_ANIMATION = yes
RGB_MATRIX_ENABLE = no
AUDIO_ENABLE = yes
EEPROM_DRIVER = i2c
endif
ifeq ($(strip $(KEYBOARD)), planck/light)
RGB_MATRIX_ENABLE = yes

View file

@ -1,7 +1,7 @@
#pragma once
// Use custom magic number so that when switching branches, EEPROM always gets reset
#define EECONFIG_MAGIC_NUMBER (uint16_t)0x1337
#define EECONFIG_MAGIC_NUMBER (uint16_t)0x1338
/* Set Polling rate to 1000Hz */
#define USB_POLLING_INTERVAL_MS 1
@ -52,6 +52,7 @@
# if defined(__AVR__) && !defined(__AVR_AT90USB1286__)
# define DISABLE_RGB_MATRIX_ALPHAS_MODS
# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
# define DISABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT
# define DISABLE_RGB_MATRIX_BREATHING
# define DISABLE_RGB_MATRIX_BAND_SAT
# define DISABLE_RGB_MATRIX_BAND_VAL

View file

@ -18,12 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "drashna.h"
userspace_config_t userspace_config;
#if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
# define DRASHNA_UNICODE_MODE UC_WIN
#else
// set to 2 for UC_WIN, set to 4 for UC_WINC
# define DRASHNA_UNICODE_MODE 2
#endif
bool mod_key_press_timer(uint16_t code, uint16_t mod_code, bool pressed) {
static uint16_t this_timer;
@ -93,19 +87,17 @@ void matrix_init_user(void) {
DDRB &= ~(1 << 0);
PORTB &= ~(1 << 0);
#endif
#if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
set_unicode_input_mode(DRASHNA_UNICODE_MODE);
get_unicode_input_mode();
#endif // UNICODE_ENABLE
matrix_init_keymap();
}
__attribute__((weak)) void keyboard_post_init_keymap(void) {}
void keyboard_post_init_user(void) {
#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
keyboard_post_init_rgb();
#if defined(RGBLIGHT_ENABLE)
keyboard_post_init_rgb_light();
#endif
#if defined(RGB_MATRIX_ENABLE)
keyboard_post_init_rgb_matrix();
#endif
keyboard_post_init_keymap();
}
@ -155,9 +147,12 @@ void matrix_scan_user(void) {
run_diablo_macro_check();
#endif // TAP_DANCE_ENABLE
#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
matrix_scan_rgb();
#if defined(RGBLIGHT_ENABLE)
matrix_scan_rgb_light();
#endif // RGBLIGHT_ENABLE
#if defined(RGB_MATRIX_ENABLE)
matrix_scan_rgb_matrix();
#endif
matrix_scan_keymap();
}
@ -168,8 +163,8 @@ __attribute__((weak)) layer_state_t layer_state_set_keymap(layer_state_t state)
// Then runs keymap's layer change check
layer_state_t layer_state_set_user(layer_state_t state) {
state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST);
#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
state = layer_state_set_rgb(state);
#if defined(RGBLIGHT_ENABLE)
state = layer_state_set_rgb_light(state);
#endif // RGBLIGHT_ENABLE
return layer_state_set_keymap(state);
}
@ -200,12 +195,6 @@ void eeconfig_init_user(void) {
userspace_config.raw = 0;
userspace_config.rgb_layer_change = true;
eeconfig_update_user(userspace_config.raw);
#if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
set_unicode_input_mode(DRASHNA_UNICODE_MODE);
get_unicode_input_mode();
#else
eeprom_update_byte(EECONFIG_UNICODEMODE, DRASHNA_UNICODE_MODE);
#endif
eeconfig_init_keymap();
keyboard_init();
}

View file

@ -25,9 +25,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef TAP_DANCE_ENABLE
# include "tap_dances.h"
#endif // TAP_DANCE_ENABLE
#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
#if defined(RGBLIGHT_ENABLE)
# include "rgb_stuff.h"
#endif
#if defined(RGB_MATRIX_ENABLE)
# include "rgb_matrix_stuff.h"
#endif
#if defined(OLED_DRIVER_ENABLE)
# include "oled_stuff.h"
#endif
/* Define layer names */
enum userspace_layers {
@ -70,7 +76,6 @@ typedef union {
bool rgb_layer_change :1;
bool is_overwatch :1;
bool nuke_switch :1;
uint8_t unicode_mod :4;
bool swapped_numbers :1;
bool rgb_matrix_idle_anim :1;
};

278
users/drashna/oled_stuff.c Normal file
View file

@ -0,0 +1,278 @@
#include "drashna.h"
extern uint8_t is_master;
#ifndef KEYLOGGER_LENGTH
// # ifdef OLED_DISPLAY_128X64
# define KEYLOGGER_LENGTH ((int)(OLED_DISPLAY_HEIGHT / OLED_FONT_WIDTH))
// # else
// # define KEYLOGGER_LENGTH (uint8_t *(OLED_DISPLAY_WIDTH / OLED_FONT_HEIGHT))
// # endif
#endif
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
'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', // 1x
'3', '4', '5', '6', '7', '8', '9', '0', 20, 19, 27, 26, 22, '-', '=', '[', // 2x
']','\\', '#', ';','\'', '`', ',', '.', '/', 128, ' ', ' ', ' ', ' ', ' ', ' ', // 3x
' ', ' ', ' ', ' ', ' ', ' ', 'P', 'S', ' ', ' ', ' ', ' ', 16, ' ', ' ', ' ', // 4x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 5x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 6x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 7x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 8x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 9x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Ax
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Bx
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Cx
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Dx
'C', 'S', 'A', 'C', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Ex
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' // Fx
};
// clang-format on
void add_keylog(uint16_t keycode) {
if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX) || (keycode >= QK_MODS && keycode <= QK_MODS_MAX)) {
keycode = keycode & 0xFF;
} else if (keycode > 0xFF) {
keycode = 0;
}
for (uint8_t i = (KEYLOGGER_LENGTH - 1); i > 0; --i) {
keylog_str[i] = keylog_str[i - 1];
}
if (keycode < (sizeof(code_to_name) / sizeof(char))) {
keylog_str[0] = pgm_read_byte(&code_to_name[keycode]);
}
log_timer = timer_read();
}
bool process_record_user_oled(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
#ifdef OLED_DRIVER_ENABLE
oled_timer = timer_read32();
add_keylog(keycode);
#endif
}
return true;
}
void update_log(void) {
if (timer_elapsed(log_timer) > 750) {
// add_keylog(0);
}
}
void render_keylogger_status(void) {
oled_write_P(PSTR(OLED_RENDER_KEYLOGGER), false);
oled_write(keylog_str, false);
}
void render_default_layer_state(void) {
oled_write_P(PSTR(OLED_RENDER_LAYOUT_NAME), false);
switch (get_highest_layer(default_layer_state)) {
case _QWERTY:
oled_write_P(PSTR(OLED_RENDER_LAYOUT_QWERTY), false);
break;
case _COLEMAK:
oled_write_P(PSTR(OLED_RENDER_LAYOUT_COLEMAK), false);
break;
case _DVORAK:
oled_write_P(PSTR(OLED_RENDER_LAYOUT_DVORAK), false);
break;
case _WORKMAN:
oled_write_P(PSTR(OLED_RENDER_LAYOUT_WORKMAN), false);
break;
case _NORMAN:
oled_write_P(PSTR(OLED_RENDER_LAYOUT_NORMAN), false);
break;
case _MALTRON:
oled_write_P(PSTR(OLED_RENDER_LAYOUT_MALTRON), false);
break;
case _EUCALYN:
oled_write_P(PSTR(OLED_RENDER_LAYOUT_EUCALYN), false);
break;
case _CARPLAX:
oled_write_P(PSTR(OLED_RENDER_LAYOUT_CARPLAX), false);
break;
}
#ifdef OLED_DISPLAY_128X64
oled_advance_page(true);
#endif
}
void render_layer_state(void) {
oled_write_P(PSTR(OLED_RENDER_LAYER_NAME), false);
#ifdef OLED_DISPLAY_128X64
oled_write_P(PSTR(" "), false);
#endif
oled_write_P(PSTR(OLED_RENDER_LAYER_LOWER), layer_state_is(_LOWER));
#ifdef OLED_DISPLAY_128X64
oled_write_P(PSTR(" "), false);
#endif
oled_write_P(PSTR(OLED_RENDER_LAYER_RAISE), layer_state_is(_RAISE));
#if _MODS
# ifdef OLED_DISPLAY_128X64
oled_write_P(PSTR(" "), false);
# endif
oled_write_P(PSTR(OLED_RENDER_LAYER_MODS), layer_state_is(_MODS));
#endif
#ifdef OLED_DISPLAY_128X64
oled_advance_page(true);
#endif
}
void render_keylock_status(uint8_t led_usb_state) {
oled_write_P(PSTR(OLED_RENDER_LOCK_NAME), false);
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR(OLED_RENDER_LOCK_NUML), led_usb_state & (1 << USB_LED_NUM_LOCK));
#ifdef OLED_DISPLAY_128X64
oled_write_P(PSTR(" "), false);
#endif
oled_write_P(PSTR(OLED_RENDER_LOCK_CAPS), led_usb_state & (1 << USB_LED_CAPS_LOCK));
#ifdef OLED_DISPLAY_128X64
oled_write_P(PSTR(" "), false);
#endif
oled_write_P(PSTR(OLED_RENDER_LOCK_SCLK), led_usb_state & (1 << USB_LED_SCROLL_LOCK));
#ifndef OLED_DISPLAY_128X64
oled_advance_page(true);
#endif
}
void render_mod_status(uint8_t modifiers) {
oled_write_P(PSTR(OLED_RENDER_MODS_NAME), false);
oled_write_P(PSTR(OLED_RENDER_MODS_SFT), (modifiers & MOD_MASK_SHIFT));
#ifdef OLED_DISPLAY_128X64
oled_write_P(PSTR(" "), false);
#endif
oled_write_P(PSTR(OLED_RENDER_MODS_CTL), (modifiers & MOD_MASK_CTRL));
#ifdef OLED_DISPLAY_128X64
oled_write_P(PSTR(" "), false);
#endif
oled_write_P(PSTR(OLED_RENDER_MODS_ALT), (modifiers & MOD_MASK_ALT));
#ifdef OLED_DISPLAY_128X64
oled_write_P(PSTR(" "), false);
#endif
oled_write_P(PSTR(OLED_RENDER_MODS_GUI), (modifiers & MOD_MASK_GUI));
}
void render_bootmagic_status(void) {
/* Show Ctrl-Gui Swap options */
static const char PROGMEM logo[][2][3] = {
{{0x97, 0x98, 0}, {0xb7, 0xb8, 0}},
{{0x95, 0x96, 0}, {0xb5, 0xb6, 0}},
};
oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NAME), false);
#ifdef OLED_DISPLAY_128X64
if (keymap_config.swap_lctl_lgui)
#else
oled_write_P(PSTR(" "), false);
#endif
{
oled_write_P(logo[1][0], false);
#ifdef OLED_DISPLAY_128X64
} else {
#endif
oled_write_P(logo[0][0], false);
}
oled_write_P(PSTR(" "), false);
#ifdef OLED_DISPLAY_128X64
oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NKRO), keymap_config.nkro);
oled_write_P(PSTR(" "), false);
oled_write_ln_P(PSTR(OLED_RENDER_BOOTMAGIC_NOGUI), !keymap_config.no_gui);
oled_write_P(PSTR("Magic "), false);
if (keymap_config.swap_lctl_lgui)
#endif
{
oled_write_P(logo[1][1], false);
#ifdef OLED_DISPLAY_128X64
} else {
#endif
oled_write_P(logo[0][1], false);
}
oled_write_P(PSTR(" "), false);
#ifdef OLED_DISPLAY_128X64
oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_GRV), keymap_config.swap_grave_esc);
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_CAPS), keymap_config.swap_control_capslock);
oled_advance_page(true);
#else
oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NKRO), keymap_config.nkro);
#endif
}
void render_user_status(void) {
oled_write_P(PSTR(OLED_RENDER_USER_NAME), false);
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR(OLED_RENDER_USER_ANIM), userspace_config.rgb_matrix_idle_anim);
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR(OLED_RENDER_USER_LAYR), userspace_config.rgb_layer_change);
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR(OLED_RENDER_USER_NUKE), userspace_config.nuke_switch);
#ifdef OLED_DISPLAY_128X64
oled_advance_page(true);
#endif
}
__attribute__((weak)) void oled_driver_render_logo(void) {
// clang-format off
static const char PROGMEM qmk_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};
// clang-format on
oled_write_P(qmk_logo, false);
}
void render_status_secondary(void) {
#if !defined(SPLIT_TRANSPORT_MIRROR) || defined(OLED_DRIVER_128x64)
oled_driver_render_logo();
#endif
#ifdef SPLIT_TRANSPORT_MIRROR
/* Show Keyboard Layout */
render_default_layer_state();
render_layer_state();
render_mod_status(get_mods() | get_oneshot_mods());
render_keylogger_status();
#endif
}
// clang-format on
void render_status_main(void) {
/* Show Keyboard Layout */
render_default_layer_state();
render_keylock_status(host_keyboard_leds());
render_bootmagic_status();
render_user_status();
render_keylogger_status();
}
void oled_task_user(void) {
if (timer_elapsed32(oled_timer) > 30000) {
oled_off();
return;
}
#ifndef SPLIT_KEYBOARD
else {
oled_on();
}
#endif
update_log();
if (is_master) {
render_status_main(); // Renders the current keyboard state (layer, lock, caps, scroll, etc)
} else {
render_status_secondary();
}
}

View file

@ -0,0 +1,91 @@
#pragma once
#include "quantum.h"
#include "oled_driver.h"
void oled_driver_render_logo(void);
bool process_record_user_oled(uint16_t keycode, keyrecord_t *record);
#ifdef OLED_DISPLAY_128X64
# define OLED_RENDER_KEYLOGGER "Keylogger: "
# define OLED_RENDER_LAYOUT_NAME "Layout: "
# define OLED_RENDER_LAYOUT_QWERTY "Qwerty"
# define OLED_RENDER_LAYOUT_COLEMAK "Colemak"
# define OLED_RENDER_LAYOUT_DVORAK "Dvorak"
# define OLED_RENDER_LAYOUT_WORKMAN "Workman"
# define OLED_RENDER_LAYOUT_NORMAN "Norman"
# define OLED_RENDER_LAYOUT_MALTRON "Matron"
# define OLED_RENDER_LAYOUT_EUCALYN "Eucalyn"
# define OLED_RENDER_LAYOUT_CARPLAX "Carplax"
# define OLED_RENDER_LAYER_NAME "Layer:\n"
# define OLED_RENDER_LAYER_LOWER "Lower"
# define OLED_RENDER_LAYER_RAISE "Raise"
# define OLED_RENDER_LAYER_ADJUST "Adjust"
# define OLED_RENDER_LAYER_MODS "Mods"
# define OLED_RENDER_LOCK_NAME "Lock: "
# define OLED_RENDER_LOCK_NUML "NUML"
# define OLED_RENDER_LOCK_CAPS "CAPS"
# define OLED_RENDER_LOCK_SCLK "SCLK"
# define OLED_RENDER_MODS_NAME "Mods: "
# define OLED_RENDER_MODS_SFT "Sft"
# define OLED_RENDER_MODS_CTL "Ctl"
# define OLED_RENDER_MODS_ALT "Alt"
# define OLED_RENDER_MODS_GUI "GUI"
# define OLED_RENDER_BOOTMAGIC_NAME "Boot "
# define OLED_RENDER_BOOTMAGIC_NKRO "NKRO"
# define OLED_RENDER_BOOTMAGIC_NOGUI "nGUI"
# define OLED_RENDER_BOOTMAGIC_GRV "GRV"
# define OLED_RENDER_BOOTMAGIC_CAPS "CAPS"
# define OLED_RENDER_USER_NAME "USER:"
# define OLED_RENDER_USER_ANIM "Anim"
# define OLED_RENDER_USER_LAYR "Layr"
# define OLED_RENDER_USER_NUKE "Nuke"
#else
# define OLED_RENDER_KEYLOGGER "KLogr"
# define OLED_RENDER_LAYOUT_NAME "Lyout"
# define OLED_RENDER_LAYOUT_QWERTY " QRTY"
# define OLED_RENDER_LAYOUT_COLEMAK " COLE"
# define OLED_RENDER_LAYOUT_DVORAK " DVRK"
# define OLED_RENDER_LAYOUT_WORKMAN " WKMN"
# define OLED_RENDER_LAYOUT_NORMAN " NORM"
# define OLED_RENDER_LAYOUT_MALTRON " MLTN"
# define OLED_RENDER_LAYOUT_EUCALYN " ECLN"
# define OLED_RENDER_LAYOUT_CARPLAX " CRPX"
# define OLED_RENDER_LAYER_NAME "LAYER"
# define OLED_RENDER_LAYER_LOWER "Lower"
# define OLED_RENDER_LAYER_RAISE "Raise"
# define OLED_RENDER_LAYER_ADJUST "Adjst"
# define OLED_RENDER_LAYER_MODS " Mods"
# define OLED_RENDER_LOCK_NAME "Lock:"
# define OLED_RENDER_LOCK_NUML "N"
# define OLED_RENDER_LOCK_CAPS "C"
# define OLED_RENDER_LOCK_SCLK "S"
# define OLED_RENDER_MODS_NAME "Mods: "
# define OLED_RENDER_MODS_SFT "S"
# define OLED_RENDER_MODS_CTL "C"
# define OLED_RENDER_MODS_ALT "A"
# define OLED_RENDER_MODS_GUI "G"
# define OLED_RENDER_BOOTMAGIC_NAME "BTMGK"
# define OLED_RENDER_BOOTMAGIC_NKRO "NKRO"
# define OLED_RENDER_BOOTMAGIC_NOGUI "nGUI"
# define OLED_RENDER_BOOTMAGIC_GRV "GRV"
# define OLED_RENDER_BOOTMAGIC_CAPS "CAPS"
# define OLED_RENDER_USER_NAME "USER:"
# define OLED_RENDER_USER_ANIM "Anim"
# define OLED_RENDER_USER_LAYR "Layr"
# define OLED_RENDER_USER_NUKE "Nuke"
#endif

View file

@ -17,7 +17,18 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
xprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed);
# endif
#endif // KEYLOGGER_ENABLE
#ifdef OLED_DRIVER_ENABLE
process_record_user_oled(keycode, record);
#endif // OLED
if (process_record_keymap(keycode, record) && process_record_secrets(keycode, record)
#ifdef RGB_MATRIX_ENABLE
&& process_record_user_rgb_matrix(keycode, record)
#endif
#ifdef RGBLIGHT_ENABLE
&& process_record_user_rgb_light(keycode, record)
#endif
) {
switch (keycode) {
case KC_QWERTY ... KC_WORKMAN:
if (record->event.pressed) {
@ -34,20 +45,24 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
case KC_MAKE: // Compiles the firmware, and adds the flash command based on keyboard bootloader
if (!record->event.pressed) {
#ifndef MAKE_BOOTLOADER
uint8_t temp_mod = mod_config(get_mods());
uint8_t temp_osm = mod_config(get_oneshot_mods());
clear_mods();
clear_oneshot_mods();
send_string_with_delay_P(PSTR("make " QMK_KEYBOARD ":" QMK_KEYMAP), TAP_CODE_DELAY);
#endif
send_string_with_delay_P(PSTR("bin/qmk"), TAP_CODE_DELAY);
#ifndef MAKE_BOOTLOADER
if ((temp_mod | temp_osm) & MOD_MASK_SHIFT)
#endif
{
send_string_with_delay_P(PSTR(":flash"), TAP_CODE_DELAY);
}
if ((temp_mod | temp_osm) & MOD_MASK_CTRL) {
send_string_with_delay_P(PSTR(" -j8 --output-sync"), TAP_CODE_DELAY);
send_string_with_delay_P(PSTR(" flash "), TAP_CODE_DELAY);
#ifndef MAKE_BOOTLOADER
} else {
send_string_with_delay_P(PSTR(" compile "), TAP_CODE_DELAY);
#endif
}
send_string_with_delay_P(PSTR("-kb " QMK_KEYBOARD " -km " QMK_KEYMAP), TAP_CODE_DELAY);
#ifdef RGB_MATRIX_SPLIT_RIGHT
send_string_with_delay_P(PSTR(" RGB_MATRIX_SPLIT_RIGHT=yes"), TAP_CODE_DELAY);
# ifndef OLED_DRIVER_ENABLE
@ -89,29 +104,221 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
#ifdef UNICODE_ENABLE
case UC_FLIP: // (ノಠ痊ಠ)ノ彡┻━┻
if (record->event.pressed) {
send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B");
send_unicode_string("(ノಠ痊ಠ)ノ彡┻━┻");
}
break;
case UC_TABL: // ┬─┬ノ( º _ ºノ)
if (record->event.pressed) {
send_unicode_hex_string("252C 2500 252C 30CE 0028 0020 00BA 0020 005F 0020 00BA 30CE 0029");
send_unicode_string("┬─┬ノ( º _ ºノ)");
}
break;
case UC_SHRG: // ¯\_(ツ)_/¯
if (record->event.pressed) {
send_unicode_hex_string("00AF 005C 005F 0028 30C4 0029 005F 002F 00AF");
send_unicode_string("¯\\_(ツ)_/¯");
}
break;
case UC_DISA: // ಠ_ಠ
if (record->event.pressed) {
send_unicode_hex_string("0CA0 005F 0CA0");
send_unicode_string("ಠ_ಠ");
}
break;
#endif
}
return process_record_keymap(keycode, record) &&
case KC_RGB_T: // This allows me to use underglow as layer indication, or as normal
#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
process_record_user_rgb(keycode, record) &&
#endif // RGBLIGHT_ENABLE
process_record_secrets(keycode, record);
if (record->event.pressed) {
userspace_config.rgb_layer_change ^= 1;
dprintf("rgblight layer change [EEPROM]: %u\n", userspace_config.rgb_layer_change);
eeconfig_update_user(userspace_config.raw);
if (userspace_config.rgb_layer_change) {
# if defined(RGBLIGHT_ENABLE) && defined(RGB_MATRIX_ENABLE)
rgblight_enable_noeeprom();
# endif
layer_state_set(layer_state); // This is needed to immediately set the layer color (looks better)
# if defined(RGBLIGHT_ENABLE) && defined(RGB_MATRIX_ENABLE)
} else {
rgblight_disable_noeeprom();
# endif
}
}
#endif // RGBLIGHT_ENABLE
break;
#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
case RGB_TOG:
// Split keyboards need to trigger on key-up for edge-case issue
# ifndef SPLIT_KEYBOARD
if (record->event.pressed) {
# else
if (!record->event.pressed) {
# endif
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_toggle();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_toggle();
# endif
}
return false;
break;
case RGB_MODE_FORWARD ... RGB_MODE_GRADIENT: // quantum_keycodes.h L400 for definitions
if (record->event.pressed) {
bool is_eeprom_updated;
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
// This disables layer indication, as it's assumed that if you're changing this ... you want that disabled
if (userspace_config.rgb_layer_change) {
userspace_config.rgb_layer_change = false;
dprintf("rgblight layer change [EEPROM]: %u\n", userspace_config.rgb_layer_change);
is_eeprom_updated = true;
}
# endif
# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
if (userspace_config.rgb_matrix_idle_anim) {
userspace_config.rgb_matrix_idle_anim = false;
dprintf("RGB Matrix Idle Animation [EEPROM]: %u\n", userspace_config.rgb_matrix_idle_anim);
is_eeprom_updated = true;
}
# endif
if (is_eeprom_updated) {
eeconfig_update_user(userspace_config.raw);
}
}
# if defined(RGBLIGHT_DISABLE_KEYCODES) || defined(RGB_MATRIX_DISABLE_KEYCODES)
if (keycode == RGB_MODE_FORWARD && record->event.pressed) {
uint8_t shifted = get_mods() & (MOD_MASK_SHIFT);
if (shifted) {
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_step_reverse();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_step_reverse();
# endif
} else {
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_step();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_step();
# endif
}
} else if (keycode == RGB_MODE_REVERSE && record->event.pressed) {
uint8_t shifted = get_mods() & (MOD_MASK_SHIFT);
if (shifted) {
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_step();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_step();
# endif
} else {
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_step_reverse();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_step_reverse();
# endif
}
} else if (keycode == RGB_HUI) {
# ifndef SPLIT_KEYBOARD
if (record->event.pressed) {
# else
if (!record->event.pressed) {
# endif
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_increase_hue();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_increase_hue();
# endif
}
} else if (keycode == RGB_HUD) {
# ifndef SPLIT_KEYBOARD
if (record->event.pressed) {
# else
if (!record->event.pressed) {
# endif
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_decrease_hue();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_decrease_hue();
# endif
}
} else if (keycode == RGB_SAI) {
# ifndef SPLIT_KEYBOARD
if (record->event.pressed) {
# else
if (!record->event.pressed) {
# endif
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_increase_sat();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_increase_sat();
# endif
}
} else if (keycode == RGB_SAD) {
# ifndef SPLIT_KEYBOARD
if (record->event.pressed) {
# else
if (!record->event.pressed) {
# endif
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_decrease_sat();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_decrease_sat();
# endif
}
} else if (keycode == RGB_VAI) {
# ifndef SPLIT_KEYBOARD
if (record->event.pressed) {
# else
if (!record->event.pressed) {
# endif
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_increase_val();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_increase_val();
# endif
}
} else if (keycode == RGB_VAD) {
# ifndef SPLIT_KEYBOARD
if (record->event.pressed) {
# else
if (!record->event.pressed) {
# endif
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_decrease_val();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_decrease_val();
# endif
}
} else if (keycode == RGB_SPI) {
if (record->event.pressed) {
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_increase_speed();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_increase_speed();
# endif
}
} else if (keycode == RGB_SPD) {
if (record->event.pressed) {
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_decrease_speed();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_decrease_speed();
# endif
}
}
return false;
# endif
#endif
}
}
return true;
}

View file

@ -0,0 +1,86 @@
#include "drashna.h"
#include "lib/lib8tion/lib8tion.h"
extern led_config_t g_led_config;
static uint32_t hypno_timer;
#if defined(SPLIT_KEYBOARD) || defined(KEYBOARD_ergodox_ez) || defined(KEYBOARD_crkbd)
# define RGB_MATRIX_REST_MODE RGB_MATRIX_CYCLE_OUT_IN_DUAL
#else
# define RGB_MATRIX_REST_MODE RGB_MATRIX_CYCLE_OUT_IN
#endif
void rgb_matrix_layer_helper(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode, uint8_t speed, uint8_t led_type) {
HSV hsv = {hue, sat, val};
if (hsv.v > rgb_matrix_config.hsv.v) {
hsv.v = rgb_matrix_config.hsv.v;
}
switch (mode) {
case 1: // breathing
{
uint16_t time = scale16by8(g_rgb_counters.tick, speed / 8);
hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
RGB rgb = hsv_to_rgb(hsv);
for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
if (HAS_FLAGS(g_led_config.flags[i], led_type)) {
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
}
break;
}
default: // Solid Color
{
RGB rgb = hsv_to_rgb(hsv);
for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
if (HAS_FLAGS(g_led_config.flags[i], led_type)) {
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
}
break;
}
}
}
__attribute__((weak)) void rgb_matrix_indicator_keymap(void) {}
void matrix_scan_rgb_matrix(void) {
#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
if (userspace_config.rgb_matrix_idle_anim && rgb_matrix_get_mode() == RGB_MATRIX_TYPING_HEATMAP && timer_elapsed32(hypno_timer) > 15000) {
rgb_matrix_mode_noeeprom(RGB_MATRIX_REST_MODE);
}
#endif
rgb_matrix_indicator_keymap();
}
void keyboard_post_init_rgb_matrix(void) {
#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
if (userspace_config.rgb_matrix_idle_anim) {
rgb_matrix_mode_noeeprom(RGB_MATRIX_REST_MODE);
}
#endif
}
bool process_record_user_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
hypno_timer = timer_read32();
if (userspace_config.rgb_matrix_idle_anim && rgb_matrix_get_mode() == RGB_MATRIX_REST_MODE) {
rgb_matrix_mode_noeeprom(RGB_MATRIX_TYPING_HEATMAP);
}
#endif
switch (keycode) {
case RGB_IDL: // This allows me to use underglow as layer indication, or as normal
#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
if (record->event.pressed) {
userspace_config.rgb_matrix_idle_anim ^= 1;
dprintf("RGB Matrix Idle Animation [EEPROM]: %u\n", userspace_config.rgb_matrix_idle_anim);
eeconfig_update_user(userspace_config.raw);
if (userspace_config.rgb_matrix_idle_anim) {
rgb_matrix_mode_noeeprom(RGB_MATRIX_TYPING_HEATMAP);
}
}
#endif
break;
}
return true;
}

View file

@ -0,0 +1,9 @@
#pragma once
#include "quantum.h"
bool process_record_user_rgb_matrix(uint16_t keycode, keyrecord_t *record);
void keyboard_post_init_rgb_matrix(void);
void matrix_scan_rgb_matrix(void);
void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
void rgb_matrix_layer_helper(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode, uint8_t speed, uint8_t led_type);

View file

@ -2,27 +2,15 @@
#include "rgb_stuff.h"
#include "eeprom.h"
#if defined(RGBLIGHT_ENABLE)
extern rgblight_config_t rgblight_config;
bool has_initialized;
void rgblight_sethsv_default_helper(uint8_t index) { rgblight_sethsv_at(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, index); }
#endif // RGBLIGHT_ENABLE
#if defined(RGB_MATRIX_ENABLE)
static uint32_t hypno_timer;
# if defined(SPLIT_KEYBOARD) || defined(KEYBOARD_ergodox_ez) || defined(KEYBOARD_crkbd)
# define RGB_MATRIX_REST_MODE RGB_MATRIX_CYCLE_OUT_IN_DUAL
# else
# define RGB_MATRIX_REST_MODE RGB_MATRIX_CYCLE_OUT_IN
# endif
#endif
/* Custom indicators for modifiers.
* This allows for certain lights to be lit up, based on what mods are active, giving some visual feedback.
* This is especially useful for One Shot Mods, since it's not always obvious if they're still lit up.
*/
#ifdef RGBLIGHT_ENABLE
#ifdef INDICATOR_LIGHTS
void set_rgb_indicators(uint8_t this_mod, uint8_t this_led, uint8_t this_osm) {
if (userspace_config.rgb_layer_change && get_highest_layer(layer_state) == 0) {
@ -214,22 +202,14 @@ void start_rgb_light(void) {
rgblight_sethsv_at(light->hue, 255, light->life, light_index);
}
#endif
#endif // RGBLIGHT_ENABLE
bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) {
bool process_record_user_rgb_light(uint16_t keycode, keyrecord_t *record) {
uint16_t temp_keycode = keycode;
// Filter out the actual keycode from MT and LT keys.
if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) {
temp_keycode &= 0xFF;
}
#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
hypno_timer = timer_read32();
if (userspace_config.rgb_matrix_idle_anim && rgb_matrix_get_mode() == RGB_MATRIX_REST_MODE) {
rgb_matrix_mode_noeeprom(RGB_MATRIX_TYPING_HEATMAP);
}
#endif
switch (temp_keycode) {
#ifdef RGBLIGHT_TWINKLE
case KC_A ... KC_SLASH:
@ -243,227 +223,18 @@ bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) {
}
break;
#endif // RGBLIGHT_TWINKLE
case KC_RGB_T: // This allows me to use underglow as layer indication, or as normal
#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
if (record->event.pressed) {
userspace_config.rgb_layer_change ^= 1;
dprintf("rgblight layer change [EEPROM]: %u\n", userspace_config.rgb_layer_change);
eeconfig_update_user(userspace_config.raw);
if (userspace_config.rgb_layer_change) {
# if defined(RGBLIGHT_ENABLE) && defined(RGB_MATRIX_ENABLE)
rgblight_enable_noeeprom();
# endif
layer_state_set(layer_state); // This is needed to immediately set the layer color (looks better)
# if defined(RGBLIGHT_ENABLE) && defined(RGB_MATRIX_ENABLE)
} else {
rgblight_disable_noeeprom();
# endif
}
}
#endif // RGBLIGHT_ENABLE
break;
case RGB_IDL: // This allows me to use underglow as layer indication, or as normal
#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
if (record->event.pressed) {
userspace_config.rgb_matrix_idle_anim ^= 1;
dprintf("RGB Matrix Idle Animation [EEPROM]: %u\n", userspace_config.rgb_matrix_idle_anim);
eeconfig_update_user(userspace_config.raw);
if (userspace_config.rgb_matrix_idle_anim) {
rgb_matrix_mode_noeeprom(RGB_MATRIX_TYPING_HEATMAP);
}
}
#endif
break;
#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
case RGB_TOG:
// Split keyboards need to trigger on key-up for edge-case issue
# ifndef SPLIT_KEYBOARD
if (record->event.pressed) {
# else
if (!record->event.pressed) {
# endif
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_toggle();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_toggle();
# endif
}
return false;
break;
case RGB_MODE_FORWARD ... RGB_MODE_GRADIENT: // quantum_keycodes.h L400 for definitions
if (record->event.pressed) {
bool is_eeprom_updated;
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
// This disables layer indication, as it's assumed that if you're changing this ... you want that disabled
if (userspace_config.rgb_layer_change) {
userspace_config.rgb_layer_change = false;
dprintf("rgblight layer change [EEPROM]: %u\n", userspace_config.rgb_layer_change);
is_eeprom_updated = true;
}
# endif
# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
if (userspace_config.rgb_matrix_idle_anim) {
userspace_config.rgb_matrix_idle_anim = false;
dprintf("RGB Matrix Idle Animation [EEPROM]: %u\n", userspace_config.rgb_matrix_idle_anim);
is_eeprom_updated = true;
}
# endif
if (is_eeprom_updated) {
eeconfig_update_user(userspace_config.raw);
}
}
# if defined(RGBLIGHT_DISABLE_KEYCODES) || defined(RGB_MATRIX_DISABLE_KEYCODES)
if (keycode == RGB_MODE_FORWARD && record->event.pressed) {
uint8_t shifted = get_mods() & (MOD_MASK_SHIFT);
if (shifted) {
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_step_reverse();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_step_reverse();
# endif
} else {
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_step();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_step();
# endif
}
} else if (keycode == RGB_MODE_REVERSE && record->event.pressed) {
uint8_t shifted = get_mods() & (MOD_MASK_SHIFT);
if (shifted) {
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_step();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_step();
# endif
} else {
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_step_reverse();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_step_reverse();
# endif
}
} else if (keycode == RGB_HUI) {
# ifndef SPLIT_KEYBOARD
if (record->event.pressed) {
# else
if (!record->event.pressed) {
# endif
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_increase_hue();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_increase_hue();
# endif
}
} else if (keycode == RGB_HUD) {
# ifndef SPLIT_KEYBOARD
if (record->event.pressed) {
# else
if (!record->event.pressed) {
# endif
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_decrease_hue();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_decrease_hue();
# endif
}
} else if (keycode == RGB_SAI) {
# ifndef SPLIT_KEYBOARD
if (record->event.pressed) {
# else
if (!record->event.pressed) {
# endif
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_increase_sat();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_increase_sat();
# endif
}
} else if (keycode == RGB_SAD) {
# ifndef SPLIT_KEYBOARD
if (record->event.pressed) {
# else
if (!record->event.pressed) {
# endif
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_decrease_sat();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_decrease_sat();
# endif
}
} else if (keycode == RGB_VAI) {
# ifndef SPLIT_KEYBOARD
if (record->event.pressed) {
# else
if (!record->event.pressed) {
# endif
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_increase_val();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_increase_val();
# endif
}
} else if (keycode == RGB_VAD) {
# ifndef SPLIT_KEYBOARD
if (record->event.pressed) {
# else
if (!record->event.pressed) {
# endif
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_decrease_val();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_decrease_val();
# endif
}
} else if (keycode == RGB_SPI) {
if (record->event.pressed) {
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_increase_speed();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_increase_speed();
# endif
}
} else if (keycode == RGB_SPD) {
if (record->event.pressed) {
# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
rgblight_decrease_speed();
# endif
# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
rgb_matrix_decrease_speed();
# endif
}
}
return false;
# endif
#endif
break;
}
return true;
}
void keyboard_post_init_rgb(void) {
#if defined(RGBLIGHT_ENABLE)
void keyboard_post_init_rgb_light(void) {
#if defined(RGBLIGHT_STARTUP_ANIMATION)
bool is_enabled = rgblight_config.enable;
if (userspace_config.rgb_layer_change) {
rgblight_enable_noeeprom();
}
if (rgblight_config.enable) {
layer_state_set_user(layer_state);
layer_state_set_rgb_light(layer_state);
uint16_t old_hue = rgblight_config.hue;
rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
for (uint16_t i = 255; i > 0; i--) {
@ -477,16 +248,10 @@ void keyboard_post_init_rgb(void) {
}
#endif
layer_state_set_user(layer_state);
#endif
#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
if (userspace_config.rgb_matrix_idle_anim) {
rgb_matrix_mode_noeeprom(RGB_MATRIX_REST_MODE);
}
#endif
layer_state_set_rgb_light(layer_state);
}
void matrix_scan_rgb(void) {
void matrix_scan_rgb_light(void) {
#ifdef RGBLIGHT_ENABLE
# ifdef RGBLIGHT_TWINKLE
scan_rgblight_fadeout();
@ -496,23 +261,15 @@ void matrix_scan_rgb(void) {
matrix_scan_indicator();
# endif
#endif
#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
if (userspace_config.rgb_matrix_idle_anim && rgb_matrix_get_mode() == RGB_MATRIX_TYPING_HEATMAP && timer_elapsed32(hypno_timer) > 15000) {
rgb_matrix_mode_noeeprom(RGB_MATRIX_REST_MODE);
}
#endif
}
#ifdef RGBLIGHT_ENABLE
void rgblight_set_hsv_and_mode(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode) {
rgblight_sethsv_noeeprom(hue, sat, val);
wait_us(175); // Add a slight delay between color and mode to ensure it's processed correctly
rgblight_mode_noeeprom(mode);
}
#endif
layer_state_t layer_state_set_rgb(layer_state_t state) {
layer_state_t layer_state_set_rgb_light(layer_state_t state) {
#ifdef RGBLIGHT_ENABLE
if (userspace_config.rgb_layer_change) {
switch (get_highest_layer(state)) {
@ -574,40 +331,3 @@ layer_state_t layer_state_set_rgb(layer_state_t state) {
return state;
}
#ifdef RGB_MATRIX_ENABLE
# include "lib/lib8tion/lib8tion.h"
extern led_config_t g_led_config;
void rgb_matrix_layer_helper(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode, uint8_t speed, uint8_t led_type) {
HSV hsv = {hue, sat, val};
if (hsv.v > rgb_matrix_config.hsv.v) {
hsv.v = rgb_matrix_config.hsv.v;
}
switch (mode) {
case 1: // breathing
{
uint16_t time = scale16by8(g_rgb_counters.tick, speed / 8);
hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
RGB rgb = hsv_to_rgb(hsv);
for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
if (HAS_FLAGS(g_led_config.flags[i], led_type)) {
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
}
break;
}
default: // Solid Color
{
RGB rgb = hsv_to_rgb(hsv);
for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
if (HAS_FLAGS(g_led_config.flags[i], led_type)) {
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
}
break;
}
}
}
#endif

View file

@ -1,10 +1,7 @@
#pragma once
#include "quantum.h"
#ifdef RGB_MATRIX_ENABLE
# include "rgb_matrix.h"
#endif
#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_TWINKLE)
#if defined(RGBLIGHT_TWINKLE)
typedef struct {
bool enabled;
uint8_t hue;
@ -13,20 +10,13 @@ typedef struct {
} rgblight_fadeout;
#endif
bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record);
void keyboard_post_init_rgb(void);
void matrix_scan_rgb(void);
layer_state_t layer_state_set_rgb(layer_state_t state);
layer_state_t default_layer_state_set_rgb(layer_state_t state);
bool process_record_user_rgb_light(uint16_t keycode, keyrecord_t *record);
void keyboard_post_init_rgb_light(void);
void matrix_scan_rgb_light(void);
layer_state_t layer_state_set_rgb_light(layer_state_t state);
layer_state_t default_layer_state_set_rgb_light(layer_state_t state);
void rgblight_sethsv_default_helper(uint8_t index);
#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_TWINKLE)
#if defined(RGBLIGHT_TWINKLE)
void scan_rgblight_fadeout(void);
#endif
#if defined(RGBLIGHT_ENABLE)
void rgblight_sethsv_default_helper(uint8_t index);
#endif
#ifdef RGB_MATRIX_ENABLE
void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
void rgb_matrix_layer_helper(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode, uint8_t speed, uint8_t led_type);
#endif

View file

@ -5,6 +5,7 @@ ifneq ($(PLATFORM),CHIBIOS)
LTO_ENABLE = yes
endif
SPACE_CADET_ENABLE = no
GRAVE_ESC_ENABLE = no
ifneq ($(strip $(NO_SECRETS)), yes)
ifneq ("$(wildcard $(USER_PATH)/secrets.c)","")
@ -19,10 +20,6 @@ ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
SRC += tap_dances.c
endif
ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
SRC += rgb_stuff.c
ifeq ($(strip $(INDICATOR_LIGHTS)), yes)
@ -41,7 +38,7 @@ endif
RGB_MATRIX_ENABLE ?= no
ifneq ($(strip $(RGB_MATRIX_ENABLE)), no)
SRC += rgb_stuff.c
SRC += rgb_matrix_stuff.c
endif
@ -61,3 +58,7 @@ endif
ifeq ($(strip $(PROTOCOL)), VUSB)
NKRO_ENABLE = no
endif
ifeq ($(strip $(OLED_DRIVER_ENABLE)), yes)
SRC += oled_stuff.c
endif