dimming fix, RAM overflow on config save

This commit is contained in:
2022-05-07 00:22:18 +03:00
parent 23cd2a2139
commit 12487b871e
3 changed files with 20 additions and 14 deletions

View File

@@ -358,13 +358,6 @@ int Item::getArg(short n) //Return arg int or first array element if Arg is arra
float Item::getFloatArg(short n) //Return arg float or first array element if Arg is array
{
if (!itemArg) return 0;//-1;
if (!n)
{
if (itemArg->type == aJson_Int) return itemArg->valueint;
else if (itemArg->type == aJson_Float) return itemArg->valuefloat;
else return 0;
}
if ((itemArg->type == aJson_Array) && ( n < aJson.getArraySize(itemArg)))
{
aJsonObject * obj = aJson.getArrayItem(itemArg, n);
@@ -373,7 +366,12 @@ float Item::getFloatArg(short n) //Return arg float or first array element if Ar
return 0;
}
else return 0;//-2;
else if (!n)
{
if (itemArg->type == aJson_Int) return itemArg->valueint;
else if (itemArg->type == aJson_Float) return itemArg->valuefloat;
}
return 0;
}
short Item::getArgCount()
@@ -910,7 +908,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion)
case S_SET:
{
long limit = limitSetValue();
if (limit && suffixCode==S_NOTFOUND) limit = 100;
//if (limit && suffixCode==S_NOTFOUND) limit = 100;
if (cmd.incrementPercents(step,limit))
{
status2Send |= SEND_PARAMETERS | SEND_DEFFERED;

View File

@@ -1495,14 +1495,17 @@ if (arg_cnt>1)
#endif
#if defined(__SAM3X8E__)
char* outBuf = (char*) malloc(MAX_JSON_CONF_SIZE); /* XXX: Dynamic size. */
if (outBuf == NULL)
long configBufSize = min(MAX_JSON_CONF_SIZE,freeRam()-1024);
debugSerial<<"Allocate "<<configBufSize<<" bytes for buffer"<<endl;
char* outBuf = (char*) malloc(configBufSize); /* XXX: Dynamic size. */
if (!outBuf)
{
sysConfStream.close();
errorSerial<<"Can't allocate RAM"<<endl;
return 500;
}
infoSerial<<F("Saving config to EEPROM..")<<endl;
aJsonStringStream stringStream(NULL, outBuf, MAX_JSON_CONF_SIZE);
aJsonStringStream stringStream(NULL, outBuf, configBufSize);
aJson.print(root, &stringStream);
int len = strlen(outBuf);
outBuf[len++]= EOFchar;

View File

@@ -87,8 +87,13 @@
#define THERMO_OVERHEAT_CELSIUS 38.
#define FM_OVERHEAT_CELSIUS 40.
#define MIN_VOLUME 25
#define INIT_VOLUME 40
#ifndef MIN_VOLUME
#define MIN_VOLUME 20
#endif
#ifndef INIT_VOLUME
#define INIT_VOLUME 30
#endif
/*
#define MAXFLASHSTR 32