diff options
Diffstat (limited to 'keyboards/lily58/keymaps/druotoni/navi_logo.c')
| -rw-r--r-- | keyboards/lily58/keymaps/druotoni/navi_logo.c | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/keyboards/lily58/keymaps/druotoni/navi_logo.c b/keyboards/lily58/keymaps/druotoni/navi_logo.c new file mode 100644 index 000000000..6041aa5eb --- /dev/null +++ b/keyboards/lily58/keymaps/druotoni/navi_logo.c | |||
| @@ -0,0 +1,117 @@ | |||
| 1 | // Copyright 2021 Nicolas Druoton (druotoni) | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include QMK_KEYBOARD_H | ||
| 5 | |||
| 6 | #include "gui_state.h" | ||
| 7 | #include "navi_logo.h" | ||
| 8 | #include "fast_random.h" | ||
| 9 | #include "draw_helper.h" | ||
| 10 | |||
| 11 | #define LOGO_SIZE 128 | ||
| 12 | |||
| 13 | // glitch stuff | ||
| 14 | #define GLITCH_FRAME_NUMBER 11 | ||
| 15 | |||
| 16 | uint8_t current_glitch_index = 0; | ||
| 17 | int current_glitch_time = 150; | ||
| 18 | uint32_t glitch_timer = 0; | ||
| 19 | |||
| 20 | static void render_logo_clean(void) { | ||
| 21 | // your logo here | ||
| 22 | static const char PROGMEM raw_logo[] = { | ||
| 23 | 0, 0, 0, 0, 0, 0, 128, 128, 0, 0, 128, 128, 192, 192, 204, 222, 222, 204, 192, 192, 128, 0, 0, 0, 128, 128, 0, 0, 0, 0, 0, 0, 192, 240, 248, 28, 14, 7, 3, 249, 252, 255, 15, 7, 3, 225, 241, 241, 241, 241, 225, 3, 7, 15, 255, 252, 249, 3, 7, 14, 28, 248, 240, 192, 192, 227, 231, 206, 28, 56, 112, 99, 15, 31, 60, 120, 240, 225, 227, 3, 3, 227, 225, 240, 120, 60, 31, 15, 103, 112, 56, 28, 206, 231, 227, 192, 0, 1, 1, 0, 0, 0, 56, 120, 96, 192, 192, 192, 96, 127, 63, 0, 0, 63, 127, 96, 192, 192, 192, 96, 120, 56, 0, 0, 0, 1, 1, 0, | ||
| 24 | }; | ||
| 25 | oled_write_raw_P(raw_logo, sizeof(raw_logo)); | ||
| 26 | } | ||
| 27 | |||
| 28 | void render_glitch_bar(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t iProb) { | ||
| 29 | // random horizontal scanlines | ||
| 30 | for (uint8_t i = 0; i < height; i++) { | ||
| 31 | bool bGenerateGlitch = (fastrand() % 100) < iProb; | ||
| 32 | |||
| 33 | if (bGenerateGlitch) { | ||
| 34 | drawline_hr(x, y + i, width, true); | ||
| 35 | } | ||
| 36 | } | ||
| 37 | } | ||
| 38 | |||
| 39 | void render_misc_glitch(uint8_t algo) { | ||
| 40 | char c = 0; | ||
| 41 | switch (algo) { | ||
| 42 | case 7: | ||
| 43 | // invert | ||
| 44 | for (uint8_t i = 0; i < LOGO_SIZE; i++) { | ||
| 45 | c = get_oled_char(i); | ||
| 46 | oled_write_raw_byte(~(c), i); | ||
| 47 | } | ||
| 48 | break; | ||
| 49 | |||
| 50 | case 8: | ||
| 51 | // wobble | ||
| 52 | for (uint8_t i = 0; i < LOGO_SIZE; i++) { | ||
| 53 | if (i < LOGO_SIZE - 1) { | ||
| 54 | copy_pixel(i + 1, -1, 85); | ||
| 55 | |||
| 56 | copy_pixel(LOGO_SIZE - 1 - 1 - i, 1, 170); | ||
| 57 | } | ||
| 58 | } | ||
| 59 | break; | ||
| 60 | } | ||
| 61 | } | ||
| 62 | |||
| 63 | static void render_logo_glitch(void) { | ||
| 64 | #ifdef WITH_GLITCH | ||
| 65 | // get a random glitch index | ||
| 66 | uint8_t glitch_prob = get_glitch_probability(); | ||
| 67 | get_glitch_index(&glitch_timer, ¤t_glitch_time, ¤t_glitch_index, 0, 150, glitch_prob, GLITCH_FRAME_NUMBER); | ||
| 68 | |||
| 69 | // no glitch | ||
| 70 | if (current_glitch_index <= 3) { | ||
| 71 | render_logo_clean(); | ||
| 72 | return; | ||
| 73 | } | ||
| 74 | |||
| 75 | // glitch time ! | ||
| 76 | switch (current_glitch_index) { | ||
| 77 | case 4: | ||
| 78 | move_block(1, 11, 24, 3, 5); | ||
| 79 | move_block(2, 19, 14, 3, 4); | ||
| 80 | move_block(9, 22, 7, 4, 4); | ||
| 81 | return; | ||
| 82 | |||
| 83 | case 5: | ||
| 84 | move_block(6, 25, 20, 7, 4); | ||
| 85 | move_block(0, 8, 32, 8, 7); | ||
| 86 | return; | ||
| 87 | case 6: | ||
| 88 | move_block(3, 7, 27, 4, -3); | ||
| 89 | move_block(13, 23, 19, 4, -4); | ||
| 90 | return; | ||
| 91 | |||
| 92 | case 7: | ||
| 93 | case 8: | ||
| 94 | render_misc_glitch(current_glitch_index); | ||
| 95 | return; | ||
| 96 | |||
| 97 | case 9: | ||
| 98 | render_glitch_bar(0, 0, 32, 32, 25); | ||
| 99 | return; | ||
| 100 | |||
| 101 | case 10: | ||
| 102 | draw_static(0, 0, 32, 32, true, 0); | ||
| 103 | return; | ||
| 104 | } | ||
| 105 | #endif | ||
| 106 | } | ||
| 107 | |||
| 108 | void render_logo(gui_state_t t) { | ||
| 109 | if (t == _IDLE) { | ||
| 110 | // on idle : glitch time ! | ||
| 111 | render_logo_glitch(); | ||
| 112 | return; | ||
| 113 | } | ||
| 114 | |||
| 115 | // standart logo | ||
| 116 | render_logo_clean(); | ||
| 117 | } | ||
