Skip to content

Commit

Permalink
[Keymap] Drashna's Keymap Update - Display Edition (qmk#9282)
Browse files Browse the repository at this point in the history
OLED Display fixes
Add support for RGBLIGHT Layers
Add gaming layer to corn and kyria
RGBLight Startup Animation fixes and improvements (uses matrix_scan now!)
Pimoroni Trackball support added (IT'S RGB!!!)
Fix issues due to code changes
  • Loading branch information
drashna committed Jun 15, 2020
1 parent 7f56569 commit 357a888
Show file tree
Hide file tree
Showing 19 changed files with 332 additions and 188 deletions.
12 changes: 11 additions & 1 deletion keyboards/crkbd/keymaps/drashna/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,17 @@ 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; }
oled_rotation_t oled_init_user(oled_rotation_t rotation) {
# ifndef SPLIT_KEYBOARD
if (is_master) {
# endif
return OLED_ROTATION_270;
# ifndef SPLIT_KEYBOARD
} else {
return rotation;
}
# endif
}
#endif

uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) {
Expand Down
1 change: 1 addition & 0 deletions keyboards/kyria/keymaps/drashna/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
# define RGBLIGHT_SAT_STEP 8
# define RGBLIGHT_VAL_STEP 8
# define RGBLIGHT_SPLIT
# define RGBLIGHT_LAYERS
#endif

// If you are using an Elite C rev3 on the slave side, uncomment the lines below:
Expand Down
48 changes: 47 additions & 1 deletion keyboards/kyria/keymaps/drashna/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ uint8_t is_master;
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, MEH(KC_MINS), TG(_DIABLO), KC_NO, K26, K27, K28, K29, RCTL_T(K2A), OS_RSFT, \
OS_LSFT, CTL_T(K21), K22, K23, K24, K25, TG(_GAMEPAD), MEH(KC_MINS), TG(_DIABLO), KC_CAPS, 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 */
Expand Down Expand Up @@ -85,6 +85,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_LSFT, ___________________BLANK___________________, _______, _______, _______, _______, ___________________BLANK___________________, KC_RSFT,
_______, _______, KC_LALT, _______, _______, _______, _______, KC_RGUI, _______, _______
),

[_GAMEPAD] = LAYOUT_wrapper(
KC_ESC, KC_K, KC_Q, KC_W, KC_E, KC_R, _______, _______, _______, _______, _______, _______,
KC_TAB, KC_G, KC_A, KC_S, KC_D, KC_F, _______, _______, _______, _______, _______, _______,
KC_LCTL, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, _______, _______, _______, LALT(KC_PSCR), _______, _______, _______, _______, _______, _______,
_______, MAGIC_TOGGLE_NKRO, KC_V, KC_SPC, KC_H, _______, _______, _______, _______, _______
),

[_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,
Expand Down Expand Up @@ -172,3 +180,41 @@ void encoder_update_user(uint8_t index, bool clockwise) {
}
}
#endif

#ifdef RGBLIGHT_LAYERS
const rgblight_segment_t PROGMEM shift_layers[] = RGBLIGHT_LAYER_SEGMENTS(
{ 8, 1, 120, 255, 255},
{ 18, 1, 120, 255, 255}
);
const rgblight_segment_t PROGMEM control_layers[] = RGBLIGHT_LAYER_SEGMENTS(
{ 6, 1, 0, 255, 255},
{ 16, 1, 0, 255, 255}
);
const rgblight_segment_t PROGMEM alt_layers[] = RGBLIGHT_LAYER_SEGMENTS(
{ 2, 1, 240, 255, 255},
{ 17, 1, 250, 255, 255}
);
const rgblight_segment_t PROGMEM gui_layers[] = RGBLIGHT_LAYER_SEGMENTS(
{ 7, 1, 51, 255, 255},
{ 12, 1, 51, 255, 255}
);

const rgblight_segment_t* const PROGMEM my_rgb_layers[] = RGBLIGHT_LAYERS_LIST(
shift_layers,
control_layers,
alt_layers,
gui_layers
);

void keyboard_post_init_keymap(void) {
rgblight_layers = my_rgb_layers;
}

void matrix_scan_keymap(void) {
uint8_t mods = mod_config(get_mods()|get_oneshot_mods());
rgblight_set_layer_state(0, mods & MOD_MASK_SHIFT);
rgblight_set_layer_state(1, mods & MOD_MASK_CTRL);
rgblight_set_layer_state(2, mods & MOD_MASK_ALT);
rgblight_set_layer_state(3, mods & MOD_MASK_GUI);
}
#endif
6 changes: 3 additions & 3 deletions keyboards/kyria/keymaps/drashna/rules.mk
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
OLED_DRIVER_ENABLE = yes # Enables the use of OLED displays
ENCODER_ENABLE = yes # ENables the use of one or more encoders
RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow
RGBLIGHT_STARTUP_ANIMATION = no
RGBLIGHT_STARTUP_ANIMATION = yes

BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration
MOUSEKEY_ENABLE = no # Mouse keys
MOUSEKEY_ENABLE = no # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = no # Console for debug
COMMAND_ENABLE = no # Commands for debug and configuration
NKRO_ENABLE = no # USB Nkey Rollover
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default
MIDI_ENABLE = no # MIDI support
UNICODE_ENABLE = yes # Unicode
UNICODE_ENABLE = no # Unicode
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
AUDIO_ENABLE = no # Audio output on port C6
FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches
Expand Down
5 changes: 4 additions & 1 deletion layouts/community/ergodox/drashna/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#define PRODUCT DrashnaDox - Hacked ErgoDox EZ Hybrid Monstrosity

#undef DEBOUNCE
#define DEBOUNCE 60
#define DEBOUNCE 15

#define TAPPING_TERM_PER_KEY

Expand All @@ -30,3 +30,6 @@
# undef RGBLIGHT_SLEEP
# endif
#endif

#define PIMORONI_TRACKBALL_INVERT_X
#define PIMORONI_TRACKBALL_INVERT_Y
58 changes: 55 additions & 3 deletions layouts/community/ergodox/drashna/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
extern rgblight_config_t rgblight_config;
#endif

enum more_custom_keycodes { KC_SWAP_NUM = NEW_SAFE_RANGE };
enum more_custom_keycodes {
KC_SWAP_NUM = NEW_SAFE_RANGE,
PM_SCROLL,
PM_PRECISION,
};

// define layer change stuff for underglow indicator
bool skip_leds = false;
Expand All @@ -33,7 +37,7 @@ bool skip_leds = false;
LALT_T(KC_TAB), K01, K02, K03, K04, K05, TG(_DIABLO), TG(_DIABLO), K06, K07, K08, K09, K0A, KC_BSLS, \
KC_C1R3, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, RALT_T(KC_QUOT), \
KC_MLSF, CTL_T(K21), K22, K23, K24, K25, TG(_GAMEPAD), TG(_GAMEPAD), K26, K27, K28, K29, RCTL_T(K2A), KC_MRSF, \
KC_GRV, OS_MEH, OS_HYPR, KC_LBRC, KC_RBRC, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, UC(0x2E2E), \
KC_GRV, OS_MEH, OS_HYPR, KC_LBRC, KC_RBRC, KC_BTN1, KC_BTN3, KC_BTN2, PM_SCROLL, PM_PRECISION, \
OS_LALT, OS_LGUI, OS_RGUI, CTL_T(KC_ESCAPE), \
KC_APP, KC_MENU, \
KC_SPC, LT(_LOWER, KC_BSPC), OS_LWR, OS_RSE, LT(_RAISE, KC_DEL), KC_ENT \
Expand Down Expand Up @@ -281,7 +285,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

[_ADJUST] = LAYOUT_ergodox_pretty_wrapper(
KC_MAKE, _______, _______, _______, _______, _______, UC_MOD, KC_NUKE, _________________ADJUST_R1_________________, KC_RST,
VRSN, _________________ADJUST_L1_________________, _______, _______, _______, _______, _______, _______, _______, EEP_RST,
VRSN, _________________ADJUST_L1_________________, _______, _______, _________________ADJUST_R1_________________, EEP_RST,
_______, _________________ADJUST_L2_________________, _________________ADJUST_R2_________________, RGB_IDL,
_______, _________________ADJUST_L3_________________, _______, _______, _________________ADJUST_R3_________________, TG(_MODS),
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
Expand All @@ -293,6 +297,26 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
};
// clang-format on

#ifdef PIMORONI_TRACKBALL_ENABLE
void run_trackball_cleanup(void) {
if (trackball_is_scrolling()) {
trackball_set_rgbw(RGB_CYAN, 0x00);
} else if (trackball_get_precision() != 1.0) {
trackball_set_rgbw(RGB_GREEN, 0x00);
} else {
trackball_set_rgbw(RGB_MAGENTA, 0x00);
}
}

void keyboard_post_init_keymap(void) {
// trackball_set_precision(1.5);
trackball_set_rgbw(RGB_MAGENTA, 0x00);
}
void shutdown_keymap(void) {
trackball_set_rgbw(RGB_RED, 0x00);
}
#endif

bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case KC_1:
Expand Down Expand Up @@ -321,6 +345,34 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
eeconfig_update_user(userspace_config.raw);
}
break;
#ifdef PIMORONI_TRACKBALL_ENABLE
case PM_SCROLL:
trackball_set_scrolling(record->event.pressed);
run_trackball_cleanup();
break;
case PM_PRECISION:
if (record->event.pressed) {
trackball_set_precision(1.5);
} else {
trackball_set_precision(1);
}
run_trackball_cleanup();
break;
#if !defined(MOUSEKEY_ENABLE) && defined(POINTING_DEVICE_ENABLE)
case KC_BTN1 ... KC_BTN3:
{
report_mouse_t currentReport = pointing_device_get_report();
if (record->event.pressed) {
currentReport.buttons |= (1 << (keycode - KC_BTN1)); // this is defined in report.h
} else {
currentReport.buttons &= ~(1 << (keycode - KC_BTN1));
}
pointing_device_set_report(currentReport);
pointing_device_send();
break;
}
# endif
#endif
}
// switch (keycode) {
// case KC_P00:
Expand Down
14 changes: 8 additions & 6 deletions layouts/community/ergodox/drashna/rules.mk
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
BOOTMAGIC_ENABLE = lite
TAP_DANCE_ENABLE = yes
COMMAND_ENABLE = no # Commands for debug and configuration
CONSOLE_ENABLE =
CONSOLE_ENABLE = no
SPACE_CADET_ENABLE = no

ifeq ($(strip $(KEYBOARD)), ergodox_ez)
RGBLIGHT_ENABLE = yes
RGB_MATRIX_ENABLE = yes
RGBLIGHT_TWINKLE = no
INDICATOR_LIGHTS = no
RGBLIGHT_ENABLE = yes
RGB_MATRIX_ENABLE = yes
RGBLIGHT_TWINKLE = no
INDICATOR_LIGHTS = no
RGBLIGHT_STARTUP_ANIMATION = yes
PIMORONI_TRACKBALL_ENABLE = yes
MOUSEKEY_ENABLE = no
endif

UNICODE_ENABLE = yes
UNICODE_ENABLE = no
UNICDOEMAP_ENABLE = no


Expand Down
11 changes: 6 additions & 5 deletions layouts/community/ortho_5x12/drashna/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ TAP_DANCE_ENABLE = no
NKRO_ENABLE = yes

ifeq ($(strip $(KEYBOARD)), fractal)
RGB_MATRIX_ENABLE = no
AUDIO_ENABLE = yes
RGBLIGHT_ENABLE = yes
RGBLIGHT_TWINKLE = yes
BOOTLOADER = qmk-dfu
RGB_MATRIX_ENABLE = no
AUDIO_ENABLE = yes
RGBLIGHT_ENABLE = yes
RGBLIGHT_TWINKLE = yes
RGBLIGHT_STARTUP_ANIMATION = yes
BOOTLOADER = qmk-dfu
endif
5 changes: 2 additions & 3 deletions users/drashna/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ QMK Firmware:
GIT_SUBMODULE_STRATEGY: recursive
tags:
- linux
image: ubuntu:18.10
image: qmkfm/base_container
before_script:
- apt-get update -qy
- apt-get install -y build-essential avr-libc binutils-arm-none-eabi binutils-avr dfu-programmer dfu-util gcc gcc-arm-none-eabi git libnewlib-arm-none-eabi gcc-avr python3 unzip wget zip
- avr-gcc --version
- uname -a
script:
- make test:all
- make planck/rev6:default planck/rev5:default
- make keebio/iris/rev2:drashna keebio/iris/rev2:drashna_old ergodox_ez:drashna ergodox_ez:drashna_glow keebio/viterbi/rev1:drashna orthodox/rev1:drashna orthodox/rev3:drashna crkbd:drashna planck/light:drashna planck/rev6:drashna fractal:drashna primekb/prime_m:drashna -j2 --output-sync
- make all:drashna -j2
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
paths:
Expand Down
7 changes: 4 additions & 3 deletions users/drashna/config.h
Original file line number Diff line number Diff line change
@@ -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)0x1338
#define EECONFIG_MAGIC_NUMBER (uint16_t)0x1339

