Added effect marquee, which will scroll a given message through the display.
This commit is contained in:
parent
73b8d162c7
commit
781954d7f1
18
include/effect_marquee.h
Normal file
18
include/effect_marquee.h
Normal file
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "prototypes.h"
|
||||
#include "functions.h"
|
||||
#include "Effect.h"
|
||||
|
||||
class MarqueeEffect : public Effect {
|
||||
private:
|
||||
Window* window = new Window(0, 0, LED_WIDTH, LED_HEIGHT-6);
|
||||
String _text = String("No text set +++ ");
|
||||
saccum78 _position = (window->width<<8);
|
||||
public:
|
||||
boolean supports_window = true;
|
||||
boolean can_be_shown_with_clock();
|
||||
void loop();
|
||||
void apply_option(String key, String value) override;
|
||||
};
|
||||
|
26
src/effect_marquee.cpp
Normal file
26
src/effect_marquee.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#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;
|
||||
}
|
@ -20,6 +20,7 @@
|
||||
#include "effect_dvd.h"
|
||||
#include "effect_analogclock.h"
|
||||
#include "effect_sines.h"
|
||||
#include "effect_marquee.h"
|
||||
#include "effect_blur2d.h"
|
||||
|
||||
Effect* current_effect;
|
||||
@ -57,6 +58,7 @@ Effect* select_effect(uint32_t code) {
|
||||
case 25: case 0x8CA97519 /* analog_clock */ : return new AnalogClockEffect();
|
||||
case 26: case 0xADB18CC5 /* sines */ : return new SinesEffect();
|
||||
case 27: case 0x0407881E /* blur2d */ : return new Blur2DEffect();
|
||||
case 28: case 0x935CFA7C /* marquee */ : return new MarqueeEffect();
|
||||
default : return NULL;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user