xenon.c (4271B)
1 /* Copyright 2020 Kyrre Havik Eriksen 2 * 3 * This program is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, either version 2 of the License, or 6 * (at your option) any later version. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 */ 16 #include "quantum.h" 17 18 #ifdef OLED_ENABLE 19 oled_rotation_t oled_init_kb(oled_rotation_t rotation) { 20 if (!is_keyboard_master()) { 21 return OLED_ROTATION_180; // flips the display 180 degrees if offhand 22 } 23 24 return OLED_ROTATION_270; 25 } 26 27 static void render_named_logo(void) { 28 static const char PROGMEM raw_logo[] = { 29 12, 60,252,252,252,236,236,140, 12, 28,248,192, 0,192,248,252,252,252,108, 12, 12,140,236, 60, 12, 0, 0, 0,248,252,252,252,236,204,204,204,204,204,204,204,204,204,204,204,204,140, 12,252,248, 0, 0, 0,252,252,252,252,236,236,236,204, 12, 60,240,192, 0, 0, 0,252,252,252,236,236, 12, 12, 12,252,248, 0, 0,192,224, 96, 48, 24, 24,140,140,132,196,196,196,196,132,140,140, 12, 24, 48, 48, 96,192,128, 0, 0,252,252,252,236,236,236,236,140, 28,120,224,128, 0, 0,252,252,252,252,236,236, 12, 12, 12,252, 30 0, 0, 0, 3, 15,255,255,255,254,248,192,195,223,255,255, 63, 15, 1,224,248, 30, 7, 1, 0, 0, 0, 0, 0,255,255,255,255,255,255, 0, 0, 1, 63, 63, 51, 51, 51, 51, 51, 51, 51,243, 3, 1, 0, 0, 0,255,255,255,255,255, 1, 15,127,255,252,240,195, 15, 60,240,255,255,255,255,255, 0, 0, 0,255,255,254,255,255,255,127, 14, 2,195,247, 63, 31, 15, 15, 15, 15, 31, 63,255,255,254,252,248,224, 1, 3, 30,252,255,255,255,255,255, 3, 31,255,254,248,225,135, 30,120,255,255,255,255,255,255, 0, 0, 0,255, 31 0, 0,128,240,252,255,255,255, 63, 7, 1,227,127,255,255,255,248,224, 1, 7, 62,240,192, 0, 0, 0, 0, 0,255,255,255,255,255,255, 1, 3, 7,255,255,207,207,207,207,207,206,204,207,192,128, 0, 0, 0,255,255,255,255,255, 0, 0, 0,255,255, 15,127,255,252,240,227,143,127,255,255, 0, 0, 0,255,255, 63,255,255,255,254,240,192,131,135, 12, 24, 48, 48, 48, 48, 24, 28, 15,159,255, 63, 31, 7,128,192,120, 31,255,255,255,255,255, 0, 0, 0,255,255, 31,127,255,252,241,199, 31,127,255,255, 0, 0, 0,255, 32 48, 62, 63, 63, 63, 63, 63, 56, 48, 60, 31, 3, 0, 3, 31, 63, 63, 63, 63, 60, 60, 56, 59, 63, 56, 0, 0, 0, 31, 63, 63, 63, 63, 63, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 56, 63, 31, 0, 0, 0, 63, 63, 63, 63, 63, 60, 56, 48, 63, 63, 0, 0, 0, 3, 31, 63, 63, 62, 61, 63, 60, 56, 48, 63, 31, 0, 0, 1, 7, 7, 15, 31, 31, 63, 63, 63, 62, 62, 62, 62, 63, 63, 63, 31, 31, 15, 14, 6, 3, 1, 0, 0, 63, 63, 63, 63, 63, 60, 56, 56, 63, 31, 0, 0, 1, 7, 31, 63, 63, 60, 63, 63, 60, 56, 48, 63 33 }; 34 oled_write_raw_P(raw_logo, sizeof(raw_logo)); 35 } 36 37 static void render_status(void) { 38 oled_write_P(PSTR("\n\n\n-----\nXENON\n-----\n\n"), false); 39 40 // Host Keyboard Layer Status 41 switch (get_highest_layer(layer_state)) { 42 case 0: 43 oled_write_P(PSTR("Base \n"), false); 44 break; 45 case 1: 46 oled_write_P(PSTR("Lower\n"), false); 47 break; 48 case 2: 49 oled_write_P(PSTR("Raise\n"), false); 50 break; 51 default: 52 oled_write_P(PSTR("Undef\n"), false); 53 } 54 oled_write_P(PSTR("Layer\n"), false); 55 } 56 57 bool oled_task_kb(void) { 58 if (!oled_task_user()) { 59 return false; 60 } 61 62 if (is_keyboard_master()) { 63 render_status(); // Renders the current keyboard state (layer, lock, caps, scroll, etc) 64 } else { 65 render_named_logo(); 66 } 67 68 return true; 69 } 70 #endif 71 72 #ifdef ENCODER_ENABLE 73 bool encoder_update_kb(uint8_t index, bool clockwise) { 74 if (!encoder_update_user(index, clockwise)) { 75 return false; 76 } 77 78 if (index == 0) { 79 // Volume control 80 if (clockwise) { 81 tap_code(KC_VOLD); 82 } else { 83 tap_code(KC_VOLU); 84 } 85 } 86 else if (index == 1) { 87 // Page up/Page down 88 if (clockwise) { 89 tap_code(KC_PGDN); 90 } else { 91 tap_code(KC_PGUP); 92 } 93 } 94 95 return true; 96 } 97 #endif