Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
TFT DisplaysIntroduction | ||||||||
Line: 13 to 13 | ||||||||
The 1.4" display is already quite a bit better even though 128x128 bit resolution is still not enough for sophisticated graphics. It is enough however to write a few lines of text and produce simple graphics, e.g. creating a graph of sensor readout results. | ||||||||
Changed: | ||||||||
< < | The 2.4" display is clearly the most powerful device, adding touch functionality. It is however so big that it is difficult to plug it onto the WeMos D1 bus, even if the connector is available. The better solution is an adapter board and a connecting cable. | |||||||
> > | The 2.4" display is clearly the most powerful device, adding touch functionality. It is however so big that it is difficult to plug it onto the WeMos D1 bus, even if the connector is available. The better solution is an adapter board and a connecting cable.This display board also features a touch screen and is one of the boards supported by the lvgl Graphical User Interface (GUI) library. | |||||||
Since the 1.4" display is enough for most our applications, it can be nicely plugged onto the bus just like any other sensor or actuator shield and it is substantially cheaper than the 2.4" solution, this is the device we chose for the course.
Preparing the hardware |
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
TFT DisplaysIntroduction | ||||||||
Line: 162 to 161 | ||||||||
| ||||||||
Changed: | ||||||||
< < | As explained above, text writing in different fonts is not exactly easy. While the original SSD1351 driver loaded its fonts from C files before using them, a procedure which could take several tens of seconds, the new version uses the same fonts but converted into Python code and stored in flash together with access methods to get the pixel information. Now, no font loading is necessary any more and text drawing becomes very fast. The text drawing demo | |||||||
> > | As explained above, text writing in different fonts is not exactly easy. While the original SSD1351 driver loaded its fonts from C files before using them, a procedure which could take several tens of seconds, the new version uses the same fonts but converted into Python code and stored in flash together with access methods to get the pixel information. Now, no font loading is necessary any more and text drawing becomes very fast. The text drawing demo | |||||||
| ||||||||
Changed: | ||||||||
< < | ||||||||
> > | You can find the source code of the demos on the github repository![]() | |||||||
Video gamesIn the list of demos for the SSD1351 driver you even find 2 simple video games: |
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
TFT DisplaysIntroduction | ||||||||
Line: 173 to 174 | ||||||||
Both games need additional hardware: a joystick in case of Super Mario and a linear potentiometer in the case of Arkanoid. demo-mario orriginally used a Bluetooth based joystick, which we don't have. I therefore replaced it with the analogue joystick from our sensor kit. Of course the software needed to be adapted correspondingly.
| ||||||||
Changed: | ||||||||
< < |
| |||||||
> > |
| |||||||
GUI elements in nanogui | ||||||||
Line: 189 to 190 | ||||||||
to work with the ST7735 driver. I did not try alevel.py, written for the pyboard and making use of its accelerometer, which is not available on our ESP32 board. The color95.py program showing the meters, was adapted to present temperature and humidity values from SHT30 measurements and I created a "Scale" widget to be used as a voltmeter in conjunction with the ESP32 ADC.Particularly interesting is also the fplot.py library allowing to plot data in cartesian or polar coordinate and which has the facility to take data in real time as they are produced by the sensor. For more details please refer to https://github.com/peterhinch/micropython-nano-gui![]() | ||||||||
Added: | ||||||||
> > |
| |||||||
The clock is Peter's original clock program adapted to the ST7735. The SHT30 meters are meter widgets from nanogui connected to real measurements from the SHT30. Yes, also in Europe we can have Ghanaian temperatures! even though relative humidity is substantially lower. | ||||||||
Changed: | ||||||||
< < | The voltmeter meter application uses a Scale widget, not part of nanogui. Peter has supplied a superclass DObject (displayable object) from which the Scale widget is derived. The demo connects to the ESP32 ADC to display measured signal levels. | |||||||
> > | The voltmeter meter application uses a Scale widget, not part of nanogui. Peter has supplied a superclass DObject (displayable object) from which the Scale widget is derived. The demo connects to the ESP32 ADC to display measured signal levels. | |||||||
PlottingPeter's nanogui repository also contains a plotting package called fplot. This package allows to produce cartesian and polar plots to be generated. Particularly interesting is a feature that allows to add real time measurements to plots as they come in. | ||||||||
Added: | ||||||||
> > | Again a few examples:
| |||||||
-- ![]() Comments | ||||||||
Line: 231 to 238 | ||||||||
| ||||||||
Added: | ||||||||
> > |
|
Line: 1 to 1 | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
TFT DisplaysIntroduction | |||||||||||||||
Line: 157 to 156 | |||||||||||||||
Again a have a few photos for you:
| |||||||||||||||
Changed: | |||||||||||||||
< < |
![]() | ||||||||||||||
> > |
| ||||||||||||||
| |||||||||||||||
Deleted: | |||||||||||||||
< < | ![]() | ||||||||||||||
| |||||||||||||||
Changed: | |||||||||||||||
< < | ![]() | ||||||||||||||
> > |
| ||||||||||||||
As explained above, text writing in different fonts is not exactly easy. While the original SSD1351 driver loaded its fonts from C files before using them, a procedure which could take several tens of seconds, the new version uses the same fonts but converted into Python code and stored in flash together with access methods to get the pixel information. Now, no font loading is necessary any more and text drawing becomes very fast. The text drawing demo
| |||||||||||||||
Line: 169 to 164 | |||||||||||||||
As explained above, text writing in different fonts is not exactly easy. While the original SSD1351 driver loaded its fonts from C files before using them, a procedure which could take several tens of seconds, the new version uses the same fonts but converted into Python code and stored in flash together with access methods to get the pixel information. Now, no font loading is necessary any more and text drawing becomes very fast. The text drawing demo
| |||||||||||||||
Added: | |||||||||||||||
> > | |||||||||||||||
| |||||||||||||||
Added: | |||||||||||||||
> > |
Video gamesIn the list of demos for the SSD1351 driver you even find 2 simple video games: Both games need additional hardware: a joystick in case of Super Mario and a linear potentiometer in the case of Arkanoid. demo-mario orriginally used a Bluetooth based joystick, which we don't have. I therefore replaced it with the analogue joystick from our sensor kit. Of course the software needed to be adapted correspondingly.
GUI elements in nanoguiPeter Hinch's nanogui library contains a few widgets that can be used to graphically display sensor results. Their number is fairly limited (that is why Peter calls it nanogui) but extensions are possible if needed. nanogui contains:
![]() PlottingPeter's nanogui repository also contains a plotting package called fplot. This package allows to produce cartesian and polar plots to be generated. Particularly interesting is a feature that allows to add real time measurements to plots as they come in. | ||||||||||||||
-- ![]() Comments | |||||||||||||||
Line: 197 to 224 | |||||||||||||||
| |||||||||||||||
Added: | |||||||||||||||
> > |
|
Line: 1 to 1 | |||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
TFT DisplaysIntroduction | |||||||||||||||||||||||||||||
Line: 67 to 67 | |||||||||||||||||||||||||||||
Finally I copied the fonts into the modules/fonts directory of the MicroPython sources and froze them into the binary. You can use the fonts by importing the MicroPython module: | |||||||||||||||||||||||||||||
Deleted: | |||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||
from ST7735 import Display, color565 import fonts/sysfont as sysfont sck = Pin(18) miso= Pin(19) mosi= Pin(23) SPI_CS = 26 SPI_DC = 5 spi = SPI(2, baudrate=32000000, sck=sck, mosi=mosi, miso=miso) display=Display(spi,SPI_CS,SPI_DC) display.draw_text(0, 0, 'Hello World!', sysfont, color565(255, 0, 0)) | |||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||
< < | In addition to font handling I received a link to micropython-nano-gui![]() | ||||||||||||||||||||||||||||
> > | In addition to font handling I received a link to micropython-nano-gui![]() | ||||||||||||||||||||||||||||
The frame bufferThere are two different approaches to the display driver: | |||||||||||||||||||||||||||||
Line: 130 to 129 | |||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||
The demosFrom my tests with the SSD1306 driver I had | |||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||
> > |
![]()
![]()
![]()
| ||||||||||||||||||||||||||||
-- ![]() | |||||||||||||||||||||||||||||
Line: 151 to 182 | |||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||
> > |
|
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
TFT DisplaysIntroduction | ||||||||
Line: 83 to 83 | ||||||||
| ||||||||
Changed: | ||||||||
< < |
| |||||||
> > |
| |||||||
I set myself the goal to write a driver which was capable of running all of these demo programs. I ended up writing a class with methods implementing both design principles. There is a method | ||||||||
Line: 92 to 92 | ||||||||
When using the frame buffer method you have to call the show() method to copy the framebuf memory to the hardware to make the drawing visible. Here are the methods: | ||||||||
Added: | ||||||||
> > | These first methods write to the hardware directly | |||||||
| ||||||||
Line: 113 to 115 | ||||||||
| ||||||||
Added: | ||||||||
> > | and these pass through the framebuffer:
The demosFrom my tests with the SSD1306 driver I had
| |||||||
-- ![]() |
Line: 1 to 1 | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
TFT DisplaysIntroduction | |||||||||||||||||||||
Line: 54 to 54 | |||||||||||||||||||||
Fonts are normally loaded into RAM before use. However, this takes time and uses a big amount of RAM memory, a very scarce resource on the standard ESP32. (We are using an ESP32 with additional PSRAM where the problem is much less critical). | |||||||||||||||||||||
Changed: | |||||||||||||||||||||
< < | Since font loading in the SSD1351 driver takes ages (the demo-font program using 9 different fonts took ~ 30s before the first character could be written. After that text writing was fast) I searched for another method and ended up asking the MicroPython forum. I got a link to the micropython-font-to-py![]() | ||||||||||||||||||||
> > | Since font loading in the SSD1351 driver takes ages (the demo-font program using 9 different fonts took ~ 30s before the first character could be written. After that text writing was fast) I searched for another method and ended up asking the MicroPython forum. Peter Hinch sent me a link to his micropython-font-to-py![]() | ||||||||||||||||||||
The problem was now how to convert the font files in C supplied with the SSD1351 driver to Python font files compatible with micropython-font-to-py. I wrote a Python script: | |||||||||||||||||||||
Line: 67 to 67 | |||||||||||||||||||||
Finally I copied the fonts into the modules/fonts directory of the MicroPython sources and froze them into the binary. You can use the fonts by importing the MicroPython module: | |||||||||||||||||||||
Changed: | |||||||||||||||||||||
< < | from ST7735 import Display, color565 import fonts/sysfont as sysfont sck = Pin(18) miso= Pin(19) mosi= Pin(23) SPI_CS = 26 SPI_DC = 5 spi = SPI(2, baudrate=32000000, sck=sck, mosi=mosi, miso=miso) display=Display(spi,SPI_CS,SPI_DC) display.draw_text(0, 0, 'Hello World!', sysfont, color565(255, 0, 0)) | ||||||||||||||||||||
> > |
from ST7735 import Display, color565 import fonts/sysfont as sysfont sck = Pin(18) miso= Pin(19) mosi= Pin(23) SPI_CS = 26 SPI_DC = 5 spi = SPI(2, baudrate=32000000, sck=sck, mosi=mosi, miso=miso) display=Display(spi,SPI_CS,SPI_DC) display.draw_text(0, 0, 'Hello World!', sysfont, color565(255, 0, 0)) In addition to font handling I received a link to micropython-nano-gui ![]() The frame bufferThere are two different approaches to the display driver:
The goalI now had:
| ||||||||||||||||||||
-- ![]() | |||||||||||||||||||||
Line: 81 to 126 | |||||||||||||||||||||
| |||||||||||||||||||||
Added: | |||||||||||||||||||||
> > |
|
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
TFT DisplaysIntroduction | ||||||||
Line: 56 to 56 | ||||||||
Since font loading in the SSD1351 driver takes ages (the demo-font program using 9 different fonts took ~ 30s before the first character could be written. After that text writing was fast) I searched for another method and ended up asking the MicroPython forum. I got a link to the micropython-font-to-py![]() | ||||||||
Changed: | ||||||||
< < | The problem was now how to convert the font files in C supplied with the SSD1351 driver to Python font files compatible with micropython-font-to-py. I wrote a Python script doing exactly this. The output is actually executable (on the PC) and will print the pixel data of the letter "A" for this font. | |||||||
> > | The problem was now how to convert the font files in C supplied with the SSD1351 driver to Python font files compatible with micropython-font-to-py. I wrote a Python script: https://iotworkshop.africa/pub/IoT_Course_English/TFTDisplay/convertFont.py.txt doing exactly this. The output is actually executable (on the PC) and will print the pixel data of the letter "A" for this font. | |||||||
![]() | ||||||||
Line: 76 to 80 | ||||||||
| ||||||||
Added: | ||||||||
> > |
|
Line: 1 to 1 | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
TFT DisplaysIntroduction | |||||||||||||
Line: 11 to 11 | |||||||||||||
| |||||||||||||
Changed: | |||||||||||||
< < | The 1.4" display is already quite a bit better even though 128x128 bit resolution is still not enough for sophisticated graphics. It is enough however to write a few lines of text and produce simply graphics, e.g. creating a graph of sensor readout results. | ||||||||||||
> > | The 1.4" display is already quite a bit better even though 128x128 bit resolution is still not enough for sophisticated graphics. It is enough however to write a few lines of text and produce simple graphics, e.g. creating a graph of sensor readout results. | ||||||||||||
The 2.4" display is clearly the most powerful device, adding touch functionality. It is however so big that it is difficult to plug it onto the WeMos D1 bus, even if the connector is available. The better solution is an adapter board and a connecting cable. | |||||||||||||
Line: 29 to 29 | |||||||||||||
The driver software | |||||||||||||
Changed: | |||||||||||||
< < | Searching the Internet I found many display drivers none of which really satisfied me: | ||||||||||||
> > | Searching the Internet I found many display drivers, none of which really satisfied me.
| ||||||||||||
| |||||||||||||
Changed: | |||||||||||||
< < |
| ||||||||||||
> > |
| ||||||||||||
| |||||||||||||
Added: | |||||||||||||
> > | Developing our own driverThe first goal for our own driver was to be able to run all the demo programs on it. Since the calling sequences of the drivers are different (different method names, different way to pass parameters) some modifications to the demo code was of course necessary. In addition the method names and parameters defined in the framebuffer should be available. Comparing the original ST7735 driver to the SSD1351 one we see the following differences
FontsFonts are normally loaded into RAM before use. However, this takes time and uses a big amount of RAM memory, a very scarce resource on the standard ESP32. (We are using an ESP32 with additional PSRAM where the problem is much less critical). Since font loading in the SSD1351 driver takes ages (the demo-font program using 9 different fonts took ~ 30s before the first character could be written. After that text writing was fast) I searched for another method and ended up asking the MicroPython forum. I got a link to the micropython-font-to-py![]() ![]() miso= Pin(19) mosi= Pin(23) SPI_CS = 26 SPI_DC = 5 spi = SPI(2, baudrate=32000000, sck=sck, mosi=mosi, miso=miso) display=Display(spi,SPI_CS,SPI_DC) display.draw_text(0, 0, 'Hello World!', sysfont, color565(255, 0, 0)) | ||||||||||||
-- ![]() Comments | |||||||||||||
Line: 47 to 75 | |||||||||||||
| |||||||||||||
Added: | |||||||||||||
> > |
|
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
TFT DisplaysIntroductionA wide range of displays is available for use with the Arduino system. For the WeMos D1 mini system I found 3 display boards. Each of them is based a on different controller chip and has different resolution. Here they are are: | ||||||||
Changed: | ||||||||
< < |
| |||||||
> > |
| |||||||
| ||||||||
Changed: | ||||||||
< < |
| |||||||
> > |
| |||||||
| ||||||||
Changed: | ||||||||
< < | Each of them has its advantages and disadvantages. The 0.96" display is really tiny and its resolution is very limited allowing to write just a few characters. The 1.4" display is already quite a bit better even though 128x128 bit resolution is still not enough for sophisticated graphics. It is enough however to write a few lines of text and produce simply graphics, e.g. to create a graph of sensor readout results. | |||||||
> > | Each of them has its advantages and disadvantages. The 0.66" display is really tiny and its resolution is very limited allowing to write just a few characters. In addition it is monochrome only. However, the reference display driver included in MicroPython uses this controller chip. There are also higher resolution and color screens using this controller but I did not find one with the WeMos D1 mini bus interface. | |||||||
Changed: | ||||||||
< < | The 2.4" display is clearly the most powerful device, adding touch functionality. It is however so big that it is difficult to plug it onto the WeMos D1 bus, even it the connector is available. The better solution is an adapter board an a connecting cable. | |||||||
> > | The 1.4" display is already quite a bit better even though 128x128 bit resolution is still not enough for sophisticated graphics. It is enough however to write a few lines of text and produce simply graphics, e.g. creating a graph of sensor readout results. The 2.4" display is clearly the most powerful device, adding touch functionality. It is however so big that it is difficult to plug it onto the WeMos D1 bus, even if the connector is available. The better solution is an adapter board and a connecting cable. | |||||||
Since the 1.4" display is enough for most our applications, it can be nicely plugged onto the bus just like any other sensor or actuator shield and it is substantially cheaper than the 2.4" solution, this is the device we chose for the course. | ||||||||
Added: | ||||||||
> > | Preparing the hardwareBefore using the display its solder jumpers on the back must be configured. There are 4 solder fields for configuration
![]() | |||||||
The driver softwareSearching the Internet I found many display drivers none of which really satisfied me: | ||||||||
Line: 33 to 46 | ||||||||
| ||||||||
Added: | ||||||||
> > |
|
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
TFT DisplaysIntroduction | ||||||||
Changed: | ||||||||
< < | A wide range of displays is available for use with the Arduino system. These displays are based on different controller chips and exist for a large range of resolutions. Examples are: | |||||||
> > | A wide range of displays is available for use with the Arduino system. For the WeMos D1 mini system I found 3 display boards. Each of them is based a on different controller chip and has different resolution. Here they are are: | |||||||
| ||||||||
Added: | ||||||||
> > | Each of them has its advantages and disadvantages. The 0.96" display is really tiny and its resolution is very limited allowing to write just a few characters. The 1.4" display is already quite a bit better even though 128x128 bit resolution is still not enough for sophisticated graphics. It is enough however to write a few lines of text and produce simply graphics, e.g. to create a graph of sensor readout results. | |||||||
Changed: | ||||||||
< < | Article text. | |||||||
> > | The 2.4" display is clearly the most powerful device, adding touch functionality. It is however so big that it is difficult to plug it onto the WeMos D1 bus, even it the connector is available. The better solution is an adapter board an a connecting cable. | |||||||
Added: | ||||||||
> > | Since the 1.4" display is enough for most our applications, it can be nicely plugged onto the bus just like any other sensor or actuator shield and it is substantially cheaper than the 2.4" solution, this is the device we chose for the course.
The driver softwareSearching the Internet I found many display drivers none of which really satisfied me:
| |||||||
-- ![]() Comments |
Line: 1 to 1 | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Added: | |||||||||||||||
> > |
TFT DisplaysIntroductionA wide range of displays is available for use with the Arduino system. These displays are based on different controller chips and exist for a large range of resolutions. Examples are:
![]() Comments
|