Skip to content

Commit

Permalink
Merge pull request #509 from visualapproach/development_v4
Browse files Browse the repository at this point in the history
Development v4
  • Loading branch information
visualapproach authored May 13, 2023
2 parents 26a1384 + 4d148b9 commit 22e7ec1
Show file tree
Hide file tree
Showing 32 changed files with 52 additions and 74 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@
*.exe
*.out
*.app
Code/.vscode/extensions.json

.pio
.vscode
21 changes: 0 additions & 21 deletions .vscode/c_cpp_properties.json

This file was deleted.

10 changes: 0 additions & 10 deletions Code/.vscode/extensions.json

This file was deleted.

10 changes: 0 additions & 10 deletions Code/.vscode/settings.json

This file was deleted.

Binary file not shown.
14 changes: 7 additions & 7 deletions Code/data/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@
<option value="2">Set air bubbles (0/1)</option>
<option value="3">Set heater (0/1)</option>
<option value="4">Set filter pump (0/1)</option>
<option value="5">Reset queue (not used)</option>
<option value="5">Reset queue (-)</option>
<option value="6">Reboot ESP</option>
<option value="7">Internal command (get target) (not used)</option>
<option value="8">Reset times (not used)</option>
<option value="9">Reset Cl timer (not used)</option>
<option value="10">Reset filter timer (not used)</option>
<option value="7">Internal command (get target) (-)</option>
<option value="8">Reset times (-)</option>
<option value="9">Reset Cl timer (-)</option>
<option value="10">Reset filter timer (-)</option>
<option value="11">Set hydrojets (0/1)</option>
<option value="12">Set display brightness (0-8)</option>
<option value="13">Set beep (0/1 or 2+text=filename)</option>
Expand All @@ -103,7 +103,7 @@
<option value="17">Take control (0/1)</option>
<option value="18">Set full power (0/1)</option>
<option value="19">Print (text)</option>
<option value="20">Set ready time (not used)</option>
<option value="20">Set ready time (-)</option>
</select>
</td>
</tr>
Expand Down Expand Up @@ -292,7 +292,7 @@ <h2>Command queue</h2>

function toggleCalibration()
{
let obj = document.getElementById("calibration");
let obj = document.getElementById('calibration');
if(obj.checked) obj.checked = false;
}
</script>
Expand Down
Binary file modified Code/data/favicon.ico
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 removed Code/datazip/favicon.ico
Binary file not shown.
Binary file added Code/datazip/favicon.ico.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion Code/datazip/filelist.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
chkupdatefw.html.gz
config.html.gz
favicon.ico
favicon.ico.gz
favicon.png
function.js.gz
furelise.tune
Expand Down
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-04-24-1854
2023-05-13-1551
2 changes: 1 addition & 1 deletion Code/gzip_littlefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def copy_data(src, dst):
print("path: " + path)
print("file: " + file)
myfile = open(drive + path + '\\' + myfilename, 'a')
if (ext in ["js", "css", "html"]):
if (ext in ["js", "css", "html", "ico"]):
myfile.write(file + ".gz\n")
with open(src, 'rb') as src, gzip.open(dst + ".gz", 'wb') as dst:
for chunk in iter(lambda: src.read(4096), b""):
Expand Down
22 changes: 16 additions & 6 deletions Code/lib/BWC_unified/bwc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,6 @@ void BWC::setup(void){
}

void BWC::begin(){
_loadSettings();
_loadCommandQueue();
_restoreStates();
// _save_melody("melody.bin");
// if(_audio_enabled) dsp->playIntro();
// dsp->LEDshow();
Expand Down Expand Up @@ -681,6 +678,7 @@ void BWC::_updateVirtualTempFix_ontempchange()
if(abs(degAboveAmbient) <= 1) return;
_R_COOLING = ((millis()-_temp_change_timestamp_ms)/3600000.0) / log((conversion*degAboveAmbient) / (conversion*(degAboveAmbient + _deltatemp)));
_vt_calibrated = true;
_save_settings_needed = true;
}

