Skip to content

Discussion Point: Unify Multiple .ino Variants Into a Single Entry File + Hardware Config System #37

@chrisdebian

Description

@chrisdebian

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:

  1. Extracting pin assignments and hardware-differing constants from existing .ino files into small per-variant config headers.

  2. Bringing shared logic into common .cpp/.h files step-by-step.

  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions