Exemplo n.º 1
0
    def get_localtime(self):
        return time.localtime()

    def get_time(self):
        now = time.localtime()
        return (now[3], now[4], now[5])

    def uptime(self):
        return time.time()

    def get_uptime_ms(self):
        return int(time.time() * 1000)


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)
Exemplo n.º 2
0
    def get_time(self):
        now = self.get_localtime()
        return (now[3], now[4], now[5])

    @property
    def uptime(self):
        return time.time() - self._epoch

    def get_uptime_ms(self):
        return int(self.uptime * 1000)


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)

accel = Accelerometer()
battery = Battery()
button = Pin('BUTTON', Pin.IN, quiet=True)
rtc = RTC()
touch = CST816S(I2C(0), Pin('TP_INT', Pin.IN, quiet=True),
                Pin('TP_RST', Pin.OUT, quiet=True))
vibrator = Vibrator(Pin('MOTOR', Pin.OUT, value=0), active_low=True)
Exemplo n.º 3
0
spi.init(polarity=1, phase=1, baudrate=8000000)
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(Pin('BATTERY', Pin.IN),
                  Signal(Pin('CHARGING', Pin.IN), invert=True),
                  Signal(Pin('USB_PWR', Pin.IN), invert=True))
button = Pin('BUTTON', Pin.IN)
i2c = I2C(1, scl='I2C_SCL', sda='I2C_SDA')
touch = CST816S(i2c)
vibrator = Vibrator(Pin('MOTOR', Pin.OUT, value=0), active_low=True)

# 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()