You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
5.6 KiB

  1. /* Copyright 2017 Fred Sundvik
  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. #if defined(VISUALIZER_ENABLE)
  17. # include "default_animations.h"
  18. # include "visualizer.h"
  19. # ifdef LCD_ENABLE
  20. # include "lcd_keyframes.h"
  21. # endif
  22. # ifdef LCD_BACKLIGHT_ENABLE
  23. # include "lcd_backlight_keyframes.h"
  24. # endif
  25. # ifdef BACKLIGHT_ENABLE
  26. # include "led_backlight_keyframes.h"
  27. # endif
  28. # include "visualizer_keyframes.h"
  29. # if defined(LCD_ENABLE) || defined(LCD_BACKLIGHT_ENABLE) || defined(BACKLIGHT_ENABLE)
  30. static bool keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) {
  31. # ifdef LCD_ENABLE
  32. lcd_keyframe_enable(animation, state);
  33. # endif
  34. # ifdef LCD_BACKLIGHT_ENABLE
  35. lcd_backlight_keyframe_enable(animation, state);
  36. # endif
  37. # ifdef BACKLIGHT_ENABLE
  38. led_backlight_keyframe_enable(animation, state);
  39. # endif
  40. return false;
  41. }
  42. static bool keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) {
  43. # ifdef LCD_ENABLE
  44. lcd_keyframe_disable(animation, state);
  45. # endif
  46. # ifdef LCD_BACKLIGHT_ENABLE
  47. lcd_backlight_keyframe_disable(animation, state);
  48. # endif
  49. # ifdef BACKLIGHT_ENABLE
  50. led_backlight_keyframe_disable(animation, state);
  51. # endif
  52. return false;
  53. }
  54. static bool keyframe_fade_in(keyframe_animation_t* animation, visualizer_state_t* state) {
  55. bool ret = false;
  56. # ifdef LCD_BACKLIGHT_ENABLE
  57. ret |= lcd_backlight_keyframe_animate_color(animation, state);
  58. # endif
  59. # ifdef BACKLIGHT_ENABLE
  60. ret |= led_backlight_keyframe_fade_in_all(animation, state);
  61. # endif
  62. return ret;
  63. }
  64. static bool keyframe_fade_out(keyframe_animation_t* animation, visualizer_state_t* state) {
  65. bool ret = false;
  66. # ifdef LCD_BACKLIGHT_ENABLE
  67. ret |= lcd_backlight_keyframe_animate_color(animation, state);
  68. # endif
  69. # ifdef BACKLIGHT_ENABLE
  70. ret |= led_backlight_keyframe_fade_out_all(animation, state);
  71. # endif
  72. return ret;
  73. }
  74. // Don't worry, if the startup animation is long, you can use the keyboard like normal
  75. // during that time
  76. keyframe_animation_t default_startup_animation = {
  77. # if LCD_ENABLE
  78. .num_frames = 3,
  79. # else
  80. .num_frames = 2,
  81. # endif
  82. .loop = false,
  83. .frame_lengths = {0,
  84. # if LCD_ENABLE
  85. 0,
  86. # endif
  87. gfxMillisecondsToTicks(5000)},
  88. .frame_functions =
  89. {
  90. keyframe_enable,
  91. # if LCD_ENABLE
  92. lcd_keyframe_draw_logo,
  93. # endif
  94. keyframe_fade_in,
  95. },
  96. };
  97. keyframe_animation_t default_suspend_animation = {
  98. # if LCD_ENABLE
  99. .num_frames = 3,
  100. # else
  101. .num_frames = 2,
  102. # endif
  103. .loop = false,
  104. .frame_lengths =
  105. {
  106. # if LCD_ENABLE
  107. 0,
  108. # endif
  109. gfxMillisecondsToTicks(1000), 0},
  110. .frame_functions =
  111. {
  112. # if LCD_ENABLE
  113. lcd_keyframe_display_layer_text,
  114. # endif
  115. keyframe_fade_out,
  116. keyframe_disable,
  117. },
  118. };
  119. # endif
  120. # if defined(BACKLIGHT_ENABLE)
  121. # define CROSSFADE_TIME 1000
  122. # define GRADIENT_TIME 3000
  123. keyframe_animation_t led_test_animation = {
  124. .num_frames = 14,
  125. .loop = true,
  126. .frame_lengths =
  127. {
  128. gfxMillisecondsToTicks(1000), // fade in
  129. gfxMillisecondsToTicks(1000), // no op (leds on)
  130. gfxMillisecondsToTicks(1000), // fade out
  131. gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
  132. gfxMillisecondsToTicks(GRADIENT_TIME), // left to rigt (outside in)
  133. gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
  134. gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom
  135. 0, // mirror leds
  136. gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
  137. gfxMillisecondsToTicks(GRADIENT_TIME), // left_to_right (mirrored, so inside out)
  138. gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
  139. gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom
  140. 0, // normal leds
  141. gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
  142. },
  143. .frame_functions =
  144. {
  145. led_backlight_keyframe_fade_in_all,
  146. keyframe_no_operation,
  147. led_backlight_keyframe_fade_out_all,
  148. led_backlight_keyframe_crossfade,
  149. led_backlight_keyframe_left_to_right_gradient,
  150. led_backlight_keyframe_crossfade,
  151. led_backlight_keyframe_top_to_bottom_gradient,
  152. led_backlight_keyframe_mirror_orientation,
  153. led_backlight_keyframe_crossfade,
  154. led_backlight_keyframe_left_to_right_gradient,
  155. led_backlight_keyframe_crossfade,
  156. led_backlight_keyframe_top_to_bottom_gradient,
  157. led_backlight_keyframe_normal_orientation,
  158. led_backlight_keyframe_crossfade,
  159. },
  160. };
  161. # endif
  162. #endif