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

View File

@@ -50,7 +50,7 @@ private:
int _nlines = 0; int _nlines = 0;
int _lp = 0; int _lp = 0;
int _tick=0; int _tick=0;
int _delayTicks = 0; int _delayTicks = 100;
int _nscrolled = 0; int _nscrolled = 0;
int _x = 0, _y = 0; int _x = 0, _y = 0;
FastLED_NeoMatrix *_matrix; 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); strncpy(msg,(char *)payload,length>255 ? 255 : length);
msg[length>255 ? 255 : length] = '\0'; msg[length>255 ? 255 : length] = '\0';
if (scroller.IsOff()) showTextMqtt = true; if (scroller.IsOff()) scroller.TurnOn();
scroller.AddLine(msg); scroller.AddLine(msg);
} else if (String("get/home/sensor/decka/bme280") == String(topic)) { } else if (String("get/home/sensor/decka/bme280") == String(topic)) {
client.publish("home/sensor/decka/bme280/temperature",(String("N:") + String(bme.readTemperature())).c_str()); client.publish("home/sensor/decka/bme280/temperature",(String("N:") + String(bme.readTemperature())).c_str());
@@ -300,11 +300,6 @@ void loop()
updateNtpTime = false; updateNtpTime = false;
} }
if (showTextMqtt) {
scroller.TurnOn();
showTextMqtt = false;
}
scroller.loop(tick); scroller.loop(tick);
client.loop(); client.loop();
} }