-
Notifications
You must be signed in to change notification settings - Fork 1.3k
LILYGO® T-Deck Support #8558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'll be using this issue to document my attempt to port CircuitPython to the LILYGO T-Deck. |
Pin-out based on the schematic provided by LILYGO.
|
WiFiWiFi works in the sense that networks can be scanned for, however I am having issues connecting to any access points. The This is likely due to a regression in CircuitPython 9.x. It seems that other ESP32 devices have issues as well: #8552 Example Codesettings.toml WIFI_SSID = "MyNetwork"
WIFI_PASSWORD = "MyPassword"
WIFI_CHANNEL = 3 code.py import os
import time
import sys
import ipaddress
import wifi
print("Broadcasted SSIDs")
for network in wifi.radio.start_scanning_networks():
print(f"{network.ssid} [Ch:{network.channel}]")
wifi.radio.stop_scanning_networks()
ssid = os.getenv("WIFI_SSID")
channel = os.getenv("WIFI_CHANNEL", 0)
try:
print(f"Connecting to: {ssid} [Ch:{channel}]")
wifi.radio.connect(
ssid=ssid,
password=os.getenv("WIFI_PASSWORD"),
channel=channel,
timeout=5
)
print("Connected.")
except ConnectionError as e:
print("Failed to connect, aborting.")
print(e)
sys.exit()
print("MAC addr:", [hex(i) for i in wifi.radio.mac_address])
print("IP address:", wifi.radio.ipv4_address) BluetoothIt's basic, but it works. I tried using the DeviceInfoService provided by the ExamplesThese examples are from the Broadcastingcode.py from adafruit_ble import BLERadio
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
ble = BLERadio()
advertisement = ProvideServicesAdvertisement()
print(f"Advertising as: {ble.name}")
ble.start_advertising(advertisement)
while True:
pass REPL
Scanningcode.py from adafruit_ble import BLERadio
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
ble = BLERadio()
print(f"Device name: {ble.name}")
print("Scanning")
found = set()
scan_responses = set()
for advertisement in ble.start_scan(ProvideServicesAdvertisement):
addr = advertisement.address
if advertisement.scan_response and addr not in scan_responses:
scan_responses.add(addr)
elif not advertisement.scan_response and addr not in found:
found.add(addr)
else:
continue
print(addr, advertisement)
print("\t" + repr(advertisement))
print() REPL
|
KeyboardThe keyboard is an ESP32-C3 chip running its own firmware and communicating via I2C. A keyboard backlight is present, it can be turned on by pressing Alt+B. There is no way to enable that via I2C, but the keyboard can be updated to support it. There is a separate UART interface (2 of 6 pins) on the main board that can be used to re-flashed the keyboard. It's recommended to solder headers or use probes on this interface, since a standard Dupont connector won't fit. However, the male pins will fit if removed from the plastic, taking care to insulate the pins from one another. Pin IO46 is labelled as a KEYBOARD_INT, but it's not needed. There isn't a corresponding pin configured in the firmware either. Currently unused, but it appears that functionality can be added. Exampleimport board
import busio
import time
i2c = busio.I2C(board.SCL, board.SDA)
keyboard = 0x55
while not i2c.try_lock():
pass
try:
while True:
r = bytearray(1)
i2c.readfrom_into(keyboard, r)
if r != b'\x00':
print(r.decode())
time.sleep(0.05)
finally:
i2c.unlock() REPL
|
I've revised My plan is to continue testing the hardware and providing examples while the PR (#8563) is reviewed. |
SpeakerWhen configured through an ExampleTook this from the audiobusio example and modified the pins. import audiobusio
import audiocore
import board
import array
import time
import math
# Generate one period of sine wave.
length = 8000 // 440
sine_wave = array.array("H", [0] * length)
for i in range(length):
sine_wave[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 15) + 2 ** 15)
sine_wave = audiocore.RawSample(sine_wave, sample_rate=8000)
i2s = audiobusio.I2SOut(board.I2S_BCK, board.I2S_WS, board.I2S_DOUT)
i2s.play(sine_wave, loop=True)
time.sleep(1)
i2s.stop() MicrophoneThe T-Deck comes with an ES7210 to handle Microphone input. This device works best with I2S, but no |
TrackballFunctional, but hard to know if it's working as designed. Fine input seems to be an issue with both the Sample Code (that comes with the T-Deck) and CircuitPython. However, when using ExamplesUsing import board
import keypad
trackball = keypad.Keys(
[
board.TRACKBALL_CLICK,
board.TRACKBALL_UP,
board.TRACKBALL_DOWN,
board.TRACKBALL_LEFT,
board.TRACKBALL_RIGHT
],
value_when_pressed=False
)
while True:
event = trackball.events.get()
# event will be None if nothing has happened.
if event:
print(event) When switching the to something like Countio, we can measure the units of movement between each sample. However, the ESP32 is limited to 4 import board
import countio
pins = [
board.TRACKBALL_UP,
board.TRACKBALL_DOWN,
board.TRACKBALL_LEFT,
board.TRACKBALL_RIGHT,
board.TRACKBALL_CLICK
]
counters = [countio.Counter(p) for p in pins]
while True:
for i, c in enumerate(counters):
if c.count > 0:
print(f"{i}: {c.count}")
c.reset() Thankfully, the resolution is not needed for the button click, so that can remain a code.py import board
import countio
import keypad
trackball = {
"up": countio.Counter(board.TRACKBALL_UP),
"down": countio.Counter(board.TRACKBALL_DOWN),
"left": countio.Counter(board.TRACKBALL_LEFT),
"right": countio.Counter(board.TRACKBALL_RIGHT)
}
click = keypad.Keys([board.TRACKBALL_CLICK], value_when_pressed=False)
while True:
event = click.events.get()
if event:
print(event)
for p, c in trackball.items():
if c.count > 0:
print(f"{p}: {c.count}")
c.reset() REPL
|
LoRaThere doesn't seem to be a CircuitPython-specific library for the SX1262 series of LoRa modules, but the one for MicroPython should work. However, the library tries to build the SPI interface rather than accepting a SPI object. Since the CircuitPython build initializes the SPI on start-up, when the library tries to initialize it, the pin in already in use.
The micropySX126X will have to be changed to accommodate for SPI ojbects or an alternative library should be used. Thus far, no other library exist for the Semtech SX126x series of LoRa modules. |
https://github.com/adafruit/Adafruit_CircuitPython_RFM9x is for a module with a SX1276 inside. |
There's a pinout difference between the two chips the SX126x and the SX127x that leads me to believe that the RFM9x library is incompatible. The biggest being the presence of the As soon as I can get a receiving device to test with, I'll give it a shot. Thanks! |
I've created a helper library for the LILYGO T-Deck on CircuitPython. Development for the peripherals will continue here. Contributions are welcome! |
@rgrizzell Thanks for your work on this!!! https://discord.com/channels/327254708534116352/334905778857050125/1173394324348735648 |
Good morning I have a perhaps stupid question but how to make the keyboard work in REPL because I have the starting file but no possibility of typing the commands directly on the t-deck |
Good question! Unfortunately, there isn't a way to use the T-Keyboard to input characters the REPL on the T-Deck. It might be feasible to add support for that. CircuitPython recently added a |
As a general rule you're better off opening a new issue rather than updating closed ones. Closed issues are harder for the Adafruit folks to track. I think this is a great question to open as an issue :D. I'm thinking a virtual REPL using the python exec() command and a simple I2C keyboard handler wouldn't be too hard to write and might be a decent stop gap in lieu of CircuitPython native support. It could just be placed in code.py. As a side note, PyDOS supports the T-Deck and will boot up on the device with keyboard support. |
Yes it's due to my lack of knowledge of git I will continue here I will leave you the link |
LILYGO® T-Deck
Specifications
CPU: ESP32-S3
Flash: 16MB
PSRAM: 8MB
Display: 2.8" ST7789 (320x240)
Radio: 2.4Ghz WiFi, Bluetooth 5, and LoRa (optional)
Enter Flash Mode (Download Mode)
The text was updated successfully, but these errors were encountered: