diff options
author | Sebastian Muszytowski <sebastian@muszytowski.net> | 2016-01-13 21:53:27 +0100 |
---|---|---|
committer | Sebastian Muszytowski <sebastian@muszytowski.net> | 2016-01-13 21:53:27 +0100 |
commit | f2d761649784f80296b34699e420fb68b2a54337 (patch) | |
tree | 10e45b1060aefa8fcca8487ca3a27cf1bf5025b2 /utilities | |
parent | dc7e4369e5e3feb3ced249ed6351787725d18a82 (diff) |
moved utility scripts to utilities
Diffstat (limited to 'utilities')
-rw-r--r-- | utilities/font_to_json.py | 27 | ||||
-rw-r--r-- | utilities/mirror_font.py | 25 |
2 files changed, 52 insertions, 0 deletions
diff --git a/utilities/font_to_json.py b/utilities/font_to_json.py new file mode 100644 index 0000000..6d1b667 --- /dev/null +++ b/utilities/font_to_json.py @@ -0,0 +1,27 @@ +#!/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) + contents = hexes[1:] + length = len(contents) + literal = int(re.findall(r'chr_([0-9]+)',line)[0]) + description = re.findall(r'\/\/(.*)$',line)[0].strip() + #for row in contents: + # print '{0:08b}'.format(int(row,16)) #.replace("1",u"\u2588").replace("0",u"\u25A2") + result[str(literal)] = { + 'literal' : literal, + 'description' : description, + 'hexcolumns' : contents, + 'length' : length + } + +print json.dumps(result) diff --git a/utilities/mirror_font.py b/utilities/mirror_font.py new file mode 100644 index 0000000..db5b5c3 --- /dev/null +++ b/utilities/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) |