Marlin: M84, M84 Sxxx, M85 Sxxx, and M18 Sxx

Note, M18 Sxx, M84 Sxx, and M85 Sxx have the same implementation.

M84 is different.
This commit is contained in:
Rob Giseburt
2017-02-06 15:18:06 -06:00
parent b50513efe5
commit bca3848b9a
4 changed files with 51 additions and 4 deletions

View File

@@ -192,6 +192,7 @@ typedef enum { // these are in order to optimized CASE
NEXT_ACTION_MARLIN_RESET_LINE_NUMBERS, // M110
NEXT_ACTION_MARLIN_REPORT_VERSION, // M115
NEXT_ACTION_MARLIN_DISPLAY_ON_SCREEN, // M117
NEXT_ACTION_MARLIN_SET_MT, // M84 (with S), M85
#endif
} cmNextAction;

View File

@@ -743,7 +743,9 @@ stat_t _parse_gcode_block(char *buf, char *active_comment)
case 117: return STAT_OK; //SET_NON_MODAL (next_action, NEXT_ACTION_MARLIN_DISPLAY_ON_SCREEN);
case 18: // compatibility alias for M84
case 84: SET_NON_MODAL (next_action, NEXT_ACTION_MARLIN_DISABLE_MOTORS);
case 85: SET_NON_MODAL (next_action, NEXT_ACTION_MARLIN_SET_MT);
case 110: SET_NON_MODAL (next_action, NEXT_ACTION_MARLIN_RESET_LINE_NUMBERS);
case 111: return STAT_OK; // ignore M111, and don't process contents of the line further
@@ -941,11 +943,26 @@ stat_t _execute_gcode_block(char *active_comment)
}
break;
}
case NEXT_ACTION_MARLIN_DISABLE_MOTORS: { // M84
ritorno(marlin_disable_motors());
case NEXT_ACTION_MARLIN_DISABLE_MOTORS: { // M84 and M18
if (gf.S_word) {
ritorno(marlin_set_motor_timeout(gv.S_word));
gf.S_word = false;
} else {
ritorno(marlin_disable_motors());
}
break;
}
case NEXT_ACTION_MARLIN_DISPLAY_ON_SCREEN: { // M184
case NEXT_ACTION_MARLIN_SET_MT: { // M85
if (gf.S_word) {
ritorno(marlin_set_motor_timeout(gv.S_word));
gf.S_word = false;
} else {
// this means nothing, but it's not an error
return status;
}
}
case NEXT_ACTION_MARLIN_DISPLAY_ON_SCREEN: { // M117
// ignore for now
return status;
}

View File

@@ -31,6 +31,7 @@
#include "temperature.h" // for temperature controls
#include "json_parser.h"
#include "planner.h"
#include "stepper.h" // for MOTOR_TIMEOUT_SECONDS_MIN/MOTOR_TIMEOUT_SECONDS_MAX
#include "MotateTimers.h" // for char definitions
#include "MotateUniqueID.h" // for Motate::UUID
@@ -484,7 +485,7 @@ stat_t marlin_set_fan_speed(const uint8_t fan, float speed)
/*
* marlin_disable_motors() - M84
* marlin_disable_motors() - M84 (without S)
*
*/
@@ -500,6 +501,33 @@ stat_t marlin_disable_motors()
return (STAT_OK);
}
/*
* marlin_set_motor_timeout() - M84 (with S), M85 Sxxx
*
*/
stat_t marlin_set_motor_timeout(float s) // M18 Sxxx, M84 Sxxx, M85 Sxxx
{
if (s < MOTOR_TIMEOUT_SECONDS_MIN) {
return (STAT_INPUT_LESS_THAN_MIN_VALUE);
}
if (s > MOTOR_TIMEOUT_SECONDS_MAX) {
return (STAT_INPUT_EXCEEDS_MAX_VALUE);
}
char buffer[128];
char *str = buffer;
// TODO: support other fans, or remapping output
str_concat(str, "{mt:");
str += floattoa(str, s, 1);
str_concat(str, "}");
cm_json_command(buffer);
return (STAT_OK);
}
/*
* marlin_report_version() - M115

View File

@@ -48,6 +48,7 @@ stat_t cm_marlin_set_extruder_mode(const uint8_t mode); // M82, M82
stat_t marlin_set_fan_speed(const uint8_t fan, float speed); // M106, M107
stat_t marlin_disable_motors(); // M84
stat_t marlin_set_motor_timeout(float s); // M18 Sxxx, M84 Sxxx, M85 Sxxx
stat_t marlin_report_version(); // M115
#endif // End of include guard: MARLIN_COMPAT_H_ONCE