Identifier is undefined error when creating a font

17 Nov 2011

I'm trying to create a font to use on my TFT screen. I used the GLCD font creator as recommended by Peter Dreschler in his cookbook article. In his cookbook article hte fonts seem to be stored in TFT_fonts library. I created a magneto font using GLCD and included it in my program but I get the "identifier "magneto" is undefined error. I dont know enough about libraries or c++ to sort this out. Can anyone help please.I imported my magneto.h file so I can see it in the compiler.

#include "mbed.h"
#include "SPI_TFT.h"
#include "magneto.h"
#include "touch_tft.h"
touch_tft tt(p19,p20,p16,p17,p11, p12, p13, p14, p15,"TFT"); // x+,x-,y+,y-,mosi, miso, sclk, cs, reset

int main() {

    tt.claim(stdout);        // send stdout to the TFT display
    tt.background(Red);    // set background to black
    tt.foreground(Black);    // set chars to white
    tt.cls();                // clear the screen
    //tt.set_font((unsigned char*) Arial12x12);  // select the font
    tt.set_font((unsigned char*) magneto);
    tt.set_orientation(1);
    tt.locate(0,100);
    printf("Black on Red Magneto")
       
}
20 Nov 2011

Are you sure that the global array representing your font is called magneto? What do the first couple of lines of the array definition in magneto.h look like? I see that Peter's looks something like:

const unsigned char Neu42x35[] = {
        211,42,35,5,
        0x16, 0x00, 0x00, 0x00, 0x00,...
21 Nov 2011

GLCD FontName : Magneto12x12 GLCD FontSize : 12 x 12

const unsigned char Magneto12x12[] = {25,12,12,2, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,............

I more or less parrotted what I could see on Peters cookbook page. I named the file magneto.h but I'm not sure if that was sufficient.

21 Nov 2011

I think you want to change the name of the font used in your set_font() call to match the name of your global char array above, Magneto12x12.

tt.set_font((unsigned char*) Magneto12x12);
22 Nov 2011

Thanks Adam That's sorted. I replaced everything magneto with Magneto12x12 everywhere.