Skip to content
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

[P116] ST7735/ST7789/ST7796 TFT Plugin and AdafruitGFX helper #3761

Merged

Conversation

tonhuisman
Copy link
Contributor

@tonhuisman tonhuisman commented Aug 13, 2021

  • New plugin P116: ST77xx TFT
    • Supports ST7735s/r 128x128, 128x160, 80x160 pixel TFT 65535 color displays
    • Supports ST7789vw 240x320, 240x240, 240x280, 135x240 pixel TFT 65535 color displays
    • Supports ST7796s 320x480 pixel 65535 color displays
  • Introducing AdafruitGFX_helper class, as a generic interface for all displays using the Adafruit_GFX library
  • Add some optional fonts (1 proportional, 5 fixed width), disabled by default
  • Plugin is included in DISPLAY builds, that have been set to LIMIT_BUILD_SIZE for ESP8266 to acquire some .bin space

Resolves: #836 and a forum request
Resolves: #1226
Resolves: #3012

TODO:

  • Add documentation
  • Improve AdafruitGFX_helper:
    • implement check x/y boundaries
    • correct color reduction for monochrome/low color displays (like eInk 2/3/4/7 colors)
    • implement support for displaying bitmaps (bmp files only) (edit: Added: 2022-03-20)
    • add processing subcommands from template
    • fix proportional font-width issue
  • Apply AdafruitGFX_helper to other graphic display plugins, where possible
    • Refactor P095 ILI9341 plugin to use AdafruitGFX_helper
    • Refactor P096 eInk plugin to use AdafruitGFX_helper
      • Add extra supported displays (UC8151D, SSD1680)
      • Add extra supported display Waveshare 2.7" (264x176px)
      • Add extra supported display Waveshare 1.54" (200x200px)
  • Investigate eInk partial updates: To be implemented in separate PR after completion of this PR.
  • Testing P116 (help wanted 😃 👍)
  • Testing P095
  • Testing P096 (help wanted 😃 👍)
    • Lolin eInk (IL3897) (250x122)
    • UC8151D (212x104)
    • SSD1680 (250x122)
    • Waveshare 2.7" (264x176px)
    • Waveshare 1.54" (200x200px)

@TD-er
Copy link
Member

TD-er commented Aug 14, 2021

Just a tip on libraries...
If you have a PlatformIO account, you can also publish a library version of your own.
Then prefix that library, just with your own account, like Adafruit does. (and I have for a few libraries, using td-er/ )
Only bad thing about it, is that you need to re-publish (and update version) every change you make.
Made that mistake a few times with the ESPEasySerial library that I forgot to publish it again.

@tonhuisman
Copy link
Contributor Author

Thanks for the pointers.
I'm currently always compiling the new helper class, that pulls in the Adafruit GFX library, but that isn't working for the IR builds, f.e., so I'll have to enable it separately.

@TD-er
Copy link
Member

TD-er commented Aug 14, 2021

Well if you're done with the lib changes to make it work with ESPEasy, we can make it into a separate library for our own.
You can also rename it in the library properties in the lib/ dir and mention that in the required libs (not sure if it is needed then...)
We may need to re-think this how to manage it as it is quite often an issue when patching libraries for our own use.

@tonhuisman
Copy link
Contributor Author

The only 'requirement' for this lib is that it doesn't pull in the SD library, as that collides with the ESPEasy SD support. (Some of these TFT displays come with a SD card-slot, that's used to display graphics in some of the examples, and that seems the reason they pull that one in, AFAICS, but I don't want/need to include these examples...)

@tonhuisman
Copy link
Contributor Author

tonhuisman commented May 8, 2022

Locally built Display build for ESP32 that does include the Display plugin set:
ESP_Easy_mega_20220508_display_ESP32_4M316k.zip

(Includes both the OTA-update .bin and Flash tool update .factory.bin files)

@zhangqilaw
Copy link

Locally built Display build for ESP32 that does include the Display plugin set: ESP_Easy_mega_20220508_display_ESP32_4M316k.zip

(Includes both the OTA-update .bin and Flash tool update .factory.bin files)
截屏2022-05-08 21 51 34
截屏2022-05-08 21 50 48
截屏2022-05-08 21 52 30
Command unknown

@tonhuisman
Copy link
Contributor Author

I'll have a look

@tonhuisman
Copy link
Contributor Author

tonhuisman commented May 8, 2022

What output do you get in the log (serial or weblog) when issuing this command? Mine shows:

HTTP: st77xx,bmp,0,0,adabot.bmp
Error  : showBmp: file not found

But that's to be expected, as my unit doesn't have that file uploaded 😉
The response in the UI then also is Command unknown
NB: I've installed the .bin file that I just uploaded.

@tonhuisman
Copy link
Contributor Author

tonhuisman commented May 8, 2022

And when using a filename that is on the filesystem I get this:

