Difference: TFTDisplay (7 vs. 8)

Revision 82020-07-27 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

TFT Displays

Introduction

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 a lightweight and minimal MicroPython GUI library for display drivers based on th e framebuf class. This library contains a few widgets to display sensor data and includes a plot library.
>
>
In addition to font handling I received a link to micropython-nano-gui a lightweight and minimal MicroPython GUI library for display drivers based on the framebuf class. This library contains a few widgets to display sensor data and includes a plot library.
 

The frame buffer

There are two different approaches to the display driver:

Line: 130 to 129
 
  • fill_ellipse(x0, y0, a, b, color)
  • fill_polygon(sides, x0, y0, r, color, rotate=0)
  • letter(self, x, y, letter, font, color, background=0,landscape=False): draw the glyph for letter at position x,y using the font font. If landscape is false the letter is drawn left to right, if landscape is true, the letter is rotated counter clock wise by 90° and is drawn from bottom to top
Changed:
<
<
  • text(self, x, y, text, font, color, background=0,landscape=False, spacing=1, nowrap = False): I think you can guess! If nowrap is true and the text is larger than the length of a text line it is wrapped to the next line.
>
>
  • text(self, x, y, text, color, font=sysfont, background=0, landscape=False, spacing=1, nowrap = False): Please note the different parameter sequence as compared to draw_text
 
  • image(path,x0,y0,w=128, h=128): draw an image from a rgb565 raw image file to the display
  • sprite(buf, x, y, w, h): draw the sprite, which was previously loaded into buf
  • show(): copies the frame buffer data to the hardware

The demos

From my tests with the SSD1306 driver I had

Changed:
<
<
  • demo_ssd1306.py
>
>
  • demo_ssd1306_fb.py: This program demonstrates
    • the drawing of lines
    • rectangles
    • filled rectangles
    • circles
    • the plot of a sine function with a text
  • demo_ssd1306.py has the same functionality but instead of passing through the frame buffer it writes to the hardware directly

Here are a few photos of some of the screen images

img_7968.png img_7996.png img_7994.png
The next demo program originated from the original ST7735 driver. It again comes in two versions:
  • graphicstest.py and
  • graphicstest_fb.py
This program has a text writing demo in addition, where a long text is displayed, wrapped to the next line once the end of the line is reached. The text is displayed in portrait mode in green font color and in white when showing off text drawing in landscape mode.

This program is quite similar in nature as demo-ssd1306.py but produces slightly different graphics and it integrates a text writing demo in addition, where a long text is displayed, wrapped to the next line once the end of the line is reached. The text is displayed in portrait mode in green font color and in white when showing off text drawing in landscape mode.

Again a have a few photos for you:

img_7972.png img_7973.png img_7964.png img_7965.png
Then we have all the demo programs that came with the SSD1351 driver, some of which are quite sophisticated.
  • demo_bouncing boxes.py: shows a number of differently colored filled rectangles that bump of the the edges of the screens.
img_8003.png

  • demo_colored_squares.py: shows a number a filled rectangles in different colors
img_7952.png

  • demo_color_palette.py:
img_8000.png

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

  • demo_fonts.py
only needed minor modification to reflect this change. However, a utility script to convert the original C font to a Python font is needed.
img_7958.png img_7959.png img_7960.png img_7961.png
  -- Uli Raich - 2020-07-04
Line: 151 to 182
 
META FILEATTACHMENT attachment="tftJumpers.png" attr="" comment="" date="1595002607" name="tftJumpers.png" path="tftJumpers.png" size="641474" user="UliRaich" version="1"
META FILEATTACHMENT attachment="font.png" attr="" comment="" date="1595323325" name="font.png" path="font.png" size="2814" user="UliRaich" version="1"
META FILEATTACHMENT attachment="convertFont.py.txt" attr="" comment="" date="1595330819" name="convertFont.py.txt" path="convertFont.py.txt" size="8820" user="UliRaich" version="1"
Changed:
<
<
META FILEATTACHMENT attachment="fonts.png" attr="" comment="" date="1595781675" name="fonts.png" path="fonts.png" size="1283691" user="UliRaich" version="1"
META FILEATTACHMENT attachment="img_7952.png" attr="" comment="" date="1595781675" name="img_7952.png" path="img_7952.png" size="724284" user="UliRaich" version="1"
META FILEATTACHMENT attachment="img_7955.png" attr="" comment="" date="1595781675" name="img_7955.png" path="img_7955.png" size="893709" user="UliRaich" version="1"
META FILEATTACHMENT attachment="img_7958.png" attr="" comment="" date="1595781675" name="img_7958.png" path="img_7958.png" size="755694" user="UliRaich" version="1"
META FILEATTACHMENT attachment="img_7959.png" attr="" comment="" date="1595781675" name="img_7959.png" path="img_7959.png" size="769610" user="UliRaich" version="1"
META FILEATTACHMENT attachment="img_7960.png" attr="" comment="" date="1595781675" name="img_7960.png" path="img_7960.png" size="845581" user="UliRaich" version="1"
META FILEATTACHMENT attachment="img_7961.png" attr="" comment="" date="1595781675" name="img_7961.png" path="img_7961.png" size="831429" user="UliRaich" version="1"
META FILEATTACHMENT attachment="img_7965.png" attr="" comment="" date="1595781675" name="img_7965.png" path="img_7965.png" size="861388" user="UliRaich" version="1"
META FILEATTACHMENT attachment="img_7968.png" attr="" comment="" date="1595781675" name="img_7968.png" path="img_7968.png" size="886988" user="UliRaich" version="1"
META FILEATTACHMENT attachment="img_7975.png" attr="" comment="" date="1595781675" name="img_7975.png" path="img_7975.png" size="673693" user="UliRaich" version="1"
>
>
META FILEATTACHMENT attachment="img_7968.png" attr="" comment="" date="1595853390" name="img_7968.png" path="img_7968.png" size="269814" user="UliRaich" version="1"
META FILEATTACHMENT attachment="img_7994.png" attr="" comment="" date="1595853390" name="img_7994.png" path="img_7994.png" size="192428" user="UliRaich" version="1"
META FILEATTACHMENT attachment="img_7996.png" attr="" comment="" date="1595853390" name="img_7996.png" path="img_7996.png" size="243060" user="UliRaich" version="1"
META FILEATTACHMENT attachment="img_7972.png" attr="" comment="" date="1595854998" name="img_7972.png" path="img_7972.png" size="251748" user="UliRaich" version="1"
META FILEATTACHMENT attachment="img_7973.png" attr="" comment="" date="1595855158" name="img_7973.png" path="img_7973.png" size="242236" user="UliRaich" version="2"
META FILEATTACHMENT attachment="img_7965.png" attr="" comment="" date="1595857372" name="img_7965.png" path="img_7965.png" size="247079" user="UliRaich" version="2"
META FILEATTACHMENT attachment="img_8000.png" attr="" comment="" date="1595856657" name="img_8000.png" path="img_8000.png" size="237104" user="UliRaich" version="1"
META FILEATTACHMENT attachment="img_7952.png" attr="" comment="" date="1595856657" name="img_7952.png" path="img_7952.png" size="210601" user="UliRaich" version="1"
META FILEATTACHMENT attachment="img_7964.png" attr="" comment="" date="1595857690" name="img_7964.png" path="img_7964.png" size="243737" user="UliRaich" version="1"
META FILEATTACHMENT attachment="img_8003.png" attr="" comment="" date="1595858017" name="img_8003.png" path="img_8003.png" size="169353" user="UliRaich" version="1"
META FILEATTACHMENT attachment="img_7958.png" attr="" comment="" date="1595858610" name="img_7958.png" path="img_7958.png" size="216572" user="UliRaich" version="1"
META FILEATTACHMENT attachment="img_7959.png" attr="" comment="" date="1595858610" name="img_7959.png" path="img_7959.png" size="225735" user="UliRaich" version="1"
META FILEATTACHMENT attachment="img_7960.png" attr="" comment="" date="1595858610" name="img_7960.png" path="img_7960.png" size="244285" user="UliRaich" version="1"
META FILEATTACHMENT attachment="img_7961.png" attr="" comment="" date="1595858610" name="img_7961.png" path="img_7961.png" size="250689" user="UliRaich" version="1"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback