Go Down

Topic: Graphics library for NodeMCU (ESP8266), ESP32 and serial+parallel TFT displays (Read 38014 times) previous topic - next topic

bodmer

Attached is a seasonal sketch, created just for fun!

It is tested on a NodeMCU (ESP8266) board with the latest TFT_eSPI library.

The "snow" falling is animated, here is a screenshot for those that do not have the required setup.



P.S. It is left as an exercise to add the missing apostrophe :-)
Formerly Rowboteer (now a broken user profile!)

TFTLCDCyg

THX bodmer great library, effort colossal!

Happy Christmas and prosperous 2018!


ESP32 Dev Module + ILI9341 2.8" + IDE 1.9.0-beta

bodmer


@TFTLCDCyg

Nice to know it works on an ESP32 and it looks better in landscape mode!

The array then needs to be 16 bits otherwise the "flakes" are only drawn in the first 256 pixels in the x direction:

Code: [Select]

uint16_t flake[NUMFLAKES][3];



Enjoy!
Formerly Rowboteer (now a broken user profile!)

stdr

Hi,

great job. I use this library for an ILI9341 display and the RPi display. It works fine.

I just wonder how to control the backlight of the RPi display. Some websites suggest that a PWM signal could be provided to gpio18 (Raspberry header). That would correspond to pin 12 on the display connector.

I tried that approach without success.

Has anyone managed to dim the backlight?

Thanks in advance.

bodmer

The Waveshare style displays compatible with the library do not have a backlight control pin :-(
Formerly Rowboteer (now a broken user profile!)

bodmer

I had a look at my display and it appears that resistor R5 is the one that supplies the backlight LEDs. If you are into board hacking then you could but the track and add a transistor switch. At your own risk...
Formerly Rowboteer (now a broken user profile!)

bodmer

#171
Feb 23, 2018, 11:30 pm Last Edit: Feb 24, 2018, 08:44 pm by bodmer Reason: Update link to master
I have added anti-aliased fonts to the TFT_eSPI library.

Fonts with configurable size and containing any arbitrary characters, or range of characters, from the Unicode 16bit character set (i.e. Basic Multilingual Plane) can be included using a Processing sketch in the Tools folder of the library. The source font files can be from your PC or selected TrueType (*.ttf and *.otf) files.

Fonts are stored in the ESP8266 or ESP32 SPIFFS FLASH memory.

New examples have been added to demonstrate. At the moment these use the print class. Drawing characters with background over-write and printing in sprites is also supported but I have not included any examples yet.

Screenshots from the examples below:







Formerly Rowboteer (now a broken user profile!)

bodmer

Latest anti-aliased test with an elegant Japanese font shows the benefits of smooth font rendering on a TFT screen. This is a 48pt font:




Formerly Rowboteer (now a broken user profile!)

david_prentice

The Smooth Fonts are impressive.    Especially for your investigation of the VLW format.

I was thinking in terms of a 4-level or 16-level Grayscale for the bitmaps.    Effectively 2x or 4x size of monochrome bitmaps.    I will see what your rendering looks like with a "coarser" colour blend.

My general conclusion is that the glyph overhead and bitmap size makes anti-aliasing impractical for a Uno.   Not impossible for Zero, Due,  Teensy, ...

If I was Japanese,   I would appreciate your example in #172.
Being a Brit,   I am more interested in attractive fonts like Helvetica/Arial.   Less so for the Final-Frontier.

I will let you know the result of my "coarse" GrayScale experiments.
There is always going to be a trade-off between Flash usage and rendering speed.   The typical 240x320 or 320x480 screen is unlikely to need fonts in scalable pitch.  Or more than 2 or 3 fonts in one application.

David.

bodmer

Hi David,

The 2 bit greyscale helps with font appearance but it is noticeably worse on smaller characters.  4 bit is good with little noticeable difference, the 565 16 bit encoding of colours limits the greyscale resolution anyway. You have probably figured out this is easy to test this by adapting the alphaBlend() function.

You will probably also notice that small or fine (single pixel line) fonts look less attractive than simple bitmaps, using larger or bold fonts works well. Italic fonts seem to render well even in small sizes.

Run length encoding is also very effective at reducing the font file size, as is omitting characters that are not needed!

SPIFFS seems to be smart and buffers the font in ~24kbyte blocks so file seeks are fast for each character until a new block of memory has to be loaded, then there is a ~30ms overhead for the next character. Thus it is good to keep the font file size down if fast rendering is needed.

If you use UTF8 encoded characters out of the normal ASCII range, then there is  "gotcha" that puzzled me for a while, the Arduino IDE has a bug where UTF8 characters in the sketch do not get encoded in the compiled code unless the sketch is saved before upload!
Formerly Rowboteer (now a broken user profile!)

bodmer

#175
Feb 26, 2018, 04:19 pm Last Edit: Feb 26, 2018, 04:24 pm by bodmer Reason: Add extra image
I have tested a GNU Free Font, these are the same source fonts that are used by the Adafruit fonts.

To generate the same size character on the screen the point size used in the "Create Font" Processing sketch must be twice the point size used in the Adafruit font name. So to reproduce the Adafruit font size of 12 the point size used in the Processing sketch would be 24. This is all to do with scaling of font point sizes to pixels. The fact that is a nice integer multiplier is handy.

Here is the Adafruit "FreeSans12pt" compared to the same font in 24 point size in the anti-aliased font:



The image is "zoomed in" to exaggerate the anti-aliased greyscale pixels use to smooth the characters.

This is thee equivalent x1 scale:


Formerly Rowboteer (now a broken user profile!)

bodmer

The library now supports 8 bit parallel TFTs with an ESP32. For example UNO style TFT displays made by mcufriend.
Formerly Rowboteer (now a broken user profile!)

Phaedra

Just tested the updated lib with an Uno Board ESP32 parallel ILI9488 and parallel HX8357D (I had to tweak the init/defines) and all is working well.

bodmer

@ Phaedra

Great, thanks for testing.

If you share the changes you made I can update the library!
Formerly Rowboteer (now a broken user profile!)

Dancopy

Hi Stan,

The Weather Station code has been updated on Github and is ready for tests.

Some 2.8" ILI9341 displays turned up today and are working fine, It is nice to have a bigger display so it can be seen at a distance.

Hi Bodmer! I have installed all libraries but it is showing the following:

Arduino: 1.8.5 (Windows 10), Placa:"NodeMCU 1.0 (ESP-12E Module), 80 MHz, 4M (1M SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

In file included from C:\Users\Daniel\Documents\Arduino\libraries\SD\src/utility/Sd2Card.h:26:0,

                 from C:\Users\Daniel\Documents\Arduino\libraries\SD\src/utility/SdFat.h:29,

                 from C:\Users\Daniel\Documents\Arduino\libraries\SD\src/SD.h:20,

                 from C:\Users\Daniel\Documents\Arduino\libraries\JPEGDecoder/JPEGDecoder.h:53,

                 from sketch\GfxUi.h:33,

                 from D:\Arduino\Displays TFT\ILI9341\TFT_ILI9341_ESP by Bodmer\esp8266 Weather Station Color by Bodmer\esp8266-weather-station-color-updated\esp8266-weather-station-color\esp8266-weather-station-color.ino:41:

C:\Users\Daniel\Documents\Arduino\libraries\SD\src/utility/Sd2PinMap.h:510:2: error: #error Architecture or board not supported.

 #error Architecture or board not supported.

  ^

In file included from D:\Arduino\Displays TFT\ILI9341\TFT_ILI9341_ESP by Bodmer\esp8266 Weather Station Color by Bodmer\esp8266-weather-station-color-updated\esp8266-weather-station-color\esp8266-weather-station-color.ino:63:0:

C:\Users\Daniel\Documents\Arduino\libraries\TimeClient/TimeClient.h:27:21: fatal error: ESPWiFi.h: No such file or directory

 #include <ESPWiFi.h>

                     ^

compilation terminated.

exit status 1

Go Up