Looking how to switch between array argument into a function

​h​ello all...
I plowed the web without finding... but in fact I obviously did not know how to formulate the request correctly

so :
I succesffully load images stored in arrays such as "const unsigned short SUNSET[1024] = {......}" using a "drawImage(const uint16_t *data)" method. ( "drawImage(SUNSET)" for the method call )

then so far so good.

But I have a lot of images and I'm looking for the syntax that would allow me to pass the reference of a requested image to the display function, for example:
"drawImage(image_number44)" instead of "drawImage(SUNSET)"

Would you mind telling me how we do that?? (argh the pointers!)
Many thanks in advance

if you meant "I would like to put my image arrays into an array so that I can iterate through them" then either:

  • create a 2D array -> maybe not ideal since you image array sizes may vary
  • or a array of pointer.

the latter seems to be more suitable.

hope that helps...

First, those images must be stored in flash, with a syntax similar to:

const unsigned char IMAGE_BLACK_0[5808] PROGMEM = { /* 0X01,0X01,0X08,0X01,0XB0,0X00, */

And you would repeat the array matrix by simply incrementing the name of the array:
IMAGE_BLACK_0, IMAGE_BLACK_1, IMAGE_BLACK_2, ...

The main program would call the named array as:

epd.DisplayFrame(IMAGE_BLACK_0, IMAGE_RED);
epd.DisplayFrame(IMAGE_BLACK_1, IMAGE_RED);
epd.DisplayFrame(IMAGE_BLACK_2, IMAGE_RED);

Many of the vendor's graphic examples show this in detail. Just extend their examples.

The code above was snatched from a 3-color eInk display:
https://github.com/Seeed-Studio/Grove_Triple_Color_E-lnk_2.13/blob/master/examples/Eink_factory_code_213/Eink_factory_code_213.ino

const unsigned short MOONRISE[] = {......};
const unsigned short SUNSET[] = {......};

const unsigned short *images[] =
{
MOONRISE,
SUNSET
}

drawImage(images[0]);  // MOONRISE
drawImage(images[1]);  // SUNSET
1 Like

Seems like all the answers match...
the last one is turnkey! I try this right away and I report
thank you already to you three

EDIT Works fine !! many thanks !! have a good evening

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