From 20e426e8469c331b53e7b0cdfdcac7d71f9c20d2 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Thu, 12 May 2016 14:07:15 +0200 Subject: [PATCH] rename gen_loader.py to loader_gen.py --- extmod/modtrezorui/gen_loader.py | 34 ------------------------------- extmod/modtrezorui/loader_gen.py | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 34 deletions(-) delete mode 100755 extmod/modtrezorui/gen_loader.py create mode 100755 extmod/modtrezorui/loader_gen.py diff --git a/extmod/modtrezorui/gen_loader.py b/extmod/modtrezorui/gen_loader.py deleted file mode 100755 index a9fd714edb..0000000000 --- a/extmod/modtrezorui/gen_loader.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/python3 -import math -import sys - -outer = 83 -inner = 55 - -print('static const int img_loader_size = %d;' % outer) -print('static const uint16_t img_loader[%d][%d] = {' % (outer, outer)) -for y in range(outer): - print(' {', end='') - for x in range(outer): - d = math.sqrt((outer - 1 - x) ** 2 + (outer - 1 - y) ** 2) - c = {} - for i in [5, 15]: - if (inner - 0.5 <= d) and (d <= inner + 0.5): - c[i] = 15 * (d - inner + 0.5); - elif (inner + 0.5 <= d) and (d <= inner + 1.5): - c[i] = 15 - elif (inner + 1.5 <= d) and (d <= inner + 2.5): - c[i] = 15 if i == 15 else 15 - (15 - i) * (d - inner - 1.5) - elif (outer - 1.5 <= d) and (d <= outer - 0.5): - c[i] = i - i * (d - outer + 1.5) - elif (inner + 2.5 < d) and (d < outer - 1.5): - c[i] = i - else: - c[i] = 0 - # clamp (should not be needed) - c[i] = max(0, min(int(c[i]), 15)) - a = int(math.atan2((outer - 1 - x), (outer - 1 - y)) * 2 * 249 / math.pi) - v = (a << 8) | (c[15] << 4) | c[5] - print('%d,' % v, end='') - print('},') -print('};') diff --git a/extmod/modtrezorui/loader_gen.py b/extmod/modtrezorui/loader_gen.py new file mode 100755 index 0000000000..8ba315898e --- /dev/null +++ b/extmod/modtrezorui/loader_gen.py @@ -0,0 +1,35 @@ +#!/usr/bin/python3 +import math +import sys + +outer = 83 +inner = 55 + +with open('loader.h', 'wt') as f: + f.write('static const int img_loader_size = %d;\n' % outer) + f.write('static const uint16_t img_loader[%d][%d] = {\n' % (outer, outer)) + for y in range(outer): + f.write(' {') + for x in range(outer): + d = math.sqrt((outer - 1 - x) ** 2 + (outer - 1 - y) ** 2) + c = {} + for i in [5, 15]: + if (inner - 0.5 <= d) and (d <= inner + 0.5): + c[i] = 15 * (d - inner + 0.5); + elif (inner + 0.5 <= d) and (d <= inner + 1.5): + c[i] = 15 + elif (inner + 1.5 <= d) and (d <= inner + 2.5): + c[i] = 15 if i == 15 else 15 - (15 - i) * (d - inner - 1.5) + elif (outer - 1.5 <= d) and (d <= outer - 0.5): + c[i] = i - i * (d - outer + 1.5) + elif (inner + 2.5 < d) and (d < outer - 1.5): + c[i] = i + else: + c[i] = 0 + # clamp (should not be needed) + c[i] = max(0, min(int(c[i]), 15)) + a = int(math.atan2((outer - 1 - x), (outer - 1 - y)) * 2 * 249 / math.pi) + v = (a << 8) | (c[15] << 4) | c[5] + f.write('%d,' % v) + f.write('},\n') + f.write('};\n')