summaryrefslogtreecommitdiffstats
path: root/users/ninjonas/oled.c
diff options
context:
space:
mode:
authorJonas Avellana <14019120+ninjonas@users.noreply.github.com>2019-09-25 22:28:06 -0600
committerDrashna Jaelre <drashna@live.com>2019-09-25 21:28:06 -0700
commitff854565ce012a325ad04b09a7bcb7c8bb9d43c5 (patch)
tree69d4970d4ea40d49483f232bf404d16f383957ba /users/ninjonas/oled.c
parent2a948e77715f0bd11d4b80315cf84c68890014d4 (diff)
[Keymap] ninjonas keymap for crkbd & ninjonas userspace updates (#6797)
* [keymap(crkbd)] introducing crkbd keymap on ninjonas profile * [keymap(crkbd)] introducing crkbd keymap on ninjonas profile * [refactor(crkbd)] reducing file size by selecting RGB animations * [refactor(crkbd)] added shiftit key * [refactor(crkbd)] added shiftit key * [chore(crkbd)] adding SLEEP_LED_ENABLE on rules.mk * [refactor(crkbd)] added keylog & removed static rainbow RGB * [feat(crkbd)] introduced em-dash '—' keymap * [feat(crkbd)] added screenshot functionality * [refactor(lily58,pinky3)] moving media keys * [refactor(lily58)] Added emdash key * [chore] removing NUMBERS & FUNCTIONS layers as they're useless * [chore] removing NUMBERS & FUNCTIONS layers as they're useless * [chore(crkbd,lily48)] Updating README.md * [feat] added K_LAPP & K_RAPP to mimic command + tab * [feat] added K_LAPP & K_RAPP to mimic command + tab * [fix(#6797)] resolving changes requested by @drashna * [fix(#6797)] first cut on using QMK OLED Driver * [fix(#6797)] cleaning up rules.mk * [fix(#6797)] making scrolling logo work * [fix(#6797)] Using OLED Driver for Lily58 * [fix(#6797)] Moved OLED driver implementation to ninjonas userspace * [fix(#6797)] Bringing back crkbd & lily58 logos * [fix(#6797)] Turning off OLED based off @drashna's workaround in #5982 * [fix(#6797)] whoops! forgot to checkin crkbd/config.h * [fix(#6797)] fixing issue with OLED randomly turning on * [fix(#6797)] using default glcdfont.c for lily58 & crkbd * [fix(#6797)] Using LINK_TIME_OPTIMIZATION_ENABLE rather than EXTRAFLAGS as per code review * [fix(#6797)] updating M_MALL macro as per code review by @fauxpark
Diffstat (limited to 'users/ninjonas/oled.c')
-rw-r--r--users/ninjonas/oled.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/users/ninjonas/oled.c b/users/ninjonas/oled.c
new file mode 100644
index 0000000000..837d497ab3
--- /dev/null
+++ b/users/ninjonas/oled.c
@@ -0,0 +1,82 @@
+#include QMK_KEYBOARD_H
+#include <stdio.h>
+#include "ninjonas.h"
+
+#ifdef OLED_DRIVER_ENABLE
+
+static uint16_t oled_timer = 0;
+extern uint8_t is_master;
+
+bool process_record_oled(uint16_t keycode, keyrecord_t *record) {
+ if (record->event.pressed) {
+ oled_timer = timer_read();
+ }
+ return true;
+}
+
+void render_default_layer_state(void) {
+ oled_write_P(PSTR("Layout: "), false);
+ switch (biton32(default_layer_state)) {
+ case _COLEMAK:
+ oled_write_P(PSTR("Colemak"), false);
+ break;
+ case _DVORAK:
+ oled_write_P(PSTR("Dvorak"), false);
+ break;
+ case _QWERTY:
+ oled_write_P(PSTR("Qwerty"), false);
+ break;
+ default:
+ oled_write_ln_P(PSTR("Undefined"), false);
+ }
+}
+
+void render_layer_state(void) {
+ oled_write_P(PSTR("\nLayer:"), false);
+ oled_write_P(PSTR(" LOW"), layer_state_is(_LOWER));
+ oled_write_P(PSTR(" RAI"), layer_state_is(_RAISE));
+ oled_write_P(PSTR(" ADJ"), layer_state_is(_ADJUST));
+}
+
+void render_mod_status(uint8_t modifiers) {
+ oled_write_P(PSTR("\nMods: "), false);
+ oled_write_P(PSTR("SHF "), (modifiers & MOD_MASK_SHIFT));
+ oled_write_P(PSTR("CTL "), (modifiers & MOD_MASK_CTRL));
+ oled_write_P(PSTR("ALT "), (modifiers & MOD_MASK_ALT));
+ oled_write_P(PSTR("GUI"), (modifiers & MOD_MASK_GUI));
+}
+
+void render_status(void){
+ render_default_layer_state();
+ render_layer_state();
+ render_mod_status(get_mods()|get_oneshot_mods());
+}
+
+static void render_logo(void) {
+ 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};
+
+ oled_write_P(qmk_logo, false);
+}
+
+void oled_task_user(void) {
+ if (timer_elapsed(oled_timer) > 30000) {
+ oled_off();
+ return;
+ }
+ #ifndef SPLIT_KEYBOARD
+ else { oled_on(); }
+ #endif
+
+ if (is_master) {
+ render_status();
+ } else {
+ render_logo();
+ oled_scroll_left();
+ }
+}
+
+#endif \ No newline at end of file