Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

- name: Generate matrix
id: matrix
run: ./ci/gen-matrix.py >> "$GITHUB_OUTPUT"
run: python3 ./ci/gen-matrix.py >> "$GITHUB_OUTPUT"

build:
name: Build ${{ matrix.name }}
Expand Down
Binary file added 2.13/mono/spi/dog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2.13/mono/spi/dog_blink.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2.13/mono/spi/dog_eat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2.13/mono/spi/dog_eat2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2.13/mono/spi/dog_happy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2.13/mono/spi/dog_look.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2.13/mono/spi/dog_sad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2.13/mono/spi/dog_surprised.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 76 additions & 0 deletions 2.13/mono/spi/jpfont.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/* generated by jpfont_gen.py - do not edit by hand */
#ifndef JPFONT_H
#define JPFONT_H
#include <stdint.h>

struct jpglyph { uint32_t cp; uint8_t size, w, h; uint16_t off; };

static const struct jpglyph jpglyphs[] = {
{0x3042, 14, 14, 14, 0},
{0x3046, 14, 14, 14, 28},
{0x3058, 14, 14, 14, 56},
{0x305D, 14, 14, 14, 84},
{0x3076, 14, 14, 14, 112},
{0x30A8, 14, 14, 14, 140},
{0x30B5, 14, 14, 14, 168},
{0x304A, 16, 16, 16, 196},
{0x304B, 16, 16, 16, 228},
{0x306A, 16, 16, 16, 260},
{0x30C3, 16, 16, 16, 292},
{0x30C8, 16, 16, 16, 324},
{0x30DA, 16, 16, 16, 356},
{0x5143, 20, 20, 20, 388},
{0x5206, 20, 20, 20, 448},
{0x6C17, 20, 20, 20, 508},
{0x7A7A, 20, 20, 20, 568},
{0x8179, 20, 20, 20, 628},
};
#define JPGLYPH_COUNT (sizeof(jpglyphs)/sizeof(jpglyphs[0]))

static const uint8_t jpbits[] = {
0x00,0x00,0x06,0x00,0x3F,0xE0,0x3F,0xE0,0x04,0x40,0x07,0xE0,0x0F,0xF0,0x1C,0x98,
0x35,0x98,0x67,0x18,0x66,0x18,0x7E,0x70,0x30,0xE0,0x00,0x00,0x00,0x00,0x0F,0xC0,
0x07,0xC0,0x00,0x00,0x03,0x80,0x3F,0xE0,0x38,0x60,0x00,0x20,0x00,0x60,0x00,0x60,
0x00,0xE0,0x07,0xC0,0x0F,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x18,0xA0,0x18,0xB0,
0x18,0xC0,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x10,0x18,0x30,0x18,0x70,
0x1F,0xE0,0x07,0x80,0x0F,0xC0,0x1F,0xE0,0x01,0x80,0x03,0x00,0x0E,0x30,0x7F,0xF0,
0x7F,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x03,0xE0,0x01,0xC0,0x00,0x00,
0x00,0x00,0x06,0x00,0x07,0x88,0x01,0xA8,0x01,0x90,0x00,0x00,0x06,0x00,0x07,0x20,
0x03,0x30,0x19,0x90,0x71,0x98,0xE1,0x98,0x4F,0x80,0x07,0x00,0x00,0x00,0x3F,0xF0,
0x3F,0xF0,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x7F,0xF8,
0x7F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x60,0x08,0x40,0x08,0x40,
0x7F,0xF8,0x7F,0xF8,0x08,0x40,0x08,0x40,0x18,0xC0,0x00,0xC0,0x01,0xC0,0x03,0x80,
0x07,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x06,0x00,0x06,0xD8,0x3F,0xDC,0x3F,0x0E,
0x06,0x02,0x06,0xE0,0x0F,0xF8,0x1E,0x1C,0x3E,0x0C,0x76,0x0C,0x76,0x1C,0x3E,0xF8,
0x1C,0xE0,0x00,0x00,0x00,0x00,0x06,0x00,0x06,0x00,0x06,0x18,0x3F,0xCC,0x7F,0xEC,
0x0C,0x66,0x0C,0x66,0x0C,0x67,0x18,0x60,0x18,0x60,0x38,0x60,0x30,0xC0,0x77,0xC0,
0x23,0x80,0x00,0x00,0x00,0x00,0x06,0x00,0x06,0x00,0x7F,0x98,0x7F,0x1E,0x0C,0x0E,
0x0C,0x60,0x18,0x60,0x18,0x60,0x38,0x60,0x33,0xF0,0x77,0xF8,0x06,0x7C,0x06,0x6C,
0x07,0xE0,0x01,0xC0,0x00,0x00,0x00,0x00,0x01,0x00,0x19,0x9C,0x19,0x9C,0x19,0x98,
0x0C,0x38,0x00,0x30,0x00,0x70,0x00,0xE0,0x03,0xC0,0x07,0x80,0x02,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,
0x07,0x80,0x07,0xF0,0x07,0xFC,0x06,0x18,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,
0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,0x16,0x07,0x16,0x0F,0x9C,
0x0F,0xC0,0x1C,0xE0,0x38,0x70,0x70,0x38,0x60,0x38,0x00,0x1C,0x00,0x0E,0x00,0x04,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0x80,0x1F,0xFF,0x80,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xE0,0x7F,0xFF,0xE0,0x03,
0x1C,0x00,0x07,0x1C,0x00,0x07,0x1C,0x00,0x07,0x1C,0x00,0x0E,0x1C,0x60,0x0E,0x1C,
0x60,0x1C,0x1C,0x60,0x78,0x1F,0xE0,0x70,0x0F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
0x03,0x0C,0x00,0x07,0x0E,0x00,0x07,0x07,0x00,0x0E,0x07,0x00,0x1C,0x03,0x80,0x3C,
0x01,0xC0,0x78,0x01,0xE0,0x7F,0xFF,0xE0,0x6F,0xFF,0xC0,0x01,0xC3,0x00,0x01,0xC3,
0x00,0x01,0x83,0x00,0x03,0x83,0x00,0x03,0x83,0x00,0x07,0x03,0x00,0x0F,0x07,0x00,
0x1E,0x07,0x00,0x3C,0x3E,0x00,0x30,0x3E,0x00,0x00,0x00,0x00,0x0E,0x00,0x00,0x0F,
0xFF,0xE0,0x1F,0xFF,0xE0,0x1C,0x00,0x00,0x3F,0xFF,0x80,0x77,0xFF,0x80,0x70,0x00,
0x00,0x3F,0xFF,0x00,0x1F,0xFF,0x00,0x00,0x63,0x00,0x0C,0x73,0x00,0x1E,0xE3,0x00,
0x0F,0xC3,0x00,0x03,0xC3,0x00,0x07,0xE3,0x20,0x0F,0xF3,0xA0,0x3E,0x7B,0xE0,0x3C,
0x11,0xE0,0x30,0x00,0xC0,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x60,0x00,0x7F,0xFF,
0xE0,0x7F,0xFF,0xE0,0x73,0x98,0xE0,0x73,0x98,0xE0,0x23,0x98,0x00,0x07,0x18,0xC0,
0x3E,0x1F,0xC0,0x3C,0x0F,0xC0,0x30,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0x80,0x1F,
0xFF,0x80,0x00,0x60,0x00,0x00,0x60,0x00,0x00,0x60,0x00,0x7F,0xFF,0xE0,0x7F,0xFF,
0xE0,0x00,0x00,0x00,0x3F,0x30,0x00,0x3F,0x7F,0xE0,0x37,0x7F,0xE0,0x37,0xE0,0x00,
0x37,0xFF,0xC0,0x3F,0xF0,0xC0,0x3F,0x70,0xC0,0x37,0x7F,0xC0,0x37,0x60,0xC0,0x37,
0x7F,0xC0,0x3F,0x3C,0x00,0x3F,0x3F,0xC0,0x37,0x7F,0xC0,0x77,0xF1,0xC0,0x67,0xFF,
0x80,0x67,0x1F,0x00,0x67,0x7F,0x80,0x6F,0xFF,0xE0,0x6E,0xE0,0xE0,0x00,0x00,0x00,
};

