Hello,
I am trying to use this TFT LCD with Arduino Mega2560 R3 Clone 3.5inch Arduino Display-UNO - LCD wiki with UTFT library. But i couldn't do wiring and always show blank/white screen. Can somebody help me ?
While i was using LCDWIKI_KBV i was using;
LCDWIKI_KBV mylcd(ILI9486,A3,A2,A1,A0,A4);
I want to change my display library with UTFT but i don't know how to do wiring and defining LCD.
The line of code is equally applicable to Uno and Mega. It simply calls analogue pins as they the ones most likely to be available, and can be used as digital. It is the order that is vital, i.e. if pin x on display is the first to be read, it must be the first to be declared, irrespective of which pin is actually used.
The constructor for UTFT would be similar to the LCDWIKI constructor.
UTFT does not support ILI9486_8 i.e. 9486 with 8 bit parallel interface
It is easy enough to change UTFT. Your display shield will always be SLOW on a Mega2560. UTFT will be slower than LCDWIKI.
Why do you want UTFT?
David.
LCWIKI doesn't allow me to change font. It look like primitive. I had try to use MCUFRIEND_kbv but i couldn't fix overwrite problem for many days than i decided to use UTFT Library. With MCUFRIEND_kbv i was printing serial integer and float numbers to the display but all numbers were overwriting again and again.
MCUFRIEND_kbv just provides regular Adafruit_GFX font handling.
i.e. transparent or background with System 7x5 font
i.e. only transparent with FreeFonts
For 7x5 background use tft.setTextColor(textColor, backgoundColor)
For FreeFont background use tft.getTextBounds() and tft.fillRect().
Yes, it is a little fiddly to use FreeFonts but you only need to write a single helper function.
You generally only want background with number printing. And this needs formatting to look attractive.
I am fairly certain that I provide a library example.
David.
This is the part of my code. I tried everything but i couldn't solve the overwrite problem with MCUFRIEND_kbv.
I would try UTFT library even it will work slow if it is possible ?
#include "Adafruit_GFX.h"
#include "MCUFRIEND_kbv.h"
MCUFRIEND_kbv tft;
#include "Fonts/Roboto_Condensed_14.h"
//RTC
#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
//RTC
#define BLACK 0x0000
#define NAVY 0x000F
#define DARKGREEN 0x03E0
#define DARKCYAN 0x03EF
#define MAROON 0x7800
#define PURPLE 0x780F
#define OLIVE 0x7BE0
#define LIGHTGREY 0xC618
#define DARKGREY 0x7BEF
#define BLUE 0x001F
#define GREEN 0x07E0
#define CYAN 0x07FF
#define RED 0xF800
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define ORANGE 0xFD20
#define GREENYELLOW 0xAFE5
#define PINK 0xF81F
//---------------------------------------------------------------------------------------------------------------
// CO2
//---------------------------------------------------------------------------------------------------------------
unsigned long startTime = millis();
//---------------------------------------------------------------------------------------------------------------
void setup() {
tft.reset();
Serial.begin(9600);
Serial3.begin(9600); //mh-z19
uint16_t ID = tft.readID();
tft.begin(ID);
tft.fillScreen(BLACK);
tft.setRotation(1-90);
tft.setTextColor(YELLOW);
tft.setTextSize(3);
tft.setFont(&Org_01);
//RTC
Serial.begin(9600);
Wire.begin();
while (!Serial) ; // wait until Arduino Serial Monitor opens
setSyncProvider(RTC.get); // the function to get the time from the RTC
if(timeStatus()!= timeSet) {
Serial.println("Hata");
} else {
Serial.println("RTC sistem saatini ayarladi.");
}
//RTC
tft.setTextWrap(false);
tft.setTextColor(LIGHTGREY, YELLOW);
tft.drawLine(5, 50, 475, 50, LIGHTGREY);
tft.setCursor(8, 90);
tft.setTextSize(2);
tft.print("NEM: ");
tft.setCursor(425, 90);
tft.setTextSize(2);
tft.print(" %");
tft.setCursor(8, 130);
tft.setTextSize(2);
tft.print("KARBONDiOKSiT: ");
tft.setCursor(425, 130);
tft.setTextSize(2);
tft.print(" ppm");
tft.setCursor(8, 170);
tft.setTextSize(2);
tft.print("SICAKLIK (Ortam): ");
tft.setCursor(425, 170);
tft.setTextSize(2);
tft.print(" C");
tft.setCursor(8, 210);
tft.setTextSize(2);
tft.print("SICAKLIK (Kompost): ");
tft.setCursor(425, 210);
tft.setTextSize(2);
tft.print(" C");
} //SETUP END
void loop() {
tft.setTextSize(4);
tft.setTextColor(RED, BLACK);
tft.setCursor(315, 95);
tft.print(sensor.readHumidity());
} //LOOP ENDS
My apologies. There is no getTextBounds() in the examples.
I have attached an example sketch.
It shows what UTFT fonts look like.
But most importantly, it shows that a single rightjustify() helper function would make your life easy.
It should work with any Adafruit_GFX style library. Just change the #include, constructor() and begin() statements. e.g. for Adafruit_ILI9341 or Adafruit_SSD1306
David.
Font_prec.zip (7.17 KB)
It's working and i loved it. As i saw there is no overwrite problem. Floating numbers but there is no any conflict ! Let me try today. I would like to ask a few question;
I am web based software developer for more than 17 years but this is my first experiment but i could able to run what i want to do. Visuality is my passion and my priority;
1-) How can i know complete function list that MCUFRIEND_kbv support ?
2-) How can i find another font that my display support or how can i convert ?
3-) Is it possible to print special alphabet letters ? For example i will use Turkish alphabet and we have letters like " i ", " ü ", " ş ", " ı (lovercase I)" and " ö "...
Thank you !
1-) How can i know complete function list that MCUFRIEND_kbv support ?
Adafruit_GFX documentation covers all the lines, circles, rectangles, print text, drawBitmap, Adafruit_GFX_Button, ... methods
There are not many "MCUFRIEND_kbv" methods. Just hardware things like vertScroll() and pushColors()
If someone volunteers to document MCUFRIEND_kbv I would be happy to help.
2-) How can i find another font that my display support or how can i convert ?
There are several Free Fonts that come with Adafruit_GFX. Look in the Adafruit_GFX/Fonts folder.
There are Free Font versions of the standard UTFT fonts in the MCUFRIEND_kbv folder
3-) Is it possible to print special alphabet letters ? For example i will use Turkish alphabet and we have letters like " i ", " ü ", " ş ", " ı (lovercase I)" and " ö "...
All the Free Fonts that come with Adafruit_GFX are 0x20 - 0x7F
You can display letters from 0x20 - 0xFF if you download a "full" Font.
I have posted several on this Forum. It is possible to create a Free Font from the standard fonts on your PC. Ask if you know which font you want.
The best way to handle international characters is to use UFT-8 text and fonts from U8g2_for_Adafruit_GFX library.
David.
While i was closing to finish my sketch i would like to know another 2 things;
1-) Transitions(refresh) of numbers are seems like a led bulb. Very sharp. Don't we another option which is ordinary cheap table clocks?
and the Date and Time (DS1307) overwrite problem. I could not handle it.
if (day()<10) {
tft.setCursor(87, 34);
tft.print("0");
rightjustify(105, 34, fabs(day()), 2, 0);
}
else {
rightjustify(87, 34, fabs(day()), 2, 0);
}
tft.setCursor(125, 34);
tft.print("/");
if (month()<10) {
tft.setCursor(145, 34);
tft.print("0");
tft.setCursor(165, 34);
tft.print(month());
}
else {
tft.setCursor(145, 34);
tft.print(month());
}
tft.setCursor(185, 34);
tft.print("/");
tft.setCursor(205, 34);
tft.print(year());
tft.setCursor(285, 345);
tft.print("-");
if (hour()<10) {
tft.setCursor(310, 34);
tft.print("0");
tft.setCursor(328, 34);
tft.print(hour());
}
else {
tft.setCursor(310, 34);
tft.print(hour());
}
tft.setCursor(348, 34);
tft.print(":");
if (minute()<10) {
tft.setCursor(368, 34);
tft.print("0");
tft.setCursor(388, 34);
tft.print(minute());
}
else {
tft.setCursor(368, 34);
tft.print(minute());
}
Thank you.
Look at the rightjustify() function
tft.getTextBounds(buf, x, y, &x1, &y1, &w, &h);
//paint the background starting at x
tft.fillRect(x, y1, w, h, bgcolor);
This works for any string that is in the buf[ ]
So you can justify month names as well as numeric values.
Of course you could also use sprintf() to create the whole formatted date and time.
Paint a fresh background. Print the sprintf() formatted text
You seldom change Month name. You often update numeric values like seconds, voltage, pressure, ...
David.