Skip to content

Commit

Permalink
[Keymap] Drashna's Improve OLEDs and custom Split code (qmk#14063)
Browse files Browse the repository at this point in the history
* Fill the oleds with right mods

* Enable double mods on x32 oleds

* Disable forced NKRO

* Make oleds fancy only on good MCUs

* Overhaul oled display

* Further enhance oled, with kitty!

* Final oled form

* Not working transport

* Transport id of woring

* Add acceleration

* fix button placement for accel macro

* Fix accelartion location and behavior

* Remove OLED sync code

* Fix alignment issue

* Remove audio hack

* Fix up zima keymap

* Add matrix slave scan function and cleanup drashna.h

* Clean up user space

* Allow userspace sync to be disable-able

* Fix weird issue with audio

* Fix alignment issue with user split sync

* Disable second rgb matrix task

* Disable additional animations

* Change dynamic keymap settings

* Hacky fix for borked corne

* Add Blackpill (F411) support to tractyl manuform

* remove manual via eeprom reset

* Remove all references to rgblight twinkle

* Fix issues with config processing
  • Loading branch information
drashna authored Aug 21, 2021
1 parent e588f2c commit 03d57c7
Show file tree
Hide file tree
Showing 20 changed files with 313 additions and 321 deletions.
1 change: 0 additions & 1 deletion layouts/community/ergodox/drashna/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ SPACE_CADET_ENABLE = no
ifeq ($(strip $(KEYBOARD)), ergodox_ez)
RGBLIGHT_ENABLE = yes
RGB_MATRIX_ENABLE = yes
RGBLIGHT_TWINKLE = no
INDICATOR_LIGHTS = no
RGBLIGHT_STARTUP_ANIMATION = yes
PIMORONI_TRACKBALL_ENABLE = yes
Expand Down
2 changes: 2 additions & 0 deletions layouts/community/numpad_5x6/drashna/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
# define RGBLIGHT_EFFECT_SNAKE_LENGTH 2
#endif // RGBLIGHT_ENABLE

#define RGBLIGHT_ALL_ANIMATIONS

#if defined(KEYBOARD_primekb_prime_m)
# undef PRODUCT
# define PRODUCT Drashna Hacked Prime_M Macro Pad
Expand Down
1 change: 0 additions & 1 deletion layouts/community/numpad_5x6/drashna/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ BACKLIGHT_ENABLE = no
NO_SECRETS = yes
BOOTMAGIC_ENABLE = lite # Enable Bootmagic Lite
INDICATOR_LIGHTS = no
RGBLIGHT_TWINKLE = yes
MAKE_BOOTLOADER = yes
RGBLIGHT_STARTUP_ANIMATION = yes
1 change: 1 addition & 0 deletions layouts/community/ortho_4x12/drashna/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
# define PRODUCT Drashna Hacked Planck Rev6
# elif defined(KEYBOARD_planck_ez)
# define PRODUCT Drashna Hacked Planck EZ
# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 4095
# endif
#endif
#undef NO_USB_STARTUP_CHECK
Expand Down
2 changes: 0 additions & 2 deletions layouts/community/ortho_4x12/drashna/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ ifneq ($(strip $(KEYBOARD)), planck/rev6)
ifeq ($(strip $(LAYOUT_HAS_RGB)), yes)
RGBLIGHT_ENABLE = yes
INDICATOR_LIGHTS = yes
RGBLIGHT_TWINKLE = yes
RGBLIGHT_STARTUP_ANIMATION = yes
endif
else
Expand All @@ -37,7 +36,6 @@ ifeq ($(strip $(KEYBOARD)), planck/ez)
ENCODER_MAP_ENABLE = yes
RGB_MATRIX_ENABLE = yes
INDICATOR_LIGHTS = yes
RGBLIGHT_TWINKLE = yes
RGBLIGHT_STARTUP_ANIMATION = yes
CONSOLE_ENABLE = yes
COMMAND_ENABLE = yes
Expand Down
1 change: 0 additions & 1 deletion layouts/community/ortho_5x12/drashna/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ ifeq ($(strip $(KEYBOARD)), fractal)
AUDIO_SUPPORTED = yes
RGBLIGHT_SUPPORTED = yes
RGBLIGHT_ENABLE = yes
RGBLIGHT_TWINKLE = yes
RGBLIGHT_STARTUP_ANIMATION = yes
BOOTLOADER = qmk-dfu
endif
14 changes: 7 additions & 7 deletions layouts/community/split_3x6_3/drashna/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ enum crkbd_keycodes { RGBRST = NEW_SAFE_RANGE };
* of use. K## is a placeholder to pass through the individual keycodes
*/

#ifdef CONVERT_TO_PROTON_C
# define MID_TMB ET_RAIS
#else
# define MID_TMB KC_ENT
#endif

// clang-format off
#define LAYOUT_split_3x6_3_wrapper(...) LAYOUT_split_3x6_3(__VA_ARGS__)
#define LAYOUT_split_3x6_3_base( \
Expand All @@ -37,7 +43,7 @@ enum crkbd_keycodes { RGBRST = NEW_SAFE_RANGE };
KC_ESC, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, KC_MINS, \
ALT_T(KC_TAB), K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, RALT_T(K1B), \
OS_LSFT, CTL_T(K21), K22, K23, K24, K25, K26, K27, K28, K29, RCTL_T(K2A), OS_RSFT, \
OS_LGUI, KC_SPC, BK_LWER, DL_RAIS, KC_ENT, OS_RGUI \
OS_LGUI, KC_SPC, BK_LWER, DL_RAIS, MID_TMB, OS_RGUI \
)
#define LAYOUT_base_wrapper(...) LAYOUT_split_3x6_3_base(__VA_ARGS__)

Expand Down Expand Up @@ -104,12 +110,6 @@ uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) {
}
#endif

void matrix_slave_scan_user(void) {
#ifdef RGB_MATRIX_ENABLE
rgb_matrix_task();
#endif
}

#ifdef RGB_MATRIX_ENABLE
void suspend_power_down_keymap(void) { rgb_matrix_set_suspend_state(true); }

Expand Down
57 changes: 33 additions & 24 deletions users/drashna/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@
# ifdef WPM_ENABLE
# define SPLIT_WPM_ENABLE
# endif
# define SELECT_SOFT_SERIAL_SPEED 1
# define SPLIT_TRANSACTION_IDS_USER RPC_ID_USER_STATE_SYNC, RPC_ID_USER_KEYMAP_SYNC, RPC_ID_USER_CONFIG_SYNC
# ifdef OLED_DRIVER_ENABLE
# define SPLIT_OLED_ENABLE
# endif
# if defined(__AVR__) && !defined(SELECT_SOFT_SERIAL_SPEED)
# define SELECT_SOFT_SERIAL_SPEED 1
# endif
# ifdef CUSTOM_SPLIT_TRANSPORT_SYNC
# define SPLIT_TRANSACTION_IDS_USER RPC_ID_USER_STATE_SYNC, RPC_ID_USER_KEYMAP_SYNC, RPC_ID_USER_CONFIG_SYNC
# endif
#endif

#ifdef AUDIO_ENABLE
Expand Down Expand Up @@ -65,23 +72,6 @@

#ifdef RGBLIGHT_ENABLE
# define RGBLIGHT_SLEEP
# undef RGBLIGHT_ANIMATIONS
# if defined(__AVR__) && !defined(__AVR_AT90USB1286__)
# define RGBLIGHT_EFFECT_BREATHING
# define RGBLIGHT_EFFECT_SNAKE
# define RGBLIGHT_EFFECT_KNIGHT
# else
# define RGBLIGHT_EFFECT_BREATHING
# define RGBLIGHT_EFFECT_RAINBOW_MOOD
# define RGBLIGHT_EFFECT_RAINBOW_SWIRL
# define RGBLIGHT_EFFECT_SNAKE
# define RGBLIGHT_EFFECT_KNIGHT
// # define RGBLIGHT_EFFECT_CHRISTMAS
// # define RGBLIGHT_EFFECT_STATIC_GRADIENT
// # define RGBLIGHT_EFFECT_RGB_TEST
// # define RGBLIGHT_EFFECT_ALTERNATING
# define RGBLIGHT_EFFECT_TWINKLE
# endif
# define RGBLIGHT_EFFECT_TWINKLE_LIFE 250
# define RGBLIGHT_EFFECT_TWINKLE_PROBABILITY 1 / 24
#endif // RGBLIGHT_ENABLE
Expand All @@ -107,8 +97,10 @@
# define DISABLE_RGB_MATRIX_CYCLE_ALL
# define DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
# define DISABLE_RGB_MATRIX_CYCLE_UP_DOWN
// # define DISABLE_RGB_MATRIX_CYCLE_OUT_IN
# if defined(SPLIT_KEYBOARD) || defined(KEYBOARD_ergodox_ez) || defined(KEYBOARD_moonlander)
# define DISABLE_RGB_MATRIX_CYCLE_OUT_IN
// # define DISABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL
# endif
# define DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
# define DISABLE_RGB_MATRIX_DUAL_BEACON
# define DISABLE_RGB_MATRIX_CYCLE_PINWHEEL
Expand All @@ -117,6 +109,12 @@
# define DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS
# define DISABLE_RGB_MATRIX_RAINDROPS
# define DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
# define DISABLE_RGB_MATRIX_HUE_BREATHING
# define DISABLE_RGB_MATRIX_HUE_PENDULUM
# define DISABLE_RGB_MATRIX_HUE_WAVE
# define DISABLE_RGB_MATRIX_PIXEL_RAIN
# define DISABLE_RGB_MATRIX_PIXEL_FLOW
# define DISABLE_RGB_MATRIX_PIXEL_FRACTAL
// # define DISABLE_RGB_MATRIX_TYPING_HEATMAP
# define DISABLE_RGB_MATRIX_DIGITAL_RAIN
# define DISABLE_RGB_MATRIX_SOLID_REACTIVE
Expand All @@ -132,7 +130,15 @@
# define DISABLE_RGB_MATRIX_SOLID_SPLASH
# define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH
# endif // AVR
#endif // RGB_MATRIX_ENABLE
# ifndef RGB_MATRIX_REST_MODE
# if defined(SPLIT_KEYBOARD) || defined(KEYBOARD_ergodox_ez) || defined(KEYBOARD_moonlander)
# define RGB_MATRIX_REST_MODE RGB_MATRIX_CYCLE_OUT_IN_DUAL
# else
# define RGB_MATRIX_REST_MODE RGB_MATRIX_CYCLE_OUT_IN
# endif
# endif
# define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_REST_MODE
#endif // RGB_MATRIX_ENABLE

