Unverified Commit 5db1ecd3 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Add Bad Apple on STM32F4 (WiP; timer is still missing)

parent 3fffef85
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
# Copyright 2020 Birte Kristina Friesel
#
# SPDX-License-Identifier: CC0-1.0

prompt "Bad Apple on STM32F4 + SSD1306 128x64 LCD"
depends on arch_stm32f446re_nucleo
#depends on meta_driver_timer
depends on driver_ssd1306 && driver_ssd1306_mode_horizontal
depends on lib_inflate && lib_inflate_lut
depends on !loop
depends on !wakeup
+16 −0
Original line number Diff line number Diff line
# 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
+16 −0
Original line number Diff line number Diff line
#!/bin/sh

# [size=WxH] ./convert.sh <file> -r <frame rate> [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
+43 −0
Original line number Diff line number Diff line
#!/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 = '__attribute__((section(".text"))) unsigned char* const frames[] = {'
postfix = "};"

print(prefix + ", ".join(frames) + postfix)
+1463 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading