Skip to content

Refactor: extract duplicated JSON parsing helpers from DisplayManager#799

Open
blade-running-man wants to merge 1 commit intoBlueforcer:mainfrom
blade-running-man:refactor/extract-json-helpers
Open

Refactor: extract duplicated JSON parsing helpers from DisplayManager#799
blade-running-man wants to merge 1 commit intoBlueforcer:mainfrom
blade-running-man:refactor/extract-json-helpers

Conversation

@blade-running-man
Copy link

Extract 4 helper functions into Functions.h/.cpp to eliminate duplicated JSON parsing blocks across DisplayManager.cpp.

Helpers added

Helper Replaces Blocks removed
getColorField() 8-line if/else color parsing with default 7
parseGradient() 14-line gradient array parsing 2
parseBarLineData() ~50-line bar/line chart parsing with autoscale 2
parseCRGB() ~24-line CRGB hex/RGB parsing 2

Impact

  • -254 lines removed from DisplayManager.cpp
  • +128 lines added (helpers + documentation)
  • Net: -126 lines
  • No behavior changes — pure mechanical extract

Why

The same JSON parsing blocks were copy-pasted between generateCustomPage(), generateNotification(), and setNewSettings(). A bug fix or format change (e.g. adding HSL support) would require updating 2-7 identical blocks instead of one.

Extract 4 helper functions into Functions.h/.cpp to eliminate repeated JSON parsing blocks in generateCustomPage, generateNotification, and setNewSettings:
- getColorField: color parsing with default value
- parseGradient: two-color gradient parsing
- parseBarLineData: bar/line chart data with autoscale
- parseCRGB: CRGB color from hex string or RGB array
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