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
This commit is contained in:
Ewoud
2023-04-07 12:43:38 +02:00
parent 20a91454d1
commit 4aea3970a3
9 changed files with 97 additions and 77 deletions

View File

@@ -827,6 +827,7 @@ build_flags_M =
-D USERMOD_WEATHER ; WLEDMM usermod -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_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_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 ;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_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 -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_HUESYNC
-D WLED_DISABLE_LOXONE -D WLED_DISABLE_LOXONE
; -D USERMOD_AUDIOREACTIVE ; -D USERMOD_AUDIOREACTIVE
; -D USERMOD_ARTIFX ; to be done
; -UWLED_USE_MY_CONFIG ; -UWLED_USE_MY_CONFIG
-D USERMOD_PIRSWITCH -D USERMOD_PIRSWITCH
-D USERMOD_DALLASTEMPERATURE ;; disabled because it hangs during usermod setup on -S3 (autodetect broken?) -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_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_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_GAMES ; WLEDMM usermod
-D USERMOD_ARTIFX
; -D WLED_DEBUG ; -D WLED_DEBUG
; monitor_filters = esp8266_exception_decoder monitor_filters = esp8266_exception_decoder
lib_deps = ${esp8266.lib_deps} lib_deps = ${esp8266.lib_deps}
OneWire@~2.3.5 ; used for USERMOD_FOUR_LINE_DISPLAY and USERMOD_DALLASTEMPERATURE OneWire@~2.3.5 ; used for USERMOD_FOUR_LINE_DISPLAY and USERMOD_DALLASTEMPERATURE
olikraus/U8g2 @ ^2.28.8 ; used for USERMOD_FOUR_LINE_DISPLAY 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} lib_deps = ${esp8266.lib_deps}
paulstoffregen/OneWire@~2.3.7 ;WLEDMM Softhack, we need this as well (instead of 2.3.5)? paulstoffregen/OneWire@~2.3.7 ;WLEDMM Softhack, we need this as well (instead of 2.3.5)?
olikraus/U8g2 # @~2.33.15 olikraus/U8g2 # @~2.33.15
Wire ; WLEDMM needed? Wire ; WLEDMM ewowi, needed?
[env:esp8266pro_16MB_S] [env:esp8266pro_16MB_S]
extends = env:d1_mini extends = env:d1_mini

View File

@@ -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. * The function should return true if configuration was successfully loaded or false if there was no configuration.
*/ */
bool readFromConfig(JsonObject &root) { 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)]; JsonObject top = root[FPSTR(_name)];
DEBUG_PRINT(FPSTR(_name));
// we look for JSON object: {"Temperature": {"pin": 0, "degC": true}} // we look for JSON object: {"Temperature": {"pin": 0, "degC": true}}
int8_t newTemperaturePin = temperaturePin; int8_t newTemperaturePin = temperaturePin;
DEBUG_PRINT(FPSTR(_name));
if (top.isNull()) { if (top.isNull()) {
DEBUG_PRINTLN(F(": No config found. (Using defaults.)")); DEBUG_PRINTLN(F(": No config found. (Using defaults.)"));

View File

@@ -55,7 +55,14 @@
#define ARTI_PRINT 1 //will show the printf calls #define ARTI_PRINT 1 //will show the printf calls
const char spaces[51] PROGMEM = " "; 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<std::string>().c_str() //WLEDMM: tbd: find out why char * is causing crashes!!!
#else
#define FREE_SIZE ESP.getFreeHeap()
#define asChar(x) ""
//x.as<const char *>() //WLEDMM: no arduinojson output for the moment as this is in testing phase
#endif
// #define OPTIMIZED_TREE 1 // #define OPTIMIZED_TREE 1
#else //embedded #else //embedded
#include "dependencies/ArduinoJson-recent.h" #include "dependencies/ArduinoJson-recent.h"
@@ -75,7 +82,8 @@
#include <sstream> #include <sstream>
const char spaces[51] = " "; 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<const char *>()
// #define OPTIMIZED_TREE 1 // #define OPTIMIZED_TREE 1
#endif #endif
@@ -90,14 +98,20 @@ void artiPrintf(char const * format, ...)
if (!logToFile) 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 else
{ {
#if ARTI_PLATFORM == ARTI_ARDUINO #if ARTI_PLATFORM == ARTI_ARDUINO
// rocket science here! As logfile.printf causes crashes/wrong output we create our own printf here // rocket science here! As logfile.printf causes crashes/wrong output we create our own printf here
// logFile.printf(format, argp); // logFile.printf(format, argp);
for (int i = 0; i < strlen(format); i++) for (size_t i = 0; i < strlen(format); i++)
{ {
if (format[i] == '%') if (format[i] == '%')
{ {
@@ -560,7 +574,7 @@ class Lexer {
{ {
while (strncmp(this->text + this->pos, endTokens, strlen(endTokens)) != 0) while (strncmp(this->text + this->pos, endTokens, strlen(endTokens)) != 0)
this->advance(); this->advance();
for (int i=0; i<strlen(endTokens); i++) for (size_t i=0; i<strlen(endTokens); i++)
this->advance(); this->advance();
} }
@@ -696,7 +710,7 @@ class Lexer {
{ {
strcpy(current_token.type, token_type); strcpy(current_token.type, token_type);
strcpy(current_token.value, token_value); strcpy(current_token.value, token_value);
for (int i=0; i<strlen(token_value); i++) for (size_t i=0; i<strlen(token_value); i++)
this->advance(); this->advance();
return; return;
} }
@@ -1072,12 +1086,12 @@ public:
float arti_get_external_variable(uint8_t variable, float par1 = floatNull, float par2 = floatNull, float par3 = floatNull); 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); void arti_set_external_variable(float value, uint8_t variable, float par1 = floatNull, float par2 = floatNull, float par3 = floatNull);
bool loop(); bool loop();
uint8_t parse(JsonVariant parseTree, const char * node_name, char operatorx, JsonVariant expression, uint8_t depth = 0) uint8_t parse(JsonVariant parseTree, const char * node_name, char operatorx, JsonVariant expression, uint8_t depth = 0)
{ {
if (depth > 50) if (depth > 50)
{ {
ERROR_ARTI("Error: Parse recursion level too deep at %s (%u)\n", parseTree.as<std::string>().c_str(), depth); ERROR_ARTI("Error: Parse recursion level too deep at %s (%u)\n", asChar(parseTree), depth);
errorOccurred = true; errorOccurred = true;
} }
if (errorOccurred) return ResultFail; if (errorOccurred) return ResultFail;
@@ -1101,7 +1115,7 @@ public:
nextNode_name = expressionElement; //e.g. block nextNode_name = expressionElement; //e.g. block
nextExpression = nodeExpression; // e.g. ["LCURL",{"*": ["statement"]},"RCURL"] nextExpression = nodeExpression; // e.g. ["LCURL",{"*": ["statement"]},"RCURL"]
// DEBUG_ARTI("%s %s %u\n", spaces+50-depth, nextNode_name, depth); //, parseTree.as<std::string>().c_str() // DEBUG_ARTI("%s %s %u\n", spaces+50-depth, nextNode_name, depth); //, asChar(parseTree)
if (parseTree.is<JsonArray>()) if (parseTree.is<JsonArray>())
{ {
@@ -1176,7 +1190,7 @@ public:
} }
else else
{ {
ERROR_ARTI("%s Programming error: undefined %c %s\n", spaces+50-depth, objectOperator, objectElement.as<std::string>().c_str()); ERROR_ARTI("%s Programming error: undefined %c %s\n", spaces+50-depth, objectOperator, asChar(objectElement));
resultChild2 = ResultFail; resultChild2 = ResultFail;
} }
counter++; counter++;
@@ -1185,7 +1199,7 @@ public:
} //not or } //not or
} // element is array } // element is array
else else
ERROR_ARTI("%s Definition error: should be an array %s %c %s\n", spaces+50-depth, stringOrEmpty(nextNode_name), operatorx, objectElement.as<std::string>().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<JsonArray>()) // e.g. ["LPAREN", "expr*", "RPAREN"] else if (nextExpression.is<JsonArray>()) // 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 else //expressionElement is not a node, not a token, not an array and not an object
{ {
if (lexer->definitionJson.containsKey(nextExpression.as<const char *>())) if (lexer->definitionJson.containsKey(nextExpression.as<const char *>()))
ERROR_ARTI("%s Programming error: %s not a node, token, array or object in %s\n", spaces+50-depth, nextExpression.as<std::string>().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 else
ERROR_ARTI("%s Definition error: \"%s\": \"%s\" node should be embedded in array\n", spaces+50-depth, stringOrEmpty(nextNode_name), nextExpression.as<std::string>().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 } //nextExpression is not a token
if (!nodeExpression.isNull()) //if node if (!nodeExpression.isNull()) //if node
@@ -1254,7 +1268,7 @@ public:
} }
else //success else //success
{ {
DEBUG_ARTI("%s found %s\n", spaces+50-depth, nextNode_name);//, nextParseTree.as<std::string>().c_str()); DEBUG_ARTI("%s found %s\n", spaces+50-depth, nextNode_name);//, asChar(nextParseTree));
//parseTree optimization moved to optimize function //parseTree optimization moved to optimize function
// if (nextParseTree.is<JsonObject>()) // if (nextParseTree.is<JsonObject>())
@@ -1269,10 +1283,10 @@ public:
// { // {
// // JsonObject nextParseTreeObject = nextParseTree.as<JsonObject>(); // // JsonObject nextParseTreeObject = nextParseTree.as<JsonObject>();
// DEBUG_ARTI("%s found %s:%s\n", spaces+50-depth, node_name, parseTree.as<std::string>().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(), nextParseTree.as<std::string>().c_str()); // 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, expression.as<std::string>().c_str()); // DEBUG_ARTI("%s expression %s\n", spaces+50-depth, asChar(expression));
// DEBUG_ARTI("%s found %s\n", spaces+50-depth, nextParseTree[nextNode_name].as<std::string>().c_str()); // DEBUG_ARTI("%s found %s\n", spaces+50-depth, asChar(nextParseTree[nextNode_name]));
// nextParseTree.remove(nextNode_name); // nextParseTree.remove(nextNode_name);
// // char temp[charLength]; // // char temp[charLength];
@@ -1281,11 +1295,11 @@ public:
// // strcat(temp, begin->key().c_str()); // // strcat(temp, begin->key().c_str());
// nextParseTree[begin->key()] = begin->value(); // nextParseTree[begin->key()] = begin->value();
// DEBUG_ARTI("%s found %s:%s\n", spaces+50-depth, node_name, parseTree.as<std::string>().c_str()); // DEBUG_ARTI("%s found %s:%s\n", spaces+50-depth, node_name, asChar(parseTree));
// } // }
// } // }
// else // else
// DEBUG_ARTI("%s no jsonobject??? %s\n", spaces+50-depth, parseTree.as<std::string>().c_str()); // DEBUG_ARTI("%s no jsonobject??? %s\n", spaces+50-depth, asChar(parseTree));
} }
} // if node } // if node
@@ -1318,7 +1332,7 @@ public:
} }
} }
else { //should never happen else { //should never happen
ERROR_ARTI("%s Programming error: no array %s %c %s\n", spaces+50-depth, stringOrEmpty(node_name), operatorx, expression.as<std::string>().c_str()); ERROR_ARTI("%s Programming error: no array %s %c %s\n", spaces+50-depth, stringOrEmpty(node_name), operatorx, asChar(expression));
} }
return result; return result;
@@ -1327,10 +1341,10 @@ public:
bool analyze(JsonVariant parseTree, const char * treeElement = nullptr, ScopedSymbolTable* current_scope = nullptr, uint8_t depth = 0) 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<std::string>().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) 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<std::string>().c_str(), depth); ERROR_ARTI("Error: Analyze recursion level too deep at %s (%u)\n", asChar(parseTree), depth);
errorOccurred = true; errorOccurred = true;
} }
if (errorOccurred) return false; if (errorOccurred) return false;
@@ -1389,7 +1403,7 @@ public:
else if (strcmp(valueStr, "||") == 0) else if (strcmp(valueStr, "||") == 0)
parseTree["token"] = F_or; parseTree["token"] = F_or;
else else
ERROR_ARTI("%s Programming error: token not defined as operator %s %s (%u)\n", spaces+50-depth, key, value.as<std::string>().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; visitedAlready = true;
} }
@@ -1543,7 +1557,7 @@ public:
{ {
JsonObject asop = value["assignoperator"]; JsonObject asop = value["assignoperator"];
JsonObject::iterator asopBegin = asop.begin(); JsonObject::iterator asopBegin = asop.begin();
ANDBG_ARTI("%s %s\n", spaces+50-depth, asopBegin->value().as<std::string>().c_str()); ANDBG_ARTI("%s %s\n", spaces+50-depth, asChar(asopBegin->value()));
if (strcmp(asopBegin->value(), "+=") == 0) if (strcmp(asopBegin->value(), "+=") == 0)
value["assignoperator"] = F_plus; value["assignoperator"] = F_plus;
else if (strcmp(asopBegin->value(), "-=") == 0) else if (strcmp(asopBegin->value(), "-=") == 0)
@@ -1623,7 +1637,7 @@ public:
{ {
// string element = parseTree; // string element = parseTree;
//for some weird reason this causes a crash on esp32 //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<std::string>().c_str(), depth); // ERROR_ARTI("%s Error: parseTree should be array or object %s (%u)\n", spaces+50-depth, asChar(parseTree), depth);
} }
return !errorOccurred; return !errorOccurred;
@@ -1632,7 +1646,7 @@ public:
//https://dev.to/lefebvre/compilers-106---optimizer--ig8 //https://dev.to/lefebvre/compilers-106---optimizer--ig8
bool optimize(JsonVariant parseTree, uint8_t depth = 0) bool optimize(JsonVariant parseTree, uint8_t depth = 0)
{ {
// DEBUG_ARTI("%s optimize %s (%u)\n", spaces+50-depth, parseTree.as<std::string>().c_str(), depth); // DEBUG_ARTI("%s optimize %s (%u)\n", spaces+50-depth, asChar(parseTree), depth);
if (parseTree.is<JsonObject>()) if (parseTree.is<JsonObject>())
{ {
@@ -1660,7 +1674,7 @@ public:
if (value.size() == 0) if (value.size() == 0)
{ {
parseTree.remove(key); parseTree.remove(key);
// DEBUG_ARTI("%s optimize: remove empty %s %s (%u)\n", spaces+50-depth, key, value.as<std::string>().c_str(), depth); // DEBUG_ARTI("%s optimize: remove empty %s %s (%u)\n", spaces+50-depth, key, asChar(value), depth);
} }
visitedAlready = true; 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) //- 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<std::string>().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<JsonObject>().begin(); JsonObject::iterator objectIterator = value.as<JsonObject>().begin();
@@ -1694,26 +1708,26 @@ public:
// // if (objectIterator2->value().is<JsonObject>() ) //&& objectIterator.size() == 1 // // if (objectIterator2->value().is<JsonObject>() ) //&& objectIterator.size() == 1
// { // {
// DEBUG_ARTI("%s node to shrink %s : %s from %s\n", spaces+50-depth, key, value.as<std::string>().c_str(), parseTree.as<std::string>().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(), objectIterator->value().as<std::string>().c_str()); // 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(), objectIterator2->value().as<std::string>().c_str()); // // 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, parseTree[key].as<std::string>().c_str()); // 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, objectIterator->value().as<std::string>().c_str()); // 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->key().c_str()] = objectIterator2->value();
// parseTree[key] = objectIterator->value(); // parseTree[key] = objectIterator->value();
// } // }
// // else // // else
// // { // // {
// // DEBUG_ARTI("%s node to shrink2 %s : %s\n", spaces+50-depth, objectIterator2->key().c_str(), objectIterator2->value().as<std::string>().c_str()); // // DEBUG_ARTI("%s node to shrink2 %s : %s\n", spaces+50-depth, objectIterator2->key().c_str(), asChar(objectIterator2->value()));
// // } // // }
// } // }
// else // 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<std::string>().c_str(), value.as<std::string>().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 (stringToNode(objectIterator->key().c_str()) == F_NoNode) // if key not a node
// if (objectIterator->value().size() == 1) // 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<std::string>().c_str(), parseTree.as<std::string>().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, objectIterator->value().as<std::string>().c_str(), parseTree[key].as<std::string>().c_str()); // 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] = objectIterator->value();
// parseTree[key]["old"] = objectIterator->key(); // parseTree[key]["old"] = objectIterator->key();
@@ -1730,7 +1744,7 @@ public:
visitedAlready = true; visitedAlready = true;
} }
else else
ERROR_ARTI("%s Programming Error: key no node and no token %s %s (%u)\n", spaces+50-depth, key, value.as<std::string>().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 if (!visitedAlready && value.size() > 0) // if size == 0 then injected key/value like operator
optimize(value, depth + 1); optimize(value, depth + 1);
@@ -1747,27 +1761,27 @@ public:
{ {
JsonObject::iterator objectIterator = value.as<JsonObject>().begin(); JsonObject::iterator objectIterator = value.as<JsonObject>().begin();
// DEBUG_ARTI("%s try replace %s by %s %s\n", spaces+50-depth, key, objectIterator->key().c_str(), parseTree.as<std::string>().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())??? 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<std::string>().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(), parseTree.as<std::string>().c_str()); // 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, value.as<std::string>().c_str()); // DEBUG_ARTI("%s found %s\n", spaces+50-depth, asChar(value));
// DEBUG_ARTI("%s found %s\n", spaces+50-depth, parseTree.as<std::string>().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(), parseTree.as<std::string>().c_str()); DEBUG_ARTI("%s replace %s by %s %s\n", spaces+50-depth, key, objectIterator->key().c_str(), asChar(parseTree));
parseTree.remove(key); parseTree.remove(key);
// parseTree[key] = value; // parseTree[key] = value;
parseTree[objectIterator->key()] = objectIterator->value(); parseTree[objectIterator->key()] = objectIterator->value();
// DEBUG_ARTI("%s found %s:%s\n", spaces+50-depth, node_name, parseTree.as<std::string>().c_str()); // DEBUG_ARTI("%s found %s:%s\n", spaces+50-depth, node_name, asChar(parseTree));
} }
// else // else
// { // {
// DEBUG_ARTI("%s not shrinkable %s %s\n", spaces+50-depth, key, value.as<std::string>().c_str()); // DEBUG_ARTI("%s not shrinkable %s %s\n", spaces+50-depth, key, asChar(value));
// if (depth > 12) { // if (depth > 12) {
// // parseTree.remove(key); // // parseTree.remove(key);
// char temp[charLength]; // char temp[charLength];
@@ -1783,8 +1797,8 @@ public:
if (stringToNode(objectIterator->key().c_str()) == F_NoNode) // if key not a node if (stringToNode(objectIterator->key().c_str()) == F_NoNode) // if key not a node
// if (objectIterator->value().size() == 1) // 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<std::string>().c_str(), parseTree.as<std::string>().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, objectIterator->value().as<std::string>().c_str(), parseTree[key].as<std::string>().c_str()); // 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] = objectIterator->value();
// parseTree[key]["old"] = objectIterator->key(); // parseTree[key]["old"] = objectIterator->key();
@@ -1829,10 +1843,10 @@ public:
{ {
// string element = parseTree; // string element = parseTree;
//for some weird reason this causes a crash on esp32 //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<std::string>().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<std::string>().c_str(), depth); // DEBUG_ARTI("%s optimized %s (%u)\n", spaces+50-depth, asChar(parseTree), depth);
return !errorOccurred; return !errorOccurred;
} //optimize } //optimize
@@ -1841,11 +1855,11 @@ public:
bool interpret(JsonVariant parseTree, const char * treeElement = nullptr, ScopedSymbolTable* current_scope = nullptr, uint8_t depth = 0) 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<std::string>().c_str(), depth); // RUNLOG_ARTI("%s Interpret %s %s (%u)\n", spaces+50-depth, stringOrEmpty(treeElement), asChar(parseTree), depth);
if (depth >= 50) if (depth >= 50)
{ {
ERROR_ARTI("Error: Interpret recursion level too deep at %s (%u)\n", parseTree.as<std::string>().c_str(), depth); ERROR_ARTI("Error: Interpret recursion level too deep at %s (%u)\n", asChar(parseTree), depth);
errorOccurred = true; errorOccurred = true;
} }
if (errorOccurred) return false; if (errorOccurred) return false;
@@ -1858,7 +1872,7 @@ public:
JsonVariant value = parseTreePair.value(); JsonVariant value = parseTreePair.value();
if (treeElement == nullptr || strcmp(treeElement, key) == 0) if (treeElement == nullptr || strcmp(treeElement, key) == 0)
{ {
// RUNLOG_ARTI("%s Interpret object element %s %s\n", spaces+50-depth, key, value.as<std::string>().c_str()); // RUNLOG_ARTI("%s Interpret object element %s %s\n", spaces+50-depth, key, asChar(value));
bool visitedAlready = false; bool visitedAlready = false;
@@ -1870,7 +1884,7 @@ public:
visitedAlready = true; visitedAlready = true;
else if (parseTree.containsKey("token")) //key is token else if (parseTree.containsKey("token")) //key is token
{ {
// RUNLOG_ARTI("%s Token %s %s %s\n", spaces+50-depth, key, valueStr, parseTree.as<std::string>().c_str()); // RUNLOG_ARTI("%s Token %s %s %s\n", spaces+50-depth, key, valueStr, asChar(parseTree));
const char * valueStr = value; const char * valueStr = value;
@@ -2183,7 +2197,7 @@ public:
{ {
uint8_t oldIndex = valueStack->stack_index; uint8_t oldIndex = valueStack->stack_index;
// RUNLOG_ARTI("%s before expr term interpret %s %s\n", spaces+50-depth, key, value.as<std::string>().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 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); // 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 else { //not array
ERROR_ARTI("%s Error: parseTree should be array or object %s (%u)\n", spaces+50-depth, parseTree.as<std::string>().c_str(), depth); ERROR_ARTI("%s Error: parseTree should be array or object %s (%u)\n", spaces+50-depth, asChar(parseTree), depth);
} }
return !errorOccurred; return !errorOccurred;

View File

@@ -15,7 +15,8 @@
#define ARTI_ARDUINO 1 #define ARTI_ARDUINO 1
#define ARTI_EMBEDDED 2 #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... #define ARTI_PLATFORM ARTI_ARDUINO // else on Windows/Linux/Mac...
#endif #endif
@@ -88,7 +89,8 @@ enum Externals
F_print, F_print,
F_jsonToPixels, //reorder only when creating new wledvxyz.json F_jsonToPixels, //reorder only when creating new wledvxyz.json
F_frameTime F_frameTime,
F_soundPressure
}; };
#if ARTI_PLATFORM != ARTI_ARDUINO #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: case F_custom3Slider:
return SEGMENT.custom3; return SEGMENT.custom3;
case F_volume: case F_volume:
case F_soundPressure:
{ {
um_data_t *um_data; um_data_t *um_data;
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) { if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
// add support for no audio // add support for no audio
um_data = simulateSound(SEGMENT.soundSim); um_data = simulateSound(SEGMENT.soundSim);
} }
float volumeSmth = *(float*) um_data->u_data[0]; if (variable == F_volume)
return *(float*) um_data->u_data[0]; //volumeSmth
return volumeSmth; else
return *(float*) um_data->u_data[9]; //soundPressure
} }
case F_hour: case F_hour:
return ((float)hour(localTime)); return ((float)hour(localTime));
@@ -431,6 +435,8 @@ float ARTI::arti_get_external_variable(uint8_t variable, float par1, float par2,
return F_custom3Slider; return F_custom3Slider;
case F_volume: case F_volume:
return F_volume; return F_volume;
case F_soundPressure:
return F_soundPressure;
case F_hour: case F_hour:
return 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) void ARTI::arti_set_external_variable(float value, uint8_t variable, float par1, float par2, float par3)
{ {
#if ARTI_PLATFORM == ARTI_ARDUINO #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) switch (variable)
{ {
case F_leds: case F_leds:

View File

@@ -60,9 +60,9 @@ uint16_t mode_ARTIFX(void) {
{ {
if (succesful) // && SEGENV.call < 250 for each frame 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; notEnoughHeap = true;
succesful = false; succesful = false;
} }
@@ -72,7 +72,7 @@ uint16_t mode_ARTIFX(void) {
// static int previousCall; // static int previousCall;
// if (millis() - previousMillis > 5000) { //tried SEGENV.aux0 but that looks to be overwritten!!! (dangling pointer???) // if (millis() - previousMillis > 5000) { //tried SEGENV.aux0 but that looks to be overwritten!!! (dangling pointer???)
// previousMillis = millis(); // 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; // previousCall = SEGENV.call;
// } // }
@@ -82,8 +82,8 @@ uint16_t mode_ARTIFX(void) {
else else
{ {
arti->closeLog(); arti->closeLog();
if (notEnoughHeap && esp_get_free_heap_size() > 20000) { if (notEnoughHeap && FREE_SIZE > 20000) {
ERROR_ARTI("Again enough free heap, restart effect (%u > 30000)\n", esp_get_free_heap_size()); ERROR_ARTI("Again enough free heap, restart effect (%u > 30000)\n", FREE_SIZE);
succesful = true; succesful = true;
notEnoughHeap = false; notEnoughHeap = false;
strcpy(previousEffect, ""); // force new create strcpy(previousEffect, ""); // force new create

View File

@@ -1419,7 +1419,7 @@ class FourLineDisplayUsermod : public Usermod {
if (pinsChanged || type!=newType) { if (pinsChanged || type!=newType) {
if (typeOK) { if (typeOK) {
typeOK = false; 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; u8x8 = nullptr;
USER_PRINTLN(F("Display terminated.")); USER_PRINTLN(F("Display terminated."));
} }

View File

@@ -6310,7 +6310,7 @@ uint16_t mode_gravimeter(void) { // Gravmeter. By Andrew Tuline.
um_data = simulateSound(SEGMENT.soundSim); um_data = simulateSound(SEGMENT.soundSim);
} }
float volumeSmth = *(float*) um_data->u_data[0]; 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 soundPressure = *(float*) um_data->u_data[9];
float agcSensitivity= *(float*) um_data->u_data[10]; float agcSensitivity= *(float*) um_data->u_data[10];
#ifdef SR_DEBUG #ifdef SR_DEBUG

View File

@@ -583,7 +583,6 @@ bool Segment::jsonToPixels(char * name, uint8_t fileNr) {
} }
} }
} }
USER_PRINTLN();
releaseJSONBufferLock(); releaseJSONBufferLock();
return true; return true;

View File

@@ -8,7 +8,7 @@
*/ */
// version code in format yymmddb (b = daily build) // 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 //uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG //#define WLED_USE_MY_CONFIG