Skip to content

Commit 6941cdd

Browse files
committed
V 4.65
1 parent 8e864da commit 6941cdd

26 files changed

+197
-414
lines changed

0_SETUP.ino

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
void setup()
22
{
33
Serial.begin(DEF_SERIAL);
4-
4+
55
#ifdef ESP32
66
snprintf(mqtt_clientid, maxHostSign, "ESP32-%llX", ESP.getEfuseMac());
7-
// Serial.printf("\n*** SYSINFO: MQTTDevice32 ID: %X\n", mqtt_clientid);
87
DEBUG_INFO("SYS", "\n*** SYSINFO: MQTTDevice32 ID: %X", mqtt_clientid);
98
// WLAN Events
109
WiFi.onEvent(WiFiEvent);
@@ -13,7 +12,6 @@ void setup()
1312
WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED);
1413
#elif ESP8266
1514
snprintf(mqtt_clientid, maxHostSign, "ESP8266-%08X", ESP.getChipId());
16-
// Serial.printf("\n*** SYSINFO: start up MQTTDevice - device ID: %s\n", mqtt_clientid);
1715
DEBUG_INFO("SYS", "\n*** SYSINFO: start up MQTTDevice - device ID: %s", mqtt_clientid);
1816
// WLAN Events
1917
wifiConnectHandler = WiFi.onStationModeGotIP(EM_WIFICONNECT);
@@ -121,7 +119,7 @@ void setupServer()
121119
server.on("/reqMiscAlert", handleRequestMiscAlert); // Misc Infos für WebConfig
122120
server.on("/reqFirm", handleRequestFirm); // Firmware version
123121
server.on("/setMisc", handleSetMisc); // Misc ändern
124-
server.on("/setMiscLang", handleSetMiscLang); // Misc ändern
122+
server.on("/setMiscLang", handleSetMiscLang); // Misc ändern
125123
server.on("/startHTTPUpdate", startHTTPUpdate); // Firmware WebUpdate
126124
server.on("/channel", handleChannel); // Server Sent Events will be handled from this URI
127125
server.on("/startSSE", startSSE); // Server Sent Events will be handled from this URI

