def test(duration=0):  # responds to switches
    if duration:
        print("Tests pushbuttons for {:5d} seconds".format(duration))
    else:
        print("Tests pushbuttons")
    objSched = Sched()
    btn1 = Pin(14, Pin.IN, Pin.PULL_UP)
    btn2 = Pin(12, Pin.IN, Pin.PULL_UP)
    Pushbutton(objSched,
               btn1,
               descriptor,
               false_func=x5print,
               false_func_args=("Red", ))  # X5 triggers on open
    Pushbutton(objSched,
               btn2,
               descriptor,
               true_func=x6print,
               true_func_args=("Yellow", ),
               long_func=yellowlong,
               long_func_args=("Long press", ),
               double_func=yellowdbl,
               double_func_args=("Double click", ))  # X6 triggers on close
    if duration:
        objSched.add_thread(stop(duration, objSched))
    objSched.run()
def test(duration=0):
    objSched = Sched()
    objSched.add_thread(robin("Thread 1"))
    objSched.add_thread(robin("Thread 2"))
    objSched.add_thread(robin("Thread 3"))
    if duration:
        objSched.add_thread(stop(duration, objSched))  # Kill after a period
    objSched.run()
Beispiel #3
0
def test(duration=0):
    objSched = Sched(True, 1)  # heartbeat on LED 1
    objSched.add_thread(robin("Thread 1"))
    objSched.add_thread(robin("Thread 2"))
    objSched.add_thread(robin("Thread 3"))
    if duration:
        objSched.add_thread(stop(duration, objSched))  # Kill after a period
    objSched.run()
def test(duration=0):
    if duration:
        print("Test LCD display for {:3d} seconds".format(duration))
    objSched = Sched()
    lcd0 = LCD(PINLIST, objSched, cols=16)
    objSched.add_thread(lcd_thread(lcd0))
    if duration:
        objSched.add_thread(stop(duration, objSched))
    objSched.run()
def test(duration = 0):
    if duration:
        print("Output accelerometer values for {:3d} seconds".format(duration))
    else:
        print("Output accelerometer values")
    objSched = Sched()
    objSched.add_thread(accelthread())
    if duration:
        objSched.add_thread(stop(duration, objSched))           # Run for a period then stop
    objSched.run()
Beispiel #6
0
def setup():
    objsched = Sched(
        True, 1)  # Instantiate the scheduler with GC and heartbeat on red LED
    tft = TFT_G("SSD1963", "LB04301", LANDSCAPE)
    touch = TOUCH("XPT2046", objsched, confidence=50, margin=50)
    # (-3886,-0.1287,-3812,-0.132,-3797,-0.07685,-3798,-0.07681))
    tft.backlight(
        100
    )  # light on: remove this line if you don't have backlight control hardware
    Screen.setup(objsched, tft, touch)
def test(duration = 0):
    objSched = Sched()
    objSched.add_thread(robin("Thread 1"))                  # Instantiate a few threads
    objSched.add_thread(robin("Thread 2"))
    objSched.add_thread(robin("Thread 3"))
    lstResult = [0, 0]
    objSched.add_thread(thr_instrument(objSched, lstResult))
    if duration:
        objSched.add_thread(stop(duration, objSched))           # Run for a period then stop
    objSched.run()
    print("Maximum delay was {:6.1f}mS".format(lstResult[0]/1000.0))
    print("Thread was executed {:3d} times in {:3d} seconds".format(lstResult[1], duration))
Beispiel #8
0
def run():
    OB = output_buffer()
    compassthread = compass.cthread(OB)
    pyb.delay(100)
    othread = outputthread(OB)
    objSched = Sched()
    objSched.add_thread(seatalkthread(OB))
    objSched.add_thread(compassthread)
    pyb.delay(100)
    objSched.add_thread(barometerthread(OB))
    objSched.add_thread(othread)
    objSched.run()
Beispiel #9
0
def test(duration=0):
    if duration:
        print("Flash LED's for {:3d} seconds".format(duration))
    leds = [pyb.LED(x)
            for x in range(1, 5)]  # Initialise all four on board LED's
    objSched = Sched()  # Instantiate the scheduler
    for x in range(4):  # Create a thread instance for each LED
        objSched.add_thread(toggle(leds[x], 0.2 + x / 2))
    if duration:
        objSched.add_thread(
            stop(duration,
                 objSched))  # Commit suicide after specified no. of seconds
    objSched.run()  # Run it!
