Skip to content

Commit a4783bf

Browse files
committed
FIX: Aufgeräumt
1 parent b471753 commit a4783bf

7 files changed

Lines changed: 74 additions & 52 deletions

File tree

Nemesis.ino

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ void setup() {
131131

132132
// Check HTTP Update
133133
check_http_update();
134-
135-
chart.on = false;
136134
}
137135
}
138136

c_bot.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ void set_iot(bool init) {
4040
iot.P_MQTT_USER = "";
4141
iot.P_MQTT_PASS = "";
4242
iot.P_MQTT_QoS = 0;
43-
4443
}
4544

4645
iot.TS_show8 = false;

c_fs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ bool loadconfig(byte count) {
272272
else return false;
273273
if (json.containsKey("god")) sys.god = json["god"];
274274
else return false;
275+
if (json.containsKey("pitsup")) sys.pitsupply = json["pitsup"];
276+
//else return false;
275277

276278
}
277279
break;
@@ -443,6 +445,7 @@ bool setconfig(byte count, const char* data[2]) {
443445
json["batmin"] = battery.min;
444446
json["logsec"] = log_sector;
445447
json["god"] = sys.god;
448+
json["pitsup"] = sys.pitsupply;
446449

447450
size_t size = json.measureLength() + 1;
448451
clearEE(EESYSTEM,EESYSTEMBEGIN); // Bereich reinigen

c_init.h

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,16 @@
2323
#include <ESP8266WiFi.h> // WIFI
2424
#include <ESP8266WiFiMulti.h> // WIFI
2525
//#include <WiFiClientSecure.h> // HTTPS
26-
//#include <WiFiUdp.h> // NTP
2726
#include <TimeLib.h> // TIME
2827
#include <EEPROM.h> // EEPROM
2928
#include <FS.h> // FILESYSTEM
3029
#include <ArduinoJson.h> // JSON
31-
#include <ESP8266mDNS.h>
32-
#include <ESPAsyncTCP.h>
30+
#include <ESP8266mDNS.h> // mDNS
31+
#include <ESPAsyncTCP.h> // ASYNCTCP
3332
#include <ESPAsyncWebServer.h> // https://github.com/me-no-dev/ESPAsyncWebServer/issues/60
34-
#include "AsyncJson.h"
35-
#include <AsyncMqttClient.h>
36-
#include <StreamString.h>
33+
#include "AsyncJson.h" // ASYNCJSON
34+
#include <AsyncMqttClient.h> // ASYNCMQTT
35+
//#include <StreamString.h>
3736

3837
extern "C" {
3938
#include "user_interface.h"
@@ -49,9 +48,9 @@ extern "C" uint32_t _SPIFFS_end; // FIRST ADRESS AFTER FS
4948

5049
// ++++++++++++++++++++++++++++++++++++++++++++++++++
5150
// SETTINGS
52-
int co = 32;
51+
5352
// HARDWARE
54-
#define FIRMWAREVERSION "v0.7.9"
53+
#define FIRMWAREVERSION "v0.8.0"
5554
#define APIVERSION "v1"
5655

5756
// CHANNELS
@@ -155,13 +154,14 @@ struct ChannelData {
155154

156155
ChannelData ch[CHANNELS];
157156

157+
// SENSORTYP
158158
String ttypname[SENSORTYPEN] = {"Maverick","Fantast-Neu","Fantast","iGrill2","ET-73",
159159
"Perfektion","5K3A1B","MOUSER47K","100K6A1B","Weber_6743",
160160
"Santos"};
161-
162-
161+
// TEMPERATURE UNIT
163162
String temp_unit = "C";
164-
//String colors[8] = {"#6495ED", "#CD2626", "#66CDAA", "#F4A460", "#D02090", "#FFEC8B", "#BA55D3", "#008B8B"};
163+
164+
// CHANNEL COLORS
165165
String colors[8] = {"#0C4C88","#22B14C","#EF562D","#FFC100","#A349A4","#804000","#5587A2","#5C7148"};
166166

167167
// PITMASTER
@@ -182,6 +182,7 @@ struct Pitmaster {
182182
Pitmaster pitmaster;
183183
int pidsize;
184184

185+
// PID PROFIL
185186
struct PID {
186187
String name;
187188
byte id;
@@ -207,6 +208,7 @@ struct PID {
207208
};
208209
PID pid[PITMASTERSIZE];
209210

211+
// AUTOTUNE
210212
struct AutoTune {
211213
bool storeValues;
212214
float temp; // BETRIEBS-TEMPERATUR
@@ -243,6 +245,7 @@ struct AutoTune {
243245

244246
AutoTune autotune;
245247

248+
// DUTYCYCLE
246249
struct DutyCycle {
247250
long timer;
248251
int value;
@@ -273,15 +276,14 @@ uint32_t log_sector; // erster Sector von APP2
273276
uint32_t freeSpaceStart; // First Sector of OTA
274277
uint32_t freeSpaceEnd; // Last Sector+1 of OTA
275278

279+
// NOTIFICATION
276280
struct Notification {
277281
byte ch; // CHANNEL
278282
bool limit; // LIMIT: 0 = LOW TEMPERATURE, 1 = HIGH TEMPERATURE
279283
};
280284

281285
Notification notification;
282286

283-
284-
285287
// SYSTEM
286288
struct System {
287289
byte hwversion; // HARDWARE VERSION
@@ -295,13 +297,13 @@ struct System {
295297
String getupdate;
296298
bool autoupdate;
297299
bool god;
300+
bool pitsupply;
298301
};
299302

300303
System sys;
301304
bool stby = false; // USB POWER SUPPLY?
302305
byte pulsalarm = 1;
303306

304-
305307
// BATTERY
306308
struct Battery {
307309
int voltage; // CURRENT VOLTAGE
@@ -342,22 +344,22 @@ struct IoT {
342344

343345
IoT iot;
344346

345-
// Chart
347+
// CLOUD CHART/LOG
346348
struct Chart {
347-
bool on; // NANO CHART ON / OFF
348-
String token; // NANO CHART TOKEN
349-
int interval; // NANO CHART INTERVALL
349+
bool on = false; // NANO CHART ON / OFF
350+
// String token; // NANO CHART TOKEN
351+
// int interval; // NANO CHART INTERVALL
350352
};
351353

352354
Chart chart;
353355

354-
355356
// OLED
356357
int current_ch = 0; // CURRENTLY DISPLAYED CHANNEL
357358
bool LADENSHOW = false; // LOADING INFORMATION?
358359
bool displayblocked = false; // No OLED Update
359360
enum {NO, CONFIGRESET, CHANGEUNIT, OTAUPDATE, HARDWAREALARM, IPADRESSE, AUTOTUNE};
360361

362+
// OLED QUESTION
361363
struct MyQuestion {
362364
int typ;
363365
int con;
@@ -388,9 +390,6 @@ struct HoldSSID {
388390
};
389391
HoldSSID holdssid;
390392

391-
// NTP
392-
byte packetBuffer[ NTP_PACKET_SIZE]; //buffer to hold incoming and outgoing packets
393-
394393
// BUTTONS
395394
byte buttonPins[]={btn_r,btn_l}; // Pins
396395
#define NUMBUTTONS sizeof(buttonPins)
@@ -528,6 +527,9 @@ void sendDataCloud();
528527

529528
String cloudData();
530529

530+
// ++++++++++++++++++++++++++++++++++++++++++++++++++++
531+
532+
531533
//++++++++++++++++++++++++++++++++++++++++++++++++++++++
532534
// Initialize Serial
533535
void set_serial() {
@@ -554,6 +556,7 @@ void set_system() {
554556
sys.god = false;
555557
battery.max = BATTMAX;
556558
battery.min = BATTMIN;
559+
sys.pitsupply = false;
557560
}
558561

559562

@@ -627,7 +630,6 @@ void timer_iot() {
627630

628631
}
629632

630-
631633
//++++++++++++++++++++++++++++++++++++++++++++++++++++++
632634
// DataLog Timer
633635
void timer_datalog() {
@@ -846,6 +848,25 @@ String getMacAddress() {
846848
}
847849

848850

851+
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
852+
// Cloud Token Generator
853+
String newToken() {
854+
String stamp = String(now(), HEX);
855+
int x = 10 - stamp.length(); //pow(16,(10 - timestamp.length()));
856+
long y = 1; // long geht bis 16^7
857+
if (x > 7) {
858+
stamp += String(random(268435456), HEX);
859+
x -= 7;
860+
}
861+
for (int i=0;i<x;i++) y *= 16;
862+
stamp += String(random(y), HEX);
863+
return (String) String(ESP.getChipId(), HEX) + stamp;
864+
}
865+
866+
867+
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
868+
// GET/POST-Request
869+
849870
#define SAVEDATALINK "/saveData.php"
850871
#define SAVELOGSLINK "/saveLogs.php"
851872
#define SENDTSLINK "/update.json"
@@ -922,7 +943,6 @@ String createParameter(int para) {
922943
return command;
923944
}
924945

925-
926946
String createCommand(bool meth, int para, const char * link, const char * host, int content) {
927947

928948
String command;
@@ -998,20 +1018,6 @@ void serverAnswer(String payload, size_t len) {
9981018
}
9991019
}
10001020

1001-
String newToken() {
1002-
String stamp = String(now(), HEX);
1003-
int x = 10 - stamp.length(); //pow(16,(10 - timestamp.length()));
1004-
long y = 1; // long geht bis 16^7
1005-
if (x > 7) {
1006-
stamp += String(random(268435456), HEX);
1007-
x -= 7;
1008-
}
1009-
for (int i=0;i<x;i++) y *= 16;
1010-
stamp += String(random(y), HEX);
1011-
Serial.println(y);
1012-
return (String) String(ESP.getChipId(), HEX) + stamp;
1013-
}
1014-
10151021
void printRequest(uint8_t* datas) {
10161022
DPRINTF("[REQUEST]\t%s\r\n", (const char*)datas);
10171023
}

c_ota.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
* Example:
2323
*
2424
* Check for new update
25-
* http://nano.wlanthermo.de/checkUpdate.php?device="nano"&serial="Serialnummer"&hw_version="v1"&sw_version="currentVersion"
25+
* http://update.wlanthermo.de/checkUpdate.php?device="nano"&serial="Serialnummer"&hw_version="v1"&sw_version="currentVersion"
2626
* ----------------------------------------------------------------------------------------------------------------------------------------
2727
* Download Firmware-version XYZ
28-
* http://nano.wlanthermo.de/checkUpdate.php?device="nano"serial="Serialnummer"&hw_version="v1"&sw_version="currentVersion"&getFirmware="XYZ"
28+
* http://update.wlanthermo.de/checkUpdate.php?device="nano"serial="Serialnummer"&hw_version="v1"&sw_version="currentVersion"&getFirmware="XYZ"
2929
* ----------------------------------------------------------------------------------------------------------------------------------------
3030
* Download Spiffs-version XYZ
31-
* http://nano.wlanthermo.de/checkUpdate.php?device="nano"serial="Serialnummer"&hw_version="v1"&sw_version="currentVersion"&getSpiffs="XYZ"
31+
* http://update.wlanthermo.de/checkUpdate.php?device="nano"serial="Serialnummer"&hw_version="v1"&sw_version="currentVersion"&getSpiffs="XYZ"
3232
* ----------------------------------------------------------------------------------------------------------------------------------------
3333
*/
3434

c_pitmaster.h

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -445,13 +445,19 @@ void pitmaster_control() {
445445
float y;
446446
pitmaster.last = millis();
447447

448+
// DUTY CYCLE PROCESS
448449
if (dutycycle.on) {
449450
if (!dutycycle.dc && (millis() - dutycycle.timer < 1000))
450451
pitmaster.value = 50;
451452
else pitmaster.value = dutycycle.value;
452-
if (dutycycle.aktor == 1) analogWrite(PITMASTER1,map(pitmaster.value,0,100,0,1024));
453-
else if (dutycycle.aktor == 0) {
453+
if (dutycycle.aktor == 1) { // FAN
454+
if (sys.pitsupply && sys.hwversion > 1) digitalWrite(PITSUPPLY, HIGH); // 12V Supply
455+
else digitalWrite(PITSUPPLY, LOW);
456+
analogWrite(PITMASTER1,map(pitmaster.value,0,100,0,1024));
457+
}
458+
else if (dutycycle.aktor == 0) { // SSR
454459
pitmaster.msec = map(pitmaster.value,0,100,0,pitmaster.pause);
460+
if (sys.hwversion > 1) digitalWrite(PITSUPPLY, HIGH); // 12V Supply
455461
if (pitmaster.msec > 0) digitalWrite(PITMASTER1, HIGH);
456462
if (pitmaster.msec < pitmaster.pause) pitmaster.event = true; // außer bei 100%
457463
}
@@ -460,10 +466,13 @@ void pitmaster_control() {
460466
else if (autotune.initialized) pitmaster.value = autotunePID();
461467
else if (!pitmaster.manual) pitmaster.value = PID_Regler();
462468
// falls manual wird value vorgegeben
463-
469+
470+
// NORMAL PITMASTER PROCESS
464471
if (pid[pitmaster.pid].aktor == 1) { // FAN
465472
int _DCmin = map(pid[pitmaster.pid].DCmin,0,100,0,1024);
466473
int _DCmax = map(pid[pitmaster.pid].DCmax,0,100,0,1024);
474+
if (sys.pitsupply && sys.hwversion > 1) digitalWrite(PITSUPPLY, HIGH); // 12V Supply
475+
else digitalWrite(PITSUPPLY, LOW);
467476
if (pitmaster.value == 0) { // bei 0 soll der Lüfter auch stehen
468477
analogWrite(PITMASTER1,0);
469478
pitmaster.timer0 = millis();
@@ -478,14 +487,16 @@ void pitmaster_control() {
478487
int _DCmin = map(pid[pitmaster.pid].DCmin,0,100,0,pitmaster.pause);
479488
int _DCmax = map(pid[pitmaster.pid].DCmax,0,100,0,pitmaster.pause);
480489
pitmaster.msec = map(pitmaster.value,0,100,_DCmin,_DCmax);
490+
if (sys.hwversion > 1) digitalWrite(PITSUPPLY, HIGH); // 12V Supply
481491
if (pitmaster.msec > 0) digitalWrite(PITMASTER1, HIGH);
482492
if (pitmaster.msec < pitmaster.pause) pitmaster.event = true; // außer bei 100%
483493
}
484494
}
485-
} else {
486-
if (pid[pitmaster.pid].aktor == 1)
495+
} else { // TURN OFF PITMASTER
496+
if (pid[pitmaster.pid].aktor == 1) // FAN
487497
analogWrite(PITMASTER1, LOW);
488-
else digitalWrite(PITMASTER1, LOW);
498+
else digitalWrite(PITMASTER1, LOW); // SSR
499+
if (sys.hwversion > 1) digitalWrite(PITSUPPLY, LOW); // 12V Supply
489500
pitmaster.value = 0;
490501
pitmaster.event = false;
491502
pitmaster.msec = 0;

c_server.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,13 @@ void server_setup() {
365365
});
366366

367367
server.on("/pitsupply",[](AsyncWebServerRequest *request){
368-
if (sys.hwversion == 2) digitalWrite(PITSUPPLY, HIGH);
369-
request->send(200, "text/plain", "aktiviert");
368+
if (sys.hwversion > 1 && !sys.pitsupply) {
369+
sys.pitsupply = true;
370+
request->send(200, "text/plain", "aktiviert");
371+
} else {
372+
sys.pitsupply = false;
373+
request->send(200, "text/plain", "deaktiviert");
374+
}
370375
});
371376

372377
server.on("/startlog",[](AsyncWebServerRequest *request){

0 commit comments

Comments
 (0)