mirrored.c (2620B)
1 // Copyright 2022 Kyle McCreery (@Kyle McCreery) 2 // SPDX-License-Identifier: GPL-2.0-or-later 3 4 #include "quantum.h" 5 6 #ifdef ENCODER_ENABLE 7 bool encoder_update_kb(uint8_t index, bool clockwise) { 8 if (!encoder_update_user(index, clockwise)) { return false; } 9 switch (index) { 10 case 0: 11 if (clockwise) { 12 tap_code(KC_VOLU); 13 } else { 14 tap_code(KC_VOLD); 15 } 16 break; 17 case 1: 18 if (clockwise) { 19 tap_code(KC_PGUP); 20 } else { 21 tap_code(KC_PGDN); 22 } 23 break; 24 25 } 26 return true; 27 } 28 #endif 29 30 #ifdef OLED_ENABLE 31 oled_rotation_t oled_init_kb(oled_rotation_t rotation) { 32 return OLED_ROTATION_270; // flips the display 270 degrees 33 } 34 35 static void render_logo(void) { // Render MechWild "MW" Logo 36 static const char PROGMEM logo_1[] = {0x8A, 0x8B, 0x8C, 0x8D, 0x00}; 37 static const char PROGMEM logo_2[] = {0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0x00}; 38 static const char PROGMEM logo_3[] = {0xCA, 0xCB, 0xCC, 0xCD, 0x00}; 39 static const char PROGMEM logo_4[] = {0x20, 0x8E, 0x8F, 0x90, 0x00}; 40 oled_set_cursor(0,0); 41 oled_write_P(logo_1, false); 42 oled_set_cursor(0,1); 43 oled_write_P(logo_2, false); 44 oled_set_cursor(0,2); 45 oled_write_P(logo_3, false); 46 oled_set_cursor(0,3); 47 oled_write_P(logo_4, false); 48 } 49 bool oled_task_kb(void) { 50 if (!oled_task_user()) { 51 return false; 52 } 53 render_logo(); 54 oled_set_cursor(0,6); 55 56 oled_write_ln_P(PSTR("Layer"), false); 57 58 switch (get_highest_layer(layer_state)) { 59 case 0: 60 oled_write_ln_P(PSTR("Base"), false); 61 break; 62 case 1: 63 oled_write_ln_P(PSTR("FN 1"), false); 64 break; 65 case 2: 66 oled_write_ln_P(PSTR("FN 2"), false); 67 break; 68 case 3: 69 oled_write_ln_P(PSTR("FN 3"), false); 70 break; 71 default: 72 oled_write_ln_P(PSTR("Undef"), false); 73 } 74 oled_write_ln_P(PSTR(""), false); 75 // Host Keyboard LED Status 76 led_t led_state = host_keyboard_led_state(); 77 oled_write_ln_P(led_state.num_lock ? PSTR("NUM ") : PSTR(" "), false); 78 oled_write_ln_P(led_state.caps_lock ? PSTR("CAP ") : PSTR(" "), false); 79 oled_write_ln_P(led_state.scroll_lock ? PSTR("SCR ") : PSTR(" "), false); 80 return false; 81 } 82 #endif