Skip to content

Commit

Permalink
pio.ini refactor + coord3D bugfix
Browse files Browse the repository at this point in the history
pio.ini
- created [env] as common denominator
- esp32dev, lolin_d32 and lolin_s2_mini:  removed items defined in env

index.js: Coord3D: save numbers without ""

SysModModel: processJson: values:
- added setValue<Coord3D> instead of jsonObject
- this caused model.json corruption !!!!
  • Loading branch information
ewowi committed Jan 27, 2024
1 parent 365f98e commit 7c1831e
Show file tree
Hide file tree
Showing 6 changed files with 894 additions and 908 deletions.
9 changes: 5 additions & 4 deletions data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -969,14 +969,15 @@ function sendValue(varNode) {
command[varId].value = varNode.innerText;
else if (varNode.className == "coord3D") {
let coord = {};
coord.x = varNode.childNodes[0].value;
coord.y = varNode.childNodes[1].value;
coord.z = varNode.childNodes[2].value;
coord.x = parseInt(varNode.childNodes[0].value);
coord.y = parseInt(varNode.childNodes[1].value);
coord.z = parseInt(varNode.childNodes[2].value);
console.log("coord", coord);
command[varId].value = coord;
}
else //number etc
command[varId].value = Number(varNode.value)?Number(varNode.value):varNode.value; //type number is default but html converts numbers in <option> to string
//https://stackoverflow.com/questions/175739/how-can-i-check-if-a-string-is-a-valid-number
command[varId].value = isNaN(varNode.value)?varNode.value:parseFloat(varNode.value); //type number is default but html converts numbers in <option> to string, float to remove the quotes from all type of numbers
console.log("sendValue", command);

requestJson(command);
Expand Down
86 changes: 35 additions & 51 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,15 @@ build_flags =
lib_deps =
https://github.com/netmindz/WLED-sync#v0.14.0.b16

[env:esp32dev]
board = esp32dev ;https://github.com/platformio/platform-espressif32/blob/develop/boards/esp32dev.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)
[env]
framework = arduino
upload_speed = 1500000
monitor_speed = 115200
monitor_filters = esp32_exception_decoder
board_build.partitions = tools/WLED_ESP32_4MB_256KB_FS.csv ;; 1.8MB firmware, 256KB filesystem (esptool erase_flash needed when changing from "standard WLED" partitions)
board_build.filesystem = littlefs
board_build.f_flash = 80000000L ; use full 80MHz speed for flash (default = 40Mhz)
board_build.flash_mode = dio ; (dio = dual i/o; more compatible than qio = quad i/o)
; build_type = debug ;increases flash size!
build_flags =
-DCONFIG_IDF_TARGET_ESP32=1
-DCONFIG_ASYNC_TCP_USE_WDT=0
-DLFS_THREADSAFE ;; enables use of semaphores in LittleFS driver
-DARDUINO_USB_CDC_ON_BOOT=0 ;; Make sure that the right HardwareSerial driver is picked in arduino-esp32 (needed on "classic ESP32")
Expand All @@ -78,76 +72,66 @@ lib_deps =
${usermod_e131.lib_deps}
; ${usermod_ha.lib_deps}
${usermod_wledaudio.lib_deps}

[env:esp32dev]
board = esp32dev ;https://github.com/platformio/platform-espressif32/blob/develop/boards/esp32dev.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}
-DCONFIG_IDF_TARGET_ESP32=1
; RAM: [== ] 15.6% (used 51124 bytes from 327680 bytes)
; Flash: [======= ] 68.1% (used 892033 bytes from 1310720 bytes)

[env:lolin_d32]
board = lolin_d32 ;https://github.com/platformio/platform-espressif32/blob/develop/boards/esp32dev.json
board = lolin_d32 ;https://github.com/platformio/platform-espressif32/blob/develop/boards/lolin_d32.json (no differences with esp32dev)
; 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)
framework = arduino
monitor_speed = 115200
monitor_filters = esp32_exception_decoder
; board_build.partitions = tools/WLED_ESP32_4MB_256KB_FS.csv ;; 1.8MB firmware, 256KB filesystem (esptool erase_flash needed when changing from "standard WLED" partitions)
board_build.filesystem = littlefs
; board_build.f_flash = 80000000L ; use full 80MHz speed for flash (default = 40Mhz)
; board_build.flash_mode = dio ; (dio = dual i/o; more compatible than qio = quad i/o)
; build_type = debug ;increases flash size!
build_flags =
; -DCONFIG_IDF_TARGET_ESP32=1
; -DCONFIG_ASYNC_TCP_USE_WDT=0
; -DLFS_THREADSAFE ;; enables use of semaphores in LittleFS driver
; -DARDUINO_USB_CDC_ON_BOOT=0 ;; Make sure that the right HardwareSerial driver is picked in arduino-esp32 (needed on "classic ESP32")
${appmod_leds.build_flags}
${usermod_e131.build_flags}
; ${usermod_ha.build_flags}
${usermod_wledaudio.build_flags}
lib_deps =
${starmod.lib_deps}
${appmod_leds.lib_deps}
${usermod_e131.lib_deps}
; ${usermod_ha.lib_deps}
${usermod_wledaudio.lib_deps}
build_flags = ${env.build_flags}
-DCONFIG_IDF_TARGET_ESP32=1
; RAM: [== ] 15.6% (used 51124 bytes from 327680 bytes)
; Flash: [======= ] 68.1% (used 892033 bytes from 1310720 bytes)

