Skip to content

Commit

Permalink
✨ MARLIN_SMALL_BUILD option (MarlinFirmware#26775)
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead authored Feb 8, 2024
1 parent 4aa48be commit 669814d
Show file tree
Hide file tree
Showing 54 changed files with 179 additions and 55 deletions.
3 changes: 3 additions & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -4527,3 +4527,6 @@

// Report uncleaned reset reason from register r2 instead of MCUSR. Supported by Optiboot on AVR.
//#define OPTIBOOT_RESET_REASON

// Shrink the build for smaller boards by sacrificing some serial feedback
//#define MARLIN_SMALL_BUILD
6 changes: 6 additions & 0 deletions Marlin/src/feature/fwretract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ void FWRetract::M207() {
}

void FWRetract::M207_report() {
TERN_(MARLIN_SMALL_BUILD, return);

SERIAL_ECHOLNPGM_P(
PSTR(" M207 S"), LINEAR_UNIT(settings.retract_length)
, PSTR(" W"), LINEAR_UNIT(settings.swap_retract_length)
Expand All @@ -237,6 +239,8 @@ void FWRetract::M208() {
}

void FWRetract::M208_report() {
TERN_(MARLIN_SMALL_BUILD, return);

SERIAL_ECHOLNPGM(
" M208 S", LINEAR_UNIT(settings.retract_recover_extra)
, " W", LINEAR_UNIT(settings.swap_retract_recover_extra)
Expand All @@ -258,6 +262,8 @@ void FWRetract::M208_report() {
}

void FWRetract::M209_report() {
TERN_(MARLIN_SMALL_BUILD, return);

SERIAL_ECHOLNPGM(" M209 S", AS_DIGIT(autoretract_enabled));
}

Expand Down
24 changes: 12 additions & 12 deletions Marlin/src/gcode/bedlevel/G26.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ void GcodeSuite::G26() {

if (bedtemp) {
if (!WITHIN(bedtemp, 40, BED_MAX_TARGET)) {
SERIAL_ECHOLNPGM("?Specified bed temperature not plausible (40-", BED_MAX_TARGET, "C).");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("Specified bed temperature not plausible (40-", BED_MAX_TARGET, "C)."));
return;
}
g26.bed_temp = bedtemp;
Expand All @@ -543,7 +543,7 @@ void GcodeSuite::G26() {
if (parser.seenval('L')) {
g26.layer_height = parser.value_linear_units();
if (!WITHIN(g26.layer_height, 0.0, 2.0)) {
SERIAL_ECHOLNPGM("?Specified layer height not plausible.");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("Specified layer height not plausible."));
return;
}
}
Expand All @@ -552,20 +552,20 @@ void GcodeSuite::G26() {
if (parser.has_value()) {
g26.retraction_multiplier = parser.value_float();
if (!WITHIN(g26.retraction_multiplier, 0.05, 15.0)) {
SERIAL_ECHOLNPGM("?Specified Retraction Multiplier not plausible.");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("Specified Retraction Multiplier not plausible."));
return;
}
}
else {
SERIAL_ECHOLNPGM("?Retraction Multiplier must be specified.");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("Retraction Multiplier must be specified."));
return;
}
}

if (parser.seenval('S')) {
g26.nozzle = parser.value_float();
if (!WITHIN(g26.nozzle, 0.1, 2.0)) {
SERIAL_ECHOLNPGM("?Specified nozzle size not plausible.");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("Specified nozzle size not plausible."));
return;
}
}
Expand All @@ -575,15 +575,15 @@ void GcodeSuite::G26() {
#if HAS_MARLINUI_MENU
g26.prime_flag = -1;
#else
SERIAL_ECHOLNPGM("?Prime length must be specified when not using an LCD.");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("Prime length must be specified when not using an LCD."));
return;
#endif
}
else {
g26.prime_flag++;
g26.prime_length = parser.value_linear_units();
if (!WITHIN(g26.prime_length, 0.0, 25.0)) {
SERIAL_ECHOLNPGM("?Specified prime length not plausible.");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("Specified prime length not plausible."));
return;
}
}
Expand All @@ -592,7 +592,7 @@ void GcodeSuite::G26() {
if (parser.seenval('F')) {
g26.filament_diameter = parser.value_linear_units();
if (!WITHIN(g26.filament_diameter, 1.0, 4.0)) {
SERIAL_ECHOLNPGM("?Specified filament size not plausible.");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("Specified filament size not plausible."));
return;
}
}
Expand All @@ -616,7 +616,7 @@ void GcodeSuite::G26() {
// If any preset or temperature was specified
if (noztemp) {
if (!WITHIN(noztemp, 165, thermalManager.hotend_max_target(active_extruder))) {
SERIAL_ECHOLNPGM("?Specified nozzle temperature not plausible.");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("Specified nozzle temperature not plausible."));
return;
}
g26.hotend_temp = noztemp;
Expand All @@ -637,20 +637,20 @@ void GcodeSuite::G26() {
if (parser.seen('R'))
g26_repeats = parser.has_value() ? parser.value_int() : GRID_MAX_POINTS + 1;
else {
SERIAL_ECHOLNPGM("?(R)epeat must be specified when not using an LCD.");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("(R)epeat must be specified when not using an LCD."));
return;
}
#endif
if (g26_repeats < 1) {
SERIAL_ECHOLNPGM("?(R)epeat value not plausible; must be at least 1.");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("(R)epeat value not plausible; must be at least 1."));
return;
}

// Set a position with 'X' and/or 'Y'. Default: current_position
g26.xy_pos.set(parser.seenval('X') ? RAW_X_POSITION(parser.value_linear_units()) : current_position.x,
parser.seenval('Y') ? RAW_Y_POSITION(parser.value_linear_units()) : current_position.y);
if (!position_is_reachable(g26.xy_pos)) {
SERIAL_ECHOLNPGM("?Specified X,Y coordinate out of bounds.");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("Specified X,Y coordinate out of bounds."));
return;
}

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/bedlevel/G35.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void GcodeSuite::G35() {

const uint8_t screw_thread = parser.byteval('S', TRAMMING_SCREW_THREAD);
if (!WITHIN(screw_thread, 30, 51) || screw_thread % 10 > 1) {
SERIAL_ECHOLNPGM("?(S)crew thread must be 30, 31, 40, 41, 50, or 51.");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("(S)crew thread must be 30, 31, 40, 41, 50, or 51."));
return;
}

