Open GM-Script-Writer-62850 opened 2 weeks ago
whet ahead and made a new write method
def write_digits(self, s, x=7):
# s is the value to show
# x is the last digit to show, starts at 0
s=str(s)
i = len(s)
while i > 0 and x > -1:
i -= 1
if i > 0 and s[i] == '.':
i -= 1
while i > -1 and s[i] == '.' and x > -1:
self.set_register(REG_DIGIT_BASE + x, 0x80)
x -= 1
i -= 1
digit = self.decode_char(s[i]) | 0x80
else:
digit = self.decode_char(s[i])
self.set_register(REG_DIGIT_BASE + x, digit)
x -= 1
else:
if i > 0:
print(s,'has',i,'digits too many to display...')
All this works as expected
while 1:
display.write_digits("........")
sleep(d)
display.write_digits("..1..2..3..4.")
sleep(d)
display.write_digits("12.34",3)
display.write_digits("56.78")
sleep(d)
display.write_digits("0123456789")
sleep(d)
display.write_digits(".1.2.3.4.5.6.7.")
sleep(d)
display.write_digits(" ")
sleep(d)
EDIT: i made a fork of this and made a bunch of improvements if you want to make any changes based on it
Existing version prints in the reverse order based on the pin out for the MAX7219 datasheet Changes:
.
).1.2.3.4.5.6.7.
works as expected..
is a bad idea, could be fixed, but is there a use case?