Giter Club home page Giter Club logo

tft_hx8357's Introduction

TFT_HX8357

An Arduino IDE compatible graphics and fonts library for Mega with a drivers for the HX8357B, HX8357C, ILI9481 and ILI9486 based TFT displays with a 16 bit parallel interface. This library will not run on an UNO and it does not support 8 bit UNO shields.

The library contains proportional fonts, different sizes can be enabled/disabled at compile time to optimise the use of FLASH memory. The library has been tested with the Mega.

In addition to the default fonts (1, 2, 4, 6, 7 and 8) the library includes and supports the encoded Free Fonts from the new Adafruit_GFX library. Unlike the Adafruit_GFX library these fonts can be automatically rendered with background and padding to over-write and erase old text, see the examples.

The library is designed to be slim and fast. Typically a clear screen for a 320 x 480 TFT will complete in only 12ms.

The library is based on the Adafruit GFX library and the aim is to retain compatibility. Significant additions have been made to the library to boost the speed for the Mega processor and to add new features. The new graphics functions include different size proportional fonts and formatting features. There are a significant number of example sketches to demonstrate the different features.

Configuration of the library font selections and other features is made by editting the User_Setup.h file in the library folder. Fonts and features can easily be disabled by commenting out lines.

The 3.2" HX8357B display I use can be found here:

http://www.banggood.com/3_2-Inch-320-X-480-TFT-LCD-Display-Module-Support-Arduino-Mega2560-p-963574.html

This HX8357B based display does appear to have a bug in the silicon of the driver chip as it sometimes generates spurious pixels on the display. The only way around this is to redraw the whole screen occasionally to wipe out the duff ones, this is most noticeable for intensive updates in small screen areas (e.g. in ring meter sketch). So my suggestion is to go for the next revision driver, the HX8357C with 3" TFT which does not exhibit the same problem:

http://www.banggood.com/3_0-Inch-320-X-480-TFT-LCD-Display-Module-Support-Arduino-Mega2560-p-963573.html

Have fun!

tft_hx8357's People

Contributors

bodmer avatar per1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tft_hx8357's Issues

PlatformIO

Can this repository be added to PlatformIO please?

Problem downloading Library

Can you please send a link to the library for ARDUINO MEGA AND ILI9481.
(I tried other libraries but they were for arduino uno So they gave a white screen on mega)
Right now i am using UTFT library and my output text is mirrored in it.

Bigger font

Hi
How to create bigger font, size 72, 96 or other? Arial or Times New Roman, maybe Serif.
Greetings

New Function - drawLeftString

----- Keywords.txt -----
drawLeftString KEYWORD2

----- TFT_HX8357.h -----
drawLeftString(char *string, int16_t dX, int16_t poY, int16_t font),

----- TFT_HX8357.cpp -----
/***************************************************************************************
** Function name: drawLeftString
** Descriptions: draw string left justified to dX
***************************************************************************************/
int16_t TFT_HX8357::drawLeftString(char *string, int16_t dX, int16_t poY, int16_t font)
{
byte tempdatum = textdatum;
int16_t sumX = 0;
textdatum = TL_DATUM;
sumX = drawString(string, dX, poY, font);
textdatum = tempdatum;
return sumX;
}

Turn off the display?

Thanks for the great work :)
Do you have an idea how to turn off the display using code (Arduino Mega2560)?

White screen

MEGA 2560 board with 3.5" TFT LCD Shield driver ili9481 no touch screen. User_setup.h uncommented for #define ILI9481. Sketch uploading successfully. Serial monitor on and displaying test data but screen is white all the time. White screen also for all other examples.

⸮HX8357 Test!
Benchmark Time (microseconds)
Screen fill 212728
Text 41364
Lines 214860
Horiz/Vert Lines 18404
Rectangles (outline) 11408
Rectangles (filled) 538204
Circles (filled) 155972
Circles (outline) 189296
Triangles (outline) 49084
Triangles (filled) 272252
Rounded rects (outline) 62488
Rounded rects (filled) 606004
Done!

drawFastHLine clipping - same issue as #17

Same issue as fastVLine, in this case when drawing a filled ellipse, values of X less than the X-radius cause the ellipse not to be filled correctly

Similar fix in CLIP_CHECK

if (x < 0) w +=x, x = 0;

Also applies (as does #17) to TFT_eSPI

HX8357 on an ESP32

I won't use your lib TFT_HX8357 for the Feather HUZZA32 with 3.5" display.
Is het posible to use your lib with this combination, and so yes where to change the pin layout
in the code?

Thanks for any help

Esp8266

Hi,

could it operate with Wemos mini/ESP8266 or it has too few legs?

BMP images flipped

Impressive library! Minor (solved) bug: While testing the example "Draw_SDcard_Bitmap.ino" on Arduino MEGA for a TFT-3.5" display, 480x320 size, 16-bit (model MAR3513) parallel interface, driver ILI9486 (marked on the module) and set as such in User_Setup.h, the following issue occurred, for any rotation 0...3 (SdFat library was used) :
-The BMB files are Left-Right flipped and writing text on a blank page with the same orientation gives inverted text.
I modified TFT_HX8357.cpp and now all works fine:

/***************************************************************************************
** Function name: setRotation
** Description: rotate the screen orientation m = 0-3 or 4-7 for BMP drawing
***************************************************************************************/

#define MADCTL_MY 0x80
#define MADCTL_MX 0x40
#define MADCTL_MV 0x20
#define MADCTL_ML 0x10
#define MADCTL_RGB 0x00
#define MADCTL_BGR 0x08
#define MADCTL_SS 0x02
#define MADCTL_GS 0x01

#ifdef ILI9481

void TFT_HX8357::setRotation(uint8_t m)
{
writecommand(HX8357_MADCTL);
rotation = m % 4;
switch (rotation) {
case 0: // Portrait
#ifdef ILI9486 // MADCTL [MY, MX, MV, ML, BGR, MH, xx, xx]
writedata (0x08+(m>3)*0x90); // Modified MVP for BMP
#else
writedata(MADCTL_BGR | MADCTL_SS);
#endif
_width = HX8357_TFTWIDTH;
_height = HX8357_TFTHEIGHT;
break;
case 1: // Landscape (Portrait + 90)
#ifdef ILI9486
writedata (0x68-(m>3)*0x40); // Modified MVP for BMP
#else
writedata(MADCTL_MV | MADCTL_BGR);
#endif
_width = HX8357_TFTHEIGHT;
_height = HX8357_TFTWIDTH;
break;
case 2: // Inverter portrait
#ifdef ILI9486
writedata (0xD8-(m>3)*0x90); // Modified MVP for BMP
#else
writedata( MADCTL_BGR | MADCTL_GS);
#endif
_width = HX8357_TFTWIDTH;
_height = HX8357_TFTHEIGHT;
break;
case 3: // Inverted landscape
#ifdef ILI9486
writedata (0xA8+(m>3)*0x40); // Modified MVP for BMP
#else
writedata(MADCTL_MV | MADCTL_BGR | MADCTL_SS | MADCTL_GS);
#endif
_width = HX8357_TFTHEIGHT;
_height = HX8357_TFTWIDTH;
break;
}
}

please add support for 8 bit lcd

Hello Mr Bodmer.

I want to use this lib for my 8bit ili9481 and ili9486 lcd from broken chinaphones.

I use diy UNO shield for ILI9481 that use PORTD pin D0 to D7 for lcd data line.
PORTC pin A0=RD, A1=WR, A2=RS, A3=CS, A4=RST.

And i use to MEGA diy shield for ILI9486, that use PORTA for the 8 bit lcd dataline.
RS=38, CS=40, WR=38, RST=41, RD=42

with that combination pin for lcd data, i know that serial function cannot be used,but for this im already not need.

Can you make/give me a test branch or solution for shield that i use to make it works with your lib code with arduino UNO/MEGA that use 8 bit lcd, because i try to change itself with not good result.

Very tanks for your response.

Sorry for my bad english.

ILI9481 MIRRORED TEXT

Hi ,
I am using ili9481 and arduino mega but my output text us mirrored. Can you please tell me what changes i have to make in setup file to fix this and where to get setup file from.

ili9488

Hay alguna manera de hacerla compatible con ili9488?
No creo que sea muy complicado, ya que, hasta lo que tengo entendido es muy similar a ili981 y ili9486, gracias.

memory overflow issue

Hi,
I'm working on a Mega based boiler controller. The whole code is a bit big and contains a few icons
When I compile the application I have something like this:

Sketch uses 121,210 bytes (47%) of program storage space. Maximum is 253,952 bytes.
Global variables use 4,501 bytes (54%) of dynamic memory, leaving 3,691 bytes for local variables. Maximum is 8,192 bytes.

If I add one more 32x32 icon then I have this:

Sketch uses 123,230 bytes (48%) of program storage space. Maximum is 253,952 bytes.
Global variables use 4,493 bytes (54%) of dynamic memory, leaving 3,699 bytes for local variables. Maximum is 8,192 bytes.

When I'm in the second scenario then the tft.drawString instead of drawing a string draw nothing or the full screen looks like randomly filled with hairlines, some icons drawn well but only a few, except that nothing readable... (I saw something similar on my PC when my video card died)
If I remove the last icon from the code to reduce memory footprint then everything working just normal.
I have version 0.27.0 installed.
Have you any idea why is that happening?

Bitmap read of SD CARd

Hi, I downloaded the library and i was particuarly interested in the example where you read the sd CArd to load a bitmap mage. i tried it and it had an error..pointing the the bitmapfunctions tab saying FILE WAS NOT DECLARED IN THE SCOPE... Can you help me with this error.. iv tried moving the libraries in the same work area.. my teachers havnet been able to figure it out. Working on a project and im really interestd on displaying images. Another thing, I was playing around with the code, I commented the function for DRAMBMP and left the DRAWRAW.. it worked. But my problem there is that i cant convert my picts to raw. the converter UTFT library has doesnt work. im using a 3.2 inch 480x320 hx8357 shield for mega. Cn you help me with eithr the code or the raw conversion?

touch signals

Hi.

With this library is possible to read touch signals?

How to use with a 3.5 tft shield?

I am using a 3.5 TFT shield and it have different pin connections than the 3.2 is there is any thing i can change or edit to make it work?

Stateless textWidth and fontHeight. How to get current font?

Hi! Thanks for your work. Some feedback:

textWidth() and fontHeight() depending on the currently set textfont just bited me in the ass.
I'm trying to find a workaround. For that, I think I would need:
Get and save current font
Set current font to whatever font you want to know the size of
Call textWidth and fontHeight
Restore saved font

But I'm stuck on getting current font because there is no getter and textfont member is protected. How do I do that?

I think it would be better for these two methods to be just pure functions. (As well as color565 and possibly others)
What also bited me was that you can create more that one TFT instance (I accidentally created 2 dynamically). You might want to consider making it a namespace instead of a class (I wrapped a namespace around TFT)

All in all, it's been a pleasure. I would appreciate you telling me how to get textfont

Ili9481 text mirrored

Hi,
I am using a Ili9481 with arduino mega but my text is mirrored . Can you help fix it please?

drawFastVLine clipping check insufficient for fillCircle

After trying to draw filled circles near the edges, I found the following:
fillCircle may be called with radius > y0 which results in drawFastVLine being called with -ve value of y.
A simple check in drawFastVLine of
if (y < 0) h += y, y = 0;
gets round this problem (on my display the centre of the circle is not filled correctly!!)
Same issue probably applies to other versions of the LCD drive.

drawEllipse()/fillEllipse() are flawed on radius >175px

On photo there are two ellipses draw: blue one with rx=175 and ry=50, and red one with rx=200 and ry=50. As you can see, the red one is bugged.
img_20180727_204410

Debug output shows that value of rx2 on line 563 computes as rx2=-25536 instead of 40000 despite using int32_t for the variable. As far as I understand it, the multiplication is performed within int16_t domain (which results in an overflow) and result is converted into int32_t.

Using the following calculation fixes the problem:

int32_t rx2 = ((int32_t)rx)*((int32_t)rx);
int32_t ry2 = ((int32_t)ry)*((int32_t)ry);

Sadly, I don't quite understand how to make a pull-request, so I post the change here.

Adjust the brightness

Hi Bodmer,

I use the Mega with HX8357B with your lib.
So how can I adjust the brightness?

Thank you,
Palm

Arduino Due (ARM) support

The include file calls AVR specific IO library. Could I convert it to support the Due boards based on ARM microcontrollers?
Is there a library already awailable?

Arduino Due

Can you modify the library to support Arduino Due? Because mega is just too slow.

Landscape text is mirrored

When running the various tests the txt in landscape mode is correct, but in portrait it is mirrored, for example the "graphics test_240x320" code.
fullsizerender

Clearing screen in tft_hx8357

Hi
What is the command for clearing screen for tft.
I tried fillScreen(color) but i deletes every thing from screen. Even what i have typed in void setup.

Possible bug in drawChar when textsize = 3

Noticed a potential for a lockup if textsize == 3 in drawChar.
Line 2202 assumes textsize x textsize is multiple of 4 when 3*3 obviously isn't!!
Should be handled as per lines 2241-2 so tnp is checked in blocks of 4 but only if > 3 i.e.
while(tnp>3){ tnp-=4; WR_STB; WR_STB; WR_STB; WR_STB; }
while(tnp) { tnp--; WR_STB;}
unless of course I've missed something (very likely!!)

Problem printing input

Hi I am using ILI9481 display with arduino mega and HX8357 library and max6675 temp sensor.
Can you please tell me the print command to print readings from max6675 ti lcd display.
(In utft library it is printNumI)

24 bit color?

In using this library with its examples, I notice that it requires a 24 bit BMP file to display a full color pic. But in defining colors in a sketch it seems to be limited to 16 bit (565) color. How can I use 24 bit RGB color definitions?

Accentuated characters not working

Hi, how can have the normal Portuguese accentuated chars on font 4?
Like these:
á, é, í, ó, ç and respective capitals

How can I view which ones are on the font files so I can replace the not used for this ones for example if there is no other way?

can't seem to get DrawString to work consistantly

Hi, below is some sample code , I cant seem to figure out why
the first works ok but the second one doesn't display at all?
i.e. it doesnt display the "ABCDEF " ,
what am i doing wrong?

include <TFT_HX8357.h> // Hardware-specific library

include "Free_Fonts.h" // Include the header file attached to this sketch

include <stdio.h>

include <SPI.h>

TFT_HX8357 tft = TFT_HX8357(); // Invoke custom library
const int chipSelect = 53;

void setup(void)
{
tft.begin();
tft.setRotation(3);
tft.fillScreen(TFT_BLACK); // Clear screen to navy background
tft.setTextColor(TFT_WHITE, TFT_BLACK);
Serial.begin(9600);
}

void loop()
{
tft.setTextColor(TFT_WHITE, TFT_BLACK);
tft.setTextDatum(TC_DATUM);
tft.drawString("1234567890123456" , 5, 55, 6);
tft.drawString("ABCDEF " , 5, 99, 6);
delay(4000);
}

Bitmap Image Not Working

Hi,
I have been trying to use this library to display simple .bmp images on a Arduino mega2560 shield I bought a while ago. Using any examples for the display work perfectly fine but when I loaded what I think is a correctly formatted bitmap image using the "Draw_SDCard_Bitmap" example code, I get some sort of corrupted image on the display. Its most likely my fault but any help would be appreciated. For reference I'll include the result I get on the shield and my original image. I'm not very experienced with Arduino related projects so if I happened to have made a stupid mistake, sorry in advance :)

Here is the image I'm trying to use (not formatted for 480x320 or in a .bmp)

and here is what the screen shows (you can kind of see that the image is there but sort of corrupted, sorry for the horrible lighting)

sorry if this is not so much an issue with the library (I just didn't know where to ask for help)

Color Problem

Some of the colors are reversed between another of them

Thanks - But can you help.

Hi,

I bought a TFT display from ebay. It said it was ILI9486. It has a 16bit parallel interface. I tried a few libraries, and this was the one that could produce any output.

I had to fix a lot of things - and the white screen was first - after picking apart the datasheet and the initialisation code - I found that setting the power option P3 (Command 0xC2) - just produced a white screen - commenting that out gave me screen output.

However - the data was not right. I've basically doubled every write strobe where data is involved - and now I almost get what I am expecting; lines, circles, interlaced text, etc. The interlaced text I have fixed previously, but I am going after an elegant solution, so 2 steps forward one step backwards.

Any thoughts as to what I might be looking at? Why two write strobes might be necessary? I tried removing compiler optimisations, adding NOPs into the strobes, to verify I wasn't looking at a race condition, but this had no effect. Is there some panel diagnostics that you know of so I can figure out if I am actually looking at a ILI9486?

Thanks

Martin

Screen gray with this library for my ILLI 9481

I tried to use your library with my screen but it only stays with the gray screen, in the examples I used, currently I use the library MCU_Friend_kbv, but it is very slow and I want to use yours, this is my tft: [https://www.youtube.com/watch?v=PAPW97X6IRM](video demonstration of use)

Wrong URL in library.properties

There is url=https://github.com/Bodmer/TFT_HX8357_Due in library.properties, pointing out to the Due version of the library. I want it to register in PlatformIO registry.
Thanks

drawBMP and drawRAW SD image loses colors

HI, using this functions images lose colors and they display mainly grey colors also using ImageConverter 565 v2.3 tool the same.
For example I have one with a red background and white text/icon and the background becomes grey.

Using other library they work ok.

This what looks like using your Draw_SDCard_Bitmap example without any changes:
PHOTO_20200608_150331

MEGA support

Hi,

according to README the libraries should work with MEGA, but the Due is ARM based board (Cortex M3) and MEGA is AVR based, so (I guess) this difference brings some errors (missing REG_PIOC_CODR).
Do you know anything about it?

Thanks.

HX8357C on an ESP32

Hi.

I have one of those HX8357C 480x320 16-bit-parallel TFT displays marked as HX8357C that are Mega2560 compatible.

As far as I see, there seems no way to connect them to a ESP32. Right?

Any chance to shift out the 16 bit data via two 74x595?

I have no clue about driving tft displays...

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.