aboutsummaryrefslogtreecommitdiff
path: root/users/xulkal/custom_oled.c
diff options
context:
space:
mode:
authorXScorpion2 <rcalt2vt@gmail.com>2019-06-05 18:14:35 -0500
committerDrashna Jaelre <drashna@live.com>2019-06-05 16:14:35 -0700
commitde968eb310b82dbba7c69971ad0d1280aaac7b27 (patch)
tree418b85336efb7f8d581875b7e57f1e985e3a28aa /users/xulkal/custom_oled.c
parentb2f7915994eb514a0348fdb864ead04c54c509c7 (diff)
downloadqmk_firmware-de968eb310b82dbba7c69971ad0d1280aaac7b27.tar.gz
qmk_firmware-de968eb310b82dbba7c69971ad0d1280aaac7b27.zip
[Keymap] Xulkal changes (#6075)
Diffstat (limited to 'users/xulkal/custom_oled.c')
-rw-r--r--users/xulkal/custom_oled.c166
1 files changed, 130 insertions, 36 deletions
diff --git a/users/xulkal/custom_oled.c b/users/xulkal/custom_oled.c
index 77e580b95..d871e96f0 100644
--- a/users/xulkal/custom_oled.c
+++ b/users/xulkal/custom_oled.c
@@ -5,60 +5,112 @@
5 5
6#ifdef OLED_DRIVER_ENABLE 6#ifdef OLED_DRIVER_ENABLE
7 7
8#ifdef RGBLIGHT_ENABLE
9rgblight_config_t rgblight_config;
10#endif
11
8static void render_logo(void) 12static void render_logo(void)
9{ 13{
10 static const char PROGMEM sol_logo[] = { 14 static const char PROGMEM font_logo[] = {
11 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94, 15 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
12 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4, 16 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
13 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0}; 17 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0};
14 oled_write_P(sol_logo, false); 18 oled_write_P(font_logo, false);
19}
20
21#if defined(OLED_90ROTATION)
22
23// TODO: Need to define this function / extern only for helix based split common keyboards
24extern uint8_t is_master;
25bool is_keyboard_master(void)
26{
27 return is_master;
28}
29
30static void render_layer(uint8_t layer)
31{
32 switch (layer)
33 {
34 case _QWERTY:
35 oled_write_P(PSTR("DFLT "), false);
36 break;
37#ifndef GAMELAYER_DISABLE
38 case _GAME:
39 oled_write_P(PSTR("GAME "), false);
40 break;
41#endif
42 case _LOWER:
43 oled_write_P(PSTR("LOWER"), false);
44 break;
45 case _RAISE:
46 oled_write_P(PSTR("RAISE"), false);
47 break;
48#ifdef TRILAYER_ENABLED
49 case _ADJUST:
50 oled_write_P(PSTR("ADJST"), false);
51 break;
52#endif
53 }
15} 54}
16 55
17static void render_status(void) 56static void render_status(void)
18{ 57{
19 // Render to mode icon 58 // Render to mode icon
20 static const char PROGMEM mode_logo[2][3] = { 59 static const char PROGMEM mode_logo[2][4] = {
21 {0x97,0x98,0}, 60 {0x97,0x98,0x0a,0},
22 {0xb7,0xb8,0} 61 {0xb7,0xb8,0x0a,0} };
23 };
24 62
25 oled_write_P(mode_logo[0], false); 63 oled_write_P(mode_logo[0], false);
64 oled_write_P(mode_logo[1], false);
26 65
27#if defined(RGB_MATRIX_ENABLE) 66 oled_write_P(PSTR("Layer"), false);
28 static char buffer[20] = {0}; 67 uint8_t layer = biton(layer_state);
29 snprintf(buffer, sizeof(buffer), " h%3d s%3d v%3d\n", rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val); 68 if (layer != _QWERTY)
30 oled_write(buffer, false); 69 render_layer(layer);
31#endif 70 else
71 render_layer(biton32(default_layer_state));
32 72
33 oled_write_P(mode_logo[1], false); 73 // Host Keyboard LED Status
74 uint8_t led_usb_state = host_keyboard_leds();
75 oled_write_P(led_usb_state & (1<<USB_LED_NUM_LOCK) ? PSTR("-----NUMLK") : PSTR("----- "), false);
76 oled_write_P(led_usb_state & (1<<USB_LED_CAPS_LOCK) ? PSTR("CAPLK") : PSTR(" "), false);
77 oled_write_P(led_usb_state & (1<<USB_LED_SCROLL_LOCK) ? PSTR("SCRLK") : PSTR(" "), false);
34 78
35#if defined(RGB_MATRIX_ENABLE) 79#if defined(RGB_MATRIX_ENABLE)
36 snprintf(buffer, sizeof(buffer), " s%3d m%3d\n", rgb_matrix_config.speed, rgb_matrix_config.mode); 80 oled_set_cursor(0, oled_max_lines() - 7);
81 oled_write_P(PSTR("-----"), false);
82 static char buffer[26] = {0};
83 snprintf(buffer, sizeof(buffer), "h%3d s%3d v%3d s%3d m%3d\n", rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val, rgb_matrix_config.speed, rgb_matrix_config.mode);
84 oled_write(buffer, false);
85#elif defined(RGBLIGHT_ENABLE)
86 oled_set_cursor(0, oled_max_lines() - 7);
87 oled_write_P(PSTR("-----"), false);
88 static char buffer[31] = {0};
89 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);
37 oled_write(buffer, false); 90 oled_write(buffer, false);
38#endif 91#endif
92}
39 93
40 // 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 94oled_rotation_t oled_init_user(oled_rotation_t rotation) {
41 oled_write_P(PSTR("Layer: "), false); 95 if (is_keyboard_master())
42 switch (biton32(layer_state)) 96 return OLED_ROTATION_270;
97 return OLED_ROTATION_180;
98}
99
100#else // OLED_90ROTATION
101
102static void render_layer(uint8_t layer)
103{
104 switch (layer)
43 { 105 {
44 case _QWERTY: 106 case _QWERTY:
45#ifndef GAMELAYER_DISABLE
46 switch (biton32(default_layer_state))
47 {
48 case _QWERTY:
49 oled_write_P(PSTR("Default\n"), false);
50 break;
51 case _GAME:
52 oled_write_P(PSTR("Game\n"), false);
53 break;
54 default:
55 oled_write_P(PSTR("Undefined\n"), false);
56 break;
57 }
58#else
59 oled_write_P(PSTR("Default\n"), false); 107 oled_write_P(PSTR("Default\n"), false);
60#endif
61 break; 108 break;
109#ifndef GAMELAYER_DISABLE
110 case _GAME:
111 oled_write_P(PSTR("Game\n"), false);
112 break;
113#endif
62 case _LOWER: 114 case _LOWER:
63 oled_write_P(PSTR("Lower\n"), false); 115 oled_write_P(PSTR("Lower\n"), false);
64 break; 116 break;
@@ -70,18 +122,60 @@ static void render_status(void)
70 oled_write_P(PSTR("Adjust\n"), false); 122 oled_write_P(PSTR("Adjust\n"), false);
71 break; 123 break;
72#endif 124#endif
73 default: 125 }
74 oled_write_P(PSTR("Undefined\n"), false); 126}
75 break; 127
76 } 128static void render_status(void)
129{
130 // Render to mode icon
131 static const char PROGMEM mode_logo[2][3] = {
132 {0x97,0x98,0},
133 {0xb7,0xb8,0}
134 };
135
136 oled_write_P(mode_logo[0], false);
137
138#if defined(RGB_MATRIX_ENABLE)
139 static char buffer[20] = {0};
140 snprintf(buffer, sizeof(buffer), " h%3d s%3d v%3d\n", rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val);
141 oled_write(buffer, false);
142#elif defined(RGBLIGHT_ENABLE)
143 static char buffer[20] = {0};
144 snprintf(buffer, sizeof(buffer), " h%3d s%3d v%3d\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
145 oled_write(buffer, false);
146#else
147 oled_write_P(PSTR("\n"));
148#endif
149
150 oled_write_P(mode_logo[1], false);
151
152#if defined(RGB_MATRIX_ENABLE)
153 snprintf(buffer, sizeof(buffer), " s%3d m%3d\n", rgb_matrix_config.speed, rgb_matrix_config.mode);
154 oled_write(buffer, false);
155#elif defined(RGBLIGHT_ENABLE)
156 snprintf(buffer, sizeof(buffer), " s%3d m%3d\n", rgblight_config.speed, rgblight_config.mode);
157 oled_write(buffer, false);
158#else
159 oled_write_P(PSTR("\n"));
160#endif
77 161
78 // Host Keyboard LED Status 162 // 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
163 oled_write_P(PSTR("Layer: "), false);
164 uint8_t layer = biton(layer_state);
165 if (layer != _QWERTY)
166 render_layer(layer);
167 else
168 render_layer(biton32(default_layer_state));
169
170 // Host Keyboard LED Status
79 uint8_t led_usb_state = host_keyboard_leds(); 171 uint8_t led_usb_state = host_keyboard_leds();
80 oled_write_P(led_usb_state & (1<<USB_LED_NUM_LOCK) ? PSTR("NUMLCK ") : PSTR(" "), false); 172 oled_write_P(led_usb_state & (1<<USB_LED_NUM_LOCK) ? PSTR("NUMLCK ") : PSTR(" "), false);
81 oled_write_P(led_usb_state & (1<<USB_LED_CAPS_LOCK) ? PSTR("CAPLCK ") : PSTR(" "), false); 173 oled_write_P(led_usb_state & (1<<USB_LED_CAPS_LOCK) ? PSTR("CAPLCK ") : PSTR(" "), false);
82 oled_write_P(led_usb_state & (1<<USB_LED_SCROLL_LOCK) ? PSTR("SCRLCK ") : PSTR(" "), false); 174 oled_write_P(led_usb_state & (1<<USB_LED_SCROLL_LOCK) ? PSTR("SCRLCK ") : PSTR(" "), false);
83} 175}
84 176
177#endif // OLED_90ROTATION
178
85void oled_task_user(void) 179void oled_task_user(void)
86{ 180{
87 if (is_keyboard_master()) 181 if (is_keyboard_master())