memlnaut-nisps/firmware/MEMLNaut-NISPS/glue/input_router.hpp

24 lines
744 B
C++
Raw Normal View History

Stream 6: extract firmware glue under firmware/ Move the Arduino sketch into firmware/MEMLNaut-NISPS/ and bridge the hardware (memllib) to the platform-agnostic nisps/ library through a slim glue layer. Delete the legacy root-level *AudioApp.hpp, modes/MEMLNautMode*.hpp, voicespaces/, IMLInterface.hpp, XiasriAnalysis, and the src/memlp submodule. Glue layout (firmware/MEMLNaut-NISPS/glue/): audio_driver.hpp - bridge memllib block callback to Mode::process via per-Mode templated trampoline (no virtual dispatch) peripherals.hpp - joystick/pots/buttons -> Mode::set_input + ML primitives midi_io.hpp - MIDI in -> mode.note_on/update_bpm/set_playing, drains mode ControlEvent ring -> MIDI UART mode_select.hpp - using-aliases mapping MEMLNautMode<Name> to nisps::modes::*Mode (build script rewrites the #define MEMLNAUT_MODE_TYPE line) input_router.hpp / output_router.hpp - top-level wire/drain entry points The sketch tree uses src/{memllib,daisysp,nisps} symlinks because Arduino-CLI rejects ".." in include paths from sketch-tree headers. mode_select.hpp #undefs Arduino's sq/min/max/abs/round macros before including nisps headers (some nisps engines use those identifiers as method names). The audio bridge struct is extern in the header and defined in the .ino because inline + __not_in_flash section attribute collide at link time. Verification: arduino-cli compile succeeds for PAFSynth, ChannelStrip, and BreakOr (rp2040:rp2040:solderparty_rp2350_stamp_xl:opt=Optimize3, -std=gnu++20). Host C++ tests under nisps/build still pass (3 binaries, 110+ tests). Build script (scripts/build-firmware.sh) updated to point at the new sketch path; mode-rewrite logic unchanged. Closes meml-gkm.
2026-04-29 16:05:38 +02:00
// firmware/glue/input_router.hpp — High-level input wiring entry point.
//
// Currently a thin re-export over `peripherals.hpp`. The intent is for this
// to grow into a schema-aware router (read mode.param_schema().input_channels
// names, look up matching hardware sources by name, attach callbacks). For
// now the trivial positional mapping in `bind_peripherals()` is sufficient
// since every existing mode's first N channels are joystick X/Y/Z(/W).
//
// Kept as its own header so growth of routing logic doesn't bloat
// peripherals.hpp.
#pragma once
#include "peripherals.hpp"
namespace nisps_firmware {
template <typename Mode>
inline void wire_inputs(Mode& mode) {
bind_peripherals(mode);
}
} // namespace nisps_firmware