From 7c56be8a724e2b0647e5a6cbd55c7b0eb948206b Mon Sep 17 00:00:00 2001 From: Sebastian Muszytowski Date: Fri, 3 Jun 2016 15:48:16 +0200 Subject: initial commit of all data --- utilities/mirror_font.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 utilities/mirror_font.py (limited to 'utilities/mirror_font.py') 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) -- cgit v1.2.3