diff options
Diffstat (limited to 'led_test.c')
| -rw-r--r-- | led_test.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/led_test.c b/led_test.c new file mode 100644 index 000000000..1aadd5541 --- /dev/null +++ b/led_test.c | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | /* | ||
| 2 | The MIT License (MIT) | ||
| 3 | |||
| 4 | Copyright (c) 2016 Fred Sundvik | ||
| 5 | |||
| 6 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 7 | of this software and associated documentation files (the "Software"), to deal | ||
| 8 | in the Software without restriction, including without limitation the rights | ||
| 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 10 | copies of the Software, and to permit persons to whom the Software is | ||
| 11 | furnished to do so, subject to the following conditions: | ||
| 12 | |||
| 13 | The above copyright notice and this permission notice shall be included in all | ||
| 14 | copies or substantial portions of the Software. | ||
| 15 | |||
| 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 22 | SOFTWARE. | ||
| 23 | */ | ||
| 24 | #include "led_test.h" | ||
| 25 | #include "gfx.h" | ||
| 26 | |||
| 27 | keyframe_animation_t led_test_animation = { | ||
| 28 | .num_frames = 1, | ||
| 29 | .loop = true, | ||
| 30 | .frame_lengths = {MS2ST(1000)}, | ||
| 31 | .frame_functions = { | ||
| 32 | keyframe_fade_in_all_leds, | ||
| 33 | }, | ||
| 34 | }; | ||
| 35 | |||
| 36 | bool keyframe_fade_in_all_leds(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 37 | (void)state; | ||
| 38 | int frame_length = animation->frame_lengths[animation->current_frame]; | ||
| 39 | int current_pos = frame_length - animation->time_left_in_frame; | ||
| 40 | uint8_t luma = 0x255 * current_pos / frame_length; | ||
| 41 | color_t color = LUMA2COLOR(luma); | ||
| 42 | gdispGClear(LED_DISPLAY, color); | ||
| 43 | gdispGFlush(LED_DISPLAY); | ||
| 44 | return true; | ||
| 45 | } | ||
