Tune log string stack usage

This commit is contained in:
Theo Arends 2021-01-02 12:23:30 +01:00
parent 6eb25a3dba
commit 78ce7b142d
3 changed files with 27 additions and 31 deletions

View File

@ -880,7 +880,7 @@ void HandleTimerConfiguration(void)
void TimerSaveSettings(void) void TimerSaveSettings(void)
{ {
char tmp[MAX_TIMERS *12]; // Need space for MAX_TIMERS x 10 digit numbers separated by a comma char tmp[MAX_TIMERS *12]; // Need space for MAX_TIMERS x 10 digit numbers separated by a comma
char message[LOGSZ]; char message[32 + (MAX_TIMERS *11)]; // MQT: Timers 0,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000
Timer timer; Timer timer;
Settings.flag3.timers_enable = Webserver->hasArg("e0"); // CMND_TIMERS Settings.flag3.timers_enable = Webserver->hasArg("e0"); // CMND_TIMERS

View File

@ -258,7 +258,7 @@ void DebugRtcDump(char* parms)
maxrow = srow + mrow; maxrow = srow + mrow;
} }
char log_data[LOGSZ]; char log_data[100]; // 020: C7 2B 2E AB 70 E8 09 AE C8 88 3D EA 7C FF 48 2F | +. p = | H/|
for (row = srow; row < maxrow; row++) { for (row = srow; row < maxrow; row++) {
idx = row * CFG_COLS; idx = row * CFG_COLS;
snprintf_P(log_data, sizeof(log_data), PSTR("%03X:"), idx); snprintf_P(log_data, sizeof(log_data), PSTR("%03X:"), idx);
@ -310,7 +310,7 @@ void DebugDump(uint32_t start, uint32_t size) {
maxrow = srow + mrow; maxrow = srow + mrow;
} }
char log_data[LOGSZ]; char log_data[150]; // 020: C7 2B 2E AB 70 E8 09 AE C8 88 3D EA 7C FF 48 2F 0E A7 D7 BF 02 0E D7 7D C9 6F B9 3A 1D 01 3F 28 | +. p = | H/ } o : ?(|
for (row = srow; row < maxrow; row++) { for (row = srow; row < maxrow; row++) {
idx = row * CFG_COLS; idx = row * CFG_COLS;
snprintf_P(log_data, sizeof(log_data), PSTR("%03X:"), idx); snprintf_P(log_data, sizeof(log_data), PSTR("%03X:"), idx);
@ -361,7 +361,7 @@ void DebugCfgDump(char* parms)
maxrow = srow + mrow; maxrow = srow + mrow;
} }
char log_data[LOGSZ]; char log_data[100]; // 020: 6D 75 73 31 3A 38 30 2F 61 70 69 2F 61 72 64 75 |mus1:80/api/ardu|
for (row = srow; row < maxrow; row++) { for (row = srow; row < maxrow; row++) {
idx = row * CFG_COLS; idx = row * CFG_COLS;
snprintf_P(log_data, sizeof(log_data), PSTR("%03X:"), idx); snprintf_P(log_data, sizeof(log_data), PSTR("%03X:"), idx);
@ -397,7 +397,7 @@ void DebugCfgPeek(char* parms)
uint16_t data16 = (buffer[address +1] << 8) + buffer[address]; uint16_t data16 = (buffer[address +1] << 8) + buffer[address];
uint32_t data32 = (buffer[address +3] << 24) + (buffer[address +2] << 16) + data16; uint32_t data32 = (buffer[address +3] << 24) + (buffer[address +2] << 16) + data16;
char log_data[LOGSZ]; char log_data[100]; // 000: 09 12 00 10 | | 0x09 (9), 0x1209 (4617), 0x10001209 (268440073)
snprintf_P(log_data, sizeof(log_data), PSTR("%03X:"), address); snprintf_P(log_data, sizeof(log_data), PSTR("%03X:"), address);
for (uint32_t i = 0; i < 4; i++) { for (uint32_t i = 0; i < 4; i++) {
snprintf_P(log_data, sizeof(log_data), PSTR("%s %02X"), log_data, buffer[address +i]); snprintf_P(log_data, sizeof(log_data), PSTR("%s %02X"), log_data, buffer[address +i]);

View File

@ -238,7 +238,6 @@ void MGC3130_sendMessage(uint8_t data[], uint8_t length){
void MGC3130_handleGesture(){ void MGC3130_handleGesture(){
//char log[LOGSZ];
char edge[5]; char edge[5];
if (MGC_data.out.gestureInfo.edgeFlick){ if (MGC_data.out.gestureInfo.edgeFlick){
snprintf_P(edge, sizeof(edge), PSTR("ED_")); snprintf_P(edge, sizeof(edge), PSTR("ED_"));
@ -248,141 +247,138 @@ void MGC3130_handleGesture(){
} }
switch(MGC_data.out.gestureInfo.gestureCode){ switch(MGC_data.out.gestureInfo.gestureCode){
case MGC3130_GESTURE_GARBAGE: case MGC3130_GESTURE_GARBAGE:
//snprintf_P(log, sizeof(log), PSTR("NONE")); //AddLog_P(LOG_LEVEL_DEBUG, PSTR("NONE"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("NONE")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("NONE"));
break; break;
case MGC3130_FLICK_WEST_EAST: case MGC3130_FLICK_WEST_EAST:
//snprintf_P(log, sizeof(log), PSTR("%sFL_WE"), edge); //AddLog_P(LOG_LEVEL_DEBUG, PSTR("%sFL_WE"), edge);
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("%sFL_WE"), edge); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("%sFL_WE"), edge);
break; break;
case MGC3130_FLICK_EAST_WEST: case MGC3130_FLICK_EAST_WEST:
//snprintf_P(log, sizeof(log), PSTR("%sFL_EW"), edge); //AddLog_P(LOG_LEVEL_DEBUG, PSTR("%sFL_EW"), edge);
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("%sFL_EW"), edge); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("%sFL_EW"), edge);
break; break;
case MGC3130_FLICK_SOUTH_NORTH: case MGC3130_FLICK_SOUTH_NORTH:
//snprintf_P(log, sizeof(log), PSTR("%sFL_SN"), edge); //AddLog_P(LOG_LEVEL_DEBUG, PSTR("%sFL_SN"), edge);
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("%sFL_SN"), edge); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("%sFL_SN"), edge);
break; break;
case MGC3130_FLICK_NORTH_SOUTH: case MGC3130_FLICK_NORTH_SOUTH:
//snprintf_P(log, sizeof(log), PSTR("%sFL_NS"), edge); //AddLog_P(LOG_LEVEL_DEBUG, PSTR("%sFL_NS"), edge);
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("%sFL_NS"), edge); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("%sFL_NS"), edge);
break; break;
case MGC3130_CIRCLE_CLOCKWISE: case MGC3130_CIRCLE_CLOCKWISE:
//snprintf_P(log, sizeof(log), PSTR("CW")); //AddLog_P(LOG_LEVEL_DEBUG, PSTR("CW"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("CW")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("CW"));
break; break;
case MGC3130_CIRCLE_CCLOCKWISE: case MGC3130_CIRCLE_CCLOCKWISE:
//snprintf_P(log, sizeof(log), PSTR("CCW")); //AddLog_P(LOG_LEVEL_DEBUG, PSTR("CCW"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("CCW")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("CCW"));
break; break;
} }
//AddLog_P(LOG_LEVEL_DEBUG, log);
} }
bool MGC3130_handleTouch(){ bool MGC3130_handleTouch(){
//char log[LOGSZ];
bool success = false; // if we find a touch of higher order, we are done bool success = false; // if we find a touch of higher order, we are done
if (MGC_data.out.touchInfo.doubleTapCentre && !success){ if (MGC_data.out.touchInfo.doubleTapCentre && !success){
//snprintf_P(log, sizeof(log), PSTR("DTAP_CENTRE")); //AddLog_P(LOG_LEVEL_DEBUG, PSTR("DTAP_CENTRE"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_C")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_C"));
MGC3130_touchTimeout = 5; MGC3130_touchTimeout = 5;
success = true; success = true;
MGC3130_touchCounter = 1; MGC3130_touchCounter = 1;
} }
else if (MGC_data.out.touchInfo.doubleTapEast && !success){ else if (MGC_data.out.touchInfo.doubleTapEast && !success){
//snprintf_P(log, sizeof(log), PSTR("DTAP_EAST")); //AddLog_P(LOG_LEVEL_DEBUG, PSTR("DTAP_EAST"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_E")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_E"));
MGC3130_touchTimeout = 5; MGC3130_touchTimeout = 5;
success = true; success = true;
MGC3130_touchCounter = 1; MGC3130_touchCounter = 1;
} }
else if (MGC_data.out.touchInfo.doubleTapNorth && !success){ else if (MGC_data.out.touchInfo.doubleTapNorth && !success){
//snprintf_P(log, sizeof(log), PSTR("DTAP_NORTH")); //AddLog_P(LOG_LEVEL_DEBUG, PSTR("DTAP_NORTH"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_N")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_N"));
MGC3130_touchTimeout = 5; MGC3130_touchTimeout = 5;
success = true; success = true;
MGC3130_touchCounter = 1; MGC3130_touchCounter = 1;
} }
else if (MGC_data.out.touchInfo.doubleTapWest && !success){ else if (MGC_data.out.touchInfo.doubleTapWest && !success){
//snprintf_P(log, sizeof(log), PSTR("DTAP_WEST")); //AddLog_P(LOG_LEVEL_DEBUG, PSTR("DTAP_WEST"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_W")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_W"));
MGC3130_touchTimeout = 5; MGC3130_touchTimeout = 5;
success = true; success = true;
MGC3130_touchCounter = 1; MGC3130_touchCounter = 1;
} }
else if (MGC_data.out.touchInfo.doubleTapSouth && !success){ else if (MGC_data.out.touchInfo.doubleTapSouth && !success){
//snprintf_P(log, sizeof(log), PSTR("DTAP_SOUTH")); //AddLog_P(LOG_LEVEL_DEBUG, PSTR("DTAP_SOUTH"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_S")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_S"));
MGC3130_touchTimeout = 5; MGC3130_touchTimeout = 5;
success = true; success = true;
MGC3130_touchCounter = 1; MGC3130_touchCounter = 1;
} }
if (MGC_data.out.touchInfo.tapCentre && !success){ if (MGC_data.out.touchInfo.tapCentre && !success){
//snprintf_P(log, sizeof(log), PSTR("TAP_CENTRE")); //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TAP_CENTRE"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_C")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_C"));
MGC3130_touchTimeout = 2; MGC3130_touchTimeout = 2;
success = true; success = true;
MGC3130_touchCounter = 1; MGC3130_touchCounter = 1;
} }
else if (MGC_data.out.touchInfo.tapEast && !success){ else if (MGC_data.out.touchInfo.tapEast && !success){
//snprintf_P(log, sizeof(log), PSTR("TAP_EAST")); //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TAP_EAST"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_E")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_E"));
MGC3130_touchTimeout = 2; MGC3130_touchTimeout = 2;
success = true; success = true;
MGC3130_touchCounter = 1; MGC3130_touchCounter = 1;
} }
else if (MGC_data.out.touchInfo.tapNorth && !success){ else if (MGC_data.out.touchInfo.tapNorth && !success){
//snprintf_P(log, sizeof(log), PSTR("TAP_NORTH")); //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TAP_NORTH"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_N")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_N"));
MGC3130_touchTimeout = 2; MGC3130_touchTimeout = 2;
success = true; success = true;
MGC3130_touchCounter = 1; MGC3130_touchCounter = 1;
} }
else if (MGC_data.out.touchInfo.tapWest && !success){ else if (MGC_data.out.touchInfo.tapWest && !success){
//snprintf_P(log, sizeof(log), PSTR("TAP_WEST")); //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TAP_WEST"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_W")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_W"));
MGC3130_touchTimeout = 2; MGC3130_touchTimeout = 2;
success = true; success = true;
MGC3130_touchCounter = 1; MGC3130_touchCounter = 1;
} }
else if (MGC_data.out.touchInfo.tapSouth && !success){ else if (MGC_data.out.touchInfo.tapSouth && !success){
//snprintf_P(log, sizeof(log), PSTR("TAP_SOUTH")); //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TAP_SOUTH"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_S")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_S"));
MGC3130_touchTimeout = 2; MGC3130_touchTimeout = 2;
success = true; success = true;
MGC3130_touchCounter = 1; MGC3130_touchCounter = 1;
} }
else if (MGC_data.out.touchInfo.touchCentre && !success){ else if (MGC_data.out.touchInfo.touchCentre && !success){
//snprintf_P(log, sizeof(log), PSTR("TOUCH_CENTRE")); //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TOUCH_CENTRE"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_C")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_C"));
success = true; success = true;
MGC3130_touchCounter++; // This will reset to 0 after touching for approx. 1h and 50 minutes ;) MGC3130_touchCounter++; // This will reset to 0 after touching for approx. 1h and 50 minutes ;)
} }
else if (MGC_data.out.touchInfo.touchEast && !success){ else if (MGC_data.out.touchInfo.touchEast && !success){
//snprintf_P(log, sizeof(log), PSTR("TOUCH_EAST")); //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TOUCH_EAST"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_E")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_E"));
success = true; success = true;
MGC3130_touchCounter++; MGC3130_touchCounter++;
} }
else if (MGC_data.out.touchInfo.touchNorth && !success){ else if (MGC_data.out.touchInfo.touchNorth && !success){
//snprintf_P(log, sizeof(log), PSTR("TOUCH_NORTH")); //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TOUCH_NORTH"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_N")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_N"));
success = true; success = true;
MGC3130_touchCounter++; MGC3130_touchCounter++;
} }
else if (MGC_data.out.touchInfo.touchWest && !success){ else if (MGC_data.out.touchInfo.touchWest && !success){
//snprintf_P(log, sizeof(log), PSTR("TOUCH_WEST")); //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TOUCH_WEST"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_W")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_W"));
success = true; success = true;
MGC3130_touchCounter++; MGC3130_touchCounter++;
} }
else if (MGC_data.out.touchInfo.touchSouth && !success){ else if (MGC_data.out.touchInfo.touchSouth && !success){
//snprintf_P(log, sizeof(log), PSTR("TOUCH_SOUTH")); //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TOUCH_SOUTH"));
snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_S")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_S"));
success = true; success = true;
MGC3130_touchCounter++; MGC3130_touchCounter++;
} }
//AddLog_P(LOG_LEVEL_DEBUG, log);
return success; return success;
} }