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
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.
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 ?
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_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.
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.