Hi all!
I have an array defined in a .h header file:
// We need this header file to use FLASH as storage with PROGMEM directive:
#include <pgmspace.h>
// Icon width and height
const uint16_t imageWidth = 64;
const uint16_t imageHeight = 32;
const unsigned short imageButtonSample[2048] PROGMEM={
That defines a graphic image for display on an LCD touchscreen and I am having problems passing that array to a class I wrote.
Here's my .h file:
class ImageButton
{
public:
ImageButton(int x, int y, int w, int h, const unsigned short *image);
void drawImageButton();
void eraseImageButton();
private:
int _xLoc; // x location of button
int _yLoc; // y location of button
int _xSize; // width of button
int _ySize; // height of button
const unsigned short *_image[2048]; // image for button
// need to do this without specifying size of image
}; // end - class ImageButton
and my .cpp file:
ImageButton::ImageButton(int x, int y, int w, int h, const unsigned short *image)
{
_xLoc = x;
_yLoc = y;
_xSize = w;
_ySize = h;
*_image = image;
}
void ImageButton::drawImageButton()
{
tft.setSwapBytes(true); // Swap the colour byte order when rendering
tft.pushImage((_xLoc - (_xSize/2)), (_yLoc - (_ySize/2)), _xSize, _ySize, *_image);
}
void ImageButton::eraseImageButton()
{
tft.fillRect((_xLoc - (_xSize/2)), (_yLoc - (_ySize/2)), _xSize, _ySize, BGColor);
}
My problem is, if I don't specify the size of the const unsigned short *_image[] in the class .h file, then other data in the program gets corrupted. Is there anyway to pass that array to the class without specifying it's size in the .h file?
In my search on this, I cam across this:
and the second answer on that post seems to be where I should be looking?
Any easier way to pass that array without knowing the size of it?
Thanks for any help,
Randy