From f2d761649784f80296b34699e420fb68b2a54337 Mon Sep 17 00:00:00 2001 From: Sebastian Muszytowski Date: Wed, 13 Jan 2016 21:53:27 +0100 Subject: moved utility scripts to utilities --- font_to_json.py | 27 --------------------------- mirror_font.py | 25 ------------------------- utilities/font_to_json.py | 27 +++++++++++++++++++++++++++ utilities/mirror_font.py | 25 +++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 52 deletions(-) delete mode 100644 font_to_json.py delete mode 100644 mirror_font.py create mode 100644 utilities/font_to_json.py create mode 100644 utilities/mirror_font.py diff --git a/font_to_json.py b/font_to_json.py deleted file mode 100644 index 6d1b667..0000000 --- a/font_to_json.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/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/mirror_font.py b/mirror_font.py deleted file mode 100644 index db5b5c3..0000000 --- a/mirror_font.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/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) 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) -- cgit v1.2.3