Replace snprintf by snprintf_P where needed

This commit is contained in:
fvanroie 2021-01-09 00:10:28 +01:00
parent 3a3920abab
commit df440de73e
7 changed files with 13 additions and 13 deletions

View File

@ -495,17 +495,17 @@ static lv_font_t * haspPayloadToFont(const char * payload)
static void gauge_format_10(lv_obj_t * gauge, char * buf, int bufsize, int32_t value)
{
snprintf(buf, bufsize, PSTR("%d"), value / 10);
snprintf_P(buf, bufsize, PSTR("%d"), value / 10);
}
static void gauge_format_100(lv_obj_t * gauge, char * buf, int bufsize, int32_t value)
{
snprintf(buf, bufsize, PSTR("%d"), value / 100);
snprintf_P(buf, bufsize, PSTR("%d"), value / 100);
}
static void gauge_format_1k(lv_obj_t * gauge, char * buf, int bufsize, int32_t value)
{
snprintf(buf, bufsize, PSTR("%d"), value / 1000);
snprintf_P(buf, bufsize, PSTR("%d"), value / 1000);
}
static void gauge_format_10k(lv_obj_t * gauge, char * buf, int bufsize, int32_t value)

View File

@ -27,7 +27,7 @@
void confDebugSet(const __FlashStringHelper * fstr_name)
{
/*char buffer[128];
snprintf(buffer, sizeof(buffer), PSTR(" * %s set"), name);
snprintf_P(buffer, sizeof(buffer), PSTR(" * %s set"), name);
debugPrintln(buffer);*/
Log.verbose(TAG_CONF, F(" * %S set"), fstr_name);
}

View File

@ -120,7 +120,7 @@ void debugPrintHaspHeader(Print * output)
" Home Automation Switch Plate\r\n"
" Open Hardware edition v"));
char buffer[32];
snprintf(buffer, sizeof(buffer), PSTR("%u.%u.%u"), HASP_VERSION_MAJOR, HASP_VERSION_MINOR, HASP_VERSION_REVISION);
snprintf_P(buffer, sizeof(buffer), PSTR("%u.%u.%u"), HASP_VERSION_MAJOR, HASP_VERSION_MINOR, HASP_VERSION_REVISION);
output->println(buffer);
output->println();
}

View File

@ -138,7 +138,7 @@ static void oobeSetupQR(const char * ssid, const char * pass)
lv_qrcode_update(qr, buffer, strlen(buffer));
lv_obj_t * qrlabel = lv_label_create(oobepage[0], NULL);
snprintf(buffer, sizeof(buffer), PSTR("Scan to connect"));
snprintf_P(buffer, sizeof(buffer), PSTR("Scan to connect"));
lv_label_set_text(qrlabel, buffer);
if(disp->driver.hor_res <= disp->driver.ver_res) {
@ -157,7 +157,7 @@ static void oobeSetupQR(const char * ssid, const char * pass)
#endif
lv_obj_t * aplabel = lv_label_create(container, NULL);
snprintf(buffer, sizeof(buffer), PSTR("Tap the screen to setup WiFi or connect to this Access Point:"));
snprintf_P(buffer, sizeof(buffer), PSTR("Tap the screen to setup WiFi or connect to this Access Point:"));
lv_label_set_text(aplabel, buffer);
lv_label_set_long_mode(aplabel, LV_LABEL_LONG_BREAK);
@ -248,13 +248,13 @@ static void oobeSetupSsid(void)
/* Create a label and position it above the text box */
lv_obj_t * pwd_label = lv_label_create(oobepage[1], NULL);
snprintf(buffer, sizeof(buffer), PSTR("Password:"));
snprintf_P(buffer, sizeof(buffer), PSTR("Password:"));
lv_label_set_text(pwd_label, buffer);
lv_obj_align(pwd_label, pwd_ta, labelpos, 0, 0);
/* Create a label and position it above the text box */
lv_obj_t * oneline_label = lv_label_create(oobepage[1], NULL);
snprintf(buffer, sizeof(buffer), PSTR("Ssid:"));
snprintf_P(buffer, sizeof(buffer), PSTR("Ssid:"));
lv_label_set_text(oneline_label, buffer);
lv_obj_align(oneline_label, oneline_ta, labelpos, 0, 0);

View File

@ -39,7 +39,7 @@ void ethernetSetup()
char ethHostname[12];
memset(ethHostname, 0, sizeof(ethHostname));
snprintf(ethHostname, sizeof(ethHostname), PSTR("HASP-%02x%02x%02x"), mac[3], mac[4], mac[5]);
snprintf_P(ethHostname, sizeof(ethHostname), PSTR("HASP-%02x%02x%02x"), mac[3], mac[4], mac[5]);
Ethernet.setCsPin(W5500_CS);
Ethernet.setRstPin(W5500_RST);

View File

@ -835,7 +835,7 @@ void handleFileDelete()
if(!httpIsAuthenticated(F("filedelete"))) return;
char mimetype[16];
snprintf(mimetype, sizeof(mimetype), PSTR("text/plain"));
snprintf_P(mimetype, sizeof(mimetype), PSTR("text/plain"));
if(webServer.args() == 0) {
return webServer.send_P(500, mimetype, PSTR("BAD ARGS"));
@ -1802,7 +1802,7 @@ void httpSetup()
webServer.on(F("/edit"), HTTP_GET, []() {
if(!handleFileRead("/edit.htm")) {
char mimetype[16];
snprintf(mimetype, sizeof(mimetype), PSTR("text/plain"));
snprintf_P(mimetype, sizeof(mimetype), PSTR("text/plain"));
webServer.send_P(404, mimetype, PSTR("FileNotFound"));
}
});

View File

@ -36,7 +36,7 @@ void slave_send_state(const __FlashStringHelper * subtopic, const char * payload
char cBuffer[strlen(payload) + 64];
memset(cBuffer, 0, sizeof(cBuffer));
snprintf(cBuffer, sizeof(cBuffer), PSTR("publish %sstate/%s %s"), slaveNodeTopic, subtopic, payload);
snprintf_P(cBuffer, sizeof(cBuffer), PSTR("publish %sstate/%s %s"), slaveNodeTopic, subtopic, payload);
slave.ExecuteCommand((char *)cBuffer);
// Log after char buffers are cleared