Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6880095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:55:49+00:00 2026-05-27T04:55:49+00:00

Ahhh, PROGMEM, pointers, pointers to pointers, addresses of pointers… My head boggles. I have

  • 0

Ahhh, PROGMEM, pointers, pointers to pointers, addresses of pointers… My head boggles.

I have a data array for the font in question

const uint8_t dejaVuSans9ptBitmaps[] = 
{
    /* @0 ' ' (5 pixels wide) */
    0x00, /*          */
    0x00, /*          */
...

to which I have added PROGMEM

const uint8_t dejaVuSans9ptBitmaps[] PROGMEM =

This is referenced in another structure like so;

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;

Am I correct in assuming this needs to change to;

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 so, it complains that

warning: pointer targets in initialization differ in signedness

For this particular line in the FONT_INFO variable;

const FONT_INFO dejaVuSans9ptFontInfo = {
    13,
    ' ',
    '~',
    dejaVuSans9ptDescriptors, 
--> dejaVuSans9ptBitmaps, <--
};

It is then drawn 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);
    ...

Which finally draws the 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 in over my head :/ Can anyone give me some direction? I have spent hours trying to use PGM_P, and pgm_read_byte etc to no avail – I always get garbage on the screen.

Save me!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:55:50+00:00Added an answer on May 27, 2026 at 4:55 am

    OK, I think I understand what is going on here.

    First, const uint8_t* data is a pointer to the data stored in PROGMEM.

    In the function void drawString(uint16_t x, uint16_t y, uint16_t color, const FONT_INFO *fontInfo, char *str) we pass a pointer to fontInfo.

    To continue, the following is important to understand;

    fontInfo.data
    (*ptr_to_fontInfo).data
    ptr_to_fontInfo->data
    

    are all the same. So ptr_to_fontInfo->data returns the data (not address)

    Then using the & operator, we pass the ‘address of’ this data to the next function

    drawCharBitmap(currentX, y, color, 
      &fontInfo->data[charOffset], charWidth, fontInfo->height)
    

    This address is stored in the declared pointer variable unint8_t *glyph here;

    void drawCharBitmap(const uint16_t xPixel, const uint16_t yPixel, 
      uint16_t color, const uint8_t *glyph, uint8_t cols, uint8_t rows)
    

    Keeping this in mind;

    int *ptr;
    int a;
    
    ptr = &a;
    

    Then glyph now points to the same address as fontInfo->data[charOffset].

    The next thing to know is;

    a[b] in C is just a fancy way for writing *(a + b)

    So glyph being a pointer, when used like this glyph[indexIntoGlyph], it is the same as *(glyph + indexIntoGlyph), and the dereferencing operator * means we get the data at that address.

    From there, we can use the pgm rules as wex described;

    If the variable is in PROGMEM, you use pgm_read_byte() as a
    replacement for the dereference operator *. For “normal” variables in
    RAM you can always write *(&a) instead of just a to return the value
    of the variable a; so to return a 8-bit wide variable from progmem you
    write pgm_read_byte(&x).

    Hope this explanation is correct and helps people (newbies like me!) understand it a bit better.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a base class Animal from which a class Cow inherits,
This is royally annoying me at the moment: Consider an array of 2 values:
So I have a Project with a UITabBarController and a few Navigation Controllers, and
In my Javascript heavy Web app, I have some scripts that are loaded in
this is something I have always had confusion about I never can seem to
Hey guys bit of a complication here, I have a create account page and
If I have code like below is it feasible? String b = abc; String
I am developing a website in which for every change (ahhh.. I hate HTML
I am new to graphs. I have two sets in a bipartite graph. I
By default tabs get added from right to left, so if I insert 1,2,3,4,5

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.