Skip to content

Instantly share code, notes, and snippets.

@EllieTheYeen
Created June 1, 2024 01:35
Show Gist options
  • Save EllieTheYeen/59fcf7874f90dd70e355ea4b390b87ff to your computer and use it in GitHub Desktop.
Save EllieTheYeen/59fcf7874f90dd70e355ea4b390b87ff to your computer and use it in GitHub Desktop.
7 Segment silly test
glyphs = {
"0": 0b11111100,
"1": 0b01100000,
"2": 0b11011010,
"3": 0b11110010,
"4": 0b01100110,
"5": 0b10110110,
"6": 0b10111110,
"7": 0b11100000,
"8": 0b11111110,
"9": 0b11110110,
}
for cha, gl in glyphs.items():
print(cha, gl)
a = bool(gl & 128) # Top
b = bool(gl & 64) # Upper right
c = bool(gl & 32) # Lower right
d = bool(gl & 16) # Bottom
e = bool(gl & 8) # Lower left
f = bool(gl & 4) # Upper left
g = bool(gl & 2) # Middle
h = bool(gl & 1) # Dot
print (' ---' if a else '')
print(('|' if f else ' ') + ' ' + ('|' if b else ' '))
print (' ---' if g else '')
print(('|' if e else ' ') + ' ' + ('|' if c else ' '))
print (' --- ' if d else ' ' + ("O" if h else ''))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment