pitrix/src/effect_marquee.cpp

27 lines
702 B
C++
Raw Normal View History

#include "effect_marquee.h"
#include "fonts.h"
boolean MarqueeEffect::can_be_shown_with_clock() {
return true;
}
void MarqueeEffect::loop() {
static int loop_counter = 0;
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;
}