Skip to content

Commit c659c59

Browse files
committed
Tested source file and examples on pi
1 parent ce60b70 commit c659c59

11 files changed

+260
-89
lines changed

examples/qwiic_alphanumeric_ex01_begin.py

100644100755
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ def run_example():
4949
print("\nSparkFun Qwiic Alphanumeric - Example 1: Begin")
5050
my_display = qwiic_alphanumeric.QwiicAlphanumeric()
5151

52-
if my_display.begin() != True:
52+
if my_display.begin() == False:
5353
print("\nThe Qwiic Alhanumeric isn't connected to the system. Please check your connection", \
5454
file=sys.stderr)
5555
return
5656

5757
print("\nQwiic Alphanumeric passed begin!")
58-
58+
5959
if __name__ == '__main__':
6060
try:
6161
run_example()
6262
except (KeyboardInterrupt, SystemExit) as exErr:
6363
print("\nEnding Example 1")
64-
sys.exit(0)
64+
sys.exit(0)

examples/qwiic_alphanumeric_ex02_turn_on_one_segment.py

100644100755
Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,72 @@ def run_example():
5050
print("\nSparkFun Qwiic Alphanumeric - Example 2: Turn On One Segment")
5151
my_display = qwiic_alphanumeric.QwiicAlphanumeric()
5252

53-
if my_display.begin() != True:
53+
if my_display.begin() == False:
5454
print("\nThe Qwiic Alphanumeric isn't connected to the system. Please check your connection", \
5555
file=sys.stderr)
5656
return
5757

5858
print("\nQwiic Alphanumeric ready!")
59-
59+
60+
# while True:
61+
# for display_num in range(0, 4):
62+
# my_display.illuminate_segment('A', display_num)
63+
# my_display.update_display()
64+
# time.sleep(1)
65+
# my_display.clear()
66+
# my_display.illuminate_segment('B', display_num)
67+
# my_display.update_display()
68+
# time.sleep(1)
69+
# my_display.clear()
70+
# my_display.illuminate_segment('C', display_num)
71+
# my_display.update_display()
72+
# time.sleep(1)
73+
# my_display.clear()
74+
# my_display.illuminate_segment('D', display_num)
75+
# my_display.update_display()
76+
# time.sleep(1)
77+
# my_display.clear()
78+
# my_display.illuminate_segment('E', display_num)
79+
# my_display.update_display()
80+
# time.sleep(1)
81+
# my_display.clear()
82+
# my_display.illuminate_segment('F', display_num)
83+
# my_display.update_display()
84+
# time.sleep(1)
85+
# my_display.clear()
86+
# my_display.illuminate_segment('G', display_num)
87+
# my_display.update_display()
88+
# time.sleep(1)
89+
# my_display.clear()
90+
# my_display.illuminate_segment('H', display_num)
91+
# my_display.update_display()
92+
# time.sleep(1)
93+
# my_display.clear()
94+
# my_display.illuminate_segment('I', display_num)
95+
# my_display.update_display()
96+
# time.sleep(1)
97+
# my_display.clear()
98+
# my_display.illuminate_segment('J', display_num)
99+
# my_display.update_display()
100+
# time.sleep(1)
101+
# my_display.clear()
102+
# my_display.illuminate_segment('K', display_num)
103+
# my_display.update_display()
104+
# time.sleep(1)
105+
# my_display.clear()
106+
# my_display.illuminate_segment('L', display_num)
107+
# my_display.update_display()
108+
# time.sleep(1)
109+
# my_display.clear()
110+
# my_display.illuminate_segment('M', display_num)
111+
# my_display.update_display()
112+
# time.sleep(1)
113+
# my_display.clear()
114+
# my_display.illuminate_segment('N', display_num)
115+
# my_display.update_display()
116+
# time.sleep(1)
117+
# my_display.clear()
118+
60119
my_display.illuminate_segment('A', 0)
61120
my_display.illuminate_segment('L', 1)
62121
my_display.illuminate_segment('I', 2)
@@ -69,4 +128,4 @@ def run_example():
69128
run_example()
70129
except (KeyboardInterrupt, SystemExit) as exErr:
71130
print("\nEnding Example 2")
72-
sys.exit(0)
131+
sys.exit(0)

examples/qwiic_alphanumeric_ex03_print_char.py

100644100755
Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,33 @@ def run_example():
4949
print("\nSparkFun Qwiic Alphanumeric - Example 3: Print Char")
5050
my_display = qwiic_alphanumeric.QwiicAlphanumeric()
5151

52-
if my_display.begin() != True:
52+
if my_display.begin() == False:
5353
print("\nThe Qwiic Alphanumeric isn't connected to the system. Please check your connection.", \
5454
file=sys.stderr)
5555
return
5656

5757
print("\nQwiic Alphanumeric ready!")
58-
58+
5959
my_display.print_char('W', 0)
6060
my_display.print_char('H', 1)
6161
my_display.print_char('A', 2)
6262
my_display.print_char('T', 3)
6363