1_LOOP.ino

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
void loop()
22
{
3-
server.handleClient(); // Webserver handle
3+
server.handleClient(); // Webserver handle
44
if (WiFi.status() == WL_CONNECTED)
55
{
6-
TickerPUBSUB.update(); // Ticker PubSubClient
6+
TickerPUBSUB.update(); // Ticker PubSubClient
77
#ifdef ESP8266
8-
if (startMDNS) // ESP8266 mDNS handle
8+
if (startMDNS) // ESP8266 mDNS handle
99
mdns.update();
1010
#endif
1111
}
1212

1313
TickerTime.update();
1414

15-
if (numberOfSensors > 0) // Ticker Sensoren
16-
TickerSen.update();
17-
if (numberOfActors > 0) // Ticker Aktoren
15+
if (numberOfSensors > 0) // Ticker Sensoren
16+
TickerSen.update();
17+
if (numberOfActors > 0) // Ticker Aktoren
1818
TickerAct.update();
19-
if (inductionStatus) // Ticker Induktion
19+
if (inductionStatus) // Ticker Induktion
2020
TickerInd.update();
21-
if (useDisplay) // Ticker Display
21+
if (useDisplay) // Ticker Display
2222
{
2323
TickerDisp.update();
2424
nextion.checkNex();

2_SENSOREN.ino

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public:
4949
{
5050
sensorsStatus = EM_DEVER;
5151
if (old_state)
52-
DEBUG_ERROR("SEN", "sensor address device error %s %s %s %s %s %s %s %s", sens_address[0], sens_address[1], sens_address[2], sens_address[3], sens_address[4], sens_address[5], sens_address[6], sens_address[7]);
52+
DEBUG_ERROR("SEN", "sensor address device error");
5353
sens_state = false;
5454
old_state = sens_state;
5555
}
@@ -106,7 +106,6 @@ public:
106106
old_state = sens_state;
107107
}
108108
sens_err = sensorsStatus;
109-
// DEBUG_VERBOSE("SEN", "Update value: %.03f type: %d id: %d", sens_value, sens_type, sens_ptid);
110109
} // if senstyp pt100
111110
else if (sens_type == 2)
112111
{
@@ -269,12 +268,10 @@ public:
269268
dtostrf(sens_value, -1, 1, buf);
270269
return buf;
271270
}
272-
273271
float getTotalValueFloat()
274272
{
275273
return round((calcOffset() - 0.05) * 10) / 10.0;
276274
}
277-
278275
char *getTotalValueString()
279276
{
280277
if (sens_value == -127.00)
@@ -286,7 +283,6 @@ public:
286283
}
287284
return buf;
288285
}
289-
290286
float calcOffset()
291287
{
292288
if (sens_value == -127.00)
@@ -307,7 +303,6 @@ public:
307303
}
308304
return sens_value;
309305
}
310-
311306
String getSens_adress_string()
312307
{
313308
return SensorAddressToString(sens_address);
@@ -513,10 +508,7 @@ void handleRequestSensors()
513508
{
514509
JsonObject sensorsObj = doc.add<JsonObject>();
515510
sensorsObj["name"] = sensors[i].getSensorName();
516-
sensorsObj["type"] = sensors[id].getSensType();
517-
// String str = sensors[i].getSensorName();
518-
// str.replace(" ", "%20"); // Erstze Leerzeichen für URL Charts
519-
// sensorsObj["namehtml"] = str;
511+
sensorsObj["type"] = sensors[i].getSensType();
520512
sensorsObj["offset1"] = sensors[i].getOffset1();
521513
sensorsObj["offset2"] = sensors[i].getOffset2();
522514
sensorsObj["sw"] = sensors[i].getSensorSwitch();
@@ -535,8 +527,8 @@ void handleRequestSensors()
535527

536528
sensorsObj["script"] = sensors[i].getSensorTopic();
537529
sensorsObj["cbpiid"] = sensors[i].getId();
538-
sensorsObj["type"] = sensors[id].getSensType();
539-
sensorsObj["pin"] = sensors[id].getSensPin();
530+
sensorsObj["type"] = sensors[i].getSensType();
531+
sensorsObj["pin"] = sensors[i].getSensPin();
540532
yield();
541533
}
542534
}

3_AKTOREN.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,6 @@ void actERR()
448448
actors[i].Update();
449449

450450
DEBUG_ERROR("ACT", "ACT MQTT event handling - actor: %s state: %d isOnBeforeError: %d", actors[i].getActorName().c_str(), actors[i].getActorState(), actors[i].getIsOnBeforeError());
451-
452451
}
453452
yield();
454453
}

4_INDUKTION.ino

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ public:
7272

