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 spi_read(channel): if str(channel) not in ['0', '1', '2', '3']: return "You seem to be trying to read from SPI channel {0}, which does not exist. Try 0, 1, 2, or 3.".format(channel) return pytronics.spiRead(channel)
def spi_read(channel): if str(channel) not in ['0', '1', '2', '3']: return "You seem to be trying to read from SPI channel {0}, which does not exist. Try 0, 1, 2, or 3.".format( channel) return pytronics.spiRead(channel)