From d689f76110ee20e45d6531eac31bf72461ed504b Mon Sep 17 00:00:00 2001 From: Anne Demey Date: Fri, 23 Oct 2020 17:14:17 -0500 Subject: [Keyboard] Add Terrazzo Keyboard (#10408) * Ciao Terrazzo! * Keymap updates * Adding info json Cleaning up keymap files Readme updates with template * Coding style updates * Removing vscode files * PR feedback updates * biton32 -> get_highest_layer update Adding license headers --- keyboards/terrazzo/terrazzo_effects/dino.h | 162 +++++++++++++++++++++ keyboards/terrazzo/terrazzo_effects/dot.h | 27 ++++ keyboards/terrazzo/terrazzo_effects/heart.h | 99 +++++++++++++ keyboards/terrazzo/terrazzo_effects/outrun.h | 127 ++++++++++++++++ keyboards/terrazzo/terrazzo_effects/pac_dude.h | 67 +++++++++ keyboards/terrazzo/terrazzo_effects/stripes.h | 35 +++++ .../terrazzo/terrazzo_effects/terrazzo_effects.inc | 7 + keyboards/terrazzo/terrazzo_effects/wpm_chart.h | 111 ++++++++++++++ 8 files changed, 635 insertions(+) create mode 100644 keyboards/terrazzo/terrazzo_effects/dino.h create mode 100644 keyboards/terrazzo/terrazzo_effects/dot.h create mode 100644 keyboards/terrazzo/terrazzo_effects/heart.h create mode 100644 keyboards/terrazzo/terrazzo_effects/outrun.h create mode 100644 keyboards/terrazzo/terrazzo_effects/pac_dude.h create mode 100644 keyboards/terrazzo/terrazzo_effects/stripes.h create mode 100644 keyboards/terrazzo/terrazzo_effects/terrazzo_effects.inc create mode 100644 keyboards/terrazzo/terrazzo_effects/wpm_chart.h (limited to 'keyboards/terrazzo/terrazzo_effects') diff --git a/keyboards/terrazzo/terrazzo_effects/dino.h b/keyboards/terrazzo/terrazzo_effects/dino.h new file mode 100644 index 0000000000..747ef6178e --- /dev/null +++ b/keyboards/terrazzo/terrazzo_effects/dino.h @@ -0,0 +1,162 @@ +/* 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 . + */ + +#ifndef DISABLE_TERRAZZO_EFFECT_DINO +TERRAZZO_EFFECT(DINO) +# ifdef TERRAZZO_EFFECT_IMPLS + +static uint8_t dino_frames[2][56] = { +{ + 0, 0, 0, 9, 9, 9, 9, + 0, 0, 0, 9, 0, 9, 9, + 9, 0, 0, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 0, 0, + 9, 9, 9, 9, 9, 0, 0, + 0, 9, 9, 9, 0, 0, 0, + 0, 9, 0, 9, 9, 0, 0, + 0, 9, 9, 0, 0, 0, 0 +}, +{ + 0, 0, 0, 9, 9, 9, 9, + 0, 0, 0, 9, 0, 9, 9, + 9, 0, 0, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 0, 0, + 9, 9, 9, 9, 9, 0, 0, + 0, 9, 9, 9, 0, 0, 0, + 0, 9, 0, 9, 0, 0, 0, + 0, 0, 0, 9, 9, 0, 0 +} +}; + +static uint8_t dino_reverse[2][56] = { +{ + 9, 9, 9, 9, 0, 0, 0, + 9, 9, 0, 9, 0, 0, 0, + 9, 9, 9, 9, 0, 0, 9, + 0, 0, 9, 9, 9, 9, 9, + 0, 0, 9, 9, 9, 9, 9, + 0, 0, 0, 9, 9, 9, 0, + 0, 0, 9, 9, 0, 9, 0, + 0, 0, 0, 0, 9, 9, 0 +}, +{ + 9, 9, 9, 9, 0, 0, 0, + 9, 9, 0, 9, 0, 0, 0, + 9, 9, 9, 9, 0, 0, 9, + 0, 0, 9, 9, 9, 9, 9, + 0, 0, 9, 9, 9, 9, 9, + 0, 0, 0, 9, 9, 9, 0, + 0, 0, 0, 9, 0, 9, 0, + 0, 0, 9, 9, 0, 0, 0 +} +}; + +static uint8_t dino_bg[10][42] = { +{ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 4, 0, + 0, 1, 1, 0, 0, 0, 4, + 1, 0, 0, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0 +}, +{ + 0, 0, 0, 0, 0, 0, 4, + 0, 0, 0, 0, 4, 0, 4, + 0, 0, 0, 0, 4, 0, 4, + 1, 1, 0, 0, 0, 4, 4, + 0, 0, 1, 1, 1, 1, 4, + 0, 0, 0, 0, 0, 0, 4 +}, +{ + 0, 0, 0, 0, 0, 4, 0, + 0, 0, 0, 4, 0, 4, 0, + 0, 0, 0, 4, 0, 4, 4, + 1, 0, 0, 0, 4, 4, 0, + 0, 1, 1, 1, 1, 4, 0, + 0, 0, 0, 0, 0, 4, 0 +}, +{ + 0, 0, 0, 0, 4, 0, 0, + 0, 0, 4, 0, 4, 0, 4, + 0, 0, 4, 0, 4, 4, 4, + 0, 0, 0, 4, 4, 0, 0, + 1, 1, 1, 1, 4, 1, 1, + 0, 0, 0, 0, 4, 0, 0 +}, +{ + 0, 0, 0, 4, 0, 0, 0, + 0, 4, 0, 4, 0, 4, 0, + 0, 4, 0, 4, 4, 4, 0, + 0, 0, 4, 4, 0, 0, 0, + 1, 1, 1, 4, 1, 1, 1, + 0, 0, 0, 4, 0, 0, 0 +}, +{ + 0, 0, 4, 0, 0, 0, 0, + 4, 0, 4, 0, 4, 0, 0, + 4, 0, 4, 4, 4, 0, 0, + 0, 4, 4, 0, 0, 0, 1, + 1, 1, 4, 1, 1, 1, 0, + 0, 0, 4, 0, 0, 0, 0 +}, +{ + 0, 4, 0, 0, 0, 0, 0, + 0, 4, 0, 4, 0, 0, 0, + 0, 4, 4, 4, 0, 0, 0, + 4, 4, 0, 0, 0, 1, 1, + 1, 4, 1, 1, 1, 0, 0, + 0, 4, 0, 0, 0, 0, 0 +}, +{ + 4, 0, 0, 0, 0, 0, 0, + 4, 0, 4, 0, 0, 0, 0, + 4, 4, 4, 0, 0, 0, 0, + 4, 0, 0, 0, 1, 1, 0, + 4, 1, 1, 1, 0, 0, 1, + 4, 0, 0, 0, 0, 0, 0 +}, +{ + 0, 0, 0, 0, 0, 0, 0, + 0, 4, 0, 0, 0, 0, 0, + 4, 4, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, + 1, 1, 1, 0, 0, 1, 1, + 0, 0, 0, 0, 0, 0, 0 +}, +{ + 0, 0, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 0, 0, 4, + 4, 0, 0, 0, 0, 0, 4, + 0, 0, 1, 1, 0, 0, 0, + 1, 1, 0, 0, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0 +} +}; + +void DINO(uint8_t i, bool dir) { + led_matrix_set_index_value_all(0); + if (dir) { + terrazzo_draw_at(0, 7, 7, 8, dino_frames[i % 2]); + } else { + terrazzo_draw_at(0, 7, 7, 8, dino_reverse[i % 2]); + + } + terrazzo_draw_at(0, 0, 7, 6, dino_bg[i % 10]); +} + +# endif +#endif \ No newline at end of file diff --git a/keyboards/terrazzo/terrazzo_effects/dot.h b/keyboards/terrazzo/terrazzo_effects/dot.h new file mode 100644 index 0000000000..e8eb8e0fce --- /dev/null +++ b/keyboards/terrazzo/terrazzo_effects/dot.h @@ -0,0 +1,27 @@ +/* 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 . + */ + +#ifndef DISABLE_TERRAZZO_EFFECT_DOT +TERRAZZO_EFFECT(DOT) +# ifdef TERRAZZO_EFFECT_IMPLS +// Animation for debugging. Lights one pixel according to animation index +void DOT(uint8_t i, bool dir) { + led_matrix_set_index_value_all(0); + led_matrix_set_index_value(i, 10); +} + +# endif +#endif \ No newline at end of file diff --git a/keyboards/terrazzo/terrazzo_effects/heart.h b/keyboards/terrazzo/terrazzo_effects/heart.h new file mode 100644 index 0000000000..bdcd2d7b97 --- /dev/null +++ b/keyboards/terrazzo/terrazzo_effects/heart.h @@ -0,0 +1,99 @@ +/* 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 . + */ + +#ifndef DISABLE_TERRAZZO_EFFECT_HEART +TERRAZZO_EFFECT(HEART) +# ifdef TERRAZZO_EFFECT_IMPLS + +static uint8_t heart_frames[4][105] = { +{ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 5, 5, 0, 5, 5, 0, + 5, 0, 0, 5, 0, 0, 5, + 5, 0, 0, 0, 0, 0, 5, + 0, 5, 0, 0, 0, 5, 0, + 0, 0, 5, 0, 5, 0, 0, + 0, 0, 0, 5, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0 +}, +{ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 5, 5, 0, 5, 5, 0, + 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, + 0, 5, 5, 5, 5, 5, 0, + 0, 0, 5, 5, 5, 0, 0, + 0, 0, 0, 5, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0 +}, +{ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 1, 1, 0, + 1, 0, 0, 5, 0, 0, 1, + 0, 5, 5, 0, 5, 5, 0, + 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, + 0, 5, 5, 5, 5, 5, 0, + 0, 0, 5, 5, 5, 0, 0, + 1, 0, 0, 5, 0, 0, 1, + 0, 1, 0, 0, 0, 1, 0, + 0, 0, 1, 0, 1, 0, 0, + 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0 +}, +{ + 0, 1, 1, 0, 1, 1, 0, + 1, 0, 0, 1, 0, 0, 1, + 0, 5, 5, 0, 5, 5, 0, + 5, 0, 0, 5, 0, 0, 5, + 0, 5, 5, 0, 5, 5, 0, + 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, + 0, 5, 5, 5, 5, 5, 0, + 0, 0, 5, 5, 5, 0, 0, + 5, 0, 0, 5, 0, 0, 5, + 0, 5, 0, 0, 0, 5, 0, + 1, 0, 5, 0, 5, 0, 1, + 0, 1, 0, 5, 0, 1, 0, + 0, 0, 1, 0, 1, 0, 0, + 0, 0, 0, 1, 0, 0, 0 +} +}; + + +void HEART(uint8_t i, bool dir) { + led_matrix_set_index_value_all(0); + terrazzo_draw_at(0, 0, 7, 15, heart_frames[i % 4]); +} + +# endif +#endif \ No newline at end of file diff --git a/keyboards/terrazzo/terrazzo_effects/outrun.h b/keyboards/terrazzo/terrazzo_effects/outrun.h new file mode 100644 index 0000000000..b4455ef49f --- /dev/null +++ b/keyboards/terrazzo/terrazzo_effects/outrun.h @@ -0,0 +1,127 @@ +/* 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 . + */ + +#ifndef DISABLE_TERRAZZO_EFFECT_OUTRUN +TERRAZZO_EFFECT(OUTRUN) +# ifdef TERRAZZO_EFFECT_IMPLS + +static uint8_t outrun_sun[25] = { + 0, 9, 9, 9, 0, + 7, 7, 7, 7, 7, + 4, 4, 4, 4, 4, + 2, 2, 2, 2, 2, + 0, 1, 1, 1, 0 +}; + +static uint8_t outrun_ground[63] = { + 0, 0, 1, 1, 1, 0, 0, + 0, 2, 0, 2, 0, 2, 0, + 0, 2, 0, 2, 0, 2, 0, + 0, 2, 0, 4, 0, 2, 0, + 2, 0, 0, 5, 0, 0, 2, + 2, 0, 0, 5, 0, 0, 2, + 2, 0, 0, 6, 0, 0, 2, + 0, 0, 0, 7, 0, 0, 0, + 0, 0, 0, 8, 0, 0, 0 +}; + +static uint8_t outrun_rows[4][63] = { +{ + 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, + 2, 2, 2, 2, 2, 2, 2, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 4, 4, 4, 4, 4, 4, 4, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0 +}, +{ + 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, + 2, 2, 2, 2, 2, 2, 2, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 4, 4, 4, 4, 4, 4, 4, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0 +}, +{ + 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, + 2, 2, 2, 2, 2, 2, 2, + 0, 0, 0, 0, 0, 0, 0, + 4, 4, 4, 4, 4, 4, 4, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 9, 9, 9, 9, 9, 9, 9, + 0, 0, 0, 0, 0, 0, 0 +}, +{ + 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, + 2, 2, 2, 2, 2, 2, 2, + 0, 0, 0, 0, 0, 0, 0, + 4, 4, 4, 4, 4, 4, 4, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 9, 9, 9, 9, 9, 9, 9 +} +}; + +bool last_dir; +uint8_t change_index = 0; + +void OUTRUN(uint8_t i, bool dir) { + led_matrix_set_index_value_all(0); + + if(dir != last_dir) { + change_index = i; + } + + uint8_t change_diff = abs(i - change_index); + uint8_t horz_bright = 9; + + if(change_diff < 4) { + if (dir) { + terrazzo_draw_at(1, 4 - change_diff, 5, 1 + change_diff, outrun_sun); + horz_bright = 3 + change_diff; + } else { + terrazzo_draw_at(1, 0 + change_diff, 5, 5 - change_diff, outrun_sun); + horz_bright = 5 - change_diff; + } + } else { + if (dir) { + terrazzo_draw_at(1, 0, 5, 5, outrun_sun); + } else { + horz_bright = 1; + } + } + + for(int x = 0; x < 7; x++){ + terrazzo_set_pixel(x, 5, horz_bright); + } + // Sun is larger but render the top 3 rows only + terrazzo_draw_at(0, 6, 7, 10, outrun_ground); + terrazzo_draw_at(0, 6, 7, 10, outrun_rows[i % 4]); + last_dir = dir; +} + +# endif +#endif \ No newline at end of file diff --git a/keyboards/terrazzo/terrazzo_effects/pac_dude.h b/keyboards/terrazzo/terrazzo_effects/pac_dude.h new file mode 100644 index 0000000000..aa4fc9923f --- /dev/null +++ b/keyboards/terrazzo/terrazzo_effects/pac_dude.h @@ -0,0 +1,67 @@ +/* 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 . + */ + +#ifndef DISABLE_TERRAZZO_EFFECT_PAC_DUDE +TERRAZZO_EFFECT(PAC_DUDE) +# ifdef TERRAZZO_EFFECT_IMPLS + +static uint8_t pac_frames[3][25] = { +{ // up + 0, 0, 0, 0, 0, + 9, 0, 0, 0, 9, + 9, 9, 0, 9, 9, + 9, 9, 9, 9, 9, + 0, 9, 9, 9, 0 +}, +{ // closed + 0, 9, 9, 9, 0, + 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, + 0, 9, 9, 9, 0 +}, +{ // down + 0, 9, 9, 9, 0, + 9, 9, 9, 9, 9, + 9, 9, 0, 9, 9, + 9, 0, 0, 0, 9, + 0, 0, 0, 0, 0 +} +}; + +static uint8_t pac_ghost[20] = { + 0, 4, 4, 4, 0, + 4, 0, 4, 0, 4, + 4, 4, 4, 4, 4, + 4, 0, 4, 0, 4 +}; + + +void PAC_DUDE(uint8_t i, bool dir) { + led_matrix_set_index_value_all(0); + if (dir) { + terrazzo_draw_at(1, 4, 5, 5, pac_frames[i % 2]); + terrazzo_set_pixel(3, 0 + i % 3, 5); + terrazzo_set_pixel(3, 3 + i % 3, 5); + } else { + terrazzo_draw_at(1, 4, 5, 5, pac_frames[1 + i % 2]); + terrazzo_draw_at(1, 8 + i % 8, 5, 4, pac_ghost); + } + +} + +# endif +#endif \ No newline at end of file diff --git a/keyboards/terrazzo/terrazzo_effects/stripes.h b/keyboards/terrazzo/terrazzo_effects/stripes.h new file mode 100644 index 0000000000..4e1238cdc4 --- /dev/null +++ b/keyboards/terrazzo/terrazzo_effects/stripes.h @@ -0,0 +1,35 @@ +/* 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 . + */ + +#ifndef DISABLE_TERRAZZO_EFFECT_STRIPES +TERRAZZO_EFFECT(STRIPES) +# ifdef TERRAZZO_EFFECT_IMPLS + +void STRIPES(uint8_t i, bool dir) { + uint8_t sweep[] = {1, 2, 3, 4, 6, 8, 10, 15, 20, 30, 40, 60}; + uint8_t levels = 12; + float soften = 5; + + for (int y = 0; y < LED_MATRIX_ROWS; y++) { + for (int x = 0; x < LED_MATRIX_COLS; x++) { + uint8_t target = (x+y+i)%levels; + terrazzo_set_pixel(x, y, floor(sweep[target] / soften)); + } + } +} + +# endif +#endif \ No newline at end of file diff --git a/keyboards/terrazzo/terrazzo_effects/terrazzo_effects.inc b/keyboards/terrazzo/terrazzo_effects/terrazzo_effects.inc new file mode 100644 index 0000000000..c5271db1b4 --- /dev/null +++ b/keyboards/terrazzo/terrazzo_effects/terrazzo_effects.inc @@ -0,0 +1,7 @@ +#include "terrazzo_effects/stripes.h" +#include "terrazzo_effects/dino.h" +#include "terrazzo_effects/outrun.h" +#include "terrazzo_effects/pac_dude.h" +#include "terrazzo_effects/heart.h" +#include "terrazzo_effects/wpm_chart.h" +#include "terrazzo_effects/dot.h" diff --git a/keyboards/terrazzo/terrazzo_effects/wpm_chart.h b/keyboards/terrazzo/terrazzo_effects/wpm_chart.h new file mode 100644 index 0000000000..5c66bc39ad --- /dev/null +++ b/keyboards/terrazzo/terrazzo_effects/wpm_chart.h @@ -0,0 +1,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 . + */ + +#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 \ No newline at end of file -- cgit v1.2.3