summaryrefslogtreecommitdiffstats
path: root/users/drashna
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@drashna.net>2023-02-28 11:14:48 -0800
committerGitHub <noreply@github.com>2023-02-28 11:14:48 -0800
commit051401175d98e777a6633445a0275b54ed36e97a (patch)
tree325d717dfbfb12e4cb45c02089602f256ddc36d6 /users/drashna
parent05631b276d557824518cdb0c7d5d78c8f118891c (diff)
[Keymap] Drashna updates for 0.20.0 (#19960)
Diffstat (limited to 'users/drashna')
-rw-r--r--users/drashna/audio_config.h33
-rw-r--r--users/drashna/callbacks.c127
-rw-r--r--users/drashna/config.h44
-rw-r--r--users/drashna/drashna.c51
-rw-r--r--users/drashna/drashna.h6
-rw-r--r--users/drashna/keyrecords/capwords.md36
-rw-r--r--users/drashna/keyrecords/process_records.c35
-rw-r--r--users/drashna/keyrecords/process_records.h9
-rw-r--r--users/drashna/keyrecords/readme.md2
-rw-r--r--users/drashna/oled/oled_stuff.c58
-rw-r--r--users/drashna/oled/oled_stuff.h9
-rw-r--r--users/drashna/oled/sh110x.c113
-rw-r--r--users/drashna/pointing/pointing.c11
-rw-r--r--users/drashna/pointing/pointing_config.h6
-rw-r--r--users/drashna/post_config.h2
-rw-r--r--users/drashna/rgb/rgb_matrix_stuff.c5
-rw-r--r--users/drashna/rgb/rgb_matrix_stuff.h2
-rw-r--r--users/drashna/rules.mk5
-rw-r--r--users/drashna/split/split_config.h12
-rw-r--r--users/drashna/split/transport_sync.c2
-rw-r--r--users/drashna/split/transport_sync.h2
21 files changed, 332 insertions, 238 deletions
diff --git a/users/drashna/audio_config.h b/users/drashna/audio_config.h
new file mode 100644
index 0000000000..21fe27ee6b
--- /dev/null
+++ b/users/drashna/audio_config.h
@@ -0,0 +1,33 @@
+// Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#define AUDIO_CLICKY
+#define AUDIO_CLICKY_FREQ_RANDOMNESS 1.5f
+
+#if __has_include("user_song_list.h")
+# include "user_song_list.h"
+#endif
+
+#ifdef USER_SONG_LIST
+# define STARTUP_SONG SONG(RICK_ROLL)
+# define GOODBYE_SONG SONG(SONIC_RING)
+# define DEFAULT_LAYER_SONGS \
+ { SONG(QWERTY_SOUND), SONG(COLEMAK_SOUND), SONG(DVORAK_SOUND), SONG(OVERWATCH_THEME) }
+# define UNICODE_SONG_MAC SONG(MARIO_THEME)
+# define UNICODE_SONG_LNX SONG(MARIO_POWERUP)
+# define UNICODE_SONG_WIN SONG(MARIO_ONEUP)
+# define UNICODE_SONG_BSD SONG(RICK_ROLL)
+# define UNICODE_SONG_WINC SONG(RICK_ROLL)
+#else
+# define STARTUP_SONG SONG(STARTUP_SOUND)
+# define GOODBYE_SONG SONG(GOODBYE_SOUND)
+# define DEFAULT_LAYER_SONGS \
+ { SONG(QWERTY_SOUND), SONG(COLEMAK_SOUND), SONG(DVORAK_SOUND), SONG(WORKMAN_SOUND) }
+# define UNICODE_SONG_MAC SONG(QWERTY_SOUND)
+# define UNICODE_SONG_LNX SONG(COLEMAK_SOUND)
+# define UNICODE_SONG_WIN SONG(DVORAK_SOUND)
+# define UNICODE_SONG_BSD SONG(WORKMAN_SOUND)
+# define UNICODE_SONG_WINC SONG(PLOVER_GOODBYE_SOUND)
+#endif
diff --git a/users/drashna/callbacks.c b/users/drashna/callbacks.c
index c2f1156cee..568f56c8d1 100644
--- a/users/drashna/callbacks.c
+++ b/users/drashna/callbacks.c
@@ -3,9 +3,8 @@
#include "drashna.h"
-
#ifdef I2C_SCANNER_ENABLE
-void matrix_scan_i2c(void);
+void housekeeping_task_i2c_scanner(void);
void keyboard_post_init_i2c(void);
#endif
@@ -21,6 +20,64 @@ void keyboard_pre_init_user(void) {
// Call user matrix init, set default RGB colors and then
// call the keymap's init function
+#ifdef CUSTOM_QUANTUM_PAINTER_ENABLE
+void keyboard_post_init_qp(void);
+#endif
+
+#ifdef OS_DETECTION_ENABLE
+os_variant_t os_type;
+
+uint32_t startup_exec(uint32_t trigger_time, void *cb_arg) {
+ /* do something */
+
+ if (is_keyboard_master()) {
+ os_type = detected_host_os();
+ if (os_type) {
+ bool is_mac = (os_type == OS_MACOS) || (os_type == OS_IOS);
+ keymap_config.swap_lctl_lgui = keymap_config.swap_rctl_rgui = is_mac;
+# ifdef UNICODE_COMMON_ENABLE
+ uint8_t mode = is_mac ? UNICODE_MODE_MACOS : UNICODE_MODE_WINCOMPOSE;
+ if (mode != get_unicode_input_mode()) {
+ set_unicode_input_mode(mode);
+ }
+# endif
+ switch (os_type) {
+ case OS_UNSURE:
+ xprintf("unknown OS Detected\n");
+ break;
+ case OS_LINUX:
+ xprintf("Linux Detected\n");
+ break;
+ case OS_WINDOWS:
+ xprintf("Windows Detected\n");
+ break;
+# if 0
+ case OS_WINDOWS_UNSURE:
+ xprintf("Windows? Detected\n");
+ break;
+# endif
+ case OS_MACOS:
+ xprintf("MacOS Detected\n");
+ break;
+ case OS_IOS:
+ xprintf("iOS Detected\n");
+ break;
+# if 0
+ case OS_PS5:
+ xprintf("PlayStation 5 Detected\n");
+ break;
+ case OS_HANDHELD:
+ xprintf("Nintend Switch/Quest 2 Detected\n");
+ break;
+# endif
+ }
+ }
+ }
+
+ return os_type ? 0 : 500;
+}
+#endif
+
__attribute__((weak)) void keyboard_post_init_keymap(void) {}
void keyboard_post_init_user(void) {
#if defined(CUSTOM_RGBLIGHT)
@@ -47,6 +104,10 @@ void keyboard_post_init_user(void) {
PORTB &= ~(1 << 0);
#endif
+#ifdef OS_DETECTION_ENABLE
+ defer_exec(100, startup_exec, NULL);
+#endif
+
keyboard_post_init_keymap();
}
@@ -102,25 +163,6 @@ void suspend_wakeup_init_user(void) {
// scan function
__attribute__((weak)) void matrix_scan_keymap(void) {}
void matrix_scan_user(void) {
- static bool has_ran_yet;
- if (!has_ran_yet) {
- has_ran_yet = true;
- startup_user();
- }
-
-#ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
- run_diablo_macro_check();
-#endif // TAP_DANCE_ENABLE
-#if defined(CUSTOM_RGB_MATRIX)
- matrix_scan_rgb_matrix();
-#endif
-#ifdef I2C_SCANNER_ENABLE
- matrix_scan_i2c();
-#endif
-#ifdef CUSTOM_OLED_DRIVER
- matrix_scan_oled();
-#endif
-
matrix_scan_keymap();
}
@@ -134,10 +176,6 @@ __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;
- }
-
state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST);
#if defined(CUSTOM_POINTING_DEVICE)
state = layer_state_set_pointing(state);
@@ -145,18 +183,33 @@ layer_state_t layer_state_set_user(layer_state_t state) {
#if defined(CUSTOM_RGBLIGHT)
state = layer_state_set_rgb_light(state);
#endif // CUSTOM_RGBLIGHT
-#if defined(AUDIO_ENABLE) && !defined(__arm__)
+#if defined(AUDIO_ENABLE)
static bool is_gamepad_on = false;
if (layer_state_cmp(state, _GAMEPAD) != is_gamepad_on) {
- is_gamepad_on = layer_state_cmp(state, _GAMEPAD);
+ static bool is_click_on = false;
+ is_gamepad_on = layer_state_cmp(state, _GAMEPAD);
if (is_gamepad_on) {
+ is_click_on = is_clicky_on();
+ if (is_click_on) {
+ clicky_off();
+ }
PLAY_LOOP(doom_song);
} else {
+ if (is_click_on) {
+ clicky_on();
+ }
stop_all_notes();
}
}
#endif
state = layer_state_set_keymap(state);
+
+#ifdef CONSOLE_ENABLE
+ char layer_buffer[16 + 5];
+ format_layer_bitmap_string(layer_buffer, state, default_layer_state);
+ dprintf("layer state: %s\n", layer_buffer);
+#endif
+
return state;
}
@@ -227,9 +280,27 @@ void matrix_slave_scan_user(void) {
#endif
__attribute__((weak)) void housekeeping_task_keymap(void) {}
-void housekeeping_task_user(void) {
+void housekeeping_task_user(void) {
+ static bool has_ran_yet;
+ if (!has_ran_yet) {
+ has_ran_yet = true;
+ startup_user();
+ }
+#ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
+ run_diablo_macro_check();
+#endif // TAP_DANCE_ENABLE
+#if defined(CUSTOM_RGB_MATRIX)
+ housekeeping_task_rgb_matrix();
+#endif
+#ifdef I2C_SCANNER_ENABLE
+ housekeeping_task_i2c_scanner();
+#endif
+#ifdef CUSTOM_OLED_DRIVER
+ housekeeping_task_oled();
+#endif
#if defined(SPLIT_KEYBOARD) && defined(SPLIT_TRANSACTION_IDS_USER)
housekeeping_task_transport_sync();
#endif
+
housekeeping_task_keymap();
}
diff --git a/users/drashna/config.h b/users/drashna/config.h
index 9edbfff56b..465ea63ee2 100644
--- a/users/drashna/config.h
+++ b/users/drashna/config.h
@@ -11,7 +11,6 @@
#endif
#define IS_COMMAND() (((get_mods() | get_oneshot_mods()) & MOD_MASK_SHIFT) == MOD_MASK_SHIFT)
-
#if defined(SPLIT_KEYBOARD)
# include "split/split_config.h"
#endif
@@ -27,51 +26,26 @@
# include "oled/oled_config.h"
#endif
+#ifdef POINTING_DEVICE_ENABLE
+# include "pointing/pointing_config.h"
+#endif // POINTING_DEVICE_ENABLE
+
+#ifdef AUDIO_ENABLE
+# include "audio_config.h"
+#endif // AUDIO_ENABLE
+
#if defined(WPM_ENABLE)
// # define WPM_LAUNCH_CONTROL
-// # define WPM_ALLOW_COUNT_REGRESSOIN
// # define WPM_UNFILTERED
+# define WPM_ALLOW_COUNT_REGRESSION
# define WPM_SAMPLE_SECONDS 10
# define WPM_SAMPLE_PERIODS 50
# define WPM_ESTIMATED_WORD_SIZE 5
#endif
-#ifdef AUDIO_ENABLE
-# define AUDIO_CLICKY
-# define AUDIO_CLICKY_FREQ_RANDOMNESS 1.5f
-
-# ifdef USER_SONG_LIST
-# define STARTUP_SONG SONG(RICK_ROLL)
-# define GOODBYE_SONG SONG(SONIC_RING)
-# define DEFAULT_LAYER_SONGS \
- { SONG(QWERTY_SOUND), SONG(COLEMAK_SOUND), SONG(DVORAK_SOUND), SONG(OVERWATCH_THEME) }
-# define UNICODE_SONG_MAC SONG(MARIO_THEME)
-# define UNICODE_SONG_LNX SONG(MARIO_POWERUP)
-# define UNICODE_SONG_WIN SONG(MARIO_ONEUP)
-# define UNICODE_SONG_BSD SONG(RICK_ROLL)
-# define UNICODE_SONG_WINC SONG(RICK_ROLL)
-# else
-# define STARTUP_SONG SONG(STARTUP_SOUND)
-# define GOODBYE_SONG SONG(GOODBYE_SOUND)
-# define DEFAULT_LAYER_SONGS \
- { SONG(QWERTY_SOUND), SONG(COLEMAK_SOUND), SONG(DVORAK_SOUND), SONG(WORKMAN_SOUND) }
-# define UNICODE_SONG_MAC SONG(QWERTY_SOUND)
-# define UNICODE_SONG_LNX SONG(COLEMAK_SOUND)
-# define UNICODE_SONG_WIN SONG(DVORAK_SOUND)
-# define UNICODE_SONG_BSD SONG(WORKMAN_SOUND)
-# define UNICODE_SONG_WINC SONG(PLOVER_GOODBYE_SOUND)
-# endif
-#endif // !AUDIO_ENABLE
#define UNICODE_SELECTED_MODES UNICODE_MODE_WINCOMPOSE, UNICODE_MODE_MACOS
-// #define WPM_ESTIMATED_WORD_SIZE 5
-#define WPM_ALLOW_COUNT_REGRESSION
-// #define WPM_UNFILTERED
-// #define WPM_SAMPLE_SECONDS 5
-// #define WPM_SAMPLE_PERIODS 50
-// #define WPM_LAUNCH_CONTROL
-
#ifndef ONESHOT_TAP_TOGGLE
# define ONESHOT_TAP_TOGGLE 2
#endif // !ONESHOT_TAP_TOGGLE
diff --git a/users/drashna/drashna.c b/users/drashna/drashna.c
index 283e82d13d..259810c70f 100644
--- a/users/drashna/drashna.c
+++ b/users/drashna/drashna.c
@@ -117,7 +117,7 @@ void do_scan(void) {
uint16_t scan_timer = 0;
-void matrix_scan_i2c(void) {
+void housekeeping_task_i2c_scanner(void) {
if (timer_elapsed(scan_timer) > 5000) {
do_scan();
scan_timer = timer_read();
@@ -139,7 +139,7 @@ float autocorrect_song[][2] = SONG(PLOVER_GOODBYE_SOUND);
# endif
# endif
-bool apply_autocorrect(uint8_t backspaces, const char *str) {
+bool apply_autocorrect(uint8_t backspaces, const char* str) {
if (layer_state_is(_GAMEPAD)) {
return false;
}
@@ -153,7 +153,31 @@ bool apply_autocorrect(uint8_t backspaces, const char *str) {
}
#endif
-#if defined(CAPS_WORD_ENABLE) && !defined(NO_ACTION_ONESHOT)
+#if defined(CAPS_WORD_ENABLE)
+bool caps_word_press_user(uint16_t keycode) {
+ switch (keycode) {
+ // Keycodes that continue Caps Word, with shift applied.
+ case KC_MINS:
+ if (!keymap_config.swap_lctl_lgui) {
+ return true;
+ }
+ case KC_A ... KC_Z:
+ add_weak_mods(MOD_BIT(KC_LSFT)); // Apply shift to next key.
+ return true;
+
+ // Keycodes that continue Caps Word, without shifting.
+ case KC_1 ... KC_0:
+ case KC_BSPC:
+ case KC_DEL:
+ case KC_UNDS:
+ return true;
+
+ default:
+ return false; // Deactivate Caps Word.
+ }
+}
+
+# if !defined(NO_ACTION_ONESHOT)
void oneshot_locked_mods_changed_user(uint8_t mods) {
if (mods & MOD_MASK_SHIFT) {
del_mods(MOD_MASK_SHIFT);
@@ -161,4 +185,25 @@ void oneshot_locked_mods_changed_user(uint8_t mods) {
caps_word_on();
}
}
+# endif
#endif
+
+void format_layer_bitmap_string(char* buffer, layer_state_t state, layer_state_t default_state) {
+ for (int i = 0; i < 16; i++) {
+ if (i == 0 || i == 4 || i == 8 || i == 12) {
+ *buffer = ' ';
+ ++buffer;
+ }
+
+ uint8_t layer = i;
+ if ((default_state & ((layer_state_t)1 << layer)) != 0) {
+ *buffer = 'D';
+ } else if ((state & ((layer_state_t)1 << layer)) != 0) {
+ *buffer = '1';
+ } else {
+ *buffer = '_';
+ }
+ ++buffer;
+ }
+ *buffer = 0;
+}
diff --git a/users/drashna/drashna.h b/users/drashna/drashna.h
index 16d7cda638..4e2a4d5acb 100644
--- a/users/drashna/drashna.h
+++ b/users/drashna/drashna.h
@@ -11,7 +11,7 @@
#ifdef TAP_DANCE_ENABLE
# include "keyrecords/tap_dances.h"
-#endif // TAP_DANCE_ENABLE
+#endif // TAP_DANCE_ENABLE
#if defined(RGBLIGHT_ENABLE)
# include "rgb/rgb_stuff.h"
#endif
@@ -27,6 +27,9 @@
#ifdef POINTING_DEVICE_ENABLE
# include "pointing/pointing.h"
#endif
+#ifdef OS_DETECTION_ENABLE
+# include "os_detection.h"
+#endif
/* Define layer names */
enum userspace_layers {
@@ -79,6 +82,7 @@ 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(uint16_t kc);
+void format_layer_bitmap_string(char* buffer, layer_state_t state, layer_state_t default_state);
// clang-format off
typedef union {
diff --git a/users/drashna/keyrecords/capwords.md b/users/drashna/keyrecords/capwords.md
deleted file mode 100644
index 1ca01ed853..0000000000
--- a/users/drashna/keyrecords/capwords.md
+++ /dev/null
@@ -1,36 +0,0 @@
-# Cap Words
-
-This is taken from [Pascal Getreuer's implemenation](https://getreuer.info/posts/keyboards/caps-word/index.html), with a number of modifications.
-
-To enable Caps Word, add `CAPS_WORD_ENABLE = yes` to your `rules.mk`.
-
-This is mostly a reproduction of Pascal's docs:
-
-## Overview
-
-All-caps identifiers like “MOD_MASK_ALT” are awkward to type.
-
-Caps Lock would be the standard solution to this problem, but it is awkward: it needs a dedicated key to toggle it (an imposition on smaller keyboards), and we need to remember to toggle it off after typing the word. Or with normal shifting, we either perform finger gymnastics or need to stop typing in the middle of the word to release shift with one hand to switch to holding shift with the other hand. In my experience, this is a nuisance especially if your shift keys are mod-taps, as in home row mods.
-
-Caps Word, implemented here, is a modern alternative to Caps Lock:
-
-* Caps Word is activated by pressing the left and right shift keys at the same time. This way you don’t need a dedicated key for using Caps Word.
-* Caps Word automatically disables itself at the end of the word.
-
-**Compatibility**: I’ve tested that this implementation works with one-shot mods and Space Cadet Shift, and it predictably handles key repeating.
-
-Unlike some other QMK Caps Word implementations, this library does not use the Caps Lock (KC_CAPS) keycode. It works even if the OS remaps Caps Lock to Ctrl or something else, as Emacs and Vim users often do.
-
-## Using Caps Word
-With the above flashed to your keyboard:
-
-1. **Activating**: Press and release both left and right shift keys at the same time. If your shift keys are mod-taps, activate Caps Word by holding both shift mod-tap keys until the tapping term, then release them.
-2. Then begin typing to get capitalized letters.
-3. **Disabling**: Caps Word disables itself when the next word breaking key is typed.
-
-If you want to explicitly stop Caps Word, press and release Ctrl or another non-shift modifier or layer key. This also disables Caps Word.
-
-## Explanation
-The code checks the mod bits on each key event, enabling Caps Word when both left and right shifts are active.
-
-While enabled, Caps Word automatically presses and releases left shift (KC_LSFT) as needed so that letters are shifted and other keys are not. The word continues while typing a–z, 0–9, -, _, and backspace. Any other key is considered “word breaking” and disables Caps Word. You can edit the switch statement at the end of the process_caps_word() function to adjust which keys count as word breaking.
diff --git a/users/drashna/keyrecords/process_records.c b/users/drashna/keyrecords/process_records.c
index 89d1c80b8f..99d95c3dff 100644
--- a/users/drashna/keyrecords/process_records.c
+++ b/users/drashna/keyrecords/process_records.c
@@ -3,6 +3,9 @@
#include "drashna.h"
#include "version.h"
+#ifdef OS_DETECTION_ENABLE
+# include "os_detection.h"
+#endif
uint16_t copy_paste_timer;
bool host_driver_disabled = false;
@@ -32,15 +35,6 @@ __attribute__((weak)) bool process_record_secrets(uint16_t keycode, keyrecord_t
* @return false Stop process keycode and do not send to host
*/
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
-#ifdef ENCODER_ENABLE // some debouncing for weird issues
- if (IS_ENCODEREVENT(record->event)) {
- static bool ignore_first = true;
- if (ignore_first) {
- ignore_first = false;
- return false;
- }
- }
-#endif
// If console is enabled, it will print the matrix position and status of each key pressed
#ifdef KEYLOGGER_ENABLE
uprintf("KL: kc: 0x%04X, col: %2u, row: %2u, pressed: %1d, time: %5u, int: %1d, count: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed, record->event.time, record->tap.interrupted, record->tap.count);
@@ -195,6 +189,29 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}
break;
}
+ case OLED_LOCK: {
+#if defined(OLED_ENABLE) && defined(CUSTOM_OLED_DRIVER)
+ extern bool is_oled_locked;
+ if (record->event.pressed) {
+ is_oled_locked = !is_oled_locked;
+ if (is_oled_locked) {
+ oled_on();
+ }
+ }
+#endif
+ } break;
+#if defined(OS_DETECTION_ENABLE) && defined(OS_DETECTION_DEBUG_ENABLE)
+ case STORE_SETUPS:
+ if (record->event.pressed) {
+ store_setups_in_eeprom();
+ }
+ return false;
+ case PRINT_SETUPS:
+ if (record->event.pressed) {
+ print_stored_setups();
+ }
+ return false;
+#endif
}
return true;
}
diff --git a/users/drashna/keyrecords/process_records.h b/users/drashna/keyrecords/process_records.h
index 5c8fe889e4..8073b7adb0 100644
--- a/users/drashna/keyrecords/process_records.h
+++ b/users/drashna/keyrecords/process_records.h
@@ -5,7 +5,7 @@
#include "drashna.h"
enum userspace_custom_keycodes {
- VRSN = SAFE_RANGE, // Prints QMK Firmware and board info
+ VRSN = QK_USER, // Prints QMK Firmware and board info
KC_QWERTY, // Sets default layer to QWERTY
FIRST_DEFAULT_LAYER_KEYCODE = KC_QWERTY, // Sets default layer to QWERTY
KC_COLEMAK_DH, // Sets default layer to COLEMAK
@@ -39,7 +39,12 @@ enum userspace_custom_keycodes {
KC_SUPER,
KC_COMIC,
KC_ACCEL,
- NEW_SAFE_RANGE // use "NEWPLACEHOLDER for keymap specific codes
+ OLED_LOCK,
+
+ STORE_SETUPS,
+ PRINT_SETUPS,
+
+ USER_SAFE_RANGE, // use "NEWPLACEHOLDER for keymap specific codes
};
bool process_record_secrets(uint16_t keycode, keyrecord_t *record);
diff --git a/users/drashna/keyrecords/readme.md b/users/drashna/keyrecords/readme.md
index 5f708f9edf..b89777db3d 100644
--- a/users/drashna/keyrecords/readme.md
+++ b/users/drashna/keyrecords/readme.md
@@ -1,7 +1,5 @@
# Keycode handling and interception
- * [Autocorrection](autocorrection/readme.md)
- * [Cap Words](capwords.md)
* [Diablo Tap Dancing](tap_dance.md)
* [Keymap Wrappers](wrappers.md)
* [Secret Macros](secrets.md)
diff --git a/users/drashna/oled/oled_stuff.c b/users/drashna/oled/oled_stuff.c
index 6dbe3b4812..98506247df 100644
--- a/users/drashna/oled/oled_stuff.c
+++ b/users/drashna/oled/oled_stuff.c
@@ -25,7 +25,7 @@
#endif
#include <string.h>
-bool is_oled_enabled = true;
+bool is_oled_enabled = true, is_oled_locked = false;
extern bool host_driver_disabled;
@@ -75,9 +75,9 @@ void add_keylog(uint16_t keycode, keyrecord_t *record) {
keycode = QK_MODS_GET_BASIC_KEYCODE(keycode);
}
-
if ((keycode == KC_BSPC) && mod_config(get_mods() | get_oneshot_mods()) & MOD_MASK_CTRL) {
memset(keylog_str, ' ', OLED_KEYLOGGER_LENGTH);
+ keylog_str[OLED_KEYLOGGER_LENGTH-1] = 0x00;
return;
}
if (record->tap.count) {
@@ -86,10 +86,10 @@ void add_keylog(uint16_t keycode, keyrecord_t *record) {
return;
}
- memmove(keylog_str, keylog_str + 1, OLED_KEYLOGGER_LENGTH - 1);
+ memmove(keylog_str, keylog_str + 1, OLED_KEYLOGGER_LENGTH - 2);
if (keycode < ARRAY_SIZE(code_to_name)) {
- keylog_str[(OLED_KEYLOGGER_LENGTH - 1)] = pgm_read_byte(&code_to_name[keycode]);
+ keylog_str[(OLED_KEYLOGGER_LENGTH - 2)] = pgm_read_byte(&code_to_name[keycode]);
}
log_timer = timer_read();
@@ -638,10 +638,10 @@ void render_pointing_dpi_status(uint16_t cpi, uint8_t padding, uint8_t col, uint
#define OLED_KAKI_SPEED 40 // above this wpm value typing animation to triggere
#define OLED_RTOGI_FRAMES 2
-//#define OLED_LTOGI_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 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 36
#define OLED_ANIM_ROWS 4
#define OLED_ANIM_MAX_FRAMES 3
@@ -735,7 +735,7 @@ void render_kitty(uint8_t col, uint8_t line) {
}
void render_unicode_mode(uint8_t col, uint8_t line) {
-#ifdef CUSTOM_UNICODE_ENABLE
+#if defined(CUSTOM_UNICODE_ENABLE) && defined(UNICODE_COMMON_ENABLE)
oled_set_cursor(col, line);
oled_write_P(PSTR("Unicode:"), false);
oled_write_P(unicode_mode_str[unicode_typing_mode], false);
@@ -802,19 +802,6 @@ void render_mouse_mode(uint8_t col, uint8_t line) {
}
void render_status_right(void) {
-#if defined(KEYBOARD_handwired_tractyl_manuform)
- oled_set_cursor(7, 0);
- oled_write_P(PSTR("Manuform"), true);
-#elif defined(KEYBOARD_bastardkb_charybdis)
- oled_set_cursor(6, 0);
- oled_write_P(PSTR("Charybdis"), true);
-#elif defined(KEYBOARD_splitkb_kyria)
- oled_set_cursor(8, 0);
- oled_write_P(PSTR("Kyria"), true);
-#else
- oled_set_cursor(8, 0);
- oled_write_P(PSTR("Right"), true);
-#endif
#if defined(OLED_DISPLAY_VERBOSE)
render_default_layer_state(1, 1);
#else
@@ -834,23 +821,6 @@ void render_status_left(void) {
#if defined(OLED_DISPLAY_VERBOSE)
render_kitty(0, 1);
-# if defined(KEYBOARD_handwired_tractyl_manuform)
- oled_set_cursor(7, 0);
- oled_write_P(PSTR("Tractyl"), true);
-# elif defined(KEYBOARD_bastardkb_charybdis)
- oled_set_cursor(6, 0);
- oled_write_P(PSTR("Charybdis"), true);
-# elif defined(KEYBOARD_splitkb_kyria)
- oled_set_cursor(7, 0);
- oled_write_P(PSTR("SplitKB"), true);
-# elif defined(KEYBOARD_handwired_fingerpunch_rockon)
- oled_set_cursor(7, 0);
- oled_write_P(PSTR("Rock On"), true);
-# else
- oled_set_cursor(8, 0);
- oled_write_P(PSTR("Left"), true);
-# endif
-
# if defined(WPM_ENABLE)
render_wpm(1, 7, 1);
# elif defined(DEBUG_MATRIX_SCAN_RATE)
@@ -883,6 +853,11 @@ __attribute__((weak)) void oled_render_large_display(bool side) {
}
}
+__attribute__((weak)) void render_oled_title(bool side) {
+ oled_write_P(side ? PSTR(" Left ") : PSTR(" Right "), true);
+ // oled_write_P(PSTR( "1234567890123" "1234567890123"), true);
+}
+
__attribute__((weak)) oled_rotation_t oled_init_keymap(oled_rotation_t rotation) {
return rotation;
}
@@ -924,6 +899,9 @@ bool oled_task_user(void) {
// 0,255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 7, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 7, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255, 0
};
oled_write_raw_P(header_image, sizeof(header_image));
+
+ oled_set_cursor(4, 0);
+ render_oled_title(is_keyboard_left());
#endif
#ifndef OLED_DISPLAY_TEST
@@ -966,6 +944,6 @@ bool oled_task_user(void) {
extern bool oled_initialized;
-__attribute__((weak)) void matrix_scan_oled(void) {
- is_oled_enabled = !(timer_elapsed32(oled_timer) > 60000);
+__attribute__((weak)) void housekeeping_task_oled(void) {
+ is_oled_enabled = is_oled_locked ? true : !(timer_elapsed32(oled_timer) > 60000);
}
diff --git a/users/drashna/oled/oled_stuff.h b/users/drashna/oled/oled_stuff.h
index df1a6d1805..419cdc11eb 100644
--- a/users/drashna/oled/oled_stuff.h
+++ b/users/drashna/oled/oled_stuff.h
@@ -45,7 +45,8 @@ void render_kitty(uint8_t col, uint8_t line);
void render_unicode_mode(uint8_t col, uint8_t line);
void render_rgb_hsv(uint8_t col, uint8_t line);
void render_mouse_mode(uint8_t col, uint8_t line);
-void matrix_scan_oled(void);
+void housekeeping_task_oled(void);
+void render_oled_title(bool side);
void oled_pan_section(bool left, uint16_t y_start, uint16_t y_end, uint16_t x_start, uint16_t x_end);
@@ -54,7 +55,7 @@ void oled_pan_section(bool left, uint16_t y_start, uint16_t y_end, uint16_t x_st
# define OLED_RENDER_KEYLOGGER "Keylogger: "
# ifndef OLED_KEYLOGGER_LENGTH
-# define OLED_KEYLOGGER_LENGTH 9
+# define OLED_KEYLOGGER_LENGTH 10
# endif
# define OLED_RENDER_LAYOUT_NAME "Layout: "
# define OLED_RENDER_LAYOUT_QWERTY "Qwerty"
@@ -101,7 +102,7 @@ void oled_pan_section(bool left, uint16_t y_start, uint16_t y_end, uint16_t x_st
#else
# define OLED_RENDER_KEYLOGGER "KLogr"
# ifndef OLED_KEYLOGGER_LENGTH
-# define OLED_KEYLOGGER_LENGTH 5
+# define OLED_KEYLOGGER_LENGTH 6
# endif
# define OLED_RENDER_LAYOUT_NAME "Lyout"
@@ -148,7 +149,7 @@ void oled_pan_section(bool left, uint16_t y_start, uint16_t y_end, uint16_t x_st
# define OLED_RENDER_WPM_COUNTER "WPM: "
#endif
-extern char keylog_str[OLED_KEYLOGGER_LENGTH];
+extern char keylog_str[];
#ifndef OLED_WPM_GRAPH_MAX_WPM
# define OLED_WPM_GRAPH_MAX_WPM 120
diff --git a/users/drashna/oled/sh110x.c b/users/drashna/oled/sh110x.c
index 9fed5a9d1a..f96a93a897 100644
--- a/users/drashna/oled/sh110x.c
+++ b/users/drashna/oled/sh110x.c
@@ -324,78 +324,77 @@ static void rotate_90(const uint8_t *src, uint8_t *dest) {
}
void oled_render(void) {
- if (!oled_initialized) {
- return;
- }
-
// Do we have work to do?
oled_dirty &= OLED_ALL_BLOCKS_MASK;
- if (!oled_dirty || oled_scrolling) {
+ if (!oled_dirty || !oled_initialized || oled_scrolling) {
return;
}
- // Find first dirty block
+ // Turn on display if it is off
+ oled_on();
+
uint8_t update_start = 0;
- while (!(oled_dirty & ((OLED_BLOCK_TYPE)1 << update_start))) {
- ++update_start;
- }
+ uint8_t num_processed = 0;
+ while (oled_dirty && num_processed++ < OLED_UPDATE_PROCESS_LIMIT) { // render all dirty blocks (up to the configured limit)
+ // Find next dirty block
+ while (!(oled_dirty & ((OLED_BLOCK_TYPE)1 << update_start))) {
+ ++update_start;
+ }
- // Set column & page position
- static uint8_t display_start[] = {I2C_CMD, PAM_PAGE_ADDR, PAM_SETCOLUMN_LSB, PAM_SETCOLUMN_MSB};
- if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
- calc_bounds(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start
- } else {
- calc_bounds_90(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start
- }
+ // Set column & page position
+ static uint8_t display_start[] = {I2C_CMD, PAM_PAGE_ADDR, PAM_SETCOLUMN_LSB, PAM_SETCOLUMN_MSB};
+ if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
+ calc_bounds(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start
+ } else {
+ calc_bounds_90(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start
+ }
- // Send column & page position
- if (I2C_TRANSMIT(display_start) != I2C_STATUS_SUCCESS) {
- print("oled_render offset command failed\n");
- return;
- }
+ // Send column & page position
+ if (I2C_TRANSMIT(display_start) != I2C_STATUS_SUCCESS) {
+ print("oled_render offset command failed\n");
+ return;
+ }
- if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
- // Send render data chunk as is
- if (I2C_WRITE_REG(I2C_DATA, &oled_buffer[OLED_BLOCK_SIZE * update_start], OLED_BLOCK_SIZE) != I2C_STATUS_SUCCESS) {
- print("oled_render data failed\n");
- return;
- }
- } else {
- // Rotate the render chunks
- const static uint8_t source_map[] = OLED_SOURCE_MAP;
- const static uint8_t target_map[] = OLED_TARGET_MAP;
-
- static uint8_t temp_buffer[OLED_BLOCK_SIZE];
- memset(temp_buffer, 0, sizeof(temp_buffer));
- for (uint8_t i = 0; i < sizeof(source_map); ++i) {
- rotate_90(&oled_buffer[OLED_BLOCK_SIZE * update_start + source_map[i]], &temp_buffer[target_map[i]]);
- }
+ if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
+ // Send render data chunk as is
+ if (I2C_WRITE_REG(I2C_DATA, &oled_buffer[OLED_BLOCK_SIZE * update_start], OLED_BLOCK_SIZE) != I2C_STATUS_SUCCESS) {
+ print("oled_render data failed\n");
+ return;
+ }
+ } else {
+ // Rotate the render chunks
+ const static uint8_t source_map[] = OLED_SOURCE_MAP;
+ const static uint8_t target_map[] = OLED_TARGET_MAP;
+
+ static uint8_t temp_buffer[OLED_BLOCK_SIZE];
+ memset(temp_buffer, 0, sizeof(temp_buffer));
+ for (uint8_t i = 0; i < sizeof(source_map); ++i) {
+ rotate_90(&oled_buffer[OLED_BLOCK_SIZE * update_start + source_map[i]], &temp_buffer[target_map[i]]);
+ }
- // For SH1106 or SH1107 the data chunk must be split