cleaned
This commit is contained in:
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