Simple test
Ensure your device works with this simple test.
examples/esp32s2tft_simpletest.py
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
7
8from rainbowio import colorwheel
9
10from adafruit_esp32s2tft import ESP32S2TFT
11
12esp32s2tft = ESP32S2TFT(default_bg=0xFFFF00, scale=2, use_network=False)
13
14# Create the labels
15esp32s2tft.add_text(text="ESP32-S2", text_position=(10, 10), text_scale=2, text_color=0xFF00FF)
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.root_group
30
31while True:
32 esp32s2tft.set_text_color(0xFF0000 if esp32s2tft.peripherals.button else 0x606060, button_label)
33 esp32s2tft.peripherals.led = esp32s2tft.peripherals.button
34 if esp32s2tft.peripherals.button:
35 esp32s2tft.peripherals.neopixel[0] = colorwheel(random.randint(0, 255))