Added initial display implementation

This commit is contained in:
David Thurstenson 2022-10-23 13:54:33 -05:00
parent e47c2babe1
commit 06df87ee19
1 changed files with 34 additions and 2 deletions

View File

@ -5,7 +5,13 @@ import adafruit_datetime as datetime
from adafruit_seesaw import seesaw, rotaryio, digitalio from adafruit_seesaw import seesaw, rotaryio, digitalio
from adafruit_debouncer import Button from adafruit_debouncer import Button
import busio import busio
import displayio
import terminalio
import adafruit_displayio_ssd1306
from adafruit_display_text import label
# Release displays so thonny doesn't block the i2c setup
displayio.release_displays()
#### ####
# i2c bus setup # i2c bus setup
@ -34,6 +40,32 @@ last_position = -1
#### ####
####
# Display setup
try:
display_bus = displayio.I2CDisplay(i2c, device_address=60)
display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=128, height=32)
except:
print("Unable to initialize display.")
text = "HELLO WORLD"
font = terminalio.FONT
color = 0xFFFFFF
text_area = label.Label(font, text=text, color=color)
text_area.x = 1
text_area.y = 12
try:
display.show(text_area)
except:
pass
# END Display setup
####
#### ####
# Neopixel setup # Neopixel setup
@ -231,8 +263,7 @@ def countdown(
current_time -= update_interval current_time -= update_interval
# Give the user feedback # Give the user feedback
# (this string will eventually go to a ssd1306 OLED display via text_area.text = prettytime(current_time)
# displayio, but just put it on the terminal output for now)
print("current time: " + prettytime(current_time)) print("current time: " + prettytime(current_time))
# Update the debouncer # Update the debouncer
@ -277,6 +308,7 @@ while True:
# Update the position tracker # Update the position tracker
last_position = position last_position = position
# User feedback # User feedback
text_area.text = prettytime(set_time)
print("Current set time: " + prettytime(set_time)) print("Current set time: " + prettytime(set_time))
# Reset timer to config value on long press # Reset timer to config value on long press