Skip to content

Commit 6c83b63

Browse files
Make the example really need to use const char*
Make the generated GIF dynamic in the example and move the original to PROGMEM (since that's where const arrays like this belong).
1 parent 2c74cdb commit 6c83b63

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

libraries/ESP8266WebServer/examples/HelloServer/HelloServer.ino

+8-3
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,20 @@ void setup(void) {
6868
});
6969

7070
server.on("/gif", []() {
71-
static const uint8_t gif[] = {
71+
static const uint8_t gif[] PROGMEM = {
7272
0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x10, 0x00, 0x10, 0x00, 0x80, 0x01,
7373
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x2c, 0x00, 0x00, 0x00, 0x00,
7474
0x10, 0x00, 0x10, 0x00, 0x00, 0x02, 0x19, 0x8c, 0x8f, 0xa9, 0xcb, 0x9d,
7575
0x00, 0x5f, 0x74, 0xb4, 0x56, 0xb0, 0xb0, 0xd2, 0xf2, 0x35, 0x1e, 0x4c,
7676
0x0c, 0x24, 0x5a, 0xe6, 0x89, 0xa6, 0x4d, 0x01, 0x00, 0x3b
7777
};
78-
79-
server.send(200, "image/gif", gif, sizeof(gif));
78+
char gif_colored[sizeof(gif)];
79+
memcpy_P(gif_colored, gif, sizeof(gif));
80+
// Set the background to a random set of colors
81+
gif_colored[16] = millis() % 256;
82+
gif_colored[17] = millis() % 256;
83+
gif_colored[18] = millis() % 256;
84+
server.send(200, "image/gif", gif_colored, sizeof(gif_colored));
8085
});
8186

8287
server.onNotFound(handleNotFound);

0 commit comments

Comments
 (0)