summaryrefslogtreecommitdiffstats
path: root/users
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2022-01-21 19:36:52 -0800
committerGitHub <noreply@github.com>2022-01-21 19:36:52 -0800
commitb090ff03ed4391f27e8e3d9a843f529bedd08e19 (patch)
treee734aa4541f05ed4f919f86ff36d85cbd17f795a /users
parent8901c9eca1db8d10b06f544553a5fc941eda51ae (diff)
[Keymap] Drashna's OLED rewrite (#15981)
Diffstat (limited to 'users')
-rw-r--r--users/drashna/callbacks.c15
-rw-r--r--users/drashna/config.h20
-rw-r--r--users/drashna/drashna.c96
-rw-r--r--users/drashna/drashna.h3
-rw-r--r--users/drashna/keyrecords/autocorrection/autocorrection.c19
-rw-r--r--users/drashna/keyrecords/caps_word.c10
-rw-r--r--users/drashna/keyrecords/process_records.c23
-rw-r--r--users/drashna/keyrecords/tap_dances.c12
-rw-r--r--users/drashna/keyrecords/unicode.c27
-rw-r--r--users/drashna/oled/oled_stuff.c670
-rw-r--r--users/drashna/oled/oled_stuff.h22
-rw-r--r--users/drashna/oled/sh110x.c860
-rw-r--r--users/drashna/pointing/pointing.c2
-rw-r--r--users/drashna/rules.mk13
-rw-r--r--users/drashna/split/transport_sync.c65
-rw-r--r--users/drashna/split/transport_sync.h4
16 files changed, 1730 insertions, 131 deletions
diff --git a/users/drashna/callbacks.c b/users/drashna/callbacks.c
index 48b076b6ba..ffc777692e 100644
--- a/users/drashna/callbacks.c
+++ b/users/drashna/callbacks.c
@@ -70,6 +70,15 @@ void shutdown_user(void) {
__attribute__((weak)) void suspend_power_down_keymap(void) {}
void suspend_power_down_user(void) {
+ if (layer_state_is(_GAMEPAD)) {
+ layer_off(_GAMEPAD);
+ }
+ if (layer_state_is(_DIABLO)) {
+ layer_off(_DIABLO);
+ }
+ if (layer_state_is(_DIABLOII)) {
+ layer_off(_DIABLOII);
+ }
#ifdef OLED_ENABLE
oled_off();
#endif
@@ -78,12 +87,6 @@ void suspend_power_down_user(void) {
__attribute__((weak)) void suspend_wakeup_init_keymap(void) {}
void suspend_wakeup_init_user(void) {
- if (layer_state_is(_GAMEPAD)) {
- layer_off(_GAMEPAD);
- }
- if (layer_state_is(_DIABLO)) {
- layer_off(_DIABLO);
- }
suspend_wakeup_init_keymap();
}
diff --git a/users/drashna/config.h b/users/drashna/config.h
index 46cd276dd4..a6b4beb741 100644
--- a/users/drashna/config.h
+++ b/users/drashna/config.h
@@ -29,7 +29,7 @@
# 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, RPC_ID_USER_WATCHDOG_SYNC
+# define SPLIT_TRANSACTION_IDS_USER RPC_ID_USER_STATE_SYNC, RPC_ID_USER_KEYMAP_SYNC, RPC_ID_USER_CONFIG_SYNC, RPC_ID_USER_WATCHDOG_SYNC, RPC_ID_USER_KEYLOG_STR
# endif
#endif
@@ -271,3 +271,21 @@
# define C14 PAL_LINE(GPIOC, 14)
# define C15 PAL_LINE(GPIOC, 15)
#endif
+
+#ifdef OLED_DRIVER_SH1107
+# define OLED_DISPLAY_CUSTOM
+# define OLED_IC_SH1107 2
+# define OLED_DISPLAY_128X128
+# define OLED_DISPLAY_WIDTH 128
+# define OLED_DISPLAY_HEIGHT 128
+# define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH)
+# define OLED_BLOCK_TYPE uint16_t
+# define OLED_SOURCE_MAP \
+ { 0, 8, 16, 24, 32, 40, 48, 56 }
+# define OLED_TARGET_MAP \
+ { 56, 48, 40, 32, 24, 16, 8, 0 }
+# define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8)
+# define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT)
+# define OLED_COM_PINS COM_PINS_ALT
+# define OLED_IC OLED_IC_SH1107
+#endif
diff --git a/users/drashna/drashna.c b/users/drashna/drashna.c
index 9128a89bc6..6e8d4ac9bd 100644
--- a/users/drashna/drashna.c
+++ b/users/drashna/drashna.c
@@ -2,25 +2,37 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include "drashna.h"
+#ifdef __AVR__
+# include <avr/wdt.h>
+#endif
userspace_config_t userspace_config;
+/**
+ * @brief Handle registering a keycode, with optional modifer based on timed event
+ *
+ * @param code keycode to send to host
+ * @param mod_code modifier to send with code, if held for tapping term or longer
+ * @param pressed the press/release event (can use "record->event.pressed" for this)
+ * @return true exits function
+ * @return false exits function
+ */
bool mod_key_press_timer(uint16_t code, uint16_t mod_code, bool pressed) {
static uint16_t this_timer;
- if (pressed) {
- this_timer = timer_read();
- } else {
- if (timer_elapsed(this_timer) < TAPPING_TERM) {
- tap_code(code);
- } else {
- register_code(mod_code);
- tap_code(code);
- unregister_code(mod_code);
- }
- }
+ mod_key_press(code, mod_code, pressed, this_timer);
return false;
}
+/**
+ * @brief Handle registation of keycode, with optional modifier based on custom timer
+ *
+ * @param code keycode to send to host
+ * @param mod_code modifier keycode to send with code, if held for tapping term or longer
+ * @param pressed the press/release event
+ * @param this_timer custom timer to use
+ * @return true
+ * @return false
+ */
bool mod_key_press(uint16_t code, uint16_t mod_code, bool pressed, uint16_t this_timer) {
if (pressed) {
this_timer = timer_read();
@@ -36,6 +48,14 @@ bool mod_key_press(uint16_t code, uint16_t mod_code, bool pressed, uint16_t this
return false;
}
+/**
+ * @brief Performs exact match for modifier values
+ *
+ * @param value the modifer varible (get_mods/get_oneshot_mods/get_weak_mods)
+ * @param mask the modifier mask to check for
+ * @return true Has the exact modifiers specifed
+ * @return false Does not have the exact modifiers specified
+ */
bool hasAllBitsInMask(uint8_t value, uint8_t mask) {
value &= 0xF;
mask &= 0xF;
@@ -43,10 +63,62 @@ bool hasAllBitsInMask(uint8_t value, uint8_t mask) {
return (value & mask) == mask;
}
-void tap_code16_nomods(uint8_t kc) {
+/**
+ * @brief Tap keycode, with no mods
+ *
+ * @param kc keycode to use
+ */
+void tap_code16_nomods(uint16_t kc) {
uint8_t temp_mod = get_mods();
clear_mods();
clear_oneshot_mods();
tap_code16(kc);
set_mods(temp_mod);
}
+
+/**
+ * @brief Run shutdown routine and soft reboot firmware.
+ *
+ */
+
+#ifdef HAPTIC_ENABLE
+# include "haptic.h"
+#endif
+
+#ifdef AUDIO_ENABLE
+# ifndef GOODBYE_SONG
+# define GOODBYE_SONG SONG(GOODBYE_SOUND)
+# endif
+float reset_song[][2] = GOODBYE_SONG;
+#endif
+
+void software_reset(void) {
+ clear_keyboard();
+#if defined(MIDI_ENABLE) && defined(MIDI_BASIC)
+ process_midi_all_notes_off();
+#endif
+#ifdef AUDIO_ENABLE
+# ifndef NO_MUSIC_MODE
+ music_all_notes_off();
+# endif
+ uint16_t timer_start = timer_read();
+ PLAY_SONG(reset_song);
+ shutdown_user();
+ while (timer_elapsed(timer_start) < 250) wait_ms(1);
+ stop_all_notes();
+#else
+ shutdown_user();
+ wait_ms(250);
+#endif
+#ifdef HAPTIC_ENABLE
+ haptic_shutdown();
+#endif
+
+#if defined(PROTOCOL_LUFA)
+ wdt_enable(WDTO_250MS);
+#elif defined(PROTOCOL_CHIBIOS)
+# if defined(MCU_STM32) || defined(MCU_KINETIS)
+ NVIC_SystemReset();
+# endif
+#endif
+}
diff --git a/users/drashna/drashna.h b/users/drashna/drashna.h
index 5a9da16273..0bf1de84cf 100644
--- a/users/drashna/drashna.h
+++ b/users/drashna/drashna.h
@@ -78,7 +78,8 @@ enum userspace_layers {
bool mod_key_press_timer(uint16_t code, uint16_t mod_code, bool pressed);
bool mod_key_press(uint16_t code, uint16_t mod_code, bool pressed, uint16_t this_timer);
bool hasAllBitsInMask(uint8_t value, uint8_t mask);
-void tap_code16_nomods(uint8_t kc);
+void tap_code16_nomods(uint16_t kc);
+void software_reset(void);
// clang-format off
typedef union {
diff --git a/users/drashna/keyrecords/autocorrection/autocorrection.c b/users/drashna/keyrecords/autocorrection/autocorrection.c
index e561224374..c7e938a341 100644
--- a/users/drashna/keyrecords/autocorrection/autocorrection.c
+++ b/users/drashna/keyrecords/autocorrection/autocorrection.c
@@ -17,6 +17,14 @@
# error Dictionary size excees maximum size permitted
# endif
+/**
+ * @brief Process handler for autocorrect feature
+ *
+ * @param keycode Keycode registered by matrix press, per keymap
+ * @param record keyrecord_t structure
+ * @return true Continue processing keycodes, and send to host
+ * @return false Stop processing keycodes, and don't send to host
+ */
bool process_autocorrection(uint16_t keycode, keyrecord_t* record) {
static uint8_t typo_buffer[AUTOCORRECTION_MAX_LENGTH] = {KC_SPC};
static uint8_t typo_buffer_size = 1;
@@ -53,6 +61,14 @@ bool process_autocorrection(uint16_t keycode, keyrecord_t* record) {
keycode &= 0xFF;
break;
# endif
+# ifdef SWAP_HANDS_ENABLE
+ case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX:
+ if (keycode >= 0x56F0 || record->event.pressed || !record->tap.count) {
+ return true;
+ }
+ keycode &= 0xFF;
+ break;
+# endif
# ifndef NO_ACTION_ONESHOT
case QK_ONE_SHOT_MOD ... QK_ONE_SHOT_MOD_MAX:
if ((keycode & 0xF) == MOD_LSFT) {
@@ -70,7 +86,6 @@ bool process_autocorrection(uint16_t keycode, keyrecord_t* record) {
}
}
-
// Subtract buffer for Backspace key, reset for other non-alpha.
if (!(KC_A <= keycode && keycode <= KC_Z)) {
if (keycode == KC_BSPC) {
@@ -83,7 +98,7 @@ bool process_autocorrection(uint16_t keycode, keyrecord_t* record) {
// Set a word boundary if space, period, digit, etc. is pressed.
// Behave more conservatively for the enter key. Reset, so that enter
// can't be used on a word ending.
- if (keycode == KC_ENT) {
+ if (keycode == KC_ENT || (keycode == KC_MINUS && (get_mods() | get_oneshot_mods()) & MOD_MASK_SHIFT)) {
typo_buffer_size = 0;
}
keycode = KC_SPC;
diff --git a/users/drashna/keyrecords/caps_word.c b/users/drashna/keyrecords/caps_word.c
index cc9ca93b72..0c7cd6cfe5 100644
--- a/users/drashna/keyrecords/caps_word.c
+++ b/users/drashna/keyrecords/caps_word.c
@@ -10,6 +10,16 @@
bool caps_word_enabled = false;
bool caps_word_shifted = false;
+/**
+ * @brief Handler for Caps Word feature.
+ *
+ * This checks the keycodes, and applies shift to the correct keys, if and when needid.
+ *
+ * @param keycode Keycode from matrix
+ * @param record keyrecord_t data structure
+ * @return true Continue processing keycode and sent to host
+ * @return false Stop processing keycode, and do not send to host
+ */
bool process_caps_word(uint16_t keycode, keyrecord_t* record) {
if (!caps_word_enabled) {
// Pressing both shift keys at the same time enables caps word.
diff --git a/users/drashna/keyrecords/process_records.c b/users/drashna/keyrecords/process_records.c
index f49ac6ef64..012a57f7e4 100644
--- a/users/drashna/keyrecords/process_records.c
+++ b/users/drashna/keyrecords/process_records.c
@@ -18,8 +18,24 @@ bool host_driver_disabled = false;
// Defines actions tor my global custom keycodes. Defined in drashna.h file
// Then runs the _keymap's record handier if not processed here
+/**
+ * @brief Keycode handler for keymaps
+ *
+ * This handles the keycodes at the keymap level, useful for keyboard specific customization
+ */
__attribute__((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; }
__attribute__((weak)) bool process_record_secrets(uint16_t keycode, keyrecord_t *record) { return true; }
+
+/**
+ * @brief Main user keycode handler
+ *
+ * This handles all of the keycodes for the user, including calling feature handlers.
+ *
+ * @param keycode Keycode from matrix
+ * @param record keyrecord_t data structure
+ * @return true Continue processing keycode and send to host
+ * @return false Stop process keycode and do not send to host
+ */
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
// If console is enabled, it will print the matrix position and status of each key pressed
#ifdef KEYLOGGER_ENABLE
@@ -215,12 +231,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *re
return false;
case REBOOT:
if (record->event.pressed) {
- shutdown_user();
-#ifdef __AVR__
- wdt_enable(WDTO_250MS);
-#else
- NVIC_SystemReset();
-#endif
+ software_reset();
}
return false;
diff --git a/users/drashna/keyrecords/tap_dances.c b/users/drashna/keyrecords/tap_dances.c
index 63eb0c3348..a1a7439164 100644
--- a/users/drashna/keyrecords/tap_dances.c
+++ b/users/drashna/keyrecords/tap_dances.c
@@ -11,7 +11,12 @@ diablo_timer_t diablo_timer[NUM_OF_DIABLO_KEYS];
// Otherwise, you will need to hit a bunch of times, or hit the "clear" command
uint8_t diablo_times[] = {0, 1, 3, 5, 10, 30};
-// Cycle through the times for the macro, starting at 0, for disabled.
+/**
+ * @brief Main function for handling diable related tap dances.
+ *
+ * @param state Main data struction contining information about events
+ * @param user_data Local data for the dance. Allows customization to be passed on to function
+ */
void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data) {
diable_keys_t *diablo_keys = (diable_keys_t *)user_data;
// Sets the keycode based on the index
@@ -43,7 +48,10 @@ qk_tap_dance_action_t tap_dance_actions[] = {
[TD_D3_4] = ACTION_TAP_DANCE_DIABLO(3, KC_4),
};
-// Checks each of the 4 timers/keys to see if enough time has elapsed
+/**
+ * @brief Runs check to see if timer has elapsed for each dance, and sends keycodes, if it has.
+ *
+ */
void run_diablo_macro_check(void) {
for (uint8_t index = 0; index < NUM_OF_DIABLO_KEYS; index++) {
// if key_interval is 0, it's disabled, so only run if it's set. If it's set, check the timer.
diff --git a/users/drashna/keyrecords/unicode.c b/users/drashna/keyrecords/unicode.c
index 4010b9c1c6..db2058e5d1 100644
--- a/users/drashna/keyrecords/unicode.c
+++ b/users/drashna/keyrecords/unicode.c
@@ -8,6 +8,11 @@
uint16_t typing_mode;
+/**
+ * @brief Registers the unicode keystrokes based on desired unicode
+ *
+ * @param glyph Unicode character, supports up to 0x1FFFF (or higher)
+ */
void tap_unicode_glyph_nomods(uint32_t glyph) {
uint8_t temp_mod = get_mods();
clear_mods();
@@ -43,6 +48,15 @@ typedef uint32_t (*translator_function_t)(bool is_shifted, uint32_t keycode);
return ret; \
}
+/**
+ * @brief Handler function for outputting unicode.
+ *
+ * @param keycode Keycode from matrix.
+ * @param record keyrecord_t data structure
+ * @param translator translator lut for different unicode modes
+ * @return true Continue processing matrix press, and send to host
+ * @return false Replace keycode, and do not send to host
+ */
bool process_record_glyph_replacement(uint16_t keycode, keyrecord_t *record, translator_function_t translator) {
uint8_t temp_mod = get_mods();
uint8_t temp_osm = get_oneshot_mods();
@@ -182,6 +196,15 @@ bool process_record_zalgo(uint16_t keycode, keyrecord_t *record) {
return true;
}
+/**
+ * @brief Main handler for unicode input
+ *
+ * @param keycode Keycode from switch matrix
+ * @param record keyrecord_t data struture
+ * @return true Send keycode from matrix to host
+ * @return false Stop processing and do not send to host
+ */
+
bool process_record_unicode(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case UC_FLIP: // (ノಠ痊ಠ)ノ彡┻━┻
@@ -265,6 +288,10 @@ bool process_record_unicode(uint16_t keycode, keyrecord_t *record) {
return process_unicode_common(keycode, record);
}
+/**
+ * @brief Initialize the default unicode mode on firmware startu
+ *
+ */
void matrix_init_unicode(void) {
unicode_input_mode_init();
}
diff --git a/users/drashna/oled/oled_stuff.c b/users/drashna/oled/oled_stuff.c
index de84766725..eeca010de0 100644
--- a/users/drashna/oled/oled_stuff.c
+++ b/users/drashna/oled/oled_stuff.c
@@ -22,17 +22,12 @@
extern bool host_driver_disabled;
-#ifndef KEYLOGGER_LENGTH
-// # ifdef OLED_DISPLAY_128X64
-# define KEYLOGGER_LENGTH ((uint8_t)(OLED_DISPLAY_HEIGHT / OLED_FONT_WIDTH))
-// # else
-// # define KEYLOGGER_LENGTH (uint8_t *(OLED_DISPLAY_WIDTH / OLED_FONT_HEIGHT))
-// # endif
-#endif
+uint32_t oled_timer = 0;
+char keylog_str[OLED_KEYLOGGER_LENGTH] = {0};
+static uint16_t log_timer = 0;
+static const char PROGMEM display_border[3] = {0x0, 0xFF, 0x0};
-uint32_t oled_timer = 0;
-static char keylog_str[KEYLOGGER_LENGTH + 1] = {0};
-static uint16_t log_timer = 0;
+deferred_token kittoken;
// clang-format off
static const char PROGMEM code_to_name[256] = {
@@ -56,10 +51,16 @@ static const char PROGMEM code_to_name[256] = {
};
// clang-format on
+/**
+ * @brief parses pressed keycodes and saves to buffer
+ *
+ * @param keycode Keycode pressed from switch matrix
+ * @param record keyrecord_t data structure
+ */
void add_keylog(uint16_t keycode, keyrecord_t *record) {
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)) {
if (((keycode & 0xFF) == KC_BSPC) && mod_config(get_mods() | get_oneshot_mods()) & MOD_MASK_CTRL) {
- memset(keylog_str, ' ', sizeof(keylog_str) - 1);
+ memset(keylog_str, ' ', OLED_KEYLOGGER_LENGTH);
return;
}
if (record->tap.count) {
@@ -72,23 +73,29 @@ void add_keylog(uint16_t keycode, keyrecord_t *record) {
return;
}
- for (uint8_t i = 1; i < KEYLOGGER_LENGTH; i++) {
- keylog_str[i - 1] = keylog_str[i];
- }
+ memmove(keylog_str, keylog_str + 1, OLED_KEYLOGGER_LENGTH - 1);
if (keycode < (sizeof(code_to_name) / sizeof(char))) {
- keylog_str[(KEYLOGGER_LENGTH - 1)] = pgm_read_byte(&code_to_name[keycode]);
+ keylog_str[(OLED_KEYLOGGER_LENGTH - 1)] = pgm_read_byte(&code_to_name[keycode]);
}
log_timer = timer_read();
}
+/**
+ * @brief Keycode handler for oled display.
+ *
+ * This adds pressed keys to buffer, but also resets the oled timer
+ *
+ * @param keycode Keycode from matrix
+ * @param record keyrecord data struture
+ * @return true
+ * @return false
+ */
bool process_record_user_oled(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
-#ifdef OLED_ENABLE
oled_timer = timer_read32();
add_keylog(keycode, record);
-#endif
}
return true;
}
@@ -99,12 +106,29 @@ void update_log(void) {
}
}
+/**
+ * @brief Renders keylogger buffer to oled
+ *
+ */
void render_keylogger_status(void) {
+#ifdef OLED_DISPLAY_VERBOSE
+ oled_set_cursor(1, 7);
+#endif
oled_write_P(PSTR(OLED_RENDER_KEYLOGGER), false);
oled_write(keylog_str, false);
+#ifdef OLED_DISPLAY_VERBOSE
+ oled_advance_page(true);
+#endif
}
+/**
+ * @brief Renders default layer state (aka layout) to oled
+ *
+ */
void render_default_layer_state(void) {
+#ifdef OLED_DISPLAY_VERBOSE
+ oled_set_cursor(5, 2);
+#endif
oled_write_P(PSTR(OLED_RENDER_LAYOUT_NAME), false);
switch (get_highest_layer(default_layer_state)) {
case _QWERTY:
@@ -120,46 +144,150 @@ void render_default_layer_state(void) {
oled_write_P(PSTR(OLED_RENDER_LAYOUT_DVORAK), false);
break;
}
-#ifdef OLED_DISPLAY_128X64
+#ifdef OLED_DISPLAY_VERBOSE
oled_advance_page(true);
#endif
}
+/**
+ * @brief Renders the active layers to the OLED
+ *
+ */
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
+#ifdef OLED_DISPLAY_VERBOSE
+ static const char PROGMEM tri_layer_image[4][3][18] = {
+ {
+ {
+ 0x80, 0x80, 0x40, 0x40, 0x20, 0x20,
+ 0x10, 0x10, 0x08, 0x08, 0x10, 0x10,
+ 0x20, 0x20, 0x40, 0x40, 0x80, 0x80
+ },
+ {
+ 0x88, 0x88, 0x5D, 0x5D, 0x3E, 0x3E,
+ 0x7C, 0x7C, 0xF8, 0xF8, 0x7C, 0x7C,
+ 0x3E, 0x3E, 0x5D, 0x5D, 0x88, 0x88
+ },
+ {
+ 0x00, 0x00, 0x01, 0x01, 0x02, 0x02,
+ 0x04, 0x04, 0x08, 0x08, 0x04, 0x04,
+ 0x02, 0x02, 0x01, 0x01, 0x00, 0x00
+ }
+ },
+ {
+ {
+ 0x80, 0x80, 0xC0, 0xC0, 0xE0, 0xE0,
+ 0xF0, 0xF0, 0xF8, 0xF8, 0xF0, 0xF0,
+ 0xE0, 0xE0, 0xC0, 0xC0, 0x80, 0x80
+ },
+ {
+ 0x88, 0x88, 0x55, 0x55, 0x23, 0x23,
+ 0x47, 0x47, 0x8F, 0x8F, 0x47, 0x47,
+ 0x23, 0x23, 0x55, 0x55, 0x88, 0x88
+ },
+ {
+ 0x00, 0x00, 0x01, 0x01, 0x02, 0x02,
+ 0x04, 0x04, 0x08, 0x08, 0x04, 0x04,
+ 0x02, 0x02, 0x01, 0x01, 0x00, 0x00
+ }
+ },
+ {
+ {
+ 0x80, 0x80, 0x40, 0x40, 0x20, 0x20,
+ 0x10, 0x10, 0x08, 0x08, 0x10, 0x10,
+ 0x20, 0x20, 0x40, 0x40, 0x80, 0x80
+ },
+ {
+ 0x88, 0x88, 0xD5, 0xD5, 0xE2, 0xE2,
+ 0xC4, 0xC4, 0x88, 0x88, 0xC4, 0xC4,
+ 0xE2, 0xE2, 0xD5, 0xD5, 0x88, 0x88
+ },
+ {
+ 0x00, 0x00, 0x01, 0x01, 0x03, 0x03,
+ 0x07, 0x07, 0x0F, 0x0F, 0x07, 0x07,
+ 0x03, 0x03, 0x01, 0x01, 0x00, 0x00
+ }
+ },
+ {
+ {
+ 0x80, 0x80, 0x40, 0xC0, 0x60, 0xA0,
+ 0x50, 0xB0, 0x58, 0xA8, 0x50, 0xB0,
+ 0x60, 0xA0, 0x40, 0xC0, 0x80, 0x80
+ },
+ {
+ 0x88, 0x88, 0x5D, 0xD5, 0x6B, 0xB6,
+ 0x6D, 0xD6, 0xAD, 0xDA, 0x6D, 0xD6,
+ 0x6B, 0xB6, 0x5D, 0xD5, 0x88, 0x88
+ },
+ {
+ 0x00, 0x00, 0x01, 0x01, 0x03, 0x02,
+ 0x05, 0x06, 0x0D, 0x0A, 0x05, 0x06,
+ 0x03, 0x02, 0x01, 0x01, 0x00, 0x00
+ }
+ }
+ };
+
+ uint8_t layer_is = 0;
+ if (layer_state_is(_ADJUST)) {
+ layer_is = 3;
+ } else if (layer_state_is(_RAISE)) {
+ layer_is = 1;
+ } else if (layer_state_is(_LOWER)) {
+ layer_is = 2;
+ }
+
+ oled_set_cursor(1, 2);
+ oled_write_raw_P(tri_layer_image[layer_is][0], sizeof(tri_layer_image[0][0]));
+ oled_set_cursor(5, 3);
+ oled_write_P(PSTR("Diablo2"), layer_state_is(_DIABLOII));
oled_write_P(PSTR(" "), false);
-#endif
- oled_write_P(PSTR(OLED_RENDER_LAYER_RAISE), layer_state_is(_RAISE));
-#ifdef OLED_DISPLAY_128X64
+ oled_write_P(PSTR("Diablo3"), layer_state_is(_DIABLO));
oled_advance_page(true);
- oled_write_P(PSTR(" "), false);
+
+ oled_set_cursor(1, 3);
+ oled_write_raw_P(tri_layer_image[layer_is][1], sizeof(tri_layer_image[0][0]));
+ oled_set_cursor(5, 4);
oled_write_P(PSTR("GamePad"), layer_state_is(_GAMEPAD));
oled_write_P(PSTR(" "), false);
- oled_write_P(PSTR("Diablo"), layer_state_is(_DIABLO));
- oled_write_P(PSTR(" "), false);
oled_write_P(PSTR("Mouse"), layer_state_is(_MOUSE));
+ oled_advance_page(true);
+
+ oled_set_cursor(1, 4);
+ oled_write_raw_P(tri_layer_image[layer_is][2], sizeof(tri_layer_image[0][0]));
+
+#else
+ oled_write_P(PSTR(OLED_RENDER_LAYER_NAME), false);
+ oled_write_P(PSTR(OLED_RENDER_LAYER_LOWER), layer_state_is(_LOWER));
+ oled_write_P(PSTR(OLED_RENDER_LAYER_RAISE), layer_state_is(_RAISE));
+ oled_advance_page(true);
#endif
}
+/**
+ * @brief Renders the current lock status to oled
+ *
+ * @param led_usb_state Current keyboard led state
+ */
void render_keylock_status(uint8_t led_usb_state) {
+#if defined(OLED_DISPLAY_VERBOSE)
+ oled_set_cursor(1, 6);
+#endif
oled_write_P(PSTR(OLED_RENDER_LOCK_NAME), false);
-#if !defined(OLED_DISPLAY_128X64)
+#if !defined(OLED_DISPLAY_VERBOSE)
oled_write_P(PSTR(" "), false);
#endif
oled_write_P(PSTR(OLED_RENDER_LOCK_NUML), led_usb_state & (1 << USB_LED_NUM_LOCK));
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR(OLED_RENDER_LOCK_CAPS), led_usb_state & (1 << USB_LED_CAPS_LOCK));
-#if defined(OLED_DISPLAY_128X64)
+#if defined(OLED_DISPLAY_VERBOSE)
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR(OLED_RENDER_LOCK_SCLK), led_usb_state & (1 << USB_LED_SCROLL_LOCK));
#endif
}
+/**
+ * @brief Renders the matrix scan rate to the host system
+ *
+ */
void render_matrix_scan_rate(void) {
#ifdef DEBUG_MATRIX_SCAN_RATE
oled_write_P(PSTR("MS:"), false);
@@ -167,10 +295,18 @@ void render_matrix_scan_rate(void) {
#endif
}
+/**
+ * @brief Renders the modifier state
+ *
+ * @param modifiers Modifiers to check against (real, weak, onesheot, etc;)
+ */
void render_mod_status(uint8_t modifiers) {
static const char PROGMEM mod_status[5][3] = {{0xE8, 0xE9, 0}, {0xE4, 0xE5, 0}, {0xE6, 0xE7, 0}, {0xEA, 0xEB, 0}, {0xEC, 0xED, 0}};
+#if defined(OLED_DISPLAY_VERBOSE)
+ oled_set_cursor(1, 5);
+#endif
oled_write_P(PSTR(OLED_RENDER_MODS_NAME), false);
-#if defined(OLED_DISPLAY_128X64)
+#if defined(OLED_DISPLAY_VERBOSE)
oled_write_P(mod_status[0], (modifiers & MOD_BIT(KC_LSHIFT)));
oled_write_P(mod_status[!keymap_config.swap_lctl_lgui ? 3 : 4], (modifiers & MOD_BIT(KC_LGUI)));
oled_write_P(mod_status[2], (modifiers & MOD_BIT(KC_LALT)));
@@ -200,26 +336,27 @@ void render_bootmagic_status(void) {
};
bool is_bootmagic_on;
-#ifdef OLED_DISPLAY_128X64
+#ifdef OLED_DISPLAY_VERBOSE
+ oled_set_cursor(7, 4);
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
+#ifdef OLED_DISPLAY_VERBOSE
if (keymap_config.swap_lctl_lgui)
#else
+ oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NAME), false);
oled_write_P(PSTR(" "), false);
#endif
{
oled_write_P(logo[1][0], is_bootmagic_on);
-#ifdef OLED_DISPLAY_128X64
+#ifdef OLED_DISPLAY_VERBOSE
} else {
#endif
oled_write_P(logo[0][0], !is_bootmagic_on);
}
-#ifndef OLED_DISPLAY_128X64
+#ifndef OLED_DISPLAY_VERBOSE
oled_write_P(PSTR(" "), false);
oled_write_P(logo[1][1], is_bootmagic_on);
oled_write_P(logo[0][1], !is_bootmagic_on);
@@ -232,10 +369,8 @@ void render_bootmagic_status(void) {
#else
oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NOGUI), keymap_config.no_gui);
#endif
-#ifdef OLED_DISPLAY_128X64
- oled_advance_page(true);
- oled_write_P(PSTR("Magic"), false);
- oled_write_P(PSTR(" "), false);
+#ifdef OLED_DISPLAY_VERBOSE
+ oled_set_cursor(7, 5);
if (keymap_config.swap_lctl_lgui) {
oled_write_P(logo[1][1], is_bootmagic_on);
} else {
@@ -248,9 +383,6 @@ void render_bootmagic_status(void) {
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_SWAP), swap_hands);
#endif
-#ifdef OLED_DISPLAY_128X64
- oled_advance_page(true);
-#endif
}
#if defined(POINTING_DEVICE_ENABLE)
@@ -269,13 +401,16 @@ void render_user_status(void) {
is_clicky_on = is_clicky_on();
# endif
#endif
+#if defined(OLED_DISPLAY_VERBOSE)
+ oled_set_cursor(1, 6);
+#endif
oled_write_P(PSTR(OLED_RENDER_USER_NAME), false);
-#if !defined(OLED_DISPLAY_128X64)
+#if !defined(OLED_DISPLAY_VERBOSE)
oled_write_P(PSTR(" "), false);
#endif
#if defined(RGB_MATRIX_ENABLE)
oled_write_P(PSTR(OLED_RENDER_USER_ANIM), userspace_config.rgb_matrix_idle_anim);
-# if !defined(OLED_DISPLAY_128X64)
+# if !defined(OLED_DISPLAY_VERBOSE)
oled_write_P(PSTR(" "), false);
# endif
#elif defined(POINTING_DEVICE_ENABLE)
@@ -289,7 +424,7 @@ void render_user_status(void) {
# ifdef AUDIO_CLICKY
static const char PROGMEM audio_clicky_status[2][3] = {{0xF4, 0xF5, 0}, {0xF6, 0xF7, 0}};
oled_write_P(audio_clicky_status[is_clicky_on && is_audio_on], false);
-# if !defined(OLED_DISPLAY_128X64)
+# if !defined(OLED_DISPLAY_VERBOSE)
oled_write_P(PSTR(" "), false);
# endif
# endif
@@ -304,30 +439,20 @@ void render_user_status(void) {
oled_write_P(uc_mod_status[get_unicode_input_mode() == UC_MAC], false);
#endif
if (userspace_config.nuke_switch) {
-#if !defined(OLED_DISPLAY_128X64)
+#if !defined(OLED_DISPLAY_VERBOSE)
oled_write_P(PSTR(" "), false);
#endif
static const char PROGMEM nukem_good[2] = {0xFA, 0};
oled_write_P(nukem_good, false);
-#if !defined(OLED_DISPLAY_128X64)
+#if !defined(OLED_DISPLAY_VERBOSE)
oled_advance_page(true);
#endif
}
-#if defined(OLED_DISPLAY_128X64)
+#if defined(OLED_DISPLAY_VERBOSE)
oled_advance_page(true);
#endif
}
-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_wpm(uint8_t padding) {
#ifdef WPM_ENABLE
@@ -356,49 +481,389 @@ void render_pointing_dpi_status(uint8_t padding) {
#endif
__attribute__((weak)) void oled_driver_render_logo_right(void) {
-#if defined(OLED_DISPLAY_128X64)
- oled_driver_render_logo();
+#if defined(OLED_DISPLAY_VERBOSE)
+ oled_set_cursor(0, 2);
render_default_layer_state();
- oled_set_cursor(0, 4);
#else
render_default_layer_state();
#endif
}
-__attribute__((weak)) void oled_driver_render_logo_left(void) {
-#if defined(OLED_DISPLAY_128X64)
- oled_driver_render_logo();
-# ifdef DEBUG_MATRIX_SCAN_RATE
+// WPM-responsive animation stuff here
+#define OLED_SLEEP_FRAMES 2
+#define OLED_SLEEP_SPEED 10 // below this wpm value your animation will idle
+
+#define OLED_WAKE_FRAMES 2 // uncomment if >1
+#define OLED_WAKE_SPEED OLED_SLEEP_SPEED // below this wpm value your animation will idle
+
+#define OLED_KAKI_FRAMES 3
+#define OLED_KAKI_SPEED 40 // above this wpm value typing animation to triggere
+
+#define OLED_RTOGI_FRAMES 2
+//#define OLED_LTOGI_FRAMES 2
+
+//#define ANIM_FRAME_DURATION 500 // how long each frame lasts in ms
+// #define SLEEP_TIMER 60000 // should sleep after this period of 0 wpm, needs fixing
+#define OLED_ANIM_SIZE 32 // number of bytes in array, minimize for adequate firmware size, max is 1024
+#define OLED_ANIM_ROWS 4
+#define OLED_ANIM_MAX_FRAMES 3
+#if (OLED_SLEEP_FRAMES > OLED_ANIM_MAX_FRAMES) || (OLED_WAKE_FRAMES > OLED_ANIM_MAX_FRAMES) || (OLED_KAKI_FRAMES > OLED_ANIM_MAX_FRAMES) || (OLED_RTOGI_FRAMES > OLED_ANIM_MAX_FRAMES)
+# error frame size too large
+#endif
+
+static uint8_t animation_frame = 0;
+static uint8_t animation_type = 0;
+
+void render_kitty(void) {
+ // Images credit j-inc(/James Incandenza) and pixelbenny.
+ // Credit to obosob for initial animation approach.
+ // heavily modified by drashna because he's a glutton for punishment
+
+ // clang-format off
+ static const char PROGMEM animation[4][OLED_ANIM_MAX_FRAMES][OLED_ANIM_ROWS][OLED_ANIM_SIZE] = {
+ // sleep frames
+ {
+ {
+ {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08,
+ 0xa8, 0x48, 0xa8, 0x18, 0x08, 0x00, 0x00, 0x00,
+ 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ },
+ {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x80,
+ 0x44, 0x84, 0x06, 0x05, 0x04, 0x80, 0x40, 0x20,
+ 0x10, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
<