1
0
Fork 0

wasp: pinetime: Enable filesystem support

This commit is contained in:
Daniel Thompson 2020-02-09 19:49:52 +00:00
parent 3bc59b1c71
commit b2c5b482d5
4 changed files with 51 additions and 25 deletions

View file

@ -1,3 +1,4 @@
freeze('.', 'watch.py', opt=3)
freeze('../..', freeze('../..',
( (
'boot.py', 'boot.py',
@ -10,11 +11,15 @@ freeze('../..',
'drivers/vibrator.py', 'drivers/vibrator.py',
'fonts.py', 'fonts.py',
'icons.py', 'icons.py',
'main.py',
'manager.py', 'manager.py',
'logo.py', 'logo.py',
'widgets.py', 'widgets.py',
), ),
opt=3 opt=3
) )
freeze('.', 'watch.py', opt=3) freeze('../../drivers/flash',
(
'bdevice.py',
'flash/flash_spi.py'
), opt=3
)

View file

@ -1,26 +1,21 @@
from machine import Pin # Start measuring time (and feeding the watchdog) before *anything* else
from machine import RTCounter from machine import RTCounter
from drivers.nrf_rtc import RTC
rtc = RTC(RTCounter(1, mode=RTCounter.PERIODIC))
rtc.counter.start()
import os
import time
from machine import Pin
#from machine import Signal #from machine import Signal
from machine import SPI from machine import SPI
from drivers.battery import Battery from drivers.battery import Battery
from drivers.nrf_rtc import RTC
from drivers.signal import Signal from drivers.signal import Signal
from drivers.st7789 import ST7789_SPI from drivers.st7789 import ST7789_SPI
from drivers.vibrator import Vibrator from drivers.vibrator import Vibrator
from flash.flash_spi import FLASH
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)
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): class Backlight(object):
lo = Pin("BL_LO", Pin.OUT, value=0) lo = Pin("BL_LO", Pin.OUT, value=0)
@ -46,17 +41,43 @@ class Backlight(object):
self.mid(mid) self.mid(mid)
self.lo(lo) self.lo(lo)
# Setup the display (and manage the backlight)
backlight = Backlight(0) backlight = Backlight(0)
display = Display() spi = SPI(0)
backlight.set(1) spi.init(polarity=1, phase=1, baudrate=8000000)
display = ST7789_SPI(240, 240, spi,
# Start measuring time (and feeding the watchdog) cs=Pin("DISP_CS", Pin.OUT),
rtc = RTC(RTCounter(1, mode=RTCounter.PERIODIC)) dc=Pin("DISP_DC", Pin.OUT),
rtc.counter.start() res=Pin("DISP_RST", Pin.OUT))
# Setup the last few bits and pieces
battery = Battery( battery = Battery(
Pin('BATTERY', Pin.IN), Pin('BATTERY', Pin.IN),
Signal(Pin('CHARGING', Pin.IN), invert=True), Signal(Pin('CHARGING', Pin.IN), invert=True),
Signal(Pin('USB_PWR', Pin.IN), invert=True)) Signal(Pin('USB_PWR', Pin.IN), invert=True))
vibrator = Vibrator(Pin('MOTOR', Pin.OUT, value=0), active_low=True) vibrator = Vibrator(Pin('MOTOR', Pin.OUT, value=0), active_low=True)
button = Pin('BUTTON', Pin.IN) button = Pin('BUTTON', Pin.IN)
# Mount the filesystem
flash = FLASH(spi, (Pin('NOR_CS', Pin.OUT, value=1),))
try:
os.mount(flash, '/flash')
except AttributeError:
# Format the filesystem (and provide a default version of main.py)
os.VfsLfs2.mkfs(flash)
os.mount(flash,'/flash')
with open('/flash/main.py', 'w') as f:
f.write('''\
import manager
wasp = manager.Manager(watch)
wasp.run()
''')
# Only change directory if the button is not pressed (this will
# allow us access to fix any problems with main.py)!
if not button.value():
os.chdir('/flash')
backlight.set(1)
else:
display.poweroff()

View file

@ -1,3 +1 @@
import manager
import watch import watch
wasp = manager.Manager(watch)

View file

@ -1 +1,3 @@
import manager, watch
wasp = manager.Manager(watch)
wasp.run() wasp.run()