summaryrefslogtreecommitdiffstats
path: root/keyboards/crkbd/keymaps/jpe230/oled/avr
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/crkbd/keymaps/jpe230/oled/avr')
-rw-r--r--keyboards/crkbd/keymaps/jpe230/oled/avr/master/oled_master_handler.c75
-rw-r--r--keyboards/crkbd/keymaps/jpe230/oled/avr/slave/oled_slave_handler.c14
2 files changed, 89 insertions, 0 deletions
diff --git a/keyboards/crkbd/keymaps/jpe230/oled/avr/master/oled_master_handler.c b/keyboards/crkbd/keymaps/jpe230/oled/avr/master/oled_master_handler.c
new file mode 100644
index 0000000000..9a75e9fa9a
--- /dev/null
+++ b/keyboards/crkbd/keymaps/jpe230/oled/avr/master/oled_master_handler.c
@@ -0,0 +1,75 @@
+// Copyright 2022 Jose Pablo Ramirez (@jpe230)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "jpe230.h"
+
+extern uint8_t logged_row;
+extern uint8_t logged_col;
+extern uint32_t oled_timer;
+static char logged_char = ' ';
+static uint16_t logged_keycode = 0;
+
+#define L_BASE 0
+#define L_LOWER 2
+#define L_RAISE 4
+#define L_ADJUST 8
+
+void oled_render_layer_state(void) {
+ oled_write_P(PSTR("Layer: "), false);
+ switch (layer_state) {
+ case L_BASE:
+ oled_write_ln_P(PSTR("Default"), false);
+ break;
+ case L_LOWER:
+ oled_write_ln_P(PSTR("Lower"), false);
+ break;
+ case L_RAISE:
+ oled_write_ln_P(PSTR("Raise"), false);
+ break;
+ case L_ADJUST:
+ case L_ADJUST|L_LOWER:
+ case L_ADJUST|L_RAISE:
+ case L_ADJUST|L_LOWER|L_RAISE:
+ oled_write_ln_P(PSTR("Adjust"), false);
+ break;
+ }
+}
+
+const char code_to_name[60] = {
+ ' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
+ 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
+ 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
+ '1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
+ 'R', 'E', 'B', 'T', '_', '-', '=', '[', ']', '\\',
+ '#', ';', '\'', '`', ',', '.', '/', ' ', ' ', ' '};
+
+void handle_oled_keypress(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 = keycode & 0xFF; }
+ if (keycode < 60) {
+ logged_char = code_to_name[keycode];
+ }
+
+ logged_keycode = keycode;
+}
+
+void oled_render_keylog(void) {
+ oled_write(get_u8_str(logged_row, '0'), false);
+ oled_write_P(PSTR(":"), false);
+ oled_write(get_u8_str(logged_col, '0'), false);
+ oled_write_P(PSTR(", "), false);
+ oled_write(get_u16_str(logged_keycode, ' '), false);
+ oled_write_P(PSTR(" : "), false);
+ oled_write((const char *)&logged_char, false);
+}
+
+void render_master_oled() {
+ if (timer_elapsed32(oled_timer) > CUSTOM_OLED_TIMEOUT) {
+ oled_off();
+ return;
+ }
+
+ oled_on();
+ oled_render_layer_state();
+ oled_render_keylog();
+}
diff --git a/keyboards/crkbd/keymaps/jpe230/oled/avr/slave/oled_slave_handler.c b/keyboards/crkbd/keymaps/jpe230/oled/avr/slave/oled_slave_handler.c
new file mode 100644
index 0000000000..159413d083
--- /dev/null
+++ b/keyboards/crkbd/keymaps/jpe230/oled/avr/slave/oled_slave_handler.c
@@ -0,0 +1,14 @@
+// Copyright 2022 Jose Pablo Ramirez (@jpe230)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "jpe230.h"
+
+void render_slave_oled() {
+ 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);
+}
+