summaryrefslogtreecommitdiff
path: root/src/app/ssd1306test/png-to-h
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2021-04-12 22:33:31 +0200
committerDaniel Friesel <derf@finalrewind.org>2021-04-12 22:33:31 +0200
commitb650f2ac498df4ba18d23ad7f02637f40917c28e (patch)
treef5c44e669295988a7c626a6be7df6003a5f0b918 /src/app/ssd1306test/png-to-h
parentde46e19c47842dc3e2050b0c7e948b9884e9a1f5 (diff)
add ssd1306 test app
Diffstat (limited to 'src/app/ssd1306test/png-to-h')
-rwxr-xr-xsrc/app/ssd1306test/png-to-h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/app/ssd1306test/png-to-h b/src/app/ssd1306test/png-to-h
new file mode 100755
index 0000000..5e95967
--- /dev/null
+++ b/src/app/ssd1306test/png-to-h
@@ -0,0 +1,23 @@
+#!/usr/bin/env python3
+
+from PIL import Image
+import sys
+
+
+def load_image(filename):
+ im = Image.open(filename)
+ w, h = im.size
+ buf = [0 for i in range(buf_w * buf_h // 8)]
+ for y in range(min(h, buf_h)):
+ for x in range(min(w, buf_w)):
+ if im.getpixel((x, y)):
+ buf[(y // 8) * buf_w + x] |= 1 << (y % 8)
+ return buf
+
+
+buf_w = int(sys.argv[1])
+buf_h = int(sys.argv[2])
+filename = sys.argv[3]
+
+buf = load_image(filename)
+print(", ".join(map(str, buf)))