Merge pull request #10534 from s-hadinger/more_pmem

Moving more to PROGMEM
This commit is contained in:
Theo Arends 2021-01-12 20:17:37 +01:00 committed by GitHub
commit 331c1089c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 52 additions and 52 deletions

View File

@ -121,26 +121,26 @@ uint32_t stack_thunk_light_get_max_usage()
}
/* Print the stack from the first used 16-byte chunk to the top, decodable by the exception decoder */
void stack_thunk_light_dump_stack()
{
uint32_t *pos = stack_thunk_light_top;
while (pos < stack_thunk_light_ptr) {
if ((pos[0] != _stackPaint) || (pos[1] != _stackPaint) || (pos[2] != _stackPaint) || (pos[3] != _stackPaint))
break;
pos += 4;
}
ets_printf(">>>stack>>>\n");
while (pos < stack_thunk_light_ptr) {
ets_printf("%08x: %08x %08x %08x %08x\n", (int32_t)pos, pos[0], pos[1], pos[2], pos[3]);
pos += 4;
}
ets_printf("<<<stack<<<\n");
}
// void stack_thunk_light_dump_stack()
// {
// uint32_t *pos = stack_thunk_light_top;
// while (pos < stack_thunk_light_ptr) {
// if ((pos[0] != _stackPaint) || (pos[1] != _stackPaint) || (pos[2] != _stackPaint) || (pos[3] != _stackPaint))
// break;
// pos += 4;
// }
// ets_printf(">>>stack>>>\n");
// while (pos < stack_thunk_light_ptr) {
// ets_printf("%08x: %08x %08x %08x %08x\n", (int32_t)pos, pos[0], pos[1], pos[2], pos[3]);
// pos += 4;
// }
// ets_printf("<<<stack<<<\n");
// }
/* Called when the stack overflow is detected by a thunk. Main memory is corrupted at this point. Do not return. */
void stack_thunk_light_fatal_overflow()
{
ets_printf("FATAL ERROR: BSSL stack overflow\n");
// ets_printf("FATAL ERROR: BSSL stack overflow\n");
abort();
}

View File

@ -727,12 +727,12 @@ void CmndRestart(void)
switch (XdrvMailbox.payload) {
case 1:
TasmotaGlobal.restart_flag = 2;
ResponseCmndChar(D_JSON_RESTARTING);
ResponseCmndChar(PSTR(D_JSON_RESTARTING));
break;
case 2:
TasmotaGlobal.restart_flag = 2;
TasmotaGlobal.restart_halt = true;
ResponseCmndChar(D_JSON_HALTING);
ResponseCmndChar(PSTR(D_JSON_HALTING));
break;
case -1:
CmndCrash(); // force a crash
@ -1208,7 +1208,7 @@ void CmndGpio(void)
if (jsflg2) {
ResponseClear();
} else {
ResponseCmndChar(D_JSON_NOT_SUPPORTED);
ResponseCmndChar(PSTR(D_JSON_NOT_SUPPORTED));
}
}
}

View File

@ -1169,7 +1169,7 @@ void Every250mSeconds(void)
}
TasmotaGlobal.restart_flag--;
if (TasmotaGlobal.restart_flag <= 0) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "%s"), (TasmotaGlobal.restart_halt) ? "Halted" : D_RESTARTING);
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "%s"), (TasmotaGlobal.restart_halt) ? PSTR("Halted") : PSTR(D_RESTARTING));
EspRestart();
}
}

View File

