-->
Page 1 of 1

NodeMCU how to put bitmap array to PROGMEM (ILI9341)

PostPosted: Sat Mar 20, 2021 7:50 pm
by washburn_it
Hi All,

I've been playing with an ESP8266 NodeMCU for some time, I bought an ILI9341 2.8" display and connected to the ESP (without touchscreen).
It receives data like temperature, humidity, pressure from a DIY weather station (powered with solar panel) through TCP.
Everything is working very good so now I would like to include also weather forecast of my area.
I'm using a local weather forecast provider that send weather data through a JSON file.
I can parse the JSON file and extract data, among all those data there is also a reference to a bitmap representing a kind of weather "state" (cloudy, sunny etc.).
Those bitmaps are 18 bitmaps, 72x68 pixels...I can't use a SD card to store all those bitmaps so I would like to "store" them in the flash memory with the PROGMEM attribute.
I used GIMP to convert each of them into a C array in a ".c" file.
The resulting file contains this:

Code: Select all/* GIMP RGB C-Source image dump (sereno.c) */

#define SERENO_WIDTH (72)
#define SERENO_HEIGHT (68)
#define SERENO_BYTES_PER_PIXEL (2) /* 2:RGB16, 3:RGB, 4:RGBA */
#define SERENO_PIXEL_DATA ((unsigned char*) SERENO_pixel_data)
const PROGMEM unsigned char SERENO_pixel_data[72 * 68 * 2 + 1]  =
("\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000............."
 "


where I added "PROGMEM" but when I compile I get the following error:

Code: Select allsketch\sereno.c:7:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'unsigned'
 const PROGMEM unsigned char SERENO_pixel_data[72 * 68 * 2 + 1] =


if I delete PROGMEM and add "static" at the beginning of the line, the bitmap is loaded but with just a few of them the memory runs out of space.
To display the bitmap I'm using Adafruit GFX library and "drawRGBBitmap".
How can I do to save all the bitmaps to flash memory?
Thank you, regards.

Roberto

Re: NodeMCU how to put bitmap array to PROGMEM (ILI9341)

PostPosted: Sun Mar 21, 2021 11:28 am
by washburn_it
I found myself the reason of the error, I didn't add the "#include <pgmspace.h>".
So I added it to the file, compiled and uploaded the sketch into the ESP but when the execution reaches

Code: Select all"drawRGBBitmap(0, 0, (uint16_t*)SERENO_pixel_data, 72, 68);"


the ESP reboots.
I also tried with SPIFF but the upload of any kind of file fails.
So...what could be the reason for that reset?
Thank you,


Roberto