cleaned
This commit is contained in:
@@ -135,7 +135,6 @@ int Scroller::GetNumberOfLines()
|
||||
int Scroller::AddLine(String line)
|
||||
{
|
||||
_Lines[_nlines] = line;
|
||||
//SetParameters(_nlines);
|
||||
return _nlines++;
|
||||
}
|
||||
|
||||
@@ -143,7 +142,6 @@ int Scroller::AddLines(String* lines,int nlines)
|
||||
{
|
||||
for (int i=0; i < nlines; i++) {
|
||||
_Lines[i] = lines[i];
|
||||
//SetParameters(i);
|
||||
}
|
||||
_nlines = nlines;
|
||||
|
||||
@@ -266,11 +264,6 @@ void Scroller::TurnOff()
|
||||
_off = true;
|
||||
}
|
||||
|
||||
void Scroller::SetColors(uint16_t *colors)
|
||||
{
|
||||
_colors = colors;
|
||||
}
|
||||
|
||||
void Scroller::loop(ulong tick)
|
||||
{
|
||||
if (_off) return;
|
||||
|
||||
@@ -7,15 +7,16 @@
|
||||
#include "ESP32TimerInterrupt.h"
|
||||
|
||||
|
||||
#define SCROLLER_TICK_TIME 100 //ms
|
||||
#define SCROLLER_TICK_TIME 50 //ms
|
||||
|
||||
typedef struct {
|
||||
char const *code;
|
||||
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 {
|
||||
uint32_t color;
|
||||
uint16_t control;
|
||||
void *font;
|
||||
} ;
|
||||
} eDict_t;
|
||||
|
||||
@@ -48,7 +49,6 @@ private:
|
||||
int _nscrolled = 0;
|
||||
int _x = 0, _y = 0;
|
||||
FastLED_NeoMatrix *_matrix;
|
||||
uint16_t *_colors;
|
||||
int _max_loops;
|
||||
bool _off = true;
|
||||
|
||||
@@ -61,7 +61,6 @@ public:
|
||||
String LineUnescaped(String);
|
||||
void DumpSetting(Setting &);
|
||||
bool decodeEscape2Setting(String es);
|
||||
void SetColors(uint16_t *colors);
|
||||
void SetMatrix(FastLED_NeoMatrix *matrix);
|
||||
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);
|
||||
|
||||
48
src/main.cpp
48
src/main.cpp
@@ -61,11 +61,7 @@ IotWebConfParameter mqttServerParam = IotWebConfParameter("MQTT server", "mqttSe
|
||||
#define NUMMATRIX (lcdw*lcdh)
|
||||
|
||||
CRGB matrixleds[NUMMATRIX];
|
||||
|
||||
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;
|
||||
|
||||
// You can specify the time server pool and the offset (in seconds, can be
|
||||
@@ -113,7 +109,7 @@ void setup_matrix()
|
||||
matrix->begin();
|
||||
matrix->setTextWrap(false);
|
||||
matrix->setBrightness(20);
|
||||
matrix->setTextColor(colors[1]);
|
||||
matrix->setTextColor(Framebuffer_GFX::Color24to16(CRGB::Green));
|
||||
matrix->print("Start");
|
||||
matrix->show();
|
||||
delay(1000);
|
||||
@@ -165,7 +161,6 @@ void setup()
|
||||
setup_matrix();
|
||||
|
||||
scroller.init();
|
||||
scroller.SetColors(colors);
|
||||
scroller.SetMatrix(matrix);
|
||||
|
||||
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) {
|
||||
char msg[256];
|
||||
|
||||
@@ -289,13 +249,13 @@ void callback(char* topic, byte* payload, unsigned int length) {
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
strncpy(msg,(char *)payload,length);
|
||||
msg[length] = '\0';
|
||||
strncpy(msg,(char *)payload,length>255 ? 255 : length);
|
||||
msg[length>255 ? 255 : length] = '\0';
|
||||
|
||||
// Switch on the LED if an 1 was received as first character
|
||||
//scroller.TurnOff();
|
||||
//scroller.DeleteLines();
|
||||
decode_payload(msg);
|
||||
scroller.AddLine(msg);
|
||||
showTextMqtt = true;
|
||||
} else if (String("get/home/sensor/decka/bme280") == String(topic)) {
|
||||
client.publish("home/sensor/decka/bme280/temperature",(String("N:") + String(bme.readTemperature())).c_str());
|
||||
|
||||
Reference in New Issue
Block a user