#endif /* JPFONT_H */
80 changes: 80 additions & 0 deletions 2.13/mono/spi/jpfont_gen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/usr/bin/env python3
"""
Generate jpfont.h: a tiny 1-bit bitmap font holding ONLY the Japanese (and any
other) glyphs used by the Open-EP Pet UI, rasterised from a system CJK font.

Each glyph is rendered into a square size*size cell (fullwidth), thresholded to
pure black/white (no anti-alias, for crisp e-paper output). Re-run after
changing any UI string; the build embeds only what is listed in JOBS.

python3 jpfont_gen.py # writes jpfont.h next to this script
"""
import os
from PIL import Image, ImageFont, ImageDraw

FONT = "/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc"
OUT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "jpfont.h")

# (pixel size, text whose unique chars must be available at that size)
JOBS = [
(20, "空腹元気気分"), # stat labels
(16, "おなかペット"), # title
(14, "エサあそぶそうじ"), # buttons: Feed / Play / Clean
]

def render_glyph(ch, size):
"""Return (w, h, rows[]) 1-bit bitmap centred in a size*size cell."""
font = ImageFont.truetype(FONT, size)
img = Image.new("L", (size, size), 0)
d = ImageDraw.Draw(img)
x0, y0, x1, y1 = font.getbbox(ch)
gw, gh = x1 - x0, y1 - y0
pos = ((size - gw) // 2 - x0, (size - gh) // 2 - y0)
d.text(pos, ch, font=font, fill=255)
px = img.load()
stride = (size + 7) // 8
rows = []
for y in range(size):
row = bytearray(stride)
for x in range(size):
if px[x, y] >= 128:
row[x >> 3] |= 0x80 >> (x & 7)
rows.append(row)
return size, size, rows

def main():
glyphs = [] # (cp, size, w, h, rows)
seen = set()
for size, text in JOBS:
for ch in text:
key = (ord(ch), size)
if key in seen:
continue
seen.add(key)
w, h, rows = render_glyph(ch, size)
glyphs.append((ord(ch), size, w, h, rows))
glyphs.sort(key=lambda g: (g[1], g[0])) # by (size, codepoint)

blob, offs = bytearray(), []
for cp, size, w, h, rows in glyphs:
offs.append(len(blob))
for row in rows:
blob += row

with open(OUT, "w") as f:
f.write("/* generated by jpfont_gen.py - do not edit by hand */\n")
f.write("#ifndef JPFONT_H\n#define JPFONT_H\n#include <stdint.h>\n\n")
f.write("struct jpglyph { uint32_t cp; uint8_t size, w, h; uint16_t off; };\n\n")
f.write("static const struct jpglyph jpglyphs[] = {\n")
for (cp, size, w, h, _), off in zip(glyphs, offs):
f.write(f"\t{{0x{cp:04X}, {size}, {w}, {h}, {off}}},\n")
f.write("};\n#define JPGLYPH_COUNT (sizeof(jpglyphs)/sizeof(jpglyphs[0]))\n\n")
f.write("static const uint8_t jpbits[] = {\n")
for i in range(0, len(blob), 16):
f.write("\t" + ",".join(f"0x{b:02X}" for b in blob[i:i+16]) + ",\n")
f.write("};\n\n#endif /* JPFONT_H */\n")

print(f"{len(glyphs)} glyphs, {len(blob)} bytes -> {OUT}")

if __name__ == "__main__":
main()
Binary file added 2.13/mono/spi/pet_auto.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading