Size of variable is too large (const unsigned char array)

Hey People,

so at the moment, i am working on a project which involves the Arduino Mega 2560.
I want to use the arduino to transfer pictures from my PC to an e-Paper display. In order to do this, i have to convert the image to a c-array, i have written some code for that, works fine.
The imagedata is stored in hex and each hex-number representes two pixels of the image.
Now, my problem is, that my Arduino Code wont compile because the array gets too big. RIght now i am trying to compile code for a 300x300 picture, which translates to 90.000 pixels and 45.000 hex-numbers. This does not work, although the Arduino Mega has more than enough RAM, so it must be a software (or brain) issue.
Does anyone have an idea, how i could work around it? The image is saved as a const unsigned char array.
Best Regards

#include <SPI.h>
#include "epd5in65f.h" //this is my library for the waveshare 5.56f display
#include "imagedata.h" //my header for the imagedata


void setup()
{

Serial.begin(115200);
Epd epd;

if (epd.Init() != 0) 
{
Serial.print("e - Paper init failed");
return;
}

epd.Clear(EPD_5IN65F_WHITE);
epd.EPD_5IN65F_Display_part(image,0,0,300,300);
}

void loop() {}

My imagedata:

#include "imagedata.h" 
#include <avr/pgmspace.h> 
 
const unsigned char image[45000] PROGMEM =
{0x01,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11
,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11
,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11..........}

Post your code in code tags.

What display library are you using? Does the library have a frame buffer? How big is the frame buffer, if there is one?

Hey, thanks for the tip, i added my code, nothing spectacular tho. I am using the waveshare library for their 5.56f e-Paper Display. You can find it here: e-Paper/Arduino/epd5in65f at master · waveshare/e-Paper · GitHub

i dont know if it uses a frame buffer or how i could identify that.

@jzargo, your topic was moved to a more suitable location on the forum.

There is a limit of 32k for an array. See e.g. Maximum PROGMEM data size - Arduino Mega

Thank you very much! This will be quite helpful. I can tweak my C++ Program to split the array once it reaches a certain size.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.