summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wasp/apps/clock.py4
-rw-r--r--wasp/apps/flashlight.py2
-rw-r--r--wasp/apps/testapp.py7
-rw-r--r--wasp/boards/pinetime/watch.py3
-rw-r--r--wasp/boards/simulator/display.py2
-rw-r--r--wasp/boards/simulator/watch.py36
6 files changed, 26 insertions, 28 deletions
diff --git a/wasp/apps/clock.py b/wasp/apps/clock.py
index 5de6271..cde39a2 100644
--- a/wasp/apps/clock.py
+++ b/wasp/apps/clock.py
@@ -3,8 +3,6 @@ import watch
import widgets
import manager
-from draw565 import Draw565
-
DIGITS = (
digits.clock_0,
digits.clock_1,
@@ -86,7 +84,7 @@ class ClockApp(object):
display.rleblit(DIGITS[now[3] // 10], pos=(0*48, 80), fg=0xbdb6)
self.on_screen = now
- draw = Draw565(display)
+ draw = watch.drawable
month = now[1] - 1
month = MONTH[month*3:(month+1)*3]
draw.string('{} {} {}'.format(now[2], month, now[0]),
diff --git a/wasp/apps/flashlight.py b/wasp/apps/flashlight.py
index d71342b..f1f9418 100644
--- a/wasp/apps/flashlight.py
+++ b/wasp/apps/flashlight.py
@@ -1,8 +1,6 @@
import watch
import manager
-from draw565 import Draw565
-
class FlashlightApp(object):
"""Trivial flashlight application.
diff --git a/wasp/apps/testapp.py b/wasp/apps/testapp.py
index 7bbfc2c..56a3853 100644
--- a/wasp/apps/testapp.py
+++ b/wasp/apps/testapp.py
@@ -3,8 +3,6 @@ import widgets
import manager
import machine
-from draw565 import Draw565
-
class TestApp():
"""Simple test application.
"""
@@ -12,7 +10,6 @@ class TestApp():
def __init__(self):
self.tests = ('Touch', 'String')
self.test = self.tests[0]
- self.drawable = Draw565(watch.display)
def foreground(self, system, effect=None):
"""Activate the application."""
@@ -36,7 +33,7 @@ class TestApp():
self.draw()
def touch(self, event):
- draw = self.drawable
+ draw = watch.drawable
if self.test == 'Touch':
draw.string('({}, {})'.format(event[1], event[2]),
0, 108, width=240)
@@ -60,6 +57,6 @@ class TestApp():
"""Redraw the display from scratch."""
watch.display.mute(True)
watch.display.fill(0)
- self.drawable.string('{} test'.format(self.test),
+ watch.drawable.string('{} test'.format(self.test),
0, 6, width=240)
watch.display.mute(False)
diff --git a/wasp/boards/pinetime/watch.py b/wasp/boards/pinetime/watch.py
index 7e4ee6f..332d761 100644
--- a/wasp/boards/pinetime/watch.py
+++ b/wasp/boards/pinetime/watch.py
@@ -7,6 +7,8 @@ rtc.counter.start()
import os
import time
+import draw565
+
from machine import I2C
from machine import Pin
#from machine import Signal
@@ -51,6 +53,7 @@ display = ST7789_SPI(240, 240, spi,
cs=Pin("DISP_CS", Pin.OUT),
dc=Pin("DISP_DC", Pin.OUT),
res=Pin("DISP_RST", Pin.OUT))
+drawable = draw565.Draw565(display)
# Setup the last few bits and pieces
battery = Battery(
diff --git a/wasp/boards/simulator/display.py b/wasp/boards/simulator/display.py
index 41d9512..3d7d388 100644
--- a/wasp/boards/simulator/display.py
+++ b/wasp/boards/simulator/display.py
@@ -101,7 +101,7 @@ class CST816SSim():
self.raise_interrupt()
def raise_interrupt(self):
- print('#INT')
+ pass
sdl2.ext.init()
window = sdl2.ext.Window("ST7789", size=(WIDTH, HEIGHT))
diff --git a/wasp/boards/simulator/watch.py b/wasp/boards/simulator/watch.py
index 91be914..f38d7a1 100644
--- a/wasp/boards/simulator/watch.py
+++ b/wasp/boards/simulator/watch.py
@@ -3,6 +3,8 @@ def sleep_ms(ms):
time.sleep(ms / 1000)
time.sleep_ms = sleep_ms
+import draw565
+
from machine import I2C
from machine import Pin
from machine import SPI
@@ -11,30 +13,22 @@ from drivers.cst816s import CST816S
from drivers.st7789 import ST7789_SPI
from drivers.vibrator import Vibrator
-button = Pin('BUTTON', Pin.IN, quiet=True)
class Backlight(object):
def __init__(self, level=1):
- self.set(level)
+ pass
def set(self, level):
+ """Set the simulated backlight level.
+
+ This function contains a subtle trick. As soon as the backlight is
+ turned off (e.g. the watch goes to sleep) then we will simulate
+ a button press in order to turn the watch back on again.
+ """
print(f'BACKLIGHT: {level}')
button.value(bool(level))
-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("DISP_CS", Pin.OUT, quiet=True)
- dc = Pin("DISP_DC", Pin.OUT, quiet=True)
- rst = Pin("DISP_RST", Pin.OUT, quiet=True)
-
- super().__init__(240, 240, spi, cs=cs, dc=dc, res=rst)
-
class Battery(object):
def __init__(self):
self.voltage = 3.9
@@ -93,10 +87,18 @@ class RTC(object):
def get_uptime_ms(self):
return int(time.time() * 1000)
-display = Display()
-touch = CST816S(I2C(0))
backlight = Backlight()
+spi = SPI(0)
+spi.init(polarity=1, phase=1, baudrate=8000000)
+display = ST7789_SPI(240, 240, spi,
+ cs=Pin("DISP_CS", Pin.OUT, quiet=True),
+ dc=Pin("DISP_DC", Pin.OUT, quiet=True),
+ res=Pin("DISP_RST", Pin.OUT, quiet=True))
+drawable = draw565.Draw565(display)
+
battery = Battery()
+button = Pin('BUTTON', Pin.IN, quiet=True)
rtc = RTC()
+touch = CST816S(I2C(0))
vibrator = Vibrator(Pin('MOTOR', Pin.OUT, value=0), active_low=True)