Пример #1
0
def light_report():
    m = {}
    m['act'] = 'light'
    m['living'] = led.get_status(config.LED_LIVING)
    m['bedroom'] = led.get_status(config.LED_BEDROOM)
    m['porch'] = led.get_status(config.LED_PORCH)

    msg = json.dumps(m)
    messenger.publish(msg, 1)
Пример #2
0
def do_steps():
    global steps_queue

    if steps_queue.qsize() == 0:
        return
    steps = steps_queue.get()
    if (steps > 0):
        step_fun = forward_one_step
        n = steps
    else:
        step_fun = backward_one_step
        n = -steps

    freq = led.get_frequency(config.LED_PORCH)
    dc = led.get_duty_cycle(config.LED_PORCH)
    status = led.get_status(config.LED_PORCH)

    led.turn_on(config.LED_PORCH, 2, 50)

    gpio_lock.acquire()
    for i in range(0, n):
        step_fun(0.01)
    set_motor_input(0, 0, 0, 0)
    gpio_lock.release()

    if status == 'on':
        led.turn_on(config.LED_PORCH, freq, dc)
    else:
        led.turn_off(config.LED_PORCH)
    status_notify()
Пример #3
0
def do_steps():
    global steps_queue

    if steps_queue.qsize() == 0:
        return;
    steps = steps_queue.get()
    if (steps > 0):
        step_fun = forward_one_step
        n = steps
    else:
        step_fun = backward_one_step
        n = -steps

    freq = led.get_frequency(config.LED_PORCH)
    dc = led.get_duty_cycle(config.LED_PORCH)
    status = led.get_status(config.LED_PORCH)

    led.turn_on(config.LED_PORCH, 2, 50)

    gpio_lock.acquire()
    for i in range(0, n):
        step_fun(0.01)
    set_motor_input(0, 0, 0, 0)
    gpio_lock.release()

    if status == 'on':
        led.turn_on(config.LED_PORCH, freq, dc)
    else:
        led.turn_off(config.LED_PORCH)
    status_notify()