Make enums into implicit char

This commit is contained in:
Scott Lahteine 2018-03-06 22:35:22 -06:00
parent e28e3bb532
commit 2057177184
22 changed files with 53 additions and 53 deletions

View File

@ -73,7 +73,7 @@ extern "C" {
//! \name Programmable Clock Sources (PCK)
//@{
enum genclk_source {
enum genclk_source : char {
GENCLK_PCK_SRC_SLCK_RC = 0, //!< Internal 32kHz RC oscillator as PCK source clock
GENCLK_PCK_SRC_SLCK_XTAL = 1, //!< External 32kHz crystal oscillator as PCK source clock
GENCLK_PCK_SRC_SLCK_BYPASS = 2, //!< External 32kHz bypass oscillator as PCK source clock
@ -92,7 +92,7 @@ enum genclk_source {
//! \name Programmable Clock Prescalers (PCK)
//@{
enum genclk_divider {
enum genclk_divider : char {
GENCLK_PCK_PRES_1 = PMC_PCK_PRES_CLK_1, //!< Set PCK clock prescaler to 1
GENCLK_PCK_PRES_2 = PMC_PCK_PRES_CLK_2, //!< Set PCK clock prescaler to 2
GENCLK_PCK_PRES_4 = PMC_PCK_PRES_CLK_4, //!< Set PCK clock prescaler to 4

View File

@ -76,7 +76,7 @@ extern "C" {
#define PLL_COUNT 0x3fU
enum pll_source {
enum pll_source : char {
PLL_SRC_MAINCK_4M_RC = OSC_MAINCK_4M_RC, //!< Internal 4MHz RC oscillator.
PLL_SRC_MAINCK_8M_RC = OSC_MAINCK_8M_RC, //!< Internal 8MHz RC oscillator.
PLL_SRC_MAINCK_12M_RC = OSC_MAINCK_12M_RC, //!< Internal 12MHz RC oscillator.

View File

@ -80,7 +80,7 @@
//! \name SBC-2 Mode page definitions
//@{
enum scsi_sbc_mode {
enum scsi_sbc_mode : char {
SCSI_MS_MODE_RW_ERR_RECOV = 0x01, //!< Read-Write Error Recovery mode page
SCSI_MS_MODE_FORMAT_DEVICE = 0x03, //!< Format Device mode page
SCSI_MS_MODE_FLEXIBLE_DISK = 0x05, //!< Flexible Disk mode page

View File

@ -184,7 +184,7 @@ struct scsi_request_sense_data {
COMPILER_PACK_RESET()
/* Vital Product Data page codes */
enum scsi_vpd_page_code {
enum scsi_vpd_page_code : char {
SCSI_VPD_SUPPORTED_PAGES = 0x00,
SCSI_VPD_UNIT_SERIAL_NUMBER = 0x80,
SCSI_VPD_DEVICE_IDENTIFICATION = 0x83,
@ -202,7 +202,7 @@ enum scsi_vpd_page_code {
/* Sense keys */
enum scsi_sense_key {
enum scsi_sense_key : char {
SCSI_SK_NO_SENSE = 0x0,
SCSI_SK_RECOVERED_ERROR = 0x1,
SCSI_SK_NOT_READY = 0x2,
@ -220,7 +220,7 @@ enum scsi_sense_key {
};
/* Additional Sense Code / Additional Sense Code Qualifier pairs */
enum scsi_asc_ascq {
enum scsi_asc_ascq : char {
SCSI_ASC_NO_ADDITIONAL_SENSE_INFO = 0x0000,
SCSI_ASC_LU_NOT_READY_REBUILD_IN_PROGRESS = 0x0405,
SCSI_ASC_WRITE_ERROR = 0x0c00,
@ -239,7 +239,7 @@ enum scsi_asc_ascq {
* used with MODE SELECT and MODE SENSE commands
* that are applicable to all SCSI devices.
*/
enum scsi_spc_mode {
enum scsi_spc_mode : char {
SCSI_MS_MODE_VENDOR_SPEC = 0x00,
SCSI_MS_MODE_INFEXP = 0x1C, // Informational exceptions control page
SCSI_MS_MODE_ALL = 0x3f,
@ -273,7 +273,7 @@ struct spc_control_page_info_execpt {
};
enum scsi_spc_mode_sense_pc {
enum scsi_spc_mode_sense_pc : char {
SCSI_MS_SENSE_PC_CURRENT = 0,
SCSI_MS_SENSE_PC_CHANGEABLE = 1,
SCSI_MS_SENSE_PC_DEFAULT = 2,

View File

@ -107,7 +107,7 @@
/**
* \brief Standard USB requests (bRequest)
*/
enum usb_reqid {
enum usb_reqid : char {
USB_REQ_GET_STATUS = 0,
USB_REQ_CLEAR_FEATURE = 1,
USB_REQ_SET_FEATURE = 3,
@ -125,7 +125,7 @@ enum usb_reqid {
* \brief Standard USB device status flags
*
*/
enum usb_device_status {
enum usb_device_status : char {
USB_DEV_STATUS_BUS_POWERED = 0,
USB_DEV_STATUS_SELF_POWERED = 1,
USB_DEV_STATUS_REMOTEWAKEUP = 2
@ -135,7 +135,7 @@ enum usb_device_status {
* \brief Standard USB Interface status flags
*
*/
enum usb_interface_status {
enum usb_interface_status : char {
USB_IFACE_STATUS_RESERVED = 0
};
@ -143,7 +143,7 @@ enum usb_interface_status {
* \brief Standard USB endpoint status flags
*
*/
enum usb_endpoint_status {
enum usb_endpoint_status : char {
USB_EP_STATUS_HALTED = 1,
};
@ -152,7 +152,7 @@ enum usb_endpoint_status {
*
* \note valid for SetFeature request.
*/
enum usb_device_feature {
enum usb_device_feature : char {
USB_DEV_FEATURE_REMOTE_WAKEUP = 1, //!< Remote wakeup enabled
USB_DEV_FEATURE_TEST_MODE = 2, //!< USB test mode
USB_DEV_FEATURE_OTG_B_HNP_ENABLE = 3,
@ -165,7 +165,7 @@ enum usb_device_feature {
*
* \note valid for USB_DEV_FEATURE_TEST_MODE request.
*/
enum usb_device_hs_test_mode {
enum usb_device_hs_test_mode : char {
USB_DEV_TEST_MODE_J = 1,
USB_DEV_TEST_MODE_K = 2,
USB_DEV_TEST_MODE_SE0_NAK = 3,
@ -176,14 +176,14 @@ enum usb_device_hs_test_mode {
/**
* \brief Standard USB endpoint feature/status flags
*/
enum usb_endpoint_feature {
enum usb_endpoint_feature : char {
USB_EP_FEATURE_HALT = 0,
};
/**
* \brief Standard USB Test Mode Selectors
*/
enum usb_test_mode_selector {
enum usb_test_mode_selector : char {
USB_TEST_J = 0x01,
USB_TEST_K = 0x02,
USB_TEST_SE0_NAK = 0x03,
@ -194,7 +194,7 @@ enum usb_test_mode_selector {
/**
* \brief Standard USB descriptor types
*/
enum usb_descriptor_type {
enum usb_descriptor_type : char {
USB_DT_DEVICE = 1,
USB_DT_CONFIGURATION = 2,
USB_DT_STRING = 3,
@ -212,7 +212,7 @@ enum usb_descriptor_type {
/**
* \brief USB Device Capability types
*/
enum usb_capability_type {
enum usb_capability_type : char {
USB_DC_USB20_EXTENSION = 0x02,
};
@ -220,7 +220,7 @@ enum usb_capability_type {
* \brief USB Device Capability - USB 2.0 Extension
* To fill bmAttributes field of usb_capa_ext_desc_t structure.
*/
enum usb_capability_extension_attr {
enum usb_capability_extension_attr : char {
USB_DC_EXT_LPM = 0x00000002,
};
@ -253,7 +253,7 @@ enum usb_capability_extension_attr {
/**
* \brief Standard USB endpoint transfer types
*/
enum usb_ep_type {
enum usb_ep_type : char {
USB_EP_TYPE_CONTROL = 0x00,
USB_EP_TYPE_ISOCHRONOUS = 0x01,
USB_EP_TYPE_BULK = 0x02,
@ -264,7 +264,7 @@ enum usb_ep_type {
/**
* \brief Standard USB language IDs for string descriptors
*/
enum usb_langid {
enum usb_langid : char {
USB_LANGID_EN_US = 0x0409, //!< English (United States)
};

View File

@ -239,13 +239,13 @@ typedef struct {
uint8_t bDataBits;
} usb_cdc_line_coding_t;
//! Possible values of bCharFormat
enum cdc_char_format {
enum cdc_char_format : char {
CDC_STOP_BITS_1 = 0, //!< 1 stop bit
CDC_STOP_BITS_1_5 = 1, //!< 1.5 stop bits
CDC_STOP_BITS_2 = 2, //!< 2 stop bits
};
//! Possible values of bParityType
enum cdc_parity {
enum cdc_parity : char {
CDC_PAR_NONE = 0, //!< No parity
CDC_PAR_ODD = 1, //!< Odd parity
CDC_PAR_EVEN = 2, //!< Even parity

View File

@ -93,9 +93,9 @@
/**
* \brief MSC USB requests (bRequest)
*/
enum usb_reqid_msc {
enum usb_reqid_msc : unsigned char {
USB_REQ_MSC_BULK_RESET = 0xFF, //!< Mass Storage Reset
USB_REQ_MSC_GET_MAX_LUN = 0xFE, //!< Get Max LUN
USB_REQ_MSC_GET_MAX_LUN = 0xFE //!< Get Max LUN
};

View File

@ -87,7 +87,7 @@ uint8 adc_pins[] = {
#endif
};
enum TEMP_PINS {
enum TEMP_PINS : char {
#if HAS_TEMP_0
TEMP_0,
#endif

View File

@ -31,8 +31,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,
@ -43,7 +42,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++)
@ -73,12 +73,12 @@ typedef enum {
/**
* 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,

View File

@ -32,7 +32,7 @@
/**
* Define debug bit-masks
*/
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
@ -45,7 +45,7 @@ enum DebugFlags {
};
#if ENABLED(EMERGENCY_PARSER)
enum e_parser_state {
enum e_parser_state : char {
state_RESET,
state_N,
state_M,

View File

@ -25,7 +25,7 @@
#include "../../../inc/MarlinConfig.h"
enum MeshLevelingState {
enum MeshLevelingState : char {
MeshReport,
MeshStart,
MeshNext,

View File

@ -47,7 +47,7 @@
// ubl_G29.cpp
enum MeshPointType { INVALID, REAL, SET_IN_BITMAP };
enum MeshPointType : char { INVALID, REAL, SET_IN_BITMAP };
// External references

View File

@ -32,13 +32,13 @@
#include "../inc/MarlinConfigPre.h"
enum AdvancedPauseMode {
enum AdvancedPauseMode : char {
ADVANCED_PAUSE_MODE_PAUSE_PRINT,
ADVANCED_PAUSE_MODE_LOAD_FILAMENT,
ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT
};
enum AdvancedPauseMessage {
enum AdvancedPauseMessage : char {
ADVANCED_PAUSE_MESSAGE_INIT,
ADVANCED_PAUSE_MESSAGE_UNLOAD,
ADVANCED_PAUSE_MESSAGE_INSERT,
@ -51,7 +51,7 @@ enum AdvancedPauseMessage {
ADVANCED_PAUSE_MESSAGE_WAIT_FOR_NOZZLES_TO_HEAT
};
enum AdvancedPauseMenuResponse {
enum AdvancedPauseMenuResponse : char {
ADVANCED_PAUSE_RESPONSE_WAIT_FOR,
ADVANCED_PAUSE_RESPONSE_EXTRUDE_MORE,
ADVANCED_PAUSE_RESPONSE_RESUME_PRINT

View File

@ -253,7 +253,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,
@ -277,7 +277,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,

View File

@ -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);

View File

@ -43,7 +43,7 @@
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,

View File

@ -267,7 +267,7 @@ public:
* Workspace planes only apply to G2/G3 moves
* (and "canned cycles" - not a current feature)
*/
enum WorkspacePlane { PLANE_XY, PLANE_ZX, PLANE_YZ };
enum WorkspacePlane : char { PLANE_XY, PLANE_ZX, PLANE_YZ };
static WorkspacePlane workspace_plane;
#endif
@ -304,7 +304,7 @@ public:
* States for managing Marlin and host communication
* Marlin sends messages if blocked or busy
*/
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)

View File

@ -36,7 +36,7 @@
*/
class Stopwatch {
private:
enum State {
enum State : char {
STOPPED,
RUNNING,
PAUSED

View File

@ -30,7 +30,7 @@
#include "../inc/MarlinConfig.h"
#include <stdint.h>
enum EndstopEnum {
enum EndstopEnum : char {
X_MIN,
Y_MIN,
Z_MIN,

View File

@ -288,7 +288,7 @@ void homeaxis(const AxisEnum axis);
*/
#if ENABLED(DUAL_X_CARRIAGE)
enum DualXMode {
enum DualXMode : char {
DXC_FULL_CONTROL_MODE, // DUAL_X_CARRIAGE only
DXC_AUTO_PARK_MODE, // DUAL_X_CARRIAGE only
DXC_DUPLICATION_MODE
@ -308,7 +308,7 @@ void homeaxis(const AxisEnum axis);
#elif ENABLED(DUAL_NOZZLE_DUPLICATION_MODE)
enum DualXMode {
enum DualXMode : char {
DXC_DUPLICATION_MODE = 2
};

View File

@ -44,7 +44,7 @@
#include "../libs/vector_3.h"
#endif
enum BlockFlagBit {
enum BlockFlagBit : char {
// Recalculate trapezoids on entry junction. For optimization.
BLOCK_BIT_RECALCULATE,
@ -60,7 +60,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),

View File

@ -49,7 +49,7 @@
/**
* States for ADC reading in the ISR
*/
enum ADCSensorState {
enum ADCSensorState : char {
#if HAS_TEMP_0
PrepareTemp_0,
MeasureTemp_0,
@ -610,7 +610,7 @@ class Temperature {
#if ENABLED(THERMAL_PROTECTION_HOTENDS) || HAS_THERMALLY_PROTECTED_BED
typedef enum TRState { TRInactive, TRFirstHeating, TRStable, TRRunaway } TRstate;
typedef enum TRState : char { TRInactive, TRFirstHeating, TRStable, TRRunaway } TRstate;
static void thermal_runaway_protection(TRState * const state, millis_t * const timer, const float &current, const float &target, const int8_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc);