Tags:
create new tag
view all tags

Exercise 10: A TFT Display and the ST7735 display controller

Introduction

The ST7735 is described in TFT Display on this TWiki. It comes with a big bunch of demo programs showing the functionality of the driver. Please inspect the source code of each of these demos and run them. This should give you a good feeling of the possibilities the driver offers.

Exercise 1: Random lines, rectangles and circles

Write a MicroPython script that draws 50

  • random lines
  • random rectangles
  • random circles
in random colors. These are 3 distinct tests. Draw the lines first, show them for 5s, clear the display and start showing the rectangles ...
img_8008.png img_8009.png img_8010.png
Write the above script once using direct drawing primitives (draw_line(...), draw_rectangle(...), draw_circle(...)) and then modify your code to use the primitives (line(...),rect(...),circle(...)) passing through the frame buffer. Where do you have to place the show() calls to get a similar result?

Exercise 2: Text drawing

Write a script that prints "DSCIT" in three different fonts (sysfont, courier20 and EspressoDolce18x24) in the colors red, green and blue. Draw the text once in portrait and once in landscape mode

img_8011.png

The font files are actually executable Python code that you can run on CPython on your laptop. Try to run e.g. courier20.py and sysfont.py. You will see a letter, which in case of the courier font will be upright(hmap() returns true), while in the sysfont case it will be turned clockwise by 90 ° (hmap() returns false). Can you write a piece of code that will transform the sysfont glyph into an upright layout?

Exercise 3: Graphical User Interface (GUI) elements from nanogui

Create 2 meters, one for temperature (0..50) and one for humidity (0..100). Generate dummy temperature and humidity values and display them in the meters.

Once the graphics works replace the dummy measurements by real ones from the SHT30.

img_8012.png img_8016.png

Exercise 4: Plots

Create a plot of a damped oscillator

img_8020.png

Exercise 5: A new GUI element (bonus point)

Create a voltmeter application to measure voltages. You will need a new Scale GUI element similar to the nanogui Dial, but designed by yourself, which displays the voltage read from an ADC. Values to be displayed must range from 0 to 5V. The photo below shows the voltmeter, reading a voltage of 1V.

img_8025.png

Exercise 6: Super Mario, a bit of a challenge!

Two simple arcade games come with the SD1351 driver demos. One of them is a Super Mario game, which however is based on hardware we don't have. As far as I can see they use a joystick with BlueTooth connection. You can replace this with an analogue joystick we have in our sensor box. 2 ADC channels are needed to read it out.

Here are the connections:

Joystick ESP32 CPU board
GND GND
5V 3.3V
VRx GPIO 33 or ADC 05
VRy GPIO 34 or ADC 10
Attenuate the input signal by 11 dB. When reading out the ADC with the joystick in its rest position you will obtain values of around 1830. If the value gets lower than 1000 Mario runs left, for values > 2000 he runs right and for values 1000..2000 he is standing still. Same for up and down on the second ADC channel. The ADC channels are only accessible on the ESP32 CPU card, not on the WeMos D1 bus! have a look at the CPU card pinout shown on the TWiki page The hardware.

This is how it will look like:

img_8026.png img_8024.png
The exercise sheet in odt format:

https://afnog.iotworkshop.africa/pub/IoT_Course_English/ST7735TFTDisplay/exercise_10.odt

-- Uli Raich - 2020-07-26

Comments

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatodt exercise_10.odt r1 manage 1658.3 K 2020-08-09 - 09:05 UliRaich  
PNGpng img_8008.png r1 manage 208.2 K 2020-07-28 - 06:55 UliRaich  
PNGpng img_8009.png r1 manage 211.2 K 2020-07-28 - 06:55 UliRaich  
PNGpng img_8010.png r1 manage 235.2 K 2020-07-28 - 06:55 UliRaich  
PNGpng img_8011.png r1 manage 184.5 K 2020-07-28 - 07:29 UliRaich  
PNGpng img_8012.png r1 manage 192.1 K 2020-07-28 - 11:55 UliRaich  
PNGpng img_8016.png r1 manage 191.6 K 2020-07-28 - 13:04 UliRaich  
PNGpng img_8020.png r1 manage 204.1 K 2020-07-28 - 14:28 UliRaich  
PNGpng img_8024.png r1 manage 170.9 K 2020-07-29 - 07:09 UliRaich  
PNGpng img_8025.png r1 manage 181.8 K 2020-07-29 - 12:49 UliRaich  
PNGpng img_8026.png r1 manage 402.3 K 2020-07-30 - 11:34 UliRaich  
Edit | Attach | Watch | Print version | History: r12 < r11 < r10 < r9 < r8 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r12 - 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