6464
my_display.update_display()
65+
66+
# # Un comment these lines if you want to see all available characters
67+
# # Print to every digit of a given display
68+
# for digit_num in range(0, 4):
69+
# for i in range(ord(' '), ord('~')):
70+
# if i is not ord(':') or ord('.'):
71+
# my_display.print_char(chr(i), digit_num)
72+
# my_display.update_display()
73+
# time.sleep(1)
74+
# my_display.clear()
6575

6676
if __name__ == '__main__':
6777
try:
6878
run_example()
6979
except (KeyboardInterrupt, SystemExit) as exErr:
7080
print("\nEnding Example 3")
71-
sys.exit(0)
81+
sys.exit(0)

examples/qwiic_alphanumeric_ex04_print_string.py

100644100755
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
def run_example():
4949

5050
print("\nSparkFun Qwiic Alphanumeric - Example 4: Print String")
51-
my_display = qwiic_alphaumeric.QwiicAlphanumeric()
51+
my_display = qwiic_alphanumeric.QwiicAlphanumeric()
5252

53-
if my_display.begin() != True:
53+
if my_display.begin() == False:
5454
print("\nThe Qwiic Alphanumeric isn't connected to the system. Please check your connection.", \
5555
file=sys.stderr)
5656
return
@@ -64,4 +64,4 @@ def run_example():
6464
run_example()
6565
except (KeyboardInterrupt, SystemExit) as exErr:
6666
print("\nEnding Example 4")
67-
sys.exit(0)
67+
sys.exit(0)

examples/qwiic_alphanumeric_ex05_set_brightness.py

100644100755
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,25 @@ def run_example():
4949
print("\nSparkFun Qwiic Alphanumeric - Example 5: Set Brightness")
5050
my_display = qwiic_alphanumeric.QwiicAlphanumeric()
5151

52-
if my_display.begin() != True:
52+
if my_display.begin() == False:
5353
print("\nThe Qwiic Alphanumeric isn't connected to the system. Please check your wiring.", \
5454
file=sys.stderr)
5555
return
5656

5757
print("\nQwiic Alphanumeric Ready!")
5858

59-
# The input to set_brightness() is a duty cycle over 16
60-
# So, the acceptable inputs to this function are ints between 0 (display off)
61-
# and 15 (full brightness)
62-
my_display.set_brightness(15)
63-
64-
my_display.print("Milk")
59+
while True:
60+
for i in range(0, 16):
61+
# The input to set_brightness() is a duty cycle over 16
62+
# So, the acceptable inputs to this function are ints between 0 (display off)
63+
# and 15 (full brightness)
64+
my_display.set_brightness(i)
65+
my_display.display_print("Milk")
66+
time.sleep(1)
6567

6668
if __name__ == '__main__':
6769
try:
6870
run_example()
6971
except (KeyboardInterrupt, SystemExit) as exErr:
7072
print("\nEnding Example 5")
71-
sys.exit(0)
73+
sys.exit(0)

examples/qwiic_alphanumeric_ex06_set_blink_rate.py

100644100755
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def run_example():
4949
print("\nSparkFun Qwiic Alphanumeric - Example 6: Set Blink Rate")
5050
my_display = qwiic_alphanumeric.QwiicAlphanumeric()
5151

52-
if my_display.begin() != True:
52+
if my_display.begin() == False:
5353
print("\nThe Qwiic Alphanumeric isn't connected to the system. Please check your connection.", \
5454
file=sys.stderr)
5555
return
@@ -58,7 +58,7 @@ def run_example():
5858

5959
# Blink rate in Hz
6060
# Acceptable options are defined by the HT16K33 datasheet and are 0.5, 1.0, or 2.0 Hz (float)
61-
my_display.set_blink_rate(2.0)
61+
my_display.set_blink_rate(0.5)
6262

6363
my_display.print("Milk")
6464

@@ -67,4 +67,4 @@ def run_example():
6767
run_example()
6868
except (KeyboardInterrupt, SystemExit) as exErr:
6969
print("\nEnding Example 6")
70-
sys.exit(0)
70+
sys.exit(0)

examples/qwiic_alphanumeric_ex07_colon_and_decimal.py

100644100755
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def run_example():
4949
print("\nSparkFun Qwiic Alphanumeric - Example 7: Colon and Decimal")
5050
my_display = qwiic_alphanumeric.QwiicAlphanumeric()
5151

