Skip to content

Commit

Permalink
Merge pull request #602 from visualapproach/development_v4
Browse files Browse the repository at this point in the history
Development v4
  • Loading branch information
visualapproach authored Aug 19, 2023
2 parents 8c770d6 + 9fd6dae commit 1975b32
Show file tree
Hide file tree
Showing 33 changed files with 282 additions and 227 deletions.
9 changes: 0 additions & 9 deletions Code/data/hwtestinfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,5 @@
</section>
</div>

<script>
var connection = new WebSocket('ws://'+location.hostname+':81/', ['arduino']);
connection.onerror = function (error) {
console.log('WebSocket Error ', error);
};
connection.onmessage = function (e) {
console.log(e.data);
}
</script>
</body>
</html>
Binary file modified Code/datazip/calib.html.gz
Binary file not shown.
Binary file modified Code/datazip/chkupdatefw.html.gz
Binary file not shown.
Binary file modified Code/datazip/config.html.gz
Binary file not shown.
Binary file modified Code/datazip/favicon.ico.gz
Binary file not shown.
Binary file modified Code/datazip/function.js.gz
Binary file not shown.
Binary file modified Code/datazip/hwconfig.html.gz
Binary file not shown.
Binary file modified Code/datazip/hwtestinfo.html.gz
Binary file not shown.
Binary file modified Code/datazip/index.html.gz
Binary file not shown.
Binary file modified Code/datazip/index.js.gz
Binary file not shown.
Binary file modified Code/datazip/main.css.gz
Binary file not shown.
Binary file modified Code/datazip/mqtt.html.gz
Binary file not shown.
Binary file modified Code/datazip/remove.html.gz
Binary file not shown.
Binary file modified Code/datazip/success.html.gz
Binary file not shown.
Binary file modified Code/datazip/upload.html.gz
Binary file not shown.
Binary file modified Code/datazip/webconfig.html.gz
Binary file not shown.
Binary file modified Code/datazip/wifi.html.gz
Binary file not shown.
Binary file modified Code/fw/firmware.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion Code/fw/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-08-16-1957
2023-08-19-2340
11 changes: 10 additions & 1 deletion Code/lib/BWC_unified/bwc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ void BWC::setup(void){
Models ciomodel;
Models dspmodel;

LittleFS.begin();
if(!_loadHardware(ciomodel, dspmodel, pins)){
pins[0] = D1;
pins[1] = D2;
Expand Down Expand Up @@ -571,8 +570,18 @@ void BWC::_handleStateChanges()
)
_save_states_needed = true;

Buttons _currbutton = dsp->dsp_toggles.pressed_button;
if(_currbutton != _prevbutton && _currbutton != NOBTN)
{
_btn_sequence[0] = _btn_sequence[1];
_btn_sequence[1] = _btn_sequence[2];
_btn_sequence[2] = _btn_sequence[3];
_btn_sequence[3] = _currbutton;
}

_prev_cio_states = cio->cio_states;
_prev_dsp_states = dsp->dsp_states;
_prevbutton = _currbutton;
/* check changes from DSP 4W - go to antigodmode if someone presses a button*/
}

Expand Down
1 change: 1 addition & 0 deletions Code/lib/BWC_unified/bwc.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ class BWC {
bool _dsp_tgt_used = true;
uint8_t _web_target = 20;
sStates _prev_cio_states, _prev_dsp_states;
Buttons _prevbutton = NOBTN;
unsigned long _temp_change_timestamp_ms, _heatred_change_timestamp_ms;
unsigned long _pump_change_timestamp_ms, _bubbles_change_timestamp_ms;
int _deltatemp;
Expand Down
21 changes: 12 additions & 9 deletions Code/lib/cio/CIO_4W.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ void CIO_4W::setup(int cio_rx, int cio_tx, int dummy)
Devices are sending on their TX lines, so we read that with RX pins on the ESP
Hence the "backwards" parameters (cio_tx goes to ESP serial RX)
*/
_cio_serial.begin(9600, SWSERIAL_8N1, cio_tx, cio_rx, false, 63);
_cio_serial.setTimeout(20);
HeapSelectIram ephemeral;
_cio_serial = new SoftwareSerial;

_cio_serial->begin(9600, SWSERIAL_8N1, cio_tx, cio_rx, false, 63);
_cio_serial->setTimeout(20);

cio_states.target = 20;
cio_states.locked = false;
Expand All @@ -24,17 +27,17 @@ void CIO_4W::setup(int cio_rx, int cio_tx, int dummy)

void CIO_4W::stop()
{
_cio_serial.stopListening();
_cio_serial->stopListening();
}

void CIO_4W::pause_all(bool action)
{
if(action)
{
_cio_serial.stopListening();
_cio_serial->stopListening();
} else
{
_cio_serial.listen();
_cio_serial->listen();
}
}

Expand All @@ -60,7 +63,7 @@ void CIO_4W::handleToggles()
/*Copy raw payload to CIO*/
for(unsigned int i = 0; i < sizeof(_to_CIO_buf); i++)
_to_CIO_buf[i] = _raw_payload_to_cio[i];
// _cio_serial.write(_to_CIO_buf, PAYLOADSIZE); //this is done in updateStates()
// _cio_serial->write(_to_CIO_buf, PAYLOADSIZE); //this is done in updateStates()
cio_states.godmode = false;
_power.HEATERPOWER = ((_to_CIO_buf[COMMANDINDEX] & getHeatBitmask1()) == getHeatBitmask1()) * 950 +
((_to_CIO_buf[COMMANDINDEX] & getHeatBitmask2()) == getHeatBitmask2()) * 950;
Expand Down Expand Up @@ -157,9 +160,9 @@ void CIO_4W::updateStates()
{
int msglen = 0;
//check if CIO has sent a message
if(!_cio_serial.available()) return;
if(!_cio_serial->available()) return;
uint8_t tempbuffer[PAYLOADSIZE];
msglen = _cio_serial.readBytes(tempbuffer, PAYLOADSIZE);
msglen = _cio_serial->readBytes(tempbuffer, PAYLOADSIZE);
if(msglen != PAYLOADSIZE) return;
uint8_t calculatedChecksum;
calculatedChecksum = tempbuffer[1]+tempbuffer[2]+tempbuffer[3]+tempbuffer[4];
Expand Down Expand Up @@ -197,7 +200,7 @@ void CIO_4W::updateStates()
cio_states.char3 = (char)(48+(_from_CIO_buf[ERRORINDEX]%10));
}
/*This is placed here so we send messages at the same rate as the cio.*/
_cio_serial.write(_to_CIO_buf, PAYLOADSIZE);
_cio_serial->write(_to_CIO_buf, PAYLOADSIZE);
return;
}

Expand Down
4 changes: 3 additions & 1 deletion Code/lib/cio/CIO_4W.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <SoftwareSerial.h>
#include "enums.h"
#include "CIO_BASE.h"
#include <umm_malloc/umm_heap_select.h>


class BWC;

Expand Down Expand Up @@ -41,7 +43,7 @@ class CIO_4W : public CIO
private:
Power _power = {1900, 40, 800, 2, 400};
uint8_t _heat_bitmask = 0;
SoftwareSerial _cio_serial;
SoftwareSerial *_cio_serial;
uint8_t _from_CIO_buf[7] = {};
uint8_t _to_CIO_buf[7] = {};
uint8_t _currentStateIndex = 0;
Expand Down
13 changes: 12 additions & 1 deletion Code/lib/cio/CIO_TYPE1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,18 @@ void CIO_6_TYPE1::updateStates()
//Unreadable characters - exit
if(cio_states.char1 == '*' || cio_states.char2 == '*' || cio_states.char3 == '*') return;
//Error or user plays with timer button - exit (error notification can be dealt with in main.cpp or elsewhere)
if(cio_states.char1 == 'E' || cio_states.char3 == 'H' || cio_states.char3 == ' ') return;
if(cio_states.char1 == 'e')
{
String errornumber;
errornumber = (char)cio_states.char2;
errornumber += (char)cio_states.char3;
cio_states.error = (uint8_t)(errornumber.toInt());
return;
}
if(cio_states.char3 == 'H' || cio_states.char3 == ' ') return;

/* Reset error state */
cio_states.error = 0;

//capture TARGET after UP/DOWN has been pressed...
if ((_button_code == getButtonCode(UP)) || (_button_code == getButtonCode(DOWN)))
Expand Down
13 changes: 12 additions & 1 deletion Code/lib/cio/CIO_TYPE2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,18 @@ void CIO_6_TYPE2::updateStates()
//Unreadable characters - exit
if(cio_states.char1 == '*' || cio_states.char2 == '*' || cio_states.char3 == '*') return;
//Error or user plays with timer button - exit (error notification can be dealt with in main.cpp or elsewhere)
if(cio_states.char1 == 'E' || cio_states.char3 == 'H' || cio_states.char3 == ' ') return;
if(cio_states.char1 == 'e')
{
String errornumber;
errornumber = (char)cio_states.char2;
errornumber += (char)cio_states.char3;
cio_states.error = (uint8_t)(errornumber.toInt());
return;
}
if(cio_states.char3 == 'H' || cio_states.char3 == ' ') return;