#ifdef OLED_DRIVER_ENABLE
# ifdef SPLIT_KEYBOARD
Expand Down Expand Up @@ -182,8 +188,6 @@
# define TAPPING_TERM_PER_KEY
#endif

#define FORCE_NKRO

#ifndef TAPPING_TOGGLE
# define TAPPING_TOGGLE 1
#endif
Expand All @@ -209,7 +213,12 @@
# undef LOCKING_RESYNC_ENABLE
#endif

#define LAYER_STATE_16BIT
#if !defined(LAYER_STATE_16BIT) && !defined(LAYER_STATE_8BIT) && !defined(LAYER_STATE_32BIT)
# define LAYER_STATE_16BIT
#endif
#ifndef DYNAMIC_KEYMAP_LAYER_COUNT
# define DYNAMIC_KEYMAP_LAYER_COUNT 11
#endif

#ifdef CONVERT_TO_PROTON_C
// pins that are available but not present on Pro Micro
Expand Down
95 changes: 59 additions & 36 deletions users/drashna/drashna.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,19 @@ bool mod_key_press(uint16_t code, uint16_t mod_code, bool pressed, uint16_t this
}

__attribute__((weak)) void keyboard_pre_init_keymap(void) {}

void keyboard_pre_init_user(void) {
void keyboard_pre_init_user(void) {
userspace_config.raw = eeconfig_read_user();
keyboard_pre_init_keymap();
}
// Add reconfigurable functions here, for keymap customization
// This allows for a global, userspace functions, and continued
// customization of the keymap. Use _keymap instead of _user
// functions in the keymaps
__attribute__((weak)) void matrix_init_keymap(void) {}
__attribute__((weak)) void matrix_init_secret(void) {}

// Call user matrix init, set default RGB colors and then
// call the keymap's init function
void matrix_init_user(void) {
__attribute__((weak)) void matrix_init_keymap(void) {}
__attribute__((weak)) void matrix_init_secret(void) {}
void matrix_init_user(void) {
#if defined(BOOTLOADER_CATERINA) && defined(__AVR__)
DDRD &= ~(1 << 5);
PORTD &= ~(1 << 5);
Expand All @@ -75,11 +73,15 @@ void matrix_init_user(void) {

matrix_init_secret();
matrix_init_keymap();
#if defined(AUDIO_ENABLE) && defined(SPLIT_KEYBOARD)
if (!is_keyboard_master()) {
stop_all_notes();
}
#endif
}

__attribute__((weak)) void keyboard_post_init_keymap(void) {}

void keyboard_post_init_user(void) {
void keyboard_post_init_user(void) {
#if defined(RGBLIGHT_ENABLE)
keyboard_post_init_rgb_light();
#endif
Expand All @@ -92,13 +94,12 @@ void keyboard_post_init_user(void) {
keyboard_post_init_keymap();
}

__attribute__((weak)) void shutdown_keymap(void) {}

#ifdef RGB_MATRIX_ENABLE
void rgb_matrix_update_pwm_buffers(void);
#endif

void shutdown_user(void) {
__attribute__((weak)) void shutdown_keymap(void) {}
void shutdown_user(void) {
#ifdef RGBLIGHT_ENABLE
rgblight_enable_noeeprom();
rgblight_mode_noeeprom(1);
Expand All @@ -113,17 +114,15 @@ void shutdown_user(void) {
}

__attribute__((weak)) void suspend_power_down_keymap(void) {}

void suspend_power_down_user(void) {
void suspend_power_down_user(void) {
#ifdef OLED_DRIVER_ENABLE
oled_off();
#endif
suspend_power_down_keymap();
}

__attribute__((weak)) void suspend_wakeup_init_keymap(void) {}

void suspend_wakeup_init_user(void) {
void suspend_wakeup_init_user(void) {
if (layer_state_is(_GAMEPAD)) {
layer_off(_GAMEPAD);
}
Expand All @@ -133,13 +132,11 @@ void suspend_wakeup_init_user(void) {
suspend_wakeup_init_keymap();
}

__attribute__((weak)) void matrix_scan_keymap(void) {}

__attribute__((weak)) void matrix_scan_secret(void) {}

// No global matrix scan code, so just run keymap's matrix
// scan function
void matrix_scan_user(void) {
__attribute__((weak)) void matrix_scan_keymap(void) {}
__attribute__((weak)) void matrix_scan_secret(void) {}
void matrix_scan_user(void) {
static bool has_ran_yet;
if (!has_ran_yet) {
has_ran_yet = true;
Expand All @@ -166,11 +163,10 @@ void matrix_scan_user(void) {
float doom_song[][2] = SONG(E1M1_DOOM);
#endif

__attribute__((weak)) layer_state_t layer_state_set_keymap(layer_state_t state) { return state; }

// on layer change, no matter where the change was initiated
// Then runs keymap's layer change check
layer_state_t layer_state_set_user(layer_state_t state) {
__attribute__((weak)) layer_state_t layer_state_set_keymap(layer_state_t state) { return state; }
layer_state_t layer_state_set_user(layer_state_t state) {
if (!is_keyboard_master()) {
return state;
}
Expand All @@ -194,10 +190,9 @@ layer_state_t layer_state_set_user(layer_state_t state) {
return state;
}

__attribute__((weak)) layer_state_t default_layer_state_set_keymap(layer_state_t state) { return state; }

// Runs state check and changes underglow color and animation
layer_state_t default_layer_state_set_user(layer_state_t state) {
__attribute__((weak)) layer_state_t default_layer_state_set_keymap(layer_state_t state) { return state; }
layer_state_t default_layer_state_set_user(layer_state_t state) {
if (!is_keyboard_master()) {
return state;
}
Expand All @@ -212,22 +207,14 @@ layer_state_t default_layer_state_set_user(layer_state_t state) {
}

__attribute__((weak)) void led_set_keymap(uint8_t usb_led) {}

// Any custom LED code goes here.
// So far, I only have keyboard specific code,
// So nothing goes here.
void led_set_user(uint8_t usb_led) { led_set_keymap(usb_led); }
void led_set_user(uint8_t usb_led) { led_set_keymap(usb_led); }

__attribute__((weak)) void eeconfig_init_keymap(void) {}

void eeconfig_init_user(void) {
void eeconfig_init_user(void) {
userspace_config.raw = 0;
userspace_config.rgb_layer_change = true;
eeconfig_update_user(userspace_config.raw);
eeconfig_init_keymap();
#ifdef VIA_ENABLE
via_eeprom_reset();
#endif
keyboard_init();
}

Expand All @@ -237,3 +224,39 @@ bool hasAllBitsInMask(uint8_t value, uint8_t mask) {

return (value & mask) == mask;
}

#ifdef SPLIT_KEYBOARD
# if defined(AUDIO_ENABLE)
bool delayed_tasks_run = false;
# endif
__attribute__((weak)) void matrix_slave_scan_keymap(void) {}
void matrix_slave_scan_user(void) {
# if defined(AUDIO_ENABLE)
# if !defined(NO_MUSIC_MODE)
music_task();
# endif
if (!is_keyboard_master()) {
static uint16_t delayed_task_timer = 0;
if (!delayed_tasks_run) {
if (!delayed_task_timer) {
delayed_task_timer = timer_read();
} else if (timer_elapsed(delayed_task_timer) > 300) {
audio_startup();
delayed_tasks_run = true;
}
}
}
# endif
# ifdef SEQUENCER_ENABLE
sequencer_task();
# endif
# ifdef LED_MATRIX_ENABLE
led_matrix_task();
# endif
# ifdef HAPTIC_ENABLE
haptic_task();
# endif

matrix_slave_scan_keymap();
}
#endif
Loading

0 comments on commit 03d57c7

Please sign in to comment.