Tags:
create new tag
view all tags

Solutions to exercise 10: TFT display

Introduction

The exercises on the TFT display can be implemented on the 1.4" display with its ST7735 controller or on the 2.4" display with the ILI9341 controller. Of course the coordinates must be adapted to the different pixel resolution of the display.

Exercise 1:

The drivers for the display controller:

  • ST7735.py
  • ili934x.py
are both already included in the MicroPython binary. Try to import them for verification. Otherwise there is nothing much to be explained about the solution. The expected results are already shown on the exercise sheet.

Exercise 2:

The text fonts are also already available in the MicroPython binary. Since RAM is a scarce resource on the ESP32 we need a method allowing to have them stored in flash and get fast access to them nevertheless. The section on fonts in TFT display explains how this is done. In order ti use the font all you have to do is

import fonts.sysfont as sysfont
display.draw_text(0, 127, 'DCSIT',  sysfont, Display.RED,landscape=True)

in case of the font sysfont.

Exercise 3:

In exercise 3 we make use of classes

  • Label
  • Meter
  • LED
defined in nanogui, a very simplistic Graphical User Interface (GUI) library developed by Peter Hinch. Please see
https://github.com/peterhinch/micropython-nano-gui. This library is again already included into the MicroPython binary. See Peter's demos and model your solution after them. color15.py provides an example very similar to what we have to do for the solution.

Exercise 4:

To solve this exercise we take a similar path as for exercise 3. Here we use the fplot module included in nanogui. Again Peter has demos showing how to use the plot classes.

Exercise 5:

This one is a bit more difficult! It requires some knowledge about complex numbers in Python. I took Peter's aclock demo as an example and developed my own Scale class, drawing only half a circle and creating a needle similar to Peter's Dial to show the values.

The result is shown on the exercise sheet.

Exercise 6:

Making the Super Mario program run on the ST7735.py driver corresponds to a porting task from one display driver to another, namely from the SSD1351 to the ST7735 driver. Explaining all porting details would go beyond the scope of this text.

-- Uli Raich - 2021-02-06

Comments

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2021-02-06 - UliRaich
 
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