Passing a variable in a function call (e-paper display) using epd2in13 library

Hi there,

I used to come here a lot on the forum. Did a lot of tinkering with several arduino’s in the past, but due to other interests I haven’t seen any code in years. Now I was in need of some application at home and thought it would be easy to make it using my good 'ol arduino. Hardware was easy enough, but now I got stuck with coding!

Probably it is a basic question, but I cant seem to figure out how to do this. I have an e-paper display hooked up to my arduino. I’m able to put individual images in there by converting a bmp to an array and calling it using


Whereas “image1” is defined in a separate .c and header file.

const unsigned char image1 [] PROGMEM={0xff..... etc};

I do have multiple images, called image1, image2, etc. I would like to switch between these images using an array or some kind. It’s easy enough to do this using a if, else construction, but this asks a lot of valuable memory (i think).

So I declared an array containing all the names of the images, a function call in my main loop and the function itself. I would like to pass an integer value equal to the amount of times I’ve pushed the button to the function. The function should parse the correct display “name”, being e.g. image1 and put it in the:


const char* dispArray[]={"image1","image2","image3",....};

void setup(){

void loop(){

void setDisplay(int i){
  epd.Reset();                                           //wake up
  epd.SetFrameMemory(dispArray[i]);        //Assign image i to the memory
  epd.DisplayFrame();                               // display
  epd.Sleep();                                            //sleep


I’m sure that there is an easy solution to this problem. Thanks in advance!


This should do it:

const unsigned char* dispArray[]={ image1, image2, image3,....};
const byte dispArrayLength = sizeof(dispArray) / sizeof(dispArray[0]); // you might find this useful for bounds checking

Just the double quotes right.. Should 've been able to figure that one out myself. I'm only able to verify right now it doesn't give any errors, will implement and test tonight.

Thanks for the reply! :smiley: