/* Copyright 2023 Justine Smithies * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "quantum.h" #ifdef OLED_ENABLE static uint32_t oled_logo_timer = 0; static bool clear_logo = true; static const char PROGMEM my_logo[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,193,193, 1, 1,193,193, 1, 1, 1, 1, 1, 1,193,193, 1, 1, 1, 1,193,193,193,193,193,193, 1, 1, 1, 1,255, 0, 0, 0, 0,192,192,192,192,192,192, 0, 0, 0, 0,192,192,192,192,192,192, 0, 0, 0, 0,192,192,192,192, 0, 0, 0, 0, 0, 0,192,192,192,192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255, 0, 0, 0, 0, 48, 48,192,192,192,192, 63, 63, 0, 0,255,255, 3, 3, 12, 12, 3, 3,255,255, 0, 0,195,195,204,204,204,204, 48, 48, 0, 0, 0, 0,255, 0, 0, 0, 0,255,255, 12, 12, 12, 12, 3, 3, 0, 0,192,192,255,255,192,192, 0, 0, 63, 63,192,192,192,192, 51, 51, 0, 0, 63, 63,192,192,192,192, 63, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255, 0, 0, 0, 0, 12, 12, 12, 12,252,252, 12, 12, 12, 12, 0, 0,252,252,192,192, 48, 48, 12, 12, 0, 0,252,252, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255, 0, 0, 0, 0,252,252,204,204,204,204, 48, 48, 0, 0,240,240, 12, 12, 12, 12,240,240, 0, 0,252,252, 0, 0,192,192, 0, 0,252,252, 0, 0,252,252,204,204,204,204, 12, 12, 0, 0,252,252,204,204,204,204, 48, 48, 0, 0,252,252,204,204,204,204, 12, 12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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #endif #ifdef OLED_ENABLE void init_timer(void){ oled_logo_timer = timer_read32(); }; void user_oled_magic(void) { // Host Keyboard Layer Status oled_write_P(PSTR("Layer: "), false); switch (get_highest_layer(layer_state)) { case 0: oled_write_P(PSTR("0\n"), false); break; case 1: oled_write_P(PSTR("1\n"), false); break; default: // Or use the write_ln shortcut over adding '\n' to the end of your string oled_write_ln_P(PSTR("Undefined"), false); } oled_write_P(PSTR("\n"), false); // Host Keyboard LED Status led_t led_state = host_keyboard_led_state(); //oled_write_P(led_state.num_lock ? PSTR("NUM ") : PSTR(" "), false); oled_write_P(PSTR("Caps lock: "), false); oled_write_P(led_state.caps_lock ? PSTR("On ") : PSTR("Off"), false); oled_write_P(PSTR("\n"), false); oled_write_P(PSTR("Scroll lock: "), false); oled_write_P(led_state.scroll_lock ? PSTR("On ") : PSTR("Off"), false); #ifdef WPM_ENABLE static char wpm_str[10]; // Write WPM oled_write_P(PSTR("\n"), false); sprintf(wpm_str, "WPM: %03d", get_current_wpm()); oled_write_P(PSTR("\n"), false); oled_write(wpm_str, false); #endif } void render_logo(void) { oled_write_raw_P(my_logo, sizeof(my_logo)); } void clear_screen(void) { if (clear_logo){ for (uint8_t i = 0; i < OLED_DISPLAY_HEIGHT; ++i) { for (uint8_t j = 0; j < OLED_DISPLAY_WIDTH; ++j) { oled_write_raw_byte(0x0, i*OLED_DISPLAY_WIDTH + j); } } clear_logo = false; } } void keyboard_post_init_kb(void) { init_timer(); keyboard_post_init_user(); } # define SHOW_LOGO 5000 bool oled_task_kb(void) { if (!oled_task_user()) { return false; } if ((timer_elapsed32(oled_logo_timer) < SHOW_LOGO)){ render_logo(); }else{ clear_screen(); user_oled_magic(); } return false; } #endif