diff options
author | Sebastian Muszytowski <sebastian@muszytowski.net> | 2016-01-13 21:50:18 +0100 |
---|---|---|
committer | Sebastian Muszytowski <sebastian@muszytowski.net> | 2016-01-13 21:50:18 +0100 |
commit | b80e5470d216183611a28466c61ec995380ec73c (patch) | |
tree | 8efddea8ab462c9facb7ed66cf6ec3330eb11a1c /mirror_font.py | |
parent | b34fba1020fc242198cbbdcc4339caaf622302b5 (diff) |
mirror the font - actually I did rotate the pcb design for better routing
Diffstat (limited to 'mirror_font.py')
-rw-r--r-- | mirror_font.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/mirror_font.py b/mirror_font.py new file mode 100644 index 0000000..db5b5c3 --- /dev/null +++ b/mirror_font.py @@ -0,0 +1,25 @@ +#!/usr/bin/python + +import sys +import os +import re +import json + +result = {} + +with open('font.h') as font: + for line in font: + if 'PROGMEM' in line: + hexes = re.findall(r'(0x[0-9a-fA-F]+)',line) + prefix = hexes[:1] + contents = hexes[1:] + length = len(contents) + literal = int(re.findall(r'chr_([0-9]+)',line)[0]) + description = re.findall(r'\/\/(.*)$',line)[0].strip() + newhexes = [] + newhexes.append(prefix[0]) + for row in contents: + bitstring = '{0:08b}'.format(int(row,16)) + newbits = bitstring[::-1] + newhexes.append( format(int(newbits,2), '#04x')) + print "const unsigned char PROGMEM chr_%s[] = {%s}; // %s" % (literal,','.join(newhexes),description) |