Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions tm1638.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,14 @@ def hex(self, val):
string = '{:08x}'.format(val & 0xffffffff)
self.segments(self.encode_string(string))

def number(self, num):
def number(self, num, leading_zero = False): # add leading zero to number
"""Display a numeric value -9999999 through 99999999, right aligned."""
# limit to range -9999999 to 99999999
num = max(-9999999, min(num, 99999999))
string = '{0: >8d}'.format(num)
if leading_zero: # if add leading zero
string = '%08d' % num # using format string to add leading zero
else:
string = '{0: >8d}'.format(num)
self.segments(self.encode_string(string))

#def float(self, num):
Expand Down