-
Notifications
You must be signed in to change notification settings - Fork 0
/
AdafruitTest-Animation.py
89 lines (73 loc) · 2.96 KB
/
AdafruitTest-Animation.py
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#AdafruitTest-Animation.py
#for Binho host adapter
# send 16 bytes of zeroes to clear the display
def wipeScreen():
binhoTester.startI2C(0, 0xE0)
for i in range(16):
binhoTester.writeByteI2C(0, 0x00)
binhoTester.endI2C(0)
return;
from binhoHostAdapter import binhoHostAdapter
from binhoHostAdapter import binhoUtilities
import time
binhoTesterCommPort = 'COM12' #may need to be changed
# create the binhoHostAdapter object
binhoTester = binhoHostAdapter.binhoHostAdapter(binhoTesterCommPort)
#initialize the Binho host adapter for I2C communication
binhoTester.setOperationMode(0, 'I2C')
binhoTester.setPullUpStateI2C(0, "DIS")
binhoTester.setClockI2C(0, 400000)
# initialize the character display
binhoTester.startI2C(0, 0xE0)
binhoTester.writeByteI2C(0, 0x21) # turn on oscillator
binhoTester.endI2C(0)
binhoTester.startI2C(0, 0xE0)
binhoTester.writeByteI2C(0, 0x81) # blink rate
binhoTester.endI2C(0)
binhoTester.startI2C(0, 0xE0)
binhoTester.writeByteI2C(0, 0xA0) # brightness
binhoTester.endI2C(0)
binhoTester.startI2C(0, 0xE0)
binhoTester.writeByteI2C(0, 0xEF)
binhoTester.endI2C(0)
#write/scroll letters
for j in range(0, 16, 2):
wipeScreen()
print(binhoTester.startI2C(0, 0xE0))
print(binhoTester.writeByteI2C(0, j)) # sets position of the character
print(binhoTester.writeByteI2C(0, 0x8F)) # LSByte of 'B' character mapping
print(binhoTester.writeByteI2C(0, 0x12)) # MSByte of 'B' character mapping
print(binhoTester.endI2C(0))
time.sleep(.2)
for j in range(0, 16, 2):
wipeScreen()
print(binhoTester.startI2C(0, 0xE0))
binhoTester.writeByteI2C(0, j) # sets position of the character
binhoTester.writeByteI2C(0, 0x00) # LSByte of 'I' character mapping
print(binhoTester.writeByteI2C(0, 0x12)) # MSByte of 'I' character mapping
print(binhoTester.endI2C(0))
time.sleep(.2)
for j in range(0, 16, 2):
wipeScreen()
print(binhoTester.startI2C(0, 0xE0))
print(binhoTester.writeByteI2C(0, j)) # sets position of the character
print(binhoTester.writeByteI2C(0, 0b00110110)) # LSByte of 'N' character mapping
print(binhoTester.writeByteI2C(0, 0b00100001)) # MSByte of 'N' character mapping
print(binhoTester.endI2C(0))
time.sleep(.2)
for j in range(0, 16, 2):
wipeScreen()
print(binhoTester.startI2C(0, 0xE0))
print(binhoTester.writeByteI2C(0, j)) # sets position of the character
print(binhoTester.writeByteI2C(0, 0b11110110)) # LSByte of 'H' character mapping
print(binhoTester.writeByteI2C(0, 0b00000000)) # MSByte of 'H' character mapping
print(binhoTester.endI2C(0))
time.sleep(.2)
for j in range(0, 16, 2):
wipeScreen()
print(binhoTester.startI2C(0, 0xE0))
print(binhoTester.writeByteI2C(0, j)) # sets position of the character
print(binhoTester.writeByteI2C(0, 63)) # LSByte of 'O' character mapping
print(binhoTester.writeByteI2C(0, 0)) # MSByte of 'O' character mapping
print(binhoTester.endI2C(0))
time.sleep(.2)