void animate(){ if(_animation_running){ int time_passed = millis() - _animation_begin_timestamp; if(time_passed < _animation_duration){ int anim_delta = map(time_passed, 0, _animation_duration, 0, 256); memcpy(_current_color, blend_colors(anim_delta, _animation_color_start, _animation_color_end), 3); Serial.println(_current_color[0], DEC); Serial.println(_current_color[1], DEC); Serial.println(_current_color[2], DEC); write_led_color(_current_color); } else { memcpy(_current_color, _animation_color_end, 3); write_led_color(_current_color); _animation_running = false; animation_did_finish(); } } } byte* blend_colors(byte steps, byte first_color[], byte second_color[]){ byte ret_color[3]; ret_color[0] = ((second_color[0] - first_color[0]) * steps / 255) + first_color[0]; ret_color[1] = ((second_color[1] - first_color[1]) * steps / 255) + first_color[1]; ret_color[2] = ((second_color[2] - first_color[2]) * steps / 255) + first_color[2]; return ret_color; }