summaryrefslogtreecommitdiff
path: root/wasp/pinetime.py
diff options
context:
space:
mode:
Diffstat (limited to 'wasp/pinetime.py')
-rw-r--r--wasp/pinetime.py54
1 files changed, 40 insertions, 14 deletions
diff --git a/wasp/pinetime.py b/wasp/pinetime.py
index cdbb230..1a771aa 100644
--- a/wasp/pinetime.py
+++ b/wasp/pinetime.py
@@ -3,18 +3,44 @@ from machine import SPI
from drivers.st7789 import ST7789_SPI
-def st7789():
- spi = SPI(0)
- # Mode 3, maximum clock speed!
- spi.init(polarity=1, phase=1, baudrate=8000000)
+class Display(ST7789_SPI):
+ def __init__(self):
+ spi = SPI(0)
+ # Mode 3, maximum clock speed!
+ spi.init(polarity=1, phase=1, baudrate=8000000)
- # Configure the display
- cs = Pin("SPI_SS2", Pin.OUT)
- dc = Pin("P18", Pin.OUT)
- rst = Pin("P26", Pin.OUT)
- tft = ST7789_SPI(240, 240, spi, cs=cs, dc=dc, res=rst)
-
- # Bring up the backlight
- bl = Pin("P22", Pin.OUT)
- bl.off() # active low
- return tft
+ # Configure the display
+ cs = Pin("DISP_CS", Pin.OUT)
+ dc = Pin("DISP_DC", Pin.OUT)
+ rst = Pin("DISP_RST", Pin.OUT)
+
+ super().__init__(240, 240, spi, cs=cs, dc=dc, res=rst)
+
+class Backlight(object):
+ lo = Pin("BL_LO", Pin.OUT, value=0)
+ mid = Pin("BL_MID", Pin.OUT, value=1)
+ hi = Pin("BL_HI", Pin.OUT, value=1)
+
+ def __init__(self, level=1):
+ self.set(level)
+
+ def set(self, level):
+ hi = 1
+ mid = 1
+ lo = 1
+
+ if level >= 3:
+ hi = 0
+ elif level == 2:
+ mid = 0
+ elif level == 1:
+ lo = 0
+
+ self.hi(hi)
+ self.mid(mid)
+ self.lo(lo)
+
+backlight = Backlight(0)
+display = Display()
+
+backlight.set(1)