Skip to content

Commit

Permalink
Live Script refactors, use bool3State, add wrover build, and more
Browse files Browse the repository at this point in the history
pio.ini
- ESPAsyncE131: back to standard v1.0.3 (WIP)
- ESPLiveScript: use ewowi fork to control latest version and add pending PR's
- Add wrover build

SysModUI
- initCheckBox by reference: use bool3State
- initValue: don't need varFun to do initValue (as also without pointers must be set)

SysModWeb:
- use 192.168.1 in curl examples (thx to the club lights 12 pro ;-) ), use pid,id in curl examples

StarJson
- lookFor: add uint8_t, comment uint16_t and int as not used at the moment

UserModLive
- rename addExternals to addDefaultExternals
- compile without progName parameter
- replace taskExists with findExecutable
- execute(BackGround)Task and killAndDelete  using exeID instead of fileName (faster)
- xecute(BackGround)Task add main as default function
- executeTask add optional int Argument
- script var: check if fileNr != UINT8_MAX, don't compile again if already in memory, execute only if compile successful, use BackGroundTask
- scripts columns: use vector iterators
- add size column
- addDefaultExternals: init scPreBaseScript
- compile: return exeID, executable as stack var

UserModMPU6050
- use bool3State
  • Loading branch information
ewowi committed Nov 3, 2024
1 parent 02ec605 commit 1a84863
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 111 deletions.
2 changes: 1 addition & 1 deletion misc/LiveScripts/blinkSL.sc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ uint8_t blinkPin; //tbd: assigment here