/* Set Polling rate to 1000Hz */
#define USB_POLLING_INTERVAL_MS 1
Expand Down Expand Up @@ -98,8 +98,9 @@
# define ONESHOT_TIMEOUT 3000
#endif // !ONESHOT_TIMEOUT

#ifndef QMK_KEYS_PER_SCAN
# define QMK_KEYS_PER_SCAN 4
#ifdef QMK_KEYS_PER_SCAN
# undef QMK_KEYS_PER_SCAN
# define QMK_KEYS_PER_SCAN 1
#endif // !QMK_KEYS_PER_SCAN

// this makes it possible to do rolling combos (zx) with keys that
Expand Down
6 changes: 1 addition & 5 deletions users/drashna/drashna.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,9 @@ void shutdown_user(void) {
rgblight_setrgb_red();
#endif // RGBLIGHT_ENABLE
#ifdef RGB_MATRIX_ENABLE
# ifdef __AVR__
rgb_matrix_set_color_all(0xFF, 0x00, 0x00);
rgb_matrix_update_pwm_buffers();
# else
rgb_matrix_sethsv_noeeprom(0, 255, 255);
rgb_matrix_mode_noeeprom(1);
# endif

#endif // RGB_MATRIX_ENABLE
shutdown_keymap();
}
Expand Down
3 changes: 3 additions & 0 deletions users/drashna/drashna.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#if defined(OLED_DRIVER_ENABLE)
# include "oled_stuff.h"
#endif
#if defined(PIMORONI_TRACKBALL_ENABLE)
# include "pimoroni_trackball.h"
#endif

/* Define layer names */
enum userspace_layers {
Expand Down
17 changes: 12 additions & 5 deletions users/drashna/oled_stuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,18 +170,25 @@ void render_bootmagic_status(void) {
{{0x95, 0x96, 0}, {0xb5, 0xb6, 0}},
};

bool is_bootmagic_on;
#ifdef OLED_DISPLAY_128X64
is_bootmagic_on = !keymap_config.swap_lctl_lgui;
#else
is_bootmagic_on = keymap_config.swap_lctl_lgui;
#endif

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);
oled_write_P(logo[1][0], is_bootmagic_on);
#ifdef OLED_DISPLAY_128X64
} else {
#endif
oled_write_P(logo[0][0], false);
oled_write_P(logo[0][0], !is_bootmagic_on);
}
oled_write_P(PSTR(" "), false);
#ifdef OLED_DISPLAY_128X64
Expand All @@ -192,11 +199,11 @@ void render_bootmagic_status(void) {
if (keymap_config.swap_lctl_lgui)
#endif
{
oled_write_P(logo[1][1], false);
oled_write_P(logo[1][1], is_bootmagic_on);
#ifdef OLED_DISPLAY_128X64
} else {
#endif
oled_write_P(logo[0][1], false);
oled_write_P(logo[0][1], !is_bootmagic_on);
}
oled_write_P(PSTR(" "), false);
#ifdef OLED_DISPLAY_128X64
Expand Down Expand Up @@ -233,7 +240,7 @@ __attribute__((weak)) void oled_driver_render_logo(void) {
}

void render_status_secondary(void) {
#if !defined(SPLIT_TRANSPORT_MIRROR) || defined(OLED_DRIVER_128x64)
#if !defined(SPLIT_TRANSPORT_MIRROR) || defined(OLED_DISPLAY_128X64)
oled_driver_render_logo();
#endif
#ifdef SPLIT_TRANSPORT_MIRROR
Expand Down
Loading

0 comments on commit 357a888

Please sign in to comment.