Skip to content

Commit

Permalink
Merge pull request #133 from visualapproach/development
Browse files Browse the repository at this point in the history
  • Loading branch information
visualapproach authored Oct 16, 2021
2 parents 106e54d + de56e66 commit a0ff594
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 8 deletions.
13 changes: 11 additions & 2 deletions Code/6-wire-version/data/WebSocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,16 @@ 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';
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';
}
//}
}

Expand Down Expand Up @@ -155,6 +163,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);
}

Expand Down
4 changes: 4 additions & 0 deletions Code/6-wire-version/data/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ <h3 id="tt"> Target temp: <label id="ttlabel" for="tt">0</label></h3>
<td style="width:20%; white-space:nowrap">Air: </td>
<td style="width:70%; white-space:nowrap; text-align:left" id="airtime">2456:-</td>
</tr>
<tr>
<td style="width:20%; white-space:nowrap" id="jettitle">Hydrojets: </td>
<td style="width:70%; white-space:nowrap; text-align:left" id="jettime">2456:-</td>
</tr>
<tr>
<td style="width:20%; white-space:nowrap">Estimated cost: </td>
<td style="width:70%; white-space:nowrap; text-align:left" id="cost">00:00:00</td>
Expand Down
26 changes: 22 additions & 4 deletions Code/6-wire-version/lib/BWC/BWC_8266.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -400,6 +401,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();
Expand All @@ -412,8 +427,6 @@ void BWC::begin2(){
saveSettingsTimer.attach(3600.0, std::bind(&BWC::saveSettingsFlag, this));
}



void BWC::loop(){
//feed the dog
ESP.wdtFeed();
Expand Down Expand Up @@ -970,6 +983,11 @@ void BWC::reloadCommandQueue(){
return;
}

void BWC::reloadSettings(){
_loadSettings();
return;
}

void BWC::_saveStates() {
if(maxeffort) {
_saveStatesNeeded = true;
Expand Down Expand Up @@ -1094,7 +1112,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
Expand Down
1 change: 1 addition & 0 deletions Code/6-wire-version/lib/BWC/BWC_8266.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class BWC {
bool maxeffort = false;
String getPressedButton();
void reloadCommandQueue();
void reloadSettings();
String getButtonName();

private:
Expand Down
4 changes: 2 additions & 2 deletions Code/6-wire-version/lib/BWC/BWC_8266_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {
Expand Down
3 changes: 3 additions & 0 deletions Code/6-wire-version/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit a0ff594

Please sign in to comment.