Light pad bank 2 from page 7, and add factory reset and a pad bank toggle to the editor.

Bank 2's lamp colours come from preset page 7, not page 3, so pad_colours.py
writes there and the editor labels it Bank 2. The factory reset loads the
image MidiSuite uploads for its own reset, and the bank toggle writes the
global-block byte MidiSuite uses to switch banks.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Sonnet 5.5 committed 2026-10-21 20:34:34 +13:00
1 parent 63b3129cca
commit 3992744a1d
9 files changed
+239 -113

No files matched your search

+51 -2
View File
@@ -158,6 +158,48 @@ async function importFile(file) {
}
}
function withBank(global, bank) {
const raw = global.raw.slice(0, 22) + bank.toString(16).padStart(2, "0") + global.raw.slice(24);
return { ...global, bank, raw };
}
async function switchBank(bank) {
try {
await request("/api/bank", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ bank }),
});
const wasDirty = dirty();
state.doc.global = withBank(state.doc.global, bank);
if (!wasDirty) {
const saved = JSON.parse(state.saved);
saved.global = withBank(saved.global, bank);
state.saved = JSON.stringify(saved);
}
state.page = bank ? 7 : 2;
$("page").value = String(state.page);
state.kind = state.kind === "pad" ? null : state.kind;
render();
setStatus(`Pad bank ${bank + 1}.`, "ok");
} catch (error) {
setStatus(error.message, "err");
}
}
async function factory() {
if (!window.confirm("Replace all eight presets with the factory settings? Nothing reaches the pad until you Save.")) return;
setStatus("Reading the factory preset…");
try {
state.doc = await request("/api/factory", { method: "POST" });
render();
setStatus("Factory settings loaded. Save to pad to store them.", "dirty");
} catch (error) {
setStatus(error.message, "err");
}
mark();
}
function render() {
if (!state.doc) return;
$("board").classList.add("ready");
@@ -185,6 +227,12 @@ function renderGlobal() {
for (const [label, key, min, max] of fields) {
row.append(field(label, numberInput(block, key, min, max)));
}
const toggle = document.createElement("button");
toggle.type = "button";
toggle.textContent = `Pad bank ${block.bank + 1}`;
toggle.title = "Switch the pad's bank now, as MidiSuite does";
toggle.addEventListener("click", () => switchBank(1 - block.bank));
row.append(toggle);
}
function renderPresets() {
@@ -207,8 +255,8 @@ function renderPages() {
const select = $("page");
const current = select.value;
select.replaceChildren();
const order = [2, 3, 0, 1, 4, 5, 6, 7];
const names = { 2: "Bank 1", 3: "Bank 2" };
const order = [2, 7, 0, 1, 3, 4, 5, 6];
const names = { 2: "Bank 1", 7: "Bank 2", 3: "Page 4 (not lit)" };
for (const page of order) {
const pads = preset().pads.slice(page * PAGE, page * PAGE + PAGE);
const option = document.createElement("option");
@@ -422,6 +470,7 @@ function renderInspector() {
$("load").addEventListener("click", () => load(true));
$("save").addEventListener("click", save);
$("export").addEventListener("click", exportFile);
$("factory").addEventListener("click", factory);
$("import").addEventListener("change", () => {
const file = $("import").files[0];
$("import").value = "";