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)
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)
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)
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)])
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)])
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)
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))
def toggle_pin(pin): if pytronics.digitalRead(pin) == '1': pytronics.digitalWrite(pin, 'LOW') else: pytronics.digitalWrite(pin, 'HIGH')
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)