🎨 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

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

View File

@ -249,9 +249,7 @@ void plan_arc(
#endif
if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, 0
#if ENABLED(SCARA_FEEDRATE_SCALING)
, inv_duration
#endif
OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)
)) break;
}
@ -266,9 +264,7 @@ void plan_arc(
#endif
planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, 0
#if ENABLED(SCARA_FEEDRATE_SCALING)
, inv_duration
#endif
OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)
);
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
#if HAS_MULTI_SERIAL
, serial_index_t serial_ind/*=-1*/
#endif
OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind/*=-1*/)
) {
commands[index_w].skip_ok = skip_ok;
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.
*/
bool GCodeQueue::RingBuffer::enqueue(const char *cmd, bool skip_ok/*=true*/
#if HAS_MULTI_SERIAL
, serial_index_t serial_ind/*=-1*/
#endif
OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind/*=-1*/)
) {
if (*cmd == ';' || length >= BUFSIZE) return false;
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 commit_command(bool skip_ok
#if HAS_MULTI_SERIAL
, serial_index_t serial_ind = serial_index_t()
#endif
OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind = serial_index_t())
);
bool enqueue(const char *cmd, bool skip_ok = true
#if HAS_MULTI_SERIAL
, serial_index_t serial_ind = serial_index_t()
#endif
OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind = serial_index_t())
);
void ok_to_send();