Simple test¶
Ensure your device works with this simple test.
1# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
2# SPDX-FileCopyrightText: Copyright (c) 2022 Melissa LeBlanc-Williams for Adafruit Industries
3#
4# SPDX-License-Identifier: Unlicense
5
6import random
7from rainbowio import colorwheel
8from adafruit_esp32s2tft import ESP32S2TFT
9
10esp32s2tft = ESP32S2TFT(default_bg=0xFFFF00, scale=2, use_network=False)
11
12# Create the labels
13esp32s2tft.add_text(
14 text="ESP32-S2", text_position=(10, 10), text_scale=2, text_color=0xFF00FF
15)
16esp32s2tft.add_text(
17 text="TFT Feather",
18 text_position=(60, 30),
19 text_anchor_point=(0.5, 0.5),
20 text_color=0xFF00FF,
21)
22button_label = esp32s2tft.add_text(
23 text="Press BOOT0 Button",
24 line_spacing=1.0,
25 text_position=(60, 50),
26 text_anchor_point=(0.5, 0.5),
27 text_color=0x606060,
28)
29esp32s2tft.display.root_group = esp32s2tft.splash
30
31while True:
32 esp32s2tft.set_text_color(
33 0xFF0000 if esp32s2tft.peripherals.button else 0x606060, button_label
34 )
35 esp32s2tft.peripherals.led = esp32s2tft.peripherals.button
36 if esp32s2tft.peripherals.button:
37 esp32s2tft.peripherals.neopixel[0] = colorwheel(random.randint(0, 255))