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

+27 -7
View File
@@ -53,7 +53,7 @@ def test_scene_colours_are_stored_on_the_note_36_pads():
}
def test_xchc_colours_are_stored_on_pad_bank_2():
def test_xchc_colours_are_stored_on_page_7_for_pad_bank_2():
writes = colours.colour_writes(bank=2, colours=colours.xchc_colours())
first = [item for item in writes if item[1] < colours.BANKS[1]]
assert [name for name, _addr, _rgb in first] == [
@@ -74,13 +74,13 @@ def test_xchc_colours_are_stored_on_pad_bank_2():
"",
"",
]
assert first[0][1:] == (1464, bytes.fromhex("f00000"))
assert first[1][1:] == (1490, bytes.fromhex("f07800"))
assert first[6][1:] == (1464 + 6 * 26, bytes.fromhex("7800f0"))
assert first[8][1:] == (1464 + 8 * 26, bytes.fromhex("f0f0f0"))
assert first[9][1:] == (1464 + 9 * 26, b"\x00\x00\x00")
assert first[0][1:] == (3128, bytes.fromhex("f00000"))
assert first[1][1:] == (3154, bytes.fromhex("f07800"))
assert first[6][1:] == (3128 + 6 * 26, bytes.fromhex("7800f0"))
assert first[8][1:] == (3128 + 8 * 26, bytes.fromhex("f0f0f0"))
assert first[9][1:] == (3128 + 9 * 26, b"\x00\x00\x00")
assert {address for name, address, _rgb in writes if name == "Red"} == {
base + 16 * 26 + 4 for base in colours.BANKS
base + 5 * 16 * 26 + 4 for base in colours.BANKS
}
@@ -99,3 +99,23 @@ def test_private_port_is_not_the_master_or_qlc():
"qlcplus:__QLC__ 128:0",
]
assert colours.private_port(names) == "SINCO:SINCO SMC-PAD-Private 20:0"
def test_identify_lights_each_page_in_its_own_colour():
factory = (ROOT / "tests" / "data" / "smc_pad_factory.bin").read_bytes()
image = colours.identify_image(factory)
preset = colours.preset
assert len(image) == len(factory)
for number in range(preset.PRESET_COUNT):
for index in range(preset.PAD_COUNT):
at = preset.colour_offset(number, index)
_name, red, green, blue = colours.PAGE_COLOURS[index // preset.PAGE_LEN]
assert image[at:at + 3] == bytes(map(colours.scale, (red, green, blue)))
changed = {at for at in range(len(image)) if image[at] != factory[at]}
lamps = {
preset.colour_offset(number, index) + step
for number in range(preset.PRESET_COUNT)
for index in range(preset.PAD_COUNT)
for step in range(3)
}
assert changed <= lamps
+27
View File
@@ -169,3 +169,30 @@ def test_factory_image_reads_as_midisuite_shows_it():
# Knob 6: CC, Channel 1, CC 35, 0–127.
knob6 = first["knobs"][5]
assert (knob6["type"], knob6["channel"], knob6["number"], knob6["left"], knob6["right"]) == (0, 1, 35, 0, 127)
def test_factory_document_packs_back_to_the_midisuite_image():
from pathlib import Path
from padeditor.preset import pack
from padeditor.server import Editor
document = Editor().factory()
assert pack(document) == (Path(__file__).parents[1] / "padeditor" / "factory.bin").read_bytes()
assert document["global"]["raw"] == "780032040000020001010000"
def test_global_bank_byte_round_trips_and_is_checked():
import pytest
from padeditor.preset import PresetError, pack_global, unpack_global
raw = bytes.fromhex("780032040000020001010001")
block = unpack_global(raw)
assert block["bank"] == 1
assert pack_global(block) == raw
block["bank"] = 0
assert pack_global(block)[11] == 0
block["bank"] = 2
with pytest.raises(PresetError):
pack_global(block)