Problem with adafruit gfx

Greeatings

I use adafruit gfx library and i have some problem with fonts.

when i chose some font like FreeMono18pt7b i get double text on my tft . ON this link is photo of my tft http://prntscr.com/fghulu

this is part of my code . tft.setCursor(15,100); tft.setTextColor(WHITE); tft.setFont(&FreeMono18pt7b); tft.setTextSize(1); tft.print("I m here !!!");

with default font its ok .

Have someone solution for this problem

Life would be much simpler if you posted your actual code.

I just had to write something from scratch:

#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

#include <Fonts/FreeMono18pt7b.h>

#define BLACK       0x0000
#define WHITE       0xFFFF

void setup(void)
{
    tft.begin(tft.readID());
    tft.fillScreen(BLACK);
    tft.setCursor(15, 100);
    tft.setTextColor(WHITE);
    tft.setFont(&FreeMono18pt7b);
    tft.setTextSize(1);
    tft.print("I m here !!!");
}

void loop(void)
{
}

And it worked just fine.

Incidentally, if you want to post a photo, why do you post it upside down?

David.

david_prentice:
Life would be much simpler if you posted your actual code.

I just had to write something from scratch:

#include <MCUFRIEND_kbv.h>

MCUFRIEND_kbv tft;

#include <Fonts/FreeMono18pt7b.h>

#define BLACK       0x0000
#define WHITE       0xFFFF

void setup(void)
{
   tft.begin(tft.readID());
   tft.fillScreen(BLACK);
   tft.setCursor(15, 100);
   tft.setTextColor(WHITE);
   tft.setFont(&FreeMono18pt7b);
   tft.setTextSize(1);
   tft.print(“I m here !!!”);
}

void loop(void)
{
}




And it worked just fine. 

Incidentally, if you want to post a photo, why do you post it upside down?

David.
/***************************************************
  This is our GFX example for the Adafruit ILI9488 Breakout and Shield
  ----> http://www.adafruit.com/products/1651

  Check out the links above for our tutorials and wiring diagrams
  These displays use SPI to communicate, 4 or 5 pins are required to
  interface (RST is optional)
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  MIT license, all text above must be included in any redistribution
 ****************************************************/


#include "SPI.h"
#include <Adafruit_GFX.h>
#include <ILI9488.h>
#include <Fonts/FreeMono18pt7b.h>
#define TFT_CS         10 
#define TFT_DC         11
#define TFT_LED        PB0
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF




ILI9488 tft = ILI9488(TFT_CS, TFT_DC);
//definisanje ulaza i izlaza
int ulaz_strelica_gore=30;
int ulaz_strelica_dole=32;
int niz_ulaza[6]={4,5,2,3,6,7};
int niz_stanja[]={};
int stanje_strelica_gore=0;
int stanje_strelica_dole=0;
int broj_ulaza=6;
int bin2int(int bin[]);
void ispis(int broj);

void ispis(int broj){

  tft.setCursor(100,200);
  tft.setTextColor(WHITE);
  tft.setFont(&FreeMono18pt7b);
  tft.setTextSize(1);
  tft.println("I m here !!!");
  
  }

int bin2int(int bin[6]) 
{
    int dec = 0, i;
    for(i = 0; i < 6; i++)
    {
        if(bin[i] == 1) dec = dec * 2 + 1;
        else if (bin[i] == 0) dec *= 2;
    }
    return dec;
}


void setup() {
  Serial.begin(9600);
 pinMode(ulaz_strelica_gore,INPUT);
 pinMode(ulaz_strelica_dole,INPUT);
  for(int i=0;i<broj_ulaza;i++)
    {
        pinMode(niz_ulaza[i],INPUT);
    }
  tft.begin();
  tft.fillScreen(BLACK);
 //pocetni_ekran();
//  tft.begin();
 
 }


void loop(void) {
//tft.fillScreen(ILI9488_BLACK);
  stanje_strelica_gore=digitalRead(ulaz_strelica_gore);
  stanje_strelica_dole=digitalRead(ulaz_strelica_dole);
   int result=0;
    for(int i=0;i<broj_ulaza;i++)
    {
        niz_stanja[i]=digitalRead(niz_ulaza[i]);
    }

    result=bin2int(niz_stanja);
ispis(result);

}

i use adafruit and ili9488 library i dont ue mcu library

Well, I don’t have an SPI ILI9488.

I built your program for an ILI9341 using “Adafruit_ILI9341.h” library.
Sure enough, it draws the text twice.

I re-built with my own “ILI9341_kbv.h” library.
It draws the text twice.

It seems rather odd. Especially since MCUFRIEND_kbv uses Adafruit_GFX and works fine.

David.

I am confused. I tried my original program but with ILI9341_kbv library:

#include <ILI9341_kbv.h>
ILI9341_kbv tft;

#include <Fonts/FreeMono18pt7b.h>

#define BLACK       0x0000
#define WHITE       0xFFFF

void setup(void)
{
    tft.begin(tft.readID());
    tft.fillScreen(BLACK);
    tft.setCursor(15, 100);
    tft.setTextColor(WHITE);
    tft.setFont(&FreeMono18pt7b);
    tft.setTextSize(1);
    tft.print("I m here !!!");
}

void loop(void)
{
}

It works just fine.

I have no idea what your “other” code does. It seems fairly benign.

David.

Ah-ha. I have cracked it.

Your program is continually executing loop(). First time. It sets the Cursor and draws "I m here !!!" correctly. Second time. It sets the Cursor about 4 pixels lower. And draws "I m here !!!" in the second position.

So it looks like a problem with setCursor() in the Adafruit_GFX library.

I am surprised that this has never been noticed.

