Replace strcmp state checks with GcodeState enum#45
Replace strcmp state checks with GcodeState enum#45theNailz wants to merge 1 commit intoKeralots:mainfrom
Conversation
…abels Introduce GcodeState enum parsed once in MQTT handler, replacing 18 scattered strcmp() calls across 3 files with compile-time safe enum comparisons. Add gcodeStateLabel() for consistent display text. - STATE_IDLE → "Ready", STATE_RUNNING → "Running", STATE_PAUSE → "Paused" STATE_PREPARE → "Preparing", STATE_FINISH → "Finished", STATE_FAILED → "Error" - Fix inconsistent display: "PAUSED" → "Paused", "ERROR!" → "Error", "Print Complete!" → "Print complete" - Add stateLabel field to /status JSON API (backward compatible) - Deduplicate days[] and months[] arrays into shared DAYS_SHORT/MONTHS_SHORT
|
Two things I noticed in this refactoring: 1. UI labels changed silently This is arguably an improvement, but it's a user-visible behavior change bundled into what reads as a pure refactoring. In particular, the exclamation mark on 2. Day/month arrays in bambu_state.h |
Summary
GcodeStateenum parsed once in MQTT handler, replacing 18strcmp()calls across 3 files with compile-time safe enum comparisonsgcodeStateLabel()for consistent human-readable display text: "Ready", "Running", "Paused", "Preparing", "Finished", "Error"stateLabelfield to/statusJSON API (backward compatible —statestill returns raw MQTT value)days[]andmonths[]arrays into sharedDAYS_SHORT/MONTHS_SHORTconstantsTest plan