aboutsummaryrefslogtreecommitdiff
path: root/keyboards/sol/keymaps/brianweyer/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/sol/keymaps/brianweyer/keymap.c')
-rwxr-xr-xkeyboards/sol/keymaps/brianweyer/keymap.c146
1 files changed, 54 insertions, 92 deletions
diff --git a/keyboards/sol/keymaps/brianweyer/keymap.c b/keyboards/sol/keymaps/brianweyer/keymap.c
index 2259e246d..9fd6ad615 100755
--- a/keyboards/sol/keymaps/brianweyer/keymap.c
+++ b/keyboards/sol/keymaps/brianweyer/keymap.c
@@ -3,9 +3,6 @@
3#include "lufa.h" 3#include "lufa.h"
4#include "split_util.h" 4#include "split_util.h"
5#endif 5#endif
6#ifdef SSD1306OLED
7 #include "common/ssd1306.h"
8#endif
9 6
10extern keymap_config_t keymap_config; 7extern keymap_config_t keymap_config;
11 8
@@ -175,38 +172,28 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
175} 172}
176 173
177void matrix_init_user(void) { 174void matrix_init_user(void) {
178 #ifdef RGBLIGHT_ENABLE 175#ifdef RGBLIGHT_ENABLE
179 RGB_current_mode = rgblight_config.mode; 176 RGB_current_mode = rgblight_config.mode;
180 #endif 177#endif
181 //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h
182 #ifdef SSD1306OLED
183 iota_gfx_init(!has_usb()); // turns on the display
184 #endif
185} 178}
186 179
187void matrix_scan_user(void) {
188 #ifdef SSD1306OLED
189 // led_test_init();
190 iota_gfx_task(); // this is what updates the display continuously
191 #endif
192}
193 180
181// OLED Driver Logic
182#ifdef OLED_DRIVER_ENABLE
194 183
195//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h 184uint8_t oled_init_user(uint8_t rotation) {
196#ifdef SSD1306OLED 185 if (!has_usb())
186 return OLED_ROTATION_180; // flip 180 for offhand
187 return rotation;
188}
197 189
198// hook point for 'led_test' keymap 190static void render_logo(void) {
199// 'default' keymap's led_test_init() is empty function, do nothing 191 static const char PROGMEM sol_logo[] = {
200// 'led_test' keymap's led_test_init() force rgblight_mode_noeeprom(35); 192 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
201__attribute__ ((weak)) 193 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
202void led_test_init(void) {} 194 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0};
203 195
204void matrix_update(struct CharacterMatrix *dest, 196 oled_write_P(sol_logo, false);
205 const struct CharacterMatrix *source) {
206 if (memcmp(dest->display, source->display, sizeof(dest->display))) {
207 memcpy(dest->display, source->display, sizeof(dest->display));
208 dest->dirty = true;
209 }
210} 197}
211 198
212//assign the right code to your layers for OLED display 199//assign the right code to your layers for OLED display
@@ -215,77 +202,52 @@ void matrix_update(struct CharacterMatrix *dest,
215#define L_ADJ (1<<_ADJ) 202#define L_ADJ (1<<_ADJ)
216#define L_ADJ_TRI (L_ADJ|L_FN) 203#define L_ADJ_TRI (L_ADJ|L_FN)
217 204
218static void render_logo(struct CharacterMatrix *matrix) { 205static void render_status(void) {
219
220 static char logo[]={
221 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
222 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
223 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,
224 0};
225 matrix_write(matrix, logo);
226}
227
228
229
230void render_status(struct CharacterMatrix *matrix) {
231
232 // Render to mode icon 206 // Render to mode icon
233 static char logo[][2][3]={{{0x95,0x96,0},{0xb5,0xb6,0}},{{0x97,0x98,0},{0xb7,0xb8,0}}}; 207 static const char PROGMEM mode_logo[4][4] = {
234 if(keymap_config.swap_lalt_lgui==false){ 208 {0x95,0x96,0x0a,0},
235 matrix_write(matrix, logo[0][0]); 209 {0xb5,0xb6,0x0a,0},
236 matrix_write_P(matrix, PSTR("\n")); 210 {0x97,0x98,0x0a,0},
237 matrix_write(matrix, logo[0][1]); 211 {0xb7,0xb8,0x0a,0} };
238 }else{ 212
239 matrix_write(matrix, logo[1][0]); 213 if (keymap_config.swap_lalt_lgui != false) {
240 matrix_write_P(matrix, PSTR("\n")); 214 oled_write_P(mode_logo[0], false);
241 matrix_write(matrix, logo[1][1]); 215 oled_write_P(mode_logo[1], false);
216 } else {
217 oled_write_P(mode_logo[2], false);
218 oled_write_P(mode_logo[3], false);
242 } 219 }
243 220
244 // 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 221 // 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
245 char buf[40]; 222
246 snprintf(buf,sizeof(buf), "Undef-%ld", layer_state); 223 oled_write_P(PSTR("Layer: "), false);
247 matrix_write_P(matrix, PSTR("\nLayer: ")); 224 switch (layer_state) {
248 switch (layer_state) { 225 case L_BASE:
249 case L_BASE: 226 oled_write_P(PSTR("Laser \n"), false);
250 matrix_write_P(matrix, PSTR("Laser")); 227 break;
251 break; 228 case L_FN:
252 case L_FN: 229 oled_write_P(PSTR("Function \n"), false);
253 matrix_write_P(matrix, PSTR("Function")); 230 break;
254 break; 231 case L_ADJ:
255 case L_ADJ: 232 case L_ADJ_TRI:
256 case L_ADJ_TRI: 233 oled_write_P(PSTR("Adjustment\n"), false);
257 matrix_write_P(matrix, PSTR("Adjustment")); 234 break;
258 break; 235 default:
259 default: 236 oled_write_P(PSTR("Undefined \n"), false);
260 matrix_write(matrix, buf); 237 }
261 }
262 238
263 // Host Keyboard LED Status 239 // Host Keyboard LED Status
264 char led[40]; 240 uint8_t led_usb_state = host_keyboard_leds();
265 snprintf(led, sizeof(led), "\n%s %s %s", 241 oled_write_P(led_usb_state & (1<<USB_LED_NUM_LOCK) ? PSTR("NUMLOCK ") : PSTR(" "), false);
266 (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ", 242 oled_write_P(led_usb_state & (1<<USB_LED_CAPS_LOCK) ? PSTR("CAPS ") : PSTR(" "), false);
267 (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ", 243 oled_write_P(led_usb_state & (1<<USB_LED_SCROLL_LOCK) ? PSTR("SCLK ") : PSTR(" "), false);
268 (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " ");
269 matrix_write(matrix, led);
270} 244}
271 245
272 246void oled_task_user(void) {
273void iota_gfx_task_user(void) { 247 if (is_master)
274 struct CharacterMatrix matrix; 248 render_status();
275 249 else
276#if DEBUG_TO_SCREEN 250 render_logo();
277 if (debug_enable) {
278 return;
279 }
280#endif
281
282 matrix_clear(&matrix);
283 if(is_master){
284 render_status(&matrix);
285 }else{
286 render_logo(&matrix);
287 }
288 matrix_update(&display, &matrix);
289} 251}
290 252
291#endif 253#endif