Skip to content

Suku sysex and rtm rx - #304

Merged
SukuWc merged 11 commits into
masterfrom
SUKU-sysex-and-rtm-rx
Jan 20, 2026
Merged

SukuWc merged 11 commits into
masterfrom
SUKU-sysex-and-rtm-rx

Conversation

@SukuWc

@SukuWc SukuWc commented Jan 13, 2026

Copy link
Copy Markdown
Member

No description provided.

SukuWc and others added 4 commits January 8, 2026 15:19
Adds state machine to properly handle USB MIDI SysEx and Real-Time
Messages. Platform code simplified to pass raw USB packets to common
state machine in grid_usb.c.

Key changes:
- Three separate RX buffers: normal MIDI, SysEx (raw bytes), RTM (raw bytes)
- State machine handles SysEx assembly with direct SWSR writes
- RTM messages processed immediately, even during SysEx reception
- Enums added for USB MIDI CIN codes and MIDI message types
- All magic numbers replaced with descriptive enum values
- grid_midi_rx_push() signature changed to accept raw USB packet bytes

Platform updates:
- ESP32 and SAMD51 code simplified to pass raw USB MIDI packets
- Single implementation shared across all platforms

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Extracts helper functions to improve readability and maintainability:
- grid_midi_rx_push_rtm() - Handle Real-Time Messages
- grid_midi_rx_push_sysex() - Handle SysEx with switch statement
- grid_midi_should_filter_sync() - Sync message filtering logic
- grid_midi_rx_push_normal() - Handle normal MIDI messages

Main function reduced from ~20 decision points to 4-5, making it easier
to understand and maintain. Each helper has a single, clear responsibility.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…ling

Fixed two critical issues in grid_midi_sysex_process_complete:
- Calculate payload offset correctly: msg.offset + GRID_CLASS_MIDISYSEX_PAYLOAD_offset + i*2
- Update msg.length after writing payload to prevent frame_end from overwriting data

Added debug print statements for monitoring MIDI message flow.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…eter_raw

Changed from grid_msg_set_parameter to grid_msg_set_parameter_raw for setting
BRC_SX and BRC_SY in both grid_midi_rx_pop and grid_midi_sysex_process_complete.

After grid_msg_init_brc, msg.offset points past the header, so grid_msg_set_parameter
writes to the wrong location. grid_msg_set_parameter_raw writes at absolute positions,
which is required for header fields.

This fixes the sysex decoder rejection where sx==sy==DEFAULT_POSITION (127) instead
of GLOBAL_POSITION (0), allowing sysexrx_cb to trigger correctly on modules.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@benblaise-intech
benblaise-intech changed the base branch from master to test-ci January 14, 2026 14:15
@benblaise-intech
benblaise-intech changed the base branch from test-ci to master January 14, 2026 14:15
@benblaise-intech
benblaise-intech changed the base branch from master to test-ci January 14, 2026 14:22
@benblaise-intech
benblaise-intech changed the base branch from test-ci to master January 14, 2026 14:23
@SukuWc
SukuWc merged commit 3549107 into master Jan 20, 2026
9 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Firmware Roadmap Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant