blob: 6a53c0263d43552ef1c58666555e0f1eca2a0d0d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
import smbus
import time
def version():
print "i2cPixel is Version 1.0.0"
def setAddress(address):
global arduinoAddress
arduinoAddress = address
def setBus(n):
global bus
bus = smbus.SMBus(n)
def greeting():
""" Send heartbeat """
bus.write_byte(arduinoAddress, 0x01)
""" Wait for response """
try:
response = bus.read_byte(arduinoAddress)
if response == 0x01:
returnMsg = True
else:
returnMsg = False
except:
returnMsg = False
""" Return if heartbeat was received """
return returnMsg
def setPixel(n, red, green, blue):
""" Send values for switching a pixel on """
bus.write_block_data(arduinoAddress, 0x02, [n, red, green, blue])
def showPixel():
bus.write_byte(arduinoAddress, 0x03)
def waitForSensor():
while True:
try:
sensorData = bus.read_byte(arduinoAddress)
if sensorData = 0x02:
""" sjekk hvilken sensor """
|