/* Reset error state */
cio_states.error = 0;

//capture TARGET after UP/DOWN has been pressed...
if ((_button_code == getButtonCode(UP)) || (_button_code == getButtonCode(DOWN)))
Expand Down
18 changes: 10 additions & 8 deletions Code/lib/dsp/DSP_4W.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

void DSP_4W::setup(int dsp_tx, int dsp_rx, int dummy, int dummy2)
{
_dsp_serial.begin(9600, SWSERIAL_8N1, dsp_tx, dsp_rx, false, 63);
_dsp_serial.setTimeout(20);
HeapSelectIram ephemeral;
_dsp_serial = new SoftwareSerial;
_dsp_serial->begin(9600, SWSERIAL_8N1, dsp_tx, dsp_rx, false, 63);
_dsp_serial->setTimeout(20);
dsp_toggles.locked_pressed = 0;
dsp_toggles.power_change = 0;
dsp_toggles.unit_change = 0;
Expand All @@ -16,17 +18,17 @@ void DSP_4W::setup(int dsp_tx, int dsp_rx, int dummy, int dummy2)

void DSP_4W::stop()
{
_dsp_serial.stopListening();
_dsp_serial->stopListening();
}

void DSP_4W::pause_all(bool action)
{
if(action)
{
_dsp_serial.stopListening();
_dsp_serial->stopListening();
} else
{
_dsp_serial.listen();
_dsp_serial->listen();
}
}

Expand All @@ -40,9 +42,9 @@ void DSP_4W::updateToggles()
int msglen = 0;
//check if display sent a message
msglen = 0;
if(!_dsp_serial.available()) return;
if(!_dsp_serial->available()) return;
uint8_t tempbuffer[PAYLOADSIZE];
msglen = _dsp_serial.readBytes(tempbuffer, PAYLOADSIZE);
msglen = _dsp_serial->readBytes(tempbuffer, PAYLOADSIZE);
if(msglen != PAYLOADSIZE) return;

//discard message if checksum is wrong
Expand Down Expand Up @@ -91,7 +93,7 @@ void DSP_4W::updateToggles()
// dsp_toggles.no_of_heater_elements_on = (_from_DSP_buf[COMMANDINDEX] & getHeatBitmask2()) > 0;

/*This is placed here to send messages at the same rate as the dsp.*/
_dsp_serial.write(_to_DSP_buf, PAYLOADSIZE);
_dsp_serial->write(_to_DSP_buf, PAYLOADSIZE);
return;
}

Expand Down
4 changes: 3 additions & 1 deletion Code/lib/dsp/DSP_4W.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <SoftwareSerial.h>
#include "enums.h"
#include "DSP_BASE.h"
#include <umm_malloc/umm_heap_select.h>


class DSP_4W : public DSP
{
Expand All @@ -29,7 +31,7 @@ class DSP_4W : public DSP
void generatePayload();

private:
SoftwareSerial _dsp_serial;
SoftwareSerial *_dsp_serial;
/*ESP to DSP*/
uint8_t _to_DSP_buf[7] = {};
/*DSP to ESP. We can ignore this message and send our own when ESP is in charge.*/
Expand Down
5 changes: 3 additions & 2 deletions Code/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ build_flags =
; -DDEBUG_ESPHTTP_CLIENT
; -DDEBUG_ESP_HTTP_UPDATE
; -DDEBUG_ESP_OOM
-include "umm_malloc/umm_malloc_cfg.h"
; -include "umm_malloc/umm_malloc_cfg.h"
; -DPIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48
-D PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED
; -D PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM32_SECHEAP_NOTSHARED
Expand All @@ -52,7 +52,8 @@ build_flags =
; -D MMU_IRAM_HEAP
; -DVTABLES_IN_FLASH
; -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH

; -D PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
-D BEARSSL_SSL_BASIC
; build_type = debug
; debug_build_flags = -Og -g2 -ggdb2
monitor_filters =
Expand Down
2 changes: 1 addition & 1 deletion Code/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <WiFi.h>
#endif
#define DEVICE_NAME "layzspa"
#define FW_VERSION "2023-08-16-1957"
#define FW_VERSION "2023-08-19-2340"

#define HA_PREFIX "homeassistant"
#define PROM_NAMESPACE "layzspa"
Expand Down
Loading

0 comments on commit 1975b32

Please sign in to comment.