logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

wpm_chart.h (2415B)


  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. #ifndef DISABLE_TERRAZZO_EFFECT_WPM_CHART
  17. TERRAZZO_EFFECT(WPM_CHART)
  18. # ifdef TERRAZZO_EFFECT_IMPLS
  19. static uint8_t number_3_4[10][12] = {
  20. { // 0
  21. 9, 9, 9,
  22. 9, 0, 9,
  23. 9, 0, 9,
  24. 9, 9, 9
  25. },
  26. { // 1
  27. 0, 9, 0,
  28. 9, 9, 0,
  29. 0, 9, 0,
  30. 9, 9, 9
  31. },
  32. { // 2
  33. 9, 9, 0,
  34. 0, 0, 9,
  35. 0, 9, 0,
  36. 9, 9, 9
  37. },
  38. { // 3
  39. 9, 9, 9,
  40. 0, 9, 0,
  41. 0, 0, 9,
  42. 9, 9, 0
  43. },
  44. { // 4
  45. 9, 0, 9,
  46. 9, 0, 9,
  47. 9, 9, 9,
  48. 0, 0, 9
  49. },
  50. { // 5
  51. 9, 9, 9,
  52. 9, 9, 0,
  53. 0, 0, 9,
  54. 9, 9, 9
  55. },
  56. { // 6
  57. 0, 0, 9,
  58. 0, 9, 0,
  59. 9, 0, 9,
  60. 0, 9, 0
  61. },
  62. { // 7
  63. 9, 9, 9,
  64. 0, 0, 9,
  65. 0, 9, 0,
  66. 9, 0, 0
  67. },
  68. { // 8
  69. 9, 9, 9,
  70. 9, 0, 9,
  71. 9, 4, 9,
  72. 9, 9, 9
  73. },
  74. { // 9
  75. 9, 9, 9,
  76. 9, 0, 9,
  77. 9, 9, 9,
  78. 0, 0, 9
  79. }
  80. };
  81. /* Reference to create a gradient effect */
  82. uint8_t wpm_levels[10] = {20, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  83. void WPM_CHART(uint8_t i, bool dir) {
  84. led_matrix_set_value_all(0);
  85. uint8_t c_wpm = get_current_wpm();
  86. uint8_t half_wpm = floor(c_wpm / 2);
  87. uint8_t max_rows = 10;
  88. /* Turn on LED for current WPM. Each pixel is 2 wpm. */
  89. for (int k = 0; k < half_wpm && k < 70; k++) {
  90. uint8_t current_row = (int)floor(k / 7);
  91. led_matrix_set_value(k, wpm_levels[max_rows - current_row]);
  92. };
  93. uint8_t d1 = (int)floor(c_wpm / 10);
  94. /* There is only room to print 2 digits. If the WPM is greater than
  95. 99 then the last 2 digits will show, ie 120 = 20. */
  96. if (c_wpm > 99) {
  97. uint8_t tens_place = d1 % 10;
  98. terrazzo_draw_at(0, 11, 3, 4, number_3_4[tens_place]);
  99. } else {
  100. terrazzo_draw_at(0, 11, 3, 4, number_3_4[d1]);
  101. }
  102. terrazzo_draw_at(4, 11, 3, 4, number_3_4[c_wpm % 10]);
  103. }
  104. # endif
  105. #endif