summaryrefslogtreecommitdiff
path: root/wasp
diff options
context:
space:
mode:
Diffstat (limited to 'wasp')
-rw-r--r--wasp/boot.py6
-rw-r--r--wasp/demo.py8
-rw-r--r--wasp/pinetime.py54
3 files changed, 48 insertions, 20 deletions
diff --git a/wasp/boot.py b/wasp/boot.py
new file mode 100644
index 0000000..79601e7
--- /dev/null
+++ b/wasp/boot.py
@@ -0,0 +1,6 @@
+import logo
+import pinetime
+
+pinetime.display.rleblit(logo.pine64, fg=0xffff)
+
+
diff --git a/wasp/demo.py b/wasp/demo.py
index 1470ff5..b74d3e6 100644
--- a/wasp/demo.py
+++ b/wasp/demo.py
@@ -24,10 +24,6 @@ colors = (
0xf81f, # magenta
)
-# Let's keep this where we can find it if someone delivers ^C to the
-# demo
-tft = pinetime.st7789()
-
def run():
l = logo.pine64
i = 0
@@ -42,8 +38,8 @@ def run():
l = logo.micropython
else:
l = logo.pine64
- tft.fill(0)
+ pinetime.display.fill(0)
- tft.rleblit(l, fg=c)
+ pinetime.display.rleblit(l, fg=c)
time.sleep(2)
gc.collect()
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)