[env:lolin_s2_mini]
board = lolin_s2_mini ;https://github.com/platformio/platform-espressif32/blob/develop/boards/lolin_s2_mini.json
;; platform = [email protected] ;; WLED default framework version
platform = [email protected] ;; this one behaves better for debugging
framework = arduino
; framework = arduino
upload_speed = 256000
monitor_speed = 115200
monitor_filters = esp32_exception_decoder
board_build.partitions = tools/WLED_ESP32_4MB_256KB_FS.csv ;; 1.8MB firmware, 256KB filesystem (esptool erase_flash needed when changing from "standard WLED" partitions)
board_build.filesystem = littlefs
; build_type = debug ;increases flash size!
build_unflags =
; -DARDUINO_USB_CDC_ON_BOOT=1 ;; un-comment if you want to use a "real" serial-to-USB moddule
build_flags =
-DARDUINO_USB_CDC_ON_BOOT=1 ;; un-comment if you want to use a "real" serial-to-USB moddule
build_flags = ${env.build_flags}
-DCONFIG_IDF_TARGET_ESP32S2=1
-DCONFIG_ASYNC_TCP_USE_WDT=0
-DLFS_THREADSAFE ;; enables use of semaphores in LittleFS driver
; -DLFS_THREADSAFE ;; enables use of semaphores in LittleFS driver
-DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_DFU_ON_BOOT=1 -DARDUINO_USB_MSC_ON_BOOT=0 ;; for debugging over USB
; -DARDUINO_USB_CDC_ON_BOOT=0 -DARDUINO_USB_DFU_ON_BOOT=1 -DARDUINO_USB_MSC_ON_BOOT=0 ;; with serial-to-USB moddule (use in case your board hangs without USB connection)
-DARDUINO_USB_MODE=0 ;; Make sure that the right HardwareSerial driver is picked in arduino-esp32 (mandatory on -S2)
; -D DEBUG=1 -D CORE_DEBUG_LEVEL=1 -D ARDUINOJSON_DEBUG=1 ;; for more debug output
${appmod_leds.build_flags}
${usermod_e131.build_flags}
; ${usermod_ha.build_flags}
${usermod_wledaudio.build_flags}
lib_deps =
${starmod.lib_deps}
${appmod_leds.lib_deps}
${usermod_e131.lib_deps}
; ${usermod_ha.lib_deps}
${usermod_wledaudio.lib_deps}
; RAM: [== ] 24.5% (used 80240 bytes from 327680 bytes)
; Flash: [========= ] 92.4% (used 1210894 bytes from 1310720 bytes)
; after WLED_ESP32_4MB_256KB_FS:
; RAM: [== ] 24.5% (used 80240 bytes from 327680 bytes)
; Flash: [====== ] 63.7% (used 1210894 bytes from 1900544 bytes)




