//Called on heater state change
Expand Down Expand Up @@ -1146,7 +1144,14 @@ void BWC::_restoreStates() {
uint8_t flt = doc[F("FLT")];
uint8_t htr = doc[F("HTR")];
uint8_t tgt = doc[F("TGT")] | 20;
uint8_t god = doc[F("GOD")] ;
command_que_item item;
item.cmd = SETGODMODE;
item.val = god;
item.xtime = 0;
item.interval = 0;
item.text = "";
add_command(item);
item.cmd = SETUNIT;
item.val = unt;
item.xtime = 0;
Expand Down Expand Up @@ -1176,11 +1181,11 @@ void BWC::_restoreStates() {
}

void BWC::reloadCommandQueue(){
_loadCommandQueue();
loadCommandQueue();
return;
}

void BWC::_loadCommandQueue(){
void BWC::loadCommandQueue(){
File file = LittleFS.open("/cmdq.json", "r");
if (!file) {
// Serial.println(F("Failed to read cmdq.json"));
Expand All @@ -1205,10 +1210,14 @@ void BWC::_loadCommandQueue(){
item.interval = doc[F("INTERVAL")][i];
String s = doc[F("TXT")][i] | "";
item.text = s;
while((item.interval > 0) && (item.xtime < (uint64_t)time(nullptr))) item.xtime += item.interval;
_command_que.push_back(item);
}

file.close();
std::sort(_command_que.begin(), _command_que.end(), _compare_command);
_loadSettings();
_restoreStates();

}

/* */
Expand Down Expand Up @@ -1259,6 +1268,7 @@ void BWC::_saveStates() {
doc[F("HTR")] = cio->cio_states.heat;
doc[F("FLT")] = cio->cio_states.pump;
doc[F("TGT")] = cio->cio_states.target;
doc[F("GOD")] = (uint8_t)cio->cio_states.godmode; //makes the file look better

// Serialize JSON to file
if (serializeJson(doc, file) == 0) {
Expand Down
2 changes: 1 addition & 1 deletion Code/lib/BWC_unified/bwc.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class BWC {
void setAmbientTemperature(int64_t amb, bool unit);
String getModel();
void print(const String& txt);
void loadCommandQueue();

// String getDebugData();

Expand All @@ -102,7 +103,6 @@ class BWC {
bool _handlecommand(Commands cmd, int64_t val, const String& txt);
void _handleCommandQ();
void _loadSettings();
void _loadCommandQueue();
void _saveCommandQueue();
void _updateTimes();
void _restoreStates();
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-04-24-1854"
#define FW_VERSION "2023-05-13-1551"

#define HA_PREFIX "homeassistant"
#define PROM_NAMESPACE "layzspa"
Expand Down
33 changes: 19 additions & 14 deletions Code/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=
-----END CERTIFICATE-----
)EOF";
X509List cert(trustRoot);
extern const unsigned char caCert[] PROGMEM;
extern const unsigned int caCertLen;
// extern const unsigned char caCert[] PROGMEM;
// extern const unsigned int caCertLen;

void setup()
{
Expand Down Expand Up @@ -87,6 +87,7 @@ void setup()
bwc.print(FW_VERSION);
Serial.println(F("End of setup()"));
heap_water_mark = ESP.getFreeHeap();
bwc.loadCommandQueue();
}

void loop()
Expand Down Expand Up @@ -679,13 +680,13 @@ void handleNotFound()

String getContentType(const String& filename)
{
if (filename.endsWith(".html")) return "text/html";
else if (filename.endsWith(".css")) return "text/css";
else if (filename.endsWith(".js")) return "application/javascript";
else if (filename.endsWith(".ico")) return "image/x-icon";
else if (filename.endsWith(".gz")) return "application/x-gzip";
else if (filename.endsWith(".json")) return "application/json";
return "text/plain";
if (filename.endsWith(".html")) return F("text/html");
else if (filename.endsWith(".css")) return F("text/css");
else if (filename.endsWith(".js")) return F("application/javascript");
else if (filename.endsWith(".ico")) return F("image/x-icon");
else if (filename.endsWith(".gz")) return F("application/x-gzip");
else if (filename.endsWith(".json")) return F("application/json");
return F("text/plain");
}

/**
Expand All @@ -711,12 +712,14 @@ bool handleFileRead(String path)
String pathWithGz = path + ".gz";
if (LittleFS.exists(pathWithGz) || LittleFS.exists(path)) { // If the file exists, either as a compressed archive, or normal
if (LittleFS.exists(pathWithGz)) // If there's a compressed version available
path += ".gz"; // Use the compressed version
path += ".gz"; // Use the compressed version
File file = LittleFS.open(path, "r"); // Open the file
// size_t sent = server.streamFile(file, contentType); // Send it to the client
server.streamFile(file, contentType); // Send it to the client
size_t fsize = file.size();
size_t sent = server.streamFile(file, contentType); // Send it to the client
// server.streamFile(file, contentType); // Send it to the client
file.close(); // Close the file again
// Serial.println("HTTP > file sent: " + path + " (" + sent + " bytes)");
Serial.println(F("File size: ") + String(fsize));
Serial.println(F("HTTP > file sent: ") + path + F(" (") + sent + F(" bytes)"));
return true;
}
// Serial.println("HTTP > file not found: " + path); // If the file doesn't exist, return false
Expand Down Expand Up @@ -1325,7 +1328,9 @@ void handleDir()
while (root.next())
{
// Serial.println(root.fileName());
mydir += F("<a href=\"/") + root.fileName() + "\">" + root.fileName() + "</a>";
String href = root.fileName();
if (href.endsWith(".gz")) href.remove(href.length()-3);
mydir += F("<a href=\"/") + href + "\">" + root.fileName() + "</a>";
mydir += F(" Size: ") + String(root.fileSize()) + F(" Bytes ");
mydir += F(" <a href=\"/remove/?FileToRemove=") + root.fileName() + F("\">remove</a><br>");
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ see build instructions for more info.
<img src="./pics/pump.jpg" width="300">

#### Schematics
It's in this project [PCB_V2](https://easyeda.com/editor#cmd=new_schematic,cmd_for_project=57033b6b623846b390539aaa0ca06959)
It's in this project [PCB_V2B](https://oshwlab.com/visualapproach/bestway-wireless-controller-2_copy)
Open the PCB tab and go to menu Fabrication, Gerber files. Order the PCB_V2B.

#### Installation
Expand Down

0 comments on commit 22e7ec1

Please sign in to comment.