52-
if my_display.begin() != True:
52+
if my_display.begin() == False:
5353
print("\nThe Qwiic Alphanumeric isn't connected to the system. Please check your connections.", \
5454
file=sys.stderr)
5555
return
@@ -59,18 +59,20 @@ def run_example():
5959
# You can print colons and decimals
6060
# NOTE: they can only go in the character position deterined by the layout of the display
6161
my_display.print("12:3.4")
62-
63-
# You can also turn decimals and colong on and off manually
62+
63+
# You can also turn decimals and colon on and off manually
6464
# my_display.decimal_on() # Turn all decimals on
6565
# my_display.decimal_off() # Turn all decimals off
66-
# my_display.decimal_on_single(0) # Turn decimal on for one display # TODO: this line should not work....
67-
# my_display.colon() # Turn all colons on
66+
# my_display.decimal_on_single(1) # Turn decimal on for display one
67+
# my_display.decimal_off_single(1) # Turn decimal off for display one
68+
# my_display.colon_on() # Turn all colons on
6869
# my_display.colon_off() # Turn all the colons off
69-
# my_display.colon_on_single(1) # Turn colon on for one display
70+
# my_display.colon_on_single(1) # Turn colon on for display one
71+
# my_display.colon_off_single(1) # Turn colon off for display one
7072

7173
if __name__ == '__main__':
7274
try:
7375
run_example()
7476
except (KeyboardInterrupt, SystemExit) as exErr:
7577
print("\nEnding Example 7")
76-
sys.exit(0)
78+
sys.exit(0)

examples/qwiic_alphanumeric_ex08_unknown_char.py

100644100755
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,20 @@ def run_example():
5050
print("\nSparkFun Qwiic Alphanumeric - Example 8: Unkown Char")
5151
my_display = qwiic_alphanumeric.QwiicAlphanumeric()
5252

53-
if my_display.begin() != True:
53+
if my_display.begin() == False:
5454
print("\nThe Qwiic Alphanumeric isn't connected to the system. Please check your connection.", \
5555
file=sys.stderr)
5656
return
5757

5858
print("\nQwiic Alphanumeric ready!")
59+
60+
# Because '\t' is a character unkown to the library, expect the display
61+
# to turn on all sefments for that unknown digit/character
62+
my_display.print("\t\t\t\t") # Tabs are not printable characters
5963

6064
if __name__ == '__main__':
6165
try:
6266
run_example()
6367
except (KeyboardInterrupt, SystemExit) as exErr:
6468
print("\nEnding Example 8")
65-
sys.exit(0)
69+
sys.exit(0)

examples/qwiic_alphanumeric_ex09_multi_display.py

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def run_example():
5050
print("\nSparkFun Qwiic Alphanumeric - Example 9: Multi Display")
5151
my_display = qwiic_alphanumeric.QwiicAlphanumeric()
5252

53-
if my_display.begin(0x70, 0x71) != True:
53+
if my_display.begin(0x73, 0x70) == False:
5454
print("\nThe Qwiic Alhanumerics aren't connected to the system. Please check your connection", \
5555
file=sys.stderr)
5656
return
@@ -64,4 +64,4 @@ def run_example():
6464
run_example()
6565
except (KeyboardInterrupt, SystemExit) as exErr:
6666
print("\nEnding Example 9")
67-
sys.exit(0)
67+
sys.exit(0)

examples/qwiic_alphanumeric_ex10_scrolling_string.py

100644100755
Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,42 @@ def run_example():
4949
print("\nSparkFun Qwiic Alphanumeric - Example 10: Scrolling String")
5050
my_display = qwiic_alphanumeric.QwiicAlphanumeric()
5151

52-
if my_display.begin(0x70, 0x71) != True:
52+
if my_display.begin(0x70, 0x72) == False:
5353
print("\nThe Qwiic Alhanumerics aren't connected to the system. Please check your connection", \
5454
file=sys.stderr)
5555
return
5656

5757
print("\nQwiic Alphanumerics passed begin!")
5858

59+
# my_display.print("GET MILK")
60+
# time.sleep(1)
61+
# my_display.print("ET MILK ")
62+
# time.sleep(1)
63+
# my_display.print("T MILK ")
64+
# time.sleep(1)
65+
# my_display.print(" MILK ")
66+
# time.sleep(1)
67+
# my_display.print("MILK ")
68+
# time.sleep(1)
69+
# my_display.print("ILK ")
70+
# time.sleep(1)
71+
# my_display.print("LK ")
72+
# time.sleep(1)
73+
# my_display.print("K ")
74+
# time.sleep(1)
75+
# my_display.print(" ")
76+
5977
my_display.print("GET MILK")
6078

6179
while 1:
62-
time.sleep(0.03)
63-
my_display.shift_left()
80+
time.sleep(1)
81+
#my_display.shift_left()
6482
# Alternatively - you could also shift the string to the right
65-
# my_display.shift_right()
83+
my_display.shift_right()
6684

6785
if __name__ == '__main__':
6886
try:
6987
run_example()
7088
except (KeyboardInterrupt, SystemExit) as exErr:
7189
print("\nEnding Example 10")
72-
sys.exit(0)
90+
sys.exit(0)

0 commit comments

Comments
 (0)