@ -475,14 +475,14 @@ void StartWebserver(int type, IPAddress ipweb)
String ipv6_addr = WifiGetIPv6();
if (ipv6_addr!="") {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP D_WEBSERVER_ACTIVE_ON " %s%s " D_WITH_IP_ADDRESS " %s and IPv6 global address %s "),
NetworkHostname(), (Mdns.begun) ? ".local" : "", ipweb.toString().c_str(), ipv6_addr.c_str());
NetworkHostname(), (Mdns.begun) ? PSTR(".local") : "", ipweb.toString().c_str(), ipv6_addr.c_str());
} else {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP D_WEBSERVER_ACTIVE_ON " %s%s " D_WITH_IP_ADDRESS " %s"),
NetworkHostname(), (Mdns.begun) ? ".local" : "", ipweb.toString().c_str());
NetworkHostname(), (Mdns.begun) ? PSTR(".local") : "", ipweb.toString().c_str());
}
#else
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP D_WEBSERVER_ACTIVE_ON " %s%s " D_WITH_IP_ADDRESS " %s"),
NetworkHostname(), (Mdns.begun) ? ".local" : "", ipweb.toString().c_str());
NetworkHostname(), (Mdns.begun) ? PSTR(".local") : "", ipweb.toString().c_str());
#endif // LWIP_IPV6 = 1
TasmotaGlobal.rules_flag.http_init = 1;
}
@ -744,7 +744,7 @@ void WSContentSendStyle_P(const char* formatP, ...)
bool sip = (static_cast<uint32_t>(WiFi.softAPIP()) != 0);
WSContentSend_P(PSTR("<h4>%s%s (%s%s%s)</h4>"), // tasmota.local (192.168.2.12, 192.168.4.1)
NetworkHostname(),
(Mdns.begun) ? ".local" : "",
(Mdns.begun) ? PSTR(".local") : "",
(lip) ? WiFi.localIP().toString().c_str() : "",
(lip && sip) ? ", " : "",
(sip) ? WiFi.softAPIP().toString().c_str() : "");
@ -1230,15 +1230,15 @@ bool HandleRootStatusRefresh(void)
uint32_t fsize = (TasmotaGlobal.devices_present < 5) ? 70 - (TasmotaGlobal.devices_present * 8) : 32;
#ifdef USE_SONOFF_IFAN
if (IsModuleIfan()) {
WSContentSend_P(HTTP_DEVICE_STATE, 36, (bitRead(TasmotaGlobal.power, 0)) ? "bold" : "normal", 54, GetStateText(bitRead(TasmotaGlobal.power, 0)));
WSContentSend_P(HTTP_DEVICE_STATE, 36, (bitRead(TasmotaGlobal.power, 0)) ? PSTR("bold") : PSTR("normal"), 54, GetStateText(bitRead(TasmotaGlobal.power, 0)));
uint32_t fanspeed = GetFanspeed();
snprintf_P(svalue, sizeof(svalue), PSTR("%d"), fanspeed);
WSContentSend_P(HTTP_DEVICE_STATE, 64, (fanspeed) ? "bold" : "normal", 54, (fanspeed) ? svalue : GetStateText(0));
WSContentSend_P(HTTP_DEVICE_STATE, 64, (fanspeed) ? PSTR("bold") : PSTR("normal"), 54, (fanspeed) ? svalue : GetStateText(0));
} else {
#endif // USE_SONOFF_IFAN
for (uint32_t idx = 1; idx <= TasmotaGlobal.devices_present; idx++) {
snprintf_P(svalue, sizeof(svalue), PSTR("%d"), bitRead(TasmotaGlobal.power, idx -1));
WSContentSend_P(HTTP_DEVICE_STATE, 100 / TasmotaGlobal.devices_present, (bitRead(TasmotaGlobal.power, idx -1)) ? "bold" : "normal", fsize, (TasmotaGlobal.devices_present < 5) ? GetStateText(bitRead(TasmotaGlobal.power, idx -1)) : svalue);
WSContentSend_P(HTTP_DEVICE_STATE, 100 / TasmotaGlobal.devices_present, (bitRead(TasmotaGlobal.power, idx -1)) ? PSTR("bold") : PSTR("normal"), fsize, (TasmotaGlobal.devices_present < 5) ? GetStateText(bitRead(TasmotaGlobal.power, idx -1)) : svalue);
}
#ifdef USE_SONOFF_IFAN
}
@ -1438,7 +1438,7 @@ void HandleTemplateConfiguration(void)
for (uint32_t i = 0; i < MAX_GPIO_PIN; i++) {
if (!FlashPin(i)) {
WSContentSend_P(PSTR("<tr><td><b><font color='#%06x'>" D_GPIO "%d</font></b></td><td%s><select id='g%d' onchange='ot(%d,this.value)'></select></td>"),
((9==i)||(10==i)) ? WebColor(COL_TEXT_WARNING) : WebColor(COL_TEXT), i, (0==i) ? " style='width:150px'" : "", i, i);
((9==i)||(10==i)) ? WebColor(COL_TEXT_WARNING) : WebColor(COL_TEXT), i, (0==i) ? PSTR(" style='width:150px'") : "", i, i);
WSContentSend_P(PSTR("<td style='width:50px'><select id='h%d'></select></td></tr>"), i);
}
}
@ -1824,7 +1824,7 @@ void HandleLoggingConfiguration(void)
idx);
for (uint32_t i = LOG_LEVEL_NONE; i <= LOG_LEVEL_DEBUG_MORE; i++) {
WSContentSend_P(PSTR("<option%s value='%d'>%d %s</option>"),
(i == llevel) ? " selected" : "", i, i,
(i == llevel) ? PSTR(" selected") : "", i, i,
GetTextIndexed(stemp1, sizeof(stemp1), i, kLoggingLevels));
}
WSContentSend_P(PSTR("</select></p>"));
@ -1880,8 +1880,8 @@ void HandleOtherConfiguration(void)
TemplateJson();
char stemp[strlen(TasmotaGlobal.mqtt_data) +1];
strlcpy(stemp, TasmotaGlobal.mqtt_data, sizeof(stemp)); // Get JSON template
WSContentSend_P(HTTP_FORM_OTHER, stemp, (USER_MODULE == Settings.module) ? " checked disabled" : "",
(Settings.flag.mqtt_enabled) ? " checked" : "", // SetOption3 - Enable MQTT
WSContentSend_P(HTTP_FORM_OTHER, stemp, (USER_MODULE == Settings.module) ? PSTR(" checked disabled") : "",
(Settings.flag.mqtt_enabled) ? PSTR(" checked") : "", // SetOption3 - Enable MQTT
SettingsText(SET_FRIENDLYNAME1), SettingsText(SET_DEVICENAME));
uint32_t maxfn = (TasmotaGlobal.devices_present > MAX_FRIENDLYNAMES) ? MAX_FRIENDLYNAMES : (!TasmotaGlobal.devices_present) ? 1 : TasmotaGlobal.devices_present;
@ -1911,9 +1911,9 @@ void HandleOtherConfiguration(void)
if (i < EMUL_MAX) {
WSContentSend_P(PSTR("<input id='r%d' name='b2' type='radio' value='%d'%s><b>%s</b> %s<br>"), // Different id only used for labels
i, i,
(i == Settings.flag2.emulation) ? " checked" : "",
(i == Settings.flag2.emulation) ? PSTR(" checked") : "",
GetTextIndexed(stemp, sizeof(stemp), i, kEmulationOptions),
(i == EMUL_NONE) ? "" : (i == EMUL_WEMO) ? D_SINGLE_DEVICE : D_MULTI_DEVICE);
(i == EMUL_NONE) ? "" : (i == EMUL_WEMO) ? PSTR(D_SINGLE_DEVICE) : PSTR(D_MULTI_DEVICE));
}
}
WSContentSend_P(PSTR("</p></fieldset>"));
@ -2086,7 +2086,7 @@ void HandleInformation(void)
#ifdef ESP32
#ifdef USE_ETHERNET
if (static_cast<uint32_t>(EthernetLocalIP()) != 0) {
WSContentSend_P(PSTR("}1" D_HOSTNAME "}2%s%s"), EthernetHostname(), (Mdns.begun) ? ".local" : "");
WSContentSend_P(PSTR("}1" D_HOSTNAME "}2%s%s"), EthernetHostname(), (Mdns.begun) ? PSTR(".local") : "");
WSContentSend_P(PSTR("}1" D_MAC_ADDRESS "}2%s"), EthernetMacAddress().c_str());
WSContentSend_P(PSTR("}1" D_IP_ADDRESS " (eth)}2%s"), EthernetLocalIP().toString().c_str());
WSContentSend_P(PSTR("}1<hr/>}2<hr/>"));
@ -2096,7 +2096,7 @@ void HandleInformation(void)
if (Settings.flag4.network_wifi) {
int32_t rssi = WiFi.RSSI();
WSContentSend_P(PSTR("}1" D_AP "%d " D_SSID " (" D_RSSI ")}2%s (%d%%, %d dBm)"), Settings.sta_active +1, HtmlEscape(SettingsText(SET_STASSID1 + Settings.sta_active)).c_str(), WifiGetRssiAsQuality(rssi), rssi);
WSContentSend_P(PSTR("}1" D_HOSTNAME "}2%s%s"), TasmotaGlobal.hostname, (Mdns.begun) ? ".local" : "");
WSContentSend_P(PSTR("}1" D_HOSTNAME "}2%s%s"), TasmotaGlobal.hostname, (Mdns.begun) ? PSTR(".local") : "");
#if LWIP_IPV6
String ipv6_addr = WifiGetIPv6();
if (ipv6_addr != "") {
@ -2788,7 +2788,7 @@ bool CaptivePortal(void)
if ((WifiIsInManagerMode()) && !ValidIpAddress(Webserver->hostHeader().c_str())) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_REDIRECTED));
Webserver->sendHeader(F("Location"), String("http://") + Webserver->client().localIP().toString(), true);
Webserver->sendHeader(F("Location"), String(F("http://")) + Webserver->client().localIP().toString(), true);
WSSend(302, CT_PLAIN, ""); // Empty content inhibits Content-length header so we have to close the socket ourselves.
Webserver->client().stop(); // Stop is needed because we sent no content length
return true;

View File

@ -1275,7 +1275,7 @@ void HandleMqttConfiguration(void)
SettingsText(SET_MQTT_HOST),
Settings.mqtt_port,
#ifdef USE_MQTT_TLS
Mqtt.mqtt_tls ? " checked" : "", // SetOption102 - Enable MQTT TLS
Mqtt.mqtt_tls ? PSTR(" checked") : "", // SetOption102 - Enable MQTT TLS
#endif // USE_MQTT_TLS
Format(str, MQTT_CLIENT_ID, sizeof(str)), MQTT_CLIENT_ID, SettingsText(SET_MQTT_CLIENT));
WSContentSend_P(HTTP_FORM_MQTT2,

View File

@ -305,7 +305,7 @@ void PrepShowTimer(uint32_t index)
char days[8] = { 0 };
for (uint32_t i = 0; i < 7; i++) {
uint8_t mask = 1 << i;
snprintf(days, sizeof(days), "%s%d", days, ((xtimer.days & mask) > 0));
snprintf(days, sizeof(days), PSTR("%s%d"), days, ((xtimer.days & mask) > 0));
}
char soutput[80];
@ -857,7 +857,7 @@ void HandleTimerConfiguration(void)
WSContentSend_P(HTTP_TIMER_SCRIPT5, MAX_TIMERS, TasmotaGlobal.devices_present);
WSContentSend_P(HTTP_TIMER_SCRIPT6, TasmotaGlobal.devices_present);
WSContentSendStyle_P(HTTP_TIMER_STYLE, WebColor(COL_FORM));
WSContentSend_P(HTTP_FORM_TIMER1, (Settings.flag3.timers_enable) ? " checked" : ""); // CMND_TIMERS
WSContentSend_P(HTTP_FORM_TIMER1, (Settings.flag3.timers_enable) ? PSTR(" checked") : ""); // CMND_TIMERS
for (uint32_t i = 0; i < MAX_TIMERS; i++) {
WSContentSend_P(PSTR("%s%u"), (i > 0) ? "," : "", Settings.timer[i].data);
}

View File

@ -4979,9 +4979,9 @@ void HandleScriptConfiguration(void) {
#ifdef xSCRIPT_STRIP_COMMENTS
uint16_t ssize = glob_script_mem.script_size;
if (bitRead(Settings.rule_enabled, 1)) ssize *= 2;
WSContentSend_P(HTTP_FORM_SCRIPT1,1,1,bitRead(Settings.rule_enabled,0) ? " checked" : "",ssize);
WSContentSend_P(HTTP_FORM_SCRIPT1,1,1,bitRead(Settings.rule_enabled,0) ? PSTR(" checked") : "",ssize);
#else
WSContentSend_P(HTTP_FORM_SCRIPT1,1,1,bitRead(Settings.rule_enabled,0) ? " checked" : "",glob_script_mem.script_size);
WSContentSend_P(HTTP_FORM_SCRIPT1,1,1,bitRead(Settings.rule_enabled,0) ? PSTR(" checked") : "",glob_script_mem.script_size);
#endif
// script is to large for WSContentSend_P

View File

@ -175,7 +175,7 @@ String HueBridgeId(void)
String temp = WiFi.macAddress();
temp.replace(":", "");
String bridgeid = temp.substring(0, 6);
bridgeid += "FFFE";
bridgeid += F("FFFE");
bridgeid += temp.substring(6);
return bridgeid; // 5CCF7FFFFE139F3D
}

View File

@ -681,9 +681,9 @@ void Z_Device::jsonAddConfig(Z_attribute_list & attr_list) const {
for (auto & data_elt : data) {
char key[8];
if (data_elt.validConfig()) {
snprintf_P(key, sizeof(key), "?%02X.%1X", data_elt.getEndpoint(), data_elt.getConfig());
snprintf_P(key, sizeof(key), PSTR("?%02X.%1X"), data_elt.getEndpoint(), data_elt.getConfig());
} else {
snprintf_P(key, sizeof(key), "?%02X", data_elt.getEndpoint());
snprintf_P(key, sizeof(key), PSTR("?%02X"), data_elt.getEndpoint());
}
key[0] = Z_Data::DataTypeToChar(data_elt.getType());
arr_data.addStr(key);

View File

@ -1903,7 +1903,7 @@ void ZCLFrame::syntheticAqaraVibration(class Z_attribute_list &attr_list, class
y = buf2.get16(2);
x = buf2.get16(4);
char temp[32];
snprintf_P(temp, sizeof(temp), "[%i,%i,%i]", x, y, z);
snprintf_P(temp, sizeof(temp), PSTR("[%i,%i,%i]"), x, y, z);
attr.setStrRaw(temp);
// calculate angles
float X = x;
@ -1912,7 +1912,7 @@ void ZCLFrame::syntheticAqaraVibration(class Z_attribute_list &attr_list, class
int32_t Angle_X = 0.5f + atanf(X/sqrtf(z*z+y*y)) * f_180pi;
int32_t Angle_Y = 0.5f + atanf(Y/sqrtf(x*x+z*z)) * f_180pi;
int32_t Angle_Z = 0.5f + atanf(Z/sqrtf(x*x+y*y)) * f_180pi;
snprintf_P(temp, sizeof(temp), "[%i,%i,%i]", Angle_X, Angle_Y, Angle_Z);
snprintf_P(temp, sizeof(temp), PSTR("[%i,%i,%i]"), Angle_X, Angle_Y, Angle_Z);
attr_list.addAttributePMEM(PSTR("AqaraAngles")).setStrRaw(temp);
}
}

View File

@ -171,7 +171,7 @@ void Z_Mapper::dumpInternals(void) const {
char hex[8];
snprintf(hex, sizeof(hex), PSTR("%d"), edge.lqi);
WSContentSend_P("{from:\"0x%04X\",to:\"0x%04X\",label:\"%s\",color:\"#%03X\"},",
WSContentSend_P(PSTR("{from:\"0x%04X\",to:\"0x%04X\",label:\"%s\",color:\"#%03X\"},"),
edge.node_1, edge.node_2, (edge.lqi > 0) ? hex : "", lqi_color);
}
WSContentSend_P(PSTR("],"));

View File

@ -2081,7 +2081,7 @@ void ZigbeeShow(bool json)
if (zigbee.permit_end_time) {
// PermitJoin in progress
WSContentSend_P(msg[ZB_WEB_PERMITJOIN_ACTIVE], D_ZIGBEE_PERMITJOIN_ACTIVE);
WSContentSend_P(msg[ZB_WEB_PERMITJOIN_ACTIVE], PSTR(D_ZIGBEE_PERMITJOIN_ACTIVE));
}
#endif
}

View File

@ -168,7 +168,7 @@ void HandlePcf8574(void)
WSContentStart_P(D_CONFIGURE_PCF8574);
WSContentSendStyle();
WSContentSend_P(HTTP_FORM_I2C_PCF8574_1, (Settings.flag3.pcf8574_ports_inverted) ? " checked" : ""); // SetOption81 - Invert all ports on PCF8574 devices
WSContentSend_P(HTTP_FORM_I2C_PCF8574_1, (Settings.flag3.pcf8574_ports_inverted) ? PST(" checked") : ""); // SetOption81 - Invert all ports on PCF8574 devices
WSContentSend_P(HTTP_TABLE100);
for (uint32_t idx = 0; idx < Pcf8574.max_devices; idx++) {
for (uint32_t idx2 = 0; idx2 < 8; idx2++) { // 8 ports on PCF8574
@ -177,8 +177,8 @@ void HandlePcf8574(void)
idx +1, idx2,
idx2 + 8*idx,
idx2 + 8*idx,
((helper & Settings.pcf8574_config[idx]) >> idx2 == 0) ? " selected " : " ",
((helper & Settings.pcf8574_config[idx]) >> idx2 == 1) ? " selected " : " "
((helper & Settings.pcf8574_config[idx]) >> idx2 == 0) ? PSTR(" selected ") : " ",
((helper & Settings.pcf8574_config[idx]) >> idx2 == 1) ? PSTR(" selected ") : " "
);
}
}

View File

@ -502,7 +502,7 @@ void UfsDirectory(void) {
WSContentSend_P(UFS_FORM_FILE_UPGc, WebColor(COL_TEXT), ts, fs);
if (ufs_dir) {
WSContentSend_P(UFS_FORM_FILE_UPGc1, WiFi.localIP().toString().c_str(),ufs_dir == 1 ? 2:1, ufs_dir == 1 ? "SDCard":"FlashFS");
WSContentSend_P(UFS_FORM_FILE_UPGc1, WiFi.localIP().toString().c_str(),ufs_dir == 1 ? 2:1, ufs_dir == 1 ? PSTR("SDCard"):PSTR("FlashFS"));
}
WSContentSend_P(UFS_FORM_FILE_UPGc2);