Lesson plan

Color TFT screens and touch UI lesson plan

Color screens on the ESP32: SPI panels and RGB565, TFT_eSPI with fonts and smooth gauges, resistive and capacitive touch, screens and a tab bar, and a spaceship life support thermostat for the boss.

4 chapters, 7 lessons, about 6 hours, on the ESP32 DevKit V1. Every lesson runs in the browser, with nothing to install.

The unit

Objectives and materials

By the end, students can

  • Panels on one bus, 16-bit color, and TFT_eSPI.
  • Gauges and buttons, then a resistive panel to press them.
  • Touch in pixels, and an app with more than one screen.
  • A life support thermostat for a spaceship cabin.

Materials for the whole unit

  • ESP32 DevKit V1
  • IPS display, ST7789
  • Round display, GC9A01
  • Temperature sensor, TMP36
  • Touch TFT, 2.8 inch ILI9341 with FT6206
  • Touch TFT, 2.8 inch ILI9341 with XPT2046

Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.

Chapter 1. About 1 h 40 min

Pixels over SPI

Panels on one bus, 16-bit color, and TFT_eSPI.

LessonTimeWhat students do
SPI panels: two screens, one busAn ST7789 and a round GC9A01 on one SPI bus: clock, data, chip select and DC, RGB565 color in 16 bits, and what a full-screen fill costs.50 min
  1. Run it: two screens, one bus
  2. Four ideas make SPI
  3. Color in 16 bits
  4. What a full screen costs
  5. Your own color
  6. Same commands, different glass
TFT_eSPI setup, colors and fontsTFT_eSPI on a 2.8 inch ILI9341: the setup defines, rotation, color565(), the numbered fonts, centered text with a datum, and a mission clock that redraws without flicker.50 min
  1. Run it: mission control
  2. The setup is at compile time
  3. Fonts and a datum
  4. A clock without flicker
  5. Turn the screen
  6. Colors by name and by number

Materials

  • ESP32 DevKit V1
  • IPS display, ST7789
  • Round display, GC9A01
  • Touch TFT, 2.8 inch ILI9341 with XPT2046

Check for understanding

Each student finishes "TFT_eSPI setup, colors and fonts" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Colors by name and by number".

Chapter 2. About 1 h 40 min

Widgets and touch

Gauges and buttons, then a resistive panel to press them.

LessonTimeWhat students do
Buttons and gaugesA rover fuel gauge: a smooth arc and a bar from one number, a color that warns below a limit, a drawn button, and the rule of redrawing only what changed.50 min
  1. Run it: a rover fuel gauge
  2. An arc from a number
  3. Feed it a number
  4. Warning colors
  5. Warn earlier
  6. Redraw only what changed
Resistive touchThe XPT2046 on the same SPI bus: raw 12-bit readings and pressure, a calibration that turns them into pixels, a mirrored axis to fix, and three buttons for the cabin lights.50 min
  1. Run it: cabin lights
  2. Press the glass
  3. Raw numbers, not pixels
  4. The wrong button
  5. Fix the calibration
  6. Calibrating a real panel

Materials

  • ESP32 DevKit V1
  • Touch TFT, 2.8 inch ILI9341 with XPT2046

Check for understanding

Each student finishes "Resistive touch" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Calibrating a real panel".

Chapter 3. About 1 h 40 min

Capacitive touch and screens

Touch in pixels, and an app with more than one screen.

LessonTimeWhat students do
Capacitive touchAn FT6206 on I2C: no pressure and no calibration, touch points already in pixels in the panel's own portrait frame, turned around for landscape, and a landing pad to hit.50 min
  1. Run it: land on the pad
  2. No moving parts
  3. Pixels, the other way up
  4. Touchdown
  5. A clear button
  6. Resistive or capacitive?
Screen navigationA spaceship console with three screens and a tab bar: one state variable, screens drawn only when they change, and touches that mean something only on their own screen.50 min
  1. Run it: a spaceship console
  2. One variable is the whole UI
  3. Buttons belong to a screen
  4. Call the ground
  5. Start somewhere else
  6. Patterns that scale

Materials

  • ESP32 DevKit V1
  • Touch TFT, 2.8 inch ILI9341 with FT6206

Check for understanding

Each student finishes "Screen navigation" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Patterns that scale".

Chapter 4. About 1 h 5 min

Boss project

A life support thermostat for a spaceship cabin.

LessonTimeWhat students do
Boss: a life support thermostatA spaceship cabin thermostat: a TMP36 in big digits, a set point on touch buttons, heating and cooling with hysteresis so it never chatters, and an alarm outside the safe range.65 min
  1. Run it: life support
  2. Hysteresis
  3. Raise the set point
  4. Hold
  5. A cold cabin
  6. Alarm
  7. A warmer crew
  8. Make it your ship

Materials

  • ESP32 DevKit V1
  • Temperature sensor, TMP36
  • Touch TFT, 2.8 inch ILI9341 with FT6206

Check for understanding

Each student finishes "Boss: a life support thermostat" on their own, without opening the hints. The simulator checks 8 of its 8 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Make it your ship".

Your class

Teach this unit as a class

Start a class from this course and its 7 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.

The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.