Skip to content

Instantly share code, notes, and snippets.

@sooop
Last active September 6, 2017 23:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sooop/3ebf4100a8c1b15783c968f130ceb570 to your computer and use it in GitHub Desktop.
Save sooop/3ebf4100a8c1b15783c968f130ceb570 to your computer and use it in GitHub Desktop.
display LCD Digits
def present(s, digits):
masks = ('02356789', '045689', '01234789', '2345689', '0268', '013456789', '0235689')
result = []
h = lambda x: ' '.join(' ' + ('-' if d in masks[x] else ' ') * s + ' '\
for d in digits)
v = lambda x: ' '.join(('|' if d in masks[x] else ' ') + ' ' * s +\
('|' if d in masks[x+1] else ' ') for d in digits)
result.append(h(0))
result += [v(1)] * s
result.append(h(3))
result += [v(4)] * s
result.append(h(6))
print('\n'.join(result))
present(3, "0123456789")
@sooop
Copy link
Author

sooop commented Sep 6, 2017

result:

 ---         ---   ---         ---   ---   ---   ---   --- 
|   |     |     |     | |   | |     |         | |   | |   |
|   |     |     |     | |   | |     |         | |   | |   |
|   |     |     |     | |   | |     |         | |   | |   |
             ---   ---   ---   ---   ---         ---   --- 
|   |     | |         |     |     | |   |     | |   |     |
|   |     | |         |     |     | |   |     | |   |     |
|   |     | |         |     |     | |   |     | |   |     |
 ---         ---   ---         ---   ---         ---   --- 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment