From 6f67132f4b29b5ccfb39dbce5d4b020b502ad32c Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Mon, 26 Dec 2022 10:20:45 +0100 Subject: [PATCH] PROGMEM string optimisation. --- usermods/mpu6050_imu/usermod_mpu6050_imu.h | 2 +- wled00/e131.cpp | 8 ++++---- wled00/wled.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/usermods/mpu6050_imu/usermod_mpu6050_imu.h b/usermods/mpu6050_imu/usermod_mpu6050_imu.h index 4ce51c43..283c986e 100644 --- a/usermods/mpu6050_imu/usermod_mpu6050_imu.h +++ b/usermods/mpu6050_imu/usermod_mpu6050_imu.h @@ -138,7 +138,7 @@ class MPU6050Driver : public Usermod { // (if it's going to break, usually the code will be 1) DEBUG_PRINT(F("DMP Initialization failed (code ")); DEBUG_PRINT(devStatus); - DEBUG_PRINTLN(F(")")); + DEBUG_PRINTLN(")"); } } diff --git a/wled00/e131.cpp b/wled00/e131.cpp index cce5233a..0c459823 100644 --- a/wled00/e131.cpp +++ b/wled00/e131.cpp @@ -96,11 +96,11 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){ if (e131SkipOutOfSequence) if (seq < e131LastSequenceNumber[previousUniverses] && seq > 20 && e131LastSequenceNumber[previousUniverses] < 250){ - DEBUG_PRINT("skipping E1.31 frame (last seq="); + DEBUG_PRINT(F("skipping E1.31 frame (last seq=")); DEBUG_PRINT(e131LastSequenceNumber[previousUniverses]); - DEBUG_PRINT(", current seq="); + DEBUG_PRINT(F(", current seq=")); DEBUG_PRINT(seq); - DEBUG_PRINT(", universe="); + DEBUG_PRINT(F(", universe=")); DEBUG_PRINT(uni); DEBUG_PRINTLN(")"); return; @@ -444,7 +444,7 @@ void sendArtnetPollReply(ArtPollReply *reply, IPAddress ipAddress, uint16_t port reply->reply_sub_sw = (uint8_t)((portAddress >> 4) & 0x000F); reply->reply_sw_out[0] = (uint8_t)(portAddress & 0x000F); - sprintf((char *)reply->reply_node_report, "#0001 [%04u] OK - WLED v" TOSTRING(WLED_VERSION), pollReplyCount); + snprintf_P((char *)reply->reply_node_report, sizeof(reply->reply_node_report)-1, PSTR("#0001 [%04u] OK - WLED v" TOSTRING(WLED_VERSION)), pollReplyCount); if (pollReplyCount < 9999) { pollReplyCount++; diff --git a/wled00/wled.cpp b/wled00/wled.cpp index e41176f4..a5110106 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -569,7 +569,7 @@ bool WLED::initEthernet() } else { DEBUG_PRINT(F("initE: Failing due to invalid eth_clk_mode (")); DEBUG_PRINT(es.eth_clk_mode); - DEBUG_PRINTLN(F(")")); + DEBUG_PRINTLN(")"); return false; }