如何在程序空间保存大量常量数据?#
在需要使用大量常量数据,如长文本,屏幕字库时,需要保存大量常量数据。 而 Arduino 的变量空间宝贵有限。那么怎么办呢?
使用程序存储空间 (Flash)
goto: Arduino-code-docs: PROGMEM
Reference#
See also#
F() Micro#
ESP32 Flash Memory - Save Permanent Data | Random Nerd Tutorials
ESP32#
PROGMEM 与 F() 在 ESP32 上变得没有用的讨论
在 .h 文件中包含常量#
R-Stuff#
https://esp32.com/viewtopic.php?t=20595#p75616
const char* statusHtml = R"literal(
<html>
...
</html>
)literal";
const char favicon_jpg[] = {
0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01,
...
0xff, 0xd9
};
const int favicon_jpg_len = 4226;