This commit is contained in:
2021-11-30 16:03:06 +01:00
parent a9e6126e8f
commit e88638c146
3 changed files with 7 additions and 55 deletions

View File

@@ -135,7 +135,6 @@ int Scroller::GetNumberOfLines()
int Scroller::AddLine(String line) int Scroller::AddLine(String line)
{ {
_Lines[_nlines] = line; _Lines[_nlines] = line;
//SetParameters(_nlines);
return _nlines++; return _nlines++;
} }
@@ -143,7 +142,6 @@ int Scroller::AddLines(String* lines,int nlines)
{ {
for (int i=0; i < nlines; i++) { for (int i=0; i < nlines; i++) {
_Lines[i] = lines[i]; _Lines[i] = lines[i];
//SetParameters(i);
} }
_nlines = nlines; _nlines = nlines;
@@ -266,11 +264,6 @@ void Scroller::TurnOff()
_off = true; _off = true;
} }
void Scroller::SetColors(uint16_t *colors)
{
_colors = colors;
}
void Scroller::loop(ulong tick) void Scroller::loop(ulong tick)
{ {
if (_off) return; if (_off) return;

View File

@@ -7,15 +7,16 @@
#include "ESP32TimerInterrupt.h" #include "ESP32TimerInterrupt.h"
#define SCROLLER_TICK_TIME 100 //ms #define SCROLLER_TICK_TIME 50 //ms
typedef struct { typedef struct {
char const *code; char const *code;
char const *name; char const *name;
enum{COLOR, BCOLOR, CONTROL, CONTOL_WITH_PARAM} tt; //Tag Type enum{COLOR, BCOLOR, FONT, CONTROL, CONTOL_WITH_PARAM} tt; //Tag Type
union { union {
uint32_t color; uint32_t color;
uint16_t control; uint16_t control;
void *font;
} ; } ;
} eDict_t; } eDict_t;
@@ -48,7 +49,6 @@ private:
int _nscrolled = 0; int _nscrolled = 0;
int _x = 0, _y = 0; int _x = 0, _y = 0;
FastLED_NeoMatrix *_matrix; FastLED_NeoMatrix *_matrix;
uint16_t *_colors;
int _max_loops; int _max_loops;
bool _off = true; bool _off = true;
@@ -61,7 +61,6 @@ public:
String LineUnescaped(String); String LineUnescaped(String);
void DumpSetting(Setting &); void DumpSetting(Setting &);
bool decodeEscape2Setting(String es); bool decodeEscape2Setting(String es);
void SetColors(uint16_t *colors);
void SetMatrix(FastLED_NeoMatrix *matrix); void SetMatrix(FastLED_NeoMatrix *matrix);
int AddLine(String line); int AddLine(String line);
void SetParameters(int line,uint8_t color=1,uint8_t brightness=10,int timeout_off=2000,int timeout_on=2000,int speed=200); void SetParameters(int line,uint8_t color=1,uint8_t brightness=10,int timeout_off=2000,int timeout_on=2000,int speed=200);

View File

@@ -61,11 +61,7 @@ IotWebConfParameter mqttServerParam = IotWebConfParameter("MQTT server", "mqttSe
#define NUMMATRIX (lcdw*lcdh) #define NUMMATRIX (lcdw*lcdh)
CRGB matrixleds[NUMMATRIX]; CRGB matrixleds[NUMMATRIX];
FastLED_NeoMatrix *matrix; FastLED_NeoMatrix *matrix;
uint16_t colors[] = {
Framebuffer_GFX::Color(255, 0, 0), Framebuffer_GFX::Color(0, 255, 0), Framebuffer_GFX::Color(0, 0, 255)};
WiFiUDP ntpUDP; WiFiUDP ntpUDP;
// You can specify the time server pool and the offset (in seconds, can be // You can specify the time server pool and the offset (in seconds, can be
@@ -113,7 +109,7 @@ void setup_matrix()
matrix->begin(); matrix->begin();
matrix->setTextWrap(false); matrix->setTextWrap(false);
matrix->setBrightness(20); matrix->setBrightness(20);
matrix->setTextColor(colors[1]); matrix->setTextColor(Framebuffer_GFX::Color24to16(CRGB::Green));
matrix->print("Start"); matrix->print("Start");
matrix->show(); matrix->show();
delay(1000); delay(1000);
@@ -165,7 +161,6 @@ void setup()
setup_matrix(); setup_matrix();
scroller.init(); scroller.init();
scroller.SetColors(colors);
scroller.SetMatrix(matrix); scroller.SetMatrix(matrix);
Serial.println(F("BME280 test")); Serial.println(F("BME280 test"));
@@ -240,41 +235,6 @@ boolean reconnect() {
} }
} }
void decode_payload(String msg)
{
/*StringSplitter *splitter = new StringSplitter(msg, ';', 2);
int n = 0;
int i = 0;
String s,m;
int color=1,brightness=10,speed=200, off=2000,on=2000;
if (splitter->getItemCount() == 2)
s = splitter->getItemAtIndex(n++);
m = splitter->getItemAtIndex(n++);
if (n == 2) {
StringSplitter *splitter = new StringSplitter(s, ':', 10);
String cmd,param;
while (i < splitter->getItemCount()) {
cmd = splitter->getItemAtIndex(i++);
param = splitter->getItemAtIndex(i++);
Serial.printf("cmd=%s,param=%s\n",cmd,param);
if (cmd == "c") color = param.toInt();
if (cmd == "b") brightness = param.toInt();
if (cmd == "s") speed = param.toInt();
if (cmd == "off") off = param.toInt();
if (cmd == "on") on = param.toInt();
}
}
*/
scroller.AddLine(msg);
/*if (n == 2) {
Serial.printf("color=%d,brightness=%d,off=%d,on=%d,speed=%d\n",color,brightness,off,on,speed);
scroller.SetParameters(i,color,brightness,off,on,speed);
}*/
}
void callback(char* topic, byte* payload, unsigned int length) { void callback(char* topic, byte* payload, unsigned int length) {
char msg[256]; char msg[256];
@@ -289,13 +249,13 @@ void callback(char* topic, byte* payload, unsigned int length) {
} }
Serial.println(); Serial.println();
strncpy(msg,(char *)payload,length); strncpy(msg,(char *)payload,length>255 ? 255 : length);
msg[length] = '\0'; msg[length>255 ? 255 : length] = '\0';
// Switch on the LED if an 1 was received as first character // Switch on the LED if an 1 was received as first character
//scroller.TurnOff(); //scroller.TurnOff();
//scroller.DeleteLines(); //scroller.DeleteLines();
decode_payload(msg); scroller.AddLine(msg);
showTextMqtt = true; showTextMqtt = true;
} 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());