summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app/pervasive-aurora-mb-bad-apple/Kconfig6
-rw-r--r--src/app/pervasive-aurora-mb-bad-apple/Makefile.inc10
-rwxr-xr-xsrc/app/pervasive-aurora-mb-bad-apple/convert16
-rwxr-xr-xsrc/app/pervasive-aurora-mb-bad-apple/frames-to-cc38
-rw-r--r--src/app/pervasive-aurora-mb-bad-apple/main.cc67
5 files changed, 137 insertions, 0 deletions
diff --git a/src/app/pervasive-aurora-mb-bad-apple/Kconfig b/src/app/pervasive-aurora-mb-bad-apple/Kconfig
new file mode 100644
index 0000000..a67bf96
--- /dev/null
+++ b/src/app/pervasive-aurora-mb-bad-apple/Kconfig
@@ -0,0 +1,6 @@
+# Copyright 2020 Daniel Friesel
+#
+# SPDX-License-Identifier: CC0-1.0
+
+prompt "Pervasive Aurora Mb Bad Apple"
+depends on framebuffer && driver_pervasive_aurora_mb && !wakeup
diff --git a/src/app/pervasive-aurora-mb-bad-apple/Makefile.inc b/src/app/pervasive-aurora-mb-bad-apple/Makefile.inc
new file mode 100644
index 0000000..9ab6de4
--- /dev/null
+++ b/src/app/pervasive-aurora-mb-bad-apple/Makefile.inc
@@ -0,0 +1,10 @@
+# vim:ft=make
+#
+# Copyright 2020 Daniel Friesel
+#
+# SPDX-License-Identifier: CC0-1.0
+
+ifdef app
+ CONFIG_lib_inflate = y
+ CONFIG_lib_inflate_lut = y
+endif
diff --git a/src/app/pervasive-aurora-mb-bad-apple/convert b/src/app/pervasive-aurora-mb-bad-apple/convert
new file mode 100755
index 0000000..10dec48
--- /dev/null
+++ b/src/app/pervasive-aurora-mb-bad-apple/convert
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+# ./convert.sh <file> -r <frame rate> [additional ffmpeg args]
+
+set -eu
+
+mkdir -p tmp
+
+ffmpeg -i "$@" tmp/frame%4d.png
+
+parallel mogrify -resize 160x160 -threshold 50% -- tmp/*.png
+
+echo "const unsigned char frame_rate = $3;" > frames.cc
+./frames-to-cc tmp/*.png >> frames.cc
+
+rm -rf tmp
diff --git a/src/app/pervasive-aurora-mb-bad-apple/frames-to-cc b/src/app/pervasive-aurora-mb-bad-apple/frames-to-cc
new file mode 100755
index 0000000..d734159
--- /dev/null
+++ b/src/app/pervasive-aurora-mb-bad-apple/frames-to-cc
@@ -0,0 +1,38 @@
+#!/usr/bin/env python3
+
+from PIL import Image
+import sys
+import zlib
+
+
+def load_image(filename):
+ im = Image.open(filename)
+ w, h = im.size
+ buf = [0 for i in range(w * h // 8)]
+ for y in range(h):
+ for x in range(w):
+ if im.getpixel((x, y)):
+ buf[x * (h//8) + y // 8] |= 1 << (7 - (y % 8))
+ return buf
+
+
+for i in range(1, len(sys.argv)):
+ buf = (
+ load_image(sys.argv[i])
+ )
+ c_buf = ",".join(map(str, buf))
+ z_buf = zlib.compress(bytes(buf), 9)
+ z_buf = z_buf[2:-4]
+ out_buf = ",".join(map(str, z_buf))
+ print(
+ f'__attribute__((section(".text"))) unsigned char const frame{i:04d}[] = {{ {out_buf} }};'
+ )
+
+frames = list()
+for i in range(1, len(sys.argv)):
+ frames.append(f"(unsigned char*)frame{i:04d}")
+
+prefix = "unsigned char* const frames[] = {"
+postfix = "};"
+
+print(prefix + ", ".join(frames) + postfix)
diff --git a/src/app/pervasive-aurora-mb-bad-apple/main.cc b/src/app/pervasive-aurora-mb-bad-apple/main.cc
new file mode 100644
index 0000000..a302c33
--- /dev/null
+++ b/src/app/pervasive-aurora-mb-bad-apple/main.cc
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2021 Daniel Friesel
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+#include "arch.h"
+#include "driver/gpio.h"
+#include "driver/stdout.h"
+#include "driver/spi.h"
+#include "driver/pervasive_aurora_mb.h"
+#include "object/framebuffer.h"
+#include "lib/inflate.h"
+
+#include "driver/timer.h"
+volatile unsigned char timer_done = 0;
+
+#include "frames.cc"
+
+__attribute__((section(".leaRAM"))) unsigned char img_buf[160 * 120 / 8];
+
+/*
+ * Flashless Update isn't working properly yet. Black-to-white transitions
+ * appear to be pretty much broken (or rather, nearly invisible).
+ * Or I broke my display, who knows.
+ */
+
+int main(void)
+{
+ unsigned int i = 0;
+ unsigned char line;
+ arch.setup();
+ gpio.setup();
+ kout.setup();
+ spi.setup();
+ pervasiveAuroraMb.setup();
+
+ timer.setup_hz_low(frame_rate);
+
+ while (1) {
+ for (i = 0; i < (sizeof(frames) / sizeof(frames[0])); i++) {
+
+ timer_done = 0;
+ timer.start(1);
+
+ inflate(frames[i], sizeof(img_buf), img_buf, sizeof(img_buf));
+ fb.clear();
+ fb.drawAt(0, 0, 160, 120, img_buf);
+
+ pervasiveAuroraMb.powerOn();
+ pervasiveAuroraMb.initialize(20, i%20);
+ pervasiveAuroraMb.sendImage((unsigned char*)fb.data, 0, 0, 160, 120);
+ pervasiveAuroraMb.sendUpdate();
+ pervasiveAuroraMb.powerOff();
+
+ while (!timer_done) {
+ arch.idle();
+ }
+ timer.stop();
+ }
+ }
+
+ return 0;
+}
+
+ON_TIMER_INTERRUPT_head
+ timer_done = 1;
+ON_TIMER_INTERRUPT_tail