7373
if (isPin(PIN_INTERRUPT))
7474
{
75-
// Interrupt deaktivert
7675
detachInterrupt(PIN_INTERRUPT);
7776
pinMode(PIN_INTERRUPT, OUTPUT);
7877
// digitalWrite(PIN_INTERRUPT, HIGH);
@@ -108,7 +107,6 @@ public:
108107
PIN_INTERRUPT = pinblue; // off possible
109108
if (isPin(PIN_INTERRUPT)) // D7
110109
{
111-
// Interrupt deaktivert
112110
pinMode(PIN_INTERRUPT, INPUT_PULLUP);
113111
attachInterrupt(digitalPinToInterrupt(PIN_INTERRUPT), readInputWrap, CHANGE);
114112
pins_used[PIN_INTERRUPT] = true;
@@ -125,7 +123,7 @@ public:
125123
{
126124
char subscribemsg[50];
127125
mqtttopic.toCharArray(subscribemsg, 50);
128-
DEBUG_VERBOSE("IND", "Subscribing to %s", subscribemsg);
126+
DEBUG_VERBOSE("IND", "Subscribing to %s", subscribemsg);
129127
pubsubClient.subscribe(subscribemsg);
130128
}
131129
}
@@ -137,7 +135,7 @@ public:
137135
{
138136
char subscribemsg[50];
139137
mqtttopic.toCharArray(subscribemsg, 50);
140-
DEBUG_VERBOSE("IND", "Unsubscribing from %s", subscribemsg);
138+
DEBUG_VERBOSE("IND", "Unsubscribing from %s", subscribemsg);
141139
pubsubClient.unsubscribe(subscribemsg);
142140
}
143141
}
@@ -297,7 +295,7 @@ public:
297295
// Glitch rausfiltern
298296
if (signalTime > 10)
299297
{
300-
if (ishigh) // PIN ist auf Rising, Bit senden hat gestartet :)
298+
if (ishigh) // PIN ist auf Rising, Bit senden hat gestartet
301299
{
302300
lastInterrupt = newInterrupt;
303301
}
@@ -348,7 +346,7 @@ public:
348346
if (isInduon && powerLevelOnError < 100 && induction_state) // powerlevelonerror == 100 -> kein event handling
349347
{
350348
powerLevelBeforeError = power;
351-
DEBUG_VERBOSE("IND", "MQTT event handling induction - power level: %d event power level: %d", power, powerLevelOnError);
349+
DEBUG_VERBOSE("IND", "MQTT event handling induction - power level: %d event power level: %d", power, powerLevelOnError);
352350
if (powerLevelOnError == 0)
353351
isInduon = false;
354352
else
@@ -472,7 +470,6 @@ public:
472470
induction inductionCooker = induction();
473471

474472
#ifdef ESP32
475-
// Interrupt deaktivert
476473
void ARDUINO_ISR_ATTR readInputWrap()
477474
{
478475
inductionCooker.readInput();
@@ -529,15 +526,15 @@ void handleRequestIndu()
529526
{
530527
case 0:
531528
pinswitched = inductionCooker.getPinWhite();
532-
tempNUMBEROFPINS = NUMBEROFPINS - 1; // without off
529+
tempNUMBEROFPINS = NUMBEROFPINS - 1; // ohne aus (-)
533530
break;
534531
case 1:
535532
pinswitched = inductionCooker.getPinYellow();
536-
tempNUMBEROFPINS = NUMBEROFPINS - 1; // without off
533+
tempNUMBEROFPINS = NUMBEROFPINS - 1;
537534
break;
538535
case 2:
539536
pinswitched = inductionCooker.getPinInterrupt();
540-
tempNUMBEROFPINS = NUMBEROFPINS; // with off
537+
tempNUMBEROFPINS = NUMBEROFPINS; // mit aus (-)
541538
break;
542539
}
543540
if (isPin(pinswitched))
@@ -570,7 +567,6 @@ void handleSetIndu()
570567
replyServerError("Server error set induction");
571568
return;
572569
}
573-
Serial.println(server.arg(0));
574570
inductionCooker.change(StringToPin(doc["pinw"]), StringToPin(doc["piny"]), StringToPin(doc["pinb"]), doc["topic"], doc["enabled"], doc["pl"]);
575571
saveConfig();
576572
replyOK();

5_DISPLAY.ino

Lines changed: 7 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ void readCustomCommand()
33
int tempID = nextion.cmdGroup;
44
int tempPage = nextion.cmdLength;
55

6-
if (tempID == 102) // 0x66 -> receive page command from readcustomcommand
6+
if (tempID == 102) // 0x66 -> page command empfangen
77
{
88
DEBUG_VERBOSE("DIS", "page command activePage: %d currentPage: %d lastcurrent: %d cmdLength: %d cmdGroup: %d", activePage, nextion.currentPageId, nextion.lastCurrentPageId, tempPage, tempID);
99
tickerDispCallback();
1010
}
11-
else // 0x65 -> receive component id from readcustomcommand
11+
else // 0x65 -> component id empfangen
1212
{
1313
DEBUG_VERBOSE("DIS", "componentID: %d activePage: %d currentPage: %d lastcurrent: %d cmdLength: %d", tempID, activePage, nextion.currentPageId, nextion.lastCurrentPageId, tempPage);
1414

@@ -46,7 +46,7 @@ void initDisplay()
4646
break;
4747
case 1:
4848
nextion.writeStr("page 1");
49-
nextion.currentPageId = 1; // setze currentPageId wenn Startseite nicht 0
49+
nextion.currentPageId = 1; // setze currentPageId wenn Startseite nicht 0
5050
nextion.lastCurrentPageId = 0;
5151
break;
5252
case 2:
@@ -61,7 +61,7 @@ void initDisplay()
6161
nextion.lastCurrentPageId = 1;
6262
break;
6363
}
64-
64+
6565
if (nextion.getDebug())
6666
DEBUG_INFO("CFG", "activePage: %d startPage: %d currentPage: %d lastcurrent: %d", activePage, startPage, nextion.currentPageId, nextion.lastCurrentPageId);
6767
tickerDispCallback();
@@ -134,31 +134,10 @@ void KettlePage() // Seite 1
134134

135135
void BrewPage() // Seite 2
136136
{
137-
// DEBUG_INFO("DIS", "BrewPage");
138137
if (strlen(structKettles[0].sensor) != 0)
139138
{
140139
nextion.writeStr(p1temp_text, structKettles[0].current_temp);
141140
nextion.writeStr(p1target_text, structKettles[0].target_temp);
142-
143-
// Serial.printf("KettlePage sensor %s current temp: %s\n", structKettles[0].sensor, structKettles[0].current_temp);
144-
145-
// if (sensors[0].getId() != "")
146-
// {
147-
// for (uint8_t i = 0; i < maxKettles; i++)
148-
// {
149-
// if (strcmp(structKettles[i].sensor, sensors[0].getId().c_str()) == 0)
150-
// {
151-
// p1temp_text.attribute("txt", structKettles[i].current_temp);
152-
// p1target_text.attribute("txt", structKettles[i].target_temp);
153-
// break;
154-
// }
155-
// }
156-
// }
157-
// else
158-
// {
159-
// p1temp_text.attribute("txt", structKettles[0].current_temp);
160-
// p1target_text.attribute("txt", "na");
161-
// }
162141
}
163142
else
164143
{
@@ -174,15 +153,11 @@ void BrewPage() // Seite 2
174153

175154
void InductionPage()
176155
{
177-
// log_e("Disp: InductionPage activeBrew: %d kettleID0: %s", activeBrew, structKettles[0].id);
178-
// p2uhrzeit_text
179-
// p2slider
180-
// p2temp_text
181156
// 316 = 0°C - 360 = 44°C - 223 = 100°C -- 53,4 je 20°C
182157

183158
int32_t aktSlider = nextion.readNum(p2slider);
184159
if (aktSlider >= 0 && aktSlider <= 100)
185-
inductionCooker.inductionNewPower(aktSlider); // inductionCooker.handleInductionPage(aktSlider);
160+
inductionCooker.inductionNewPower(aktSlider);
186161

187162
nextion.writeStr(p2temp_text, String(structKettles[0].current_temp).c_str());
188163
if (sensors[0].calcOffset() < 16.0)
@@ -387,7 +362,6 @@ void cbpi4steps_handlemqtt(unsigned char *payload)
387362

388363
for (uint8_t i = 0; i < stepsCounter; i++)
389364
{
390-
// if (structSteps[i].id == doc["id"])
391365
if (strcmp(structSteps[i].id, doc["id"]) == 0)
392366
{
393367
int minutes = props["Timer"].as<int>() | 0;
@@ -422,7 +396,6 @@ void cbpi4steps_handlemqtt(unsigned char *payload)
422396
current_step = true;
423397
for (uint8_t i = 0; i < stepsCounter; i++)
424398
{
425-
// if (structSteps[i].name == doc["name"])
426399
if (strcmp(structSteps[i].name, doc["name"]) == 0)
427400
{
428401
if (stepsCounter >= i + 1)
@@ -527,7 +500,6 @@ void cbpi4steps_handlemqtt(unsigned char *payload)
527500
}
528501
else
529502
{
530-
// if (props.containsKey("Timer"))
531503
if (props["Timer"].is<int>())
532504
{
533505
int minutes = props["Timer"].as<int>();
@@ -616,16 +588,8 @@ void cbpi4notification_handlemqtt(unsigned char *payload)
616588
strlcpy(notify, doc["message"] | "", maxNotifySign);
617589
}
618590

619-
// void cbpi4fermenter_handlemqtt(unsigned char *payload, unsigned int length)
620591
void cbpi4fermenter_handlemqtt(unsigned char *payload)
621592
{
622-
// Serial.printf("Display ferm len: %d\n", length);
623-
// for (unsigned int i = 0; i < length; i++)
624-
// {
625-
// Serial.print((char)payload[i]);
626-
// }
627-
// Serial.println();
628-
629593
JsonDocument doc;
630594
JsonDocument filter;
631595
filter["id"] = true;
@@ -635,13 +599,12 @@ void cbpi4fermenter_handlemqtt(unsigned char *payload)
635599
filter["target_temp"] = true;
636600
// filter["steps"]["name"] = true;
637601
DeserializationError error = deserializeJson(doc, (const char *)payload, DeserializationOption::Filter(filter));
638-
// DeserializationError error = deserializeJson(doc, (const char *)payload);
639602
if (error)
640603
{
641604
DEBUG_ERROR("DIS", "handlemqtt fermenter deserialize Json error %s MemoryUsage %d", error.c_str());
642605
return;
643606
}
644-
607+
645608
fermenterStatus = doc["state"] | false;
646609

647610
for (uint8_t i = 0; i < maxKettles; i++)
@@ -655,9 +618,6 @@ void cbpi4fermenter_handlemqtt(unsigned char *payload)
655618
char sensorupdate[45];
656619
sprintf(sensorupdate, "%s%s", cbpi4sensor_topic, structKettles[i].sensor);
657620
pubsubClient.subscribe(sensorupdate);
658-
659-
// Serial.printf("#%d new kettle name %s kettle-id: %s sensor-id: %s target: %s update: %s\n", i, structKettles[i].name, structKettles[i].id, structKettles[i].sensor, structKettles[i].target_temp, sensorupdate);
660-
661621
switch (i)
662622
{
663623
case 0:
@@ -683,7 +643,6 @@ void cbpi4fermenter_handlemqtt(unsigned char *payload)
683643
{
684644
if (strcmp(structKettles[i].id, doc["id"]) == 0)
685645
{
686-
// Serial.printf("#%d old kettle name %s kettle-id: %s sensor-id: %s target: %s update: %s\n", i, structKettles[i].name, structKettles[i].id, structKettles[i].sensor, structKettles[i].target_temp, sensorupdate);
687646
dtostrf(doc["target_temp"], -1, 1, structKettles[i].target_temp);
688647
switch (i)
689648
{
@@ -718,12 +677,11 @@ void cbpi4fermentersteps_handlemqtt(unsigned char *payload)
718677
DEBUG_ERROR("DIS", "handlemqtt notification deserialize Json error %s MemoryUsage %d", error.c_str());
719678
return;
720679
}
721-
680+
722681
if (fermenterStatus)
723682
{
724683
strlcpy(currentStepName, doc["name"] | "", maxStepSign);
725684
sprintf(currentStepRemain, "%s", "");
726-
// sprintf(currentStepRemain, "%02d:%02d:%02d", doc["props"]["TimerD"].as<int>(), doc["props"]["TimerH"].as<int>(), doc["props"]["TimerM"].as<int>());
727685
}
728686
else
729687
{

0 commit comments

Comments
 (0)