qmk_keymaps/keyboards/crkbd/keymaps/sajenim/oled.c

128 lines
2.9 KiB
C
Raw Normal View History

2023-02-19 17:51:22 +08:00
#include QMK_KEYBOARD_H
2023-04-13 11:48:44 +08:00
#include "features/sentence_case.h"
2023-02-19 17:51:22 +08:00
#include "layers.h"
2023-04-13 11:48:44 +08:00
#include <stdio.h>
2024-02-05 10:57:08 +08:00
// Declare screen rotation for each half
2023-02-19 17:51:22 +08:00
oled_rotation_t oled_init_user(oled_rotation_t rotation) {
if (is_keyboard_master()) {
return OLED_ROTATION_270;
} else {
2023-05-27 15:46:47 +08:00
return OLED_ROTATION_180;
2023-02-19 17:51:22 +08:00
}
return rotation;
}
2024-02-05 10:57:08 +08:00
// Setup the master screen
2023-02-19 17:51:22 +08:00
void oled_render_master(void) {
2023-04-13 11:48:44 +08:00
// Layer Status
switch (get_highest_layer(layer_state)) {
case L_CANARY:
2023-05-27 15:46:47 +08:00
oled_write(" BAS ", false);
2023-04-13 11:48:44 +08:00
break;
case L_LOWER:
2023-05-27 15:46:47 +08:00
oled_write(" LWR ", false);
2023-04-13 11:48:44 +08:00
break;
2023-08-15 07:39:18 +08:00
case L_UPPER:
2023-05-27 15:46:47 +08:00
oled_write(" RSE ", false);
2023-04-13 11:48:44 +08:00
break;
case L_ADJUST:
2023-05-27 15:46:47 +08:00
oled_write(" ADJ ", false);
2023-04-13 11:48:44 +08:00
break;
case L_EXTEND:
2023-05-27 15:46:47 +08:00
oled_write(" EXT ", false);
2023-04-13 11:48:44 +08:00
break;
default:
2023-05-27 15:46:47 +08:00
oled_write(" UND ", false);
2023-04-13 11:48:44 +08:00
}
2023-02-19 17:51:22 +08:00
2023-04-13 11:48:44 +08:00
// Mod Status
uint8_t this_mod = get_mods();
uint8_t this_osm = get_oneshot_mods();
2023-02-19 17:51:22 +08:00
2023-04-13 11:48:44 +08:00
oled_write("-----", false);
2023-02-19 17:51:22 +08:00
2023-04-13 11:48:44 +08:00
if ((this_mod | this_osm) & MOD_MASK_GUI) {
oled_write("gui:*", false);
} else {
oled_write("gui:.", false);
}
if ((this_mod | this_osm) & MOD_MASK_ALT) {
oled_write("alt:*", false);
} else {
oled_write("alt:.", false);
}
if ((this_mod | this_osm) & MOD_MASK_SHIFT) {
oled_write("sft:*", false);
} else {
oled_write("sft:.", false);
}
if ((this_mod | this_osm) & MOD_MASK_CTRL) {
oled_write("ctl:*", false);
} else {
oled_write("ctl:.", false);
}
2023-05-27 15:46:47 +08:00
// Feature Status
oled_write("-----", false);
bool autoshift_enabled = get_autoshift_state();
if (autoshift_enabled) {
oled_write("as: *", false);
} else {
oled_write("as: .", false);
}
bool autocorrect_enabled = autocorrect_is_enabled();
if (autocorrect_enabled) {
oled_write("ac: *", false);
} else {
oled_write("ac: .", false);
}
bool combo_enabled = is_combo_enabled();
if (combo_enabled) {
oled_write("cm: *", false);
} else {
oled_write("cm: .", false);
}
bool sentence_case_enabled = is_sentence_case_on();
if (sentence_case_enabled) {
oled_write("sc: *", false);
} else {
oled_write("sc: .", false);
}
2023-04-13 11:48:44 +08:00
// WPM Status
char wpm_str[4];
sprintf(wpm_str, "%03d", get_current_wpm());
oled_set_cursor(1, 14);
oled_write_ln(wpm_str, false);
oled_write(" wpm", false);
2023-02-19 17:51:22 +08:00
}
2024-02-05 10:57:08 +08:00
// Corne keyboard logo
2023-05-27 15:46:47 +08:00
void oled_render_logo(void) {
static const char PROGMEM crkbd_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};
oled_write_P(crkbd_logo, false);
}
2024-02-05 10:57:08 +08:00
// Render our screens
2023-05-27 15:46:47 +08:00
bool oled_task_user(void) {
2023-04-13 11:48:44 +08:00
if (is_keyboard_master()) {
oled_render_master();
} else {
2023-05-27 15:46:47 +08:00
oled_render_logo();
2023-04-13 11:48:44 +08:00
}
return false;
}