; Compiler warnings FastLed:
; In file included from .pio/libdeps/esp32dev/FastLED/src/FastLED.h:75,
; from src/App/AppLeds.h:11,
Expand Down
2 changes: 1 addition & 1 deletion src/App/AppModLeds.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class AppModLeds:public SysModule {

leds.endPos = mdl->getValue(var, rowNr).as<Coord3D>();

USER_PRINTF("fxEnd %d %d %d - %d %d %d\n", leds.startPos.x, leds.startPos.y, leds.startPos.z, leds.endPos.x, leds.endPos.y, leds.endPos.z);
USER_PRINTF("fxEnd chFun %d %d %d - %d %d %d\n", leds.startPos.x, leds.startPos.y, leds.startPos.z, leds.endPos.x, leds.endPos.y, leds.endPos.z);

leds.fadeToBlackBy();

Expand Down
3 changes: 2 additions & 1 deletion src/Sys/SysModModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ namespace ArduinoJson {
dst["x"] = src.x;
dst["y"] = src.y;
dst["z"] = src.z;
USER_PRINTF("dest %d,%d,%d -> %s ", src.x, src.y, src.z, dst.as<String>().c_str());
return true;
}

Expand All @@ -74,7 +75,7 @@ namespace ArduinoJson {
}

static bool checkJson(JsonVariantConst src) {
return src["x"].is<int>() && src["y"].is<int>() && src["z"].is<int>();
return src["x"].is<uint16_t>() && src["y"].is<uint16_t>() && src["z"].is<uint16_t>();
}
};
}
Expand Down
8 changes: 4 additions & 4 deletions src/Sys/SysModUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ const char * SysModUI::processJson(JsonVariant &json) { //& as we update it

JsonObject var = mdl->findVar(key);

USER_PRINTF("processJson k:%s r:%s (%s == %s ? %d)\n", key, rowNr?rowNr:"na", var["value"].as<String>().c_str(), value.as<String>().c_str(), var["value"] == value["value"]);
USER_PRINTF("processJson %s[%s] (%s == %s ? %d)\n", key, rowNr?rowNr:"na", var["value"].as<String>().c_str(), value["value"].as<String>().c_str(), var["value"] == value["value"]);

if (!var.isNull())
{
Expand All @@ -303,7 +303,7 @@ const char * SysModUI::processJson(JsonVariant &json) { //& as we update it
if (value["value"].is<bool>()) {
bool varValue = var["value"][atoi(rowNr)];
bool newValue = value["value"];
changed = (varValue && !newValue) || (!varValue && newValue);
changed = (varValue && !newValue) || (!varValue && newValue); //checking 2 booleans!
}
else
changed = var["value"][atoi(rowNr)] != value["value"];
Expand All @@ -329,8 +329,8 @@ const char * SysModUI::processJson(JsonVariant &json) { //& as we update it
mdl->setValue(key, value["value"].as<bool>(), rowNr?atoi(rowNr):-1);
else if (value["value"].is<int>())
mdl->setValue(key, value["value"].as<int>(), rowNr?atoi(rowNr):-1);
else if (value["value"].is<JsonObject>())
mdl->setValue(key, value["value"].as<JsonObject>(), rowNr?atoi(rowNr):-1);
else if (value["value"].is<Coord3D>()) //do not use is<JsonObject>() for Coord3D as Coord2D is more specific and we need to assign the values, otherwise corrupt values in model !!!!
mdl->setValue(key, value["value"].as<Coord3D>(), rowNr?atoi(rowNr):-1);
else {
USER_PRINTF("processJson %s %s->%s not a supported type yet\n", key, var["value"].as<String>().c_str(), value.as<String>().c_str());
}
Expand Down
Loading

0 comments on commit 7c1831e

Please sign in to comment.