Expand Down
9 changes: 5 additions & 4 deletions Marlin/src/gcode/bedlevel/M420.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,12 @@ void GcodeSuite::M420() {
const int16_t a = settings.calc_num_meshes();

if (!a) {
SERIAL_ECHOLNPGM("?EEPROM storage not available.");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("EEPROM storage not available."));
return;
}

if (!WITHIN(storage_slot, 0, a - 1)) {
SERIAL_ECHOLNPGM("?Invalid storage slot.");
SERIAL_ECHOLNPGM("?Use 0 to ", a - 1);
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("Invalid storage slot. Use 0 to ", a - 1));
return;
}

Expand All @@ -120,7 +119,7 @@ void GcodeSuite::M420() {

#else

SERIAL_ECHOLNPGM("?EEPROM storage not available.");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("EEPROM storage not available."));
return;

#endif
Expand Down Expand Up @@ -245,6 +244,8 @@ void GcodeSuite::M420() {
}

void GcodeSuite::M420_report(const bool forReplay/*=true*/) {
TERN_(MARLIN_SMALL_BUILD, return);

report_heading_etc(forReplay, F(
TERN(MESH_BED_LEVELING, "Mesh Bed Leveling", TERN(AUTO_BED_LEVELING_UBL, "Unified Bed Leveling", "Auto Bed Leveling"))
));
Expand Down
8 changes: 4 additions & 4 deletions Marlin/src/gcode/bedlevel/abl/G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ G29_TYPE GcodeSuite::G29() {

abl.verbose_level = parser.intval('V');
if (!WITHIN(abl.verbose_level, 0, 4)) {
SERIAL_ECHOLNPGM("?(V)erbose level implausible (0-4).");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("(V)erbose level implausible (0-4)."));
G29_RETURN(false, false);
}

Expand All @@ -365,11 +365,11 @@ G29_TYPE GcodeSuite::G29() {
if (parser.seenval('P')) abl.grid_points.x = abl.grid_points.y = parser.value_int();

if (!WITHIN(abl.grid_points.x, 2, GRID_MAX_POINTS_X)) {
SERIAL_ECHOLNPGM("?Probe points (X) implausible (2-" STRINGIFY(GRID_MAX_POINTS_X) ").");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("Probe points (X) implausible (2-" STRINGIFY(GRID_MAX_POINTS_X) ")."));
G29_RETURN(false, false);
}
if (!WITHIN(abl.grid_points.y, 2, GRID_MAX_POINTS_Y)) {
SERIAL_ECHOLNPGM("?Probe points (Y) implausible (2-" STRINGIFY(GRID_MAX_POINTS_Y) ").");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("Probe points (Y) implausible (2-" STRINGIFY(GRID_MAX_POINTS_Y) ")."));
G29_RETURN(false, false);
}

Expand Down Expand Up @@ -404,7 +404,7 @@ G29_TYPE GcodeSuite::G29() {
DEBUG_ECHOLNPGM("G29 L", abl.probe_position_lf.x, " R", abl.probe_position_rb.x,
" F", abl.probe_position_lf.y, " B", abl.probe_position_rb.y);
}
SERIAL_ECHOLNPGM("? (L,R,F,B) out of bounds.");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG(" (L,R,F,B) out of bounds."));
G29_RETURN(false, false);
}

Expand Down
8 changes: 4 additions & 4 deletions Marlin/src/gcode/calibrate/G33.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ void GcodeSuite::G33() {

const int8_t probe_points = parser.intval('P', DELTA_CALIBRATION_DEFAULT_POINTS);
if (!WITHIN(probe_points, 0, 10)) {
SERIAL_ECHOLNPGM("?(P)oints implausible (0-10).");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("(P)oints implausible (0-10)."));
return;
}

Expand All @@ -409,19 +409,19 @@ void GcodeSuite::G33() {

const float calibration_precision = parser.floatval('C', 0.0f);
if (calibration_precision < 0) {
SERIAL_ECHOLNPGM("?(C)alibration precision implausible (>=0).");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("(C)alibration precision implausible (>=0)."));
return;
}

const int8_t force_iterations = parser.intval('F', 0);
if (!WITHIN(force_iterations, 0, 30)) {
SERIAL_ECHOLNPGM("?(F)orce iteration implausible (0-30).");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("(F)orce iteration implausible (0-30)."));
return;
}

const int8_t verbose_level = parser.byteval('V', 1);
if (!WITHIN(verbose_level, 0, 3)) {
SERIAL_ECHOLNPGM("?(V)erbose level implausible (0-3).");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("(V)erbose level implausible (0-3)."));
return;
}

Expand Down
16 changes: 9 additions & 7 deletions Marlin/src/gcode/calibrate/G34_M422.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,19 @@ void GcodeSuite::G34() {

const int8_t z_auto_align_iterations = parser.intval('I', Z_STEPPER_ALIGN_ITERATIONS);
if (!WITHIN(z_auto_align_iterations, 1, 30)) {
SERIAL_ECHOLNPGM("?(I)teration out of bounds (1-30).");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("(I)teration out of bounds (1-30)."));
break;
}

const float z_auto_align_accuracy = parser.floatval('T', Z_STEPPER_ALIGN_ACC);
if (!WITHIN(z_auto_align_accuracy, 0.01f, 1.0f)) {
SERIAL_ECHOLNPGM("?(T)arget accuracy out of bounds (0.01-1.0).");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("(T)arget accuracy out of bounds (0.01-1.0)."));
break;
}

const float z_auto_align_amplification = TERN(HAS_Z_STEPPER_ALIGN_STEPPER_XY, Z_STEPPER_ALIGN_AMP, parser.floatval('A', Z_STEPPER_ALIGN_AMP));
if (!WITHIN(ABS(z_auto_align_amplification), 0.5f, 2.0f)) {
SERIAL_ECHOLNPGM("?(A)mplification out of bounds (0.5-2.0).");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("(A)mplification out of bounds (0.5-2.0)."));
break;
}

Expand Down Expand Up @@ -450,7 +450,7 @@ void GcodeSuite::M422() {
const bool is_probe_point = parser.seen_test('S');

if (TERN0(HAS_Z_STEPPER_ALIGN_STEPPER_XY, is_probe_point && parser.seen_test('W'))) {
SERIAL_ECHOLNPGM("?(S) and (W) may not be combined.");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("(S) and (W) may not be combined."));
return;
}

Expand All @@ -460,7 +460,7 @@ void GcodeSuite::M422() {
);

if (!is_probe_point && TERN1(HAS_Z_STEPPER_ALIGN_STEPPER_XY, !parser.seen_test('W'))) {
SERIAL_ECHOLNPGM("?(S)" TERN_(HAS_Z_STEPPER_ALIGN_STEPPER_XY, " or (W)") " is required.");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("(S)" TERN_(HAS_Z_STEPPER_ALIGN_STEPPER_XY, " or (W)") " is required."));
return;
}

