refactor: optimize JSON generation and improve MIDI handling logic - #10
Open
tomaustin700 wants to merge 19 commits into
Open
refactor: optimize JSON generation and improve MIDI handling logic#10tomaustin700 wants to merge 19 commits into
tomaustin700 wants to merge 19 commits into
Conversation
added 19 commits
May 27, 2026 13:26
… executeSwitchLogic
- Fix naming conventions (f_name/max_characters/tempText) - Make EEPROM addresses static constexpr - Remove commented-out code and obvious comments - Remove excessive blank lines - Inline single-use variables in toggleMidiFilePlayback - Add comprehensive README with preset format docs - Add setup-local.ps1 for local build prerequisites
…d and prev-preset - Replace 3 toggle booleans with switchToggled[3] array - Extract sendPcArray/sendCcArray to deduplicate PC/CC iteration - Fix long-hold: measure actual hold duration (press→release) not time-between-presses - Fix prev-preset reloading same preset when already at 0 - Clamp CC numbers in sendControlChange (was only clamping values) - Pad trailing spaces in displayCenteredLine to clear stale characters - Remove redundant presetListCount (use presetCount directly) - Remove unused pinMode(13, OUTPUT)
- Extract pure logic functions and constants into logic.h for testability - Add test/CMakeLists.txt with Google Test v1.14.0 via FetchContent - Add test/test_logic.cpp covering all extracted functions: clampMidi, hasElapsed, extractNumber, comparePresetNames, calculateCenterPadding, calculateSwitchPadding, canNavigateNext, canNavigatePrev, adjustPcProgram, plus constants and toggle state - Update midicontroller.ino to include logic.h (removes duplicates) - Add unit-tests job to CI workflow (runs before firmware compile) - Add .gitignore for test/build/
Extract and test additional pure logic from branch changes: - validateStoredPreset / validateStoredPcProgram: EEPROM validation - toggleCcValue: refactored toggle CC value determination - computePrefetchCandidate: directional preset prefetch logic - hasJsonExtension: file filtering for preset list loading - pcJsonToMidi: 1-indexed JSON to 0-indexed MIDI conversion - formatSwitchActionMessage: null-safe UI message formatting - clampPresetIndex: preset bounds clamping in changePreset Integration tests: - Full switch toggle cycle with CC values across all switches - Reset-all after preset change - Forward/backward navigation with prefetch scenarios - Direction reversal prefetch adaptation
Verify correct MIDI output for all button-press scenarios: - Preset OnLoad: PC/CC messages sent on preset navigation - Switch press (non-toggle): CC values sent as-is from JSON - Switch press (toggle): CC overridden to 127/0 based on state - PC mode: increment/decrement with clamping, always via USB - Long-hold PC mode toggle: sends current program - Value clamping: out-of-range PC/CC values safely bounded - PC offset: 1-indexed JSON → 0-indexed MIDI verified - USB routing: defaults to false, respects explicit true/false - Channel routing: each event routed to its specified channel - Full scenarios: preset load + switch cycles, navigation, toggle reset Uses ArduinoJson v6.21.5 in test build via FetchContent and a MIDI mock layer that records messages for assertion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.