def test(duration=0
         ):  # Runs oscillator, counts interrupts, responds to switches
    if duration:
        print("Test interrupt on pin X8 for {:3d} seconds".format(duration))
    objSched = Sched()  # Requires jumper between pins X7 and X8
    objSched.add_thread(oscillator(1))  # 1Hz
    objSched.add_thread(irqtest_thread())
    Switch(objSched, 'X5', open_func=x5print,
           open_func_args=("Red", ))  # X5 triggers on open
    Switch(objSched, 'X6', x6print, ("Yellow", ))  # X6 triggers on close
    if duration:
        objSched.add_thread(stop(duration, objSched))
    objSched.run()
def test():
    freq(160000000)
    mtx = Pin(14, Pin.OUT)  # Define pins
    mckout = Pin(15, Pin.OUT, value=0)  # clocks must be initialised to zero.
    mrx = Pin(13, Pin.IN)
    mckin = Pin(12, Pin.IN)

    objsched = Sched(heartbeat=1)
    channel = SynCom(objsched, True, mckin, mckout, mrx, mtx)
    channel.start()
    objsched.add_thread(passive_thread(channel))
    try:
        objsched.run()
    finally:
        mckout(0)
Beispiel #12
0
def test(duration=0):
    if duration:
        print("Flash LED's for {:3d} seconds".format(duration))
    print('Interrupt with ctrl-C or wait for deliberate error')
    print('Expect the usual error dump. But should see four exit lines first.')
    leds = [pyb.LED(x)
            for x in range(1, 5)]  # Initialise all four on board LED's
    objSched = Sched()  # Instantiate the scheduler
    for x in range(4):  # Create a thread instance for each LED
        objSched.add_thread(toggle(leds[x], 0.2 + x / 2, x))
    if duration:
        objSched.add_thread(
            stop(duration,
                 objSched))  # Commit suicide after specified no. of seconds
    objSched.run()  # Run it!
Beispiel #13
0
def test():
    stx = Pin(Pin.board.Y5, Pin.OUT_PP)  # Define pins
    sckout = Pin(Pin.board.Y6, Pin.OUT_PP)
    sckout.value(0)  # Don't assert clock until data is set
    srx = Pin(Pin.board.Y7, Pin.IN)
    sckin = Pin(Pin.board.Y8, Pin.IN)
    reset = Pin(Pin.board.Y4, Pin.OPEN_DRAIN)

    objsched = Sched(heartbeat=1)
    channel = SynCom(objsched, False, sckin, sckout, srx, stx)
    channel.start(reset, 0)
    objsched.add_thread(initiator_thread(channel))
    try:
        objsched.run()
    finally:
        sckout.value(0)
def test(duration):
    assert duration >= 1, 'Duration must be at least one second'
    print('Running test for {} seconds'.format(duration))
    objSched = Sched()
    leds = [pyb.LED(x)
            for x in range(1, 5)]  # Initialise all four on board LED's
    for x in range(4):  # Create a thread instance for each LED
        objSched.add_thread(toggle(leds[x], 0.2 + x / 2))


#    objSched.add_thread(robin("Thread 1"))      # Instantiate a few threads
#    objSched.add_thread(robin("Thread 2"))
#    objSched.add_thread(robin("Thread 3"))
    lstResult = [0, 0]
    objSched.add_thread(thr_instrument(objSched, lstResult))
    objSched.add_thread(instrument(objSched, 0.1, duration))
    objSched.run()
    print("Maximum roundrobin yield delay was {:6.1f}mS".format(lstResult[0] /
                                                                1000.0))
    print(
        "Thread thr_instrument was executed {:3d} times in {:3d} seconds {:5d}Hz"
        .format(lstResult[1], duration, lstResult[1] // duration))
Beispiel #15
0
def test():
    sched = Sched(True)
    sched.add_thread(flash(0, 0.5))
    sched.add_thread(flash(2, 0.25))
    sched.add_thread(stop(5.6, sched))
    sched.run()
Beispiel #16
0
from usched import Sched
from machine import Pin
from time import sleep

led1 = Pin(4, Pin.OUT)
led2 = Pin(13, Pin.OUT)


def toggle1(objLED):
    while True:
        sleep(1)
        yield
        objLED.value(not objLED.value())


def toggle2(objLED):
    while True:
        sleep(.1)
        yield
        objLED.value(not objLED.value())


objSched = Sched()
objSched.add_thread(toggle1(led1))
objSched.add_thread(toggle2(led2))
objSched.run()
Beispiel #17
0
def test():
    objSched = Sched()
    lcd0 = LCD(PINLIST, objSched, cols=24)
    objSched.add_thread(master(lcd=lcd0))
    objSched.run()
Beispiel #18
0
def test():
    print("Demonstration of subthreads")
    objSched = Sched()
    objSched.add_thread(
        waitforit(objSched))  # Test of one thread waiting on another
    objSched.run()