Files
fmini-1/web/make_fmini_installer.py
T
Claude 2ddc729cf7 SMK-37 port: the FMini-1 mapping (pads, faders, < >, knobs), SMK37.md, the installer
The owner's mapping (smk37-port.yaml), in fmini_app.c behind BOARD_SMK37:
- Pads: the UI owns them (smk_input.h smk_pad_ui: a hit plays no note). A
  preset picker: the 16 presets of the page that holds the loaded one, in
  their category's colour (the loaded one bright), a pad loads its preset (in
  the SAVE dialog: the slot it writes). In the SEQ pop-up they show 16 of its
  64 slots in the pop-up's colours (the page of the step that plays, or of
  the slot a take writes next).
- FADER BANK: A the A.ENV knobs, B the F.ENV knobs, C the MIX knobs, and the
  screen shows that page; a fader takes over once it moves (fa_ctl_apply,
  absolute as a CC); main.c's smk_faders hands the faders to FMini-1.
- < / >: preset -1 / +1; held 1 s, five a second.
- Knobs: K1 MASTER, K2 PRESETS, K3 SELECT, K4 ALGORITHM, K5..K8 KNOB 1..4
  (panel.c, PANEL_MAGIC "FNS1"); the on-screen "K1-K4" hints read K5-K8 and
  SCL reads SCALE on the SMK.
- Buttons at the FM-1's places (the layer's map; PATCH is HOME, FILT; power-on
  on FILT as ever); KNOB BANK free; the mod wheel is CC1 as on the FM-1.
- SMK37.md (models, controls, build, install, the way back, safety), one
  README line, CREDITS (genkigenki's board layer and kit).
- Installer page: make_fmini_installer.py embeds this version's SMK-37
  packages beside the FM-1's when they are in build/; the page reads the
  connected device's model and installs that model's package (a picked .fwsc
  stays as it is); a note says so. The Installer workflow builds the three
  SMK packages before the FM-1 (last) and publishes them for download.

The FM-1 build is byte-identical to 2.5.0. Untested on hardware; the pad,
fader and button mapping has no host test yet (only the build and the board
layer's tests cover the SMK).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QUF6pQ1NkTwmBC8SR8AK94
2026-11-09 12:59:51 -03:00

51 lines
3.1 KiB
Python

#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-3.0-only
# FMini-1: the official site, one self-contained page (site_fmini.html: the Minimoog-styled site with the screens, the presets,
# MIDI and the Felucca installer's logic; the firmware package and every picture are embedded).
# web/make_fmini_installer.py build/fmini-1-fm1-<version>.fwsc OUT.html [VERSION]
# Serve it over https or http://localhost (Web MIDI with SysEx needs a secure context), in Chrome / Edge.
import base64
import json
import re
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
from make_site import HERE, strip_module, product_of # noqa: E402
def main(pkg, out, version="1.4.2"):
raw = Path(pkg).read_bytes()
product = product_of(raw)
if not re.fullmatch(r"FM-1_9\d\d", product) or b"FELUCCA-LOADER-1" not in raw:
raise SystemExit(f"{pkg}: not a Felucca-loader package (identity {product!r})")
html = (HERE / "site_fmini.html").read_text(encoding="utf-8")
lib = "\n".join(strip_module((HERE / f).read_text(encoding="utf-8")) for f in ("fm1pkg.js", "fm1ota.js", "fm1backup.js"))
url = "data:application/octet-stream;base64," + base64.b64encode(raw).decode()
boards = [] # the SMK-37 packages of this version beside the FM-1's (BOARD=smk37 builds), when present
for b in sorted(Path(pkg).parent.glob(f"fmini-1-smk37*-{version}.fwsc")):
rb = b.read_bytes()
pb = product_of(rb)
if not re.fullmatch(r"(SMK-37 Pro|SMK-37 Elite|MKE-P37)_9\d\d", pb) or b"FELUCCA-LOADER-1" not in rb:
raise SystemExit(f"{b}: not an SMK-37 package of FMini-1 (identity {pb!r})")
boards.append({"product": pb, "pkg": "data:application/octet-stream;base64," + base64.b64encode(rb).decode()})
meta = json.dumps({"version": version, "product": product, "pkg": url, "boards": boards})
hero = "data:image/jpeg;base64," + base64.b64encode((HERE.parent / "assets" / "fmini-installer-hero.jpg").read_bytes()).decode()
imgs = {p.stem: ("data:image/" + ("webp" if p.suffix == ".webp" else "png") + ";base64,") + base64.b64encode(p.read_bytes()).decode() for p in sorted((HERE.parent / "assets" / "site").glob("*.*"))}
names = re.findall(r'"([A-Z0-9 .\'/+&-]{2,12})"', (HERE.parent / "firmware" / "src" / "eng_fmini_presets.h").read_text())[:10]
html = html.replace("/*IMGS*/{}", json.dumps(imgs)).replace("/*PRESETS*/[]", json.dumps(names))
for mark in ("/*LIB*/", "/*META*/", "/*HERO*/"):
if html.count(mark) != 1:
raise SystemExit(f"site_fmini.html must contain {mark} once")
html = html.replace("/*LIB*/", lib).replace("/*META*/", meta).replace("/*HERO*/", hero)
html = html.replace('<span class="ver" id="ver">v1.1.0</span>', f'<span class="ver" id="ver">v{version}</span>', 1)
Path(out).write_text(html, encoding="utf-8")
print(f"{out}: {len(html)} B, {product}, package {len(raw)} B embedded" +
(f"; SMK-37: {', '.join(b['product'] for b in boards)}" if boards else ""))
if __name__ == "__main__":
if len(sys.argv) not in (3, 4):
sys.exit(__doc__)
main(*sys.argv[1:])