Skip to content

Refactor: reduce repetition and clarify non-obvious code#72

Merged
thePunderWoman merged 1 commit intomainfrom
refactor/cleanup-pass
Apr 29, 2026
Merged

Refactor: reduce repetition and clarify non-obvious code#72
thePunderWoman merged 1 commit intomainfrom
refactor/cleanup-pass

Conversation

@thePunderWoman
Copy link
Copy Markdown
Owner

Summary

  • drive_controllers.cpp — Four 7-line switch blocks that mapped a button number to a PS3 button field have been replaced with DRIVE_BTNFIELD / DOME_BTNFIELD macros, consistent with the existing DISPATCH_BUTTON macro style in the same file
  • buttons.cpp / console.hprocessButton, processLongButton, and processAltButton were structurally identical; extracted processButtonLayer(num, label, actions) and kept the three public methods as one-line wrappers
  • audio.cpp / audio.h — The three-line SetVolume(CH_V…) SetVolume(CH_A…) SetVolume(CH_B…) pattern appeared in applyHCRVolume, restoreVolumes, and toggleMute; extracted sendAllHCRVolumes(v, a, b)
  • config.cpp — Seven consecutive else-if blocks each calling applyDomePositionParams() collapsed into one chained || expression, matching the pattern already used elsewhere in processConfig
  • audio.h — One-line comment explaining the unsigned-wraparound trick on fLastVolumeUpdate initialisation

No behaviour changes. Net: −105 lines / +56 lines.

Test plan

  • pio test -e native — 448/448 pass
  • pio run — firmware builds clean

🤖 Generated with Claude Code

- drive_controllers: replace 4 repeated button-number switch blocks with
  DRIVE_BTNFIELD/DOME_BTNFIELD macros, consistent with existing macro style
- buttons: extract processButtonLayer() helper; processButton/Long/Alt
  become one-line wrappers instead of three identical copies
- audio: extract sendAllHCRVolumes(v,a,b); used in applyHCRVolume,
  restoreVolumes, and toggleMute
- config: collapse 7 identical dome-seek else-if blocks (each calling
  applyDomePositionParams) into one chained || expression
- audio.h: comment the unsigned-wraparound trick on fLastVolumeUpdate init

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@thePunderWoman thePunderWoman merged commit 3b2e063 into main Apr 29, 2026
1 check passed
@thePunderWoman thePunderWoman deleted the refactor/cleanup-pass branch April 29, 2026 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant