From 2ddc729cf7910a782fd148e988f7bde7b41c6ca4 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 9 Nov 2026 12:59:51 -0300 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_01QUF6pQ1NkTwmBC8SR8AK94 --- .github/workflows/installer.yml | 11 +- CREDITS.md | 6 ++ README.md | 2 + SMK37.md | 98 ++++++++++-------- firmware/hal/smk_input.h | 9 ++ firmware/src/fmini_app.c | 175 +++++++++++++++++++++++++++++++- firmware/src/main.c | 4 + firmware/src/panel.c | 7 +- web/make_fmini_installer.py | 12 ++- web/site_fmini.html | 25 +++++ 10 files changed, 292 insertions(+), 57 deletions(-) diff --git a/.github/workflows/installer.yml b/.github/workflows/installer.yml index aa9965b..141742b 100644 --- a/.github/workflows/installer.yml +++ b/.github/workflows/installer.yml @@ -41,14 +41,19 @@ jobs: https://gitee.com/Jieli-Tech/fw-AC79_AIoT_SDK.git "$HOME/fw-AC79_AIoT_SDK" - name: Build the firmware - run: ./build.sh + run: | + BOARD=smk37 ./build.sh # the SMK-37 packages (SMK37.md): Pro, Elite, MKE-P37 + BOARD=smk37 MODEL=elite ./build.sh + BOARD=smk37 MODEL=mke ./build.sh + ./build.sh # the FM-1 last (the shared intermediates are the FM-1's again) - name: Make the installer page run: | VERSION=$(sed -n 's/^#define FMINI_VERSION "v\(.*\)"/\1/p' firmware/src/core.h) mkdir -p _site - python3 web/make_fmini_installer.py "$(ls build/fmini-1-fm1-*.fwsc | head -1)" _site/index.html "$VERSION" - cp "$(ls build/fmini-1-fm1-*.fwsc | head -1)" "_site/fmini-1-$VERSION.fwsc" + python3 web/make_fmini_installer.py "build/fmini-1-fm1-$VERSION.fwsc" _site/index.html "$VERSION" + cp "build/fmini-1-fm1-$VERSION.fwsc" "_site/fmini-1-$VERSION.fwsc" + for f in build/fmini-1-smk37*-"$VERSION".fwsc; do cp "$f" _site/; done # (the SMK-37 packages to download) cp docs/fmini-ad.mp4 docs/fmini-ad-poster.jpg _site/ mkdir -p _site/editor && cp web/editor_fmini.html _site/editor/index.html # the patch editor (web/test_editor_fmini.py) cp -r docs/emu _site/emu # the browser emulator (web/emu/build_wasi.sh builds docs/emu) diff --git a/CREDITS.md b/CREDITS.md index 67415dc..6885c32 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -31,3 +31,9 @@ thanks the work below; each keeps its own licence (see [LICENSE](LICENSE), [LICE [jasonpersinger](https://github.com/jasonpersinger) (the ROOM reverb click fix, #121), [renebohne](https://github.com/renebohne) (MIDI Program Change, #179), [gospodindilly-ops](https://github.com/gospodindilly-ops) (the second core, #247) + +## SMK-37 port + +The SMK-37 board layer (input HAL, display, pad LEDs, flash map, update path, installers and their tests) is +genkigenki's (M. Geisler), from [genkigenki/Felucca](https://github.com/genkigenki/Felucca) branch `smk37` +(hugelton/Felucca#237), GPL-3.0, with the [fm1-to-smk37](https://github.com/genkigenki/fm1-to-smk37) kit's guide. diff --git a/README.md b/README.md index 7624075..1d16392 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ Official site: (with Web Installer) Supports the new FM-1 versions (with the UC25HQ80 flash chip). +**M-Vave SMK-37 (beta):** see [SMK-37 instructions](SMK37.md). + ## 3. Credits FMini-1 was made by Guilherme Ruppert. It is inspired and partially based on the [Felucca](https://github.com/hugelton/Felucca) project by Leo Kuroshita (Hügelton Instruments). diff --git a/SMK37.md b/SMK37.md index d06878b..4a5c4a0 100644 --- a/SMK37.md +++ b/SMK37.md @@ -1,82 +1,90 @@ -# Felucca on the SMK-37 (beta) +# FMini-1 on the M-Vave SMK-37 (beta) -Felucca also builds for the SMK-37, a 37-key controller with the same chip as the FM-1. The FM-1 build -is unchanged; everything for the SMK-37 is behind `BOARD_SMK37`. +FMini-1 also builds for the M-Vave SMK-37, a 37-key controller with the same chip as the FM-1. The FM-1 build is +unchanged; everything for the SMK-37 is behind `BOARD_SMK37`. The board layer comes from the +[fm1-to-smk37](https://github.com/genkigenki/fm1-to-smk37) kit (genkigenki/Felucca, branch `smk37`). The decisions +behind the mapping are in [smk37-port.yaml](smk37-port.yaml). + +Nothing here has been tested on a real SMK-37 yet. ## Supported models -- **SMK-37 Pro**: the default build (package identity `SMK-37 Pro_900`). -- **SMK-37 Elite**: `MODEL=elite` (identity `SMK-37 Elite_900`). -- **MKE-P37**: `MODEL=mke` (identity `MKE-P37_900`). +- **SMK-37 Pro**: the default build, `fmini-1-smk37-.fwsc` (identity `SMK-37 Pro_900`). Also the Starrykey 37 Play. +- **SMK-37 Elite**: `fmini-1-smk37-elite-.fwsc` (identity `SMK-37 Elite_900`). +- **MKE-P37**: `fmini-1-smk37-mke-.fwsc` (identity `MKE-P37_900`). -All of them are the same hardware. Each build carries its model's name, so the stock updater still takes that -unit's stock package later: install the package for your model. The installers take a package only for exactly -the connected model (an Elite package is refused on a Pro, an FM-1 package on any SMK, an SMK package on an FM-1); -the unit's own stock package is the same model, so the way back to stock is always open. +They are the same hardware. Each package carries its model's name, so the manufacturer's updater still takes that +unit's own stock package later: install the package for your model. The installers take a package only for exactly +the connected model. ## Controls -The FM-1's manual still applies; the SMK-37's controls map onto the FM-1's like this. - -| SMK-37 | Felucca | +| SMK-37 | FMini-1 | | --- | --- | | Keys F3..G5 (the middle 27) | the FM-1's 27 keys, with velocity | -| Keys C3..E3 and G#5..C6 (the outer 10) | more notes for the selected track (its key map, scale and octave), one note each, with velocity | -| 16 pads | the 16 white keys F3..G5, with velocity, low notes on the bottom row; where the keys are a grid (the DRUM grid, NAME, the layers) steps 1-8 are the top row and 9-16 the bottom row. Lit in the theme colour | +| Keys C3..E3 and G#5..C6 (the outer 10) | more notes, one each, with velocity | +| 16 pads | the 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 the pads show 16 of its 64 steps (the page of the step that plays, or of the slot a take writes next) | | K1 | MASTER (volume) | -| K2 / K3 / K4 | SELECT / ALGORITHM / PRESETS | -| K5..K8 | KNOB 1..4 | -| FX, SCALE, CHORD, NOTE REPEAT, PARA, GLOBE | FX, SCL, ENV, LFO, EDIT, GLO | -| PATCH / BT | HOME / SAVE | -| ARP / SEQ | ARP / SEQ | +| K2 / K3 / K4 | PRESETS / SELECT / ALGORITHM | +| K5..K8 | KNOB 1..4 (the page's four knobs) | +| PATCH | HOME: the FILT page, the pop-ups close | +| PARA | EDIT: FILT; again on FILT, PRESET SETTINGS | +| SCALE | SCL: OSC, again MIX; in the delay pop-up, tap tempo | +| CHORD | ENV: F.ENV, again A.ENV | +| NOTE REPEAT | LFO: CTRL | +| FX | FX; again, the four FX pop-ups in turn | +| GLOBE | GLO: the GLOBAL pop-up | +| BT | SAVE | +| ARP / SEQ | the ARP / SEQ pop-ups | | SEQ PLAY / SEQ REC | PLAY / REC | | OCTAVE- / OCTAVE+ | OCT- / OCT+ | -| KNOB BANK | as HOME held: opens or closes the menu (lit while the menu is open) | -| < / > | the previous / next page of the current page group; in the menu, the previous / next row; on HOME, > is HOME tapped | -| FADER BANK | what the faders set for tracks 1..4: A LEVEL, B PAN, C REV send, D DLY send (lit off bank A) | -| Faders 1..4 | tracks 1..4 in the current bank; a fader takes over only once it moves | -| Pitch wheel | pitch bend of the selected track (its MIDI channel's bend range, 2 semitones unless set); also sent as MIDI | -| Mod wheel | the selected track's mod wheel (CC1, the MOD matrix's MODW source); also sent as MIDI | +| < / > | the previous / next preset; held 1 s, five presets a second | +| FADER BANK | what the faders set: A the A.ENV knobs, B the F.ENV knobs, C the MIX knobs; it opens that page (lit off bank A) | +| Faders 1..4 | the four knobs of the bank's page; a fader takes over only once it moves | +| KNOB BANK | (free) | +| Pitch wheel | pitch bend (the preset's PITCH BEND range); also sent as MIDI | +| Mod wheel | as MIDI CC1 on the FM-1 (the vibrato); also sent as MIDI | | OCTAVE- + OCTAVE+ held at power-on | HARDWARE CALIBRATION: teach the buttons and knobs again | -The SMK-37's TRS jack is a MIDI output and this build does not use it; there is no TRS MIDI IN. MIDI works over USB. +The SMK-37's TRS jack is a MIDI output and this build does not use it; there is no TRS MIDI IN, so MIDI clock comes +over USB only. ## Build See [BUILDING.md](BUILDING.md) for the toolchain. ```sh -BOARD=smk37 ./build.sh # build/felucca-smk37.fwsc (SMK-37 Pro) -BOARD=smk37 MODEL=elite ./build.sh # build/felucca-smk37-elite.fwsc -BOARD=smk37 MODEL=mke ./build.sh # build/felucca-smk37-mke.fwsc +BOARD=smk37 ./build.sh # build/fmini-1-smk37-.fwsc (SMK-37 Pro) +BOARD=smk37 MODEL=elite ./build.sh # build/fmini-1-smk37-elite-.fwsc +BOARD=smk37 MODEL=mke ./build.sh # build/fmini-1-smk37-mke-.fwsc ./build.sh # the FM-1 build again before tests/run_tests.sh (the tests use its files) ``` ## Install -Connect the keyboard by USB and run, with the package for your model: +Make a full flash backup first (the fm1-to-smk37 kit, `docs/02-update-and-recovery.md`, section 3), and have the +manufacturer's package for your model and its updater ready. Then connect the keyboard by USB and run, with the +package for your model: ```sh -python3 tools/fm1_install.py build/felucca-smk37.fwsc +python3 tools/fm1_install.py build/fmini-1-smk37-.fwsc ``` -`fm1_install.py` needs `mido` and `python-rtmidi` (`pip3 install mido python-rtmidi`). It checks that the package -is for the connected model. +`fm1_install.py` needs `mido` and `python-rtmidi` (`pip3 install mido python-rtmidi`). It checks that the package is +for the connected model. ## Going back to the stock firmware -Install the manufacturer's firmware package for your model with the manufacturer's updater. It works directly, because -the installed package keeps the keyboard's model name. `tools/fm1_install.py` can also install the stock SMK-37 Pro -V016 package. +Install the manufacturer's firmware package for your model with the manufacturer's updater. It works directly, +because the installed package keeps the keyboard's model name. ## Safety -- Back up first: have the stock package for your model and the manufacturer's updater ready before you install. -- Keep the USB cable connected until the install has finished and the keyboard has restarted. -- The first start clears the stock firmware's settings, and any other firmware's data, in the shared data area. -- The stock firmware's key, knob and fader mapping (in the user sample area) is kept intact. Before the first - sample is written there, Felucca releases the stock firmware's marker for that area, so after going back to - stock the stock firmware rebuilds its factory mapping instead of reading erased data. -- The firmware never writes the keyboard's calibration, Bluetooth pairing or key areas; the flash map refuses - them at compile time and again in the flash driver. +- The first start clears the stock firmware's settings, and any other firmware's data, in the shared data area + (FMini-1's store is tagged `SMK37DATAFMINI`). +- FMini-1's 200 preset slots live in the user sample area (0xC2000..0xDBFFF). The stock firmware's key, knob and + fader mapping there is kept until FMini-1 first writes a preset; the stock marker is released before that, so the + stock firmware rebuilds its factory mapping after a return to stock. +- The firmware never writes the keyboard's calibration, Bluetooth pairing or key areas; the flash map refuses them at + compile time and again in the flash driver. - Installing other firmware is at your own risk. diff --git a/firmware/hal/smk_input.h b/firmware/hal/smk_input.h index 707b4fb..0d93106 100644 --- a/firmware/hal/smk_input.h +++ b/firmware/hal/smk_input.h @@ -102,6 +102,10 @@ static volatile uint8_t smk_pad_grid; /* set by the UI: pads as a step grid, w * black keys between them (C#4 D#4 - F#4 G#4 A#4 - C#5); note-key index (0 = F3) by hardware pad, -1 = none */ static const int8_t SMK_PIANO_NOTE[SMK_NPAD] = {7, 9, 11, 12, 14, 16, 18, 19, 8, 10, -1, 13, 15, 17, -1, 20}; static volatile uint8_t smk_pad_piano; +/* the UI owns the pads (FMini-1: a preset picker, the SEQ's steps): a hit plays no note, it sets the hardware pad's bit + * in smk_pad_hits (taken by the UI); a release does nothing */ +static volatile uint8_t smk_pad_ui; +static volatile uint16_t smk_pad_hits; static uint8_t smk_pad_note[SMK_NPAD]; /* the note key a pad pressed (+1; 0 = none): its release ends that one */ #define SMK_WHITE_OF_PAD(p) (smk_pad_grid ? (p) : (p) < 8u ? (p) + 8u : (p) - 8u) @@ -439,6 +443,11 @@ static void smk__padq(uint32_t pad, uint32_t vel) /* a pad hit (vel) or rele { int32_t n0 = smk_pad_piano ? SMK_PIANO_NOTE[pad] : (int32_t)SMK_WHITE_NOTE[SMK_WHITE_OF_PAD(pad)]; uint32_t n, bit; + if (smk_pad_ui && !smk_pad_note[pad]) { /* (a note a pad started before keeps its release) */ + if (vel) + smk_pad_hits |= (uint16_t)(1u << pad); + return; + } if (vel) { if (n0 < 0) return; /* (a gap of the piano layout) */ diff --git a/firmware/src/fmini_app.c b/firmware/src/fmini_app.c index fed17ae..1619be1 100644 --- a/firmware/src/fmini_app.c +++ b/firmware/src/fmini_app.c @@ -30,6 +30,15 @@ #define FA_NPAGE 7u static uint8_t fa_page; /* 0..6 */ +#if BOARD_SMK37 /* the four page knobs are K5..K8 on the SMK-37, its SCL button SCALE */ +#define FA_K14 "K5-K8" +#define FA_K13 "K5-K7" +#define FA_SCL "SCALE" +#else +#define FA_K14 "K1-K4" +#define FA_K13 "K1-K3" +#define FA_SCL "SCL" +#endif static uint8_t fa_env_last; /* ENV: the page it opened last (F.ENV or A.ENV) */ static uint32_t fa_sig_prev = 0xFFFFFFFFu; static uint16_t fa_knob_bmp[38 * 38]; /* the baked knob: 0 = transparent */ @@ -524,7 +533,7 @@ static void fa_fx_dialog(void) cv_rect(20, 66, 200, 1, FA_RULE); for (i = 0; i < 4u; i++) fa_pop_knob(pg, i, 39 + (int32_t)i * 54, 112, fmg_cur[pg] == i); - fa_ctext(120, 190, &AF_X, fmg_fx == 2u ? "K1-K4 SCL=TAP FX=NEXT" : "K1-K4 SELECT ALGO FX=NEXT", FA_MU); + fa_ctext(120, 190, &AF_X, fmg_fx == 2u ? FA_K14 " " FA_SCL "=TAP FX=NEXT" : FA_K14 " SELECT ALGO FX=NEXT", FA_MU); } static void fa_wave_boxes(uint32_t pg, uint32_t cur) @@ -771,7 +780,7 @@ static void fa_ar_dialog(void) fmt_int(val, song.g[G_BPM]); fa_line(62 + (int32_t)i * 22, FA_AR_LB[i], val, i == fa_ar_row); } - fa_ctext(120, 196, &AF_S, "SELECT ALGO K1-K4 ARP=CLOSE", FA_MU); + fa_ctext(120, 196, &AF_S, "SELECT ALGO " FA_K14 " ARP=CLOSE", FA_MU); } /* the ARP button: a tap turns it on / off (on another screen, while it is on, a tap only opens the pop-up); held HOLD on / off. @@ -894,7 +903,7 @@ static void fa_sc_dialog(void) fmt_int(val, song.g[G_BPM]); fa_line(70 + (int32_t)i * 28, FA_SC_LB[i], val, i == fa_sc_row); } - fa_ctext(120, 196, &AF_S, "SELECT ALGO K1-K3 SEQ=CLOSE", FA_MU); + fa_ctext(120, 196, &AF_S, "SELECT ALGO " FA_K13 " SEQ=CLOSE", FA_MU); } static void fa_seq_note(track_t *t, uint32_t note) @@ -2305,6 +2314,160 @@ static void fa_reload_reset(void) fa_factory_extras(t, cur); } +#if BOARD_SMK37 +/* ------------------------------------------------ the SMK-37's extras --- * + * (smk37-port.yaml, the owner's choices) The 16 pads are the UI's (smk_input.h smk_pad_ui): a preset picker, the 16 + * presets of the page that holds the loaded one, in their category's colour (the loaded one full, the others dim), a pad + * loads its preset; in the SEQ pop-up they show 16 of its 64 slots (the page of the step that plays, or of the slot a + * take writes next) in the pop-up's colours. FADER BANK: the faders set the four knobs of A.ENV, then F.ENV, then MIX, + * and the screen shows that page. < / >: the previous / next preset; held 1 s, five a second. */ +static uint8_t fa_fbank, fa_fbank_new = 1; /* 0 A.ENV, 1 F.ENV, 2 MIX */ +static const uint8_t FA_FB_PAGE[3] = {5u, 4u, 2u}; + +static uint32_t fa_ctl_of(uint32_t pg, uint32_t i) /* page pg's control i -> the control number (fa_ctl_apply) */ +{ + uint32_t p, n = 0; + for (p = 0; p < pg; p++) + n += fmg_count(p) - (p == 0u); /* (as fa_ctl_loc) */ + return n + i; +} + +/* the four faders on the bank's page (main.c calls it each frame); a fader takes over only once it moves (also after a + * bank change), so nothing jumps; one moved shows its page (when no pop-up is up) */ +static void fa_smk_faders(void) +{ + static uint8_t last[4] = {0xFF, 0xFF, 0xFF, 0xFF}; + uint32_t i, pg = FA_FB_PAGE[fa_fbank % 3u]; + if (fa_fbank_new) { + fa_fbank_new = 0; + for (i = 0; i < 4u; i++) + last[i] = 0xFF; + } + for (i = 0; i < 4u; i++) { + uint32_t v = fm1_in.fader[i]; + if (last[i] == 0xFF || fm1_in.frames < 200u) { /* (the first readings settle) */ + last[i] = (uint8_t)v; + continue; + } + if (v == last[i]) + continue; + last[i] = (uint8_t)v; + if (!fa_gl && !fa_sq && !fa_ar && !fa_sv && !fa_sc && !fmg_fx && fa_page != pg) + fa_goto(pg); + fmg_force_page = (int8_t)pg; + fa_ctl_apply(fa_ctl_of(pg, i), v); + fmg_force_page = (int8_t)fa_page; + ui.force = 1; + } +} + +static void fa_smk_input(uint32_t pressed) +{ + static uint32_t lr_t0, lr_next; + static int32_t lr_dir; + uint32_t hits, p, cur; + int32_t d = ((pressed >> SMK_BTN_RIGHT) & 1u) ? 1 : ((pressed >> SMK_BTN_LEFT) & 1u) ? -1 : 0; + smk_pad_ui = 1; + if ((pressed >> SMK_BTN_FADER_BANK) & 1u) { /* FADER BANK: A.ENV -> F.ENV -> MIX, and that page */ + fa_fbank = (uint8_t)((fa_fbank + 1u) % 3u); + fa_fbank_new = 1; + smk_fbank = fa_fbank; /* (ui_input.c smk_leds: lit off bank A) */ + if (!fa_gl && !fa_sq && !fa_ar && !fa_sv && !fa_sc) + fa_goto(FA_FB_PAGE[fa_fbank]); + } + if (d) { /* < / >: a preset; held, it runs on */ + lr_dir = d; + lr_t0 = fm1_ms; + lr_next = fm1_ms + 1000u; + } else if (lr_dir && !((fm1_in.buttons >> (lr_dir > 0 ? SMK_BTN_RIGHT : SMK_BTN_LEFT)) & 1u)) { + lr_dir = 0; + } else if (lr_dir && (int32_t)(fm1_ms - lr_next) >= 0) { + d = lr_dir; + lr_next += 200u; /* five a second */ + (void)lr_t0; + } + if (d && !fa_gl) + fa_preset(d); + fm1_irq_off(); + hits = smk_pad_hits; + smk_pad_hits = 0; + fm1_irq_on(); + if (!hits || fa_gl || fa_sq || fa_sc) /* (the SEQ's pads show its steps: no action) */ + return; + cur = fa_sv ? fa_sv_slot : fa_cur_slot(); + for (p = 0; p < SMK_NPAD; p++) + if ((hits >> p) & 1u) { + uint32_t k = cur / 16u * 16u + p; /* pads 1-8 the top row: hardware pads 0..7 */ + if (k >= FMINI_NSLOT) + continue; + if (fa_sv) { /* the SAVE dialog: the slot it writes */ + fa_sv_slot = (uint8_t)k; + fa_sv_fill(); + } else if (k != cur) { + fa_preset((int32_t)k - (int32_t)cur); + } + cur = k; + } +} + +/* the pads' colours, over smk_leds' picture (fa_leds) */ +static uint32_t fa_cat_rgb(char c) /* a category's colour (category.c's letters) */ +{ + switch (c) { + case 'B': return 0xE0402Au; /* bass: red */ + case 'L': return 0xE0752Bu; /* lead: orange (the panel's) */ + case 'P': return 0x2F7FE0u; /* pad: blue */ + case 'U': return 0x30C060u; /* pluck: green */ + case 'K': return 0xE0C030u; /* keys: yellow */ + default: return 0xA050E0u; /* fx (and the rest): violet */ + } +} +static void fa_pad(uint32_t p, uint32_t rgb, uint32_t lv) /* lv 0..256 */ +{ + padled_set(p, (uint8_t)(((rgb >> 16) & 255u) * lv >> 8), (uint8_t)(((rgb >> 8) & 255u) * lv >> 8), + (uint8_t)((rgb & 255u) * lv >> 8)); +} +static void fa_smk_pads(void) +{ + uint32_t p; + if ((int32_t)(fm1_ms - padled_hold_until) < 0) /* (console padtest has them) */ + return; + if (fa_sq) { /* the SEQ pop-up: 16 of its 64 slots, as on its grid */ + const track_t *t = TSEL; + uint32_t len = (uint32_t)clamp(t->p[P_SLEN], 1, NSTEP), now = song.playing ? t->seq_idx % len : 99u, notes = 0, base; + for (p = 0; p < len; p++) + notes |= t->step[p].n; + base = (fa_sq_rec ? fa_sq_cur : now < NSTEP ? now : 0u) / 16u * 16u; + for (p = 0; p < SMK_NPAD; p++) { + uint32_t i = base + p; + if (i >= NSTEP) + fa_pad(p, 0, 0); + else if (i == now) + fa_pad(p, 0xE0752Bu, 256u); /* the step that plays: orange */ + else if (i < len && t->step[i].n) + fa_pad(p, 0xD6382Bu, 96u); /* recorded: red */ + else if (fa_sq_rec && i == fa_sq_cur && fa_sq_blink()) + fa_pad(p, 0xECE4D0u, 160u); /* the next slot of the take: cream */ + else if (i < len && (notes || fa_sq_cur)) + fa_pad(p, 0xD6382Bu, 24u); /* a rest of the take: a dark red */ + else + fa_pad(p, 0x2A2520u, 32u); /* empty */ + } + return; + } + { + uint32_t cur = fa_sv ? fa_sv_slot : fa_cur_slot(), base = cur / 16u * 16u; + for (p = 0; p < SMK_NPAD; p++) { + uint32_t k = base + p; + if (k >= FMINI_NSLOT) + fa_pad(p, 0, 0); + else + fa_pad(p, fa_cat_rgb(FMINI_CATS[k]), k == cur ? 256u : 20u); + } + } +} +#endif + static void fa_input(void) { uint32_t pressed = fm1_input_edges(0), k; @@ -2358,6 +2521,9 @@ static void fa_input(void) if (!fa_ar && !fa_sq && !fa_sc) fa_tp = 0; /* the TAP TEMPO pop-up lives over the ARP or SEQ pop-up alone */ fa_buttons(pressed); +#if BOARD_SMK37 + fa_smk_input(pressed); +#endif if ((s = panel_enc(EN_PRESET)) != 0 && !fa_gl) fa_preset(s); fa_track_preset(); /* a new preset (the knob, a Program Change, a saved one): the screen stays */ @@ -2619,7 +2785,8 @@ static void fa_leds(void) #if BOARD_SMK37 { static const uint8_t Z[LED_BUF]; /* (no DRUM-grid lanes, no SCALE LEDS on FMini-1) */ - smk_leds(nl, nb, nm, Z, Z); /* the 19 button LEDs and the pads (ui_input.c) */ + smk_leds(nl, nb, nm, Z, Z); /* the 19 button LEDs (ui_input.c) */ + fa_smk_pads(); /* the pads: the picker or the SEQ's steps */ } #else for (k = 0; k < FM1_NCOL; k++) { diff --git a/firmware/src/main.c b/firmware/src/main.c index 3836c95..a2e1dbd 100644 --- a/firmware/src/main.c +++ b/firmware/src/main.c @@ -92,6 +92,10 @@ static void smk_faders(void) { static uint8_t last[4] = {0xFF, 0xFF, 0xFF, 0xFF}; uint32_t i; +#if FELUCCA_FMINI_ONLY + fa_smk_faders(); /* FMini-1: the faders set the A.ENV / F.ENV / MIX knobs */ + return; +#endif if (smk_fbank_new) { /* a new bank: wait for each fader to move */ smk_fbank_new = 0; for (i = 0; i < 4u; i++) diff --git a/firmware/src/panel.c b/firmware/src/panel.c index 854683d..1282f5c 100644 --- a/firmware/src/panel.c +++ b/firmware/src/panel.c @@ -20,7 +20,8 @@ static const char *const E_NAME[NE] = {"SELECT", "ALGORITHM", "PRESETS", "KNOB 1 #define FM1_NENC 7u #endif #if BOARD_SMK37 -#define PANEL_MAGIC 0x504E5334u /* "PNS4" (SMK-37 Pro): bump when PANEL_DEFAULT changes */ +#define PANEL_MAGIC 0x464E5331u /* "FNS1" (FMini-1 on the SMK-37: K2 PRESETS, K3 SELECT, K4 ALGORITHM): bump when + * PANEL_DEFAULT changes */ #else #define PANEL_MAGIC 0x50414E35u /* "PAN5": bump when PANEL_DEFAULT changes */ #endif @@ -38,12 +39,12 @@ panel_t panel __attribute__((section(".noinit"))); * FX = FX, SCALE = SEL, CHORD = ENV, NOTE REPEAT = LFO, PARA = EDIT, GLOBE = GLO, PATCH = HOME, BT = SAVE, * ARP, SEQ as printed, SEQ PLAY = PLAY, SEQ REC = REC, OCTAVE- / + as printed. KNOB BANK (the menu), FADER BANK, * < and > (pages) keep SMK functions (ui_input.c). Knobs as the FM-1's top row: K1 = MASTER (smk_input.h: the FM-1's MASTER pot, as a virtual one), - * K2 = SELECT, K3 = ALGORITHM (track), K4 = PRESETS; K5..K8 = KNOB 1..4 (the screen's four dials). + * FMini-1 (the owner's order): K2 = PRESETS, K3 = SELECT, K4 = ALGORITHM; K5..K8 = KNOB 1..4 (the screen's four dials). * HARDWARE CALIBRATION (OCT- + OCT+ at power-on) re-teaches all of it. */ static const panel_t PANEL_DEFAULT = { PANEL_MAGIC, {14, 8, 9, 7, 13, 10, 12, 11, 6, 15, 16, 17, 4, 5}, - {1, 2, 3, 4, 5, 6, 7}, + {2, 3, 1, 4, 5, 6, 7}, /* SELECT = K3, ALGORITHM = K4, PRESETS = K2 (encoders 2, 3, 1) */ {1, 1, 1, 1, 1, 1, 1}, }; #else diff --git a/web/make_fmini_installer.py b/web/make_fmini_installer.py index 08fad50..19a987e 100644 --- a/web/make_fmini_installer.py +++ b/web/make_fmini_installer.py @@ -22,7 +22,14 @@ def main(pkg, out, version="1.4.2"): 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() - meta = json.dumps({"version": version, "product": product, "pkg": url}) + 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] @@ -33,7 +40,8 @@ def main(pkg, out, version="1.4.2"): html = html.replace("/*LIB*/", lib).replace("/*META*/", meta).replace("/*HERO*/", hero) html = html.replace('v1.1.0', f'v{version}', 1) Path(out).write_text(html, encoding="utf-8") - print(f"{out}: {len(html)} B, {product}, package {len(raw)} B embedded") + 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__": diff --git a/web/site_fmini.html b/web/site_fmini.html index 61b2f1a..b667591 100644 --- a/web/site_fmini.html +++ b/web/site_fmini.html @@ -388,6 +388,7 @@

+

@@ -421,6 +422,7 @@ const TEXT = { pt: { intro: "Conecte o FM-1 por USB. (Funciona no Chrome ou no Edge.)", compat: "Compatível com as novas versões do FM-1 (com o chip de flash UC25HQ80).", + smk: "M-Vave SMK-37 (Pro, Elite, MKE-P37; beta): o instalador reconhece o modelo conectado e grava o pacote dele. Faça antes um backup completo da flash.", warn: "Não desconecte o cabo USB durante a gravação.", install: "Instalar", other: "English", fw_pick: "Instalar outro firmware (.fwsc)…", fw_bad: "Este arquivo não é um firmware FM-1 válido.", @@ -455,6 +457,7 @@ const TEXT = { en: { intro: "Connect the FM-1 by USB. (Works in Chrome or Edge.)", compat: "Supports the new FM-1 versions (with the UC25HQ80 flash chip).", + smk: "M-Vave SMK-37 (Pro, Elite, MKE-P37; beta): the installer recognises the connected model and writes its package. Make a full flash backup first.", warn: "Do not unplug the USB cable while writing.", install: "Install", other: "Português", fw_pick: "Install another firmware (.fwsc)…", fw_bad: "This file is not a valid FM-1 firmware.", @@ -693,9 +696,29 @@ function stopCrawl() { if (crawl) clearInterval(crawl); crawl = null; } let image = null; const meta = /*META*/; let product = meta.product; /* the package to install: the site's, or one chosen below */ +let picked = false; /* a .fwsc the player chose: installed as it is (no board choice) */ +/* the board's package: the connected device's model picks the site's FM-1 package or one of meta.boards (the SMK-37 + * Pro, Elite, MKE-P37 packages, when the page carries them); none: the FM-1's (install() then names the model) */ +async function chooseBoard(up) { + if (picked || !meta.boards || !meta.boards.length) return; + const dev = await up.find(() => true); + if (!dev) return; + dev.link.close(); + const want = (p) => sameModel(dev.id.model, p.split("_")[0]); + const hit = want(meta.product) ? null : meta.boards.find((b) => want(b.product)); + const use = hit || { product: meta.product, pkg: meta.pkg }; + if (use.product === product && image) return; + const r = await fetch(use.pkg); + const pkg = new Uint8Array(await r.arrayBuffer()); + if (productOf(pkg) !== use.product) throw Object.assign(new Error("package"), { code: "badpkg" }); + image = logicalImage(pkg); + product = use.product; + log(`board: ${dev.id.text} -> ${product}`); +} document.querySelectorAll(".curver").forEach((e) => { e.textContent = "v" + meta.version; }); document.querySelectorAll(".curver-b").forEach((e) => { e.textContent = "(v" + meta.version + ")"; }); { const dl = document.getElementById("fwdl"); if (dl) { dl.href = meta.pkg; dl.download = "FMini-1-" + meta.version + ".fwsc"; } } +{ const n = document.getElementById("smknote"); if (n) n.hidden = !(meta.boards && meta.boards.length); } let writing = false; let wake = null; @@ -761,6 +784,7 @@ async function runInstall(portName) { if (k === "reboot") { stopCrawl(); sayK("reboot"); setBar(100, "reboot"); } if (k === "done") { stopCrawl(); setBar(100, "done"); sayK("done"); } }; + await chooseBoard(up); const ota = await up.find((id) => /^ota-/i.test(id.model)); if (ota) { ota.link.close(); @@ -800,6 +824,7 @@ $("fwfile").addEventListener("change", async (e) => { if (!/^FM-1_9\d\d$/.test(prod) || !hasMarker(pkg)) { sayK("fw_bad"); $("go").disabled = true; image = null; return; } image = logicalImage(pkg); product = prod; + picked = true; say(`${file.name} (${prod})`); $("go").disabled = false; setBar(0, null);