1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-27 13:56:24 +00:00

🎨 Macros for optional arguments (#21969)

This commit is contained in:
Scott Lahteine 2021-05-23 21:33:22 -05:00 committed by Scott Lahteine
parent 61f2bb1228
commit e75c3b6c54
28 changed files with 120 additions and 351 deletions

View File

@ -195,6 +195,11 @@
#define __TERN(T,V...) ___TERN(_CAT(_NO,T),V) // Prepend '_NO' to get '_NOT_0' or '_NOT_1' #define __TERN(T,V...) ___TERN(_CAT(_NO,T),V) // Prepend '_NO' to get '_NOT_0' or '_NOT_1'
#define ___TERN(P,V...) THIRD(P,V) // If first argument has a comma, A. Else B. #define ___TERN(P,V...) THIRD(P,V) // If first argument has a comma, A. Else B.
#define _OPTARG(A) , A
#define OPTARG(O,A) TERN_(O,DEFER4(_OPTARG)(A))
#define _OPTCODE(A) A;
#define OPTCODE(O,A) TERN_(O,DEFER4(_OPTCODE)(A))
// Macros to avoid 'f + 0.0' which is not always optimized away. Minus included for symmetry. // Macros to avoid 'f + 0.0' which is not always optimized away. Minus included for symmetry.
// Compiler flags -fno-signed-zeros -ffinite-math-only also cover 'f * 1.0', 'f - f', etc. // Compiler flags -fno-signed-zeros -ffinite-math-only also cover 'f * 1.0', 'f - f', etc.
#define PLUS_TERN0(O,A) _TERN(_ENA_1(O),,+ (A)) // OPTION ? '+ (A)' : '<nul>' #define PLUS_TERN0(O,A) _TERN(_ENA_1(O),,+ (A)) // OPTION ? '+ (A)' : '<nul>'

View File

@ -103,9 +103,7 @@ public:
} }
static float get_z(const xy_pos_t &pos static float get_z(const xy_pos_t &pos
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) OPTARG(ENABLE_LEVELING_FADE_HEIGHT, const_float_t factor=1.0f)
, const_float_t factor=1.0f
#endif
) { ) {
#if DISABLED(ENABLE_LEVELING_FADE_HEIGHT) #if DISABLED(ENABLE_LEVELING_FADE_HEIGHT)
constexpr float factor = 1.0f; constexpr float factor = 1.0f;

View File

@ -362,15 +362,11 @@
while (--segments) { while (--segments) {
raw += diff; raw += diff;
planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, segment_xyz_mm planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, segment_xyz_mm
#if ENABLED(SCARA_FEEDRATE_SCALING) OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)
, inv_duration
#endif
); );
} }
planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, segment_xyz_mm planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, segment_xyz_mm
#if ENABLED(SCARA_FEEDRATE_SCALING) OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)
, inv_duration
#endif
); );
return false; // Did not set current from destination return false; // Did not set current from destination
} }

View File

@ -41,7 +41,7 @@ bool CaseLight::on = CASE_LIGHT_DEFAULT_ON;
#if CASE_LIGHT_IS_COLOR_LED #if CASE_LIGHT_IS_COLOR_LED
#include "leds/leds.h" #include "leds/leds.h"
constexpr uint8_t init_case_light[] = CASE_LIGHT_DEFAULT_COLOR; constexpr uint8_t init_case_light[] = CASE_LIGHT_DEFAULT_COLOR;
LEDColor CaseLight::color = { init_case_light[0], init_case_light[1], init_case_light[2], TERN_(HAS_WHITE_LED, init_case_light[3]) }; LEDColor CaseLight::color = { init_case_light[0], init_case_light[1], init_case_light[2] OPTARG(HAS_WHITE_LED, init_case_light[3]) };
#endif #endif
void CaseLight::update(const bool sflag) { void CaseLight::update(const bool sflag) {

View File

@ -91,11 +91,7 @@ void FWRetract::reset() {
* Note: Auto-retract will apply the set Z hop in addition to any Z hop * Note: Auto-retract will apply the set Z hop in addition to any Z hop
* included in the G-code. Use M207 Z0 to to prevent double hop. * included in the G-code. Use M207 Z0 to to prevent double hop.
*/ */
void FWRetract::retract(const bool retracting void FWRetract::retract(const bool retracting OPTARG(HAS_MULTI_EXTRUDER, bool swapping/*=false*/)) {
#if HAS_MULTI_EXTRUDER
, bool swapping/*=false*/
#endif
) {
// Prevent two retracts or recovers in a row // Prevent two retracts or recovers in a row
if (retracted[active_extruder] == retracting) return; if (retracted[active_extruder] == retracting) return;

View File

@ -74,11 +74,7 @@ public:
#endif #endif
} }
static void retract(const bool retracting static void retract(const bool retracting OPTARG(HAS_MULTI_EXTRUDER, bool swapping = false));
#if HAS_MULTI_EXTRUDER
, bool swapping = false
#endif
);
static void M207(); static void M207();
static void M207_report(const bool forReplay=false); static void M207_report(const bool forReplay=false);

View File

@ -75,9 +75,7 @@ void LEDLights::setup() {
} }
void LEDLights::set_color(const LEDColor &incol void LEDLights::set_color(const LEDColor &incol
#if ENABLED(NEOPIXEL_LED) OPTARG(NEOPIXEL_LED, bool isSequence/*=false*/)
, bool isSequence/*=false*/
#endif
) { ) {
#if ENABLED(NEOPIXEL_LED) #if ENABLED(NEOPIXEL_LED)

View File

@ -43,46 +43,21 @@
*/ */
typedef struct LEDColor { typedef struct LEDColor {
uint8_t r, g, b uint8_t r, g, b
#if HAS_WHITE_LED OPTARG(HAS_WHITE_LED, w)
, w OPTARG(NEOPIXEL_LED, i)
#if ENABLED(NEOPIXEL_LED)
, i
#endif
#endif
; ;
LEDColor() : r(255), g(255), b(255) LEDColor() : r(255), g(255), b(255)
#if HAS_WHITE_LED OPTARG(HAS_WHITE_LED, w(255))
, w(255) OPTARG(NEOPIXEL_LED, i(NEOPIXEL_BRIGHTNESS))
#if ENABLED(NEOPIXEL_LED)
, i(NEOPIXEL_BRIGHTNESS)
#endif
#endif
{} {}
LEDColor(uint8_t r, uint8_t g, uint8_t b LEDColor(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED, uint8_t w=0) OPTARG(NEOPIXEL_LED, uint8_t i=NEOPIXEL_BRIGHTNESS))
#if HAS_WHITE_LED : r(r), g(g), b(b) OPTARG(HAS_WHITE_LED, w(w)) OPTARG(NEOPIXEL_LED, i(i)) {}
, uint8_t w=0
#if ENABLED(NEOPIXEL_LED)
, uint8_t i=NEOPIXEL_BRIGHTNESS
#endif
#endif
) : r(r), g(g), b(b)
#if HAS_WHITE_LED
, w(w)
#if ENABLED(NEOPIXEL_LED)
, i(i)
#endif
#endif
{}
LEDColor(const uint8_t (&rgbw)[4]) : r(rgbw[0]), g(rgbw[1]), b(rgbw[2]) LEDColor(const uint8_t (&rgbw)[4]) : r(rgbw[0]), g(rgbw[1]), b(rgbw[2])
#if HAS_WHITE_LED OPTARG(HAS_WHITE_LED, w(rgbw[3]))
, w(rgbw[3]) OPTARG(NEOPIXEL_LED, i(NEOPIXEL_BRIGHTNESS))
#if ENABLED(NEOPIXEL_LED)
, i(NEOPIXEL_BRIGHTNESS)
#endif
#endif
{} {}
LEDColor& operator=(const uint8_t (&rgbw)[4]) { LEDColor& operator=(const uint8_t (&rgbw)[4]) {
@ -111,15 +86,7 @@ typedef struct LEDColor {
/** /**
* Color helpers and presets * Color helpers and presets
*/ */
#if HAS_WHITE_LED #define MakeLEDColor(R,G,B,W,I) LEDColor(R, G, B OPTARG(HAS_WHITE_LED, W) OPTARG(NEOPIXEL_LED, I))
#if ENABLED(NEOPIXEL_LED)
#define MakeLEDColor(R,G,B,W,I) LEDColor(R, G, B, W, I)
#else
#define MakeLEDColor(R,G,B,W,I) LEDColor(R, G, B, W)
#endif
#else
#define MakeLEDColor(R,G,B,W,I) LEDColor(R, G, B)
#endif
#define LEDColorOff() LEDColor( 0, 0, 0) #define LEDColorOff() LEDColor( 0, 0, 0)
#define LEDColorRed() LEDColor(255, 0, 0) #define LEDColorRed() LEDColor(255, 0, 0)
@ -147,25 +114,15 @@ public:
static void setup(); // init() static void setup(); // init()
static void set_color(const LEDColor &color static void set_color(const LEDColor &color
#if ENABLED(NEOPIXEL_LED) OPTARG(NEOPIXEL_LED, bool isSequence=false)
, bool isSequence=false
#endif
); );
static inline void set_color(uint8_t r, uint8_t g, uint8_t b static inline void set_color(uint8_t r, uint8_t g, uint8_t b
#if HAS_WHITE_LED OPTARG(HAS_WHITE_LED, uint8_t w=0)
, uint8_t w=0 OPTARG(NEOPIXEL_LED, uint8_t i=NEOPIXEL_BRIGHTNESS)
#endif OPTARG(NEOPIXEL_LED, bool isSequence=false)
#if ENABLED(NEOPIXEL_LED)
, uint8_t i=NEOPIXEL_BRIGHTNESS
, bool isSequence=false
#endif
) { ) {
set_color(MakeLEDColor(r, g, b, w, i) set_color(MakeLEDColor(r, g, b, w, i) OPTARG(NEOPIXEL_LED, isSequence));
#if ENABLED(NEOPIXEL_LED)
, isSequence
#endif
);
} }
static inline void set_off() { set_color(LEDColorOff()); } static inline void set_off() { set_color(LEDColorOff()); }

View File

@ -93,9 +93,7 @@ static void PCA9632_WriteRegister(const byte addr, const byte regadd, const byte
} }
static void PCA9632_WriteAllRegisters(const byte addr, const byte regadd, const byte vr, const byte vg, const byte vb static void PCA9632_WriteAllRegisters(const byte addr, const byte regadd, const byte vr, const byte vg, const byte vb
#if ENABLED(PCA9632_RGBW) OPTARG(PCA9632_RGBW, const byte vw)
, const byte vw
#endif
) { ) {
#if DISABLED(PCA9632_NO_AUTO_INC) #if DISABLED(PCA9632_NO_AUTO_INC)
uint8_t data[4]; uint8_t data[4];
@ -143,9 +141,7 @@ void PCA9632_set_led_color(const LEDColor &color) {
; ;
PCA9632_WriteAllRegisters(PCA9632_ADDRESS,PCA9632_PWM0, color.r, color.g, color.b PCA9632_WriteAllRegisters(PCA9632_ADDRESS,PCA9632_PWM0, color.r, color.g, color.b
#if ENABLED(PCA9632_RGBW) OPTARG(PCA9632_RGBW, color.w)
, color.w
#endif
); );
PCA9632_WriteRegister(PCA9632_ADDRESS,PCA9632_LEDOUT, LEDOUT); PCA9632_WriteRegister(PCA9632_ADDRESS,PCA9632_LEDOUT, LEDOUT);
} }

View File

@ -70,15 +70,9 @@ class TMCStorage {
} }
struct { struct {
#if ENABLED(HAS_STEALTHCHOP) OPTCODE(HAS_STEALTHCHOP, bool stealthChop_enabled = false)
bool stealthChop_enabled = false; OPTCODE(HYBRID_THRESHOLD, uint8_t hybrid_thrs = 0)
#endif OPTCODE(USE_SENSORLESS, int16_t homing_thrs = 0)
#if ENABLED(HYBRID_THRESHOLD)
uint8_t hybrid_thrs = 0;
#endif
#if ENABLED(USE_SENSORLESS)
int16_t homing_thrs = 0;
#endif
} stored; } stored;
}; };

View File

@ -330,12 +330,8 @@ typedef struct {
thermalManager.setTargetBed(bed_temp); thermalManager.setTargetBed(bed_temp);
// Wait for the temperature to stabilize // Wait for the temperature to stabilize
if (!thermalManager.wait_for_bed(true if (!thermalManager.wait_for_bed(true OPTARG(G26_CLICK_CAN_CANCEL, true)))
#if G26_CLICK_CAN_CANCEL return G26_ERR;
, true
#endif
)
) return G26_ERR;
} }
#else #else
@ -352,11 +348,8 @@ typedef struct {
thermalManager.setTargetHotend(hotend_temp, active_extruder); thermalManager.setTargetHotend(hotend_temp, active_extruder);
// Wait for the temperature to stabilize // Wait for the temperature to stabilize
if (!thermalManager.wait_for_hotend(active_extruder, true if (!thermalManager.wait_for_hotend(active_extruder, true OPTARG(G26_CLICK_CAN_CANCEL, true)))
#if G26_CLICK_CAN_CANCEL return G26_ERR;
, true
#endif
)) return G26_ERR;
#if HAS_WIRED_LCD #if HAS_WIRED_LCD
ui.reset_status(); ui.reset_status();

View File

@ -249,9 +249,7 @@ void plan_arc(
#endif #endif
if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, 0 if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, 0
#if ENABLED(SCARA_FEEDRATE_SCALING) OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)
, inv_duration
#endif
)) break; )) break;
} }
@ -266,9 +264,7 @@ void plan_arc(
#endif #endif
planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, 0 planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, 0
#if ENABLED(SCARA_FEEDRATE_SCALING) OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)
, inv_duration
#endif
); );
TERN_(AUTO_BED_LEVELING_UBL, raw[l_axis] = start_L); TERN_(AUTO_BED_LEVELING_UBL, raw[l_axis] = start_L);

