コード例 #1
0
except:
    ble_enabled = False

if ble_enabled:
    print("SKIP")
    raise SystemExit

mch = os.uname().machine
if 'PCA10040' in mch:
    num_of_counters = 3
else:
    raise Exception('Board not supported!')

# Test that all instances are available
for i in range(num_of_counters):
    tim = RTCounter(i, period=5, mode=RTCounter.PERIODIC, callback=None)
    print(tim)
    tim.deinit()

# Test that too high instance number fails
try:
    tim = RTCounter(num_of_counters+1)
except ValueError:
    print('ValueError')

# Test that -1 is not allowed
try:
    tim = RTCounter(-1)
except ValueError:
    print("ValueError")
コード例 #2
0
ファイル: watch.py プロジェクト: mulm/wasp-os
# Start measuring time (and feeding the watchdog) before *anything* else
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 SPI

from drivers.battery import Battery
from drivers.signal import Signal
from drivers.st7789 import ST7789_SPI
from drivers.vibrator import Vibrator
from flash.flash_spi import FLASH


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