diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index b19c86a77..ff35b97ec 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -5312,7 +5312,7 @@ void home_all_axes() { gcode_G28(true); } constexpr uint8_t _7P_STEP = 1, // 7-point step - to change number of calibration points _4P_STEP = _7P_STEP * 2, // 4-point step NPP = _7P_STEP * 6; // number of calibration points on the radius - enum CalEnum { // the 7 main calibration points - add definitions if needed + enum CalEnum : char { // the 7 main calibration points - add definitions if needed CEN = 0, __A = 1, _AB = __A + _7P_STEP, diff --git a/Marlin/enum.h b/Marlin/enum.h index 13858971e..b4e7564f5 100644 --- a/Marlin/enum.h +++ b/Marlin/enum.h @@ -33,8 +33,7 @@ * - X_HEAD and Y_HEAD is used for systems that don't have a 1:1 relationship * between X_AXIS and X Head movement, like CoreXY bots */ -enum AxisEnum { - NO_AXIS = -1, +enum AxisEnum : unsigned char { X_AXIS = 0, A_AXIS = 0, Y_AXIS = 1, @@ -45,7 +44,8 @@ enum AxisEnum { X_HEAD = 4, Y_HEAD = 5, Z_HEAD = 6, - ALL_AXES = 100 + ALL_AXES = 0xFE, + NO_AXIS = 0xFF }; #define LOOP_S_LE_N(VAR, S, N) for (uint8_t VAR=S; VAR<=N; VAR++) @@ -76,7 +76,7 @@ typedef enum { * Debug flags * Not yet widely applied */ -enum DebugFlags { +enum DebugFlags : unsigned char { DEBUG_NONE = 0, DEBUG_ECHO = _BV(0), ///< Echo commands in order as they are processed DEBUG_INFO = _BV(1), ///< Print messages for code that has debug output @@ -88,7 +88,7 @@ enum DebugFlags { DEBUG_ALL = 0xFF }; -enum EndstopEnum { +enum EndstopEnum : char { X_MIN, Y_MIN, Z_MIN, @@ -105,7 +105,7 @@ enum EndstopEnum { }; #if ENABLED(EMERGENCY_PARSER) - enum e_parser_state { + enum e_parser_state : char { state_RESET, state_N, state_M, @@ -122,14 +122,14 @@ enum EndstopEnum { #endif #if ENABLED(ADVANCED_PAUSE_FEATURE) - enum AdvancedPauseMenuResponse { + enum AdvancedPauseMenuResponse : char { ADVANCED_PAUSE_RESPONSE_WAIT_FOR, ADVANCED_PAUSE_RESPONSE_EXTRUDE_MORE, ADVANCED_PAUSE_RESPONSE_RESUME_PRINT }; #if ENABLED(ULTIPANEL) - enum AdvancedPauseMessage { + enum AdvancedPauseMessage : char { ADVANCED_PAUSE_MESSAGE_INIT, ADVANCED_PAUSE_MESSAGE_UNLOAD, ADVANCED_PAUSE_MESSAGE_INSERT, @@ -143,7 +143,7 @@ enum EndstopEnum { }; #endif - enum AdvancedPauseMode { + enum AdvancedPauseMode : char { ADVANCED_PAUSE_MODE_PAUSE_PRINT, ADVANCED_PAUSE_MODE_LOAD_FILAMENT, ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT @@ -155,7 +155,7 @@ enum EndstopEnum { * Marlin sends messages if blocked or busy */ #if ENABLED(HOST_KEEPALIVE_FEATURE) - enum MarlinBusyState { + enum MarlinBusyState : char { NOT_BUSY, // Not in a handler IN_HANDLER, // Processing a GCode IN_PROCESS, // Known to be blocking command input (as in G29) @@ -167,12 +167,12 @@ enum EndstopEnum { /** * SD Card */ -enum LsAction { LS_SerialPrint, LS_Count, LS_GetFilename }; +enum LsAction : char { LS_SerialPrint, LS_Count, LS_GetFilename }; /** * Ultra LCD */ -enum LCDViewAction { +enum LCDViewAction : char { LCDVIEW_NONE, LCDVIEW_REDRAW_NOW, LCDVIEW_CALL_REDRAW_NEXT, @@ -184,7 +184,7 @@ enum LCDViewAction { * Dual X Carriage modes. A Dual Nozzle can also do duplication. */ #if ENABLED(DUAL_X_CARRIAGE) || ENABLED(DUAL_NOZZLE_DUPLICATION_MODE) - enum DualXMode { + enum DualXMode : char { DXC_FULL_CONTROL_MODE, // DUAL_X_CARRIAGE only DXC_AUTO_PARK_MODE, // DUAL_X_CARRIAGE only DXC_DUPLICATION_MODE @@ -196,7 +196,7 @@ enum LCDViewAction { * (and "canned cycles" - not a current feature) */ #if ENABLED(CNC_WORKSPACE_PLANES) - enum WorkspacePlane { PLANE_XY, PLANE_ZX, PLANE_YZ }; + enum WorkspacePlane : char { PLANE_XY, PLANE_ZX, PLANE_YZ }; #endif #endif // __ENUM_H__ diff --git a/Marlin/fastio.h b/Marlin/fastio.h index 0f7df9765..50a37ffb8 100644 --- a/Marlin/fastio.h +++ b/Marlin/fastio.h @@ -41,7 +41,6 @@ typedef int8_t pin_t; #define AVR_ATmega2561_FAMILY (defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)) #define AVR_ATmega328_FAMILY (defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega328p__)) - /** * Include Ports and Functions */ @@ -118,7 +117,7 @@ typedef int8_t pin_t; */ // Waveform Generation Modes -typedef enum { +enum WaveGenMode : char { WGM_NORMAL, // 0 WGM_PWM_PC_8, // 1 WGM_PWM_PC_9, // 2 @@ -135,18 +134,18 @@ typedef enum { WGM_reserved, // 13 WGM_FAST_PWM_ICRn, // 14 COM OCnA WGM_FAST_PWM_OCRnA // 15 COM OCnA -} WaveGenMode; +}; // Compare Modes -typedef enum { +enum CompareMode : char { COM_NORMAL, // 0 COM_TOGGLE, // 1 Non-PWM: OCnx ... Both PWM (WGM 9,11,14,15): OCnA only ... else NORMAL COM_CLEAR_SET, // 2 Non-PWM: OCnx ... Fast PWM: OCnx/Bottom ... PF-FC: OCnx Up/Down COM_SET_CLEAR // 3 Non-PWM: OCnx ... Fast PWM: OCnx/Bottom ... PF-FC: OCnx Up/Down -} CompareMode; +}; // Clock Sources -typedef enum { +enum ClockSource : char { CS_NONE, // 0 CS_PRESCALER_1, // 1 CS_PRESCALER_8, // 2 @@ -155,10 +154,10 @@ typedef enum { CS_PRESCALER_1024, // 5 CS_EXT_FALLING, // 6 CS_EXT_RISING // 7 -} ClockSource; +}; // Clock Sources (Timer 2 only) -typedef enum { +enum ClockSource2 : char { CS2_NONE, // 0 CS2_PRESCALER_1, // 1 CS2_PRESCALER_8, // 2 @@ -167,7 +166,7 @@ typedef enum { CS2_PRESCALER_128, // 5 CS2_PRESCALER_256, // 6 CS2_PRESCALER_1024 // 7 -} ClockSource2; +}; // Get interrupt bits in an orderly way #define GET_WGM(T) (((TCCR##T##A >> WGM##T##0) & 0x3) | ((TCCR##T##B >> WGM##T##2 << 2) & 0xC)) diff --git a/Marlin/mesh_bed_leveling.h b/Marlin/mesh_bed_leveling.h index 11e3150ab..f3a374af5 100644 --- a/Marlin/mesh_bed_leveling.h +++ b/Marlin/mesh_bed_leveling.h @@ -25,7 +25,7 @@ #include "MarlinConfig.h" -enum MeshLevelingState { +enum MeshLevelingState : char { MeshReport, MeshStart, MeshNext, diff --git a/Marlin/planner.h b/Marlin/planner.h index d55fa0da0..bc0a39d5e 100644 --- a/Marlin/planner.h +++ b/Marlin/planner.h @@ -40,7 +40,7 @@ #include "vector_3.h" #endif -enum BlockFlagBit { +enum BlockFlagBit : char { // Recalculate trapezoids on entry junction. For optimization. BLOCK_BIT_RECALCULATE, @@ -56,7 +56,7 @@ enum BlockFlagBit { BLOCK_BIT_CONTINUED }; -enum BlockFlag { +enum BlockFlag : char { BLOCK_FLAG_RECALCULATE = _BV(BLOCK_BIT_RECALCULATE), BLOCK_FLAG_NOMINAL_LENGTH = _BV(BLOCK_BIT_NOMINAL_LENGTH), BLOCK_FLAG_BUSY = _BV(BLOCK_BIT_BUSY), diff --git a/Marlin/stopwatch.h b/Marlin/stopwatch.h index 74eb72e8d..f5ac78bfa 100644 --- a/Marlin/stopwatch.h +++ b/Marlin/stopwatch.h @@ -36,7 +36,7 @@ */ class Stopwatch { private: - enum State { + enum State : char { STOPPED, RUNNING, PAUSED diff --git a/Marlin/temperature.h b/Marlin/temperature.h index c43776a5d..710c9c23f 100644 --- a/Marlin/temperature.h +++ b/Marlin/temperature.h @@ -56,7 +56,7 @@ /** * States for ADC reading in the ISR */ -enum ADCSensorState { +enum ADCSensorState : char { #if HAS_TEMP_0 PrepareTemp_0, MeasureTemp_0, @@ -613,7 +613,7 @@ class Temperature { #if ENABLED(THERMAL_PROTECTION_HOTENDS) || HAS_THERMALLY_PROTECTED_BED - typedef enum TRState { TRInactive, TRFirstHeating, TRStable, TRRunaway } TRstate; + enum TRState : char { TRInactive, TRFirstHeating, TRStable, TRRunaway }; static void thermal_runaway_protection(TRState * const state, millis_t * const timer, const float ¤t, const float &target, const int8_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc); diff --git a/Marlin/tmc_util.cpp b/Marlin/tmc_util.cpp index 2778d9963..9b2c35582 100644 --- a/Marlin/tmc_util.cpp +++ b/Marlin/tmc_util.cpp @@ -251,7 +251,7 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) { #if ENABLED(TMC_DEBUG) - enum TMC_debug_enum { + enum TMC_debug_enum : char { TMC_CODES, TMC_ENABLED, TMC_CURRENT, @@ -275,7 +275,7 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) { TMC_HSTRT, TMC_SGT }; - enum TMC_drv_status_enum { + enum TMC_drv_status_enum : char { TMC_DRV_CODES, TMC_STST, TMC_OLB, diff --git a/Marlin/tmc_util.h b/Marlin/tmc_util.h index aa1fb6329..acd3ff8fe 100644 --- a/Marlin/tmc_util.h +++ b/Marlin/tmc_util.h @@ -29,7 +29,7 @@ extern bool report_tmc_status; -enum TMC_AxisEnum { TMC_X, TMC_X2, TMC_Y, TMC_Y2, TMC_Z, TMC_Z2, TMC_E0, TMC_E1, TMC_E2, TMC_E3, TMC_E4 }; +enum TMC_AxisEnum : char { TMC_X, TMC_X2, TMC_Y, TMC_Y2, TMC_Z, TMC_Z2, TMC_E0, TMC_E1, TMC_E2, TMC_E3, TMC_E4 }; constexpr uint32_t _tmc_thrs(const uint16_t msteps, const int32_t thrs, const uint32_t spmm) { return 12650000UL * msteps / (256 * thrs * spmm); diff --git a/Marlin/ubl.h b/Marlin/ubl.h index 0a54c7c7a..4b0316974 100644 --- a/Marlin/ubl.h +++ b/Marlin/ubl.h @@ -50,7 +50,7 @@ // ubl_G29.cpp -enum MeshPointType { INVALID, REAL, SET_IN_BITMAP }; +enum MeshPointType : char { INVALID, REAL, SET_IN_BITMAP }; // External references