-
Notifications
You must be signed in to change notification settings - Fork 6
/
si4703Example.py
45 lines (38 loc) · 1.4 KB
/
si4703Example.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
#!/usr/bin/env python 2
#example program for testing the si4703 library
from si4703Library import si4703Radio
def main():
# device ID is typically 0x10 - confirm with "sudo i2cdetect 1"
radio = si4703Radio(0x10, 5, 19)
radio.si4703Init()
radio.si4703SetChannel(987)
radio.si4703SetVolume(5)
print str(radio.si4703GetChannel())
print str(radio.si4703GetVolume())
try:
while True:
#check for stuff
kbInput = raw_input(">>")
if kbInput == "1":
radio.si4703SeekDown()
print str(radio.si4703GetChannel())
if kbInput == "2":
radio.si4703SeekUp()
print str(radio.si4703GetChannel())
if kbInput == "3":
radio.si4703SetChannel(987)
print str(radio.si4703GetChannel())
if kbInput == "+":
radio.si4703SetVolume(radio.si4703GetVolume()+1)
print str(radio.si4703GetVolume())
if kbInput == "-":
radio.si4703SetVolume(radio.si4703GetVolume()-1)
print str(radio.si4703GetVolume())
if kbInput == "r":
pass
except KeyboardInterrupt:
print "Exiting program"
print "Shutting down radio"
radio.si4703ShutDown()
if __name__ == "__main__":
main()