View File

@ -84,9 +84,7 @@ char GCodeQueue::injected_commands[64]; // = { 0 }
void GCodeQueue::RingBuffer::commit_command(bool skip_ok void GCodeQueue::RingBuffer::commit_command(bool skip_ok
#if HAS_MULTI_SERIAL OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind/*=-1*/)
, serial_index_t serial_ind/*=-1*/
#endif
) { ) {
commands[index_w].skip_ok = skip_ok; commands[index_w].skip_ok = skip_ok;
TERN_(HAS_MULTI_SERIAL, commands[index_w].port = serial_ind); TERN_(HAS_MULTI_SERIAL, commands[index_w].port = serial_ind);
@ -100,9 +98,7 @@ void GCodeQueue::RingBuffer::commit_command(bool skip_ok
* Return false for a full buffer, or if the 'command' is a comment. * Return false for a full buffer, or if the 'command' is a comment.
*/ */
bool GCodeQueue::RingBuffer::enqueue(const char *cmd, bool skip_ok/*=true*/ bool GCodeQueue::RingBuffer::enqueue(const char *cmd, bool skip_ok/*=true*/
#if HAS_MULTI_SERIAL OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind/*=-1*/)
, serial_index_t serial_ind/*=-1*/
#endif
) { ) {
if (*cmd == ';' || length >= BUFSIZE) return false; if (*cmd == ';' || length >= BUFSIZE) return false;
strcpy(commands[index_w].buffer, cmd); strcpy(commands[index_w].buffer, cmd);

View File

@ -80,15 +80,11 @@ public:
void advance_pos(uint8_t &p, const int inc) { if (++p >= BUFSIZE) p = 0; length += inc; } void advance_pos(uint8_t &p, const int inc) { if (++p >= BUFSIZE) p = 0; length += inc; }
void commit_command(bool skip_ok void commit_command(bool skip_ok
#if HAS_MULTI_SERIAL OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind = serial_index_t())
, serial_index_t serial_ind = serial_index_t()
#endif
); );
bool enqueue(const char *cmd, bool skip_ok = true bool enqueue(const char *cmd, bool skip_ok = true
#if HAS_MULTI_SERIAL OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind = serial_index_t())
, serial_index_t serial_ind = serial_index_t()
#endif
); );
void ok_to_send(); void ok_to_send();

View File

@ -758,13 +758,9 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) {
// Tell ui.update() to start a move to current_position after a short delay. // Tell ui.update() to start a move to current_position after a short delay.
// //
void ManualMove::soon(const AxisEnum move_axis void ManualMove::soon(const AxisEnum move_axis
#if MULTI_E_MANUAL OPTARG(MULTI_E_MANUAL, const int8_t eindex/*=active_extruder*/)
, const int8_t eindex/*=-1*/
#endif
) { ) {
#if MULTI_E_MANUAL TERN_(MULTI_E_MANUAL, if (move_axis == E_AXIS) e_index = eindex);
if (move_axis == E_AXIS) e_index = eindex >= 0 ? eindex : active_extruder;
#endif
start_time = millis() + (menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves start_time = millis() + (menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves
axis = move_axis; axis = move_axis;
//SERIAL_ECHOLNPAIR("Post Move with Axis ", AS_CHAR(axis_codes[axis]), " soon."); //SERIAL_ECHOLNPAIR("Post Move with Axis ", AS_CHAR(axis_codes[axis]), " soon.");

View File

@ -182,11 +182,7 @@
static bool constexpr processing = false; static bool constexpr processing = false;
#endif #endif
static void task(); static void task();
static void soon(const AxisEnum axis static void soon(const AxisEnum axis OPTARG(MULTI_E_MANUAL, const int8_t eindex=active_extruder));
#if MULTI_E_MANUAL
, const int8_t eindex=-1
#endif
);
}; };
#endif #endif

View File

@ -94,17 +94,13 @@ void lcd_move_z() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_Z), Z_AXIS); }
#if E_MANUAL #if E_MANUAL
static void lcd_move_e(TERN_(MULTI_E_MANUAL, const int8_t eindex=-1)) { static void lcd_move_e(TERN_(MULTI_E_MANUAL, const int8_t eindex=active_extruder)) {
if (ui.use_click()) return ui.goto_previous_screen_no_defer(); if (ui.use_click()) return ui.goto_previous_screen_no_defer();
if (ui.encoderPosition) { if (ui.encoderPosition) {
if (!ui.manual_move.processing) { if (!ui.manual_move.processing) {
const float diff = float(int32_t(ui.encoderPosition)) * ui.manual_move.menu_scale; const float diff = float(int32_t(ui.encoderPosition)) * ui.manual_move.menu_scale;
TERN(IS_KINEMATIC, ui.manual_move.offset, current_position.e) += diff; TERN(IS_KINEMATIC, ui.manual_move.offset, current_position.e) += diff;
ui.manual_move.soon(E_AXIS ui.manual_move.soon(E_AXIS OPTARG(MULTI_E_MANUAL, eindex));
#if MULTI_E_MANUAL
, eindex
#endif
);
ui.refresh(LCDVIEW_REDRAW_NOW); ui.refresh(LCDVIEW_REDRAW_NOW);
} }
ui.encoderPosition = 0; ui.encoderPosition = 0;
@ -139,7 +135,7 @@ void _goto_manual_move(const_float_t scale) {
ui.goto_screen(_manual_move_func_ptr); ui.goto_screen(_manual_move_func_ptr);
} }
void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int8_t eindex=-1) { void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int8_t eindex=active_extruder) {
_manual_move_func_ptr = func; _manual_move_func_ptr = func;
START_MENU(); START_MENU();
if (LCD_HEIGHT >= 4) { if (LCD_HEIGHT >= 4) {
@ -188,7 +184,7 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int
#if E_MANUAL #if E_MANUAL
inline void _goto_menu_move_distance_e() { inline void _goto_menu_move_distance_e() {
ui.goto_screen([]{ _menu_move_distance(E_AXIS, []{ lcd_move_e(TERN_(MULTI_E_MANUAL, active_extruder)); }, -1); }); ui.goto_screen([]{ _menu_move_distance(E_AXIS, []{ lcd_move_e(); }); });
} }
inline void _menu_move_distance_e_maybe() { inline void _menu_move_distance_e_maybe() {

View File

@ -724,11 +724,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
drawMessage(msg); drawMessage(msg);
#endif #endif
ui.manual_move.soon(axis ui.manual_move.soon(axis OPTARG(MULTI_E_MANUAL, motionAxisState.e_selection));
#if MULTI_E_MANUAL
, motionAxisState.e_selection
#endif
);
} }
drawAxisValue(axis); drawAxisValue(axis);

View File

@ -709,11 +709,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
drawMessage(msg); drawMessage(msg);
#endif #endif
ui.manual_move.soon(axis ui.manual_move.soon(axis OPTARG(MULTI_E_MANUAL, motionAxisState.e_selection));
#if MULTI_E_MANUAL
, motionAxisState.e_selection
#endif
);
} }
drawAxisValue(axis); drawAxisValue(axis);

View File

@ -711,11 +711,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
drawMessage(msg); drawMessage(msg);
#endif #endif
ui.manual_move.soon(axis ui.manual_move.soon(axis OPTARG(MULTI_E_MANUAL, motionAxisState.e_selection));
#if MULTI_E_MANUAL
, motionAxisState.e_selection
#endif
);
} }
drawAxisValue(axis); drawAxisValue(axis);

View File

@ -411,9 +411,7 @@ void line_to_current_position(const_feedRate_t fr_mm_s/*=feedrate_mm_s*/) {
* - Extrude the specified length regardless of flow percentage. * - Extrude the specified length regardless of flow percentage.
*/ */
void _internal_move_to_destination(const_feedRate_t fr_mm_s/*=0.0f*/ void _internal_move_to_destination(const_feedRate_t fr_mm_s/*=0.0f*/
#if IS_KINEMATIC OPTARG(IS_KINEMATIC, const bool is_fast/*=false*/)
, const bool is_fast/*=false*/
#endif
) { ) {
const feedRate_t old_feedrate = feedrate_mm_s; const feedRate_t old_feedrate = feedrate_mm_s;
if (fr_mm_s) feedrate_mm_s = fr_mm_s; if (fr_mm_s) feedrate_mm_s = fr_mm_s;
@ -433,9 +431,7 @@ void _internal_move_to_destination(const_feedRate_t fr_mm_s/*=0.0f*/
feedrate_mm_s = old_feedrate; feedrate_mm_s = old_feedrate;
feedrate_percentage = old_pct; feedrate_percentage = old_pct;
#if HAS_EXTRUDERS TERN_(HAS_EXTRUDERS, planner.e_factor[active_extruder] = old_fac);
planner.e_factor[active_extruder] = old_fac;
#endif
} }
/** /**
@ -607,10 +603,8 @@ void restore_feedrate_and_scaling() {
* at the same positions relative to the machine. * at the same positions relative to the machine.
*/ */
void update_software_endstops(const AxisEnum axis void update_software_endstops(const AxisEnum axis
#if HAS_HOTEND_OFFSET OPTARG(HAS_HOTEND_OFFSET, const uint8_t old_tool_index/*=0*/)
, const uint8_t old_tool_index/*=0*/ OPTARG(HAS_HOTEND_OFFSET, const uint8_t new_tool_index/*=0*/)
, const uint8_t new_tool_index/*=0*/
#endif
) { ) {
#if ENABLED(DUAL_X_CARRIAGE) #if ENABLED(DUAL_X_CARRIAGE)
@ -858,17 +852,13 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) {
segment_idle(next_idle_ms); segment_idle(next_idle_ms);
raw += segment_distance; raw += segment_distance;
if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, cartesian_segment_mm if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, cartesian_segment_mm
#if ENABLED(SCARA_FEEDRATE_SCALING) OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)
, inv_duration
#endif
)) break; )) break;
} }
// Ensure last segment arrives at target location. // Ensure last segment arrives at target location.
planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, cartesian_segment_mm planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, cartesian_segment_mm
#if ENABLED(SCARA_FEEDRATE_SCALING) OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)
, inv_duration
#endif
); );
return false; // caller will update current_position return false; // caller will update current_position
@ -929,9 +919,7 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) {
segment_idle(next_idle_ms); segment_idle(next_idle_ms);
raw += segment_distance; raw += segment_distance;
if (!planner.buffer_line(raw, fr_mm_s, active_extruder, cartesian_segment_mm if (!planner.buffer_line(raw, fr_mm_s, active_extruder, cartesian_segment_mm
#if ENABLED(SCARA_FEEDRATE_SCALING) OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)
, inv_duration
#endif
)) break; )) break;
} }

View File

@ -278,11 +278,7 @@ void line_to_current_position(const_feedRate_t fr_mm_s=feedrate_mm_s);
void prepare_line_to_destination(); void prepare_line_to_destination();
void _internal_move_to_destination(const_feedRate_t fr_mm_s=0.0f void _internal_move_to_destination(const_feedRate_t fr_mm_s=0.0f OPTARG(IS_KINEMATIC, const bool is_fast=false));
#if IS_KINEMATIC
, const bool is_fast=false
#endif
);
inline void prepare_internal_move_to_destination(const_feedRate_t fr_mm_s=0.0f) { inline void prepare_internal_move_to_destination(const_feedRate_t fr_mm_s=0.0f) {
_internal_move_to_destination(fr_mm_s); _internal_move_to_destination(fr_mm_s);

View File

@ -1757,12 +1757,8 @@ void Planner::synchronize() {
* Returns true if movement was properly queued, false otherwise (if cleaning) * Returns true if movement was properly queued, false otherwise (if cleaning)
*/ */
bool Planner::_buffer_steps(const xyze_long_t &target bool Planner::_buffer_steps(const xyze_long_t &target
#if HAS_POSITION_FLOAT OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float)
, const xyze_pos_t &target_float OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm)
#endif
#if HAS_DIST_MM_ARG
, const xyze_float_t &cart_dist_mm
#endif
, feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters
) { ) {
@ -1823,12 +1819,8 @@ bool Planner::_buffer_steps(const xyze_long_t &target
*/ */
bool Planner::_populate_block(block_t * const block, bool split_move, bool Planner::_populate_block(block_t * const block, bool split_move,
const abce_long_t &target const abce_long_t &target
#if HAS_POSITION_FLOAT OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float)
, const xyze_pos_t &target_float OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm)
#endif
#if HAS_DIST_MM_ARG
, const xyze_float_t &cart_dist_mm
#endif
, feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters/*=0.0*/ , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters/*=0.0*/
) { ) {
@ -2763,9 +2755,7 @@ void Planner::buffer_sync_block(TERN_(LASER_SYNCHRONOUS_M106_M107, uint8_t sync_
* Return 'false' if no segment was queued due to cleaning, cold extrusion, full queue, etc. * Return 'false' if no segment was queued due to cleaning, cold extrusion, full queue, etc.
*/ */
bool Planner::buffer_segment(const_float_t a, const_float_t b, const_float_t c, const_float_t e bool Planner::buffer_segment(const_float_t a, const_float_t b, const_float_t c, const_float_t e
#if HAS_DIST_MM_ARG OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm)
, const xyze_float_t &cart_dist_mm
#endif
, const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters/*=0.0*/ , const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters/*=0.0*/
) { ) {
@ -2857,9 +2847,7 @@ bool Planner::buffer_segment(const_float_t a, const_float_t b, const_float_t c,
* inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled) * inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled)
*/ */
bool Planner::buffer_line(const_float_t rx, const_float_t ry, const_float_t rz, const_float_t e, const_feedRate_t fr_mm_s, const uint8_t extruder, const float millimeters bool Planner::buffer_line(const_float_t rx, const_float_t ry, const_float_t rz, const_float_t e, const_feedRate_t fr_mm_s, const uint8_t extruder, const float millimeters
#if ENABLED(SCARA_FEEDRATE_SCALING) OPTARG(SCARA_FEEDRATE_SCALING, const_float_t inv_duration)
, const_float_t inv_duration
#endif
) { ) {
xyze_pos_t machine = { rx, ry, rz, e }; xyze_pos_t machine = { rx, ry, rz, e };
TERN_(HAS_POSITION_MODIFIERS, apply_modifiers(machine)); TERN_(HAS_POSITION_MODIFIERS, apply_modifiers(machine));

View File

@ -707,12 +707,8 @@ class Planner {
* Returns true if movement was buffered, false otherwise * Returns true if movement was buffered, false otherwise
*/ */
static bool _buffer_steps(const xyze_long_t &target static bool _buffer_steps(const xyze_long_t &target
#if HAS_POSITION_FLOAT OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float)
, const xyze_pos_t &target_float OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm)
#endif
#if HAS_DIST_MM_ARG
, const xyze_float_t &cart_dist_mm
#endif
, feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0 , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0
); );
@ -728,14 +724,9 @@ class Planner {
* *
* Returns true is movement is acceptable, false otherwise * Returns true is movement is acceptable, false otherwise
*/ */
static bool _populate_block(block_t * const block, bool split_move, static bool _populate_block(block_t * const block, bool split_move, const xyze_long_t &target
const xyze_long_t &target OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float)
#if HAS_POSITION_FLOAT OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm)
, const xyze_pos_t &target_float
#endif
#if HAS_DIST_MM_ARG
, const xyze_float_t &cart_dist_mm
#endif
, feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0 , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0
); );
@ -768,22 +759,16 @@ class Planner {
* millimeters - the length of the movement, if known * millimeters - the length of the movement, if known
*/ */
static bool buffer_segment(const_float_t a, const_float_t b, const_float_t c, const_float_t e static bool buffer_segment(const_float_t a, const_float_t b, const_float_t c, const_float_t e
#if HAS_DIST_MM_ARG OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm)
, const xyze_float_t &cart_dist_mm
#endif
, const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0 , const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0
); );
FORCE_INLINE static bool buffer_segment(abce_pos_t &abce FORCE_INLINE static bool buffer_segment(abce_pos_t &abce
#if HAS_DIST_MM_ARG OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm)
, const xyze_float_t &cart_dist_mm
#endif
, const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0 , const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0
) { ) {
return buffer_segment(abce.a, abce.b, abce.c, abce.e return buffer_segment(abce.a, abce.b, abce.c, abce.e
#if HAS_DIST_MM_ARG OPTARG(HAS_DIST_MM_ARG, cart_dist_mm)
, cart_dist_mm
#endif
, fr_mm_s, extruder, millimeters); , fr_mm_s, extruder, millimeters);
} }
@ -801,20 +786,14 @@ class Planner {
* inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled) * inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled)
*/ */
static bool buffer_line(const_float_t rx, const_float_t ry, const_float_t rz, const_float_t e, const_feedRate_t fr_mm_s, const uint8_t extruder, const float millimeters=0.0 static bool buffer_line(const_float_t rx, const_float_t ry, const_float_t rz, const_float_t e, const_feedRate_t fr_mm_s, const uint8_t extruder, const float millimeters=0.0
#if ENABLED(SCARA_FEEDRATE_SCALING) OPTARG(SCARA_FEEDRATE_SCALING, const_float_t inv_duration=0.0)
, const_float_t inv_duration=0.0
#endif
); );
FORCE_INLINE static bool buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s, const uint8_t extruder, const float millimeters=0.0 FORCE_INLINE static bool buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s, const uint8_t extruder, const float millimeters=0.0
#if ENABLED(SCARA_FEEDRATE_SCALING) OPTARG(SCARA_FEEDRATE_SCALING, const_float_t inv_duration=0.0)
, const_float_t inv_duration=0.0
#endif
) { ) {
return buffer_line(cart.x, cart.y, cart.z, cart.e, fr_mm_s, extruder, millimeters return buffer_line(cart.x, cart.y, cart.z, cart.e, fr_mm_s, extruder, millimeters
#if ENABLED(SCARA_FEEDRATE_SCALING) OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)
, inv_duration
#endif
); );
} }

View File

@ -3335,11 +3335,8 @@ void Temperature::isr() {
* Extruder: " T0:nnn.nn /nnn.nn" * Extruder: " T0:nnn.nn /nnn.nn"
* With ADC: " T0:nnn.nn /nnn.nn (nnn.nn)" * With ADC: " T0:nnn.nn /nnn.nn (nnn.nn)"
*/ */
static void print_heater_state(const_celsius_float_t c, const_celsius_float_t t static void print_heater_state(const heater_id_t e, const_celsius_float_t c, const_celsius_float_t t
#if ENABLED(SHOW_TEMP_ADC_VALUES) OPTARG(SHOW_TEMP_ADC_VALUES, const float r)
, const float r
#endif
, const heater_id_t e=INDEX_NONE
) { ) {
char k; char k;
switch (e) { switch (e) {
@ -3385,64 +3382,28 @@ void Temperature::isr() {
} }
void Temperature::print_heater_states(const uint8_t target_extruder void Temperature::print_heater_states(const uint8_t target_extruder
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) OPTARG(TEMP_SENSOR_1_AS_REDUNDANT, const bool include_r/*=false*/)
, const bool include_r/*=false*/
#endif
) { ) {
#if HAS_TEMP_HOTEND #if HAS_TEMP_HOTEND
print_heater_state(degHotend(target_extruder), degTargetHotend(target_extruder) print_heater_state(H_NONE, degHotend(target_extruder), degTargetHotend(target_extruder) OPTARG(SHOW_TEMP_ADC_VALUES, rawHotendTemp(target_extruder)));
#if ENABLED(SHOW_TEMP_ADC_VALUES)
, rawHotendTemp(target_extruder)
#endif
);
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
if (include_r) print_heater_state(degHotendRedundant(), degTargetHotend(0) if (include_r) print_heater_state(H_REDUNDANT, degHotendRedundant(), degTargetHotend(0) OPTARG(SHOW_TEMP_ADC_VALUES, rawHotendTempRedundant()));
#if ENABLED(SHOW_TEMP_ADC_VALUES)
, rawHotendTempRedundant()
#endif
, H_REDUNDANT
);
#endif #endif
#endif #endif
#if HAS_HEATED_BED #if HAS_HEATED_BED
print_heater_state(degBed(), degTargetBed() print_heater_state(H_BED, degBed(), degTargetBed() OPTARG(SHOW_TEMP_ADC_VALUES, rawBedTemp()));
#if ENABLED(SHOW_TEMP_ADC_VALUES)
, rawBedTemp()
#endif
, H_BED
);
#endif #endif
#if HAS_TEMP_CHAMBER #if HAS_TEMP_CHAMBER
print_heater_state(degChamber(), TERN0(HAS_HEATED_CHAMBER, degTargetChamber()) print_heater_state(H_CHAMBER, degChamber(), TERN0(HAS_HEATED_CHAMBER, degTargetChamber()) OPTARG(SHOW_TEMP_ADC_VALUES, rawChamberTemp()));
#if ENABLED(SHOW_TEMP_ADC_VALUES) #endif
, rawChamberTemp()
#endif
, H_CHAMBER
);
#endif // HAS_TEMP_CHAMBER
#if HAS_TEMP_COOLER #if HAS_TEMP_COOLER
print_heater_state(degCooler(), TERN0(HAS_COOLER, degTargetCooler()) print_heater_state(H_COOLER, degCooler(), TERN0(HAS_COOLER, degTargetCooler()) OPTARG(SHOW_TEMP_ADC_VALUES, rawCoolerTemp()));
#if ENABLED(SHOW_TEMP_ADC_VALUES) #endif
, rawCoolerTemp()
#endif
, H_COOLER
);
#endif // HAS_TEMP_COOLER
#if HAS_TEMP_PROBE #if HAS_TEMP_PROBE
print_heater_state(degProbe(), 0 print_heater_state(H_PROBE, degProbe(), 0 OPTARG(SHOW_TEMP_ADC_VALUES, rawProbeTemp()) );
#if ENABLED(SHOW_TEMP_ADC_VALUES)
, rawProbeTemp()
#endif
, H_PROBE
);
#endif #endif
#if HAS_MULTI_HOTEND #if HAS_MULTI_HOTEND
HOTEND_LOOP() print_heater_state(degHotend(e), degTargetHotend(e) HOTEND_LOOP() print_heater_state((heater_id_t)e, degHotend(e), degTargetHotend(e) OPTARG(SHOW_TEMP_ADC_VALUES, rawHotendTemp(e)));
#if ENABLED(SHOW_TEMP_ADC_VALUES)
, rawHotendTemp(e)
#endif
, (heater_id_t)e
);
#endif #endif
SERIAL_ECHOPAIR(" @:", getHeaterPower((heater_id_t)target_extruder)); SERIAL_ECHOPAIR(" @:", getHeaterPower((heater_id_t)target_extruder));
#if HAS_HEATED_BED #if HAS_HEATED_BED
@ -3465,10 +3426,7 @@ void Temperature::isr() {
#if ENABLED(AUTO_REPORT_TEMPERATURES) #if ENABLED(AUTO_REPORT_TEMPERATURES)
AutoReporter<Temperature::AutoReportTemp> Temperature::auto_reporter; AutoReporter<Temperature::AutoReportTemp> Temperature::auto_reporter;
void Temperature::AutoReportTemp::report() { void Temperature::AutoReportTemp::report() { print_heater_states(active_extruder); SERIAL_EOL(); }
print_heater_states(active_extruder);
SERIAL_EOL();
}
#endif #endif
#if HAS_HOTEND && HAS_STATUS_MESSAGE #if HAS_HOTEND && HAS_STATUS_MESSAGE
@ -3495,11 +3453,8 @@ void Temperature::isr() {
#endif #endif
bool Temperature::wait_for_hotend(const uint8_t target_extruder, const bool no_wait_for_cooling/*=true*/ bool Temperature::wait_for_hotend(const uint8_t target_extruder, const bool no_wait_for_cooling/*=true*/
#if G26_CLICK_CAN_CANCEL OPTARG(G26_CLICK_CAN_CANCEL, const bool click_to_cancel/*=false*/)
, const bool click_to_cancel/*=false*/
#endif
) { ) {
#if ENABLED(AUTOTEMP) #if ENABLED(AUTOTEMP)
REMEMBER(1, planner.autotemp_enabled, false); REMEMBER(1, planner.autotemp_enabled, false);
#endif #endif
@ -3638,9 +3593,7 @@ void Temperature::isr() {
#endif #endif
bool Temperature::wait_for_bed(const bool no_wait_for_cooling/*=true*/ bool Temperature::wait_for_bed(const bool no_wait_for_cooling/*=true*/
#if G26_CLICK_CAN_CANCEL OPTARG(G26_CLICK_CAN_CANCEL, const bool click_to_cancel/*=false*/)
, const bool click_to_cancel/*=false*/
#endif
) { ) {
#if TEMP_BED_RESIDENCY_TIME > 0 #if TEMP_BED_RESIDENCY_TIME > 0
millis_t residency_start_ms = 0; millis_t residency_start_ms = 0;

View File

@ -46,7 +46,7 @@
// Element identifiers. Positive values are hotends. Negative values are other heaters or coolers. // Element identifiers. Positive values are hotends. Negative values are other heaters or coolers.
typedef enum : int8_t { typedef enum : int8_t {
INDEX_NONE = -6, H_NONE = -6,
H_COOLER, H_PROBE, H_REDUNDANT, H_CHAMBER, H_BED, H_COOLER, H_PROBE, H_REDUNDANT, H_CHAMBER, H_BED,
H_E0, H_E1, H_E2, H_E3, H_E4, H_E5, H_E6, H_E7 H_E0, H_E1, H_E2, H_E3, H_E4, H_E5, H_E6, H_E7
} heater_id_t; } heater_id_t;
@ -395,21 +395,21 @@ class Temperature {
} heater_idle_t; } heater_idle_t;
// Indices and size for the heater_idle array // Indices and size for the heater_idle array
#define _ENUM_FOR_E(N) IDLE_INDEX_E##N, enum IdleIndex : int8_t {
enum IdleIndex : uint8_t { _II = -1
REPEAT(HOTENDS, _ENUM_FOR_E)
#if ENABLED(HAS_HEATED_BED) #define _IDLE_INDEX_E(N) ,IDLE_INDEX_E##N
IDLE_INDEX_BED, REPEAT(HOTENDS, _IDLE_INDEX_E)
#endif #undef _IDLE_INDEX_E
NR_HEATER_IDLE
OPTARG(HAS_HEATED_BED, IDLE_INDEX_BED)
, NR_HEATER_IDLE
}; };
#undef _ENUM_FOR_E
// Convert the given heater_id_t to idle array index // Convert the given heater_id_t to idle array index
static inline IdleIndex idle_index_for_id(const int8_t heater_id) { static inline IdleIndex idle_index_for_id(const int8_t heater_id) {
#if HAS_HEATED_BED TERN_(HAS_HEATED_BED, if (heater_id == H_BED) return IDLE_INDEX_BED);
if (heater_id == H_BED) return IDLE_INDEX_BED;
#endif
return (IdleIndex)_MAX(heater_id, 0); return (IdleIndex)_MAX(heater_id, 0);
} }
@ -672,9 +672,7 @@ class Temperature {
#if HAS_TEMP_HOTEND #if HAS_TEMP_HOTEND
static bool wait_for_hotend(const uint8_t target_extruder, const bool no_wait_for_cooling=true static bool wait_for_hotend(const uint8_t target_extruder, const bool no_wait_for_cooling=true
#if G26_CLICK_CAN_CANCEL OPTARG(G26_CLICK_CAN_CANCEL, const bool click_to_cancel=false)
, const bool click_to_cancel=false
#endif
); );
#if ENABLED(WAIT_FOR_HOTEND) #if ENABLED(WAIT_FOR_HOTEND)
@ -721,9 +719,7 @@ class Temperature {
} }
static bool wait_for_bed(const bool no_wait_for_cooling=true static bool wait_for_bed(const bool no_wait_for_cooling=true
#if G26_CLICK_CAN_CANCEL OPTARG(G26_CLICK_CAN_CANCEL, const bool click_to_cancel=false)
, const bool click_to_cancel=false
#endif
); );
static void wait_for_bed_heating(); static void wait_for_bed_heating();
@ -859,9 +855,7 @@ class Temperature {
#if HAS_TEMP_SENSOR #if HAS_TEMP_SENSOR
static void print_heater_states(const uint8_t target_extruder static void print_heater_states(const uint8_t target_extruder
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) OPTARG(TEMP_SENSOR_1_AS_REDUNDANT, const bool include_r=false)
, const bool include_r=false
#endif
); );
#if ENABLED(AUTO_REPORT_TEMPERATURES) #if ENABLED(AUTO_REPORT_TEMPERATURES)
struct AutoReportTemp { static void report(); }; struct AutoReportTemp { static void report(); };
@ -925,35 +919,24 @@ class Temperature {
#if HAS_THERMAL_PROTECTION #if HAS_THERMAL_PROTECTION
// Indices and size for the tr_state_machine array. One for each protected heater. // Indices and size for the tr_state_machine array. One for each protected heater.
#define _ENUM_FOR_E(N) RUNAWAY_IND_E##N, enum RunawayIndex : int8_t {
enum RunawayIndex : uint8_t { _RI = -1
#if ENABLED(THERMAL_PROTECTION_HOTENDS) #if ENABLED(THERMAL_PROTECTION_HOTENDS)
REPEAT(HOTENDS, _ENUM_FOR_E) #define _RUNAWAY_IND_E(N) ,RUNAWAY_IND_E##N
REPEAT(HOTENDS, _RUNAWAY_IND_E)
#undef _RUNAWAY_IND_E
#endif #endif
#if ENABLED(HAS_THERMALLY_PROTECTED_BED) OPTARG(HAS_THERMALLY_PROTECTED_BED, RUNAWAY_IND_BED)
RUNAWAY_IND_BED, OPTARG(THERMAL_PROTECTION_CHAMBER, RUNAWAY_IND_CHAMBER)
#endif OPTARG(THERMAL_PROTECTION_COOLER, RUNAWAY_IND_COOLER)
#if ENABLED(THERMAL_PROTECTION_CHAMBER) , NR_HEATER_RUNAWAY
RUNAWAY_IND_CHAMBER,
#endif
#if ENABLED(THERMAL_PROTECTION_COOLER)
RUNAWAY_IND_COOLER,
#endif
NR_HEATER_RUNAWAY
}; };
#undef _ENUM_FOR_E
// Convert the given heater_id_t to runaway state array index // Convert the given heater_id_t to runaway state array index
static inline RunawayIndex runaway_index_for_id(const int8_t heater_id) { static inline RunawayIndex runaway_index_for_id(const int8_t heater_id) {
#if HAS_THERMALLY_PROTECTED_CHAMBER TERN_(HAS_THERMALLY_PROTECTED_CHAMBER, if (heater_id == H_CHAMBER) return RUNAWAY_IND_CHAMBER);
if (heater_id == H_CHAMBER) return RUNAWAY_IND_CHAMBER; TERN_(HAS_THERMALLY_PROTECTED_CHAMBER, if (heater_id == H_COOLER) return RUNAWAY_IND_COOLER);
#endif TERN_(HAS_THERMALLY_PROTECTED_BED, if (heater_id == H_BED) return RUNAWAY_IND_BED);
#if HAS_THERMALLY_PROTECTED_CHAMBER
if (heater_id == H_COOLER) return RUNAWAY_IND_COOLER;
#endif
#if HAS_THERMALLY_PROTECTED_BED
if (heater_id == H_BED) return RUNAWAY_IND_BED;
#endif
return (RunawayIndex)_MAX(heater_id, 0); return (RunawayIndex)_MAX(heater_id, 0);
} }

View File

@ -956,12 +956,6 @@ uint8_t BulkOnly::HandleUsbError(uint8_t error, uint8_t index) {
return ((error && !count) ? MASS_ERR_GENERAL_USB_ERROR : MASS_ERR_SUCCESS); return ((error && !count) ? MASS_ERR_GENERAL_USB_ERROR : MASS_ERR_SUCCESS);
} }
#if MS_WANT_PARSER
uint8_t BulkOnly::Transaction(CommandBlockWrapper *pcbw, uint16_t buf_size, void *buf) {
return Transaction(CommandBlockWrapper *pcbw, uint16_t buf_size, void *buf, 0);
}
#endif
/** /**
* For driver use only. * For driver use only.
* *
@ -972,9 +966,7 @@ uint8_t BulkOnly::HandleUsbError(uint8_t error, uint8_t index) {
* @return * @return
*/ */
uint8_t BulkOnly::Transaction(CommandBlockWrapper *pcbw, uint16_t buf_size, void *buf uint8_t BulkOnly::Transaction(CommandBlockWrapper *pcbw, uint16_t buf_size, void *buf
#if MS_WANT_PARSER OPTARG(MS_WANT_PARSER, uint8_t flags/*=0*/)
, uint8_t flags
#endif
) { ) {
#if MS_WANT_PARSER #if MS_WANT_PARSER
uint16_t bytes = (pcbw->dCBWDataTransferLength > buf_size) ? buf_size : pcbw->dCBWDataTransferLength; uint16_t bytes = (pcbw->dCBWDataTransferLength > buf_size) ? buf_size : pcbw->dCBWDataTransferLength;

View File

@ -553,10 +553,7 @@ private:
bool IsValidCSW(CommandStatusWrapper *pcsw, CommandBlockWrapperBase *pcbw); bool IsValidCSW(CommandStatusWrapper *pcsw, CommandBlockWrapperBase *pcbw);
uint8_t ClearEpHalt(uint8_t index); uint8_t ClearEpHalt(uint8_t index);
#if MS_WANT_PARSER uint8_t Transaction(CommandBlockWrapper *cbw, uint16_t bsize, void *buf OPTARG(MS_WANT_PARSER, uint8_t flags=0));
uint8_t Transaction(CommandBlockWrapper *cbw, uint16_t bsize, void *buf, uint8_t flags);
#endif
uint8_t Transaction(CommandBlockWrapper *cbw, uint16_t bsize, void *buf);
uint8_t HandleUsbError(uint8_t error, uint8_t index); uint8_t HandleUsbError(uint8_t error, uint8_t index);
uint8_t HandleSCSIError(uint8_t status); uint8_t HandleSCSIError(uint8_t status);
}; };