Exemplo n.º 1
0
def flash_led():
    if pytronics.digitalRead('LED') == '1':
        pytronics.digitalWrite('LED', 'LOW')
        message = "LED off"
    else:
        pytronics.digitalWrite('LED', 'HIGH')
        message = "LED on"
    return (message)
Exemplo n.º 2
0
def flash_led():
    if pytronics.digitalRead('LED') == '1':
        pytronics.digitalWrite('LED', 'LOW')
        message = "LED off"
    else:
        pytronics.digitalWrite('LED', 'HIGH')
        message = "LED on"
    return (message)
Exemplo n.º 3
0
def digital_toggle(pin_name):
    if pin_name in DIGITAL_PINS:
        if pytronics.digitalRead(pin_name) == '1':
            pytronics.digitalWrite(pin_name, 'LOW')
            return 'Set pin {0} to LOW'.format(pin_name)
        else:
            pytronics.digitalWrite(pin_name, 'HIGH')
            return 'Set pin {0} to HIGH'.format(pin_name)
    else:
        return DIGITAL_PIN_NAME_ERROR.format(pin_name)
Exemplo n.º 4
0
def digital_toggle(pin_name):
    if pin_name in DIGITAL_PINS:
        if str(pytronics.digitalRead(pin_name)) == '1':
            pytronics.digitalWrite(pin_name, 'LOW')
            return 'Set pin {0} to LOW'.format(pin_name)
        else:
            pytronics.digitalWrite(pin_name, 'HIGH')
            return 'Set pin {0} to HIGH'.format(pin_name)
    else:
        return DIGITAL_PIN_NAME_ERROR.format(pin_name)
Exemplo n.º 5
0
def pvs_read():
    pytronics.spiSetSpeed(1000000)
    pytronics.pinMode('3', 'INPUT')
    pytronics.pinMode('5', 'OUTPUT')
    pytronics.digitalWrite('5', 'LOW')
    pytronics.digitalWrite('5', 'HIGH')
    start = time.time()
    while((time.time() < start + 1000) and (pytronics.digitalRead('4') == '1')):
        pass
    data = pytronics.spiRead(14)
    b = bitstring.BitArray(hex=binascii.hexlify(data))
    return ', '.join([str(5*float(chunk.int)/16384) for chunk in b.cut(14)])
Exemplo n.º 6
0
def pvs_read():
    pytronics.spiSetSpeed(1000000)
    pytronics.pinMode("3", "INPUT")
    pytronics.pinMode("5", "OUTPUT")
    pytronics.digitalWrite("5", "LOW")
    pytronics.digitalWrite("5", "HIGH")
    start = time.time()
    while (time.time() < start + 1000) and (pytronics.digitalRead("4") == "1"):
        pass
    data = pytronics.spiRead(14)
    b = bitstring.BitArray(hex=binascii.hexlify(data))
    return ", ".join([str(5 * float(chunk.int) / 16384) for chunk in b.cut(14)])
Exemplo n.º 7
0
def digital_read(pin_name):
    if pin_name not in DIGITAL_PINS:
        return DIGITAL_PIN_NAME_ERROR.format(pin_name)
    else:
        return pytronics.digitalRead(pin_name)
Exemplo n.º 8
0
def digital_read(pin_name):
    if pin_name not in DIGITAL_PINS:
        return DIGITAL_PIN_NAME_ERROR.format(pin_name)
    else:
        return str(pytronics.digitalRead(pin_name))
Exemplo n.º 9
0
def toggle_pin(pin):
    if pytronics.digitalRead(pin) == '1':
        pytronics.digitalWrite(pin, 'LOW')
    else:
        pytronics.digitalWrite(pin, 'HIGH')
Exemplo n.º 10
0
def index():
    pin = pytronics.digitalRead(2)
    (chan0, chan1, chan2, chan3) = [pytronics.analogRead(chan) for chan in ['A0', 'A1', 'A2', 'A3']]
    return render_template('/relay.html', chan0=chan0, chan1=chan1, chan2=chan2, chan3=chan3, pin=pin)
Exemplo n.º 11
0
def toggle_pin(pin):
    if pytronics.digitalRead(pin) == '1':
        pytronics.digitalWrite(pin, 'LOW')
    else:
        pytronics.digitalWrite(pin, 'HIGH')