logo

qmk_firmware

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

outrun.h (3139B)


  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_OUTRUN
  17. TERRAZZO_EFFECT(OUTRUN)
  18. # ifdef TERRAZZO_EFFECT_IMPLS
  19. static uint8_t outrun_sun[25] = {
  20. 0, 9, 9, 9, 0,
  21. 7, 7, 7, 7, 7,
  22. 4, 4, 4, 4, 4,
  23. 2, 2, 2, 2, 2,
  24. 0, 1, 1, 1, 0
  25. };
  26. static uint8_t outrun_ground[63] = {
  27. 0, 0, 1, 1, 1, 0, 0,
  28. 0, 2, 0, 2, 0, 2, 0,
  29. 0, 2, 0, 2, 0, 2, 0,
  30. 0, 2, 0, 4, 0, 2, 0,
  31. 2, 0, 0, 5, 0, 0, 2,
  32. 2, 0, 0, 5, 0, 0, 2,
  33. 2, 0, 0, 6, 0, 0, 2,
  34. 0, 0, 0, 7, 0, 0, 0,
  35. 0, 0, 0, 8, 0, 0, 0
  36. };
  37. static uint8_t outrun_rows[4][63] = {
  38. {
  39. 1, 1, 1, 1, 1, 1, 1,
  40. 0, 0, 0, 0, 0, 0, 0,
  41. 2, 2, 2, 2, 2, 2, 2,
  42. 0, 0, 0, 0, 0, 0, 0,
  43. 0, 0, 0, 0, 0, 0, 0,
  44. 4, 4, 4, 4, 4, 4, 4,
  45. 0, 0, 0, 0, 0, 0, 0,
  46. 0, 0, 0, 0, 0, 0, 0,
  47. 0, 0, 0, 0, 0, 0, 0
  48. },
  49. {
  50. 0, 0, 0, 0, 0, 0, 0,
  51. 1, 1, 1, 1, 1, 1, 1,
  52. 0, 0, 0, 0, 0, 0, 0,
  53. 2, 2, 2, 2, 2, 2, 2,
  54. 0, 0, 0, 0, 0, 0, 0,
  55. 0, 0, 0, 0, 0, 0, 0,
  56. 4, 4, 4, 4, 4, 4, 4,
  57. 0, 0, 0, 0, 0, 0, 0,
  58. 0, 0, 0, 0, 0, 0, 0
  59. },
  60. {
  61. 1, 1, 1, 1, 1, 1, 1,
  62. 0, 0, 0, 0, 0, 0, 0,
  63. 2, 2, 2, 2, 2, 2, 2,
  64. 0, 0, 0, 0, 0, 0, 0,
  65. 4, 4, 4, 4, 4, 4, 4,
  66. 0, 0, 0, 0, 0, 0, 0,
  67. 0, 0, 0, 0, 0, 0, 0,
  68. 9, 9, 9, 9, 9, 9, 9,
  69. 0, 0, 0, 0, 0, 0, 0
  70. },
  71. {
  72. 0, 0, 0, 0, 0, 0, 0,
  73. 1, 1, 1, 1, 1, 1, 1,
  74. 0, 0, 0, 0, 0, 0, 0,
  75. 2, 2, 2, 2, 2, 2, 2,
  76. 0, 0, 0, 0, 0, 0, 0,
  77. 4, 4, 4, 4, 4, 4, 4,
  78. 0, 0, 0, 0, 0, 0, 0,
  79. 0, 0, 0, 0, 0, 0, 0,
  80. 9, 9, 9, 9, 9, 9, 9
  81. }
  82. };
  83. bool last_dir;
  84. uint8_t change_index = 0;
  85. void OUTRUN(uint8_t i, bool dir) {
  86. led_matrix_set_value_all(0);
  87. if(dir != last_dir) {
  88. change_index = i;
  89. }
  90. uint8_t change_diff = abs(i - change_index);
  91. uint8_t horz_bright = 9;
  92. if(change_diff < 4) {
  93. if (dir) {
  94. terrazzo_draw_at(1, 4 - change_diff, 5, 1 + change_diff, outrun_sun);
  95. horz_bright = 3 + change_diff;
  96. } else {
  97. terrazzo_draw_at(1, 0 + change_diff, 5, 5 - change_diff, outrun_sun);
  98. horz_bright = 5 - change_diff;
  99. }
  100. } else {
  101. if (dir) {
  102. terrazzo_draw_at(1, 0, 5, 5, outrun_sun);
  103. } else {
  104. horz_bright = 1;
  105. }
  106. }
  107. for(int x = 0; x < 7; x++){
  108. terrazzo_set_pixel(x, 5, horz_bright);
  109. }
  110. // Sun is larger but render the top 3 rows only
  111. terrazzo_draw_at(0, 6, 7, 10, outrun_ground);
  112. terrazzo_draw_at(0, 6, 7, 10, outrun_rows[i % 4]);
  113. last_dir = dir;
  114. }
  115. # endif
  116. #endif