void setup()
{
blinkPin = 5; //tbd make blinkPin an ui control
blinkPin = 2; //tbd make blinkPin an ui control

//pinsM->allocatePin(2, "Blink", "On board led"); //class methods and strings supported?
pinMode(blinkPin, OUTPUT); //tbd: part of allocatePin?
Expand Down
25 changes: 22 additions & 3 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ lib_deps =
build_flags =
-D STARBASE_USERMOD_E131
lib_deps =
https://github.com/forkineye/ESPAsyncE131.git#9655aae7 ; no tag #v1.0.3 as commits after these tags exists
https://github.com/forkineye/ESPAsyncE131.git#v1.0.3
; https://github.com/forkineye/ESPAsyncE131.git#9655aae7 ; no tag #v1.0.3 as commits after these tags exists

[STARBASE_USERMOD_HA]
build_flags =
Expand All @@ -70,7 +71,8 @@ lib_deps =
build_flags =
-D STARBASE_USERMOD_LIVE
lib_deps =
https://github.com/hpwit/ESPLiveScript.git#5928b9d ;v2.9.3 @ 20241027 18:40
; https://github.com/hpwit/ESPLiveScript.git#17b4bb7 ;v2.9.3 @ 20241030 15:39
https://github.com/ewowi/ESPLiveScript.git#v2.9.3 ;ewowi repo adds some proposed PR's and makes sure we don't have unexpected updates

[STARBASE]
build_flags =
Expand Down Expand Up @@ -143,6 +145,23 @@ build_flags =
lib_deps =
${env.lib_deps}

; https://github.com/platformio/platform-espressif32/issues/1360
; https://community.platformio.org/t/support-esp32-wrover-module/17717
; note: flasghing to new board goes wrong, try first without ICVD then with and without etc until it works (witchcraft)
[env:esp32_wrover]
board = esp-wrover-kit ; esp-wrover-kit ;https://github.com/platformio/platform-espressif32/blob/develop/boards/esp-wrover-kit.json
; recommended to pin to a platform version, see https://github.com/platformio/platform-espressif32/releases
platform = [email protected] ;using platformio/framework-arduinoespressif32 @ ~3.20014.0 / framework-arduinoespressif32 @ 3.20014.231204 (2.0.14)
upload_speed = 1500000
build_flags =
${env.build_flags}
-D CONFIG_IDF_TARGET_ESP32=1
-D ARDUINO_USB_CDC_ON_BOOT=0 ; Make sure that the right HardwareSerial driver is picked in arduino-esp32 (needed on "classic ESP32")
-DBOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue
lib_deps =
${env.lib_deps}


[env:pico32]
board = pico32 ;https://github.com/platformio/platform-espressif32/blob/develop/boards/pico32.json
Expand Down Expand Up @@ -237,7 +256,7 @@ platform = [email protected] ;default is Espressif 32 (6.5.0)
; platform = espressif32@ ~6.3.2 ; WLEDMM:
; platform = platformio/espressif32@^6.7.0 ;TroyHacks:
; platform_packages ;default is framework-arduinoespressif32 @ 3.20014.231204 (2.0.14)
; WLEDMM: platformio/framework-arduinoespressif32 @ 3.20009.0 ;; select arduino-esp32 v2.0.9 (arduino-esp32 2.0.10 thru 2.0.14 are buggy so avoid them)
; WLEDMM: platformio/framework-arduinoespressif32 @ 3.20009.0 ; select arduino-esp32 v2.0.9 (arduino-esp32 2.0.10 thru 2.0.14 are buggy so avoid them)
; TroyHacks: platformio/[email protected]
; ;toolchain-riscv32-esp@~12.2
; ;toolchain-xtensa-esp32s3@~12.2
Expand Down
8 changes: 4 additions & 4 deletions src/Sys/SysModUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ class SysModUI: public SysModule {
return initVarAndValue<bool3State>(parent, id, "checkbox", value, 0, 0, readOnly, varFun);
}
//init a checkbox using referenced value
JsonObject initCheckBox(JsonObject parent, const char * id, bool * value = nullptr, bool readOnly = false, VarFun varFun = nullptr) {
return initVarAndValue<bool>(parent, id, "checkbox", value, 0, 0, readOnly, varFun);
JsonObject initCheckBox(JsonObject parent, const char * id, bool3State *value = nullptr, bool readOnly = false, VarFun varFun = nullptr) {
return initVarAndValue<bool3State>(parent, id, "checkbox", value, 0, 0, readOnly, varFun);
}

//a button never gets a value
Expand Down Expand Up @@ -289,7 +289,7 @@ class SysModUI: public SysModule {
}
else { //do onChange on existing value
//no call of onChange for buttons otherwise all buttons will be fired which is highly undesirable
if (var["type"] != "button" && !var["fun"].isNull() ) { //!isPointer because 0 is also a value then && (!isPointer || value)
if (var["type"] != "button") { // && !var["fun"].isNull(): also if no varFun to update pointers !isPointer because 0 is also a value then && (!isPointer || value)
bool onChangeExists = false;
if (var["value"].is<JsonArray>()) {
//refill the vector
Expand All @@ -298,7 +298,7 @@ class SysModUI: public SysModule {
}
}
else {
onChangeExists = mdl->callVarOnChange(var, mdl->setValueRowNr, true); //init, also set var["p"]
onChangeExists = mdl->callVarOnChange(var, mdl->setValueRowNr, true); //init, also set var["p"]
}

if (onChangeExists)
Expand Down
12 changes: 6 additions & 6 deletions src/Sys/SysModWeb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ void SysModWeb::connectedChanged() {


// ppf("%s server (re)started\n", name); //causes crash for some reason...
ppf("server (re)started\n");
ppf("connectedChanged: web server (re)started %s \n", name);
}
//else remove handlers...
}

//WebSocket connection to 'ws://192.168.8.152/ws' failed: The operation couldn’t be completed. Protocol error
//WS error 192.168.8.126 9 (2)
//WebSocket connection to 'ws://192.168.1.152/ws' failed: The operation couldn’t be completed. Protocol error
//WS error 192.168.1.126 9 (2)
//WS event data 0.0.0.0 (1) 0 0 0=0? 34 0
//WS pong 0.0.0.0 9 (1)
//wsEvent deserializeJson failed with code EmptyInput
Expand Down Expand Up @@ -476,7 +476,7 @@ void SysModWeb::serveNewUI(WebRequest *request) {

void SysModWeb::serveUpload(WebRequest *request, const String& fileName, size_t index, byte *data, size_t len, bool final) {

// curl -F '[email protected]' 192.168.8.213/upload
// curl -F '[email protected]' 192.168.1.213/upload
ppf("serveUpload r:%s f:%s i:%d l:%d f:%d\n", request->url().c_str(), fileName.c_str(), index, len, final);

mdl->setValue("Files", "upload", index/10000);
Expand Down Expand Up @@ -530,7 +530,7 @@ void SysModWeb::serveUpload(WebRequest *request, const String& fileName, size_t

void SysModWeb::serveUpdate(WebRequest *request, const String& fileName, size_t index, byte *data, size_t len, bool final) {

// curl -F '[email protected]' 192.168.8.213/upload
// curl -F '[email protected]' 192.168.1.213/upload
// ppf("serveUpdate r:%s f:%s i:%d l:%d f:%d\n", request->url().c_str(), fileName.c_str(), index, len, final);

mdl->setValue("System", "update", index/10000);
Expand Down Expand Up @@ -711,7 +711,7 @@ void SysModWeb::serializeState(JsonVariant root) {

}
void SysModWeb::serializeInfo(JsonVariant root) {
const char * jsonInfo = "{\"ver\":\"0.14.1-b30.36\",\"rel\":\"abc_wled_controller_v43_M\",\"vid\":2402252,\"leds\":{\"count\":1024,\"countP\":1024,\"pwr\":1124,\"fps\":32,\"maxpwr\":9500,\"maxseg\":32,\"matrix\":{\"w\":32,\"h\":32},\"seglc\":[1],\"lc\":1,\"rgbw\":false,\"wv\":0,\"cct\":0},\"str\":false,\"name\":\"WLED-Wladi\",\"udpport\":21324,\"live\":false,\"liveseg\":-1,\"lm\":\"\",\"lip\":\"\",\"ws\":2,\"fxcount\":195,\"palcount\":75,\"cpalcount\":0,\"maps\":[{\"id\":0}],\"outputs\":[1024],\"wifi\":{\"bssid\":\"\",\"rssi\":0,\"signal\":100,\"channel\":1},\"fs\":{\"u\":20,\"t\":983,\"pmt\":0},\"ndc\":16,\"arch\":\"esp32\",\"core\":\"v3.3.6-16-gcc5440f6a2\",\"lwip\":0,\"totalheap\":294784,\"getflash\":4194304,\"freeheap\":115988,\"freestack\":6668,\"minfreeheap\":99404,\"e32core0code\":12,\"e32core0text\":\"SW restart\",\"e32core1code\":12,\"e32core1text\":\"SW restart\",\"e32code\":4,\"e32text\":\"SW error (panic or exception)\",\"e32model\":\"ESP32-D0WDQ5 rev.3\",\"e32cores\":2,\"e32speed\":240,\"e32flash\":4,\"e32flashspeed\":80,\"e32flashmode\":2,\"e32flashtext\":\" (DIO)\",\"uptime\":167796,\"opt\":79,\"brand\":\"WLED\",\"product\":\"MoonModules\",\"mac\":\"08b61f6fa800\",\"ip\":\"192.168.8.171\"}";
const char * jsonInfo = "{\"ver\":\"0.14.1-b30.36\",\"rel\":\"abc_wled_controller_v43_M\",\"vid\":2402252,\"leds\":{\"count\":1024,\"countP\":1024,\"pwr\":1124,\"fps\":32,\"maxpwr\":9500,\"maxseg\":32,\"matrix\":{\"w\":32,\"h\":32},\"seglc\":[1],\"lc\":1,\"rgbw\":false,\"wv\":0,\"cct\":0},\"str\":false,\"name\":\"WLED-Wladi\",\"udpport\":21324,\"live\":false,\"liveseg\":-1,\"lm\":\"\",\"lip\":\"\",\"ws\":2,\"fxcount\":195,\"palcount\":75,\"cpalcount\":0,\"maps\":[{\"id\":0}],\"outputs\":[1024],\"wifi\":{\"bssid\":\"\",\"rssi\":0,\"signal\":100,\"channel\":1},\"fs\":{\"u\":20,\"t\":983,\"pmt\":0},\"ndc\":16,\"arch\":\"esp32\",\"core\":\"v3.3.6-16-gcc5440f6a2\",\"lwip\":0,\"totalheap\":294784,\"getflash\":4194304,\"freeheap\":115988,\"freestack\":6668,\"minfreeheap\":99404,\"e32core0code\":12,\"e32core0text\":\"SW restart\",\"e32core1code\":12,\"e32core1text\":\"SW restart\",\"e32code\":4,\"e32text\":\"SW error (panic or exception)\",\"e32model\":\"ESP32-D0WDQ5 rev.3\",\"e32cores\":2,\"e32speed\":240,\"e32flash\":4,\"e32flashspeed\":80,\"e32flashmode\":2,\"e32flashtext\":\" (DIO)\",\"uptime\":167796,\"opt\":79,\"brand\":\"WLED\",\"product\":\"MoonModules\"}";
JsonDocument docInfo;

deserializeJson(root, jsonInfo);
Expand Down
14 changes: 7 additions & 7 deletions src/Sys/SysModWeb.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,18 @@ class SysModWeb:public SysModule {
void serveJson(WebRequest *request);


// curl -F '[email protected]' 192.168.8.213/upload
// curl -F '[email protected]' 192.168.1.213/upload
void serveUpload(WebRequest *request, const String& fileName, size_t index, byte *data, size_t len, bool final);
// curl -s -F "update=@/Users/ewoudwijma/Developer/GitHub/ewowi/StarBase/.pio/build/esp32dev/firmware.bin" 192.168.8.102/update /dev/null &
// curl -s -F "update=@/Users/ewoudwijma/Developer/GitHub/ewowi/StarBase/.pio/build/esp32dev/firmware.bin" 192.168.1.102/update /dev/null &
void serveUpdate(WebRequest *request, const String& fileName, size_t index, byte *data, size_t len, bool final);
void serveFiles(WebRequest *request);

//processJsonUrl handles requests send in javascript using fetch and from a browser or curl
//try this !!!: curl -X POST "http://192.168.121.196/json" -d '{"pin2":false}' -H "Content-Type: application/json"
//curl -X POST "http://4.3.2.1/json" -d '{"pin2":false}' -H "Content-Type: application/json"
//curl -X POST "http://4.3.2.1/json" -d '{"brightness":20, "v":true}' -H "Content-Type: application/json"
//curl -X POST "http://192.168.8.125/json" -d '{"effect":2}' -H "Content-Type: application/json"
//curl -X POST "http://192.168.8.152/json" -d '{"nrOfLeds":2000}' -H "Content-Type: application/json"
//try this !!!:
//curl -X POST "http://4.3.2.1/json" -d '{"Pins.pin19":false}' -H "Content-Type: application/json"
//curl -X POST "http://4.3.2.1/json" -d '{"Fixture.brightness":20, "v":true}' -H "Content-Type: application/json"
//curl -X POST "http://192.168.1.125/json" -d '{"leyers.effect":2}' -H "Content-Type: application/json"
//curl -X POST "http://192.168.1.152/json" -d '{"nrOfLeds":2000}' -H "Content-Type: application/json"

//handle "v" and processJson (on /json)
void jsonHandler(WebRequest *request, JsonVariant json);
Expand Down
28 changes: 15 additions & 13 deletions src/Sys/SysStarJson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,21 @@
files->filesChanged = true;
}

//look for uint8 var
// void lookFor(const char * id, uint8_t * value) {
// // const char *p = (const char*)&value; //pointer trick
// uint8List.push_back(value);
// addToVars(id, "uint8", uint8List.size()-1);
void StarJson::lookFor(const char * id, uint8_t * value) {
uint8List.push_back(value);
addToVars(id, "uint8", uint8List.size()-1);
}

// void StarJson::lookFor(const char * id, uint16_t * value) {
// uint16List.push_back(value);
// addToVars(id, "uint16", uint16List.size()-1);
// }

//look for uint16 var
void StarJson::lookFor(const char * id, uint16_t * value) {
uint16List.push_back(value);
addToVars(id, "uint16", uint16List.size()-1);
}
// void StarJson::lookFor(const char * id, int * value) {
// intList.push_back(value);
// addToVars(id, "int", intList.size()-1);
// }

//look for char var
void StarJson::lookFor(const char * id, char * value) {
charList.push_back(value);
addToVars(id, "char", charList.size()-1);
Expand Down Expand Up @@ -201,8 +202,9 @@
// ppf("check %s %s %s\n", vd->id, varId, value);
if (strncmp(vd->id, varId, 32)==0) {
// ppf("StarJson found %s:%s %d %s %d %d\n", varId, vd->type, vd->index, value?value:"", uint16CollectList.size(), funList.size());
// if (strncmp(vd->type, "uint8") ==0 && value) *uint8List[vd->index] = atoi(value);
if (strncmp(vd->type, "uint16", 7) ==0 && value) *uint16List[vd->index] = atoi(value);
if (strncmp(vd->type, "uint8", 7) ==0 && value) *uint8List[vd->index] = atoi(value);
// if (strncmp(vd->type, "uint16", 7) ==0 && value) *uint16List[vd->index] = atoi(value);
// if (strncmp(vd->type, "int", 7) ==0 && value) *intList[vd->index] = atoi(value);
if (strncmp(vd->type, "char", 5) ==0 && value) strlcpy(charList[vd->index], value, 32); //assuming size 32 here
if (strncmp(vd->type, "fun", 4) ==0) funList[vd->index](uint16CollectList); //call for every found item (no value check)
foundCounter++;
Expand Down
14 changes: 6 additions & 8 deletions src/Sys/SysStarJson.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,10 @@ class StarJson {
// addToVars(id, "uint8", uint8List.size()-1);
// }

//look for uint16 var
void lookFor(const char * id, uint16_t * value);

//look for char var
void lookFor(const char * id, uint8_t * value);
// void lookFor(const char * id, uint16_t * value);
// void lookFor(const char * id, int * value);
void lookFor(const char * id, char * value);

//look for array of integers
void lookFor(const char * id, std::function<void(std::vector<uint16_t>)> fun);

//reads from file until all vars have been found (then stops reading)
Expand All @@ -61,8 +58,9 @@ class StarJson {
File f;
byte character; //the last character parsed
std::vector<VarDetails> varDetails; //details of vars looking for
// std::vector<uint8_t *> uint8List; //pointer of uint8 to assign found values to (index of list stored in varDetails)
std::vector<uint16_t *> uint16List; //same for uint16
std::vector<uint8_t *> uint8List; //pointer of uint8 to assign found values to (index of list stored in varDetails)
// std::vector<uint16_t *> uint16List; //same for uint16
// std::vector<int *> intList; //same for int
std::vector<char *> charList; //same for char
std::vector<std::function<void(std::vector<uint16_t>)>> funList; //same for function calls
std::vector<String> varStack; //objects and arrays store their names in a stack
Expand Down
Loading

0 comments on commit 1a84863

Please sign in to comment.