From bc6563cfc5032ece761e8983162ed80a02480ac2 Mon Sep 17 00:00:00 2001 From: visualapproach Date: Fri, 15 Oct 2021 20:45:25 +0200 Subject: [PATCH 1/4] 6w: Initialize times variables before use --- Code/6-wire-version/lib/BWC/BWC_8266.cpp | 23 ++++++++++++++++++++--- Code/6-wire-version/lib/BWC/BWC_8266.h | 1 + Code/6-wire-version/src/main.cpp | 3 +++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Code/6-wire-version/lib/BWC/BWC_8266.cpp b/Code/6-wire-version/lib/BWC/BWC_8266.cpp index 69148e6d..fc1f08d4 100644 --- a/Code/6-wire-version/lib/BWC/BWC_8266.cpp +++ b/Code/6-wire-version/lib/BWC/BWC_8266.cpp @@ -400,6 +400,20 @@ void BWC::begin( } void BWC::begin2(){ + //Initialize variables + _cltime = 0; + _ftime = 0; + _uptime = 0; + _pumptime = 0; + _heatingtime = 0; + _airtime = 0; + _jettime = 0; + _timezone = 0; + _price = 1; + _finterval = 30; + _clinterval = 14; + _audio = true; + _restoreStatesOnStart = false; _dsp.textOut(F(" hello ")); _startNTP(); LittleFS.begin(); @@ -412,8 +426,6 @@ void BWC::begin2(){ saveSettingsTimer.attach(3600.0, std::bind(&BWC::saveSettingsFlag, this)); } - - void BWC::loop(){ //feed the dog ESP.wdtFeed(); @@ -970,6 +982,11 @@ void BWC::reloadCommandQueue(){ return; } +void BWC::reloadSettings(){ + _loadSettings(); + return; +} + void BWC::_saveStates() { if(maxeffort) { _saveStatesNeeded = true; @@ -1094,7 +1111,7 @@ void BWC::_saveRebootInfo(){ void BWC::_updateTimes(){ uint32_t now = millis(); - static uint32_t prevtime; + static uint32_t prevtime = now; int elapsedtime = now-prevtime; prevtime = now; if (elapsedtime < 0) return; //millis() rollover every 49 days diff --git a/Code/6-wire-version/lib/BWC/BWC_8266.h b/Code/6-wire-version/lib/BWC/BWC_8266.h index 891bf430..7d209f19 100644 --- a/Code/6-wire-version/lib/BWC/BWC_8266.h +++ b/Code/6-wire-version/lib/BWC/BWC_8266.h @@ -115,6 +115,7 @@ class BWC { bool maxeffort = false; String getPressedButton(); void reloadCommandQueue(); + void reloadSettings(); String getButtonName(); private: diff --git a/Code/6-wire-version/src/main.cpp b/Code/6-wire-version/src/main.cpp index e3d20027..12b38d6f 100644 --- a/Code/6-wire-version/src/main.cpp +++ b/Code/6-wire-version/src/main.cpp @@ -221,6 +221,9 @@ void handleFileUpload() { // upload a new file to the LittleFS server.send(303); if(upload.filename == "cmdq.txt"){ bwc.reloadCommandQueue(); + } + if(upload.filename == "settings.txt"){ + bwc.reloadSettings(); } } else { server.send(500, "text/plain", "500: couldn't create file"); From ce183a65acafdf2a17315b648679e6d1cdc75509 Mon Sep 17 00:00:00 2001 From: visualapproach Date: Sat, 16 Oct 2021 09:58:11 +0200 Subject: [PATCH 2/4] Added jettime to web interface Totals --- Code/6-wire-version/data/WebSocket.js | 10 ++++++++-- Code/6-wire-version/data/index.html | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Code/6-wire-version/data/WebSocket.js b/Code/6-wire-version/data/WebSocket.js index bde59fc6..83f70f62 100644 --- a/Code/6-wire-version/data/WebSocket.js +++ b/Code/6-wire-version/data/WebSocket.js @@ -82,8 +82,14 @@ function handlemsg(e) { ] document.getElementById('mqtt').innerHTML = "MQTT:" + mqtt_states[msgobj.MQTT + 4]; //console.log(msgobj.PressedButton); - if(msgobj.HASJETS) document.getElementById('jets').style.visibility = 'visible' - else document.getElementById('jets').style.visibility = 'hidden'; + if(msgobj.HASJETS) { + document.getElementById('jets').style.visibility = 'visible'; + document.getElementById('jettime').style.visibility = 'visible'; + } + else { + document.getElementById('jets').style.visibility = 'hidden'; + document.getElementById('jettime').style.visibility = 'hidden'; + } //} } diff --git a/Code/6-wire-version/data/index.html b/Code/6-wire-version/data/index.html index d929bb2b..f6cd96af 100644 --- a/Code/6-wire-version/data/index.html +++ b/Code/6-wire-version/data/index.html @@ -134,6 +134,10 @@

Target temp:

Air: 2456:- + + Hydrojets: + 2456:- + Estimated cost: 00:00:00 From 299b61a2d4e6f4c7323d185abf1a5e0ee8bf53c3 Mon Sep 17 00:00:00 2001 From: visualapproach Date: Sat, 16 Oct 2021 10:04:44 +0200 Subject: [PATCH 3/4] jettime update --- Code/6-wire-version/data/WebSocket.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Code/6-wire-version/data/WebSocket.js b/Code/6-wire-version/data/WebSocket.js index 83f70f62..57ed422f 100644 --- a/Code/6-wire-version/data/WebSocket.js +++ b/Code/6-wire-version/data/WebSocket.js @@ -161,6 +161,7 @@ function handlemsg(e) { document.getElementById('uptime').innerHTML = s2dhms(msgobj.UPTIME); document.getElementById('airtime').innerHTML = s2dhms(msgobj.AIRTIME); document.getElementById('filtertime').innerHTML = s2dhms(msgobj.PUMPTIME); + document.getElementById('jettime').innerHTML = s2dhms(msgobj.JETTIME); document.getElementById('cost').innerHTML = (msgobj.COST).toFixed(2); } From de56e6601b9ab3236589a990342d1f5a2d06b87a Mon Sep 17 00:00:00 2001 From: visualapproach Date: Sat, 16 Oct 2021 10:20:31 +0200 Subject: [PATCH 4/4] jettime-more fixes --- Code/6-wire-version/data/WebSocket.js | 2 ++ Code/6-wire-version/data/index.html | 2 +- Code/6-wire-version/lib/BWC/BWC_8266.cpp | 3 ++- Code/6-wire-version/lib/BWC/BWC_8266_globals.h | 4 ++-- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Code/6-wire-version/data/WebSocket.js b/Code/6-wire-version/data/WebSocket.js index 57ed422f..79efbe91 100644 --- a/Code/6-wire-version/data/WebSocket.js +++ b/Code/6-wire-version/data/WebSocket.js @@ -85,10 +85,12 @@ function handlemsg(e) { if(msgobj.HASJETS) { document.getElementById('jets').style.visibility = 'visible'; document.getElementById('jettime').style.visibility = 'visible'; + document.getElementById('jettitle').style.visibility = 'visible'; } else { document.getElementById('jets').style.visibility = 'hidden'; document.getElementById('jettime').style.visibility = 'hidden'; + document.getElementById('jettitle').style.visibility = 'hidden'; } //} } diff --git a/Code/6-wire-version/data/index.html b/Code/6-wire-version/data/index.html index f6cd96af..f0a560c9 100644 --- a/Code/6-wire-version/data/index.html +++ b/Code/6-wire-version/data/index.html @@ -135,7 +135,7 @@

Target temp:

2456:- - Hydrojets: + Hydrojets: 2456:- diff --git a/Code/6-wire-version/lib/BWC/BWC_8266.cpp b/Code/6-wire-version/lib/BWC/BWC_8266.cpp index fc1f08d4..a38bb929 100644 --- a/Code/6-wire-version/lib/BWC/BWC_8266.cpp +++ b/Code/6-wire-version/lib/BWC/BWC_8266.cpp @@ -67,7 +67,8 @@ void CIO::loop(void) { states[CHAR1] = (uint8_t)_getChar(payload[DGT1_IDX]); states[CHAR2] = (uint8_t)_getChar(payload[DGT2_IDX]); states[CHAR3] = (uint8_t)_getChar(payload[DGT3_IDX]); - states[JETSSTATE] = (payload[HJT_IDX] & (1 << HJT_BIT)) > 0; + if(HASJETS) states[JETSSTATE] = (payload[HJT_IDX] & (1 << HJT_BIT)) > 0; + else states[JETSSTATE] = 0; //Determine if display is showing target temp or actual temp or anything else. //capture TARGET after UP/DOWN has been pressed... if( ((button == ButtonCodes[UP]) || (button == ButtonCodes[DOWN])) && (prevButton != ButtonCodes[UP]) && (prevButton != ButtonCodes[DOWN]) ) capturePhase = 1; diff --git a/Code/6-wire-version/lib/BWC/BWC_8266_globals.h b/Code/6-wire-version/lib/BWC/BWC_8266_globals.h index 64c88ae5..5618aca1 100644 --- a/Code/6-wire-version/lib/BWC/BWC_8266_globals.h +++ b/Code/6-wire-version/lib/BWC/BWC_8266_globals.h @@ -44,8 +44,8 @@ const byte F_IDX = 9; const byte F_BIT = 3; const byte PWR_IDX = 9; const byte PWR_BIT = 4; -const byte HJT_IDX = 9; //still to be verified. This is an educated guess -const byte HJT_BIT = 5; //if correct the web page should show correct states on everything +const byte HJT_IDX = 9; +const byte HJT_BIT = 5; //7-segment codes. MSB always 1 const uint8_t CHARCODES[] = {