UTFT problem (solved now)

Hello.

After upgrading to IDE 1.6.5 my program doesn't work anymore. Because i want to continue with IDE 1.6.5 i have some questions.

In this example i have a error message after the line:
myGLCD.setFont(Sinclair_M);

The error message is:
invalid conversion from 'const uint8_t* {aka const unsigned char*}' to 'uint8_t* {aka unsigned char*}' [-fpermissive]

Main program

#include "Sinclair_M.c"
#include <UTFT.h>

// Declare which fonts we will be using
extern uint8_t SmallFont[];
extern uint8_t BigFont[];

UTFT myGLCD(TFT01_50,38,39,40,41);

void setup()
{
  myGLCD.InitLCD();
  myGLCD.clrScr();
}

void loop()
{
  myGLCD.setColor(0, 255, 0);
  myGLCD.setBackColor(0, 0, 0);

  //myGLCD.setFont(Sinclair_M);
  myGLCD.setFont(Sinclair_M);


  
  myGLCD.print(" !\"#$%&'()*+,-./", CENTER, 0);
  myGLCD.print("0123456789:;<=>?", CENTER, 16);
  myGLCD.print("@ABCDEFGHIJKLMNO", CENTER, 32);
  myGLCD.print("PQRSTUVWXYZ[\\]^_", CENTER, 48);
  myGLCD.print("`abcdefghijklmno", CENTER, 64);
  myGLCD.print("pqrstuvwxyz{|}~ ", CENTER, 80);

  myGLCD.setFont(SmallFont);
  myGLCD.print(" !\"#$%&'()*+,-./0123456789:;<=>?", CENTER, 120);
  myGLCD.print("@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_", CENTER, 132);
  myGLCD.print("`abcdefghijklmnopqrstuvwxyz{|}~ ", CENTER, 144);

  while(1) {};
}

Code for the inported font

// Sinclair_M.c
// Font type    : Full (95 characters)
// Font size    : 16x16 pixels
// Memory usage : 3044 bytes

#if defined(__AVR__)
	#include <avr/pgmspace.h>
	#define fontdatatype const uint8_t
#elif defined(__PIC32MX__)
	#define PROGMEM
	#define fontdatatype const unsigned char
#elif defined(__arm__)
	#define PROGMEM
	#define fontdatatype const unsigned char
#endif

fontdatatype Sinclair_M[3044] PROGMEM={
0x10,0x10,0x20,0x5F,

My question is: What do i wrong?

Usually you would use extern to bring in the font array.

extern uint8_t Sinclair_M[];

Thank you.

But const uint8_t is already declaired in the .C file. This file is original from Henning Karlsen, the maker of UTFT fonts. When i make the declaration external, it gives a conflicting declaration error. This is logical for me.

Maybe another help to solve this?

Where is your font file located?

My font file is located in the same map as the sketch.

See what happens if you put it into the UTFT folder instead.

invalid conversion from 'const uint8_t* {aka const unsigned char*}' to 'uint8_t* {aka unsigned char*}' [-fpermissive]

I am guessing when you declare variable as "const" you need to define it / use it as "const" too.
The message implies that you are no longer treating the variable as "const".

It is not the purpose of "const" anyway ?

invalid conversion from 'const uint8_t* {aka const unsigned char*}' to 'uint8_t* {aka unsigned char*}' [-fpermissive]

I am guessing when you declare variable as "const" you need to define it / use it as "const" too.
The message implies that you are no longer treating the variable as "const".

It is not the purpose of "const" anyway ?

It has nothing to do with that. I get the exact same error when I try to bring in my font file the way the OP is trying to do.

#include "TRONFont.c"
#include <UTFT.h>

// Declare which fonts we will be using
extern uint8_t SmallFont[];
extern uint8_t BigFont[];

UTFT myGLCD(TFT01_50,38,39,40,41);

void setup()
{
  myGLCD.InitLCD();
  myGLCD.clrScr();
}

void loop()
{
  myGLCD.setColor(0, 255, 0);
  myGLCD.setBackColor(0, 0, 0);

  //myGLCD.setFont(Sinclair_M);
  myGLCD.setFont(TRONFont);


  
  myGLCD.print(" !\"#$%&'()*+,-./", CENTER, 0);
  myGLCD.print("0123456789:;<=>?", CENTER, 16);
  myGLCD.print("@ABCDEFGHIJKLMNO", CENTER, 32);
  myGLCD.print("PQRSTUVWXYZ[\\]^_", CENTER, 48);
  myGLCD.print("`abcdefghijklmno", CENTER, 64);
  myGLCD.print("pqrstuvwxyz{|}~ ", CENTER, 80);

  myGLCD.setFont(SmallFont);
  myGLCD.print(" !\"#$%&'()*+,-./0123456789:;<=>?", CENTER, 120);
  myGLCD.print("@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_", CENTER, 132);
  myGLCD.print("`abcdefghijklmnopqrstuvwxyz{|}~ ", CENTER, 144);

  while(1) {};
}

Result:

sketch_sep22a.ino: In function 'void loop()':
sketch_sep22a.ino:24:26: error: invalid conversion from 'const unsigned char*' to 'uint8_t* {aka unsigned char*}' [-fpermissive]
In file included from sketch_sep22a.ino:3:0:
C:\Users\Andrew\Documents\Arduino\libraries\UTFT/UTFT.h:219:8: error: initializing argument 1 of 'void UTFT::setFont(uint8_t*)' [-fpermissive]
void setFont(uint8_t* font);
^
Error compiling.

Now it if I call the font file with extern it works.

#include <UTFT.h>

// Declare which fonts we will be using
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t TRONFont[];

UTFT myGLCD(TFT01_50,38,39,40,41);

void setup()
{
  myGLCD.InitLCD();
  myGLCD.clrScr();
}

void loop()
{
  myGLCD.setColor(0, 255, 0);
  myGLCD.setBackColor(0, 0, 0);

  //myGLCD.setFont(Sinclair_M);
  myGLCD.setFont(TRONFont);


  
  myGLCD.print(" !\"#$%&'()*+,-./", CENTER, 0);
  myGLCD.print("0123456789:;<=>?", CENTER, 16);
  myGLCD.print("@ABCDEFGHIJKLMNO", CENTER, 32);
  myGLCD.print("PQRSTUVWXYZ[\\]^_", CENTER, 48);
  myGLCD.print("`abcdefghijklmno", CENTER, 64);
  myGLCD.print("pqrstuvwxyz{|}~ ", CENTER, 80);

  myGLCD.setFont(SmallFont);
  myGLCD.print(" !\"#$%&'()*+,-./0123456789:;<=>?", CENTER, 120);
  myGLCD.print("@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_", CENTER, 132);
  myGLCD.print("`abcdefghijklmnopqrstuvwxyz{|}~ ", CENTER, 144);

  while(1) {};
}

Result:

Sketch uses 27,976 bytes (5%) of program storage space. Maximum is 524,288 bytes.

I also put my font file in the UTFT folder so now it has the DefaultFonts file and my TRONFont file

PROBLEM SOLVED!

Many thanks to everybody. And special thanks to HazardsMind. Your example was great!

What did i do now?
As showed in the example, this line: #include "Sinclair_M.c" have been deleted.
Original in IDE 1.0.6 I did make the declaration: extern uint8_t Sinclair_M[]; And i still have to do this.

The Sinclair_M.c file is still in the same directory as the scetch. But putting this file in the UTFT directory also works.

So, now i can continue my program! :slight_smile:

After much research (and this post!) I figured it out. extern must be used not #include and I had to put my font.c file into the UTFT library folder that has the DefaultFonts.c file in it.