-
Notifications
You must be signed in to change notification settings - Fork 42
Description
I wasn't quite sure how to write this up, so have used AI to try to make it more readable.
I noticed that there are several .ino files that serve as separate entry points for different hardware variants. This makes sense historically — each build has slightly different pinouts or UI layouts — but it also leads to duplicated logic and makes changes harder to maintain across variants.
I’d like to propose a friendly discussion about a possible improvement:
Suggestion
Consolidate the multiple .ino variant files into a single main .ino, and move hardware-specific details (pin assignments, button layouts, display type, optional features, etc.) into dedicated configuration headers.
Why this might help?
Reduce duplicated code: Right now, UI logic, DSP, menu code, and other core functions often appear in multiple variant .ino files. Unifying them means bug fixes and improvements only have to be made once.
Easier maintenance long-term: As new features are added, maintaining multiple entry points can cause drift or subtle inconsistencies.
Cleaner architecture: A small hardware-abstraction layer (HAL) or hw_config.h file per variant can centralize all pin definitions and hardware capabilities. The main firmware stays identical across all builds.
Simple for users: Builders only select a hardware variant by changing (or copying) one config file, instead of choosing between multiple .ino sketches.
What this could look like
A possible structure (just one idea for discussion):
/src
usdx_main.ino ← single entry point
core/ ← DSP, menus, CAT, audio, filters, etc.
hw/
variants/
config_classic.h
config_whitebuttons.h
config_xyz.h
hw_base.h ← shared interface
hw_base.cpp
Users would compile by selecting the right config file, e.g.:
#include "hw/variants/config_whitebuttons.h"
or via a compile-time flag like:
-DUSDX_HW_WHITEBUTTONS
🧩 This change can be gradual
This doesn’t require a big rewrite all at once — it could be done incrementally by:
-
Extracting pin assignments and hardware-differing constants from existing .ino files into small per-variant config headers.
-
Bringing shared logic into common .cpp/.h files step-by-step.
-
Slowly retiring the multiple .ino entry points once the unified one is stable.
The code goes beyond my understanding, but appears logical. This is just an idea, please just ignore, if it's mad.