summaryrefslogtreecommitdiff
path: root/users/xulkal/custom_oled.c
diff options
context:
space:
mode:
Diffstat (limited to 'users/xulkal/custom_oled.c')
-rw-r--r--users/xulkal/custom_oled.c207
1 files changed, 105 insertions, 102 deletions
diff --git a/users/xulkal/custom_oled.c b/users/xulkal/custom_oled.c
index 7280ef7019..448e6ca107 100644
--- a/users/xulkal/custom_oled.c
+++ b/users/xulkal/custom_oled.c
@@ -3,12 +3,15 @@
#include <stdio.h>
-#ifdef OLED_DRIVER_ENABLE
-
#ifdef RGBLIGHT_ENABLE
rgblight_config_t rgblight_config;
#endif
+#if KEYBOARD_helix_rev2
+extern uint8_t is_master;
+bool is_keyboard_master(void) { return is_master; }
+#endif
+
static void render_logo(void)
{
static const char PROGMEM font_logo[] = {
@@ -18,21 +21,38 @@ static void render_logo(void)
oled_write_P(font_logo, false);
}
-#if defined(OLED_90ROTATION)
-
-// TODO: Need to define this function / extern only for helix based split common keyboards
-extern uint8_t is_master;
-bool is_keyboard_master(void)
+static void render_icon(void)
{
- return is_master;
+#ifdef OLED_90ROTATION
+ static const char PROGMEM font_icon[] = {
+ 0x9b,0x9c,0x9d,0x9e,0x9f,
+ 0xbb,0xbc,0xbd,0xbe,0xbf,
+ 0xdb,0xdc,0xdd,0xde,0xdf,0
+ };
+#else
+ static const char PROGMEM font_icon[] = {
+ // Use \r (0x0d) to jump to the next line without clearing the rest of the current line
+ 0x9b,0x9c,0x9d,0x9e,0x9f,0x0d,
+ 0xbb,0xbc,0xbd,0xbe,0xbf,0x0d,
+ 0xdb,0xdc,0xdd,0xde,0xdf,0
+ };
+#endif
+ oled_write_P(font_icon, false);
}
-static void render_layer(uint8_t layer)
+static void render_layer(void)
{
+ uint8_t layer = layer_state ? biton(layer_state) : biton32(default_layer_state);
+#ifdef OLED_90ROTATION
+ oled_write_P(PSTR("Layer"), false);
+#else
+ oled_write_P(PSTR("Layer: "), false);
+#endif
+
switch (layer)
{
case _QWERTY:
- oled_write_P(PSTR("DFLT "), false);
+ oled_write_P(PSTR("BASE "), false);
break;
#ifndef GAMELAYER_DISABLE
case _GAME:
@@ -53,125 +73,110 @@ static void render_layer(uint8_t layer)
}
}
-static void render_status(void)
+static void render_keyboard_leds(void)
{
- // Render to mode icon
- static const char PROGMEM mode_logo[2][4] = {
- {0x97,0x98,0x0a,0},
- {0xb7,0xb8,0x0a,0} };
-
- oled_write_P(mode_logo[0], false);
- oled_write_P(mode_logo[1], false);
+ // Host Keyboard LED Status
+ uint8_t led_state = host_keyboard_leds();
+#ifdef OLED_90ROTATION
+ oled_write_P(IS_LED_ON(led_state, USB_LED_NUM_LOCK) ? PSTR("NUMLK") : PSTR(" "), false);
+ oled_write_P(IS_LED_ON(led_state, USB_LED_CAPS_LOCK) ? PSTR("CAPLK") : PSTR(" "), false);
+ oled_write_P(IS_LED_ON(led_state, USB_LED_SCROLL_LOCK) ? PSTR("SCRLK") : PSTR(" "), false);
+#else
+ oled_write_P(IS_LED_ON(led_state, USB_LED_NUM_LOCK) ? PSTR("NUM ") : PSTR(" "), false);
+ oled_write_P(IS_LED_ON(led_state, USB_LED_CAPS_LOCK) ? PSTR("CAPS ") : PSTR(" "), false);
+ oled_write_P(IS_LED_ON(led_state, USB_LED_SCROLL_LOCK) ? PSTR("SCRL") : PSTR(" "), false);
+#endif
+}
- oled_write_P(PSTR("Layer"), false);
- uint8_t layer = biton(layer_state);
- if (layer != _QWERTY)
- render_layer(layer);
- else
- render_layer(biton32(default_layer_state));
+#ifdef RGB_OLED_MENU
+extern uint8_t rgb_encoder_state;
+#endif
- // Host Keyboard LED Status
- uint8_t led_usb_state = host_keyboard_leds();
- oled_write_P(led_usb_state & (1<<USB_LED_NUM_LOCK) ? PSTR("-----NUMLK") : PSTR("----- "), false);
- oled_write_P(led_usb_state & (1<<USB_LED_CAPS_LOCK) ? PSTR("CAPLK") : PSTR(" "), false);
- oled_write_P(led_usb_state & (1<<USB_LED_SCROLL_LOCK) ? PSTR("SCRLK") : PSTR(" "), false);
+#if defined(OLED_90ROTATION)
+#ifdef RGB_ENABLE
+static void render_rgb_state(void)
+{
+ // TODO: need to do a bit more handling here for horizontal rendering
#if defined(RGB_MATRIX_ENABLE)
- oled_set_cursor(0, oled_max_lines() - 7);
- oled_write_P(PSTR("-----"), false);
+ static char buffer[31] = {0};
+ snprintf(buffer, sizeof(buffer), "h%3d s%3d v%3d s%3d m%3d e%3d ", rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, rgb_matrix_config.speed, rgb_matrix_config.mode, rgb_matrix_get_flags());
+#elif defined(RGBLIGHT_ENABLE)
static char buffer[26] = {0};
- snprintf(buffer, sizeof(buffer), "h%3d s%3d v%3d s%3d m%3d\n", rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, rgb_matrix_config.speed, rgb_matrix_config.mode);
+ snprintf(buffer, sizeof(buffer), "h%3d s%3d v%3d s%3d m%3d ", rgblight_config.hue, rgblight_config.sat, rgblight_config.val, rgblight_config.speed, rgblight_config.mode);
+#endif
+
+#ifdef RGB_OLED_MENU
+ buffer[4 + rgb_encoder_state * 5] = '<';
+#endif
oled_write(buffer, false);
-#elif defined(RGBLIGHT_ENABLE)
- oled_set_cursor(0, oled_max_lines() - 7);
+}
+#endif
+
+static void render_status(void)
+{
+ render_icon();
+ render_layer();
+
+ // Host Keyboard LED Status
oled_write_P(PSTR("-----"), false);
- static char buffer[31] = {0};
- snprintf(buffer, sizeof(buffer), "h%3d s%3d v%3d s%3d m%3d\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val, rgblight_config.speed, rgblight_config.mode);
- oled_write(buffer, false);
+ render_keyboard_leds();
+
+ oled_write_P(PSTR("-----"), false);
+#ifdef RGB_ENABLE
+ render_rgb_state();
#endif
}
oled_rotation_t oled_init_user(oled_rotation_t rotation) {
+#if KEYBOARD_helix_rev2
if (is_keyboard_master())
return OLED_ROTATION_270;
- return OLED_ROTATION_180;
+ return rotation;
+#else
+ if (is_keyboard_master())
+ return OLED_ROTATION_90;
+ return rotation;
+#endif
}
#else // OLED_90ROTATION
-static void render_layer(uint8_t layer)
+#ifdef RGB_ENABLE
+static void render_rgb_state(void)
{
- switch (layer)
- {
- case _QWERTY:
- oled_write_P(PSTR("Default\n"), false);
- break;
-#ifndef GAMELAYER_DISABLE
- case _GAME:
- oled_write_P(PSTR("Game\n"), false);
- break;
+ // TODO: need to do a bit more handling here for horizontal rendering
+#if defined(RGB_MATRIX_ENABLE)
+ static char buffer[37] = {0};
+ snprintf(buffer, sizeof(buffer), "h%3d s%3d v%3d s%3d m%3d e%3d ", rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, rgb_matrix_config.speed, rgb_matrix_config.mode, rgb_matrix_get_flags());
+#elif defined(RGBLIGHT_ENABLE)
+ static char buffer[32] = {0};
+ snprintf(buffer, sizeof(buffer), "h%3d s%3d v%3d s%3d m%3d ", rgblight_config.hue, rgblight_config.sat, rgblight_config.val, rgblight_config.speed, rgblight_config.mode);
#endif
- case _LOWER:
- oled_write_P(PSTR("Lower\n"), false);
- break;
- case _RAISE:
- oled_write_P(PSTR("Raise\n"), false);
- break;
-#ifdef TRILAYER_ENABLED
- case _ADJUST:
- oled_write_P(PSTR("Adjust\n"), false);
- break;
+
+#ifdef RGB_OLED_MENU
+ buffer[4 + rgb_encoder_state * 5] = '<';
#endif
- }
+ oled_write(buffer, false);
}
+#endif
static void render_status(void)
{
- // Render to mode icon
- static const char PROGMEM mode_logo[2][3] = {
- {0x97,0x98,0},
- {0xb7,0xb8,0}
- };
+ render_icon();
- oled_write_P(mode_logo[0], false);
+ // Host Layer Status
+ oled_set_cursor(6, 0);
+ render_layer();
-#if defined(RGB_MATRIX_ENABLE)
- static char buffer[20] = {0};
- snprintf(buffer, sizeof(buffer), " h%3d s%3d v%3d\n", rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v);
- oled_write(buffer, false);
-#elif defined(RGBLIGHT_ENABLE)
- static char buffer[20] = {0};
- snprintf(buffer, sizeof(buffer), " h%3d s%3d v%3d\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
- oled_write(buffer, false);
-#else
- oled_write_P(PSTR("\n"));
-#endif
-
- oled_write_P(mode_logo[1], false);
+ // Host Keyboard LED Status
+ oled_set_cursor(6, 1);
+ render_keyboard_leds();
-#if defined(RGB_MATRIX_ENABLE)
- snprintf(buffer, sizeof(buffer), " s%3d m%3d\n", rgb_matrix_config.speed, rgb_matrix_config.mode);
- oled_write(buffer, false);
-#elif defined(RGBLIGHT_ENABLE)
- snprintf(buffer, sizeof(buffer), " s%3d m%3d\n", rgblight_config.speed, rgblight_config.mode);
- oled_write(buffer, false);
-#else
- oled_write_P(PSTR("\n"));
+#ifdef RGB_ENABLE
+ oled_set_cursor(6, 2);
+ render_rgb_state();
#endif
-
- // Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below
- oled_write_P(PSTR("Layer: "), false);
- uint8_t layer = biton(layer_state);
- if (layer != _QWERTY)
- render_layer(layer);
- else
- render_layer(biton32(default_layer_state));
-
- // Host Keyboard LED Status
- uint8_t led_usb_state = host_keyboard_leds();
- oled_write_P(led_usb_state & (1<<USB_LED_NUM_LOCK) ? PSTR("NUMLCK ") : PSTR(" "), false);
- oled_write_P(led_usb_state & (1<<USB_LED_CAPS_LOCK) ? PSTR("CAPLCK ") : PSTR(" "), false);
- oled_write_P(led_usb_state & (1<<USB_LED_SCROLL_LOCK) ? PSTR("SCRLCK ") : PSTR(" "), false);
}
#endif // OLED_90ROTATION
@@ -186,5 +191,3 @@ void oled_task_user(void)
oled_scroll_left();
}
}
-
-#endif