From 4aea3970a3985c72b04f735bb02ee3d3576ed2a6 Mon Sep 17 00:00:00 2001 From: Ewoud Date: Fri, 7 Apr 2023 12:43:38 +0200 Subject: [PATCH] ARTI-FX support 8266 (experimental!!) add soundpressure Add ARTI-FX to esp8266_4MB_M (experimental!) Arti.h - FREE_SIZE ESP.getFreeHeap() for 8266 - define asChar(x) to print to Serial/File depending on ESP32/8266 - artiPrintf: print to USER_PRINTF (experimental) Arti_wled.h - add ARDUINO_ARCH_ESP8266 to ARTI_ARDUINO - add soundPressure usermod_v2_artifx.h: use FREE_SIZE --- platformio.ini | 7 +- usermods/Temperature/usermod_temperature.h | 4 +- usermods/artifx/arti.h | 128 ++++++++++-------- usermods/artifx/arti_wled.h | 18 ++- usermods/artifx/usermod_v2_artifx.h | 10 +- .../usermod_v2_four_line_display_ALT.h | 2 +- wled00/FX.cpp | 2 +- wled00/FX_2Dfcn.cpp | 1 - wled00/wled.h | 2 +- 9 files changed, 97 insertions(+), 77 deletions(-) diff --git a/platformio.ini b/platformio.ini index 8e5829eb..7babe2c5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -827,6 +827,7 @@ build_flags_M = -D USERMOD_WEATHER ; WLEDMM usermod -D USERMOD_MPU6050_IMU ; gyro/accelero for USERMOD_GAMES (ONLY WORKS IF USERMOD_FOUR_LINE_DISPLAY NOT INCLUDED - I2C SHARING BUG) -D USERMOD_GAMES ; WLEDMM usermod + ; -D USERMOD_FASTLED ; WLEDMM usermod: CC BY-NC 3.0 licensed effects by Stefan Petrick, include this usermod only if you accept the terms! ;WLEDMM: only setting WLED_DEBUG_HOST is enough, ip and port can be defined in sync settings as well -D WLED_DEBUG_HOST='"192.168.x.x"' ;; to send debug messages over network to host 192.168.x.y - FQDN is also possible -D WLED_DEBUG_PORT=1768 ;; port for network debugging. default = 7868 @@ -1072,7 +1073,6 @@ build_flags = ${common.build_flags_esp8266} -D WLED_DISABLE_HUESYNC -D WLED_DISABLE_LOXONE ; -D USERMOD_AUDIOREACTIVE - ; -D USERMOD_ARTIFX ; to be done ; -UWLED_USE_MY_CONFIG -D USERMOD_PIRSWITCH -D USERMOD_DALLASTEMPERATURE ;; disabled because it hangs during usermod setup on -S3 (autodetect broken?) @@ -1081,8 +1081,9 @@ build_flags = ${common.build_flags_esp8266} -D USERMOD_FOUR_LINE_DISPLAY -D USERMOD_MPU6050_IMU ; gyro/accelero for USERMOD_GAMES (ONLY WORKS IF USERMOD_FOUR_LINE_DISPLAY NOT INCLUDED - I2C SHARING BUG) -D USERMOD_GAMES ; WLEDMM usermod + -D USERMOD_ARTIFX ; -D WLED_DEBUG -; monitor_filters = esp8266_exception_decoder +monitor_filters = esp8266_exception_decoder lib_deps = ${esp8266.lib_deps} OneWire@~2.3.5 ; used for USERMOD_FOUR_LINE_DISPLAY and USERMOD_DALLASTEMPERATURE olikraus/U8g2 @ ^2.28.8 ; used for USERMOD_FOUR_LINE_DISPLAY @@ -1117,7 +1118,7 @@ build_flags = ${common.build_flags_esp8266} -D WLED_RELEASE_NAME=ESP8266 lib_deps = ${esp8266.lib_deps} paulstoffregen/OneWire@~2.3.7 ;WLEDMM Softhack, we need this as well (instead of 2.3.5)? olikraus/U8g2 # @~2.33.15 - Wire ; WLEDMM needed? + Wire ; WLEDMM ewowi, needed? [env:esp8266pro_16MB_S] extends = env:d1_mini diff --git a/usermods/Temperature/usermod_temperature.h b/usermods/Temperature/usermod_temperature.h index 885f445e..1c49163a 100644 --- a/usermods/Temperature/usermod_temperature.h +++ b/usermods/Temperature/usermod_temperature.h @@ -339,12 +339,12 @@ class UsermodTemperature : public Usermod { * The function should return true if configuration was successfully loaded or false if there was no configuration. */ bool readFromConfig(JsonObject &root) { - bool configComplete = Usermod::readFromConfig(root); + /*bool configComplete = */Usermod::readFromConfig(root); //WLEDMM: configComplete not implemented here (todo?) JsonObject top = root[FPSTR(_name)]; + DEBUG_PRINT(FPSTR(_name)); // we look for JSON object: {"Temperature": {"pin": 0, "degC": true}} int8_t newTemperaturePin = temperaturePin; - DEBUG_PRINT(FPSTR(_name)); if (top.isNull()) { DEBUG_PRINTLN(F(": No config found. (Using defaults.)")); diff --git a/usermods/artifx/arti.h b/usermods/artifx/arti.h index 290a7604..6ee8420c 100644 --- a/usermods/artifx/arti.h +++ b/usermods/artifx/arti.h @@ -55,7 +55,14 @@ #define ARTI_PRINT 1 //will show the printf calls const char spaces[51] PROGMEM = " "; - #define FREE_SIZE esp_get_free_heap_size() + #if defined(ARDUINO_ARCH_ESP32) + #define FREE_SIZE esp_get_free_heap_size() + #define asChar(x) x.as().c_str() //WLEDMM: tbd: find out why char * is causing crashes!!! + #else + #define FREE_SIZE ESP.getFreeHeap() + #define asChar(x) "" + //x.as() //WLEDMM: no arduinojson output for the moment as this is in testing phase + #endif // #define OPTIMIZED_TREE 1 #else //embedded #include "dependencies/ArduinoJson-recent.h" @@ -75,7 +82,8 @@ #include const char spaces[51] = " "; - #define FREE_SIZE (unsigned int)0 + #define FREE_SIZE (unsigned int)0 //No free heap function found on embedded + #define asChar(x) x.as() // #define OPTIMIZED_TREE 1 #endif @@ -90,14 +98,20 @@ void artiPrintf(char const * format, ...) if (!logToFile) { - vprintf(format, argp); + //WLEDMM: to be done, check if we can move to USER_PRINTF + #if ARTI_PLATFORM == ARTI_ARDUINO //defined in arti_definition.h e.g. arti_wled.h! + USER_PRINTF(format, argp); //WLEDMM also supporting netprint + #else + vprintf(format, argp); + #endif + } else { #if ARTI_PLATFORM == ARTI_ARDUINO // rocket science here! As logfile.printf causes crashes/wrong output we create our own printf here // logFile.printf(format, argp); - for (int i = 0; i < strlen(format); i++) + for (size_t i = 0; i < strlen(format); i++) { if (format[i] == '%') { @@ -560,7 +574,7 @@ class Lexer { { while (strncmp(this->text + this->pos, endTokens, strlen(endTokens)) != 0) this->advance(); - for (int i=0; iadvance(); } @@ -696,7 +710,7 @@ class Lexer { { strcpy(current_token.type, token_type); strcpy(current_token.value, token_value); - for (int i=0; iadvance(); return; } @@ -1072,12 +1086,12 @@ public: float arti_get_external_variable(uint8_t variable, float par1 = floatNull, float par2 = floatNull, float par3 = floatNull); void arti_set_external_variable(float value, uint8_t variable, float par1 = floatNull, float par2 = floatNull, float par3 = floatNull); bool loop(); - + uint8_t parse(JsonVariant parseTree, const char * node_name, char operatorx, JsonVariant expression, uint8_t depth = 0) { if (depth > 50) { - ERROR_ARTI("Error: Parse recursion level too deep at %s (%u)\n", parseTree.as().c_str(), depth); + ERROR_ARTI("Error: Parse recursion level too deep at %s (%u)\n", asChar(parseTree), depth); errorOccurred = true; } if (errorOccurred) return ResultFail; @@ -1101,7 +1115,7 @@ public: nextNode_name = expressionElement; //e.g. block nextExpression = nodeExpression; // e.g. ["LCURL",{"*": ["statement"]},"RCURL"] - // DEBUG_ARTI("%s %s %u\n", spaces+50-depth, nextNode_name, depth); //, parseTree.as().c_str() + // DEBUG_ARTI("%s %s %u\n", spaces+50-depth, nextNode_name, depth); //, asChar(parseTree) if (parseTree.is()) { @@ -1176,7 +1190,7 @@ public: } else { - ERROR_ARTI("%s Programming error: undefined %c %s\n", spaces+50-depth, objectOperator, objectElement.as().c_str()); + ERROR_ARTI("%s Programming error: undefined %c %s\n", spaces+50-depth, objectOperator, asChar(objectElement)); resultChild2 = ResultFail; } counter++; @@ -1185,7 +1199,7 @@ public: } //not or } // element is array else - ERROR_ARTI("%s Definition error: should be an array %s %c %s\n", spaces+50-depth, stringOrEmpty(nextNode_name), operatorx, objectElement.as().c_str()); + ERROR_ARTI("%s Definition error: should be an array %s %c %s\n", spaces+50-depth, stringOrEmpty(nextNode_name), operatorx, asChar(objectElement)); } else if (nextExpression.is()) // e.g. ["LPAREN", "expr*", "RPAREN"] { @@ -1230,9 +1244,9 @@ public: else //expressionElement is not a node, not a token, not an array and not an object { if (lexer->definitionJson.containsKey(nextExpression.as())) - ERROR_ARTI("%s Programming error: %s not a node, token, array or object in %s\n", spaces+50-depth, nextExpression.as().c_str(), stringOrEmpty(nextNode_name)); + ERROR_ARTI("%s Programming error: %s not a node, token, array or object in %s\n", spaces+50-depth, asChar(nextExpression), stringOrEmpty(nextNode_name)); else - ERROR_ARTI("%s Definition error: \"%s\": \"%s\" node should be embedded in array\n", spaces+50-depth, stringOrEmpty(nextNode_name), nextExpression.as().c_str()); + ERROR_ARTI("%s Definition error: \"%s\": \"%s\" node should be embedded in array\n", spaces+50-depth, stringOrEmpty(nextNode_name), asChar(nextExpression)); } //nextExpression is not a token if (!nodeExpression.isNull()) //if node @@ -1254,7 +1268,7 @@ public: } else //success { - DEBUG_ARTI("%s found %s\n", spaces+50-depth, nextNode_name);//, nextParseTree.as().c_str()); + DEBUG_ARTI("%s found %s\n", spaces+50-depth, nextNode_name);//, asChar(nextParseTree)); //parseTree optimization moved to optimize function // if (nextParseTree.is()) @@ -1269,10 +1283,10 @@ public: // { // // JsonObject nextParseTreeObject = nextParseTree.as(); - // DEBUG_ARTI("%s found %s:%s\n", spaces+50-depth, node_name, parseTree.as().c_str()); - // DEBUG_ARTI("%s found replace %s by %s %s\n", spaces+50-depth, nextNode_name, begin->key().c_str(), nextParseTree.as().c_str()); - // DEBUG_ARTI("%s expression %s\n", spaces+50-depth, expression.as().c_str()); - // DEBUG_ARTI("%s found %s\n", spaces+50-depth, nextParseTree[nextNode_name].as().c_str()); + // DEBUG_ARTI("%s found %s:%s\n", spaces+50-depth, node_name, asChar(parseTree)); + // DEBUG_ARTI("%s found replace %s by %s %s\n", spaces+50-depth, nextNode_name, begin->key().c_str(), asChar(nextParseTree)); + // DEBUG_ARTI("%s expression %s\n", spaces+50-depth, asChar(expression)); + // DEBUG_ARTI("%s found %s\n", spaces+50-depth, asChar(nextParseTree[nextNode_name])); // nextParseTree.remove(nextNode_name); // // char temp[charLength]; @@ -1281,11 +1295,11 @@ public: // // strcat(temp, begin->key().c_str()); // nextParseTree[begin->key()] = begin->value(); - // DEBUG_ARTI("%s found %s:%s\n", spaces+50-depth, node_name, parseTree.as().c_str()); + // DEBUG_ARTI("%s found %s:%s\n", spaces+50-depth, node_name, asChar(parseTree)); // } // } // else - // DEBUG_ARTI("%s no jsonobject??? %s\n", spaces+50-depth, parseTree.as().c_str()); + // DEBUG_ARTI("%s no jsonobject??? %s\n", spaces+50-depth, asChar(parseTree)); } } // if node @@ -1318,7 +1332,7 @@ public: } } else { //should never happen - ERROR_ARTI("%s Programming error: no array %s %c %s\n", spaces+50-depth, stringOrEmpty(node_name), operatorx, expression.as().c_str()); + ERROR_ARTI("%s Programming error: no array %s %c %s\n", spaces+50-depth, stringOrEmpty(node_name), operatorx, asChar(expression)); } return result; @@ -1327,10 +1341,10 @@ public: bool analyze(JsonVariant parseTree, const char * treeElement = nullptr, ScopedSymbolTable* current_scope = nullptr, uint8_t depth = 0) { - // ANDBG_ARTI("%s Depth %u %s\n", spaces+50-depth, depth, parseTree.as().c_str()); + // ANDBG_ARTI("%s Depth %u %s\n", spaces+50-depth, depth, asChar(parseTree)); if (depth > 24) //otherwise stack canary errors on Arduino (value determined after testing, should be revisited) { - ERROR_ARTI("Error: Analyze recursion level too deep at %s (%u)\n", parseTree.as().c_str(), depth); + ERROR_ARTI("Error: Analyze recursion level too deep at %s (%u)\n", asChar(parseTree), depth); errorOccurred = true; } if (errorOccurred) return false; @@ -1389,7 +1403,7 @@ public: else if (strcmp(valueStr, "||") == 0) parseTree["token"] = F_or; else - ERROR_ARTI("%s Programming error: token not defined as operator %s %s (%u)\n", spaces+50-depth, key, value.as().c_str(), depth); + ERROR_ARTI("%s Programming error: token not defined as operator %s %s (%u)\n", spaces+50-depth, key, asChar(value), depth); visitedAlready = true; } @@ -1543,7 +1557,7 @@ public: { JsonObject asop = value["assignoperator"]; JsonObject::iterator asopBegin = asop.begin(); - ANDBG_ARTI("%s %s\n", spaces+50-depth, asopBegin->value().as().c_str()); + ANDBG_ARTI("%s %s\n", spaces+50-depth, asChar(asopBegin->value())); if (strcmp(asopBegin->value(), "+=") == 0) value["assignoperator"] = F_plus; else if (strcmp(asopBegin->value(), "-=") == 0) @@ -1623,7 +1637,7 @@ public: { // string element = parseTree; //for some weird reason this causes a crash on esp32 - // ERROR_ARTI("%s Error: parseTree should be array or object %s (%u)\n", spaces+50-depth, parseTree.as().c_str(), depth); + // ERROR_ARTI("%s Error: parseTree should be array or object %s (%u)\n", spaces+50-depth, asChar(parseTree), depth); } return !errorOccurred; @@ -1632,7 +1646,7 @@ public: //https://dev.to/lefebvre/compilers-106---optimizer--ig8 bool optimize(JsonVariant parseTree, uint8_t depth = 0) { - // DEBUG_ARTI("%s optimize %s (%u)\n", spaces+50-depth, parseTree.as().c_str(), depth); + // DEBUG_ARTI("%s optimize %s (%u)\n", spaces+50-depth, asChar(parseTree), depth); if (parseTree.is()) { @@ -1660,7 +1674,7 @@ public: if (value.size() == 0) { parseTree.remove(key); - // DEBUG_ARTI("%s optimize: remove empty %s %s (%u)\n", spaces+50-depth, key, value.as().c_str(), depth); + // DEBUG_ARTI("%s optimize: remove empty %s %s (%u)\n", spaces+50-depth, key, asChar(value), depth); } visitedAlready = true; @@ -1682,7 +1696,7 @@ public: { //- check if a node is not used in analyzer / interpreter and has only one element: go to the parent and replace itself with its child (shrink) - // DEBUG_ARTI("%s node try to shrink %s : %s (%u)\n", spaces+50-depth, key, value.as().c_str(), value.size()); + // DEBUG_ARTI("%s node try to shrink %s : %s (%u)\n", spaces+50-depth, key, asChar(value), value.size()); JsonObject::iterator objectIterator = value.as().begin(); @@ -1694,26 +1708,26 @@ public: // // if (objectIterator2->value().is() ) //&& objectIterator.size() == 1 // { - // DEBUG_ARTI("%s node to shrink %s : %s from %s\n", spaces+50-depth, key, value.as().c_str(), parseTree.as().c_str()); - // DEBUG_ARTI("%s node to shrink %s : %s\n", spaces+50-depth, objectIterator->key().c_str(), objectIterator->value().as().c_str()); - // // DEBUG_ARTI("%s node to shrink %s : %s\n", spaces+50-depth, objectIterator2->key().c_str(), objectIterator2->value().as().c_str()); - // DEBUG_ARTI("%s node to shrink replace %s\n", spaces+50-depth, parseTree[key].as().c_str()); - // DEBUG_ARTI("%s node to shrink by %s\n", spaces+50-depth, objectIterator->value().as().c_str()); + // DEBUG_ARTI("%s node to shrink %s : %s from %s\n", spaces+50-depth, key, asChar(value), asChar(parseTree)); + // DEBUG_ARTI("%s node to shrink %s : %s\n", spaces+50-depth, objectIterator->key().c_str(), asChar(objectIterator->value())); + // // DEBUG_ARTI("%s node to shrink %s : %s\n", spaces+50-depth, objectIterator2->key().c_str(), asChar(objectIterator2->value())); + // DEBUG_ARTI("%s node to shrink replace %s\n", spaces+50-depth, asChar(parseTree[key])); + // DEBUG_ARTI("%s node to shrink by %s\n", spaces+50-depth, asChar(objectIterator->value())); // // parseTree[key][objectIterator->key().c_str()] = objectIterator2->value(); // parseTree[key] = objectIterator->value(); // } // // else // // { - // // DEBUG_ARTI("%s node to shrink2 %s : %s\n", spaces+50-depth, objectIterator2->key().c_str(), objectIterator2->value().as().c_str()); + // // DEBUG_ARTI("%s node to shrink2 %s : %s\n", spaces+50-depth, objectIterator2->key().c_str(), asChar(objectIterator2->value())); // // } // } // else - // DEBUG_ARTI("%s value should be an object %s in %s : %s from %s\n", spaces+50-depth, objectIterator->key().c_str(), key, objectIterator->value().as().c_str(), value.as().c_str()); + // DEBUG_ARTI("%s value should be an object %s in %s : %s from %s\n", spaces+50-depth, objectIterator->key().c_str(), key, asChar(objectIterator->value()), asChar(value)); if (stringToNode(objectIterator->key().c_str()) == F_NoNode) // if key not a node // if (objectIterator->value().size() == 1) { - DEBUG_ARTI("%s node to shrink %s in %s : %s from %s\n", spaces+50-depth, objectIterator->key().c_str(), key, value.as().c_str(), parseTree.as().c_str()); - // DEBUG_ARTI("%s node to shrink %s in %s = %s from %s\n", spaces+50-depth, objectIterator->key().c_str(), key, objectIterator->value().as().c_str(), parseTree[key].as().c_str()); + DEBUG_ARTI("%s node to shrink %s in %s : %s from %s\n", spaces+50-depth, objectIterator->key().c_str(), key, asChar(value), asChar(parseTree)); + // DEBUG_ARTI("%s node to shrink %s in %s = %s from %s\n", spaces+50-depth, objectIterator->key().c_str(), key, asChar(objectIterator->value()), asChar(parseTree[key])); parseTree[key] = objectIterator->value(); // parseTree[key]["old"] = objectIterator->key(); @@ -1730,7 +1744,7 @@ public: visitedAlready = true; } else - ERROR_ARTI("%s Programming Error: key no node and no token %s %s (%u)\n", spaces+50-depth, key, value.as().c_str(), depth); + ERROR_ARTI("%s Programming Error: key no node and no token %s %s (%u)\n", spaces+50-depth, key, asChar(value), depth); if (!visitedAlready && value.size() > 0) // if size == 0 then injected key/value like operator optimize(value, depth + 1); @@ -1747,27 +1761,27 @@ public: { JsonObject::iterator objectIterator = value.as().begin(); - // DEBUG_ARTI("%s try replace %s by %s %s\n", spaces+50-depth, key, objectIterator->key().c_str(), parseTree.as().c_str()); + // DEBUG_ARTI("%s try replace %s by %s %s\n", spaces+50-depth, key, objectIterator->key().c_str(), asChar(parseTree)); if (strcmp(objectIterator->key().c_str(), "ID") != 0) //&& definitionJson.containsKey(objectIterator->key())??? { - // DEBUG_ARTI("%s found %s:%s\n", spaces+50-depth, node_name, parseTree.as().c_str()); - // DEBUG_ARTI("%s found replace %s by %s %s\n", spaces+50-depth, key, objectIterator->key().c_str(), parseTree.as().c_str()); - // DEBUG_ARTI("%s found %s\n", spaces+50-depth, value.as().c_str()); + // DEBUG_ARTI("%s found %s:%s\n", spaces+50-depth, node_name, asChar(parseTree)); + // DEBUG_ARTI("%s found replace %s by %s %s\n", spaces+50-depth, key, objectIterator->key().c_str(), asChar(parseTree)); + // DEBUG_ARTI("%s found %s\n", spaces+50-depth, asChar(value)); - // DEBUG_ARTI("%s found %s\n", spaces+50-depth, parseTree.as().c_str()); - DEBUG_ARTI("%s replace %s by %s %s\n", spaces+50-depth, key, objectIterator->key().c_str(), parseTree.as().c_str()); + // DEBUG_ARTI("%s found %s\n", spaces+50-depth, asChar(parseTree)); + DEBUG_ARTI("%s replace %s by %s %s\n", spaces+50-depth, key, objectIterator->key().c_str(), asChar(parseTree)); parseTree.remove(key); // parseTree[key] = value; parseTree[objectIterator->key()] = objectIterator->value(); - // DEBUG_ARTI("%s found %s:%s\n", spaces+50-depth, node_name, parseTree.as().c_str()); + // DEBUG_ARTI("%s found %s:%s\n", spaces+50-depth, node_name, asChar(parseTree)); } // else // { - // DEBUG_ARTI("%s not shrinkable %s %s\n", spaces+50-depth, key, value.as().c_str()); + // DEBUG_ARTI("%s not shrinkable %s %s\n", spaces+50-depth, key, asChar(value)); // if (depth > 12) { // // parseTree.remove(key); // char temp[charLength]; @@ -1783,8 +1797,8 @@ public: if (stringToNode(objectIterator->key().c_str()) == F_NoNode) // if key not a node // if (objectIterator->value().size() == 1) { - DEBUG_ARTI("%s node to shrink %s in %s : %s from %s\n", spaces+50-depth, objectIterator->key().c_str(), key, value.as().c_str(), parseTree.as().c_str()); - // DEBUG_ARTI("%s node to shrink %s in %s = %s from %s\n", spaces+50-depth, objectIterator->key().c_str(), key, objectIterator->value().as().c_str(), parseTree[key].as().c_str()); + DEBUG_ARTI("%s node to shrink %s in %s : %s from %s\n", spaces+50-depth, objectIterator->key().c_str(), key, asChar(value), asChar(parseTree)); + // DEBUG_ARTI("%s node to shrink %s in %s = %s from %s\n", spaces+50-depth, objectIterator->key().c_str(), key, asChar(objectIterator->value()), asChar(parseTree[key])); parseTree[key] = objectIterator->value(); // parseTree[key]["old"] = objectIterator->key(); @@ -1829,10 +1843,10 @@ public: { // string element = parseTree; //for some weird reason this causes a crash on esp32 - ERROR_ARTI("%s Error: parseTree should be array or object %s (%u)\n", spaces+50-depth, parseTree.as().c_str(), depth); + ERROR_ARTI("%s Error: parseTree should be array or object %s (%u)\n", spaces+50-depth, asChar(parseTree), depth); } - // DEBUG_ARTI("%s optimized %s (%u)\n", spaces+50-depth, parseTree.as().c_str(), depth); + // DEBUG_ARTI("%s optimized %s (%u)\n", spaces+50-depth, asChar(parseTree), depth); return !errorOccurred; } //optimize @@ -1841,11 +1855,11 @@ public: bool interpret(JsonVariant parseTree, const char * treeElement = nullptr, ScopedSymbolTable* current_scope = nullptr, uint8_t depth = 0) { - // RUNLOG_ARTI("%s Interpret %s %s (%u)\n", spaces+50-depth, stringOrEmpty(treeElement), parseTree.as().c_str(), depth); + // RUNLOG_ARTI("%s Interpret %s %s (%u)\n", spaces+50-depth, stringOrEmpty(treeElement), asChar(parseTree), depth); if (depth >= 50) { - ERROR_ARTI("Error: Interpret recursion level too deep at %s (%u)\n", parseTree.as().c_str(), depth); + ERROR_ARTI("Error: Interpret recursion level too deep at %s (%u)\n", asChar(parseTree), depth); errorOccurred = true; } if (errorOccurred) return false; @@ -1858,7 +1872,7 @@ public: JsonVariant value = parseTreePair.value(); if (treeElement == nullptr || strcmp(treeElement, key) == 0) { - // RUNLOG_ARTI("%s Interpret object element %s %s\n", spaces+50-depth, key, value.as().c_str()); + // RUNLOG_ARTI("%s Interpret object element %s %s\n", spaces+50-depth, key, asChar(value)); bool visitedAlready = false; @@ -1870,7 +1884,7 @@ public: visitedAlready = true; else if (parseTree.containsKey("token")) //key is token { - // RUNLOG_ARTI("%s Token %s %s %s\n", spaces+50-depth, key, valueStr, parseTree.as().c_str()); + // RUNLOG_ARTI("%s Token %s %s %s\n", spaces+50-depth, key, valueStr, asChar(parseTree)); const char * valueStr = value; @@ -2183,7 +2197,7 @@ public: { uint8_t oldIndex = valueStack->stack_index; - // RUNLOG_ARTI("%s before expr term interpret %s %s\n", spaces+50-depth, key, value.as().c_str()); + // RUNLOG_ARTI("%s before expr term interpret %s %s\n", spaces+50-depth, key, asChar(value)); interpret(value, nullptr, current_scope, depth + 1); //pushes results // RUNLOG_ARTI("%s %s interpret > (%u - %u = %u)\n", spaces+50-depth, key, valueStack->stack_index, oldIndex, valueStack->stack_index - oldIndex); @@ -2414,7 +2428,7 @@ public: } } else { //not array - ERROR_ARTI("%s Error: parseTree should be array or object %s (%u)\n", spaces+50-depth, parseTree.as().c_str(), depth); + ERROR_ARTI("%s Error: parseTree should be array or object %s (%u)\n", spaces+50-depth, asChar(parseTree), depth); } return !errorOccurred; diff --git a/usermods/artifx/arti_wled.h b/usermods/artifx/arti_wled.h index dd85931b..f905f743 100644 --- a/usermods/artifx/arti_wled.h +++ b/usermods/artifx/arti_wled.h @@ -15,7 +15,8 @@ #define ARTI_ARDUINO 1 #define ARTI_EMBEDDED 2 -#ifdef ESP32 //ESP32 is set in wled context: small trick to set WLED context +// #ifdef ESP32 //ESP32 is set in wled context: small trick to set WLED context +#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266) //ESP32 is set in wled context: small trick to set WLED context #define ARTI_PLATFORM ARTI_ARDUINO // else on Windows/Linux/Mac... #endif @@ -88,7 +89,8 @@ enum Externals F_print, F_jsonToPixels, //reorder only when creating new wledvxyz.json - F_frameTime + F_frameTime, + F_soundPressure }; #if ARTI_PLATFORM != ARTI_ARDUINO @@ -380,15 +382,17 @@ float ARTI::arti_get_external_variable(uint8_t variable, float par1, float par2, case F_custom3Slider: return SEGMENT.custom3; case F_volume: + case F_soundPressure: { um_data_t *um_data; if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) { // add support for no audio um_data = simulateSound(SEGMENT.soundSim); } - float volumeSmth = *(float*) um_data->u_data[0]; - - return volumeSmth; + if (variable == F_volume) + return *(float*) um_data->u_data[0]; //volumeSmth + else + return *(float*) um_data->u_data[9]; //soundPressure } case F_hour: return ((float)hour(localTime)); @@ -431,6 +435,8 @@ float ARTI::arti_get_external_variable(uint8_t variable, float par1, float par2, return F_custom3Slider; case F_volume: return F_volume; + case F_soundPressure: + return F_soundPressure; case F_hour: return F_hour; @@ -449,7 +455,7 @@ float ARTI::arti_get_external_variable(uint8_t variable, float par1, float par2, void ARTI::arti_set_external_variable(float value, uint8_t variable, float par1, float par2, float par3) { #if ARTI_PLATFORM == ARTI_ARDUINO - // MEMORY_ARTI("%s %s %u %u (%u)\n", spaces+50-depth, variable_name, par1, par2, esp_get_free_heap_size()); + // MEMORY_ARTI("%s %s %u %u (%u)\n", spaces+50-depth, variable_name, par1, par2, FREE_SIZE); switch (variable) { case F_leds: diff --git a/usermods/artifx/usermod_v2_artifx.h b/usermods/artifx/usermod_v2_artifx.h index 9a6fe443..23229512 100644 --- a/usermods/artifx/usermod_v2_artifx.h +++ b/usermods/artifx/usermod_v2_artifx.h @@ -60,9 +60,9 @@ uint16_t mode_ARTIFX(void) { { if (succesful) // && SEGENV.call < 250 for each frame { - if (esp_get_free_heap_size() <= 20000) + if (FREE_SIZE <= 20000) { - ERROR_ARTI("Not enough free heap (%u <= 30000)\n", esp_get_free_heap_size()); + ERROR_ARTI("Not enough free heap (%u <= 30000)\n", FREE_SIZE); notEnoughHeap = true; succesful = false; } @@ -72,7 +72,7 @@ uint16_t mode_ARTIFX(void) { // static int previousCall; // if (millis() - previousMillis > 5000) { //tried SEGENV.aux0 but that looks to be overwritten!!! (dangling pointer???) // previousMillis = millis(); - // MEMORY_ARTI("Heap renderFrame %u %u fps\n", esp_get_free_heap_size(), (SEGENV.call - previousCall)/5); + // MEMORY_ARTI("Heap renderFrame %u %u fps\n", FREE_SIZE, (SEGENV.call - previousCall)/5); // previousCall = SEGENV.call; // } @@ -82,8 +82,8 @@ uint16_t mode_ARTIFX(void) { else { arti->closeLog(); - if (notEnoughHeap && esp_get_free_heap_size() > 20000) { - ERROR_ARTI("Again enough free heap, restart effect (%u > 30000)\n", esp_get_free_heap_size()); + if (notEnoughHeap && FREE_SIZE > 20000) { + ERROR_ARTI("Again enough free heap, restart effect (%u > 30000)\n", FREE_SIZE); succesful = true; notEnoughHeap = false; strcpy(previousEffect, ""); // force new create diff --git a/usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.h b/usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.h index ff60a4d4..85862888 100644 --- a/usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.h +++ b/usermods/usermod_v2_four_line_display_ALT/usermod_v2_four_line_display_ALT.h @@ -1419,7 +1419,7 @@ class FourLineDisplayUsermod : public Usermod { if (pinsChanged || type!=newType) { if (typeOK) { typeOK = false; - if (u8x8 != nullptr) delete u8x8; + if (u8x8 != nullptr) delete u8x8; //WLEDMM warning: deleting object of polymorphic class type 'U8X8' which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor] u8x8 = nullptr; USER_PRINTLN(F("Display terminated.")); } diff --git a/wled00/FX.cpp b/wled00/FX.cpp index df71a056..e873b5f7 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -6310,7 +6310,7 @@ uint16_t mode_gravimeter(void) { // Gravmeter. By Andrew Tuline. um_data = simulateSound(SEGMENT.soundSim); } float volumeSmth = *(float*) um_data->u_data[0]; - int16_t volumeRaw = *(int16_t*)um_data->u_data[1]; + // int16_t volumeRaw = *(int16_t*)um_data->u_data[1]; //WLEDMM: this variable not used here float soundPressure = *(float*) um_data->u_data[9]; float agcSensitivity= *(float*) um_data->u_data[10]; #ifdef SR_DEBUG diff --git a/wled00/FX_2Dfcn.cpp b/wled00/FX_2Dfcn.cpp index f1003e45..45eb6ac1 100644 --- a/wled00/FX_2Dfcn.cpp +++ b/wled00/FX_2Dfcn.cpp @@ -583,7 +583,6 @@ bool Segment::jsonToPixels(char * name, uint8_t fileNr) { } } } - USER_PRINTLN(); releaseJSONBufferLock(); return true; diff --git a/wled00/wled.h b/wled00/wled.h index 256d0ecd..076ab6bd 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2304061 +#define VERSION 2304070 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG