summaryrefslogtreecommitdiff
path: root/keyboards/terrazzo/terrazzo_effects/wpm_chart.h
blob: 5c66bc39ad7a6b16bde03d852c263848ce5dae56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/* Copyright 2020 ademey "MsMustard"
 *
 * 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 <http://www.gnu.org/licenses/>.
 */

#ifndef DISABLE_TERRAZZO_EFFECT_WPM_CHART
TERRAZZO_EFFECT(WPM_CHART)
#   ifdef TERRAZZO_EFFECT_IMPLS

static uint8_t number_3_4[10][12] = {
{ // 0
    9, 9, 9,
    9, 0, 9,
    9, 0, 9,
    9, 9, 9
}, 
{ // 1
    0, 9, 0,
    9, 9, 0,
    0, 9, 0,
    9, 9, 9
},
{ // 2
    9, 9, 0,
    0, 0, 9,
    0, 9, 0,
    9, 9, 9
},
{ // 3
    9, 9, 9,
    0, 9, 0,
    0, 0, 9,
    9, 9, 0
},
{ // 4
    9, 0, 9,
    9, 0, 9,
    9, 9, 9,
    0, 0, 9
},
{ // 5
    9, 9, 9,
    9, 9, 0,
    0, 0, 9,
    9, 9, 9
},
{ // 6
    0, 0, 9,
    0, 9, 0,
    9, 0, 9,
    0, 9, 0
},
{ // 7
    9, 9, 9,
    0, 0, 9,
    0, 9, 0,
    9, 0, 0
},
{ // 8
    9, 9, 9,
    9, 0, 9,
    9, 4, 9,
    9, 9, 9
},
{ // 9
    9, 9, 9,
    9, 0, 9,
    9, 9, 9,
    0, 0, 9
}
};

/* Reference to create a gradient effect */
uint8_t wpm_levels[10] = {20, 9, 8, 7, 6, 5, 4, 3, 2, 1};

void WPM_CHART(uint8_t i, bool dir) {
    led_matrix_set_index_value_all(0);
    uint8_t c_wpm = get_current_wpm();
    uint8_t half_wpm = floor(c_wpm / 2);
    uint8_t max_rows = 10;
    /* Turn on LED for current WPM. Each pixel is 2 wpm. */
    for (int k = 0; k < half_wpm && k < 70; k++) {
        uint8_t current_row = (int)floor(k / 7);
        led_matrix_set_index_value(k, wpm_levels[max_rows - current_row]);
    };
    uint8_t d1 = (int)floor(c_wpm / 10);
    /* There is only room to print 2 digits. If the WPM is greater than
       99 then the last 2 digits will show, ie 120 = 20. */
    if (c_wpm > 99) {
        uint8_t tens_place = d1 % 10;
        terrazzo_draw_at(0, 11, 3, 4, number_3_4[tens_place]);
    } else {
        terrazzo_draw_at(0, 11, 3, 4, number_3_4[d1]);
    }
    
    terrazzo_draw_at(4, 11, 3, 4, number_3_4[c_wpm % 10]);
}

#   endif
#endif