Skip to content

Commit

Permalink
Merge pull request #805 from visualapproach/development_v4
Browse files Browse the repository at this point in the history
Development v4
  • Loading branch information
visualapproach authored Oct 7, 2024
2 parents 6521c4f + 8f49a28 commit 873e0c7
Show file tree
Hide file tree
Showing 44 changed files with 854 additions and 827 deletions.
4 changes: 3 additions & 1 deletion Code/data/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
<option value="21">Set R (internal use)</option>
<option value="22">Reset filter rinse timer (-)</option>
<option value="23">Reset filter clean timer (-)</option>
<option value="24">Set power on/off (0/1)</option>
</select>
</td>
</tr>
Expand Down Expand Up @@ -290,12 +291,13 @@ <h2>Command queue</h2>
const setR = 21;
const resetrinsefiltertimer = 22;
const resetcleanfiltertimer = 23;
const setpower = 24;

const commandlist = [
'Set target', 'Set unit', 'Set bubbles', 'Set heat', 'Set pump', 'Reset queue', 'Reboot ESP',
'Internal cmd', 'Reset times', 'Reset Cl timer', 'Reset change filter timer', 'Set jets', 'Set brightness',
'Beep', 'Set ambient temp F.', 'Set ambient temp C.', 'Reset daily meter', 'Take control', 'Full power',
'Print text', 'Set ready', 'Set R', 'Reset rinse filter timer', 'Reset clean filter timer'
'Print text', 'Set ready', 'Set R', 'Reset rinse filter timer', 'Reset clean filter timer', 'Set power'
];