Info   : HTTP: st77xx,bmp,0,0,droid80.bmp
Info   : showBmp: bitmap w:80, h:80, dpt:24, colors:16777216, cmp:0, pl:1, x:0, y:0
Info   : showBmp: x: 0, y:0, dw:128, dh:128
Info   : showBmp: Done.

@zhangqilaw
Copy link

And when using a filename that is on the filesystem I get this:

Info   : HTTP: st77xx,bmp,0,0,droid80.bmp
Info   : showBmp: bitmap w:80, h:80, dpt:24, colors:16777216, cmp:0, pl:1, x:0, y:0
Info   : showBmp: x: 0, y:0, dw:128, dh:128
Info   : showBmp: Done.

ok

@zhangqilaw
Copy link

ESP32 IL9341 Same connection method,ESP_Easy_mega_20220328_display_ESP32_4M316k normal display,ESP_Easy_mega_20220427_display_ESP32_4M316k,not display。
IMG_1628

@tonhuisman
Copy link
Contributor Author

ESP_Easy_mega_20220427_display_ESP32_4M316k,not display。

If you connect BLK to VCC, I expect the display to work. An issue regarding PWM on ESP32 has been fixed after the 20220427 release.
If you download and install the Display bin from f.e. this Github Actions build, the backlight control should work again as intended.

@zhangqilaw
Copy link

zhangqilaw commented May 12, 2022 via email

@zhangqilaw
Copy link

1、connect BLK to VCC and Github Actions build can't display content.The screen is white after sending the command(no display Espeasy),reupdate firmware 20220328 display ok
2、I found a new fix,2.4 IL9341 St7789 (240320) and st7796(320480) display can be added, but the color is incorrect.
IMG_1647

@tonhuisman
Copy link
Contributor Author

Can you try the Display build from this Actions run ?, that adds some more supported display models to the ILI9341 plugin (P095).
The ST77xx driver (P116) is not going to work correctly with an ILI934x display, that's for sure.

@zhangqilaw
Copy link

Can you try the Display build from this Actions run ?, that adds some more supported display models to the ILI9341 plugin (P095). The ST77xx driver (P116) is not going to work correctly with an ILI934x display, that's for sure.

update this new firmware [this Actions run](https://github.com/letscontrolit/ESPEasy/actions/runs/2296287234 normal display,
but
IMG_1649
`On System#Boot do
ili9341,clear,red
timerSet,1,10
endon
On Rules#Timer=1 do

 ili9341,txtfull,0,30,2,white,%ip%
 timerset,2,1
 ili9341,txtfull,0,0,3,white,YELLOW,HelloWorld
 ili9341,txtfull,0,60,3,white,%systime%-%uptime%
 ili9341,txtfull,0,100,3,white,Co2[Co2#]
 ili9341,txtfull,0,130,3,white,QNH[perssure#Pressure]
 ili9341,txtfull,0,160,3,white,PM2.5[pm#pm2.5]
 ili9341,txtfull,0,190,3,white,Temp[perssure#Temperature]c
 timerset,1,1

endon`

time display?

@tonhuisman
Copy link
Contributor Author

If you also include a background color in your txtfull subcommand: ili9341,txtfull,0,60,3,white,black,%systime%-%uptime%, then it won't have a transparent bg-color that doesn't erase what's already there, but overwrite any previous text with black 😃

@zhangqilaw
Copy link

How do I enable other fonts in a custom build?
ps:enable whitrabt8pt

@tonhuisman
Copy link
Contributor Author

How do I enable other fonts in a custom build? ps:enable whitrabt8pt

2 ways:

  1. If you have copied Custom-sample.h to Custom.h and enabled the desired plugins, then add a line:
    # define ADAGFX_FONTS_EXTRA_8PT_INCLUDED

  2. If you are just local-building with an existing Display build, then in file AdafruitGFX_helper.h around line 48 enable the define mentioned above, and also disable around line 81 # undef ADAGFX_FONTS_INCLUDED, as it may be in the LIMIT_BUILD_SIZE sets (though in up to date sources from mega branch this is no longer the case for ESP32)

@zhangqilaw
Copy link

How do I enable other fonts in a custom build? ps:enable whitrabt8pt

2 ways:

  1. If you have copied Custom-sample.h to Custom.h and enabled the desired plugins, then add a line:
    # define ADAGFX_FONTS_EXTRA_8PT_INCLUDED
  2. If you are just local-building with an existing Display build, then in file AdafruitGFX_helper.h around line 48 enable the define mentioned above, and also disable around line 81 # undef ADAGFX_FONTS_INCLUDED, as it may be in the LIMIT_BUILD_SIZE sets (though in up to date sources from mega branch this is no longer the case for ESP32)

Can I add fonts that are not in the library separately?

for example:Roboto Font Family

@tonhuisman
Copy link
Contributor Author

Fonts have to be converted to data, and compiled into the bin before they can be used.
I've added 3 fonts, Roboto, RobotoCondensed (both proportional width) and RobotoMono (fixed width) in 3 sizes, 8pt, 12pt and 16pt to a custom build for testing.
This build is based on the current mega branch, and has all fonts explicitly enabled. For regular MAX builds, that already have had all fonts included until now, I'll only enable the RobotoMono fonts (they seem the most usable), and leave the others as optional for a local custom build. This will be in a new PR soon.

ESP_Easy_mega_20220515_custom_ESP32_4M316k.zip

@zhangqilaw
Copy link

Fonts have to be converted to data, and compiled into the bin before they can be used. I've added 3 fonts, Roboto, RobotoCondensed (both proportional width) and RobotoMono (fixed width) in 3 sizes, 8pt, 12pt and 16pt to a custom build for testing. This build is based on the current mega branch, and has all fonts explicitly enabled. For regular MAX builds, that already have had all fonts included until now, I'll only enable the RobotoMono fonts (they seem the most usable), and leave the others as optional for a local custom build. This will be in a new PR soon.

ESP_Easy_mega_20220515_custom_ESP32_4M316k.zip
截屏2022-05-16 下午4 28 31

@TD-er
Copy link
Member

TD-er commented May 16, 2022

Ah after deleting my downloaded files, I got a similar error.
Can you change in platformio_core_defs.ini this section:

[core_esp32_IDF4_4__2_0_3]
platform                    = https://github.com/tasmota/platform-espressif32/releases/download/v.2.0.3/platform-espressif32-v.2.0.3.zip

Leave the rest as is.

If that still results in errors, please delete te following (selected) folders in your user home dir in .platformio:
image

Then you may need to call a "clean All" build (which results in an error) and then again make a new build.

@zhangqilaw
Copy link

zhangqilaw commented May 18, 2022

https://github.com/tasmota/platform-espressif32/releases/download/v.2.0.3/platform-espressif32-v.2.0.3.zip
IMG_1854
IMG_1855
font display overlay

rules:
On System#Boot do
ili9341,clear
timerSet,1,10
endon
On Rules#Timer=1 do
timerset,2,1
ili9341,font,default
ili9341,txtfull,2,0,2,green,black,%sysyear%/%sysmonth%/%sysday%
ili9341,txtfull,2,18,2,green,black,%systime%
ili9341,font,roboto8pt
ili9341,txtfull,2,75,1,white,black,TAT:[perssure#Temperature]°C
ili9341,txtfull,2,105,1,white,black,QNH:[perssure#Pressure]
ili9341,txtfull,20,140,1,white,black,PM:[pm#pm2.5]
ili9341,txtfull,2,175,1,white,black,Co2:[Co2#]
timerset,1,1
endon

@tonhuisman
Copy link
Contributor Author

Does that work better if you do not use the roboto8pt font?, or use robotomono8pt?

@zhangqilaw
Copy link

Does that work better if you do not use the roboto8pt font?, or use robotomono8pt?
101652880447_ pic
111652880448_ pic
If you use the default font, the display is normal, with roboto8pt or robotomono, the numbers will be displayed by the robot.
st77xx

On System#Boot do
st77xx,clear
timerSet,1,10
endon
On Rules#Timer=1 do
timerset,2,1
st77xx,font,robotomono8pt
st77xx,txtfull,0,60,1,white,black,%systime%
//-%uptime%

 timerset,1,1

endon

@tonhuisman
Copy link
Contributor Author

Hm, it gets quite confusing if you show alternating the ILI9xxx and the ST77xx displays. The net result will be the same on both (they use the same code for displaying), so please keep it to 1 display/rules version you share.

Possible cause is that the space character for this font isn't wide enough (or 0) to wipe out the previous content. I'll have a look.

@zhangqilaw
Copy link

Hm, it gets quite confusing if you show alternating the ILI9xxx and the ST77xx displays. The net result will be the same on both (they use the same code for displaying), so please keep it to 1 display/rules version you share.

Possible cause is that the space character for this font isn't wide enough (or 0) to wipe out the previous content. I'll have a look.

I tested ili9341 and st37xx, both of which have the same problem. Maybe font isn't wide enough (or 0),Which piece of code should be modified?

@TD-er
Copy link
Member

TD-er commented May 18, 2022

The colon on the last picture also doesn't look like it is monospaced.
So perhaps the font doesn't have proper widths reported in the font?

@zhangqilaw
Copy link

The colon on the last picture also doesn't look like it is monospaced. So perhaps the font doesn't have proper widths reported in the font?
截屏2022-05-19 上午10 36 24

@tonhuisman
Copy link
Contributor Author

The true in that calculateTextMetrics() call indicates it is a proportionally spaced font.

I'm working on fixes in this area, just haven't ironed out all the wrinkles yet.

@TD-er
Copy link
Member

TD-er commented May 19, 2022

I'm working on fixes in this area, just haven't ironed out all the wrinkles yet.

But with ironing out the wrinkles, you make it monospaced again ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document new plugins (TFT plugin) Add support for the Wemos ST7735S display Feature request color display
5 participants