title: Leaving a data array (Font) in FLASH - PROGMEM in AVR GCC
body: <p>Ahhh, PROGMEM, pointers, pointers to pointers, addresses of pointers... My head boggles.</p>
  
  <p>I have a data array for the font in question</p>
  
  <pre><code>const uint8_t dejaVuSans9ptBitmaps[] = 
  {
      /* @0 ' ' (5 pixels wide) */
      0x00, /*          */
      0x00, /*          */
  ...
  </code></pre>
  
  <p>to which I have added PROGMEM</p>
  
  <pre><code>const uint8_t dejaVuSans9ptBitmaps[] PROGMEM =
  </code></pre>
  
  <p>This is referenced in another structure like so;</p>
  
  <pre><code>const FONT_INFO dejaVuSans9ptFontInfo = {
     13,
     ' ',
     '~',
     dejaVuSans9ptDescriptors, 
     dejaVuSans9ptBitmaps,
  };
  </code></pre>
  
  <p>The structure is defined as;</p>
  
  <pre><code>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;
  </code></pre>
  
  <p>Am I correct in assuming this needs to change to;</p>
  
  <pre><code>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;
  </code></pre>
  
  <p>When I do so, it complains that </p>
  
  <pre><code>warning: pointer targets in initialization differ in signedness
  </code></pre>
  
  <p>For this particular line in the FONT_INFO variable;</p>
  
  <pre><code>const FONT_INFO dejaVuSans9ptFontInfo = {
      13,
      ' ',
      '~',
      dejaVuSans9ptDescriptors, 
  --&gt; dejaVuSans9ptBitmaps, &lt;--
  };
  </code></pre>
  
  <p>It is then drawn using the function;</p>
  
  <pre><code>void drawString(uint16_t x, uint16_t y, uint16_t color, const FONT_INFO *fontInfo, char *str) {
      ...
      drawCharBitmap(currentX, y, color, &amp;fontInfo-&gt;data[charOffset], charWidth, fontInfo-&gt;height);
      ...
  </code></pre>
  
  <p>Which finally draws the glyph;</p>
  
  <pre><code>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] &amp; (0X80)) drawPixel(currentX, currentY, color);
     ...
  </code></pre>
  
  <p>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.</p>
  
  <p>Save me!</p>