Skip to content

Commit ea1bcb7

Browse files
author
=Dale Weber
committed
Added error checking for digit and bitmask values
1 parent 30d4991 commit ea1bcb7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

examples/ht16k33_animation_demo.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,13 @@ def animate(digits, bitmasks, delay=DEFAULT_CHAR_DELAY_SEC, auto_write=True):
6868
raise ValueError("The delay between frames must be positive!")
6969
else:
7070
for dig in digits:
71+
if not 0 <= dig <= 3:
72+
raise ValueError('Digit value ({0}) must be an integer in the range: 0-3'.format(dig))
73+
7174
for bits in bitmasks:
75+
if not 0 <= bits <= 0xFFFF:
76+
raise ValueError('Bitmask ({0}) value must be an integer in the range: 0-65535'.format(bits))
77+
7278
display.set_digit_raw(dig, bits)
7379

7480
if auto_write:

0 commit comments

Comments
 (0)