Skip to content

Commit

Permalink
Merge pull request MarlinFirmware#8849 from silentninja1/patch-3
Browse files Browse the repository at this point in the history
[1.1.x] //Actions on Pause / Resume (M600, M125, etc.)
  • Loading branch information
thinkyhead authored Dec 25, 2017
2 parents 59d047c + 3c7cdcd commit 19e768d
Show file tree
Hide file tree
Showing 38 changed files with 323 additions and 72 deletions.
8 changes: 8 additions & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,14 @@
*/
//#define ACTION_ON_KILL "poweroff"

/**
* Specify an action command to send to the host on pause and resume.
* Will be sent in the form '//action:ACTION_ON_PAUSE', e.g. '//action:pause'.
* The host must be configured to handle the action command.
*/
//#define ACTION_ON_PAUSE "pause"
//#define ACTION_ON_RESUME "resume"

//===========================================================================
//====================== I2C Position Encoder Settings ======================
//===========================================================================
Expand Down
51 changes: 27 additions & 24 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2502,27 +2502,25 @@ static void clean_up_after_endstop_or_probe_move() {
* Reset calibration results to zero.
*/
void reset_bed_level() {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("reset_bed_level");
#endif
set_bed_leveling_enabled(false);
#if ENABLED(MESH_BED_LEVELING)
if (leveling_is_valid()) {
mbl.reset();
mbl.has_mesh = false;
}
#else
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("reset_bed_level");
#endif
#if ABL_PLANAR
planner.bed_level_matrix.set_to_identity();
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
bilinear_start[X_AXIS] = bilinear_start[Y_AXIS] =
bilinear_grid_spacing[X_AXIS] = bilinear_grid_spacing[Y_AXIS] = 0;
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
z_values[x][y] = NAN;
#elif ENABLED(AUTO_BED_LEVELING_UBL)
ubl.reset();
#endif
#elif ENABLED(AUTO_BED_LEVELING_UBL)
ubl.reset();
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
bilinear_start[X_AXIS] = bilinear_start[Y_AXIS] =
bilinear_grid_spacing[X_AXIS] = bilinear_grid_spacing[Y_AXIS] = 0;
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
z_values[x][y] = NAN;
#elif ABL_PLANAR
planner.bed_level_matrix.set_to_identity();
#endif
}

Expand Down Expand Up @@ -6497,6 +6495,10 @@ inline void gcode_M17() {
) {
if (move_away_flag) return false; // already paused

#ifdef ACTION_ON_PAUSE
SERIAL_ECHOLNPGM("//action:" ACTION_ON_PAUSE);
#endif

if (!DEBUGGING(DRYRUN) && unload_length != 0) {
#if ENABLED(PREVENT_COLD_EXTRUSION)
if (!thermalManager.allow_cold_extrude &&
Expand Down Expand Up @@ -6729,6 +6731,10 @@ inline void gcode_M17() {
lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_STATUS);
#endif

#ifdef ACTION_ON_RESUME
SERIAL_ECHOLNPGM("//action:" ACTION_ON_RESUME);
#endif

#if ENABLED(SDSUPPORT)
if (sd_print_paused) {
card.startFileprint();
Expand Down Expand Up @@ -8600,7 +8606,6 @@ inline void gcode_M121() { endstops.enable_globally(false); }
* Z = override Z raise
*/
inline void gcode_M125() {
point_t park_point = NOZZLE_PARK_POINT;

// Initial retract before move to filament change position
const float retract = parser.seen('L') ? parser.value_axis_units(E_AXIS) : 0
Expand All @@ -8609,16 +8614,14 @@ inline void gcode_M121() { endstops.enable_globally(false); }
#endif
;

// Lift Z axis
if (parser.seenval('Z'))
park_point.z = parser.linearval('Z');
point_t park_point = NOZZLE_PARK_POINT;

// Move XY axes to filament change position or given position
if (parser.seenval('X'))
park_point.x = parser.linearval('X');
if (parser.seenval('X')) park_point.x = parser.linearval('X');
if (parser.seenval('Y')) park_point.y = parser.linearval('Y');

if (parser.seenval('Y'))
park_point.y = parser.linearval('Y');
// Lift Z axis
if (parser.seenval('Z')) park_point.z = parser.linearval('Z');

#if HOTENDS > 1 && DISABLED(DUAL_X_CARRIAGE)
park_point.x += (active_extruder ? hotend_offset[X_AXIS][active_extruder] : 0);
Expand Down Expand Up @@ -9638,7 +9641,7 @@ void quickstop_stepper() {

#if ENABLED(EEPROM_SETTINGS)
const int8_t storage_slot = parser.has_value() ? parser.value_int() : ubl.storage_slot;
const int16_t a = settings.calc_num_meshes();
const uint16_t a = settings.calc_num_meshes();

if (!a) {
SERIAL_PROTOCOLLNPGM("?EEPROM storage not available.");
Expand Down
54 changes: 26 additions & 28 deletions Marlin/configuration_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
* 539 M200 D parser.volumetric_enabled (bool)
* 540 M200 T D planner.filament_size (float x5) (T0..3)
*
* HAVE_TMC2130 || HAVE_TMC2208: 22 bytes
* HAS_TRINAMIC: 22 bytes
* 560 M906 X Stepper X current (uint16_t)
* 562 M906 Y Stepper Y current (uint16_t)
* 564 M906 Z Stepper Z current (uint16_t)
Expand Down Expand Up @@ -203,7 +203,7 @@ MarlinSettings settings;
#include "mesh_bed_leveling.h"
#endif

#if ENABLED(HAVE_TMC2130) || ENABLED(HAVE_TMC2208)
#if HAS_TRINAMIC
#include "stepper_indirection.h"
#endif

Expand Down Expand Up @@ -283,7 +283,7 @@ void MarlinSettings::postprocess() {
bool MarlinSettings::eeprom_error;

#if ENABLED(AUTO_BED_LEVELING_UBL)
int MarlinSettings::meshes_begin;
int16_t MarlinSettings::meshes_begin;
#endif

void MarlinSettings::write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
Expand Down Expand Up @@ -383,9 +383,8 @@ void MarlinSettings::postprocess() {
sizeof(mbl.z_values) == GRID_MAX_POINTS * sizeof(mbl.z_values[0][0]),
"MBL Z array is the wrong size."
);
const bool leveling_is_on = mbl.has_mesh;
const uint8_t mesh_num_x = GRID_MAX_POINTS_X, mesh_num_y = GRID_MAX_POINTS_Y;
EEPROM_WRITE(leveling_is_on);
EEPROM_WRITE(mbl.has_mesh);
EEPROM_WRITE(mbl.z_offset);
EEPROM_WRITE(mesh_num_x);
EEPROM_WRITE(mesh_num_y);
Expand Down Expand Up @@ -581,7 +580,7 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(dummy);
}

#endif // !NO_VOLUMETRICS
#endif

// Save TMC2130 or TMC2208 Configuration, and placeholder values
uint16_t val;
Expand Down Expand Up @@ -1282,18 +1281,18 @@ void MarlinSettings::postprocess() {
}
#endif

int MarlinSettings::calc_num_meshes() {
uint16_t MarlinSettings::calc_num_meshes() {
//obviously this will get more sophisticated once we've added an actual MAT

if (meshes_begin <= 0) return 0;

return (meshes_end - meshes_begin) / sizeof(ubl.z_values);
}

void MarlinSettings::store_mesh(int8_t slot) {
void MarlinSettings::store_mesh(const int8_t slot) {

#if ENABLED(AUTO_BED_LEVELING_UBL)
const int a = calc_num_meshes();
const uint16_t a = calc_num_meshes();
if (!WITHIN(slot, 0, a - 1)) {
#if ENABLED(EEPROM_CHITCHAT)
ubl_invalid_slot(a);
Expand Down Expand Up @@ -1323,11 +1322,11 @@ void MarlinSettings::postprocess() {
#endif
}

void MarlinSettings::load_mesh(int8_t slot, void *into /* = 0 */) {
void MarlinSettings::load_mesh(const int8_t slot, void * const into/*=NULL*/) {

#if ENABLED(AUTO_BED_LEVELING_UBL)

const int16_t a = settings.calc_num_meshes();
const uint16_t a = settings.calc_num_meshes();

if (!WITHIN(slot, 0, a - 1)) {
#if ENABLED(EEPROM_CHITCHAT)
Expand Down Expand Up @@ -1385,17 +1384,13 @@ void MarlinSettings::reset() {
planner.retract_acceleration = DEFAULT_RETRACT_ACCELERATION;
planner.travel_acceleration = DEFAULT_TRAVEL_ACCELERATION;
planner.min_feedrate_mm_s = DEFAULT_MINIMUMFEEDRATE;
planner.min_segment_time_us = DEFAULT_MINSEGMENTTIME;
planner.min_travel_feedrate_mm_s = DEFAULT_MINTRAVELFEEDRATE;
planner.min_segment_time_us = DEFAULT_MINSEGMENTTIME;
planner.max_jerk[X_AXIS] = DEFAULT_XJERK;
planner.max_jerk[Y_AXIS] = DEFAULT_YJERK;
planner.max_jerk[Z_AXIS] = DEFAULT_ZJERK;
planner.max_jerk[E_AXIS] = DEFAULT_EJERK;

#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
new_z_fade_height = 10.0;
#endif

#if HAS_HOME_OFFSET
ZERO(home_offset);
#endif
Expand All @@ -1417,7 +1412,14 @@ void MarlinSettings::reset() {
LOOP_XYZ(i) HOTEND_LOOP() hotend_offset[i][e] = tmp4[i][e];
#endif

// Applies to all MBL and ABL
//
// Global Leveling
//

#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
new_z_fade_height = 0.0;
#endif

#if HAS_LEVELING
reset_bed_level();
#endif
Expand Down Expand Up @@ -1478,10 +1480,6 @@ void MarlinSettings::reset() {
lcd_preheat_fan_speed[1] = PREHEAT_2_FAN_SPEED;
#endif

#if HAS_LCD_CONTRAST
lcd_contrast = DEFAULT_LCD_CONTRAST;
#endif

#if ENABLED(PIDTEMP)
#if ENABLED(PID_PARAMS_PER_HOTEND) && HOTENDS > 1
HOTEND_LOOP()
Expand All @@ -1505,6 +1503,10 @@ void MarlinSettings::reset() {
thermalManager.bedKd = scalePID_d(DEFAULT_bedKd);
#endif

#if HAS_LCD_CONTRAST
lcd_contrast = DEFAULT_LCD_CONTRAST;
#endif

#if ENABLED(FWRETRACT)
autoretract_enabled = false;
retract_length = RETRACT_LENGTH;
Expand Down Expand Up @@ -1599,10 +1601,6 @@ void MarlinSettings::reset() {
stepper.digipot_current(q, (stepper.motor_current_setting[q] = tmp_motor_current_setting[q]));
#endif

#if ENABLED(AUTO_BED_LEVELING_UBL)
ubl.reset();
#endif

#if ENABLED(SKEW_CORRECTION_GCODE)
planner.xy_skew_factor = XY_SKEW_FACTOR;
#if ENABLED(SKEW_CORRECTION_FOR_Z)
Expand Down Expand Up @@ -1710,7 +1708,7 @@ void MarlinSettings::reset() {
SERIAL_ECHOLNPGM(" M200 D0");
}

#endif
#endif // !NO_VOLUMETRICS

if (!forReplay) {
CONFIG_ECHO_START;
Expand Down Expand Up @@ -2062,7 +2060,7 @@ void MarlinSettings::reset() {
/**
* TMC2130 stepper driver current
*/
#if ENABLED(HAVE_TMC2130)
#if HAS_TRINAMIC
if (!forReplay) {
CONFIG_ECHO_START;
SERIAL_ECHOLNPGM("Stepper driver current:");
Expand Down Expand Up @@ -2108,7 +2106,7 @@ void MarlinSettings::reset() {
/**
* TMC2130 Sensorless homing thresholds
*/
#if ENABLED(HAVE_TMC2130) && ENABLED(SENSORLESS_HOMING)
#if ENABLED(SENSORLESS_HOMING)
if (!forReplay) {
CONFIG_ECHO_START;
SERIAL_ECHOLNPGM("Sensorless homing threshold:");
Expand Down
16 changes: 8 additions & 8 deletions Marlin/configuration_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class MarlinSettings {

#if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
// That can store is enabled
FORCE_INLINE static int get_start_of_meshes() { return meshes_begin; }
FORCE_INLINE static int get_end_of_meshes() { return meshes_end; }
static int calc_num_meshes();
static void store_mesh(int8_t slot);
static void load_mesh(int8_t slot, void *into = 0);
FORCE_INLINE static int16_t get_start_of_meshes() { return meshes_begin; }
FORCE_INLINE static int16_t get_end_of_meshes() { return meshes_end; }
static uint16_t calc_num_meshes();
static void store_mesh(const int8_t slot);
static void load_mesh(const int8_t slot, void * const into=NULL);

//static void delete_mesh(); // necessary if we have a MAT
//static void defrag_meshes(); // "
Expand All @@ -66,9 +66,9 @@ class MarlinSettings {

#if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
// That can store is enabled
static int meshes_begin;
const static int meshes_end = E2END - 128; // 128 is a placeholder for the size of the MAT; the MAT will always
// live at the very end of the eeprom
static int16_t meshes_begin;
const static int16_t meshes_end = E2END - 128; // 128 is a placeholder for the size of the MAT; the MAT will always
// live at the very end of the eeprom

#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,14 @@
*/
//#define ACTION_ON_KILL "poweroff"

/**
* Specify an action command to send to the host on pause and resume.
* Will be sent in the form '//action:ACTION_ON_PAUSE', e.g. '//action:pause'.
* The host must be configured to handle the action command.
*/
//#define ACTION_ON_PAUSE "pause"
//#define ACTION_ON_RESUME "resume"

//===========================================================================
//====================== I2C Position Encoder Settings ======================
//===========================================================================
Expand Down
8 changes: 8 additions & 0 deletions Marlin/example_configurations/Anet/A6/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,14 @@
*/
//#define ACTION_ON_KILL "poweroff"

/**
* Specify an action command to send to the host on pause and resume.
* Will be sent in the form '//action:ACTION_ON_PAUSE', e.g. '//action:pause'.
* The host must be configured to handle the action command.
*/
//#define ACTION_ON_PAUSE "pause"
//#define ACTION_ON_RESUME "resume"

//===========================================================================
//====================== I2C Position Encoder Settings ======================
//===========================================================================
Expand Down
8 changes: 8 additions & 0 deletions Marlin/example_configurations/Anet/A8/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,14 @@
*/
//#define ACTION_ON_KILL "poweroff"

/**
* Specify an action command to send to the host on pause and resume.
* Will be sent in the form '//action:ACTION_ON_PAUSE', e.g. '//action:pause'.
* The host must be configured to handle the action command.
*/
//#define ACTION_ON_PAUSE "pause"
//#define ACTION_ON_RESUME "resume"

//===========================================================================
//====================== I2C Position Encoder Settings ======================
//===========================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,14 @@
*/
//#define ACTION_ON_KILL "poweroff"

/**
* Specify an action command to send to the host on pause and resume.
* Will be sent in the form '//action:ACTION_ON_PAUSE', e.g. '//action:pause'.
* The host must be configured to handle the action command.
*/
//#define ACTION_ON_PAUSE "pause"
//#define ACTION_ON_RESUME "resume"

//===========================================================================
//====================== I2C Position Encoder Settings ======================
//===========================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,14 @@
*/
//#define ACTION_ON_KILL "poweroff"

/**
* Specify an action command to send to the host on pause and resume.
* Will be sent in the form '//action:ACTION_ON_PAUSE', e.g. '//action:pause'.
* The host must be configured to handle the action command.
*/
//#define ACTION_ON_PAUSE "pause"
//#define ACTION_ON_RESUME "resume"

//===========================================================================
//====================== I2C Position Encoder Settings ======================
//===========================================================================
Expand Down
Loading

0 comments on commit 19e768d

Please sign in to comment.