Use serial shorthand

This commit is contained in:
Scott Lahteine 2021-02-04 23:22:42 -06:00
parent 49564e5310
commit 708ea3d0bb
21 changed files with 88 additions and 132 deletions

View File

@ -419,8 +419,7 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
if (parked_or_ignoring) gcode.reset_stepper_timeout(ms);
if (gcode.stepper_max_timed_out(ms)) {
SERIAL_ERROR_START();
SERIAL_ECHOLNPAIR(STR_KILL_INACTIVE_TIME, parser.command_ptr);
SERIAL_ERROR_MSG(STR_KILL_INACTIVE_TIME, parser.command_ptr);
kill();
}

View File

@ -352,8 +352,7 @@ public:
}
}
else {
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("Packet header(", packet.header.sync, "?) corrupt");
SERIAL_ECHO_MSG("Packet header(", packet.header.sync, "?) corrupt");
stream_state = StreamState::PACKET_RESEND;
}
}
@ -387,8 +386,7 @@ public:
stream_state = StreamState::PACKET_PROCESS;
}
else {
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("Packet(", packet.header.sync, ") payload corrupt");
SERIAL_ECHO_MSG("Packet(", packet.header.sync, ") payload corrupt");
stream_state = StreamState::PACKET_RESEND;
}
}
@ -406,8 +404,7 @@ public:
if (packet_retries < MAX_RETRIES || MAX_RETRIES == 0) {
packet_retries++;
stream_state = StreamState::PACKET_RESET;
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("Resend request ", int(packet_retries));
SERIAL_ECHO_MSG("Resend request ", int(packet_retries));
SERIAL_ECHOLNPAIR("rs", sync);
}
else

View File

@ -67,8 +67,7 @@ void CancelObject::uncancel_object(const int8_t obj) {
void CancelObject::report() {
if (active_object >= 0) {
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("Active Object: ", int(active_object));
SERIAL_ECHO_MSG("Active Object: ", int(active_object));
}
if (canceled) {

View File

@ -514,8 +514,7 @@ static void mmu2_not_responding() {
extruder = index; // filament change is finished
active_extruder = 0;
ENABLE_AXIS_E0();
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(STR_ACTIVE_EXTRUDER, int(extruder));
SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, int(extruder));
}
ui.reset_status();
}
@ -602,8 +601,7 @@ static void mmu2_not_responding() {
active_extruder = 0;
ENABLE_AXIS_E0();
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(STR_ACTIVE_EXTRUDER, int(extruder));
SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, int(extruder));
ui.reset_status();
}
@ -698,8 +696,7 @@ static void mmu2_not_responding() {
extruder = index; //filament change is finished
active_extruder = 0;
ENABLE_AXIS_E0();
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(STR_ACTIVE_EXTRUDER, int(extruder));
SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, int(extruder));
ui.reset_status();
}

View File

