[Keymap] Drashna updates for 0.20.0 (#19960)

This commit is contained in:
Drashna Jaelre 2023-02-28 11:14:48 -08:00 committed by GitHub
parent 05631b276d
commit 051401175d
Failed to generate hash of commit
34 changed files with 459 additions and 346 deletions

View file

@ -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);
}

View file

@ -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

View file

@ -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
uint8_t update_start = 0;
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
}
// 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]]);
}
// For SH1106 or SH1107 the data chunk must be split into separate pieces for each page
const uint8_t columns_in_block = (OLED_BLOCK_SIZE + OLED_DISPLAY_HEIGHT - 1) / OLED_DISPLAY_HEIGHT * 8;
const uint8_t num_pages = OLED_BLOCK_SIZE / columns_in_block;
for (uint8_t i = 0; i < num_pages; ++i) {
// Send column & page position for all pages except the first one
if (i > 0) {
display_start[1]++;
if (I2C_TRANSMIT(display_start) != I2C_STATUS_SUCCESS) {
print("oled_render offset command failed\n");
return;
}
}
// Send data for the page
if (I2C_WRITE_REG(I2C_DATA, &temp_buffer[columns_in_block * i], columns_in_block) != I2C_STATUS_SUCCESS) {
print("oled_render90 data failed\n");
return;
}
}
}
// Turn on display if it is off
oled_on();
// Clear dirty flag
oled_dirty &= ~((OLED_BLOCK_TYPE)1 << update_start);
uint8_t update_start = 0;
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
}
// 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]]);
}
// For SH1106 or SH1107 the data chunk must be split into separate pieces for each page
const uint8_t columns_in_block = (OLED_BLOCK_SIZE + OLED_DISPLAY_HEIGHT - 1) / OLED_DISPLAY_HEIGHT * 8;
const uint8_t num_pages = OLED_BLOCK_SIZE / columns_in_block;
for (uint8_t i = 0; i < num_pages; ++i) {
// Send column & page position for all pages except the first one
if (i > 0) {
display_start[1]++;
if (I2C_TRANSMIT(display_start) != I2C_STATUS_SUCCESS) {
print("oled_render offset command failed\n");
return;
}
}
// Send data for the page
if (I2C_WRITE_REG(I2C_DATA, &temp_buffer[columns_in_block * i], columns_in_block) != I2C_STATUS_SUCCESS) {
print("oled_render90 data failed\n");
return;
}
}
}
// Clear dirty flag
oled_dirty &= ~((OLED_BLOCK_TYPE)1 << update_start);
}
}
void oled_set_cursor(uint8_t col, uint8_t line) {