first commit
This commit is contained in:
commit
b8768c3ff8
249 files changed
+38439
No files matched your search
Whitespace-only changes.
@@ -0,0 +1,22 @@
|
||||
import wiringpi
|
||||
import time
|
||||
import sys
|
||||
from wiringpi import GPIO
|
||||
|
||||
wiringpi.wiringPiSetup()
|
||||
NUM = wiringpi.getGpioNum()
|
||||
|
||||
for i in range(0, NUM):
|
||||
wiringpi.pinMode(i, GPIO.OUTPUT) ;
|
||||
|
||||
while True:
|
||||
try:
|
||||
for i in range(0, NUM):
|
||||
wiringpi.digitalWrite(i, GPIO.HIGH)
|
||||
time.sleep(1)
|
||||
for i in range(0, NUM):
|
||||
wiringpi.digitalWrite(i, GPIO.LOW)
|
||||
time.sleep(1)
|
||||
except KeyboardInterrupt:
|
||||
print("\nexit")
|
||||
sys.exit(0)
|
||||
@@ -0,0 +1,14 @@
|
||||
import wiringpi
|
||||
PIN_TO_SENSE = 23
|
||||
|
||||
def gpio_callback():
|
||||
print "GPIO_CALLBACK!"
|
||||
|
||||
wiringpi.wiringPiSetupGpio()
|
||||
wiringpi.pinMode(PIN_TO_SENSE, wiringpi.GPIO.INPUT)
|
||||
wiringpi.pullUpDnControl(PIN_TO_SENSE, wiringpi.GPIO.PUD_UP)
|
||||
|
||||
wiringpi.wiringPiISR(PIN_TO_SENSE, wiringpi.GPIO.INT_EDGE_BOTH, gpio_callback)
|
||||
|
||||
while True:
|
||||
wiringpi.delay(2000)
|
||||
@@ -0,0 +1,5 @@
|
||||
# Demonstrates use of Arduino-like delay function
|
||||
import wiringpi
|
||||
print 'Hello World'
|
||||
wiringpi.delay(1500) # Delay for 1.5 seconds
|
||||
print 'Hi again!'
|
||||
@@ -0,0 +1,133 @@
|
||||
import sys
|
||||
import time
|
||||
import wiringpi
|
||||
from datetime import datetime
|
||||
import operator
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(description='i2c')
|
||||
parser.add_argument("--device", type=str, default="/dev/i2c-0", help='specify the i2c node')
|
||||
args = parser.parse_args()
|
||||
|
||||
i2caddr = 0x68
|
||||
|
||||
def b2s(bcd, mask):
|
||||
bcd &= mask
|
||||
b1 = bcd & 0x0F
|
||||
b2 = ((bcd >> 4) & 0x0F)*10
|
||||
return b1 + b2
|
||||
|
||||
def decCompensation(units):
|
||||
unitsU = units%10
|
||||
if units >= 50:
|
||||
units = 0x50 + unitsU
|
||||
elif units >= 40:
|
||||
units = 0x40 + unitsU
|
||||
elif units >= 30:
|
||||
units = 0x30 + unitsU
|
||||
elif units >= 20:
|
||||
units = 0x20 + unitsU
|
||||
elif units >= 10:
|
||||
units = 0x10 + unitsU
|
||||
return units
|
||||
|
||||
def getHours():
|
||||
HH = time.strftime("%H")
|
||||
return decCompensation(int(HH))
|
||||
|
||||
def getMins():
|
||||
MM = time.strftime("%M")
|
||||
return decCompensation(int(MM))
|
||||
|
||||
def getSecs():
|
||||
SS = time.strftime("%S")
|
||||
return decCompensation(int(SS))
|
||||
|
||||
def getWeeks():
|
||||
WW = time.strftime("%w")
|
||||
return decCompensation(int(WW))
|
||||
|
||||
def getDays():
|
||||
DD = time.strftime("%d")
|
||||
return decCompensation(int(DD))
|
||||
|
||||
def getMons():
|
||||
MON = time.strftime("%m")
|
||||
return decCompensation(int(MON))
|
||||
|
||||
def getYear():
|
||||
YY = time.strftime("%Y")
|
||||
return decCompensation(int(YY))
|
||||
|
||||
def ds1307_write_byte(fd, reg, byte):
|
||||
if wiringpi.wiringPiI2CWriteReg8(fd, reg, byte) < 0:
|
||||
print("Error write byte to ds1307")
|
||||
return -1
|
||||
return 0
|
||||
|
||||
def ds1307_read_byte(fd, reg):
|
||||
byte = wiringpi.wiringPiI2CReadReg8(fd, reg)
|
||||
if byte < 0:
|
||||
print("Error read byte from ds1307")
|
||||
return -1
|
||||
return byte
|
||||
|
||||
def sys2rtcSet(fd):
|
||||
ds1307_write_byte(fd, 0x02, getHours())
|
||||
ds1307_write_byte(fd, 0x01, getMins())
|
||||
ds1307_write_byte(fd, 0x00, getSecs())
|
||||
ds1307_write_byte(fd, 0x03, getWeeks())
|
||||
ds1307_write_byte(fd, 0x04, getDays())
|
||||
ds1307_write_byte(fd, 0x05, getMons())
|
||||
ds1307_write_byte(fd, 0x06, getYear())
|
||||
|
||||
def read_register(fd):
|
||||
byte = ds1307_read_byte(fd, 0x0)
|
||||
if byte >> 7:
|
||||
ds1307_write_byte(fd, 0x0, 0x0)
|
||||
second = operator.mod(byte, 16) + operator.floordiv(byte, 16) * 10
|
||||
|
||||
byte = ds1307_read_byte(fd, 0x01)
|
||||
minute = operator.mod(byte, 16) + operator.floordiv(byte, 16) * 10
|
||||
|
||||
byte = ds1307_read_byte(fd, 0x02)
|
||||
hour = operator.mod(byte, 16) + operator.floordiv(byte, 16) * 10
|
||||
|
||||
week = ds1307_read_byte(fd, 0x03)
|
||||
|
||||
byte = ds1307_read_byte(fd, 0x04)
|
||||
day = operator.mod(byte, 16) + operator.floordiv(byte, 16) * 10
|
||||
|
||||
byte = ds1307_read_byte(fd, 0x05)
|
||||
month = operator.mod(byte, 16) + operator.floordiv(byte, 16) * 10
|
||||
|
||||
byte = ds1307_read_byte(fd, 0x06)
|
||||
year = operator.mod(byte, 16) + operator.floordiv(byte, 16) * 10 + 1970
|
||||
|
||||
if year == 2000 or month > 12 or month<1 or day < 1 or day > 31:
|
||||
return False
|
||||
|
||||
if second > 59:
|
||||
return False
|
||||
return datetime(year,month,day,hour,minute,second)
|
||||
|
||||
def main():
|
||||
wiringpi.wiringPiSetup()
|
||||
fd = wiringpi.wiringPiI2CSetupInterface(args.device, i2caddr)
|
||||
try:
|
||||
sys2rtcSet(fd)
|
||||
while True:
|
||||
time.sleep(1)
|
||||
dt = read_register(fd)
|
||||
if not dt:
|
||||
continue
|
||||
else:
|
||||
str_time = dt.strftime("%a %Y-%m-%d %H:%M:%S")
|
||||
print("%s"%(str_time))
|
||||
except KeyboardInterrupt:
|
||||
print("\nexit")
|
||||
sys.exit(0)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import wiringpi
|
||||
INPUT = 0
|
||||
OUTPUT = 1
|
||||
LOW = 0
|
||||
HIGH = 1
|
||||
BUTTONS = [13,12,10,11]
|
||||
LEDS = [0,1,2,3,4,5,6,7,8,9]
|
||||
PUD_UP = 2
|
||||
|
||||
wiringpi.wiringPiSetup()
|
||||
|
||||
for button in BUTTONS:
|
||||
wiringpi.pinMode(button,INPUT)
|
||||
wiringpi.pullUpDnControl(button,PUD_UP)
|
||||
|
||||
for led in LEDS:
|
||||
wiringpi.pinMode(led,OUTPUT)
|
||||
|
||||
while 1:
|
||||
for index,button in enumerate(BUTTONS):
|
||||
button_state = wiringpi.digitalRead(button)
|
||||
first_led = LEDS[index*2]
|
||||
second_led = LEDS[(index*2)+1]
|
||||
#print str(button) + ' ' + str(button_state)
|
||||
wiringpi.digitalWrite(first_led,1-button_state)
|
||||
wiringpi.digitalWrite(second_led,1-button_state)
|
||||
wiringpi.delay(20)
|
||||
@@ -0,0 +1,95 @@
|
||||
# Turns on each pin of an mcp23017 on address 0x20 ( quick2wire IO expander )
|
||||
import wiringpi
|
||||
|
||||
PIN_BACKLIGHT = 67 # LED
|
||||
PIN_SCLK = 68 # Clock SCLK
|
||||
PIN_SDIN = 69 # DN(MOSI)
|
||||
PIN_DC = 70 # D/C
|
||||
PIN_RESET = 71 # RST Reset
|
||||
PIN_SCE = 72 # SCE
|
||||
|
||||
#PIN_BACKLIGHT = 5
|
||||
#PIN_SCLK = 4
|
||||
#PIN_SDIN = 3
|
||||
#PIN_DC = 2
|
||||
#PIN_RESET = 1
|
||||
#PIN_SCE = 0
|
||||
|
||||
OUTPUT = 1
|
||||
INPUT = 0
|
||||
HIGH = 1
|
||||
LOW = 0
|
||||
|
||||
LCD_C = 0
|
||||
LCD_D = 1
|
||||
|
||||
LCD_X = 84
|
||||
LCD_Y = 48
|
||||
LCD_SEGS = 504
|
||||
|
||||
MSBFIRST = 1
|
||||
LSBFIRST = 0
|
||||
|
||||
SLOW_DOWN = 400
|
||||
|
||||
pin_base = 65
|
||||
i2c_addr = 0x21
|
||||
|
||||
wiringpi.wiringPiSetup()
|
||||
wiringpi.mcp23017Setup(pin_base,i2c_addr)
|
||||
|
||||
def slow_shift_out(data_pin, clock_pin, data):
|
||||
for bit in bin(data).replace('0b','').rjust(8,'0'):
|
||||
wiringpi.digitalWrite(clock_pin,LOW)
|
||||
wiringpi.delay(SLOW_DOWN)
|
||||
wiringpi.digitalWrite(data_pin,int(bit))
|
||||
wiringpi.delay(SLOW_DOWN)
|
||||
wiringpi.digitalWrite(clock_pin,HIGH)
|
||||
wiringpi.delay(SLOW_DOWN)
|
||||
|
||||
def lcd_write(dc, data):
|
||||
wiringpi.digitalWrite(PIN_DC, dc)
|
||||
wiringpi.digitalWrite(PIN_SCE, LOW)
|
||||
wiringpi.delay(SLOW_DOWN)
|
||||
#wiringpi.shiftOut(PIN_SDIN, PIN_SCLK, MSBFIRST, data)
|
||||
slow_shift_out(PIN_SDIN, PIN_SCLK, data)
|
||||
wiringpi.digitalWrite(PIN_SCE, HIGH)
|
||||
wiringpi.delay(SLOW_DOWN)
|
||||
#wiringpi.delay(2)
|
||||
|
||||
def lcd_initialise():
|
||||
wiringpi.pinMode(PIN_BACKLIGHT,OUTPUT)
|
||||
wiringpi.digitalWrite(PIN_BACKLIGHT, HIGH)
|
||||
wiringpi.pinMode(PIN_SCE, OUTPUT)
|
||||
wiringpi.pinMode(PIN_RESET, OUTPUT)
|
||||
wiringpi.pinMode(PIN_DC, OUTPUT)
|
||||
wiringpi.pinMode(PIN_SDIN, OUTPUT)
|
||||
wiringpi.pinMode(PIN_SCLK, OUTPUT)
|
||||
wiringpi.digitalWrite(PIN_RESET, LOW)
|
||||
wiringpi.delay(SLOW_DOWN)
|
||||
wiringpi.digitalWrite(PIN_RESET, HIGH)
|
||||
wiringpi.delay(SLOW_DOWN)
|
||||
lcd_write(LCD_C, 0x21 ) # LCD Extended Commands.
|
||||
lcd_write(LCD_C, 0xCC ) # Set LCD Vop (Contrast).
|
||||
lcd_write(LCD_C, 0x04 ) # Set Temp coefficent. //0x04
|
||||
lcd_write(LCD_C, 0x14 ) # LCD bias mode 1:48. //0x13
|
||||
lcd_write(LCD_C, 0x0C ) # LCD in normal mode.
|
||||
lcd_write(LCD_C, 0x20 )
|
||||
lcd_write(LCD_C, 0x0C )
|
||||
|
||||
def lcd_clear():
|
||||
for time in range(0, LCD_SEGS):
|
||||
lcd_write(LCD_D, 0x00)
|
||||
|
||||
def lcd_fill():
|
||||
for time in range(0, LCD_SEGS):
|
||||
lcd_write(LCD_D, 0xFF)
|
||||
|
||||
|
||||
lcd_initialise()
|
||||
|
||||
for time in range(0,4):
|
||||
lcd_clear()
|
||||
wiringpi.delay(1000)
|
||||
lcd_fill()
|
||||
wiringpi.delay(1000)
|
||||
@@ -0,0 +1,28 @@
|
||||
import sys
|
||||
import time
|
||||
import wiringpi
|
||||
from wiringpi import GPIO
|
||||
|
||||
I2C_ADDR = 0x38
|
||||
BASE = 100
|
||||
|
||||
wiringpi.wiringPiSetup()
|
||||
wiringpi.pcf8574Setup(BASE, I2C_ADDR)
|
||||
|
||||
i = 0
|
||||
while i < 8:
|
||||
wiringpi.pinMode(BASE + i, GPIO.OUTPUT)
|
||||
i += 1
|
||||
|
||||
wiringpi.pinMode(BASE + 0, GPIO.OUTPUT)
|
||||
|
||||
while True:
|
||||
try:
|
||||
wiringpi.digitalWrite(BASE + 0, GPIO.HIGH)
|
||||
time.sleep(1)
|
||||
wiringpi.digitalWrite(BASE + 0, GPIO.LOW)
|
||||
time.sleep(1)
|
||||
except KeyboardInterrupt:
|
||||
print('\nExit')
|
||||
sys.exit(0)
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import sys
|
||||
import time
|
||||
import wiringpi
|
||||
from wiringpi import GPIO
|
||||
|
||||
I2C_ADDR = 0x48
|
||||
BASE = 64
|
||||
A0 = BASE+0
|
||||
|
||||
wiringpi.wiringPiSetup()
|
||||
wiringpi.pcf8591Setup(BASE, I2C_ADDR)
|
||||
while True:
|
||||
try:
|
||||
value = wiringpi.analogRead(A0)
|
||||
print("value: %d"%value)
|
||||
time.sleep(2)
|
||||
except KeyboardInterrupt:
|
||||
print('\nExit')
|
||||
sys.exit(0)
|
||||
@@ -0,0 +1,67 @@
|
||||
import wiringpi
|
||||
from wiringpi import GPIO
|
||||
|
||||
pin = 6
|
||||
|
||||
def getval(pin):
|
||||
tl=[]
|
||||
tb=[]
|
||||
wiringpi.wiringPiSetup()
|
||||
wiringpi.pinMode(pin, GPIO.OUTPUT)
|
||||
wiringpi.digitalWrite(pin, GPIO.HIGH)
|
||||
wiringpi.delay(1)
|
||||
wiringpi.digitalWrite(pin, GPIO.LOW)
|
||||
wiringpi.delay(25)
|
||||
wiringpi.digitalWrite(pin, GPIO.HIGH)
|
||||
wiringpi.delayMicroseconds(20)
|
||||
wiringpi.pinMode(pin, GPIO.INPUT)
|
||||
while(wiringpi.digitalRead(pin)==1): pass
|
||||
|
||||
for i in range(45):
|
||||
tc=wiringpi.micros()
|
||||
'''
|
||||
'''
|
||||
while(wiringpi.digitalRead(pin)==0): pass
|
||||
while(wiringpi.digitalRead(pin)==1):
|
||||
if wiringpi.micros()-tc>500:
|
||||
break
|
||||
if wiringpi.micros()-tc>500:
|
||||
break
|
||||
tl.append(wiringpi.micros()-tc)
|
||||
|
||||
tl=tl[1:]
|
||||
for i in tl:
|
||||
if i>100:
|
||||
tb.append(1)
|
||||
else:
|
||||
tb.append(0)
|
||||
|
||||
return tb
|
||||
|
||||
def GetResult(pin):
|
||||
for i in range(10):
|
||||
SH=0;SL=0;TH=0;TL=0;C=0
|
||||
result=getval(pin)
|
||||
|
||||
if len(result)==40:
|
||||
for i in range(8):
|
||||
SH*=2;SH+=result[i] # humi Integer
|
||||
SL*=2;SL+=result[i+8] # humi decimal
|
||||
TH*=2;TH+=result[i+16] # temp Integer
|
||||
TL*=2;TL+=result[i+24] # temp decimal
|
||||
C*=2;C+=result[i+32] # Checksum
|
||||
if ((SH+SL+TH+TL)%256)==C and C!=0:
|
||||
break
|
||||
else:
|
||||
print("Read Sucess,But checksum error! retrying")
|
||||
|
||||
else:
|
||||
print("Read failer! Retrying")
|
||||
break
|
||||
wiringpi.delay(200)
|
||||
return SH,SL,TH,TL
|
||||
|
||||
SH,SL,TH,TL=GetResult(pin)
|
||||
print("humi:",SH,SL,"temp:",TH,TL)
|
||||
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
#import sys
|
||||
import wiringpi
|
||||
from wiringpi import GPIO
|
||||
|
||||
PIN = 6
|
||||
|
||||
def oneWireReset(pin):
|
||||
wiringpi.pinMode(pin, GPIO.OUTPUT)
|
||||
wiringpi.digitalWrite(pin, GPIO.HIGH)
|
||||
wiringpi.digitalWrite(pin, GPIO.LOW)
|
||||
wiringpi.delayMicroseconds(500)
|
||||
wiringpi.digitalWrite(pin, GPIO.HIGH)
|
||||
wiringpi.delayMicroseconds(60)
|
||||
wiringpi.pinMode(pin, GPIO.INPUT)
|
||||
if not wiringpi.digitalRead(pin):
|
||||
ack = 1
|
||||
else:
|
||||
ack = 0
|
||||
wiringpi.delayMicroseconds(500)
|
||||
return ack
|
||||
|
||||
def writeBit(pin, bit):
|
||||
wiringpi.pinMode(pin, GPIO.OUTPUT)
|
||||
wiringpi.digitalWrite(pin, GPIO.LOW)
|
||||
wiringpi.delayMicroseconds(2)
|
||||
wiringpi.digitalWrite(pin, bit)
|
||||
wiringpi.delayMicroseconds(80)
|
||||
wiringpi.digitalWrite(pin, GPIO.HIGH)
|
||||
wiringpi.delayMicroseconds(1)
|
||||
|
||||
def oneWireSendComm(pin, byte):
|
||||
i = 0
|
||||
while i < 8:
|
||||
sta = byte & 0x01
|
||||
writeBit(pin, sta)
|
||||
byte >>= 1
|
||||
i += 1
|
||||
|
||||
def readBit(pin):
|
||||
wiringpi.pinMode(pin, GPIO.OUTPUT)
|
||||
wiringpi.digitalWrite(pin, GPIO.HIGH)
|
||||
wiringpi.digitalWrite(pin, GPIO.LOW)
|
||||
wiringpi.delayMicroseconds(2)
|
||||
wiringpi.digitalWrite(pin, GPIO.HIGH)
|
||||
|
||||
wiringpi.pinMode(pin, GPIO.INPUT)
|
||||
wiringpi.delayMicroseconds(2)
|
||||
|
||||
tmp = wiringpi.digitalRead(pin)
|
||||
wiringpi.delayMicroseconds(40)
|
||||
return tmp
|
||||
|
||||
def oneWireReceive(pin):
|
||||
i = 0
|
||||
k = 0
|
||||
while i < 8:
|
||||
j = readBit(pin)
|
||||
k = (j << 7) | (k >> 1)
|
||||
i += 1
|
||||
k = k & 0x00FF
|
||||
return k
|
||||
|
||||
def tempchange(lsb, msb):
|
||||
if (msb >= 0xF0):
|
||||
msb = 255 - msb
|
||||
lsb = 256 - lsb
|
||||
tem = -(msb*16*16 + lsb)
|
||||
else:
|
||||
tem = (msb*16*16 + lsb)
|
||||
temp = tem*0.0625
|
||||
print("Current Temp: %.2f"%(temp))
|
||||
|
||||
def main():
|
||||
wiringpi.wiringPiSetup()
|
||||
if oneWireReset(PIN):
|
||||
oneWireSendComm(PIN, 0xcc)
|
||||
oneWireSendComm(PIN, 0x44)
|
||||
if oneWireReset(PIN):
|
||||
oneWireSendComm(PIN, 0xcc)
|
||||
oneWireSendComm(PIN, 0xbe)
|
||||
lsb = oneWireReceive(PIN)
|
||||
msb = oneWireReceive(PIN)
|
||||
tempchange(lsb, msb)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import sys
|
||||
import time
|
||||
import wiringpi
|
||||
from wiringpi import GPIO
|
||||
|
||||
I2C_ADDR = 0x48
|
||||
BASE = 64
|
||||
A0 = BASE+0
|
||||
A1 = BASE+1
|
||||
|
||||
wiringpi.wiringPiSetup()
|
||||
wiringpi.pcf8591Setup(BASE, I2C_ADDR)
|
||||
|
||||
while True:
|
||||
try:
|
||||
i = 0
|
||||
while i < 2:
|
||||
if 0 == i:
|
||||
x = wiringpi.analogRead(A0)
|
||||
if 1 == i:
|
||||
y = wiringpi.analogRead(A1)
|
||||
i += 1
|
||||
print("X=%d Y=%d"%(x,y))
|
||||
time.sleep(1)
|
||||
except KeyboardInterrupt:
|
||||
print('\nExit')
|
||||
sys.exit(0)
|
||||
@@ -0,0 +1,22 @@
|
||||
import sys
|
||||
import time
|
||||
import wiringpi
|
||||
from wiringpi import GPIO
|
||||
|
||||
PIN = 6
|
||||
|
||||
wiringpi.wiringPiSetup()
|
||||
wiringpi.pinMode(PIN, GPIO.OUTPUT)
|
||||
|
||||
while True:
|
||||
try:
|
||||
wiringpi.digitalWrite(PIN, GPIO.HIGH)
|
||||
print(wiringpi.digitalRead(PIN))
|
||||
time.sleep(1)
|
||||
wiringpi.digitalWrite(PIN, GPIO.LOW)
|
||||
print(wiringpi.digitalRead(PIN))
|
||||
time.sleep(1)
|
||||
except KeyboardInterrupt:
|
||||
print("\nexit")
|
||||
sys.exit(0)
|
||||
|
||||
@@ -0,0 +1,320 @@
|
||||
import sys
|
||||
import time
|
||||
import wiringpi
|
||||
from wiringpi import GPIO
|
||||
|
||||
I2C_ADDR = 0x3c
|
||||
fd = 0
|
||||
yi = [' ',' ',' ',' ']
|
||||
zi = [
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//0
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//1
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//2
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//3
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//4
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//5
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//6
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//7
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//8
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//9
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//10
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//11
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//12
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//13
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//14
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//15
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//16
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//17
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//18
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//19
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//20
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//21
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//22
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//23
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//24
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//25
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//26
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//27
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//28
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//29
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//30
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//31
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//32
|
||||
|
||||
0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x00,0x00,0x00,0x00,#//33
|
||||
|
||||
0x00,0x10,0x0C,0x02,0x10,0x0C,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//34
|
||||
|
||||
0x00,0x40,0xC0,0x78,0x40,0xC0,0x78,0x00,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x00,#//35
|
||||
|
||||
0x00,0x70,0x88,0x88,0xFC,0x08,0x30,0x00,0x00,0x18,0x20,0x20,0xFF,0x21,0x1E,0x00,#//36
|
||||
|
||||
0xF0,0x08,0xF0,0x80,0x60,0x18,0x00,0x00,0x00,0x31,0x0C,0x03,0x1E,0x21,0x1E,0x00,#//37
|
||||
|
||||
0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x2C,0x19,0x27,0x21,0x10,#//38
|
||||
|
||||
0x00,0x12,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//39
|
||||
|
||||
0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,#//40
|
||||
|
||||
0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,#//41
|
||||
|
||||
0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,#//42
|
||||
|
||||
0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x0F,0x01,0x01,0x01,#//43
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x70,0x00,0x00,0x00,0x00,0x00,#//44
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x00,#//45
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,#//46
|
||||
|
||||
0x00,0x00,0x00,0x00,0xC0,0x38,0x04,0x00,0x00,0x60,0x18,0x07,0x00,0x00,0x00,0x00,#//47
|
||||
|
||||
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,#//48
|
||||
|
||||
0x00,0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,#//49
|
||||
|
||||
0x00,0x70,0x08,0x08,0x08,0x08,0xF0,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,#//50
|
||||
|
||||
0x00,0x30,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x18,0x20,0x21,0x21,0x22,0x1C,0x00,#//51
|
||||
|
||||
0x00,0x00,0x80,0x40,0x30,0xF8,0x00,0x00,0x00,0x06,0x05,0x24,0x24,0x3F,0x24,0x24,#//52
|
||||
|
||||
0x00,0xF8,0x88,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x20,0x20,0x20,0x11,0x0E,0x00,#//53
|
||||
|
||||
0x00,0xE0,0x10,0x88,0x88,0x90,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x20,0x1F,0x00,#//54
|
||||
|
||||
0x00,0x18,0x08,0x08,0x88,0x68,0x18,0x00,0x00,0x00,0x00,0x3E,0x01,0x00,0x00,0x00,#//55
|
||||
|
||||
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,#//56
|
||||
|
||||
0x00,0xF0,0x08,0x08,0x08,0x10,0xE0,0x00,0x00,0x01,0x12,0x22,0x22,0x11,0x0F,0x00,#//57
|
||||
|
||||
0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,#//58
|
||||
|
||||
0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0x00,0x00,#//59
|
||||
|
||||
0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,#//60
|
||||
|
||||
0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x02,0x02,0x02,0x02,0x02,0x02,0x00,#//61
|
||||
|
||||
0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,#//62
|
||||
|
||||
0x00,0x70,0x48,0x08,0x08,0x88,0x70,0x00,0x00,0x00,0x00,0x30,0x37,0x00,0x00,0x00,#//63
|
||||
|
||||
0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x28,0x2F,0x28,0x17,0x00,#//64
|
||||
|
||||
0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,#//65
|
||||
|
||||
0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,#//66
|
||||
|
||||
0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,#//67
|
||||
|
||||
0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,#//68
|
||||
|
||||
0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,#//69
|
||||
|
||||
0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,#//70
|
||||
|
||||
0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,#//71
|
||||
|
||||
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,#//72
|
||||
|
||||
0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,#//73
|
||||
|
||||
0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,#//74
|
||||
|
||||
0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,#//75
|
||||
|
||||
0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,#//76
|
||||
|
||||
0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x01,0x3E,0x01,0x3F,0x20,0x00,#//77
|
||||
|
||||
0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,#//78
|
||||
|
||||
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,#//79
|
||||
|
||||
0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,#//80
|
||||
|
||||
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x28,0x28,0x30,0x50,0x4F,0x00,#//81
|
||||
|
||||
0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,#//82
|
||||
|
||||
0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,#//83
|
||||
|
||||
0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,#//84
|
||||
|
||||
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,#//85
|
||||
|
||||
0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,#//86
|
||||
|
||||
0x08,0xF8,0x00,0xF8,0x00,0xF8,0x08,0x00,0x00,0x03,0x3E,0x01,0x3E,0x03,0x00,0x00,#//87
|
||||
|
||||
0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,#//88
|
||||
|
||||
0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,#//89
|
||||
|
||||
0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,#//90
|
||||
|
||||
0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,#//91
|
||||
|
||||
0x00,0x04,0x38,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,#//92
|
||||
|
||||
0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,#//93
|
||||
|
||||
0x00,0x00,0x04,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//94
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,#//95
|
||||
|
||||
0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//96
|
||||
|
||||
0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x19,0x24,0x24,0x12,0x3F,0x20,0x00,#//97
|
||||
|
||||
0x10,0xF0,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,#//98
|
||||
|
||||
0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,#//99
|
||||
|
||||
0x00,0x00,0x80,0x80,0x80,0x90,0xF0,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,#//100
|
||||
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x24,0x24,0x24,0x24,0x17,0x00,#//101
|
||||
|
||||
0x00,0x80,0x80,0xE0,0x90,0x90,0x20,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,#//102
|
||||
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,#//103
|
||||
|
||||
0x10,0xF0,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,#//104
|
||||
|
||||
0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,#//105
|
||||
|
||||
0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,#//106
|
||||
|
||||
0x10,0xF0,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x06,0x29,0x30,0x20,0x00,#//107
|
||||
|
||||
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,#//108
|
||||
|
||||
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,#//109
|
||||
|
||||
0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,#//110
|
||||
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,#//111
|
||||
|
||||
0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0x91,0x20,0x20,0x11,0x0E,0x00,#//112
|
||||
|
||||
0x00,0x00,0x00,0x80,0x80,0x00,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0x91,0xFF,0x80,#//113
|
||||
|
||||
0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,#//114
|
||||
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,#//115
|
||||
|
||||
0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x10,0x00,#//116
|
||||
|
||||
0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,#//117
|
||||
|
||||
0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x03,0x0C,0x30,0x0C,0x03,0x00,0x00,#//118
|
||||
|
||||
0x80,0x80,0x00,0x80,0x80,0x00,0x80,0x80,0x01,0x0E,0x30,0x0C,0x07,0x38,0x06,0x01,#//119
|
||||
|
||||
0x00,0x80,0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x20,0x31,0x0E,0x2E,0x31,0x20,0x00,#//120
|
||||
|
||||
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x81,0x86,0x78,0x18,0x06,0x01,0x00,#//121
|
||||
|
||||
0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,#//122
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0xFC,0x02,0x02,0x00,0x00,0x00,0x00,0x01,0x3E,0x40,0x40,#//122
|
||||
|
||||
0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,#//124
|
||||
|
||||
0x02,0x02,0xFC,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x3E,0x01,0x00,0x00,0x00,0x00,#//125
|
||||
|
||||
0x00,0x02,0x01,0x02,0x02,0x04,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//126
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,#//127
|
||||
]
|
||||
|
||||
def full_string(s):
|
||||
while len(s) < 16:
|
||||
s += ' '
|
||||
return s
|
||||
|
||||
def main():
|
||||
#init
|
||||
wiringpi.wiringPiSetup()
|
||||
fd = wiringpi.wiringPiI2CSetup(I2C_ADDR)
|
||||
if not fd:
|
||||
return False;
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x00, 0xa1)
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x00, 0xc8)
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x00, 0x8d)
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x00, 0x14)
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x00, 0xa6)
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x00, 0x21)
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x00, 0x00)
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x00, 0x7f)
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x00, 0xaf)
|
||||
|
||||
#clear oled
|
||||
for a in range(8):
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x00, 0xb0 + a)
|
||||
for b in range(128):
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x40, 0x00)
|
||||
|
||||
while True:
|
||||
try:
|
||||
#get time
|
||||
yi[0] = full_string("++++OrangePi++++")
|
||||
#yi[1] = full_string(time.strftime("%m/%d %w"))
|
||||
yi[1] = full_string(time.strftime("%m/%d %a"))
|
||||
yi[2] = full_string(time.strftime("%H:%M"))
|
||||
yi[3] = full_string("SSD1306 I2C OLED")
|
||||
|
||||
#write
|
||||
for zt3 in range(4):
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x00, 0xb0+(zt3*2))
|
||||
for zt4 in range(16):
|
||||
for zt in range(8):
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x40, zi[ord(yi[zt3][zt4])*16+zt])
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x00, 0xb0+(zt3*2)+1)
|
||||
for zt4 in range(16):
|
||||
for zt in range(8):
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x40, zi[ord(yi[zt3][zt4])*16+zt+8])
|
||||
time.sleep(1)
|
||||
except KeyboardInterrupt:
|
||||
print("\nexit")
|
||||
sys.exit(0)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import sys
|
||||
import time
|
||||
import wiringpi
|
||||
from wiringpi import GPIO
|
||||
|
||||
SIA = 9
|
||||
SIB= 10
|
||||
SW = 6
|
||||
|
||||
wiringpi.wiringPiSetup()
|
||||
wiringpi.pinMode(SW, GPIO.INPUT)
|
||||
wiringpi.pinMode(SIA, GPIO.INPUT)
|
||||
wiringpi.pinMode(SIB, GPIO.INPUT)
|
||||
|
||||
flag = 0
|
||||
resetflag = 0
|
||||
globalCount = 0
|
||||
|
||||
while True:
|
||||
try:
|
||||
lastSib = wiringpi.digitalRead(SIB)
|
||||
while not wiringpi.digitalRead(SW):
|
||||
resetflag = 1
|
||||
while not wiringpi.digitalRead(SIA):
|
||||
currentSib = wiringpi.digitalRead(SIB)
|
||||
flag =1
|
||||
|
||||
if resetflag:
|
||||
globalCount = 0
|
||||
resetflag = 0
|
||||
print ('Count reset\ncurrent = 0')
|
||||
continue
|
||||
if flag:
|
||||
if lastSib == 0 and currentSib == 1:
|
||||
print ('Anticlockwise rotation')
|
||||
globalCount += 1
|
||||
if lastSib == 1 and currentSib == 0:
|
||||
print ('clockwise rotation')
|
||||
globalCount -=1
|
||||
|
||||
flag =0
|
||||
print ('current = %s' % globalCount)
|
||||
except KeyboardInterrupt:
|
||||
print('\nExit')
|
||||
sys.exit(0)
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
import sys
|
||||
import time
|
||||
import wiringpi
|
||||
#from wiringpi import GPIO
|
||||
|
||||
I2C_ADDR = 0x68
|
||||
|
||||
def b2s(bcd, mask):
|
||||
bcd &= mask
|
||||
b1 = bcd & 0x0F
|
||||
b2 = ((bcd >> 4) & 0x0F)*10
|
||||
return b1 + b2
|
||||
|
||||
def decCompensation(units):
|
||||
unitsU = units%10
|
||||
if units >= 50:
|
||||
units = 0x50 + unitsU
|
||||
elif units >= 40:
|
||||
units = 0x40 + unitsU
|
||||
elif units >= 30:
|
||||
units = 0x30 + unitsU
|
||||
elif units >= 20:
|
||||
units = 0x20 + unitsU
|
||||
elif units >= 10:
|
||||
units = 0x10 + unitsU
|
||||
return units
|
||||
|
||||
def getHours():
|
||||
HH = time.strftime("%H")
|
||||
return decCompensation(int(HH))
|
||||
|
||||
def getMins():
|
||||
MM = time.strftime("%M")
|
||||
return decCompensation(int(MM))
|
||||
|
||||
def getSecs():
|
||||
SS = time.strftime("%S")
|
||||
return decCompensation(int(SS))
|
||||
|
||||
def getWeeks():
|
||||
WW = time.strftime("%w")
|
||||
return decCompensation(int(WW))
|
||||
|
||||
def getDays():
|
||||
DD = time.strftime("%d")
|
||||
return decCompensation(int(DD))
|
||||
|
||||
def getMons():
|
||||
MON = time.strftime("%m")
|
||||
return decCompensation(int(MON))
|
||||
|
||||
def getYear():
|
||||
YY = time.strftime("%Y")
|
||||
return decCompensation(int(YY))
|
||||
|
||||
def clear_register(fd):
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x02, 0b0) # hours
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x01, 0b0) # mins
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x00, 0b10000000) # secs
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x03, 0b0) # weeks
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x04, 0b0) # days
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x05, 0b0) # mons
|
||||
|
||||
def sys2rtcSet(fd):
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x02, getHours())
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x01, getMins())
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x00, getSecs()+0b10000000)
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x03, getWeeks())
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x04, getDays())
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x05, getMons())
|
||||
wiringpi.wiringPiI2CWriteReg8(fd, 0x06, getYear())
|
||||
|
||||
def read_register(fd):
|
||||
secs = b2s(wiringpi.wiringPiI2CReadReg8(fd, 0x00), 0x7F)
|
||||
mins = b2s(wiringpi.wiringPiI2CReadReg8(fd, 0x01), 0x7F)
|
||||
hours = b2s(wiringpi.wiringPiI2CReadReg8(fd, 0x02) - 0b10000000, 0x3F)
|
||||
week = b2s(wiringpi.wiringPiI2CReadReg8(fd, 0x03), 0x3F)
|
||||
day = b2s(wiringpi.wiringPiI2CReadReg8(fd, 0x04), 0x1F)
|
||||
mon = b2s(wiringpi.wiringPiI2CReadReg8(fd, 0x05), 0x07)
|
||||
year = b2s(wiringpi.wiringPiI2CReadReg8(fd, 0x06), 0xFF) + 1970
|
||||
print("week:%d mon:%d day:%d hours:%d mins:%d secs:%d year:%d"%(week,mon,day,hours,mins,secs,year))
|
||||
|
||||
def main():
|
||||
wiringpi.wiringPiSetup()
|
||||
fd = wiringpi.wiringPiI2CSetup(I2C_ADDR)
|
||||
if not fd:
|
||||
return False;
|
||||
while True:
|
||||
try:
|
||||
# clear RTC Register
|
||||
clear_register(fd)
|
||||
# set sys time to RTC Register
|
||||
sys2rtcSet(fd)
|
||||
# read RTC Register
|
||||
read_register(fd)
|
||||
time.sleep(1)
|
||||
except KeyboardInterrupt:
|
||||
print("\nexit")
|
||||
sys.exit(0)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import sys
|
||||
import wiringpi
|
||||
from wiringpi import GPIO
|
||||
|
||||
LED = 6
|
||||
PIN = 16
|
||||
|
||||
wiringpi.wiringPiSetup()
|
||||
wiringpi.pinMode(LED, GPIO.OUTPUT)
|
||||
wiringpi.pinMode(PIN, GPIO.INPUT)
|
||||
|
||||
while True:
|
||||
try:
|
||||
if wiringpi.digitalRead(PIN):
|
||||
wiringpi.digitalWrite(LED, GPIO.LOW)
|
||||
else:
|
||||
wiringpi.digitalWrite(LED, GPIO.HIGH)
|
||||
except KeyboardInterrupt:
|
||||
print("\nexit")
|
||||
sys.exit(0)
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
# Turns on each pin of an mcp23017 on address 0x20 ( quick2wire IO expander )
|
||||
import wiringpi
|
||||
|
||||
pin_base = 65
|
||||
i2c_addr = 0x20
|
||||
pins = [65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80]
|
||||
|
||||
wiringpi.wiringPiSetup()
|
||||
wiringpi.mcp23017Setup(pin_base,i2c_addr)
|
||||
|
||||
for pin in pins:
|
||||
wiringpi.pinMode(pin,1)
|
||||
wiringpi.digitalWrite(pin,1)
|
||||
# wiringpi.delay(1000)
|
||||
# wiringpi.digitalWrite(pin,0)
|
||||
@@ -0,0 +1,29 @@
|
||||
import wiringpi
|
||||
import sys
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(description='')
|
||||
parser.add_argument("--device", type=str, default="/dev/ttyS4", help='specify the serial node')
|
||||
args = parser.parse_args()
|
||||
|
||||
wiringpi.wiringPiSetup()
|
||||
serial = wiringpi.serialOpen(args.device, 115200)
|
||||
if serial < 0:
|
||||
print("Unable to open serial device: %s"% args.device)
|
||||
sys.exit(-1)
|
||||
|
||||
for count in range(0, 256):
|
||||
try:
|
||||
print("\nOut: %3d:" % count, end="")
|
||||
wiringpi.serialFlush(serial)
|
||||
wiringpi.serialPutchar(serial, count)
|
||||
wiringpi.delayMicroseconds(300000)
|
||||
|
||||
while wiringpi.serialDataAvail(serial):
|
||||
print(" -> %3d" % wiringpi.serialGetchar(serial), end="")
|
||||
wiringpi.serialFlush(serial)
|
||||
except KeyboardInterrupt:
|
||||
print("\nexit")
|
||||
sys.exit(0)
|
||||
|
||||
wiringpi.serialClose(serial) # Pass in ID
|
||||
@@ -0,0 +1,19 @@
|
||||
# Pulsates an LED connected to GPIO pin 1 with a suitable resistor 4 times using softPwm
|
||||
# softPwm uses a fixed frequency
|
||||
import wiringpi
|
||||
|
||||
OUTPUT = 1
|
||||
|
||||
PIN_TO_PWM = 1
|
||||
|
||||
wiringpi.wiringPiSetup()
|
||||
wiringpi.pinMode(PIN_TO_PWM,OUTPUT)
|
||||
wiringpi.softPwmCreate(PIN_TO_PWM,0,100) # Setup PWM using Pin, Initial Value and Range parameters
|
||||
|
||||
for time in range(0,4):
|
||||
for brightness in range(0,100): # Going from 0 to 100 will give us full off to full on
|
||||
wiringpi.softPwmWrite(PIN_TO_PWM,brightness) # Change PWM duty cycle
|
||||
wiringpi.delay(10) # Delay for 0.2 seconds
|
||||
for brightness in reversed(range(0,100)):
|
||||
wiringpi.softPwmWrite(PIN_TO_PWM,brightness)
|
||||
wiringpi.delay(10)
|
||||
@@ -0,0 +1,16 @@
|
||||
# Test of the softTone module in wiringPi
|
||||
# Plays a scale out on pin 3 - connect pizeo disc to pin 3 & 0v
|
||||
import wiringpi
|
||||
|
||||
PIN = 3
|
||||
|
||||
SCALE = [262, 294, 330, 349, 392, 440, 494, 525]
|
||||
|
||||
wiringpi.wiringPiSetup()
|
||||
wiringpi.softToneCreate(PIN)
|
||||
|
||||
while True:
|
||||
for idx in range(8):
|
||||
print(idx)
|
||||
wiringpi.softToneWrite(PIN, SCALE[idx])
|
||||
wiringpi.delay(500)
|
||||
@@ -0,0 +1,39 @@
|
||||
import wiringpi
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(description='')
|
||||
parser.add_argument("--channel", type=int, default=1, help='specify the spi channel')
|
||||
parser.add_argument("--port", type=int, default=0, help='specify the spi port')
|
||||
parser.add_argument("--speed", type=int, default=500000, help='specify the spi speed')
|
||||
parser.add_argument("--mode", type=int, default=0, help='specify the spi mode')
|
||||
args = parser.parse_args()
|
||||
|
||||
default_tx = [
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0x40, 0x00, 0x00, 0x00, 0x00, 0x95,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xF0, 0x0D,
|
||||
]
|
||||
|
||||
def hexdump(src, line_size, prefix):
|
||||
result = []
|
||||
digits = 4 if isinstance(src, str) else 2
|
||||
|
||||
for i in range(0, len(src), line_size):
|
||||
s = src[i:i + line_size]
|
||||
hexa = ' '.join([hex(x)[2:].upper().zfill(digits) for x in s])
|
||||
text = ''.join([chr(x) if 0x20 <= x < 0x7F else '.' for x in s])
|
||||
result.append(prefix + ' | ' + hexa.ljust(line_size * (digits + 1)) + ' |' + "{0}".format(text) + '|')
|
||||
|
||||
return '\n'.join(result)
|
||||
|
||||
print("spi mode: 0x%x" % args.mode);
|
||||
print("max speed: %d Hz (%d KHz)\n" %(args.speed, args.speed / 1000), end='');
|
||||
|
||||
wiringpi.wiringPiSPISetupMode(args.channel, args.port, args.speed, args.mode)
|
||||
revlen, recvData = wiringpi.wiringPiSPIDataRW(args.channel, bytes(default_tx))
|
||||
|
||||
print(hexdump(bytes(default_tx), 32, "TX"))
|
||||
print(hexdump(bytes(recvData), 32, "RX"))
|
||||
@@ -0,0 +1,18 @@
|
||||
# Turns on each pin of an mcp23017 on address 0x20 ( quick2wire IO expander )
|
||||
import wiringpi
|
||||
|
||||
pin_base = 65
|
||||
i2c_addr = 0x20
|
||||
i2c_addr_2 = 0x21
|
||||
#pins = [65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80]
|
||||
|
||||
wiringpi.wiringPiSetup()
|
||||
wiringpi.mcp23017Setup(pin_base,i2c_addr)
|
||||
wiringpi.mcp23017Setup(pin_base+16,i2c_addr_2)
|
||||
|
||||
#for pin in pins:
|
||||
for pin in range(65,96):
|
||||
wiringpi.pinMode(pin,1)
|
||||
wiringpi.digitalWrite(pin,1)
|
||||
# wiringpi.delay(1000)
|
||||
# wiringpi.digitalWrite(pin,0)
|
||||
Reference in new issue
Block a user