Last active
September 7, 2018 05:50
-
-
Save nmz787/6a9681d93fd67e4b58ffb5caab257b82 to your computer and use it in GitHub Desktop.
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
""" | |
parse and print the characters stored in the HEX ROM associated with the MAX1000 POV LED TEXT demo | |
(here: https://github.com/vpecanins/max1000-tutorial/tree/master/demo02_led_text) | |
.hex format is: | |
First character (:) = Start of a record | |
Next two characters = Record length (in this example, 10h) | |
Next four characters = Load address (in this example, 0080h) | |
Next two characters = Record type (see below) | |
Remaining characters = Actual data | |
Last two characters = Checksum (i.e., sum of all bytes + checksum = 00) | |
The last line of the file is special, and always looks like the last line shown above. HEX record types are shown below: | |
00 = Data record | |
01 = End of file record | |
02 = Extended segment address record | |
03 = Start segment address record | |
04 = Extended linear address record | |
05 = Start linear address record | |
""" | |
import sys | |
def open_file_and_get_bits(filepath): | |
f=open(filepath, 'r') | |
ff=f.read() | |
f.close() | |
char_list1=[a for a in ff.split('\n') if len(a)] | |
char_list=[] | |
for a in char_list1: | |
record_len = int(a[1:3],16) | |
if record_len: | |
x=a[9:-2] | |
v=bin(int(x, 16))[2:] | |
n=128-len(v) | |
v='0'*n+v | |
char_list.append(v) | |
return char_list | |
def print_chars(list_of_bits): | |
rows=[[' ' for i in range(5)] for j in range(8)] | |
def grab_char_and_rotate_then_print(_chars, i): | |
for column in range(5): | |
#for jj in range(5-1,-1,-1): | |
for row in range(8-1,-1,-1): | |
rows[row][column] = ' ' if _chars[i]=='0' else '*' | |
i+=1 | |
for r in rows: | |
print(''.join(r)) | |
for bits in list_of_bits: | |
grab_char_and_rotate_then_print(bits, 0) | |
print('\n') | |
grab_char_and_rotate_then_print(bits, 64) | |
print('\n') | |
char_list = open_file_and_get_bits('font5x7.hex') | |
print_chars(char_list) |
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
* | |
* | |
* | |
* | |
* | |
* | |
* * | |
* * | |
* * | |
* * | |
* * | |
***** | |
* * | |
***** | |
* * | |
* * | |
* | |
**** | |
* * | |
*** | |
* * | |
**** | |
* | |
** | |
** * | |
* | |
* | |
* | |
* ** | |
** | |
** | |
* * | |
* * | |
* | |
* * * | |
* * | |
** * | |
** | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* * | |
* | |
***** | |
* | |
* * | |
* | |
* | |
***** | |
* | |
* | |
** | |
* | |
* | |
***** | |
** | |
** | |
* | |
* | |
* | |
* | |
* | |
*** | |
* * | |
* ** | |
* * * | |
** * | |
* * | |
*** | |
* | |
** | |
* | |
* | |
* | |
* | |
*** | |
*** | |
* * | |
* | |
* | |
* | |
* | |
***** | |
***** | |
* | |
* | |
* | |
* | |
* * | |
*** | |
* | |
** | |
* * | |
* * | |
***** | |
* | |
* | |
***** | |
* | |
**** | |
* | |
* | |
* * | |
*** | |
** | |
* | |
* | |
**** | |
* * | |
* * | |
*** | |
***** | |
* | |
* | |
* | |
* | |
* | |
* | |
*** | |
* * | |
* * | |
*** | |
* * | |
* * | |
*** | |
*** | |
* * | |
* * | |
**** | |
* | |
* | |
** | |
** | |
** | |
** | |
** | |
** | |
** | |
** | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
***** | |
***** | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
*** | |
* * | |
* | |
* | |
* | |
* | |
*** | |
* * | |
* | |
** * | |
* * * | |
* * * | |
*** | |
*** | |
* * | |
* * | |
* * | |
***** | |
* * | |
* * | |
**** | |
* * | |
* * | |
**** | |
* * | |
* * | |
**** | |
*** | |
* * | |
* | |
* | |
* | |
* * | |
*** | |
*** | |
* * | |
* * | |
* * | |
* * | |
* * | |
*** | |
***** | |
* | |
* | |
**** | |
* | |
* | |
***** | |
***** | |
* | |
* | |
*** | |
* | |
* | |
* | |
*** | |
* * | |
* | |
* | |
* ** | |
* * | |
*** | |
* * | |
* * | |
* * | |
***** | |
* * | |
* * | |
* * | |
*** | |
* | |
* | |
* | |
* | |
* | |
*** | |
*** | |
* | |
* | |
* | |
* | |
* * | |
** | |
* * | |
* * | |
* * | |
** | |
* * | |
* * | |
* * | |
* | |
* | |
* | |
* | |
* | |
* | |
***** | |
* * | |
** ** | |
* * * | |
* * | |
* * | |
* * | |
* * | |
* * | |
* * | |
** * | |
* * * | |
* ** | |
* * | |
* * | |
*** | |
* * | |
* * | |
* * | |
* * | |
* * | |
*** | |
**** | |
* * | |
* * | |
**** | |
* | |
* | |
* | |
*** | |
* * | |
* * | |
* * | |
* * * | |
* * | |
** * | |
**** | |
* * | |
* * | |
**** | |
* * | |
* * | |
* * | |
**** | |
* | |
* | |
*** | |
* | |
* | |
**** | |
***** | |
* | |
* | |
* | |
* | |
* | |
* | |
* * | |
* * | |
* * | |
* * | |
* * | |
* * | |
*** | |
* * | |
* * | |
* * | |
* * | |
* * | |
* * | |
* | |
* * | |
* * | |
* * | |
* * * | |
* * * | |
** ** | |
* * | |
* * | |
* * | |
* * | |
* | |
* * | |
* * | |
* * | |
* * | |
* * | |
* * | |
* | |
* | |
* | |
* | |
***** | |
* | |
* | |
* | |
* | |
* | |
***** | |
*** | |
* | |
* | |
* | |
* | |
* | |
*** | |
* | |
* | |
* | |
* | |
* | |
*** | |
* | |
* | |
* | |
* | |
* | |
*** | |
* | |
* * | |
* * | |
***** | |
* | |
* | |
* | |
*** | |
* | |
**** | |
* * | |
**** | |
* | |
* | |
* ** | |
** * | |
* * | |
* * | |
**** | |
*** | |
* | |
* | |
* * | |
*** | |
* | |
* | |
** * | |
* ** | |
* * | |
* * | |
**** | |
*** | |
* * | |
***** | |
* | |
*** | |
** | |
* * | |
* | |
*** | |
* | |
* | |
* | |
**** | |
* * | |
**** | |
* | |
** | |
* | |
* | |
* ** | |
** * | |
* * | |
* * | |
* * | |
* | |
** | |
* | |
* | |
* | |
*** | |
* | |
** | |
* | |
* | |
* * | |
** | |
* | |
* | |
* * | |
* * | |
** | |
* * | |
* * | |
** | |
* | |
* | |
* | |
* | |
* | |
*** | |
** * | |
* * * | |
* * * | |
* * | |
* * | |
* ** | |
** * | |
* * | |
* * | |
* * | |
*** | |
* * | |
* * | |
* * | |
*** | |
**** | |
* * | |
**** | |
* | |
* | |
** * | |
* ** | |
**** | |
* | |
* | |
* ** | |
** * | |
* | |
* | |
* | |
*** | |
* | |
*** | |
* | |
**** | |
* | |
* | |
*** | |
* | |
* | |
* * | |
** | |
* * | |
* * | |
* * | |
* ** | |
** * | |
* * | |
* * | |
* * | |
* * | |
* | |
* * | |
* * | |
* * * | |
* * * | |
* * | |
* * | |
* * | |
* | |
* * | |
* * | |
* * | |
* * | |
**** | |
* | |
*** | |
***** | |
* | |
* | |
* | |
***** | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
* | |
***** | |
* | |
* | |
* | |
* | |
***** | |
* | |
* | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment