-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TFT_eSPI library documentation #415
Comments
Writing support documentation has been on my "To Do" list for a long time. It would take many hours to do this and at the moment I am busy with paid work. I can help with more specific questions that have short answers! |
I understand you. Years ago, I wrote a lot of code. These were Pascal and assembler times :-). I quickly learned to comment very accurately at the time of writing. I know that in the future I won't have time for this. Yes. I have a specific problem, although I don't know if it will be a "short answer" ;-) With the help of your library, I can use several types of fonts. I can't handle them. The examples show the use of different types, but never all at once. Sometimes the files needed to use them are in the sample script folders. I can't handle setting up my own script with Local custom fonts, Free Fonts, TrueType fonts.... There are also many ways to use them:
It's probably not all font functions. Which fonts does it apply to? I would be grateful if you could help me learn how to use fonts. |
I have sympathy for you as there are so many options. The library is based on an old (2015) version of the Adafruit_ILI9341 + GFX library. At he time the library only had a very simple small 7x5 bitmap font which was not nice when scaled up and used on TFTs, so I created a new font format and published the library for the humble UNO here. This introduced the concept of numbered fonts. The original Adafruit bitmap being Font 1. The ones I added were Fonts 2, 4, 6, 7 and 8. Each one having increasing size and font 7 being a 7 segment font. To use say font 4 you then just use: An alternative to these two lines is: The "TFT_Rainbow_one_lib" example would be a good one to look at. Adafruit finally decided to add a new font format that I call Free Fonts. To retain compatibility with the Adafruit library I added these. To use these fonts you need to use for example: tft.setFreeFont (MYFONT32); // Select the free font Unfortunately the Free Fonts do not render well in small sizes as they tend to have jagged edges due to stray pixels on curves (usually 8's look terrible). Since the ESP8266 and ESP32 have SPIFFS I had a light bulb moment and realised that anti-aliased fonts could be accommodated. To use these you have to load the font first as shown in Font Demo 1,2,3,4. For example: tft.loadFont(AA_FONT_SMALL); // Must load the font first After you have unloaded the font the previous bitmap font methods can be used: I know this can be confusing but this is down to the way the library has evolved. The drawString(...) and font formatting (tft.setDatum(...) etc) will work with any of the fonts. The Adafruit font rendering is a little crude, you have to use tft.setCursor(x,y) then tft.print(...). I wanted to be able to set the text datum, so for example text could easily be drawn in the middle of a box. So I introduced the drawString() function and the setDatum() function. Because short numbers and strings do not fully over-write larger one drawn on screen previously I added the setTextPadding(pixel_width) function. To use this you must define both foreground text colours and background ones. I will try to create an example this weekwnd that supports all the fonts but I cannot guarantee I will find the time so it is worth experimenting. If you tell me exactly what you wish to display and which font you want to use then I can give you some guidance. |
I am very, very grateful to you for these clarifications. It's worth putting them on Git for others. |
Ditto, I am trying to figure out exactly how the text datum and drawstring functions work, but I am still not understanding it. The example could be made a little clearer for now as an alternative. There just seems to be too many conditionals. If smooth font , padding, etc. "Normally strings are printed relative to the top left corner but this can be Top left corner of what? Doesn't the adafruit library use bottom left corner for glyph fonts? Also what is drawRightString, drawCenterString ? I tried enabling PADDING_DEBUG, but still not seeing any change or borders.. , or any difference using different textDatums.. I guess I will play with the string align example, but it needs some comments or serial prints I think. |
Ok I think I get it now. I think it is a just a confusing example. Why not add a method to pass in the alignment to the function also, instead of a global toggle? I will rewrite this to be a little cleared and PR it. |
I think the "Free_Font_Demo" example will help you. This part of the sketch shows the datum marker on the screen and the text. |
I will check that one out. This was also confusing in the stringalign sketch, invisible stuff tft.setTextColor(TFT_BLACK);
tft.drawString("X",160,180,2); |
oh that is perfect, much better example of textDatum |
Just wanted to add that your library is very useful! However, the documentation of the library is quite hard for a beginner. Would you take PRs on simple documentation even if it was not the complete set of methods that your library provides? |
Thanks. I have created a separate empty repository for the time being so you can push PR's there. |
I have and ESP32-32 WROVER with 4MB PSRAM. I'm making use of SPRITES but am finding that I am running out of memory. Your documentation mentioned that PSRAM is the answer. Any hints on how to configure PlatformIO so that I can use the PSRAM and get bigger sprites? Might be a good addition to future documentation. |
The Arduno IDE has a menu option to enable PSRAM. Once enabled the Sprites are automatically put in PSRAM. I do not use PlatformIO, but I assume there would be a way to enable it. |
I saw that the Arduino IDE allowed the option but I did not see any changes when I turned it on. So I moved over to PIO. If the PSRAM is automatic, I must have other problems. Does deletesprite |
Deallocate memory from the heap? |
Looking at createSprite.cpp, I see treatment for PSRAM configuration and the use of ps_calloc. Should the deleteSprite do the reverse? |
As far as I am aware "free" works for PSRAM. |
I think this is where I'm having a problem. I can't figure out what exactly goes into the platfomio.ini file. Thanks for the quick replies. |
I meant to add a link to the article here. Worth a read as it shows how to see the PSRAM size etc and wwhat to add to the plaatformio.ini file. |
Thanks much. I've managed to get the PSRAM activated (actually per that very same article). Confirmed with ESP. getFreePsram(). The problem I now have is a core 1 panic. Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled. Thanks for the replies - I know this is a problem tracking, not support assistance. |
So I've managed to get the PSRAM recognized, problem is I now get a consistent core panic (below). Any ideas what is causing this? (notice the createSprite call. platformio.ini file: [env:esp32dev] SPRAM2: 4294967041 Backtrace: 0x4008ebaf:0x3ffcbf10 0x4008f1ba:0x3ffcbf30 0x40087e18:0x3ffcbf50 0x400880bb:0x3ffcbf70 0x40081edb:0x3ffcbf90 0x400d8547:0x3ffcbfb0 0x400d8601:0x3ffcbfd0 0x400d353f:0x3ffcbff0 0x400d4071:0x3ffcc040 0x400e6309:0x3ffcc0c0 0x4008bca1:0x3ffcc0e0 |
I am unable to decipher the possible cause from the debug output. Can you provide a complete example sketch that demonstrates the problem and will run on a minimal ESP32 plus display setup. |
Hello Bodmer, For testing and learning purpose, I would like to replace one of your images. When the ESP32 start there is nothing displayed; 'black screen - black scren' and reboot. **ets Jun 8 2016 00:22:57 rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
|
Ok foud solution encode on 'RAW' C ;-) site found here :https://lvgl.io/tools/imageconverter |
Hello everybody, |
There is a way to do that if you define a viewport first. See examle here: |
Hi, I just using the TFT_eSPI library for displaying images that are loaded in 16bit hex format and using tft.pushImage function for displaying a loaded images in ST7735 Driver Display. I need to know how to change the image's color in case it change from white to green without changing the original data in array. Is there any function for changing the colour of image? |
I am having so confusions with the pins and its interface with ESP32. |
I strongly recommend to do a google search and read some articles about SPI bus usage. There is no standard to name the SPI relevant pins in a consistent manner. That causes a lot of confusion for new SPI users. As their is still no golden solution after all this years (who the heck started this crap?) you will have to remember the names in use to be able to "translate" the SPI pins. The easiest is to use HW SPI. Check pin definition of used library and compare with ESP32 pinout. Learn from googled sources that the ESP32 has two separate SPI interfaces, often labeled as VSPI and HSPI and why it is better not to mix them up. I found I2C in the beginning easier to use, but once you understood it does make not much difference anymore. And SPI is faster :-) |
Would be nice if somebody finds the time and will to help Mr. Bodmer. Gifted programmers prefer IMHO creative tasks and writing documentation seems to be less so. I am sure we can get help from him once we found a start. However there is a existing and tested workaround for this problem if you happen to be a LINUX user: Use grep. Like so: Go to the (library) folder where you want to search. Open terminal. Type, for example ,grep -nri "drawstring" and then enter. This will give you (for TFT_eSPI) an output also containing TFT_eSPI.h:641: drawString(const char *string, int32_t x, int32_t y, uint8_t font), // Draw string using specified font number from which you learn that the first parameter is the string you want to draw. 2nd and 3rd are xy coordinates and forth is the font. Headerfiles and Grep together gives documentation! On a legacy OS you might want to try this link: https://gnuwin32.sourceforge.net/packages/grep.htm |
Hello. Tell me how can I change the font? |
Hello and welcome, everyone! Marc |
Hello! In my current project, I use ESP32 and display with ILI9341. I would like to use your library, but - as a beginner - I have a lot of trouble with that. Is there somewhere documentation that describes the operation of all library functions? Eg:
tft.drawString (.....)
has four parameters, but what? What is thetext datum
? ...Of course, I will laboriously find explanations in the examples. But if there is documentation, it will be easier and faster.
Tomasz
The text was updated successfully, but these errors were encountered: