application: better new hour animation

This commit is contained in:
King Kévin 2017-10-08 18:35:57 +02:00
parent 0cbaf714d2
commit 4994c6a77d
1 changed files with 18 additions and 2 deletions

View File

@ -344,10 +344,26 @@ static void clock_animate_time(uint32_t time)
*/
static void clock_hours(void)
{
for (uint16_t i=0; i<512; i++) { // fade in and out
for (uint16_t i=0; i<255; i++) { // fade out
for (uint16_t led=0; led<LED_WS2812B_LEDS; led++) { // fade minutes out
if (clock_leds[led*3+1]) {
clock_leds[led*3+1] -= 1; // fade minutes out (green)
}
if (clock_leds[led*3+0]) {
clock_leds[led*3+0] -= 1; // fade seconds out (red)
}
}
clock_leds_set(); // set the colors of all LEDs
led_ws2812b_transmit(); // transmit set color
// delay some time for the animation
for (uint32_t j=0; j<40000; j++) {
__asm__("nop");
}
}
for (uint16_t i=0; i<512; i++) { // fade hour marks in and out
uint8_t brightness = (i>255 ? 512-i-1 : i); // get fade brightness
for (uint8_t hour=0; hour<12; hour++) { // set all hour colors
uint16_t led = LED_WS2812B_LEDS/12*hour; // get LED four hour mark
uint16_t led = LED_WS2812B_LEDS*hour/12; // get LED four hour mark
clock_leds[led*3+0] = brightness; // set brightness
clock_leds[led*3+1] = brightness; // set brightness
clock_leds[led*3+2] = brightness; // set brightness