瀏覽代碼

Merge pull request #9974 from thinkyhead/bf2_tmc_util_progmem

[2.0.x] Move tmc_util.* extended_axis_codes to PROGMEM
Scott Lahteine 7 年之前
父節點
當前提交
920d92aa46
沒有連結到貢獻者的電子郵件帳戶。

+ 2
- 2
Marlin/src/HAL/HAL_DUE/usb/genclk.h 查看文件

73
 //! \name Programmable Clock Sources (PCK)
73
 //! \name Programmable Clock Sources (PCK)
74
 //@{
74
 //@{
75
 
75
 
76
-enum genclk_source {
76
+enum genclk_source : char {
77
 	GENCLK_PCK_SRC_SLCK_RC       = 0, //!< Internal 32kHz RC oscillator as PCK source clock
77
 	GENCLK_PCK_SRC_SLCK_RC       = 0, //!< Internal 32kHz RC oscillator as PCK source clock
78
 	GENCLK_PCK_SRC_SLCK_XTAL     = 1, //!< External 32kHz crystal oscillator as PCK source clock
78
 	GENCLK_PCK_SRC_SLCK_XTAL     = 1, //!< External 32kHz crystal oscillator as PCK source clock
79
 	GENCLK_PCK_SRC_SLCK_BYPASS   = 2, //!< External 32kHz bypass oscillator as PCK source clock
79
 	GENCLK_PCK_SRC_SLCK_BYPASS   = 2, //!< External 32kHz bypass oscillator as PCK source clock
92
 //! \name Programmable Clock Prescalers (PCK)
92
 //! \name Programmable Clock Prescalers (PCK)
93
 //@{
93
 //@{
94
 
94
 
95
-enum genclk_divider {
95
+enum genclk_divider : char {
96
 	GENCLK_PCK_PRES_1  = PMC_PCK_PRES_CLK_1, //!< Set PCK clock prescaler to 1
96
 	GENCLK_PCK_PRES_1  = PMC_PCK_PRES_CLK_1, //!< Set PCK clock prescaler to 1
97
 	GENCLK_PCK_PRES_2  = PMC_PCK_PRES_CLK_2, //!< Set PCK clock prescaler to 2
97
 	GENCLK_PCK_PRES_2  = PMC_PCK_PRES_CLK_2, //!< Set PCK clock prescaler to 2
98
 	GENCLK_PCK_PRES_4  = PMC_PCK_PRES_CLK_4, //!< Set PCK clock prescaler to 4
98
 	GENCLK_PCK_PRES_4  = PMC_PCK_PRES_CLK_4, //!< Set PCK clock prescaler to 4

+ 1
- 1
Marlin/src/HAL/HAL_DUE/usb/pll.h 查看文件

76
 
76
 
77
 #define PLL_COUNT           0x3fU
77
 #define PLL_COUNT           0x3fU
78
 
78
 
79
-enum pll_source {
79
+enum pll_source : char {
80
 	PLL_SRC_MAINCK_4M_RC        = OSC_MAINCK_4M_RC,     //!< Internal 4MHz RC oscillator.
80
 	PLL_SRC_MAINCK_4M_RC        = OSC_MAINCK_4M_RC,     //!< Internal 4MHz RC oscillator.
81
 	PLL_SRC_MAINCK_8M_RC        = OSC_MAINCK_8M_RC,     //!< Internal 8MHz RC oscillator.
81
 	PLL_SRC_MAINCK_8M_RC        = OSC_MAINCK_8M_RC,     //!< Internal 8MHz RC oscillator.
82
 	PLL_SRC_MAINCK_12M_RC       = OSC_MAINCK_12M_RC,    //!< Internal 12MHz RC oscillator.
82
 	PLL_SRC_MAINCK_12M_RC       = OSC_MAINCK_12M_RC,    //!< Internal 12MHz RC oscillator.

+ 1
- 1
Marlin/src/HAL/HAL_DUE/usb/sbc_protocol.h 查看文件

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

+ 5
- 5
Marlin/src/HAL/HAL_DUE/usb/spc_protocol.h 查看文件

184
 COMPILER_PACK_RESET()
184
 COMPILER_PACK_RESET()
185
 
185
 
186
 /* Vital Product Data page codes */
186
 /* Vital Product Data page codes */
187
-enum scsi_vpd_page_code {
187
+enum scsi_vpd_page_code : char {
188
 	SCSI_VPD_SUPPORTED_PAGES = 0x00,
188
 	SCSI_VPD_SUPPORTED_PAGES = 0x00,
189
 	SCSI_VPD_UNIT_SERIAL_NUMBER = 0x80,
189
 	SCSI_VPD_UNIT_SERIAL_NUMBER = 0x80,
190
 	SCSI_VPD_DEVICE_IDENTIFICATION = 0x83,
190
 	SCSI_VPD_DEVICE_IDENTIFICATION = 0x83,
202
 
202
 
203
 
203
 
204
 /* Sense keys */
204
 /* Sense keys */
205
-enum scsi_sense_key {
205
+enum scsi_sense_key : char {
206
 	SCSI_SK_NO_SENSE = 0x0,
206
 	SCSI_SK_NO_SENSE = 0x0,
207
 	SCSI_SK_RECOVERED_ERROR = 0x1,
207
 	SCSI_SK_RECOVERED_ERROR = 0x1,
208
 	SCSI_SK_NOT_READY = 0x2,
208
 	SCSI_SK_NOT_READY = 0x2,
220
 };
220
 };
221
 
221
 
222
 /* Additional Sense Code / Additional Sense Code Qualifier pairs */
222
 /* Additional Sense Code / Additional Sense Code Qualifier pairs */
223
-enum scsi_asc_ascq {
223
+enum scsi_asc_ascq : char {
224
 	SCSI_ASC_NO_ADDITIONAL_SENSE_INFO = 0x0000,
224
 	SCSI_ASC_NO_ADDITIONAL_SENSE_INFO = 0x0000,
225
 	SCSI_ASC_LU_NOT_READY_REBUILD_IN_PROGRESS = 0x0405,
225
 	SCSI_ASC_LU_NOT_READY_REBUILD_IN_PROGRESS = 0x0405,
226
 	SCSI_ASC_WRITE_ERROR = 0x0c00,
226
 	SCSI_ASC_WRITE_ERROR = 0x0c00,
239
  * used with MODE SELECT and MODE SENSE commands
239
  * used with MODE SELECT and MODE SENSE commands
240
  * that are applicable to all SCSI devices.
240
  * that are applicable to all SCSI devices.
241
  */
241
  */
242
-enum scsi_spc_mode {
242
+enum scsi_spc_mode : char {
243
 	SCSI_MS_MODE_VENDOR_SPEC = 0x00,
243
 	SCSI_MS_MODE_VENDOR_SPEC = 0x00,
244
 	SCSI_MS_MODE_INFEXP = 0x1C,    // Informational exceptions control page
244
 	SCSI_MS_MODE_INFEXP = 0x1C,    // Informational exceptions control page
245
 	SCSI_MS_MODE_ALL = 0x3f,
245
 	SCSI_MS_MODE_ALL = 0x3f,
273
 };
273
 };
274
 
274
 
275
 
275
 
276
-enum scsi_spc_mode_sense_pc {
276
+enum scsi_spc_mode_sense_pc : char {
277
 	SCSI_MS_SENSE_PC_CURRENT = 0,
277
 	SCSI_MS_SENSE_PC_CURRENT = 0,
278
 	SCSI_MS_SENSE_PC_CHANGEABLE = 1,
278
 	SCSI_MS_SENSE_PC_CHANGEABLE = 1,
279
 	SCSI_MS_SENSE_PC_DEFAULT = 2,
279
 	SCSI_MS_SENSE_PC_DEFAULT = 2,

+ 13
- 13
Marlin/src/HAL/HAL_DUE/usb/usb_protocol.h 查看文件

107
 /**
107
 /**
108
  * \brief Standard USB requests (bRequest)
108
  * \brief Standard USB requests (bRequest)
109
  */
109
  */
110
-enum usb_reqid {
110
+enum usb_reqid : char {
111
 	USB_REQ_GET_STATUS = 0,
111
 	USB_REQ_GET_STATUS = 0,
112
 	USB_REQ_CLEAR_FEATURE = 1,
112
 	USB_REQ_CLEAR_FEATURE = 1,
113
 	USB_REQ_SET_FEATURE = 3,
113
 	USB_REQ_SET_FEATURE = 3,
125
  * \brief Standard USB device status flags
125
  * \brief Standard USB device status flags
126
  *
126
  *
127
  */
127
  */
128
-enum usb_device_status {
128
+enum usb_device_status : char {
129
 	USB_DEV_STATUS_BUS_POWERED = 0,
129
 	USB_DEV_STATUS_BUS_POWERED = 0,
130
 	USB_DEV_STATUS_SELF_POWERED = 1,
130
 	USB_DEV_STATUS_SELF_POWERED = 1,
131
 	USB_DEV_STATUS_REMOTEWAKEUP = 2
131
 	USB_DEV_STATUS_REMOTEWAKEUP = 2
135
  * \brief Standard USB Interface status flags
135
  * \brief Standard USB Interface status flags
136
  *
136
  *
137
  */
137
  */
138
-enum usb_interface_status {
138
+enum usb_interface_status : char {
139
 	USB_IFACE_STATUS_RESERVED = 0
139
 	USB_IFACE_STATUS_RESERVED = 0
140
 };
140
 };
141
 
141
 
143
  * \brief Standard USB endpoint status flags
143
  * \brief Standard USB endpoint status flags
144
  *
144
  *
145
  */
145
  */
146
-enum usb_endpoint_status {
146
+enum usb_endpoint_status : char {
147
 	USB_EP_STATUS_HALTED = 1,
147
 	USB_EP_STATUS_HALTED = 1,
148
 };
148
 };
149
 
149
 
152
  *
152
  *
153
  * \note valid for SetFeature request.
153
  * \note valid for SetFeature request.
154
  */
154
  */
155
-enum usb_device_feature {
155
+enum usb_device_feature : char {
156
 	USB_DEV_FEATURE_REMOTE_WAKEUP = 1, //!< Remote wakeup enabled
156
 	USB_DEV_FEATURE_REMOTE_WAKEUP = 1, //!< Remote wakeup enabled
157
 	USB_DEV_FEATURE_TEST_MODE = 2,     //!< USB test mode
157
 	USB_DEV_FEATURE_TEST_MODE = 2,     //!< USB test mode
158
 	USB_DEV_FEATURE_OTG_B_HNP_ENABLE = 3,
158
 	USB_DEV_FEATURE_OTG_B_HNP_ENABLE = 3,
165
  *
165
  *
166
  * \note valid for USB_DEV_FEATURE_TEST_MODE request.
166
  * \note valid for USB_DEV_FEATURE_TEST_MODE request.
167
  */
167
  */
168
-enum usb_device_hs_test_mode {
168
+enum usb_device_hs_test_mode : char {
169
 	USB_DEV_TEST_MODE_J = 1,
169
 	USB_DEV_TEST_MODE_J = 1,
170
 	USB_DEV_TEST_MODE_K = 2,
170
 	USB_DEV_TEST_MODE_K = 2,
171
 	USB_DEV_TEST_MODE_SE0_NAK = 3,
171
 	USB_DEV_TEST_MODE_SE0_NAK = 3,
176
 /**
176
 /**
177
  * \brief Standard USB endpoint feature/status flags
177
  * \brief Standard USB endpoint feature/status flags
178
  */
178
  */
179
-enum usb_endpoint_feature {
179
+enum usb_endpoint_feature : char {
180
 	USB_EP_FEATURE_HALT = 0,
180
 	USB_EP_FEATURE_HALT = 0,
181
 };
181
 };
182
 
182
 
183
 /**
183
 /**
184
  * \brief Standard USB Test Mode Selectors
184
  * \brief Standard USB Test Mode Selectors
185
  */
185
  */
186
-enum usb_test_mode_selector {
186
+enum usb_test_mode_selector : char {
187
 	USB_TEST_J = 0x01,
187
 	USB_TEST_J = 0x01,
188
 	USB_TEST_K = 0x02,
188
 	USB_TEST_K = 0x02,
189
 	USB_TEST_SE0_NAK = 0x03,
189
 	USB_TEST_SE0_NAK = 0x03,
194
 /**
194
 /**
195
  * \brief Standard USB descriptor types
195
  * \brief Standard USB descriptor types
196
  */
196
  */
197
-enum usb_descriptor_type {
197
+enum usb_descriptor_type : char {
198
 	USB_DT_DEVICE = 1,
198
 	USB_DT_DEVICE = 1,
199
 	USB_DT_CONFIGURATION = 2,
199
 	USB_DT_CONFIGURATION = 2,
200
 	USB_DT_STRING = 3,
200
 	USB_DT_STRING = 3,
212
 /**
212
 /**
213
  * \brief USB Device Capability types
213
  * \brief USB Device Capability types
214
  */
214
  */
215
-enum usb_capability_type {
215
+enum usb_capability_type : char {
216
 	USB_DC_USB20_EXTENSION = 0x02,
216
 	USB_DC_USB20_EXTENSION = 0x02,
217
 };
217
 };
218
 
218
 
220
  * \brief USB Device Capability - USB 2.0 Extension
220
  * \brief USB Device Capability - USB 2.0 Extension
221
  * To fill bmAttributes field of usb_capa_ext_desc_t structure.
221
  * To fill bmAttributes field of usb_capa_ext_desc_t structure.
222
  */
222
  */
223
-enum usb_capability_extension_attr {
223
+enum usb_capability_extension_attr : char {
224
 	USB_DC_EXT_LPM  = 0x00000002,
224
 	USB_DC_EXT_LPM  = 0x00000002,
225
 };
225
 };
226
 
226
 
253
 /**
253
 /**
254
  * \brief Standard USB endpoint transfer types
254
  * \brief Standard USB endpoint transfer types
255
  */
255
  */
256
-enum usb_ep_type {
256
+enum usb_ep_type : char {
257
 	USB_EP_TYPE_CONTROL = 0x00,
257
 	USB_EP_TYPE_CONTROL = 0x00,
258
 	USB_EP_TYPE_ISOCHRONOUS = 0x01,
258
 	USB_EP_TYPE_ISOCHRONOUS = 0x01,
259
 	USB_EP_TYPE_BULK = 0x02,
259
 	USB_EP_TYPE_BULK = 0x02,
264
 /**
264
 /**
265
  * \brief Standard USB language IDs for string descriptors
265
  * \brief Standard USB language IDs for string descriptors
266
  */
266
  */
267
-enum usb_langid {
267
+enum usb_langid : char {
268
 	USB_LANGID_EN_US = 0x0409, //!< English (United States)
268
 	USB_LANGID_EN_US = 0x0409, //!< English (United States)
269
 };
269
 };
270
 
270
 

+ 2
- 2
Marlin/src/HAL/HAL_DUE/usb/usb_protocol_cdc.h 查看文件

239
 	uint8_t bDataBits;
239
 	uint8_t bDataBits;
240
 } usb_cdc_line_coding_t;
240
 } usb_cdc_line_coding_t;
241
 //! Possible values of bCharFormat
241
 //! Possible values of bCharFormat
242
-enum cdc_char_format {
242
+enum cdc_char_format : char {
243
 	CDC_STOP_BITS_1 = 0,	//!< 1 stop bit
243
 	CDC_STOP_BITS_1 = 0,	//!< 1 stop bit
244
 	CDC_STOP_BITS_1_5 = 1,	//!< 1.5 stop bits
244
 	CDC_STOP_BITS_1_5 = 1,	//!< 1.5 stop bits
245
 	CDC_STOP_BITS_2 = 2,	//!< 2 stop bits
245
 	CDC_STOP_BITS_2 = 2,	//!< 2 stop bits
246
 };
246
 };
247
 //! Possible values of bParityType
247
 //! Possible values of bParityType
248
-enum cdc_parity {
248
+enum cdc_parity : char {
249
 	CDC_PAR_NONE = 0,	//!< No parity
249
 	CDC_PAR_NONE = 0,	//!< No parity
250
 	CDC_PAR_ODD = 1,	//!< Odd parity
250
 	CDC_PAR_ODD = 1,	//!< Odd parity
251
 	CDC_PAR_EVEN = 2,	//!< Even parity
251
 	CDC_PAR_EVEN = 2,	//!< Even parity

+ 2
- 2
Marlin/src/HAL/HAL_DUE/usb/usb_protocol_msc.h 查看文件

93
 /**
93
 /**
94
  * \brief MSC USB requests (bRequest)
94
  * \brief MSC USB requests (bRequest)
95
  */
95
  */
96
-enum usb_reqid_msc {
96
+enum usb_reqid_msc : unsigned char {
97
 	USB_REQ_MSC_BULK_RESET = 0xFF,	//!< Mass Storage Reset
97
 	USB_REQ_MSC_BULK_RESET = 0xFF,	//!< Mass Storage Reset
98
-	USB_REQ_MSC_GET_MAX_LUN = 0xFE,	//!< Get Max LUN
98
+	USB_REQ_MSC_GET_MAX_LUN = 0xFE 	//!< Get Max LUN
99
 };
99
 };
100
 
100
 
101
 
101
 

+ 1
- 1
Marlin/src/HAL/HAL_STM32F1/HAL_Stm32f1.cpp 查看文件

87
   #endif
87
   #endif
88
 };
88
 };
89
 
89
 
90
-enum TEMP_PINS {
90
+enum TEMP_PINS : char {
91
   #if HAS_TEMP_0
91
   #if HAS_TEMP_0
92
     TEMP_0,
92
     TEMP_0,
93
   #endif
93
   #endif

+ 5
- 5
Marlin/src/core/enum.h 查看文件

31
  *  - X_HEAD and Y_HEAD is used for systems that don't have a 1:1 relationship
31
  *  - X_HEAD and Y_HEAD is used for systems that don't have a 1:1 relationship
32
  *    between X_AXIS and X Head movement, like CoreXY bots
32
  *    between X_AXIS and X Head movement, like CoreXY bots
33
  */
33
  */
34
-enum AxisEnum {
35
-  NO_AXIS   = -1,
34
+enum AxisEnum : unsigned char {
36
   X_AXIS    = 0,
35
   X_AXIS    = 0,
37
   A_AXIS    = 0,
36
   A_AXIS    = 0,
38
   Y_AXIS    = 1,
37
   Y_AXIS    = 1,
43
   X_HEAD    = 4,
42
   X_HEAD    = 4,
44
   Y_HEAD    = 5,
43
   Y_HEAD    = 5,
45
   Z_HEAD    = 6,
44
   Z_HEAD    = 6,
46
-  ALL_AXES  = 100
45
+  ALL_AXES  = 0xFE,
46
+  NO_AXIS   = 0xFF
47
 };
47
 };
48
 
48
 
49
 #define LOOP_S_LE_N(VAR, S, N) for (uint8_t VAR=S; VAR<=N; VAR++)
49
 #define LOOP_S_LE_N(VAR, S, N) for (uint8_t VAR=S; VAR<=N; VAR++)
73
 /**
73
 /**
74
  * SD Card
74
  * SD Card
75
  */
75
  */
76
-enum LsAction { LS_SerialPrint, LS_Count, LS_GetFilename };
76
+enum LsAction : char { LS_SerialPrint, LS_Count, LS_GetFilename };
77
 
77
 
78
 /**
78
 /**
79
  * Ultra LCD
79
  * Ultra LCD
80
  */
80
  */
81
-enum LCDViewAction {
81
+enum LCDViewAction : char {
82
   LCDVIEW_NONE,
82
   LCDVIEW_NONE,
83
   LCDVIEW_REDRAW_NOW,
83
   LCDVIEW_REDRAW_NOW,
84
   LCDVIEW_CALL_REDRAW_NEXT,
84
   LCDVIEW_CALL_REDRAW_NEXT,

+ 2
- 2
Marlin/src/core/serial.h 查看文件

32
 /**
32
 /**
33
  * Define debug bit-masks
33
  * Define debug bit-masks
34
  */
34
  */
35
-enum DebugFlags {
35
+enum DebugFlags : unsigned char {
36
   DEBUG_NONE          = 0,
36
   DEBUG_NONE          = 0,
37
   DEBUG_ECHO          = _BV(0), ///< Echo commands in order as they are processed
37
   DEBUG_ECHO          = _BV(0), ///< Echo commands in order as they are processed
38
   DEBUG_INFO          = _BV(1), ///< Print messages for code that has debug output
38
   DEBUG_INFO          = _BV(1), ///< Print messages for code that has debug output
45
 };
45
 };
46
 
46
 
47
 #if ENABLED(EMERGENCY_PARSER)
47
 #if ENABLED(EMERGENCY_PARSER)
48
-  enum e_parser_state {
48
+  enum e_parser_state : char {
49
     state_RESET,
49
     state_RESET,
50
     state_N,
50
     state_N,
51
     state_M,
51
     state_M,

+ 1
- 1
Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h 查看文件

25
 
25
 
26
 #include "../../../inc/MarlinConfig.h"
26
 #include "../../../inc/MarlinConfig.h"
27
 
27
 
28
-enum MeshLevelingState {
28
+enum MeshLevelingState : char {
29
   MeshReport,
29
   MeshReport,
30
   MeshStart,
30
   MeshStart,
31
   MeshNext,
31
   MeshNext,

+ 1
- 1
Marlin/src/feature/bedlevel/ubl/ubl.h 查看文件

47
 
47
 
48
 // ubl_G29.cpp
48
 // ubl_G29.cpp
49
 
49
 
50
-enum MeshPointType { INVALID, REAL, SET_IN_BITMAP };
50
+enum MeshPointType : char { INVALID, REAL, SET_IN_BITMAP };
51
 
51
 
52
 // External references
52
 // External references
53
 
53
 

+ 3
- 3
Marlin/src/feature/pause.h 查看文件

32
 
32
 
33
 #include "../inc/MarlinConfigPre.h"
33
 #include "../inc/MarlinConfigPre.h"
34
 
34
 
35
-enum AdvancedPauseMode {
35
+enum AdvancedPauseMode : char {
36
   ADVANCED_PAUSE_MODE_PAUSE_PRINT,
36
   ADVANCED_PAUSE_MODE_PAUSE_PRINT,
37
   ADVANCED_PAUSE_MODE_LOAD_FILAMENT,
37
   ADVANCED_PAUSE_MODE_LOAD_FILAMENT,
38
   ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT
38
   ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT
39
 };
39
 };
40
 
40
 
41
-enum AdvancedPauseMessage {
41
+enum AdvancedPauseMessage : char {
42
   ADVANCED_PAUSE_MESSAGE_INIT,
42
   ADVANCED_PAUSE_MESSAGE_INIT,
43
   ADVANCED_PAUSE_MESSAGE_UNLOAD,
43
   ADVANCED_PAUSE_MESSAGE_UNLOAD,
44
   ADVANCED_PAUSE_MESSAGE_INSERT,
44
   ADVANCED_PAUSE_MESSAGE_INSERT,
51
   ADVANCED_PAUSE_MESSAGE_WAIT_FOR_NOZZLES_TO_HEAT
51
   ADVANCED_PAUSE_MESSAGE_WAIT_FOR_NOZZLES_TO_HEAT
52
 };
52
 };
53
 
53
 
54
-enum AdvancedPauseMenuResponse {
54
+enum AdvancedPauseMenuResponse : char {
55
   ADVANCED_PAUSE_RESPONSE_WAIT_FOR,
55
   ADVANCED_PAUSE_RESPONSE_WAIT_FOR,
56
   ADVANCED_PAUSE_RESPONSE_EXTRUDE_MORE,
56
   ADVANCED_PAUSE_RESPONSE_EXTRUDE_MORE,
57
   ADVANCED_PAUSE_RESPONSE_RESUME_PRINT
57
   ADVANCED_PAUSE_RESPONSE_RESUME_PRINT

+ 50
- 41
Marlin/src/feature/tmc_util.cpp 查看文件

37
 #endif
37
 #endif
38
 
38
 
39
 bool report_tmc_status = false;
39
 bool report_tmc_status = false;
40
-char extended_axis_codes[11][3] = { "X", "X2", "Y", "Y2", "Z", "Z2", "E0", "E1", "E2", "E3", "E4" };
41
 
40
 
42
 /**
41
 /**
43
  * Check for over temperature or short to ground error flags.
42
  * Check for over temperature or short to ground error flags.
96
   #endif
95
   #endif
97
 
96
 
98
   template<typename TMC>
97
   template<typename TMC>
99
-  void monitor_tmc_driver(TMC &st, const char * const axisName, uint8_t &otpw_cnt) {
98
+  void monitor_tmc_driver(TMC &st, const TMC_AxisEnum axis, uint8_t &otpw_cnt) {
100
     TMC_driver_data data = get_driver_data(st);
99
     TMC_driver_data data = get_driver_data(st);
101
 
100
 
102
     #if ENABLED(STOP_ON_ERROR)
101
     #if ENABLED(STOP_ON_ERROR)
103
       if (data.is_error) {
102
       if (data.is_error) {
104
         SERIAL_EOL();
103
         SERIAL_EOL();
105
-        SERIAL_ECHO(axisName);
106
-        SERIAL_ECHOPGM(" driver error detected:");
107
-        if (data.is_ot) SERIAL_ECHOPGM("\novertemperature");
108
-        if (st.s2ga()) SERIAL_ECHOPGM("\nshort to ground (coil A)");
109
-        if (st.s2gb()) SERIAL_ECHOPGM("\nshort to ground (coil B)");
110
-        SERIAL_EOL();
104
+        _tmc_say_axis(axis);
105
+        SERIAL_ECHOLNPGM(" driver error detected:");
106
+        if (data.is_ot) SERIAL_ECHOLNPGM("overtemperature");
107
+        if (st.s2ga()) SERIAL_ECHOLNPGM("short to ground (coil A)");
108
+        if (st.s2gb()) SERIAL_ECHOLNPGM("short to ground (coil B)");
111
         #if ENABLED(TMC_DEBUG)
109
         #if ENABLED(TMC_DEBUG)
112
           tmc_report_all();
110
           tmc_report_all();
113
         #endif
111
         #endif
124
       SERIAL_EOL();
122
       SERIAL_EOL();
125
       SERIAL_ECHO(timestamp);
123
       SERIAL_ECHO(timestamp);
126
       SERIAL_ECHOPGM(": ");
124
       SERIAL_ECHOPGM(": ");
127
-      SERIAL_ECHO(axisName);
125
+      _tmc_say_axis(axis);
128
       SERIAL_ECHOPGM(" driver overtemperature warning! (");
126
       SERIAL_ECHOPGM(" driver overtemperature warning! (");
129
       SERIAL_ECHO(st.getCurrent());
127
       SERIAL_ECHO(st.getCurrent());
130
       SERIAL_ECHOLNPGM("mA)");
128
       SERIAL_ECHOLNPGM("mA)");
134
       if (data.is_otpw && !st.isEnabled() && otpw_cnt > 4) {
132
       if (data.is_otpw && !st.isEnabled() && otpw_cnt > 4) {
135
         st.setCurrent(st.getCurrent() - CURRENT_STEP_DOWN, R_SENSE, HOLD_MULTIPLIER);
133
         st.setCurrent(st.getCurrent() - CURRENT_STEP_DOWN, R_SENSE, HOLD_MULTIPLIER);
136
         #if ENABLED(REPORT_CURRENT_CHANGE)
134
         #if ENABLED(REPORT_CURRENT_CHANGE)
137
-          SERIAL_ECHO(axisName);
135
+          _tmc_say_axis(axis);
138
           SERIAL_ECHOLNPAIR(" current decreased to ", st.getCurrent());
136
           SERIAL_ECHOLNPAIR(" current decreased to ", st.getCurrent());
139
         #endif
137
         #endif
140
       }
138
       }
148
 
146
 
149
     if (report_tmc_status) {
147
     if (report_tmc_status) {
150
       const uint32_t pwm_scale = get_pwm_scale(st);
148
       const uint32_t pwm_scale = get_pwm_scale(st);
151
-      SERIAL_ECHO(axisName);
149
+      _tmc_say_axis(axis);
152
       SERIAL_ECHOPAIR(":", pwm_scale);
150
       SERIAL_ECHOPAIR(":", pwm_scale);
153
       SERIAL_ECHOPGM(" |0b"); SERIAL_PRINT(get_status_response(st), BIN);
151
       SERIAL_ECHOPGM(" |0b"); SERIAL_PRINT(get_status_response(st), BIN);
154
       SERIAL_ECHOPGM("| ");
152
       SERIAL_ECHOPGM("| ");
169
       next_cOT = millis() + 500;
167
       next_cOT = millis() + 500;
170
       #if HAS_HW_COMMS(X) || ENABLED(IS_TRAMS)
168
       #if HAS_HW_COMMS(X) || ENABLED(IS_TRAMS)
171
         static uint8_t x_otpw_cnt = 0;
169
         static uint8_t x_otpw_cnt = 0;
172
-        monitor_tmc_driver(stepperX, extended_axis_codes[TMC_X], x_otpw_cnt);
170
+        monitor_tmc_driver(stepperX, TMC_X, x_otpw_cnt);
173
       #endif
171
       #endif
174
       #if HAS_HW_COMMS(Y) || ENABLED(IS_TRAMS)
172
       #if HAS_HW_COMMS(Y) || ENABLED(IS_TRAMS)
175
         static uint8_t y_otpw_cnt = 0;
173
         static uint8_t y_otpw_cnt = 0;
176
-        monitor_tmc_driver(stepperY, extended_axis_codes[TMC_Y], y_otpw_cnt);
174
+        monitor_tmc_driver(stepperY, TMC_Y, y_otpw_cnt);
177
       #endif
175
       #endif
178
       #if HAS_HW_COMMS(Z) || ENABLED(IS_TRAMS)
176
       #if HAS_HW_COMMS(Z) || ENABLED(IS_TRAMS)
179
         static uint8_t z_otpw_cnt = 0;
177
         static uint8_t z_otpw_cnt = 0;
180
-        monitor_tmc_driver(stepperZ, extended_axis_codes[TMC_Z], z_otpw_cnt);
178
+        monitor_tmc_driver(stepperZ, TMC_Z, z_otpw_cnt);
181
       #endif
179
       #endif
182
       #if HAS_HW_COMMS(X2)
180
       #if HAS_HW_COMMS(X2)
183
         static uint8_t x2_otpw_cnt = 0;
181
         static uint8_t x2_otpw_cnt = 0;
184
-        monitor_tmc_driver(stepperX2, extended_axis_codes[TMC_X], x2_otpw_cnt);
182
+        monitor_tmc_driver(stepperX2, TMC_X, x2_otpw_cnt);
185
       #endif
183
       #endif
186
       #if HAS_HW_COMMS(Y2)
184
       #if HAS_HW_COMMS(Y2)
187
         static uint8_t y2_otpw_cnt = 0;
185
         static uint8_t y2_otpw_cnt = 0;
188
-        monitor_tmc_driver(stepperY2, extended_axis_codes[TMC_Y], y2_otpw_cnt);
186
+        monitor_tmc_driver(stepperY2, TMC_Y, y2_otpw_cnt);
189
       #endif
187
       #endif
190
       #if HAS_HW_COMMS(Z2)
188
       #if HAS_HW_COMMS(Z2)
191
         static uint8_t z2_otpw_cnt = 0;
189
         static uint8_t z2_otpw_cnt = 0;
192
-        monitor_tmc_driver(stepperZ2, extended_axis_codes[TMC_Z], z2_otpw_cnt);
190
+        monitor_tmc_driver(stepperZ2, TMC_Z, z2_otpw_cnt);
193
       #endif
191
       #endif
194
       #if HAS_HW_COMMS(E0) || ENABLED(IS_TRAMS)
192
       #if HAS_HW_COMMS(E0) || ENABLED(IS_TRAMS)
195
         static uint8_t e0_otpw_cnt = 0;
193
         static uint8_t e0_otpw_cnt = 0;
196
-        monitor_tmc_driver(stepperE0, extended_axis_codes[TMC_E0], e0_otpw_cnt);
194
+        monitor_tmc_driver(stepperE0, TMC_E0, e0_otpw_cnt);
197
       #endif
195
       #endif
198
       #if HAS_HW_COMMS(E1)
196
       #if HAS_HW_COMMS(E1)
199
         static uint8_t e1_otpw_cnt = 0;
197
         static uint8_t e1_otpw_cnt = 0;
200
-        monitor_tmc_driver(stepperE1, extended_axis_codes[TMC_E1], e1_otpw_cnt);
198
+        monitor_tmc_driver(stepperE1, TMC_E1, e1_otpw_cnt);
201
       #endif
199
       #endif
202
       #if HAS_HW_COMMS(E2)
200
       #if HAS_HW_COMMS(E2)
203
         static uint8_t e2_otpw_cnt = 0;
201
         static uint8_t e2_otpw_cnt = 0;
204
-        monitor_tmc_driver(stepperE2, extended_axis_codes[TMC_E2], e2_otpw_cnt);
202
+        monitor_tmc_driver(stepperE2, TMC_E2, e2_otpw_cnt);
205
       #endif
203
       #endif
206
       #if HAS_HW_COMMS(E3)
204
       #if HAS_HW_COMMS(E3)
207
         static uint8_t e3_otpw_cnt = 0;
205
         static uint8_t e3_otpw_cnt = 0;
208
-        monitor_tmc_driver(stepperE3, extended_axis_codes[TMC_E3], e3_otpw_cnt);
206
+        monitor_tmc_driver(stepperE3, TMC_E3, e3_otpw_cnt);
209
       #endif
207
       #endif
210
       #if HAS_HW_COMMS(E4)
208
       #if HAS_HW_COMMS(E4)
211
         static uint8_t e4_otpw_cnt = 0;
209
         static uint8_t e4_otpw_cnt = 0;
212
-        monitor_tmc_driver(stepperE4, extended_axis_codes[TMC_E4], e4_otpw_cnt);
210
+        monitor_tmc_driver(stepperE4, TMC_E4, e4_otpw_cnt);
213
       #endif
211
       #endif
214
 
212
 
215
       if (report_tmc_status) SERIAL_EOL();
213
       if (report_tmc_status) SERIAL_EOL();
218
 
216
 
219
 #endif // MONITOR_DRIVER_STATUS
217
 #endif // MONITOR_DRIVER_STATUS
220
 
218
 
221
-void _tmc_say_current(const char name[], const uint16_t curr) {
222
-  SERIAL_ECHO(name);
219
+void _tmc_say_axis(const TMC_AxisEnum axis) {
220
+  const static char ext_X[]  PROGMEM = "X",  ext_X2[] PROGMEM = "X2",
221
+                    ext_Y[]  PROGMEM = "Y",  ext_Y2[] PROGMEM = "Y2",
222
+                    ext_Z[]  PROGMEM = "Z",  ext_Z2[] PROGMEM = "Z2",
223
+                    ext_E0[] PROGMEM = "E0", ext_E1[] PROGMEM = "E1",
224
+                    ext_E2[] PROGMEM = "E2", ext_E3[] PROGMEM = "E3",
225
+                    ext_E4[] PROGMEM = "E4";
226
+  const static char* const tmc_axes[] PROGMEM = { ext_X, ext_X2, ext_Y, ext_Y2, ext_Z, ext_Z2, ext_E0, ext_E1, ext_E2, ext_E3, ext_E4 };
227
+  serialprintPGM(tmc_axes[axis]);
228
+}
229
+
230
+void _tmc_say_current(const TMC_AxisEnum axis, const uint16_t curr) {
231
+  _tmc_say_axis(axis);
223
   SERIAL_ECHOLNPAIR(" axis driver current: ", curr);
232
   SERIAL_ECHOLNPAIR(" axis driver current: ", curr);
224
 }
233
 }
225
-void _tmc_say_otpw(const char name[], const bool otpw) {
226
-  SERIAL_ECHO(name);
234
+void _tmc_say_otpw(const TMC_AxisEnum axis, const bool otpw) {
235
+  _tmc_say_axis(axis);
227
   SERIAL_ECHOPGM(" axis temperature prewarn triggered: ");
236
   SERIAL_ECHOPGM(" axis temperature prewarn triggered: ");
228
   serialprintPGM(otpw ? PSTR("true") : PSTR("false"));
237
   serialprintPGM(otpw ? PSTR("true") : PSTR("false"));
229
   SERIAL_EOL();
238
   SERIAL_EOL();
230
 }
239
 }
231
-void _tmc_say_otpw_cleared(const char name[]) {
232
-  SERIAL_ECHO(name);
240
+void _tmc_say_otpw_cleared(const TMC_AxisEnum axis) {
241
+  _tmc_say_axis(axis);
233
   SERIAL_ECHOLNPGM(" prewarn flag cleared");
242
   SERIAL_ECHOLNPGM(" prewarn flag cleared");
234
 }
243
 }
235
-void _tmc_say_pwmthrs(const char name[], const uint32_t thrs) {
236
-  SERIAL_ECHO(name);
244
+void _tmc_say_pwmthrs(const TMC_AxisEnum axis, const uint32_t thrs) {
245
+  _tmc_say_axis(axis);
237
   SERIAL_ECHOLNPAIR(" stealthChop max speed set to ", thrs);
246
   SERIAL_ECHOLNPAIR(" stealthChop max speed set to ", thrs);
238
 }
247
 }
239
-void _tmc_say_sgt(const char name[], const int8_t sgt) {
240
-  SERIAL_ECHO(name);
248
+void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) {
249
+  _tmc_say_axis(axis);
241
   SERIAL_ECHOPGM(" driver homing sensitivity set to ");
250
   SERIAL_ECHOPGM(" driver homing sensitivity set to ");
242
   SERIAL_PRINTLN(sgt, DEC);
251
   SERIAL_PRINTLN(sgt, DEC);
243
 }
252
 }
244
 
253
 
245
 #if ENABLED(TMC_DEBUG)
254
 #if ENABLED(TMC_DEBUG)
246
 
255
 
247
-  enum TMC_debug_enum {
256
+  enum TMC_debug_enum : char {
248
     TMC_CODES,
257
     TMC_CODES,
249
     TMC_ENABLED,
258
     TMC_ENABLED,
250
     TMC_CURRENT,
259
     TMC_CURRENT,
268
     TMC_HSTRT,
277
     TMC_HSTRT,
269
     TMC_SGT
278
     TMC_SGT
270
   };
279
   };
271
-  enum TMC_drv_status_enum {
280
+  enum TMC_drv_status_enum : char {
272
     TMC_DRV_CODES,
281
     TMC_DRV_CODES,
273
     TMC_STST,
282
     TMC_STST,
274
     TMC_OLB,
283
     TMC_OLB,
290
     TMC_S2VSB,
299
     TMC_S2VSB,
291
     TMC_S2VSA
300
     TMC_S2VSA
292
   };
301
   };
293
-  static void drv_status_print_hex(const char name[], const uint32_t drv_status) {
294
-    SERIAL_ECHO(name);
302
+  static void drv_status_print_hex(const TMC_AxisEnum axis, const uint32_t drv_status) {
303
+    _tmc_say_axis(axis);
295
     SERIAL_ECHOPGM(" = 0x");
304
     SERIAL_ECHOPGM(" = 0x");
296
     for (int B = 24; B >= 8; B -= 8){
305
     for (int B = 24; B >= 8; B -= 8){
297
       SERIAL_PRINT((drv_status >> (B + 4)) & 0xF, HEX);
306
       SERIAL_PRINT((drv_status >> (B + 4)) & 0xF, HEX);
345
   #endif
354
   #endif
346
 
355
 
347
   template <typename TMC>
356
   template <typename TMC>
348
-  static void tmc_status(TMC &st, TMC_AxisEnum axis, const TMC_debug_enum i, const float spmm) {
357
+  static void tmc_status(TMC &st, const TMC_AxisEnum axis, const TMC_debug_enum i, const float spmm) {
349
     SERIAL_ECHO('\t');
358
     SERIAL_ECHO('\t');
350
     switch(i) {
359
     switch(i) {
351
-      case TMC_CODES: SERIAL_ECHO(extended_axis_codes[axis]); break;
360
+      case TMC_CODES: _tmc_say_axis(axis); break;
352
       case TMC_ENABLED: serialprintPGM(st.isEnabled() ? PSTR("true") : PSTR("false")); break;
361
       case TMC_ENABLED: serialprintPGM(st.isEnabled() ? PSTR("true") : PSTR("false")); break;
353
       case TMC_CURRENT: SERIAL_ECHO(st.getCurrent()); break;
362
       case TMC_CURRENT: SERIAL_ECHO(st.getCurrent()); break;
354
       case TMC_RMS_CURRENT: SERIAL_PROTOCOL(st.rms_current()); break;
363
       case TMC_RMS_CURRENT: SERIAL_PROTOCOL(st.rms_current()); break;
390
   }
399
   }
391
 
400
 
392
   template <typename TMC>
401
   template <typename TMC>
393
-  static void tmc_parse_drv_status(TMC &st, TMC_AxisEnum axis, const TMC_drv_status_enum i) {
402
+  static void tmc_parse_drv_status(TMC &st, const TMC_AxisEnum axis, const TMC_drv_status_enum i) {
394
     SERIAL_CHAR('\t');
403
     SERIAL_CHAR('\t');
395
     switch(i) {
404
     switch(i) {
396
-      case TMC_DRV_CODES:     SERIAL_ECHO(extended_axis_codes[axis]);  break;
405
+      case TMC_DRV_CODES:     _tmc_say_axis(axis);  break;
397
       case TMC_STST:          if (st.stst())         SERIAL_CHAR('X'); break;
406
       case TMC_STST:          if (st.stst())         SERIAL_CHAR('X'); break;
398
       case TMC_OLB:           if (st.olb())          SERIAL_CHAR('X'); break;
407
       case TMC_OLB:           if (st.olb())          SERIAL_CHAR('X'); break;
399
       case TMC_OLA:           if (st.ola())          SERIAL_CHAR('X'); break;
408
       case TMC_OLA:           if (st.ola())          SERIAL_CHAR('X'); break;
402
       case TMC_DRV_OTPW:      if (st.otpw())         SERIAL_CHAR('X'); break;
411
       case TMC_DRV_OTPW:      if (st.otpw())         SERIAL_CHAR('X'); break;
403
       case TMC_OT:            if (st.ot())           SERIAL_CHAR('X'); break;
412
       case TMC_OT:            if (st.ot())           SERIAL_CHAR('X'); break;
404
       case TMC_DRV_CS_ACTUAL: SERIAL_PRINT(st.cs_actual(), DEC);       break;
413
       case TMC_DRV_CS_ACTUAL: SERIAL_PRINT(st.cs_actual(), DEC);       break;
405
-      case TMC_DRV_STATUS_HEX:drv_status_print_hex(extended_axis_codes[axis], st.DRV_STATUS()); break;
414
+      case TMC_DRV_STATUS_HEX:drv_status_print_hex(axis, st.DRV_STATUS()); break;
406
       default: tmc_parse_drv_status(st, i); break;
415
       default: tmc_parse_drv_status(st, i); break;
407
     }
416
     }
408
   }
417
   }

+ 23
- 26
Marlin/src/feature/tmc_util.h 查看文件

28
 #include "../inc/MarlinConfig.h"
28
 #include "../inc/MarlinConfig.h"
29
 
29
 
30
 extern bool report_tmc_status;
30
 extern bool report_tmc_status;
31
-extern char extended_axis_codes[11][3];
32
 
31
 
33
-enum TMC_AxisEnum {
34
-  TMC_X, TMC_X2, TMC_Y, TMC_Y2, TMC_Z, TMC_Z2,
35
-  TMC_E0, TMC_E1, TMC_E2, TMC_E3, TMC_E4
36
-};
32
+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 };
37
 
33
 
38
 constexpr uint32_t _tmc_thrs(const uint16_t msteps, const int32_t thrs, const uint32_t spmm) {
34
 constexpr uint32_t _tmc_thrs(const uint16_t msteps, const int32_t thrs, const uint32_t spmm) {
39
   return 12650000UL * msteps / (256 * thrs * spmm);
35
   return 12650000UL * msteps / (256 * thrs * spmm);
40
 }
36
 }
41
 
37
 
42
-void _tmc_say_current(const char name[], const uint16_t curr);
43
-void _tmc_say_otpw(const char name[], const bool otpw);
44
-void _tmc_say_otpw_cleared(const char name[]);
45
-void _tmc_say_pwmthrs(const char name[], const uint32_t thrs);
46
-void _tmc_say_sgt(const char name[], const int8_t sgt);
38
+void _tmc_say_axis(const TMC_AxisEnum axis);
39
+void _tmc_say_current(const TMC_AxisEnum axis, const uint16_t curr);
40
+void _tmc_say_otpw(const TMC_AxisEnum axis, const bool otpw);
41
+void _tmc_say_otpw_cleared(const TMC_AxisEnum axis);
42
+void _tmc_say_pwmthrs(const TMC_AxisEnum axis, const uint32_t thrs);
43
+void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt);
47
 
44
 
48
 template<typename TMC>
45
 template<typename TMC>
49
-void tmc_get_current(TMC &st, const char name[]) {
50
-  _tmc_say_current(name, st.getCurrent());
46
+void tmc_get_current(TMC &st, const TMC_AxisEnum axis) {
47
+  _tmc_say_current(axis, st.getCurrent());
51
 }
48
 }
52
 template<typename TMC>
49
 template<typename TMC>
53
-void tmc_set_current(TMC &st, const char name[], const int mA) {
50
+void tmc_set_current(TMC &st, const TMC_AxisEnum axis, const int mA) {
54
   st.setCurrent(mA, R_SENSE, HOLD_MULTIPLIER);
51
   st.setCurrent(mA, R_SENSE, HOLD_MULTIPLIER);
55
-  tmc_get_current(st, name);
52
+  tmc_get_current(st, axis);
56
 }
53
 }
57
 template<typename TMC>
54
 template<typename TMC>
58
-void tmc_report_otpw(TMC &st, const char name[]) {
59
-  _tmc_say_otpw(name, st.getOTPW());
55
+void tmc_report_otpw(TMC &st, const TMC_AxisEnum axis) {
56
+  _tmc_say_otpw(axis, st.getOTPW());
60
 }
57
 }
61
 template<typename TMC>
58
 template<typename TMC>
62
-void tmc_clear_otpw(TMC &st, const char name[]) {
59
+void tmc_clear_otpw(TMC &st, const TMC_AxisEnum axis) {
63
   st.clear_otpw();
60
   st.clear_otpw();
64
-  _tmc_say_otpw_cleared(name);
61
+  _tmc_say_otpw_cleared(axis);
65
 }
62
 }
66
 template<typename TMC>
63
 template<typename TMC>
67
-void tmc_get_pwmthrs(TMC &st, const char name[], const uint16_t spmm) {
68
-  _tmc_say_pwmthrs(name, _tmc_thrs(st.microsteps(), st.TPWMTHRS(), spmm));
64
+void tmc_get_pwmthrs(TMC &st, const TMC_AxisEnum axis, const uint16_t spmm) {
65
+  _tmc_say_pwmthrs(axis, _tmc_thrs(st.microsteps(), st.TPWMTHRS(), spmm));
69
 }
66
 }
70
 template<typename TMC>
67
 template<typename TMC>
71
-void tmc_set_pwmthrs(TMC &st, const char name[], const int32_t thrs, const uint32_t spmm) {
68
+void tmc_set_pwmthrs(TMC &st, const TMC_AxisEnum axis, const int32_t thrs, const uint32_t spmm) {
72
   st.TPWMTHRS(_tmc_thrs(st.microsteps(), thrs, spmm));
69
   st.TPWMTHRS(_tmc_thrs(st.microsteps(), thrs, spmm));
73
-  tmc_get_pwmthrs(st, name, spmm);
70
+  tmc_get_pwmthrs(st, axis, spmm);
74
 }
71
 }
75
 template<typename TMC>
72
 template<typename TMC>
76
-void tmc_get_sgt(TMC &st, const char name[]) {
77
-  _tmc_say_sgt(name, st.sgt());
73
+void tmc_get_sgt(TMC &st, const TMC_AxisEnum axis) {
74
+  _tmc_say_sgt(axis, st.sgt());
78
 }
75
 }
79
 template<typename TMC>
76
 template<typename TMC>
80
-void tmc_set_sgt(TMC &st, const char name[], const int8_t sgt_val) {
77
+void tmc_set_sgt(TMC &st, const TMC_AxisEnum axis, const int8_t sgt_val) {
81
   st.sgt(sgt_val);
78
   st.sgt(sgt_val);
82
-  tmc_get_sgt(st, name);
79
+  tmc_get_sgt(st, axis);
83
 }
80
 }
84
 
81
 
85
 void monitor_tmc_driver();
82
 void monitor_tmc_driver();

+ 1
- 1
Marlin/src/gcode/calibrate/G33.cpp 查看文件

43
 constexpr uint8_t _7P_STEP = 1,              // 7-point step - to change number of calibration points
43
 constexpr uint8_t _7P_STEP = 1,              // 7-point step - to change number of calibration points
44
                   _4P_STEP = _7P_STEP * 2,   // 4-point step
44
                   _4P_STEP = _7P_STEP * 2,   // 4-point step
45
                   NPP      = _7P_STEP * 6;   // number of calibration points on the radius
45
                   NPP      = _7P_STEP * 6;   // number of calibration points on the radius
46
-enum CalEnum {                               // the 7 main calibration points - add definitions if needed
46
+enum CalEnum : char {                               // the 7 main calibration points - add definitions if needed
47
   CEN      = 0,
47
   CEN      = 0,
48
   __A      = 1,
48
   __A      = 1,
49
   _AB      = __A + _7P_STEP,
49
   _AB      = __A + _7P_STEP,

+ 2
- 2
Marlin/src/gcode/feature/trinamic/M906.cpp 查看文件

37
   LOOP_XYZE(i) values[i] = parser.intval(axis_codes[i]);
37
   LOOP_XYZE(i) values[i] = parser.intval(axis_codes[i]);
38
 
38
 
39
   #define TMC_SET_GET_CURRENT(P,Q) do { \
39
   #define TMC_SET_GET_CURRENT(P,Q) do { \
40
-    if (values[P##_AXIS]) tmc_set_current(stepper##Q, extended_axis_codes[TMC_##Q], values[P##_AXIS]); \
41
-    else tmc_get_current(stepper##Q, extended_axis_codes[TMC_##Q]); } while(0)
40
+    if (values[P##_AXIS]) tmc_set_current(stepper##Q, TMC_##Q, values[P##_AXIS]); \
41
+    else tmc_get_current(stepper##Q, TMC_##Q); } while(0)
42
 
42
 
43
   #if X_IS_TRINAMIC
43
   #if X_IS_TRINAMIC
44
     TMC_SET_GET_CURRENT(X,X);
44
     TMC_SET_GET_CURRENT(X,X);

+ 13
- 13
Marlin/src/gcode/feature/trinamic/M911-M915.cpp 查看文件

36
  */
36
  */
37
 void GcodeSuite::M911() {
37
 void GcodeSuite::M911() {
38
   #if ENABLED(X_IS_TMC2130) || (ENABLED(X_IS_TMC2208) && PIN_EXISTS(X_SERIAL_RX)) || ENABLED(IS_TRAMS)
38
   #if ENABLED(X_IS_TMC2130) || (ENABLED(X_IS_TMC2208) && PIN_EXISTS(X_SERIAL_RX)) || ENABLED(IS_TRAMS)
39
-    tmc_report_otpw(stepperX, extended_axis_codes[TMC_X]);
39
+    tmc_report_otpw(stepperX, TMC_X);
40
   #endif
40
   #endif
41
   #if ENABLED(Y_IS_TMC2130) || (ENABLED(Y_IS_TMC2208) && PIN_EXISTS(Y_SERIAL_RX)) || ENABLED(IS_TRAMS)
41
   #if ENABLED(Y_IS_TMC2130) || (ENABLED(Y_IS_TMC2208) && PIN_EXISTS(Y_SERIAL_RX)) || ENABLED(IS_TRAMS)
42
-    tmc_report_otpw(stepperY, extended_axis_codes[TMC_Y]);
42
+    tmc_report_otpw(stepperY, TMC_Y);
43
   #endif
43
   #endif
44
   #if ENABLED(Z_IS_TMC2130) || (ENABLED(Z_IS_TMC2208) && PIN_EXISTS(Z_SERIAL_RX)) || ENABLED(IS_TRAMS)
44
   #if ENABLED(Z_IS_TMC2130) || (ENABLED(Z_IS_TMC2208) && PIN_EXISTS(Z_SERIAL_RX)) || ENABLED(IS_TRAMS)
45
-    tmc_report_otpw(stepperZ, extended_axis_codes[TMC_Z]);
45
+    tmc_report_otpw(stepperZ, TMC_Z);
46
   #endif
46
   #endif
47
   #if ENABLED(E0_IS_TMC2130) || (ENABLED(E0_IS_TMC2208) && PIN_EXISTS(E0_SERIAL_RX)) || ENABLED(IS_TRAMS)
47
   #if ENABLED(E0_IS_TMC2130) || (ENABLED(E0_IS_TMC2208) && PIN_EXISTS(E0_SERIAL_RX)) || ENABLED(IS_TRAMS)
48
-    tmc_report_otpw(stepperE0, extended_axis_codes[TMC_E0]);
48
+    tmc_report_otpw(stepperE0, TMC_E0);
49
   #endif
49
   #endif
50
 }
50
 }
51
 
51
 
56
   const bool clearX = parser.seen(axis_codes[X_AXIS]), clearY = parser.seen(axis_codes[Y_AXIS]), clearZ = parser.seen(axis_codes[Z_AXIS]), clearE = parser.seen(axis_codes[E_AXIS]),
56
   const bool clearX = parser.seen(axis_codes[X_AXIS]), clearY = parser.seen(axis_codes[Y_AXIS]), clearZ = parser.seen(axis_codes[Z_AXIS]), clearE = parser.seen(axis_codes[E_AXIS]),
57
            clearAll = (!clearX && !clearY && !clearZ && !clearE) || (clearX && clearY && clearZ && clearE);
57
            clearAll = (!clearX && !clearY && !clearZ && !clearE) || (clearX && clearY && clearZ && clearE);
58
   #if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS) || (ENABLED(X_IS_TMC2208) && PIN_EXISTS(X_SERIAL_RX))
58
   #if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS) || (ENABLED(X_IS_TMC2208) && PIN_EXISTS(X_SERIAL_RX))
59
-    if (clearX || clearAll) tmc_clear_otpw(stepperX, extended_axis_codes[TMC_X]);
59
+    if (clearX || clearAll) tmc_clear_otpw(stepperX, TMC_X);
60
   #endif
60
   #endif
61
   #if ENABLED(X2_IS_TMC2130) || (ENABLED(X2_IS_TMC2208) && PIN_EXISTS(X_SERIAL_RX))
61
   #if ENABLED(X2_IS_TMC2130) || (ENABLED(X2_IS_TMC2208) && PIN_EXISTS(X_SERIAL_RX))
62
-    if (clearX || clearAll) tmc_clear_otpw(stepperX, extended_axis_codes[TMC_X]);
62
+    if (clearX || clearAll) tmc_clear_otpw(stepperX, TMC_X);
63
   #endif
63
   #endif
64
 
64
 
65
   #if ENABLED(Y_IS_TMC2130) || (ENABLED(Y_IS_TMC2208) && PIN_EXISTS(Y_SERIAL_RX))
65
   #if ENABLED(Y_IS_TMC2130) || (ENABLED(Y_IS_TMC2208) && PIN_EXISTS(Y_SERIAL_RX))
66
-    if (clearY || clearAll) tmc_clear_otpw(stepperY, extended_axis_codes[TMC_Y]);
66
+    if (clearY || clearAll) tmc_clear_otpw(stepperY, TMC_Y);
67
   #endif
67
   #endif
68
 
68
 
69
   #if ENABLED(Z_IS_TMC2130) || (ENABLED(Z_IS_TMC2208) && PIN_EXISTS(Z_SERIAL_RX))
69
   #if ENABLED(Z_IS_TMC2130) || (ENABLED(Z_IS_TMC2208) && PIN_EXISTS(Z_SERIAL_RX))
70
-    if (clearZ || clearAll) tmc_clear_otpw(stepperZ, extended_axis_codes[TMC_Z]);
70
+    if (clearZ || clearAll) tmc_clear_otpw(stepperZ, TMC_Z);
71
   #endif
71
   #endif
72
 
72
 
73
   #if ENABLED(E0_IS_TMC2130) || (ENABLED(E0_IS_TMC2208) && PIN_EXISTS(E0_SERIAL_RX))
73
   #if ENABLED(E0_IS_TMC2130) || (ENABLED(E0_IS_TMC2208) && PIN_EXISTS(E0_SERIAL_RX))
74
-    if (clearE || clearAll) tmc_clear_otpw(stepperE0, extended_axis_codes[TMC_E0]);
74
+    if (clearE || clearAll) tmc_clear_otpw(stepperE0, TMC_E0);
75
   #endif
75
   #endif
76
 }
76
 }
77
 
77
 
84
     LOOP_XYZE(i) values[i] = parser.intval(axis_codes[i]);
84
     LOOP_XYZE(i) values[i] = parser.intval(axis_codes[i]);
85
 
85
 
86
     #define TMC_SET_GET_PWMTHRS(P,Q) do { \
86
     #define TMC_SET_GET_PWMTHRS(P,Q) do { \
87
-      if (values[P##_AXIS]) tmc_set_pwmthrs(stepper##Q, extended_axis_codes[TMC_##Q], values[P##_AXIS], planner.axis_steps_per_mm[P##_AXIS]); \
88
-      else tmc_get_pwmthrs(stepper##Q, extended_axis_codes[TMC_##Q], planner.axis_steps_per_mm[P##_AXIS]); } while(0)
87
+      if (values[P##_AXIS]) tmc_set_pwmthrs(stepper##Q, TMC_##Q, values[P##_AXIS], planner.axis_steps_per_mm[P##_AXIS]); \
88
+      else tmc_get_pwmthrs(stepper##Q, TMC_##Q, planner.axis_steps_per_mm[P##_AXIS]); } while(0)
89
 
89
 
90
     #if X_IS_TRINAMIC
90
     #if X_IS_TRINAMIC
91
       TMC_SET_GET_PWMTHRS(X,X);
91
       TMC_SET_GET_PWMTHRS(X,X);
129
 #if ENABLED(SENSORLESS_HOMING)
129
 #if ENABLED(SENSORLESS_HOMING)
130
   void GcodeSuite::M914() {
130
   void GcodeSuite::M914() {
131
     #define TMC_SET_GET_SGT(P,Q) do { \
131
     #define TMC_SET_GET_SGT(P,Q) do { \
132
-      if (parser.seen(axis_codes[P##_AXIS])) tmc_set_sgt(stepper##Q, extended_axis_codes[TMC_##Q], parser.value_int()); \
133
-      else tmc_get_sgt(stepper##Q, extended_axis_codes[TMC_##Q]); } while(0)
132
+      if (parser.seen(axis_codes[P##_AXIS])) tmc_set_sgt(stepper##Q, TMC_##Q, parser.value_int()); \
133
+      else tmc_get_sgt(stepper##Q, TMC_##Q); } while(0)
134
 
134
 
135
     #ifdef X_HOMING_SENSITIVITY
135
     #ifdef X_HOMING_SENSITIVITY
136
       #if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS)
136
       #if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS)

+ 2
- 2
Marlin/src/gcode/gcode.h 查看文件

267
      * Workspace planes only apply to G2/G3 moves
267
      * Workspace planes only apply to G2/G3 moves
268
      * (and "canned cycles" - not a current feature)
268
      * (and "canned cycles" - not a current feature)
269
      */
269
      */
270
-    enum WorkspacePlane { PLANE_XY, PLANE_ZX, PLANE_YZ };
270
+    enum WorkspacePlane : char { PLANE_XY, PLANE_ZX, PLANE_YZ };
271
     static WorkspacePlane workspace_plane;
271
     static WorkspacePlane workspace_plane;
272
   #endif
272
   #endif
273
 
273
 
304
      * States for managing Marlin and host communication
304
      * States for managing Marlin and host communication
305
      * Marlin sends messages if blocked or busy
305
      * Marlin sends messages if blocked or busy
306
      */
306
      */
307
-    enum MarlinBusyState {
307
+    enum MarlinBusyState : char {
308
       NOT_BUSY,           // Not in a handler
308
       NOT_BUSY,           // Not in a handler
309
       IN_HANDLER,         // Processing a GCode
309
       IN_HANDLER,         // Processing a GCode
310
       IN_PROCESS,         // Known to be blocking command input (as in G29)
310
       IN_PROCESS,         // Known to be blocking command input (as in G29)

+ 1
- 1
Marlin/src/libs/stopwatch.h 查看文件

36
  */
36
  */
37
 class Stopwatch {
37
 class Stopwatch {
38
   private:
38
   private:
39
-    enum State {
39
+    enum State : char {
40
       STOPPED,
40
       STOPPED,
41
       RUNNING,
41
       RUNNING,
42
       PAUSED
42
       PAUSED

+ 1
- 1
Marlin/src/module/endstops.h 查看文件

30
 #include "../inc/MarlinConfig.h"
30
 #include "../inc/MarlinConfig.h"
31
 #include <stdint.h>
31
 #include <stdint.h>
32
 
32
 
33
-enum EndstopEnum {
33
+enum EndstopEnum : char {
34
   X_MIN,
34
   X_MIN,
35
   Y_MIN,
35
   Y_MIN,
36
   Z_MIN,
36
   Z_MIN,

+ 2
- 2
Marlin/src/module/motion.h 查看文件

288
  */
288
  */
289
 #if ENABLED(DUAL_X_CARRIAGE)
289
 #if ENABLED(DUAL_X_CARRIAGE)
290
 
290
 
291
-  enum DualXMode {
291
+  enum DualXMode : char {
292
     DXC_FULL_CONTROL_MODE,  // DUAL_X_CARRIAGE only
292
     DXC_FULL_CONTROL_MODE,  // DUAL_X_CARRIAGE only
293
     DXC_AUTO_PARK_MODE,     // DUAL_X_CARRIAGE only
293
     DXC_AUTO_PARK_MODE,     // DUAL_X_CARRIAGE only
294
     DXC_DUPLICATION_MODE
294
     DXC_DUPLICATION_MODE
308
 
308
 
309
 #elif ENABLED(DUAL_NOZZLE_DUPLICATION_MODE)
309
 #elif ENABLED(DUAL_NOZZLE_DUPLICATION_MODE)
310
 
310
 
311
-  enum DualXMode {
311
+  enum DualXMode : char {
312
     DXC_DUPLICATION_MODE = 2
312
     DXC_DUPLICATION_MODE = 2
313
   };
313
   };
314
 
314
 

+ 2
- 2
Marlin/src/module/planner.h 查看文件

44
   #include "../libs/vector_3.h"
44
   #include "../libs/vector_3.h"
45
 #endif
45
 #endif
46
 
46
 
47
-enum BlockFlagBit {
47
+enum BlockFlagBit : char {
48
   // Recalculate trapezoids on entry junction. For optimization.
48
   // Recalculate trapezoids on entry junction. For optimization.
49
   BLOCK_BIT_RECALCULATE,
49
   BLOCK_BIT_RECALCULATE,
50
 
50
 
60
   BLOCK_BIT_CONTINUED
60
   BLOCK_BIT_CONTINUED
61
 };
61
 };
62
 
62
 
63
-enum BlockFlag {
63
+enum BlockFlag : char {
64
   BLOCK_FLAG_RECALCULATE          = _BV(BLOCK_BIT_RECALCULATE),
64
   BLOCK_FLAG_RECALCULATE          = _BV(BLOCK_BIT_RECALCULATE),
65
   BLOCK_FLAG_NOMINAL_LENGTH       = _BV(BLOCK_BIT_NOMINAL_LENGTH),
65
   BLOCK_FLAG_NOMINAL_LENGTH       = _BV(BLOCK_BIT_NOMINAL_LENGTH),
66
   BLOCK_FLAG_BUSY                 = _BV(BLOCK_BIT_BUSY),
66
   BLOCK_FLAG_BUSY                 = _BV(BLOCK_BIT_BUSY),

+ 2
- 2
Marlin/src/module/temperature.h 查看文件

49
 /**
49
 /**
50
  * States for ADC reading in the ISR
50
  * States for ADC reading in the ISR
51
  */
51
  */
52
-enum ADCSensorState {
52
+enum ADCSensorState : char {
53
   #if HAS_TEMP_0
53
   #if HAS_TEMP_0
54
     PrepareTemp_0,
54
     PrepareTemp_0,
55
     MeasureTemp_0,
55
     MeasureTemp_0,
610
 
610
 
611
     #if ENABLED(THERMAL_PROTECTION_HOTENDS) || HAS_THERMALLY_PROTECTED_BED
611
     #if ENABLED(THERMAL_PROTECTION_HOTENDS) || HAS_THERMALLY_PROTECTED_BED
612
 
612
 
613
-      typedef enum TRState { TRInactive, TRFirstHeating, TRStable, TRRunaway } TRstate;
613
+      typedef enum TRState : char { TRInactive, TRFirstHeating, TRStable, TRRunaway } TRstate;
614
 
614
 
615
       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);
615
       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);
616
 
616
 

Loading…
取消
儲存