Loading src/app/pervasive-aurora-mb-bad-apple/Kconfig 0 → 100644 +6 −0 Original line number Diff line number Diff line # Copyright 2020 Daniel Friesel # # SPDX-License-Identifier: CC0-1.0 prompt "Pervasive Aurora Mb Bad Apple" depends on framebuffer && driver_pervasive_aurora_mb && !wakeup src/app/pervasive-aurora-mb-bad-apple/Makefile.inc 0 → 100644 +10 −0 Original line number Diff line number Diff line # 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 src/app/pervasive-aurora-mb-bad-apple/convert 0 → 100755 +16 −0 Original line number Diff line number Diff line #!/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 src/app/pervasive-aurora-mb-bad-apple/frames-to-cc 0 → 100755 +38 −0 Original line number Diff line number Diff line #!/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) src/app/pervasive-aurora-mb-bad-apple/main.cc 0 → 100644 +67 −0 Original line number Diff line number Diff line /* * 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 Loading
src/app/pervasive-aurora-mb-bad-apple/Kconfig 0 → 100644 +6 −0 Original line number Diff line number Diff line # Copyright 2020 Daniel Friesel # # SPDX-License-Identifier: CC0-1.0 prompt "Pervasive Aurora Mb Bad Apple" depends on framebuffer && driver_pervasive_aurora_mb && !wakeup
src/app/pervasive-aurora-mb-bad-apple/Makefile.inc 0 → 100644 +10 −0 Original line number Diff line number Diff line # 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
src/app/pervasive-aurora-mb-bad-apple/convert 0 → 100755 +16 −0 Original line number Diff line number Diff line #!/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
src/app/pervasive-aurora-mb-bad-apple/frames-to-cc 0 → 100755 +38 −0 Original line number Diff line number Diff line #!/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)
src/app/pervasive-aurora-mb-bad-apple/main.cc 0 → 100644 +67 −0 Original line number Diff line number Diff line /* * 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