aboutsummaryrefslogtreecommitdiff
path: root/keyboards/terrazzo/terrazzo_effects/outrun.h
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/terrazzo/terrazzo_effects/outrun.h')
-rw-r--r--keyboards/terrazzo/terrazzo_effects/outrun.h127
1 files changed, 127 insertions, 0 deletions
diff --git a/keyboards/terrazzo/terrazzo_effects/outrun.h b/keyboards/terrazzo/terrazzo_effects/outrun.h
new file mode 100644
index 000000000..b4455ef49
--- /dev/null
+++ b/keyboards/terrazzo/terrazzo_effects/outrun.h
@@ -0,0 +1,127 @@
1/* Copyright 2020 ademey "MsMustard"
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#ifndef DISABLE_TERRAZZO_EFFECT_OUTRUN
18TERRAZZO_EFFECT(OUTRUN)
19# ifdef TERRAZZO_EFFECT_IMPLS
20
21static uint8_t outrun_sun[25] = {
22 0, 9, 9, 9, 0,
23 7, 7, 7, 7, 7,
24 4, 4, 4, 4, 4,
25 2, 2, 2, 2, 2,
26 0, 1, 1, 1, 0
27};
28
29static uint8_t outrun_ground[63] = {
30 0, 0, 1, 1, 1, 0, 0,
31 0, 2, 0, 2, 0, 2, 0,
32 0, 2, 0, 2, 0, 2, 0,
33 0, 2, 0, 4, 0, 2, 0,
34 2, 0, 0, 5, 0, 0, 2,
35 2, 0, 0, 5, 0, 0, 2,
36 2, 0, 0, 6, 0, 0, 2,
37 0, 0, 0, 7, 0, 0, 0,
38 0, 0, 0, 8, 0, 0, 0
39};
40
41static uint8_t outrun_rows[4][63] = {
42{
43 1, 1, 1, 1, 1, 1, 1,
44 0, 0, 0, 0, 0, 0, 0,
45 2, 2, 2, 2, 2, 2, 2,
46 0, 0, 0, 0, 0, 0, 0,
47 0, 0, 0, 0, 0, 0, 0,
48 4, 4, 4, 4, 4, 4, 4,
49 0, 0, 0, 0, 0, 0, 0,
50 0, 0, 0, 0, 0, 0, 0,
51 0, 0, 0, 0, 0, 0, 0
52},
53{
54 0, 0, 0, 0, 0, 0, 0,
55 1, 1, 1, 1, 1, 1, 1,
56 0, 0, 0, 0, 0, 0, 0,
57 2, 2, 2, 2, 2, 2, 2,
58 0, 0, 0, 0, 0, 0, 0,
59 0, 0, 0, 0, 0, 0, 0,
60 4, 4, 4, 4, 4, 4, 4,
61 0, 0, 0, 0, 0, 0, 0,
62 0, 0, 0, 0, 0, 0, 0
63},
64{
65 1, 1, 1, 1, 1, 1, 1,
66 0, 0, 0, 0, 0, 0, 0,
67 2, 2, 2, 2, 2, 2, 2,
68 0, 0, 0, 0, 0, 0, 0,
69 4, 4, 4, 4, 4, 4, 4,
70 0, 0, 0, 0, 0, 0, 0,
71 0, 0, 0, 0, 0, 0, 0,
72 9, 9, 9, 9, 9, 9, 9,
73 0, 0, 0, 0, 0, 0, 0
74},
75{
76 0, 0, 0, 0, 0, 0, 0,
77 1, 1, 1, 1, 1, 1, 1,
78 0, 0, 0, 0, 0, 0, 0,
79 2, 2, 2, 2, 2, 2, 2,
80 0, 0, 0, 0, 0, 0, 0,
81 4, 4, 4, 4, 4, 4, 4,
82 0, 0, 0, 0, 0, 0, 0,
83 0, 0, 0, 0, 0, 0, 0,
84 9, 9, 9, 9, 9, 9, 9
85}
86};
87
88bool last_dir;
89uint8_t change_index = 0;
90
91void OUTRUN(uint8_t i, bool dir) {
92 led_matrix_set_index_value_all(0);
93
94 if(dir != last_dir) {
95 change_index = i;
96 }
97
98 uint8_t change_diff = abs(i - change_index);
99 uint8_t horz_bright = 9;
100
101 if(change_diff < 4) {
102 if (dir) {
103 terrazzo_draw_at(1, 4 - change_diff, 5, 1 + change_diff, outrun_sun);
104 horz_bright = 3 + change_diff;
105 } else {
106 terrazzo_draw_at(1, 0 + change_diff, 5, 5 - change_diff, outrun_sun);
107 horz_bright = 5 - change_diff;
108 }
109 } else {
110 if (dir) {
111 terrazzo_draw_at(1, 0, 5, 5, outrun_sun);
112 } else {
113 horz_bright = 1;
114 }
115 }
116
117 for(int x = 0; x < 7; x++){
118 terrazzo_set_pixel(x, 5, horz_bright);
119 }
120 // Sun is larger but render the top 3 rows only
121 terrazzo_draw_at(0, 6, 7, 10, outrun_ground);
122 terrazzo_draw_at(0, 6, 7, 10, outrun_rows[i % 4]);
123 last_dir = dir;
124}
125
126# endif
127#endif \ No newline at end of file