I bought this screen (ST7789) to use it with an ESP8266 as a cheap internet connected display.
Unfortunately it was harder to find the right library to use it than I would have thought, so I figure out it would be helpful to explain it.
Here is how I manage to display an image without an SD card.
EDIT : I previously used Arduino_STT7789 library ,in the video, which was buggy / slow. I now use TFT_eSPI which will display our image really fast.
Install / Setup TFT_eSPI libraryFirst we need to install the TFT_eSPI library.
We have to modify User_Setup.h inside the library to setup our screen, but once it is done it will works with every sketches.
Download my example here : https://github.com/maditnerd/st7789_bitmap
You can also find this file in my github repo inside the User_Setup folder.
- Install TFT_eSPI using the Library Manager
- Go to your libraries folder (on Windows it is Documents/Arduino/libraries)
- Go inside TFT_eSPI folder and open User_Setup.h
- Replace User_Setup.h with my file
You can find a diagram at the end of this tutorial.
- D5 --> SCL (Hardware SPI)
- D7 --> SDA (Hardware SPI)
- D0 --> RES (can be change)
- D1 --> DC (can be change)
You can test any examples available in TFT_eSPI or test my code which display an image.
Convert an image to codeSo what if you don't want to draw mercy (or any kind of support) :-) ?
The image is saved inside bitmap.h, you need to convert your image into code and copy paste it inside the array.
To do this, we will use LCD image converter.You can find it here : https://sourceforge.net/projects/lcd-image-converter/
- Resize your image to the size of your screen (240x240)
- Click on New Image
- Go to Image / Import and choose your image
- Go to Options / Conversion
- Choose Preset : Color R5G6B5
- Go to the Image Tab
- Change Block Size to 16bit
- Click on Show Preview
- Copy all the code
- Paste it inside the array
const uint16_t mercy [] PROGMEM = {// --> PASTE HERE};
That's it, upload the code, and it should display your image.
Note: There is an example inside TFT_eSPI library to decode jpeg file inside 160x128/TFT_flash_jpg. It is of course slower to load but could be useful.
Build a small versionCase STL file is available at the end of this tutorial
In order to reduce the size, I had to remove the pins on the screen
And then I used 30 AWG Wrapping Cable.
After that, I solder the screen on my wemos mini pro clone.
Afterwards, put some electrical tape on the screen to avoid short-circuits.
Finally you just have to print the case.https://www.thingiverse.com/thing:3509423
That's it for this tutorial.
You can follow me on twitter, if you want to know what I will do next with this screen : https://twitter.com/m4dnerd
Comments