Expand Down Expand Up @@ -490,11 +490,11 @@ void GcodeSuite::M422() {

if (is_probe_point) {
if (!probe.can_reach(pos.x, Y_CENTER)) {
SERIAL_ECHOLNPGM("?(X) out of bounds.");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("(X) out of bounds."));
return;
}
if (!probe.can_reach(pos)) {
SERIAL_ECHOLNPGM("?(Y) out of bounds.");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("(Y) out of bounds."));
return;
}
}
Expand All @@ -503,6 +503,8 @@ void GcodeSuite::M422() {
}

void GcodeSuite::M422_report(const bool forReplay/*=true*/) {
TERN_(MARLIN_SMALL_BUILD, return);

report_heading(forReplay, F(STR_Z_AUTO_ALIGN));
for (uint8_t i = 0; i < NUM_Z_STEPPERS; ++i) {
report_echo_start(forReplay);
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/gcode/calibrate/M425.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ void GcodeSuite::M425() {
}

void GcodeSuite::M425_report(const bool forReplay/*=true*/) {
TERN_(MARLIN_SMALL_BUILD, return);

report_heading_etc(forReplay, F(STR_BACKLASH_COMPENSATION));
SERIAL_ECHOLNPGM_P(
PSTR(" M425 F"), backlash.get_correction()
Expand Down
8 changes: 4 additions & 4 deletions Marlin/src/gcode/calibrate/M48.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ void GcodeSuite::M48() {

const int8_t verbose_level = parser.byteval('V', 1);
if (!WITHIN(verbose_level, 0, 4)) {
SERIAL_ECHOLNPGM("?(V)erbose level implausible (0-4).");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("(V)erbose level implausible (0-4)."));
return;
}

const int8_t n_samples = parser.byteval('P', 10);
if (!WITHIN(n_samples, 4, 50)) {
SERIAL_ECHOLNPGM("?Sample size not plausible (4-50).");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("Sample size not plausible (4-50)."));
return;
}

Expand All @@ -82,15 +82,15 @@ void GcodeSuite::M48() {

if (!probe.can_reach(test_position)) {
LCD_MESSAGE_MAX(MSG_M48_OUT_OF_BOUNDS);
SERIAL_ECHOLNPGM("? (X,Y) out of bounds.");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG(" (X,Y) out of bounds."));
return;
}

// Get the number of leg moves per test-point
bool seen_L = parser.seen('L');
uint8_t n_legs = seen_L ? parser.value_byte() : 0;
if (n_legs > 15) {
SERIAL_ECHOLNPGM("?Legs of movement implausible (0-15).");
SERIAL_ECHOLNPGM(GCODE_ERR_MSG("Legs of movement implausible (0-15)."));
return;
}
if (n_legs == 1) n_legs = 2;
Expand Down
9 changes: 8 additions & 1 deletion Marlin/src/gcode/calibrate/M665.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
}

void GcodeSuite::M665_report(const bool forReplay/*=true*/) {
TERN_(MARLIN_SMALL_BUILD, return);

report_heading_etc(forReplay, F(STR_DELTA_SETTINGS));
SERIAL_ECHOLNPGM_P(
PSTR(" M665 L"), LINEAR_UNIT(delta_diagonal_rod)
Expand Down Expand Up @@ -132,6 +134,8 @@
}

void GcodeSuite::M665_report(const bool forReplay/*=true*/) {
TERN_(MARLIN_SMALL_BUILD, return);

report_heading_etc(forReplay, F(STR_SCARA_SETTINGS " (" STR_S_SEG_PER_SEC TERN_(HAS_SCARA_OFFSET, " " STR_SCARA_P_T_Z) ")"));
SERIAL_ECHOLNPGM_P(
PSTR(" M665 S"), segments_per_second
Expand Down Expand Up @@ -170,6 +174,8 @@
}

void GcodeSuite::M665_report(const bool forReplay/*=true*/) {
TERN_(MARLIN_SMALL_BUILD, return);

report_heading_etc(forReplay, F(STR_POLARGRAPH_SETTINGS));
SERIAL_ECHOLNPGM_P(
PSTR(" M665 S"), LINEAR_UNIT(segments_per_second),
Expand All @@ -196,10 +202,11 @@
}

void GcodeSuite::M665_report(const bool forReplay/*=true*/) {
TERN_(MARLIN_SMALL_BUILD, return);
report_heading_etc(forReplay, F(STR_POLAR_SETTINGS));
SERIAL_ECHOLNPGM_P(PSTR(" M665 S"), segments_per_second);
}

#endif
#endif // POLAR

#endif // IS_KINEMATIC
Loading

0 comments on commit 669814d

Please sign in to comment.