Concatenate PROGMEM strings
Posted: Thu Mar 17, 2022 3:00 am
Hi,
I'm building a simple web interface to a simple ESP32 application to learn about the ESP32 WROOM processer.
I have 3 html pages and I would like the same logo to be present on every page. The logo is represented in the html img tag shown below in the code, and the image itself is rather big (memory).
Is there a way to store the image in PROGMEM only once, instead of repeating the same html img tag in all pages?
In the example below I would imagine I would need 3 PROGMEM and piece them together something like FIRST_PART_HTML+IMG+LAST_PART_HTML in the handleData function?
Thank you in advance.
I'm building a simple web interface to a simple ESP32 application to learn about the ESP32 WROOM processer.
I have 3 html pages and I would like the same logo to be present on every page. The logo is represented in the html img tag shown below in the code, and the image itself is rather big (memory).
Is there a way to store the image in PROGMEM only once, instead of repeating the same html img tag in all pages?
In the example below I would imagine I would need 3 PROGMEM and piece them together something like FIRST_PART_HTML+IMG+LAST_PART_HTML in the handleData function?
Thank you in advance.
- #include <ESPAsyncWebServer.h>
- const char data_html[] PROGMEM = R"=====(
- <!DOCTYPE html>
- <html>
- ... additional html ...
- <body>
- <img src="data:image/png;base64,iVBORw0KGgoA .... .... .... .... ">
- ... additional html ...
- </body>
- </html>
- )=====";
- void handleData(AsyncWebServerRequest *request) {
- request->send_P(200, "text/html", data_html);
- }
- server.on("/data", handleData);