1
0
Fork 0

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.
This commit is contained in:
Daniel Thompson 2020-01-29 17:30:57 +00:00
parent 564200757c
commit d3d98c8ffb
7 changed files with 90 additions and 40 deletions

View file

@ -1,33 +1,55 @@
Watch Application System in Python Watch Application System in Python
================================== ==================================
Despite the grand ambitions of the name, currently this repo simply Currently WASP is primarily useful as a pre-packaged MicroPython
combines a bootloader, derived from the Adafruit NRF52 bootloader, with development environment for PineTime. Whilst there are plans to grow
MicroPython. Both have been ported to Pine64 PineTime and the Desay it into a smart watch runtime for Pine64 PineTime and the Desay
DS-D6 fitness band. DS-D6 fitness tracker this goal has yet to be achieved.
Try: WASP includes a robust bootloader based on the Adafruit NRF52
Bootloader. It has been extended to make it robust for development on
form-factor devices without a reset button, power switch, SWD debugger
or UART. This allows us to confidently develop on sealed devices relying
only on BLE for updates.
Building from a git clone
-------------------------
~~~ ~~~
make submodules make submodules
make softdevice make softdevice
make -j `nproc` all make -j `nproc` BOARD=pinetime all
make flash
~~~ ~~~
Then use nRFConnect (for Android) to program micropython.zip. Installing
----------
At the end of this process your watch may *look* dead but, if it works, Note: *If you have a new PineTime then it will have been delivered with
you will be able to use the Nordic UART Service to access the flash protection enabled. You must disable the flash protection before
MicroPython REPL. trying to program it.*
Drivers are, for the most part, an exercise for the reader but * Use an SWD programmer to install `bootloader.hex` to the PineTime.
there is a proof-of-concept display driver. To experiment try: This file is an Intel HEX file containing both the bootloader and
the Nordic SoftDevice. Be careful to disconnect cleanly from the
debug software since just pulling out the SWD cable will mean the
nRF52 will still believe it is being debugged.
* Copy `micropython.zip` to your Android device and download nRF Connect
for Android if you do not already have it.
* In nRF Connect, choose settings and reduce the DFU packet count from
10 to 4.
* Connect to PineDFU using nRFConnect, click the DFU button and send
`micropython.zip` to the device.
At the end of this process your watch you will see a couple of splash
screens (bootloader shows a small Pine64 logo, MicroPython shows are
larger one). Once the second splash screen appears you will be able to
use the Nordic UART Service to access the MicroPython REPL.
Drivers are still in development, see the [TODO list](todo.md) for
current status. In the mean time try the following and then take
a look at the `wasp/` directory to see how it works:
~~~ ~~~
import pinetime, time import demo
tft = pinetime.st7789() demo.run()
tft.white()
time.sleep(2)
tft.black()
~~~ ~~~

View file

@ -34,7 +34,7 @@ The TODO list helps keep track on progress towards that goal. It is not
- [ ] Bitmap blitting - [ ] Bitmap blitting
- [X] RLE coder and decoder - [X] RLE coder and decoder
- [ ] Optimized RLE inner loops - [ ] Optimized RLE inner loops
* [ ] Backlight driver * [X] Backlight driver
* [ ] Button driver (interrupt based) * [ ] Button driver (interrupt based)
* [ ] Battery/charger driver * [ ] Battery/charger driver
* [ ] Simple clock and battery level application * [ ] Simple clock and battery level application

View file

@ -1,6 +1,6 @@
freeze('$(MPY_DIR)/../wasp', freeze('$(MPY_DIR)/../wasp',
( (
'main.py', 'boot.py',
'demo.py', 'demo.py',
'drivers/st7789.py', 'drivers/st7789.py',
'logo.py', 'logo.py',

@ -1 +1 @@
Subproject commit b6f0dee43e4c51afad6a0b1badd534df7a4494ad Subproject commit e668ed3ed3778bf5aea08e766cc8d82eb0a4c247

6
wasp/boot.py Normal file
View file

@ -0,0 +1,6 @@
import logo
import pinetime
pinetime.display.rleblit(logo.pine64, fg=0xffff)

View file

@ -24,10 +24,6 @@ colors = (
0xf81f, # magenta 0xf81f, # magenta
) )
# Let's keep this where we can find it if someone delivers ^C to the
# demo
tft = pinetime.st7789()
def run(): def run():
l = logo.pine64 l = logo.pine64
i = 0 i = 0
@ -42,8 +38,8 @@ def run():
l = logo.micropython l = logo.micropython
else: else:
l = logo.pine64 l = logo.pine64
tft.fill(0) pinetime.display.fill(0)
tft.rleblit(l, fg=c) pinetime.display.rleblit(l, fg=c)
time.sleep(2) time.sleep(2)
gc.collect() gc.collect()

View file

@ -3,18 +3,44 @@ from machine import SPI
from drivers.st7789 import ST7789_SPI from drivers.st7789 import ST7789_SPI
def st7789(): class Display(ST7789_SPI):
spi = SPI(0) def __init__(self):
# Mode 3, maximum clock speed! spi = SPI(0)
spi.init(polarity=1, phase=1, baudrate=8000000) # Mode 3, maximum clock speed!
spi.init(polarity=1, phase=1, baudrate=8000000)
# Configure the display # Configure the display
cs = Pin("SPI_SS2", Pin.OUT) cs = Pin("DISP_CS", Pin.OUT)
dc = Pin("P18", Pin.OUT) dc = Pin("DISP_DC", Pin.OUT)
rst = Pin("P26", Pin.OUT) rst = Pin("DISP_RST", Pin.OUT)
tft = ST7789_SPI(240, 240, spi, cs=cs, dc=dc, res=rst)
# Bring up the backlight super().__init__(240, 240, spi, cs=cs, dc=dc, res=rst)
bl = Pin("P22", Pin.OUT)
bl.off() # active low class Backlight(object):
return tft 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)