David.

david_prentice: Ah-ha. I have cracked it.

Your program is continually executing loop(). First time. It sets the Cursor and draws "I m here !!!" correctly. Second time. It sets the Cursor about 4 pixels lower. And draws "I m here !!!" in the second position.

So it looks like a problem with setCursor() in the Adafruit_GFX library.

I am surprised that this has never been noticed.

David.

i resolve my problem but now i have other one.

Can you explane my how can i make my own fonts in this library ?

What is/was the problem with Adafruit_GFX ?

Ah-ha. I see the solution:

    tft.setFont(&FreeMono18pt7b);  //call setFont()
    tft.setCursor(0, 200);         //before setCursor()
    tft.setTextColor(WHITE);
    tft.setTextSize(1);
    tft.print("I m here !!!");
    delay(1000);

Regarding Fonts. Adafruit provide a program for creating Free Fonts. The source code is already in the Adafruit_GFX library folder.

No, I have not used it. However, I have converted existing Fonts from other popular formats e.g. UFTF fonts. Did it with an Arduino sketch.

David.

Please read my thread and help me sir!!! Thanks!!!

https://forum.arduino.cc/index.php?topic=481377.0

david_prentice: What is/was the problem with Adafruit_GFX ?

Ah-ha. I see the solution:

    tft.setFont(&FreeMono18pt7b);  //call setFont()
    tft.setCursor(0, 200);         //before setCursor()
    tft.setTextColor(WHITE);
    tft.setTextSize(1);
    tft.print("I m here !!!");
    delay(1000);

Regarding Fonts. Adafruit provide a program for creating Free Fonts. The source code is already in the Adafruit_GFX library folder.

No, I have not used it. However, I have converted existing Fonts from other popular formats e.g. UFTF fonts. Did it with an Arduino sketch.

David.

you use UTFT fonts maker and add this font to adafruit library?

Do you know have in adafruit some method for printing number like printNumI in UTFT ???

Look at the UTFT code if you really want such an unintuitive set of methods.

Yes, UTFT does let you do the formatting which Arduino Print methods lack. It is not difficult to steal some UTFT ideas for your own helper function to format an integer or float.

Some of the right alignment, centering gets a little messy. Look at my UTFTGLUE class. Look at my FreeDefaultFonts.h implementation. It is simply the standard UTFT fonts converted to FreeFonts format. And incidentally uses much less Flash memory.

Look at how Marek or Bodmer handle fonts in their ILI9341 libraries.

David.

david_prentice: Look at the UTFT code if you really want such an unintuitive set of methods.

Yes, UTFT does let you do the formatting which Arduino Print methods lack. It is not difficult to steal some UTFT ideas for your own helper function to format an integer or float.

Some of the right alignment, centering gets a little messy. Look at my UTFTGLUE class. Look at my FreeDefaultFonts.h implementation. It is simply the standard UTFT fonts converted to FreeFonts format. And incidentally uses much less Flash memory.

Look at how Marek or Bodmer handle fonts in their ILI9341 libraries.

David.

I see on forum one your post , you make 7 segment font for adafruit , can you explane me how you make it , i dont use LInux i m on windows 7 . How can i make my own bigger font then 24p maybe 48 or 96 p .

If you say which UTFT font that you want to be converted, I will do it for you. It will be easier than me posting the sketch.

I just use an Arduino sketch that parses the UTFT font and writes the appropriate C statements to the Serial Terminal.

Be realistic. A 96 pixel high alphabetic font is going to take lots of flash. And you won't get many letters on a 240x320 screen. Ok, there is more room on a 320x480.

There is not much spare memory on a Uno.

David.

david_prentice: If you say which UTFT font that you want to be converted, I will do it for you. It will be easier than me posting the sketch.

I just use an Arduino sketch that parses the UTFT font and writes the appropriate C statements to the Serial Terminal.

Be realistic. A 96 pixel high alphabetic font is going to take lots of flash. And you won't get many letters on a 240x320 screen. Ok, there is more room on a 320x480.

There is not much spare memory on a Uno.

David.

Greeatings.

http://www.rinkydinkelectronics.com/r_fonts.phpIf you can only numbers from calibribold font . thank you.

And if you have time for explane me how you do that . you can write here .

Thank you

Here is the generated font:

FreeCalibriBold32x48.h (10.1 KB)

david_prentice: Here is the generated font:

i try code and i need bigger font maybe 96 not 48 can you make bigger ?

I use only number , i make my own utft font can you make this one https://ufile.io/owb7s

I think that Adafruit_GFX will let you use setTextSize(2) and double the size. Of course this will be blocky.

You need a font generator / editor program on your PC. There are several.

David.

david_prentice: I think that Adafruit_GFX will let you use setTextSize(2) and double the size. Of course this will be blocky.

You need a font generator / editor program on your PC. There are several.

David.

i use setTextSize but the quality od letters are low

I used your horrible link in #15. It does not look like a proper UTFT font to me.

Do you really want a 128x192 font? It is far too big for a Uno.

My conversion sketch is not creating good data. I am not sure why. I am actually using a 128k STM32. So I don't have any size problems.

Quite honestly, it is easier to draw digits with graphics than to waste lots of Flash in a 10 digit font.

David.

david_prentice: I used your horrible link in #15. It does not look like a proper UTFT font to me.

Do you really want a 128x192 font? It is far too big for a Uno.

My conversion sketch is not creating good data. I am not sure why. I am actually using a 128k STM32. So I don't have any size problems.

Quite honestly, it is easier to draw digits with graphics than to waste lots of Flash in a 10 digit font.

David.

i dont use uno i use mega , i use this size because i need big numbers , on my display are only number and text for web.