7 Segment character value generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#The order segments are connected to the shift register (D = dot) | |
input = ['a','b','c','d','e','f','g','D'] | |
reverse = True #Depends on direction of outputs/shifting | |
negate = True #Common Cathode = False Common Anode = True | |
characters = [("abcdef", '0/O'), | |
("bc", '1/I'), | |
("abdeg", '2'), | |
("abcdg", '3'), | |
("bcfg", '4'), | |
("acdfg", '5/s'), | |
("acdefg", '6'), | |
("abc", '7'), | |
("abcdefg",'8/B'), | |
("abcfg", '9/g'), | |
("abcefg", 'A'), | |
("cdefg", 'b'), | |
("deg", 'c'), | |
("adef", 'C'), | |
("bcdeg", 'd'), | |
("adefg", 'E'), | |
("aefg", 'F'), | |
("acdef", 'G'), | |
("bcefg", 'H'), | |
("bcd", 'J'), | |
("def", 'L'), | |
("ceg", 'n'), | |
("cdeg", 'o'), | |
("abefg", 'P'), | |
("abcfg", 'q'), | |
("eg", 'r'), | |
("defg", 't'), | |
("cde", 'u'), | |
("bcdef", 'U'), | |
("bcdfg", 'y'), | |
("D", '.')] | |
for character in characters: | |
output = 0 | |
for segment in character[0]: | |
if reverse: | |
output |= (1<<input.index(segment)) | |
else: | |
output |= (128>>input.index(segment)) | |
output = ~output & 0xFF | |
print "Character: " + character[1] | |
print "Hex: " + "0x{0:02X}".format(output) | |
print "Binary: "+"{0:08b}".format(output) | |
print "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment