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.

176 lines
5.0 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 = {
  84. 0,
  85. #if LCD_ENABLE
  86. 0,
  87. #endif
  88. gfxMillisecondsToTicks(5000)},
  89. .frame_functions = {
  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. #if LCD_ENABLE
  106. 0,
  107. #endif
  108. gfxMillisecondsToTicks(1000),
  109. 0},
  110. .frame_functions = {
  111. #if LCD_ENABLE
  112. lcd_keyframe_display_layer_text,
  113. #endif
  114. keyframe_fade_out,
  115. keyframe_disable,
  116. },
  117. };
  118. #endif
  119. #if defined(BACKLIGHT_ENABLE)
  120. #define CROSSFADE_TIME 1000
  121. #define GRADIENT_TIME 3000
  122. keyframe_animation_t led_test_animation = {
  123. .num_frames = 14,
  124. .loop = true,
  125. .frame_lengths = {
  126. gfxMillisecondsToTicks(1000), // fade in
  127. gfxMillisecondsToTicks(1000), // no op (leds on)
  128. gfxMillisecondsToTicks(1000), // fade out
  129. gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
  130. gfxMillisecondsToTicks(GRADIENT_TIME), // left to rigt (outside in)
  131. gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
  132. gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom
  133. 0, // mirror leds
  134. gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
  135. gfxMillisecondsToTicks(GRADIENT_TIME), // left_to_right (mirrored, so inside out)
  136. gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
  137. gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom
  138. 0, // normal leds
  139. gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
  140. },
  141. .frame_functions = {
  142. led_backlight_keyframe_fade_in_all,
  143. keyframe_no_operation,
  144. led_backlight_keyframe_fade_out_all,
  145. led_backlight_keyframe_crossfade,
  146. led_backlight_keyframe_left_to_right_gradient,
  147. led_backlight_keyframe_crossfade,
  148. led_backlight_keyframe_top_to_bottom_gradient,
  149. led_backlight_keyframe_mirror_orientation,
  150. led_backlight_keyframe_crossfade,
  151. led_backlight_keyframe_left_to_right_gradient,
  152. led_backlight_keyframe_crossfade,
  153. led_backlight_keyframe_top_to_bottom_gradient,
  154. led_backlight_keyframe_normal_orientation,
  155. led_backlight_keyframe_crossfade,
  156. },
  157. };
  158. #endif
  159. #endif