What I try to get, is a structure, which contains an 2D array of bytes which should store a binary picture.
typedef enum{
PIC_ID_DOUBLE_UP,
PIC_ID_DOUBLE_DOWN,
}PICPictureId_t;
typedef struct{
PICPictureId_t picId;
uint8 width;
uint8 height;
uint8 (**dataPointer);
}PICPicture_t;
The dimensions (in pixels) are determined by the width and height. Now I tried to initialize an array of pictures. I want to store the whole data in the flash.
PICPicture_t pictures[] = {
{
.height = 3,
.width = 16,
.picId = PIC_ID_DOUBLE_UP,
.dataPointer = ???
}
};
How could I initialize the pointer to the data? I get a version which compiles (after studying the answer here: A pointer to 2d array), if I use a pointer to an array in the picture struct and then set the pointer to the first element of the doubleUp 2D array:
typedef struct{
PICPictureId_t picId;
uint8 width;
uint8 height;
uint8 (*dataPointer)[2];
}PICPicture_t;
uint8 doubleUp[3][2] = {
{0x12 ,0x13},
{0x22 ,0x32},
{0x22 ,0x32}
};
PICPicture_t pictures[] = {
{
.height = 3,
.width = 16,
.picId = PIC_ID_DOUBLE_UP,
.dataPointer = &(doubleUp[0]),
}
};
But here I have to declare the dimension of the second array but I want to make the structure idependent of the dimension and use for this the height and width field.