function totimestamp()
Expand Down
38 changes: 18 additions & 20 deletions Code/data/mqtt.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,34 +46,31 @@
<td><input type="checkbox" id="enableMqtt"></td>
</tr>
<tr>
<td>IP Address:</td>
<td>MQTT host addr:</td>
<td>
<input type="text" id="mqttIpAddress1" maxlength="3" style="width:30px">
. <input type="text" id="mqttIpAddress2" maxlength="3" style="width:30px">
. <input type="text" id="mqttIpAddress3" maxlength="3" style="width:30px">
. <input type="text" id="mqttIpAddress4" maxlength="3" style="width:30px">
<input type="text" id="mqttHost" maxlength="63" value="IP or FQDN of the broker">
</td>
</tr>
<tr>
<td>Port:</td>
<td><input type="text" id="mqttPort"></td>
<td><input type="text" id="mqttPort" maxlength="31"></td>
</tr>
<tr>
<td>Username:</td>
<td><input type="text" id="mqttUsername"></td>
<td><input type="text" id="mqttUsername" maxlength="31"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="text" id="mqttPassword"></td>
<td><input type="text" id="mqttPassword" maxlength="31"></td>
<!--<td><input type="password" id="mqttPassword"><input type="checkbox" onclick="togglePlainText('mqttPassword')"></td>-->
</tr>
<tr>
<td>Client ID:</td>
<td><input type="text" id="mqttClientId"></td>
<td><input type="text" id="mqttClientId" maxlength="31"></td>
</tr>
<tr>
<td>Base Topic:</td>
<td><input type="text" id="mqttBaseTopic"></td>
<td><input type="text" id="mqttBaseTopic" maxlength="31"></td>
</tr>
<tr>
<td>Telemetry Interval (s):</td>
Expand Down Expand Up @@ -179,10 +176,10 @@
var json = JSON.parse(req.responseText);
console.log(json);
document.getElementById('enableMqtt').checked = json.enableMqtt;
document.getElementById('mqttIpAddress1').value = json.mqttIpAddress[0];
document.getElementById('mqttIpAddress2').value = json.mqttIpAddress[1];
document.getElementById('mqttIpAddress3').value = json.mqttIpAddress[2];
document.getElementById('mqttIpAddress4').value = json.mqttIpAddress[3];
document.getElementById('mqttHost').value = json.mqttHost;
// document.getElementById('mqttIpAddress2').value = json.mqttIpAddress[1];
// document.getElementById('mqttIpAddress3').value = json.mqttIpAddress[2];
// document.getElementById('mqttIpAddress4').value = json.mqttIpAddress[3];
document.getElementById('mqttPort').value = json.mqttPort;
document.getElementById('mqttUsername').value = json.mqttUsername;
document.getElementById('mqttPassword').value = json.mqttPassword;
Expand All @@ -203,12 +200,13 @@
req.open('POST', '/setmqtt/');
var json = {
'enableMqtt':(document.getElementById('enableMqtt').checked),
'mqttIpAddress':[
parseInt(document.getElementById('mqttIpAddress1').value),
parseInt(document.getElementById('mqttIpAddress2').value),
parseInt(document.getElementById('mqttIpAddress3').value),
parseInt(document.getElementById('mqttIpAddress4').value)
],
// 'mqttIpAddress':[
// parseInt(document.getElementById('mqttIpAddress1').value),
// parseInt(document.getElementById('mqttIpAddress2').value),
// parseInt(document.getElementById('mqttIpAddress3').value),
// parseInt(document.getElementById('mqttIpAddress4').value)
// ],
'mqttHost':(document.getElementById('mqttHost').value),
'mqttPort':parseInt(document.getElementById('mqttPort').value),
'mqttUsername':(document.getElementById('mqttUsername').value),
'mqttPassword':(document.getElementById('mqttPassword').value),
Expand Down
2 changes: 1 addition & 1 deletion Code/lib/BWC_unified/FW_VERSION.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define FW_VERSION "2024-07-23-1743"
#define FW_VERSION "2024-10-07-1913"
67 changes: 64 additions & 3 deletions Code/lib/BWC_unified/bwc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,8 @@ void BWC::_handleCommandQ() {
bool BWC::_handlecommand(Commands cmd, int64_t val, const String& txt="")
{
bool restartESP = false;
dsp->text += String(" ") + txt;

_format_text(txt);
switch (cmd)
{
case SETTARGET:
Expand Down Expand Up @@ -595,6 +595,10 @@ bool BWC::_handlecommand(Commands cmd, int64_t val, const String& txt="")
_vt_calibrated = true;
_save_settings_needed = true;
break;
case SETPOWER:
val = std::clamp((int)val, 0, 1);
cio->cio_toggles.power_change = (val != cio->cio_states.power);
break;
default:
break;
}
Expand All @@ -615,6 +619,63 @@ bool BWC::_handlecommand(Commands cmd, int64_t val, const String& txt="")
return false;
}

void BWC::_format_text(const String &txt)
{
dsp->text += ' ';

/* Check for special character '<>' surrounding variable field */
/* Example "T <time>" would show "T 12 44" */
/*
possible field variables suggestion:
time
IP-addr
date
*/

String field;
bool fieldmode = false;
field.reserve(15);
String formatted_text;
formatted_text.reserve(63);
for(unsigned int i = 0; i < txt.length(); i++)
{
if(txt[i] == '>')
{
//process field
if(field.equals(F("time")))
{
//copy new fieldstring to formatted_text
tm buf;
time_t t = time(NULL);
gmtime_r(&t, &buf);
formatted_text += String(buf.tm_hour);
formatted_text += ' ';
formatted_text += String(buf.tm_min);
}
//other if statements go here

//set fieldmode off
fieldmode = false;
field.clear();
}
else if(txt[i] == '<')
{
//set fieldmode on
fieldmode = true;
}
else
{
//if fieldmode off - copy char to formatted_text
//else copy char to field
if(fieldmode) field += txt[i];
else formatted_text += txt[i];
}
}

dsp->text += formatted_text;
}

void BWC::_handleStateChanges()
{
if(_prev_cio_states != cio->cio_states || _prev_dsp_states.brightness != dsp->dsp_states.brightness) _new_data_available = true;
Expand Down Expand Up @@ -1528,7 +1589,7 @@ void BWC::_saveCommandQueue(){
BWC_LOG_P(PSTR("Failed to save cmdq.json\n"),0);
return;
} else {
BWC_LOG_P(PSTR("Writing cmdq.json: "),0);
BWC_LOG_P(PSTR("Writing cmdq.json\n"),0);
}
/*Do not save instant reboot command. Don't ask me how I know.*/
if(_command_que.size())
Expand Down
27 changes: 8 additions & 19 deletions Code/lib/BWC_unified/bwc.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,13 @@
#include <vector>
#include <optional>
#include "enums.h"
#include "CIO_PRE2021.h"
#include "CIO_2021.h"
#include "CIO_2021HJT.h"
#include "CIO_54149E.h"
#include "CIO_54173.h"
#include "CIO_54154.h"
#include "CIO_54144.h"
#include "CIO_54138.h"
#include "CIO_54123.h"
#include "CIO_4W_MODEL_SPECIFIC.h"
#include "CIO_TYPE1_MODEL_SPECIFIC.h"
#include "CIO_TYPE2_MODEL_SPECIFIC.h"

#include "DSP_PRE2021.h"
#include "DSP_2021.h"
#include "DSP_2021HJT.h"
#include "DSP_54149E.h"
#include "DSP_54173.h"
#include "DSP_54154.h"
#include "DSP_54144.h"
#include "DSP_54138.h"
#include "DSP_54123.h"
#include "DSP_4W_MODEL_SPECIFIC.h"
#include "DSP_TYPE1_MODEL_SPECIFIC.h"
#include "DSP_TYPE2_MODEL_SPECIFIC.h"

#include "FW_VERSION.h"
#include "bwc_debug.h"
Expand Down Expand Up @@ -111,7 +99,8 @@ class BWC {

private:
bool _loadHardware(Models& cioNo, Models& dspNo, int pins[], std::optional<Power>& power_levels);
bool _handlecommand(Commands cmd, int64_t val, const String& txt);
bool _handlecommand(Commands cmd, int64_t val, const String &txt);
void _format_text(const String &txt);
void _handleCommandQ();
void _loadSettings();
void _saveCommandQueue();
Expand Down
3 changes: 2 additions & 1 deletion Code/lib/BWC_unified/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ enum Commands: byte
SETREADY,
SETR,
RESETFRINSETIMER,
RESETFCLEANTIMER
RESETFCLEANTIMER,
SETPOWER
};

enum ToggleButtons: byte
Expand Down
15 changes: 0 additions & 15 deletions Code/lib/cio/CIO_2021.cpp

This file was deleted.

29 changes: 0 additions & 29 deletions Code/lib/cio/CIO_2021.h

This file was deleted.

15 changes: 0 additions & 15 deletions Code/lib/cio/CIO_2021HJT.cpp

This file was deleted.

29 changes: 0 additions & 29 deletions Code/lib/cio/CIO_2021HJT.h

This file was deleted.

5 changes: 1 addition & 4 deletions Code/lib/cio/CIO_4W.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
#include <Arduino.h>
#include <SoftwareSerial.h>
#include "enums.h"
#include "CIO_BASE.h"
#include <umm_malloc/umm_heap_select.h>


class BWC;
#include "CIO_BASE.h"

class CIO_4W : public CIO
{
Expand Down
Loading

0 comments on commit 873e0c7

Please sign in to comment.