Ahhh, PROGMEM, pointers, pointers to pointers, addresses of pointers ... My head hurts.
I have a dataset for the font in question
const uint8_t dejaVuSans9ptBitmaps[] = { 0x00, 0x00, ...
to which I added PROGMEM
const uint8_t dejaVuSans9ptBitmaps[] PROGMEM =
This refers to another structure, for example:
const FONT_INFO dejaVuSans9ptFontInfo = { 13, ' ', '~', dejaVuSans9ptDescriptors, dejaVuSans9ptBitmaps, };
The structure is defined as:
typedef struct { const uint8_t height; const uint8_t startChar; const uint8_t endChar; const FONT_CHAR_INFO* charInfo; const uint8_t* data; } FONT_INFO;
Do I correctly assume that this needs to be changed:
typedef struct { const uint8_t height; const uint8_t startChar; const uint8_t endChar; const FONT_CHAR_INFO* charInfo; const PGM_P data; } FONT_INFO;
When I do this, he complains that
warning: pointer targets in initialization differ in signedness
For this particular line in the variable FONT_INFO;
const FONT_INFO dejaVuSans9ptFontInfo = { 13, ' ', '~', dejaVuSans9ptDescriptors, --> dejaVuSans9ptBitmaps, <-- };
Then, drawing is performed using the function;
void drawString(uint16_t x, uint16_t y, uint16_t color, const FONT_INFO *fontInfo, char *str) { ... drawCharBitmap(currentX, y, color, &fontInfo->data[charOffset], charWidth, fontInfo->height); ...
What finally draws a glyph,
void drawCharBitmap(const uint16_t xPixel, const uint16_t yPixel, uint16_t color, const uint8_t *glyph, uint8_t cols, uint8_t rows) { ... if (glyph[indexIntoGlyph] & (0X80)) drawPixel(currentX, currentY, color); ...
I am above my head: / Can someone give me some direction? I spent hours trying to use PGM_P, and pgm_read_byte etc., but to no avail - I always get garbage on the screen.
Save me!