Added blink animation (Resolves #106)
This commit is contained in:
@ -339,7 +339,8 @@ void secondsToHMS( const float seconds, uint16_t &h, uint16_t &m, uint16_t &s )
|
||||
h = t;
|
||||
}
|
||||
|
||||
std::string get_current_driving_time_string() {
|
||||
std::string get_current_driving_time_string()
|
||||
{
|
||||
uint16_t hour{};
|
||||
uint16_t minute{};
|
||||
uint16_t second{};
|
||||
@ -347,3 +348,27 @@ std::string get_current_driving_time_string() {
|
||||
std::string out = fmt::format("Drive: {:02d}:{:02d}:{:02d}", hour, minute, second);
|
||||
return out;
|
||||
}
|
||||
|
||||
uint8_t time_to_percent(std::chrono::duration<long, std::ratio<1,1000>> repeat, std::chrono::duration<long, std::ratio<1,1000>> riseTime, std::chrono::duration<long, std::ratio<1,1000>> fullTime, size_t numLeds, bool invert)
|
||||
{
|
||||
const auto now = espchrono::millis_clock::now().time_since_epoch() % repeat;
|
||||
int activated = invert ? numLeds : 0;
|
||||
if (now <= riseTime)
|
||||
{
|
||||
if (invert)
|
||||
{
|
||||
activated = numLeds - ((now*numLeds) / riseTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
activated = (now*numLeds) / riseTime;
|
||||
}
|
||||
}
|
||||
else if (now < riseTime + fullTime)
|
||||
{
|
||||
activated = invert ? 0 : numLeds;
|
||||
}
|
||||
else
|
||||
activated = invert ? numLeds : 0;
|
||||
return activated;
|
||||
}
|
||||
|
Reference in New Issue
Block a user