How to use the pfio.digital_write function in pfio

To help you get started, we’ve selected a few pfio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thomasmacpherson / piface / python / piface / pfion.py View on Github external
sock.sendto(p.for_network(), sender)

        elif packet.command == READ_OUT_CMD:
            output_bitp = pfio.read_output()
            p = PfionPacket(READ_OUT_ACK)
            p.bit_pattern = output_bitp
            sock.sendto(p.for_network(), sender)

        elif packet.command == READ_IN_CMD:
            input_bitp = pfio.read_input()
            p = PfionPacket(READ_IN_ACK)
            p.bit_pattern = input_bitp
            sock.sendto(p.for_network(), sender)

        elif packet.command == DIGITAL_WRITE_CMD:
            pfio.digital_write(packet.pin_number, packet.pin_value)
            p = PfionPacket(DIGITAL_WRITE_ACK)
            sock.sendto(p.for_network(), sender)

        elif packet.command ==  DIGITAL_READ_CMD:
            pin_value = pfio.digital_read(packet.pin_number)
            p = PfionPacket(DIGITAL_READ_ACK)
            p.pin_number = packet.pin_number
            p.pin_value  = pin_value
            sock.sendto(p.for_network(), sender)

        elif callback != None:
            callback(packet, sender)

        elif verbose:
            print "Unkown packet command (%d). Ignoring." % packet.command
github thomasmacpherson / piface / build / lib.linux-armv6l-2.6 / shift.py View on Github external
def shift_out(data_pin, latch_pin, clock_pin, edian, data):
	delay()
	print "Latch pin low"
	pfio.digital_write(latch_pin,0)
	delay()	
	print "clock pin low"
	pfio.digital_write(clock_pin, 0)
	delay()
	
	data_bits = str(bin(data)[2:].zfill(8))


	if edian:

		for bit in data_bits:
			bit = int(bit)
			print bit
			pfio.digital_write(data_pin, bit)
			delay()
			pulse_clock(clock_pin)

	else:
		for bit in reversed(data_bits):
github thomasmacpherson / piface / build / lib.linux-armv6l-2.6 / shift.py View on Github external
def pulse_clock(clock_pin):
	print "clock high"
	pfio.digital_write(clock_pin, 1)
	delay()	
	print "clock low"
	pfio.digital_write(clock_pin, 0)
	delay()
github thomasmacpherson / piface / build / lib.linux-armv6l-2.6 / shift.py View on Github external
def pulse_clock(clock_pin):
	print "clock high"
	pfio.digital_write(clock_pin, 1)
	delay()	
	print "clock low"
	pfio.digital_write(clock_pin, 0)
	delay()
github thomasmacpherson / piface / build / lib.linux-armv6l-2.6 / shift.py View on Github external
def shift_out(data_pin, latch_pin, clock_pin, edian, data):
	delay()
	print "Latch pin low"
	pfio.digital_write(latch_pin,0)
	delay()	
	print "clock pin low"
	pfio.digital_write(clock_pin, 0)
	delay()
	
	data_bits = str(bin(data)[2:].zfill(8))


	if edian:

		for bit in data_bits:
			bit = int(bit)
			print bit
			pfio.digital_write(data_pin, bit)
			delay()
			pulse_clock(clock_pin)
github thomasmacpherson / piface / build / lib.linux-armv6l-2.6 / shift.py View on Github external
print bit
			pfio.digital_write(data_pin, bit)
			delay()
			pulse_clock(clock_pin)

	else:
		for bit in reversed(data_bits):
			bit = int(bit)
			print bit
			pfio.digital_write(data_pin, bit)
			delay()
			pulse_clock(clock_pin)

	delay()
	print "latch pin high"
	pfio.digital_write(latch_pin,1)
github thomasmacpherson / piface / build / lib.linux-armv6l-2.6 / shift.py View on Github external
if edian:

		for bit in data_bits:
			bit = int(bit)
			print bit
			pfio.digital_write(data_pin, bit)
			delay()
			pulse_clock(clock_pin)

	else:
		for bit in reversed(data_bits):
			bit = int(bit)
			print bit
			pfio.digital_write(data_pin, bit)
			delay()
			pulse_clock(clock_pin)

	delay()
	print "latch pin high"
	pfio.digital_write(latch_pin,1)