From 467b1b587811a2091d04a5faab20d6430313cd51 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sat, 10 Feb 2024 22:11:25 +0100 Subject: rename ssd1306-bad-apple to bad-apple-msp430fr-ssd1306-128x64 --- src/app/bad-apple-msp430fr-ssd1306-128x64/Kconfig | 6 ++ .../bad-apple-msp430fr-ssd1306-128x64/Makefile.inc | 16 +++++ src/app/bad-apple-msp430fr-ssd1306-128x64/convert | 16 +++++ .../bad-apple-msp430fr-ssd1306-128x64/frames-to-cc | 42 ++++++++++++ src/app/bad-apple-msp430fr-ssd1306-128x64/main.cc | 74 ++++++++++++++++++++++ src/app/ssd1306-bad-apple/Kconfig | 6 -- src/app/ssd1306-bad-apple/Makefile.inc | 16 ----- src/app/ssd1306-bad-apple/convert | 16 ----- src/app/ssd1306-bad-apple/frames-to-cc | 42 ------------ src/app/ssd1306-bad-apple/main.cc | 74 ---------------------- 10 files changed, 154 insertions(+), 154 deletions(-) create mode 100644 src/app/bad-apple-msp430fr-ssd1306-128x64/Kconfig create mode 100644 src/app/bad-apple-msp430fr-ssd1306-128x64/Makefile.inc create mode 100755 src/app/bad-apple-msp430fr-ssd1306-128x64/convert create mode 100755 src/app/bad-apple-msp430fr-ssd1306-128x64/frames-to-cc create mode 100644 src/app/bad-apple-msp430fr-ssd1306-128x64/main.cc delete mode 100644 src/app/ssd1306-bad-apple/Kconfig delete mode 100644 src/app/ssd1306-bad-apple/Makefile.inc delete mode 100755 src/app/ssd1306-bad-apple/convert delete mode 100755 src/app/ssd1306-bad-apple/frames-to-cc delete mode 100644 src/app/ssd1306-bad-apple/main.cc (limited to 'src') diff --git a/src/app/bad-apple-msp430fr-ssd1306-128x64/Kconfig b/src/app/bad-apple-msp430fr-ssd1306-128x64/Kconfig new file mode 100644 index 0000000..575e11b --- /dev/null +++ b/src/app/bad-apple-msp430fr-ssd1306-128x64/Kconfig @@ -0,0 +1,6 @@ +# Copyright 2020 Birte Kristina Friesel +# +# SPDX-License-Identifier: CC0-1.0 + +prompt "SSD1306 Bad Apple" +depends on driver_ssd1306 && !wakeup diff --git a/src/app/bad-apple-msp430fr-ssd1306-128x64/Makefile.inc b/src/app/bad-apple-msp430fr-ssd1306-128x64/Makefile.inc new file mode 100644 index 0000000..4d1b6d3 --- /dev/null +++ b/src/app/bad-apple-msp430fr-ssd1306-128x64/Makefile.inc @@ -0,0 +1,16 @@ +# vim:ft=make +# +# Copyright 2020 Birte Kristina Friesel +# +# SPDX-License-Identifier: CC0-1.0 + +ifdef app + override arch_drivers += i2c,timer + CONFIG_driver_ssd1306 = y + COMMON_FLAGS += -DCONFIG_driver_ssd1306 + CONFIG_driver_ssd1306_width = 128 + CONFIG_driver_ssd1306_height = 64 + CONFIG_lib_inflate = y + CONFIG_lib_inflate_lut = y + CONFIG_arch_msp430fr5994lp_large_mode = y +endif diff --git a/src/app/bad-apple-msp430fr-ssd1306-128x64/convert b/src/app/bad-apple-msp430fr-ssd1306-128x64/convert new file mode 100755 index 0000000..7d2ca0e --- /dev/null +++ b/src/app/bad-apple-msp430fr-ssd1306-128x64/convert @@ -0,0 +1,16 @@ +#!/bin/sh + +# [size=WxH] ./convert.sh -r [additional ffmpeg args] + +set -eu + +mkdir -p tmp + +ffmpeg -i "$@" tmp/frame%4d.png + +parallel mogrify -resize "${size:-128x64}" -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/bad-apple-msp430fr-ssd1306-128x64/frames-to-cc b/src/app/bad-apple-msp430fr-ssd1306-128x64/frames-to-cc new file mode 100755 index 0000000..bcbabf7 --- /dev/null +++ b/src/app/bad-apple-msp430fr-ssd1306-128x64/frames-to-cc @@ -0,0 +1,42 @@ +#!/usr/bin/env python3 + +from PIL import Image +import os +import sys +import zlib + +buf_w, buf_h = map(int, os.getenv("size", "128x64").split("x")) + +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 + + +for i in range(1, len(sys.argv) - 2, 3): + buf = ( + load_image(sys.argv[i]) + + load_image(sys.argv[i + 1]) + + load_image(sys.argv[i + 2]) + ) + 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) - 2, 3): + frames.append(f"(unsigned char*)frame{i:04d}") + +prefix = "unsigned char* const frames[] = {" +postfix = "};" + +print(prefix + ", ".join(frames) + postfix) diff --git a/src/app/bad-apple-msp430fr-ssd1306-128x64/main.cc b/src/app/bad-apple-msp430fr-ssd1306-128x64/main.cc new file mode 100644 index 0000000..d8d1b6f --- /dev/null +++ b/src/app/bad-apple-msp430fr-ssd1306-128x64/main.cc @@ -0,0 +1,74 @@ +/* + * Copyright 2020 Birte Kristina Friesel + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#include "arch.h" +#include "driver/gpio.h" +#include "driver/stdout.h" +#include "driver/i2c.h" +#include "driver/ssd1306.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[(SSD1306_WIDTH * SSD1306_HEIGHT / 8) * 3]; + +int main(void) +{ + unsigned int i = 0; + unsigned char line; + arch.setup(); + gpio.setup(); + kout.setup(); + i2c.setup(); + ssd1306.init(); + + timer.setup_hz_low(frame_rate); + + while (1) { + for (i = 0; i < (sizeof(frames) / sizeof(frames[0])); i++) { + + timer_done = 0; + timer.start(1); + + ssd1306.showImage(img_buf + (SSD1306_WIDTH * SSD1306_HEIGHT / 8 * 2), SSD1306_WIDTH * SSD1306_HEIGHT / 8); + + inflate(frames[i], sizeof(img_buf), img_buf, sizeof(img_buf)); + + while (!timer_done) { + arch.idle(); + } + timer.stop(); + + timer_done = 0; + timer.start(1); + + ssd1306.showImage(img_buf + (SSD1306_WIDTH * SSD1306_HEIGHT / 8 * 0), SSD1306_WIDTH * SSD1306_HEIGHT / 8); + + while (!timer_done) { + arch.idle(); + } + timer.stop(); + + timer_done = 0; + timer.start(1); + + ssd1306.showImage(img_buf + (SSD1306_WIDTH * SSD1306_HEIGHT / 8 * 1), SSD1306_WIDTH * SSD1306_HEIGHT / 8); + + while (!timer_done) { + arch.idle(); + } + timer.stop(); + } + } + + return 0; +} + +ON_TIMER_INTERRUPT_head + timer_done = 1; +ON_TIMER_INTERRUPT_tail diff --git a/src/app/ssd1306-bad-apple/Kconfig b/src/app/ssd1306-bad-apple/Kconfig deleted file mode 100644 index 575e11b..0000000 --- a/src/app/ssd1306-bad-apple/Kconfig +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright 2020 Birte Kristina Friesel -# -# SPDX-License-Identifier: CC0-1.0 - -prompt "SSD1306 Bad Apple" -depends on driver_ssd1306 && !wakeup diff --git a/src/app/ssd1306-bad-apple/Makefile.inc b/src/app/ssd1306-bad-apple/Makefile.inc deleted file mode 100644 index 4d1b6d3..0000000 --- a/src/app/ssd1306-bad-apple/Makefile.inc +++ /dev/null @@ -1,16 +0,0 @@ -# vim:ft=make -# -# Copyright 2020 Birte Kristina Friesel -# -# SPDX-License-Identifier: CC0-1.0 - -ifdef app - override arch_drivers += i2c,timer - CONFIG_driver_ssd1306 = y - COMMON_FLAGS += -DCONFIG_driver_ssd1306 - CONFIG_driver_ssd1306_width = 128 - CONFIG_driver_ssd1306_height = 64 - CONFIG_lib_inflate = y - CONFIG_lib_inflate_lut = y - CONFIG_arch_msp430fr5994lp_large_mode = y -endif diff --git a/src/app/ssd1306-bad-apple/convert b/src/app/ssd1306-bad-apple/convert deleted file mode 100755 index 7d2ca0e..0000000 --- a/src/app/ssd1306-bad-apple/convert +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -# [size=WxH] ./convert.sh -r [additional ffmpeg args] - -set -eu - -mkdir -p tmp - -ffmpeg -i "$@" tmp/frame%4d.png - -parallel mogrify -resize "${size:-128x64}" -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/ssd1306-bad-apple/frames-to-cc b/src/app/ssd1306-bad-apple/frames-to-cc deleted file mode 100755 index bcbabf7..0000000 --- a/src/app/ssd1306-bad-apple/frames-to-cc +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python3 - -from PIL import Image -import os -import sys -import zlib - -buf_w, buf_h = map(int, os.getenv("size", "128x64").split("x")) - -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 - - -for i in range(1, len(sys.argv) - 2, 3): - buf = ( - load_image(sys.argv[i]) - + load_image(sys.argv[i + 1]) - + load_image(sys.argv[i + 2]) - ) - 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) - 2, 3): - frames.append(f"(unsigned char*)frame{i:04d}") - -prefix = "unsigned char* const frames[] = {" -postfix = "};" - -print(prefix + ", ".join(frames) + postfix) diff --git a/src/app/ssd1306-bad-apple/main.cc b/src/app/ssd1306-bad-apple/main.cc deleted file mode 100644 index d8d1b6f..0000000 --- a/src/app/ssd1306-bad-apple/main.cc +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2020 Birte Kristina Friesel - * - * SPDX-License-Identifier: BSD-2-Clause - */ -#include "arch.h" -#include "driver/gpio.h" -#include "driver/stdout.h" -#include "driver/i2c.h" -#include "driver/ssd1306.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[(SSD1306_WIDTH * SSD1306_HEIGHT / 8) * 3]; - -int main(void) -{ - unsigned int i = 0; - unsigned char line; - arch.setup(); - gpio.setup(); - kout.setup(); - i2c.setup(); - ssd1306.init(); - - timer.setup_hz_low(frame_rate); - - while (1) { - for (i = 0; i < (sizeof(frames) / sizeof(frames[0])); i++) { - - timer_done = 0; - timer.start(1); - - ssd1306.showImage(img_buf + (SSD1306_WIDTH * SSD1306_HEIGHT / 8 * 2), SSD1306_WIDTH * SSD1306_HEIGHT / 8); - - inflate(frames[i], sizeof(img_buf), img_buf, sizeof(img_buf)); - - while (!timer_done) { - arch.idle(); - } - timer.stop(); - - timer_done = 0; - timer.start(1); - - ssd1306.showImage(img_buf + (SSD1306_WIDTH * SSD1306_HEIGHT / 8 * 0), SSD1306_WIDTH * SSD1306_HEIGHT / 8); - - while (!timer_done) { - arch.idle(); - } - timer.stop(); - - timer_done = 0; - timer.start(1); - - ssd1306.showImage(img_buf + (SSD1306_WIDTH * SSD1306_HEIGHT / 8 * 1), SSD1306_WIDTH * SSD1306_HEIGHT / 8); - - while (!timer_done) { - arch.idle(); - } - timer.stop(); - } - } - - return 0; -} - -ON_TIMER_INTERRUPT_head - timer_done = 1; -ON_TIMER_INTERRUPT_tail -- cgit v1.2.3