summaryrefslogtreecommitdiff
path: root/wasp/pinetime.py
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2020-01-29 17:30:57 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-01-29 17:30:57 (GMT)
commitd3d98c8ffb1feded5b77c34f67aa1f2b4ae19a2e (patch)
tree369153700d5a304366180844c5a1eff13a20521e /wasp/pinetime.py
parent564200757cce485ba9cb7b12d25c5c98b3fe6e26 (diff)
wasp: Re-enable REPL by default
The demo is still there but it needs to be activated by hand (or the manifest can be updated to include main.py by default.
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)