Skip to content

Commit 324e829

Browse files
committed
Fix printing strings with colons/decimals
Fixes #6
1 parent fef4ad0 commit 324e829

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

qwiic_alphanumeric.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -965,19 +965,21 @@ def print(self, print_string):
965965
self.clear()
966966

967967
self.digit_position = 0
968+
string_index = 0
968969

969-
for i in range(0, min(len(print_string), self.number_of_displays * 4)):
970+
while string_index < len(print_string) and self.digit_position < (4 * self.number_of_displays):
970971
# For special characters like '.' or ':', do not increment the digit position
971-
if print_string[i] == '.':
972+
if print_string[string_index] == '.':
972973
self.print_char('.', 0)
973-
elif print_string[i] == ':':
974+
elif print_string[string_index] == ':':
974975
self.print_char(':', 0)
975976
else:
976-
self.print_char(print_string[i], self.digit_position)
977+
self.print_char(print_string[string_index], self.digit_position)
977978
# Record to internal list
978-
self.display_content[i] = print_string[i]
979+
self.display_content[self.digit_position] = print_string[string_index]
979980

980-
self.digit_position = self.digit_position + 1
981+
self.digit_position += 1
982+
string_index += 1
981983

982984
self.update_display()
983985

0 commit comments

Comments
 (0)