This commit is contained in:
2021-12-24 21:20:32 +01:00
parent 2ef3284a10
commit 4b8bc6b0ff
3 changed files with 14 additions and 18 deletions

View File

@@ -138,6 +138,7 @@ int Scroller::GetNumberOfLines()
int Scroller::AddLine(String line)
{
if (_nlines > MAX_LINES) return _nlines;
_Lines[_nlines] = line;
return _nlines++;
}
@@ -264,7 +265,7 @@ bool Scroller::TurnOn()
_x = 0;
_y = 0;
_nscrolled = 0;
_delayTicks = 0;
_delayTicks = 100;
return true;
}
@@ -281,17 +282,11 @@ void Scroller::TurnOff()
void Scroller::loop(ulong tick)
{
if (_off) return;
if (_off || _nlines == 0) return;
int delta = tick - _tick;
if (_lp == _nlines) {
_lp =0;
_nscrolled++;
_delayTicks = 50;
}
if (TimesScrolled() == _act_setting.control.loops) {
if (TimesScrolled() > _act_setting.control.loops) {
Serial.println("MAX LOOP");
TurnOff();
return;
@@ -300,10 +295,16 @@ void Scroller::loop(ulong tick)
if (_delayTicks - delta <= 0) _delayTicks = Scroll();
else _delayTicks -= delta;
if (_delayTicks < 0) _delayTicks = 0;
_tick = tick;
if (_lp > _nlines) {
_lp =0;
_nscrolled++;
_delayTicks = 500;
}
}
int Scroller::TimesScrolled()

View File

@@ -50,7 +50,7 @@ private:
int _nlines = 0;
int _lp = 0;
int _tick=0;
int _delayTicks = 0;
int _delayTicks = 100;
int _nscrolled = 0;
int _x = 0, _y = 0;
FastLED_NeoMatrix *_matrix;

View File

@@ -250,7 +250,7 @@ void callback(char* topic, byte* payload, unsigned int length) {
strncpy(msg,(char *)payload,length>255 ? 255 : length);
msg[length>255 ? 255 : length] = '\0';
if (scroller.IsOff()) showTextMqtt = true;
if (scroller.IsOff()) scroller.TurnOn();
scroller.AddLine(msg);
} else if (String("get/home/sensor/decka/bme280") == String(topic)) {
client.publish("home/sensor/decka/bme280/temperature",(String("N:") + String(bme.readTemperature())).c_str());
@@ -300,11 +300,6 @@ void loop()
updateNtpTime = false;
}
if (showTextMqtt) {
scroller.TurnOn();
showTextMqtt = false;
}
scroller.loop(tick);
client.loop();
}