Ejemplo n.º 1
0
def setLight(color, value):
	
	if color in [None, 'none']:
		return
	
	if color not in _pins:
		raise Exception('Unsupported light color.')
	print('set light', color, value)
	gpio.write(_pins[color], value)
Ejemplo n.º 2
0
def setLight(color, value):

    if color in [None, 'none']:
        return

    if color not in _pins:
        raise Exception('Unsupported light color.')
    print('set light', color, value)
    gpio.write(_pins[color], value)
def exchange(dOut):
    # Trade 1 byte between CPI and Arduino.

    global cpiState, ardState

    ardState = gpio.read(ARD)

    dIn = 0
    for i in range(BITS):

        gpio.write(DAT_OUT, (dOut >> i) % 2)

        gpio.write(CPI, cpiState)
        cpiState = not cpiState

        starTime = time.time()
        while(gpio.read(ARD) == ardState):
            time.sleep(0.0001)
            if starTime + TIMEOUT < time.time():
                return -1
        ardState = not ardState

        dIn += gpio.read(DAT_IN) << i

    gpio.write(CPI, cpiState)
    cpiState = not cpiState

    return dIn
Ejemplo n.º 4
0
import gpio

register = gpio.read(18)
print "Read: 0x%08X" % register

gpio.write(18, 0)