pitrix/src/effects/marquee.cpp

26 lines
684 B
C++

#include "effects/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;
}