@ -142,8 +142,7 @@ void GcodeSuite::G29() {
if (parser.seenval('I')) {
ix = parser.value_int();
if (!WITHIN(ix, 0, GRID_MAX_POINTS_X - 1)) {
SERIAL_ECHOPAIR("I out of range (0-", int(GRID_MAX_POINTS_X - 1));
SERIAL_ECHOLNPGM(")");
SERIAL_ECHOLNPAIR("I out of range (0-", int(GRID_MAX_POINTS_X - 1), ")");
return;
}
}
@ -153,8 +152,7 @@ void GcodeSuite::G29() {
if (parser.seenval('J')) {
iy = parser.value_int();
if (!WITHIN(iy, 0, GRID_MAX_POINTS_Y - 1)) {
SERIAL_ECHOPAIR("J out of range (0-", int(GRID_MAX_POINTS_Y - 1));
SERIAL_ECHOLNPGM(")");
SERIAL_ECHOLNPAIR("J out of range (0-", int(GRID_MAX_POINTS_Y - 1), ")");
return;
}
}
@ -182,10 +180,8 @@ void GcodeSuite::G29() {
} // switch(state)
if (state == MeshNext) {
SERIAL_ECHOPAIR("MBL G29 point ", _MIN(mbl_probe_index, GRID_MAX_POINTS));
SERIAL_ECHOLNPAIR(" of ", int(GRID_MAX_POINTS));
}
if (state == MeshNext)
SERIAL_ECHOLNPAIR("MBL G29 point ", _MIN(mbl_probe_index, GRID_MAX_POINTS), " of ", int(GRID_MAX_POINTS));
report_current_position();
}

View File

@ -34,7 +34,9 @@
* U<angle> - Stowed Angle
*/
void GcodeSuite::M281() {
if (!parser.seenval('P')) return;
const int servo_index = parser.value_int();
if (WITHIN(servo_index, 0, NUM_SERVOS - 1)) {
#if ENABLED(BLTOUCH)
@ -53,16 +55,14 @@ void GcodeSuite::M281() {
angle_change = true;
}
if (!angle_change) {
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(" Servo ", servo_index,
SERIAL_ECHO_MSG(" Servo ", servo_index,
" L", servo_angles[servo_index][0],
" U", servo_angles[servo_index][1]);
}
}
else {
SERIAL_ERROR_START();
SERIAL_ECHOLNPAIR("Servo ", servo_index, " out of range");
}
else
SERIAL_ERROR_MSG("Servo ", servo_index, " out of range");
}
#endif // EDITABLE_SERVO_ANGLES

View File

@ -35,14 +35,15 @@
* D<dval> - Set the D value
*/
void GcodeSuite::M304() {
if (parser.seen('P')) thermalManager.temp_bed.pid.Kp = parser.value_float();
if (parser.seen('I')) thermalManager.temp_bed.pid.Ki = scalePID_i(parser.value_float());
if (parser.seen('D')) thermalManager.temp_bed.pid.Kd = scalePID_d(parser.value_float());
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(" p:", thermalManager.temp_bed.pid.Kp,
SERIAL_ECHO_MSG(" p:", thermalManager.temp_bed.pid.Kp,
" i:", unscalePID_i(thermalManager.temp_bed.pid.Ki),
" d:", unscalePID_d(thermalManager.temp_bed.pid.Kd));
}
#endif // PIDTEMPBED

View File

@ -49,10 +49,8 @@ void GcodeSuite::M305() {
const bool do_set = parser.seen("BCRT");
// A valid P index is required
if (t_index >= (USER_THERMISTORS) || (do_set && t_index < 0)) {
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("!Invalid index. (0 <= P <= ", int(USER_THERMISTORS - 1), ")");
}
if (t_index >= (USER_THERMISTORS) || (do_set && t_index < 0))
SERIAL_ECHO_MSG("!Invalid index. (0 <= P <= ", int(USER_THERMISTORS - 1), ")");
else if (do_set) {
if (parser.seen('R')) // Pullup resistor value
if (!thermalManager.set_pull_up_res(t_index, parser.value_float()))

View File

@ -31,7 +31,9 @@
* M280: Get or set servo position. P<index> [S<angle>]
*/
void GcodeSuite::M280() {
if (!parser.seen('P')) return;
const int servo_index = parser.value_int();
if (WITHIN(servo_index, 0, NUM_SERVOS - 1)) {
if (parser.seen('S')) {
@ -41,15 +43,12 @@ void GcodeSuite::M280() {
else
MOVE_SERVO(servo_index, a);
}
else {
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(" Servo ", servo_index, ": ", servo[servo_index].read());
}
}
else {
SERIAL_ERROR_START();
SERIAL_ECHOLNPAIR("Servo ", servo_index, " out of range");
else
SERIAL_ECHO_MSG(" Servo ", servo_index, ": ", servo[servo_index].read());
}
else
SERIAL_ERROR_MSG("Servo ", servo_index, " out of range");
}
#endif // HAS_SERVOS

View File

@ -32,14 +32,14 @@
* S<seconds> Optional. Set the keepalive interval.
*/
void GcodeSuite::M113() {
if (parser.seenval('S')) {
host_keepalive_interval = parser.value_byte();
NOMORE(host_keepalive_interval, 60);
}
else {
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("M113 S", (unsigned long)host_keepalive_interval);
}
else
SERIAL_ECHO_MSG("M113 S", (uint16_t)host_keepalive_interval);
}
#endif // HOST_KEEPALIVE_FEATURE

View File

@ -42,14 +42,12 @@
FORCE_INLINE void mod_probe_offset(const float &offs) {
if (TERN1(BABYSTEP_HOTEND_Z_OFFSET, active_extruder == 0)) {
probe.offset.z += offs;
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(STR_PROBE_OFFSET " " STR_Z, probe.offset.z);
SERIAL_ECHO_MSG(STR_PROBE_OFFSET " " STR_Z, probe.offset.z);
}
else {
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
hotend_offset[active_extruder].z -= offs;
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(STR_PROBE_OFFSET STR_Z ": ", hotend_offset[active_extruder].z);
SERIAL_ECHO_MSG(STR_PROBE_OFFSET STR_Z ": ", hotend_offset[active_extruder].z);
#endif
}
}

View File

@ -35,6 +35,5 @@ void GcodeSuite::M31() {
ui.set_status(buffer);
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("Print time: ", buffer);
SERIAL_ECHO_MSG("Print time: ", buffer);
}

View File

@ -552,10 +552,8 @@ void AnycubicTFTClass::GetCommandFromTFT() {
a_command = ((int)((strtod(&TFTcmdbuffer[TFTbufindw][TFTstrchr_pointer - TFTcmdbuffer[TFTbufindw] + 1], nullptr))));
#if ENABLED(ANYCUBIC_LCD_DEBUG)
if ((a_command > 7) && (a_command != 20)) { // No debugging of status polls, please!
SERIAL_ECHOPGM("TFT Serial Command: ");
SERIAL_ECHOLN(TFTcmdbuffer[TFTbufindw]);
}
if ((a_command > 7) && (a_command != 20)) // No debugging of status polls, please!
SERIAL_ECHOLNPAIR("TFT Serial Command: ", TFTcmdbuffer[TFTbufindw]);
#endif
switch (a_command) {

View File

@ -1074,7 +1074,7 @@ void CLCD::init() {
uint8_t device_id = mem_read_8(REG::ID); // Read Device ID, Should Be 0x7C;
if (device_id == 0x7C) {
#if ENABLED(TOUCH_UI_DEBUG)
SERIAL_ECHO_MSG("FTDI chip initialized ");
SERIAL_ECHO_MSG("FTDI chip initialized");
#endif
break;
}
@ -1083,8 +1083,7 @@ void CLCD::init() {
if (counter == 249) {
#if ENABLED(TOUCH_UI_DEBUG)
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("Timeout waiting for device ID, should be 124, got ", device_id);
SERIAL_ECHO_MSG("Timeout waiting for device ID, should be 124, got ", int(device_id));
#endif
}
}
@ -1101,10 +1100,8 @@ void CLCD::init() {
else
delay(1);
if (ENABLED(TOUCH_UI_DEBUG) && counter == 99) {
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("Timeout waiting for reset status. Should be 0x00, got ", reset_status);
}
if (ENABLED(TOUCH_UI_DEBUG) && counter == 99)
SERIAL_ECHO_MSG("Timeout waiting for reset status. Should be 0x00, got ", int(reset_status));
}
mem_write_8(REG::PWM_DUTY, 0); // turn off Backlight, Frequency already is set to 250Hz default

View File

@ -124,8 +124,7 @@ namespace FTDI {
case UNPRESSED:
if (tag != 0) {
#if ENABLED(TOUCH_UI_DEBUG)
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("Touch start: ", tag);
SERIAL_ECHO_MSG("Touch start: ", int(tag));
#endif
pressed_tag = tag;
@ -186,8 +185,7 @@ namespace FTDI {
if (UIData::flags.bits.touch_end_sound) sound.play(unpress_sound);
#if ENABLED(TOUCH_UI_DEBUG)
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("Touch end: ", pressed_tag);
SERIAL_ECHO_MSG("Touch end: ", int(pressed_tag));
#endif
const uint8_t saved_pressed_tag = pressed_tag;

View File

@ -43,8 +43,7 @@ void ScreenRef::setScreen(onRedraw_func_t onRedraw_ptr) {
if (type != 0xFF) {
setType(type);
#if ENABLED(TOUCH_UI_DEBUG)
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("New screen: ", type);
SERIAL_ECHO_MSG("New screen: ", int(type));
#endif
}
}

View File

@ -127,8 +127,7 @@ void BioPrintingDialogBox::setStatusMessage(const char* message) {
storeBackground();
#if ENABLED(TOUCH_UI_DEBUG)
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("New status message: ", message);
SERIAL_ECHO_MSG("New status message: ", message);
#endif
if (AT_SCREEN(BioPrintingDialogBox))

View File

@ -2946,7 +2946,7 @@ void MarlinSettings::reset() {
}
#define CONFIG_ECHO_START() do{ if (!forReplay) SERIAL_ECHO_START(); }while(0)
#define CONFIG_ECHO_MSG(STR) do{ CONFIG_ECHO_START(); SERIAL_ECHOLNPGM(STR); }while(0)
#define CONFIG_ECHO_MSG(V...) do{ CONFIG_ECHO_START(); SERIAL_ECHOLNPAIR(V); }while(0)
#define CONFIG_ECHO_HEADING(STR) config_heading(forReplay, PSTR(STR))
#if HAS_TRINAMIC_CONFIG
@ -3039,8 +3039,7 @@ void MarlinSettings::reset() {
}
#if EXTRUDERS == 1
CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR(" M200 S", int(parser.volumetric_enabled)
CONFIG_ECHO_MSG(" M200 S", int(parser.volumetric_enabled)
, " D", LINEAR_UNIT(planner.filament_size[0])
#if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT)
, " L", LINEAR_UNIT(planner.volumetric_extruder_limit[0])
@ -3048,17 +3047,16 @@ void MarlinSettings::reset() {
);
#else
LOOP_L_N(i, EXTRUDERS) {
CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR(" M200 T", int(i)
CONFIG_ECHO_MSG(" M200 T", int(i)
, " D", LINEAR_UNIT(planner.filament_size[i])
#if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT)
, " L", LINEAR_UNIT(planner.volumetric_extruder_limit[i])
#endif
);
}
CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR(" M200 S", int(parser.volumetric_enabled));
CONFIG_ECHO_MSG(" M200 S", int(parser.volumetric_enabled));
#endif
#endif // EXTRUDERS && !NO_VOLUMETRICS
CONFIG_ECHO_HEADING("Steps per unit:");
@ -3194,7 +3192,7 @@ void MarlinSettings::reset() {
CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR_P(
PSTR(" M420 S"), planner.leveling_active ? 1 : 0
PSTR(" M420 S"), int(planner.leveling_active)
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
, SP_Z_STR, LINEAR_UNIT(planner.z_fade_height)
#endif
@ -3260,8 +3258,7 @@ void MarlinSettings::reset() {
#elif ENABLED(BLTOUCH) || (HAS_Z_SERVO_PROBE && defined(Z_SERVO_ANGLES))
case Z_PROBE_SERVO_NR:
#endif
CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR(" M281 P", int(i), " L", servo_angles[i][0], " U", servo_angles[i][1]);
CONFIG_ECHO_MSG(" M281 P", int(i), " L", servo_angles[i][0], " U", servo_angles[i][1]);
default: break;
}
}
@ -3382,8 +3379,7 @@ void MarlinSettings::reset() {
#endif // PIDTEMP
#if ENABLED(PIDTEMPBED)
CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR(
CONFIG_ECHO_MSG(
" M304 P", thermalManager.temp_bed.pid.Kp
, " I", unscalePID_i(thermalManager.temp_bed.pid.Ki)
, " D", unscalePID_d(thermalManager.temp_bed.pid.Kd)
@ -3400,16 +3396,14 @@ void MarlinSettings::reset() {
#if HAS_LCD_CONTRAST
CONFIG_ECHO_HEADING("LCD Contrast:");
CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR(" M250 C", ui.contrast);
CONFIG_ECHO_MSG(" M250 C", ui.contrast);
#endif
TERN_(CONTROLLER_FAN_EDITABLE, M710_report(forReplay));
#if ENABLED(POWER_LOSS_RECOVERY)
CONFIG_ECHO_HEADING("Power-Loss Recovery:");
CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR(" M413 S", int(recovery.enabled));
CONFIG_ECHO_MSG(" M413 S", int(recovery.enabled));
#endif
#if ENABLED(FWRETRACT)
@ -3424,8 +3418,7 @@ void MarlinSettings::reset() {
);
CONFIG_ECHO_HEADING("Recover: S<length> F<units/m>");
CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR(
CONFIG_ECHO_MSG(
" M208 S", LINEAR_UNIT(fwretract.settings.retract_recover_extra)
, " W", LINEAR_UNIT(fwretract.settings.swap_retract_recover_extra)
, " F", LINEAR_UNIT(MMS_TO_MMM(fwretract.settings.retract_recover_feedrate_mm_s))
@ -3434,8 +3427,7 @@ void MarlinSettings::reset() {
#if ENABLED(FWRETRACT_AUTORETRACT)
CONFIG_ECHO_HEADING("Auto-Retract: S=0 to disable, 1 to interpret E-only moves as retract/recover");
CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR(" M209 S", fwretract.autoretract_enabled ? 1 : 0);
CONFIG_ECHO_MSG(" M209 S", int(fwretract.autoretract_enabled));
#endif // FWRETRACT_AUTORETRACT
@ -3780,13 +3772,10 @@ void MarlinSettings::reset() {
#if ENABLED(LIN_ADVANCE)
CONFIG_ECHO_HEADING("Linear Advance:");
#if EXTRUDERS < 2
CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR(" M900 K", planner.extruder_advance_K[0]);
CONFIG_ECHO_MSG(" M900 K", planner.extruder_advance_K[0]);
#else
LOOP_L_N(i, EXTRUDERS) {
CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR(" M900 T", int(i), " K", planner.extruder_advance_K[i]);
}
LOOP_L_N(i, EXTRUDERS)
CONFIG_ECHO_MSG(" M900 T", int(i), " K", planner.extruder_advance_K[i]);
#endif
#endif
@ -3851,8 +3840,7 @@ void MarlinSettings::reset() {
#if HAS_FILAMENT_SENSOR
CONFIG_ECHO_HEADING("Filament runout sensor:");
CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR(
CONFIG_ECHO_MSG(
" M412 S", int(runout.enabled)
#if HAS_FILAMENT_RUNOUT_DISTANCE
, " D", LINEAR_UNIT(runout.runout_distance())

View File

@ -1037,8 +1037,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) {
#if ENABLED(PID_BED_DEBUG)
{
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(
SERIAL_ECHO_MSG(
" PID_BED_DEBUG : Input ", temp_bed.celsius, " Output ", pid_output,
#if DISABLED(PID_OPENLOOP)
STR_PID_DEBUG_PTERM, work_pid.Kp,

View File

@ -1196,8 +1196,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
gcode.process_subcommands_now_P(PSTR(EVENT_GCODE_AFTER_TOOLCHANGE));
#endif
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(STR_ACTIVE_EXTRUDER, int(active_extruder));
SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, int(active_extruder));
#endif // HAS_MULTI_EXTRUDER
}

View File

@ -270,10 +270,9 @@ void CardReader::printListing(SdFile parent, const char * const prepend/*=nullpt
// Get a new directory object using the full path
// and dive recursively into it.
SdFile child;
if (!child.open(&parent, dosFilename, O_READ)) {
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(STR_SD_CANT_OPEN_SUBDIR, dosFilename);
}
if (!child.open(&parent, dosFilename, O_READ))
SERIAL_ECHO_MSG(STR_SD_CANT_OPEN_SUBDIR, dosFilename);
printListing(child, path);
// close() is done automatically by destructor of SdFile
}
@ -594,8 +593,7 @@ void CardReader::openFileRead(char * const path, const uint8_t subcall_type/*=0*
filespos[file_subcall_ctr] = sdpos;
// For sub-procedures say 'SUBROUTINE CALL target: "..." parent: "..." pos12345'
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("SUBROUTINE CALL target:\"", path, "\" parent:\"", proc_filenames[file_subcall_ctr], "\" pos", sdpos);
SERIAL_ECHO_MSG("SUBROUTINE CALL target:\"", path, "\" parent:\"", proc_filenames[file_subcall_ctr], "\" pos", sdpos);
file_subcall_ctr++;
break;
@ -941,10 +939,8 @@ void CardReader::cd(const char * relpath) {
workDirParents[workDirDepth++] = workDir;
TERN_(SDCARD_SORT_ALPHA, presort());
}
else {
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(STR_SD_CANT_ENTER_SUBDIR, relpath);
}
else
SERIAL_ECHO_MSG(STR_SD_CANT_ENTER_SUBDIR, relpath);
}
int8_t CardReader::cdup() {