pitrix/src/effect_marquee.cpp
Fabian Schlenz 382631d7d7 Effect#loop now gets the time since the last run of the loop in ms. This enables
the effects to show animations that stay fluid independent of the current frame rate.
2019-10-01 06:29:32 +02:00

26 lines
683 B
C++

#include "effect_marquee.h"
#include "fonts.h"
boolean MarqueeEffect::can_be_shown_with_clock() {
return true;
}
void MarqueeEffect::loop(uint16_t ms) {
window->clear();
CRGB color = CHSV(0, 255, 255);
uint16_t width = _text.length() * 6;
window->drawSubText(&font5x7, _position, 0, _text, &color);
_position-=100;
if ((_position>>8) <= -width) { // Font is out of the window
_position = 0;
}
if ((_position>>8) + width < window->width) { // Text isn't filling the window up any more
window->drawSubText(&font5x7, _position + (width<<8), 0, _text, &color);
}
}
void MarqueeEffect::apply_option(String key, String value) {
if (key.equals("text")) _text = value;
}