pi40.c (11716B)
1 /* Copyright 2022 ziptyze 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 17 #include "quantum.h" 18 19 #ifdef OLED_ENABLE 20 21 static uint32_t oled_logo_timer = 0; 22 static bool clear_logo = true; 23 static const char PROGMEM my_logo[] = { 24 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 25 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 26 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 27 0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f, 28 0x0f, 0x0f, 0x0f, 0x1f, 0xff, 0xff, 0xff, 0x1f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 29 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x00, 30 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 31 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 32 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 33 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 34 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 35 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 36 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 37 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 38 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 39 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 40 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 41 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 42 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 43 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 44 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 45 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 46 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 47 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 48 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 49 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 50 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 51 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xfb, 52 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 53 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 54 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 55 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 56 }; 57 58 #endif 59 60 #ifdef OLED_ENABLE 61 62 void init_timer(void){ 63 oled_logo_timer = timer_read32(); 64 }; 65 66 void user_oled_magic(void) { 67 // Host Keyboard Layer Status 68 oled_write_P(PSTR("Layer: "), false); 69 70 switch (get_highest_layer(layer_state)) { 71 case 0: 72 oled_write_P(PSTR("One\n"), false); 73 break; 74 case 1: 75 oled_write_P(PSTR("Two\n"), false); 76 break; 77 case 2: 78 oled_write_P(PSTR("Three\n"), false); 79 break; 80 case 3: 81 oled_write_P(PSTR("Four\n"), false); 82 break; 83 case 4: 84 oled_write_P(PSTR("Five\n"), false); 85 break; 86 case 5: 87 oled_write_P(PSTR("Six\n"), false); 88 break; 89 case 6: 90 oled_write_P(PSTR("Seven\n"), false); 91 break; 92 case 7: 93 oled_write_P(PSTR("Eight\n"), false); 94 break; 95 case 8: 96 oled_write_P(PSTR("Nine\n"), false); 97 break; 98 case 9: 99 oled_write_P(PSTR("Ten\n"), false); 100 break; 101 default: 102 // Or use the write_ln shortcut over adding '\n' to the end of your string 103 oled_write_ln_P(PSTR("Undefined"), false); 104 } 105 106 // Host Keyboard LED Status 107 led_t led_state = host_keyboard_led_state(); 108 oled_write_P(led_state.caps_lock ? PSTR("Cap(x) ") : PSTR("Cap( ) "), false); 109 oled_write_P(led_state.num_lock ? PSTR("Num(x) ") : PSTR("Num( ) "), false); 110 oled_write_P(led_state.scroll_lock ? PSTR("Scrl(x)") : PSTR("Scrl( )"), false); 111 112 113 switch (rgb_matrix_get_mode()) { 114 case 1: 115 oled_write_P(PSTR("Solid Color\n "), false); 116 break; 117 case 2: 118 oled_write_P(PSTR("Alphas Mods\n "), false); 119 break; 120 case 3: 121 oled_write_P(PSTR("Gradient Up Down\n "), false); 122 break; 123 case 4: 124 oled_write_P(PSTR("Gradient Left Right\n "), false); 125 break; 126 case 5: 127 oled_write_P(PSTR("Breathing\n "), false); 128 break; 129 case 6: 130 oled_write_P(PSTR("Band Sat\n "), false); 131 break; 132 case 7: 133 oled_write_P(PSTR("Band Val\n "), false); 134 break; 135 case 8: 136 oled_write_P(PSTR("Band Pinwheel Sat\n "), false); 137 break; 138 case 9: 139 oled_write_P(PSTR("Band Pinwheel Val\n "), false); 140 break; 141 case 10: 142 oled_write_P(PSTR("Band Spiral Sat\n "), false); 143 break; 144 case 11: 145 oled_write_P(PSTR("Band Spiral Val\n "), false); 146 break; 147 case 12: 148 oled_write_P(PSTR("Cycle All\n "), false); 149 break; 150 case 13: 151 oled_write_P(PSTR("Cycle Left Right\n "), false); 152 break; 153 case 14: 154 oled_write_P(PSTR("Cycle Up Down\n "), false); 155 break; 156 case 15: 157 oled_write_P(PSTR("Rainbow\nMoving Chevron "), false); 158 break; 159 case 16: 160 oled_write_P(PSTR("Cycle Out In\n "), false); 161 break; 162 case 17: 163 oled_write_P(PSTR("Cycle Out In Dual\n "), false); 164 break; 165 case 18: 166 oled_write_P(PSTR("Cycle Pinwheel\n "), false); 167 break; 168 case 19: 169 oled_write_P(PSTR("Cycle Spiral\n "), false); 170 break; 171 case 20: 172 oled_write_P(PSTR("Dual Beacon\n "), false); 173 break; 174 case 21: 175 oled_write_P(PSTR("Rainbow Beacon\n "), false); 176 break; 177 case 22: 178 oled_write_P(PSTR("Rainbow Pinwheels\n "), false); 179 break; 180 case 23: 181 oled_write_P(PSTR("Raindrops\n "), false); 182 break; 183 case 24: 184 oled_write_P(PSTR("Jellybean Raindrops\n "), false); 185 break; 186 case 25: 187 oled_write_P(PSTR("Hue Breathing\n "), false); 188 break; 189 case 26: 190 oled_write_P(PSTR("Hue Pendulum\n "), false); 191 break; 192 case 27: 193 oled_write_P(PSTR("Hue Wave\n "), false); 194 break; 195 case 28: 196 oled_write_P(PSTR("Pixel Rain\n "), false); 197 break; 198 case 29: 199 oled_write_P(PSTR("Pixel Flow\n "), false); 200 break; 201 case 30: 202 oled_write_P(PSTR("Pixel Fractal\n "), false); 203 break; 204 case 31: 205 oled_write_P(PSTR("Typing Heatmap\n "), false); 206 break; 207 case 32: 208 oled_write_P(PSTR("Digital Rain\n "), false); 209 break; 210 case 33: 211 oled_write_P(PSTR("Solid Reactive\nSimple "), false); 212 break; 213 case 34: 214 oled_write_P(PSTR("Solid Reactive\n "), false); 215 break; 216 case 35: 217 oled_write_P(PSTR("Solid Reactive\nWide "), false); 218 break; 219 case 36: 220 oled_write_P(PSTR("Solid Reactive\nMultiwide "), false); 221 break; 222 case 37: 223 oled_write_P(PSTR("Solid Reactive\nCross "), false); 224 break; 225 case 38: 226 oled_write_P(PSTR("Solid Reactive\nMulticross "), false); 227 break; 228 case 39: 229 oled_write_P(PSTR("Solid Reactive\nNexus "), false); 230 break; 231 case 40: 232 oled_write_P(PSTR("Solid Reactive\nMultinexus "), false); 233 break; 234 case 41: 235 oled_write_P(PSTR("Splash\n "), false); 236 break; 237 case 42: 238 oled_write_P(PSTR("Multisplash\n "), false); 239 break; 240 case 43: 241 oled_write_P(PSTR("Solid Splash\n "), false); 242 break; 243 case 44: 244 oled_write_P(PSTR("Solid Multisplash\n "), false); 245 break; 246 default: 247 // Or use the write_ln shortcut over adding '\n' to the end of your string 248 oled_write_ln_P(PSTR("Undefined\n "), false); 249 } 250 251 } 252 253 void render_logo(void) { 254 oled_write_raw_P(my_logo, sizeof(my_logo)); 255 } 256 257 void clear_screen(void) { 258 if (clear_logo){ 259 for (uint8_t i = 0; i < OLED_DISPLAY_HEIGHT; ++i) { 260 for (uint8_t j = 0; j < OLED_DISPLAY_WIDTH; ++j) { 261 oled_write_raw_byte(0x0, i*OLED_DISPLAY_WIDTH + j); 262 } 263 } 264 clear_logo = false; 265 } 266 } 267 268 oled_rotation_t oled_init_kb(oled_rotation_t rotation) { 269 return OLED_ROTATION_180; 270 } 271 272 void keyboard_post_init_kb(void) { 273 init_timer(); 274 275 keyboard_post_init_user(); 276 } 277 278 # define SHOW_LOGO 5000 279 bool oled_task_kb(void) { 280 if (!oled_task_user()) { return false; } 281 if ((timer_elapsed32(oled_logo_timer) < SHOW_LOGO)){ 282 render_logo(); 283 }else{ 284 clear_screen(); 285 user_oled_magic(); 286 } 287 return false; 288 } 289 290 #endif