Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix 2.0.x #16

Merged
merged 5 commits into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,6 @@ bool wait_for_heatup = true;

#endif

// Inactivity shutdown
millis_t max_inactive_time, // = 0
stepper_inactive_time = SEC_TO_MS(DEFAULT_STEPPER_DEACTIVE_TIME);

#if PIN_EXISTS(CHDK)
extern millis_t chdk_timeout;
#endif
Expand Down Expand Up @@ -469,26 +465,39 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {

const millis_t ms = millis();

if (max_inactive_time && ELAPSED(ms, gcode.previous_move_ms + max_inactive_time)) {
// Prevent steppers timing-out in the middle of M600
// unless PAUSE_PARK_NO_STEPPER_TIMEOUT is disabled
const bool parked_or_ignoring = ignore_stepper_queue ||
(BOTH(ADVANCED_PAUSE_FEATURE, PAUSE_PARK_NO_STEPPER_TIMEOUT) && did_pause_print);

// Reset both the M18/M84 activity timeout and the M85 max 'kill' timeout
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);
kill();
}

// Prevent steppers timing-out in the middle of M600
#define STAY_TEST (BOTH(ADVANCED_PAUSE_FEATURE, PAUSE_PARK_NO_STEPPER_TIMEOUT) && did_pause_print)
// M18 / M94 : Handle steppers inactive time timeout
if (gcode.stepper_inactive_time) {

if (stepper_inactive_time) {
static bool already_shutdown_steppers; // = false

// Any moves in the planner? Resets both the M18/M84
// activity timeout and the M85 max 'kill' timeout
if (planner.has_blocks_queued())
gcode.reset_stepper_timeout();
else if (!STAY_TEST && !ignore_stepper_queue && ELAPSED(ms, gcode.previous_move_ms + stepper_inactive_time)) {
gcode.reset_stepper_timeout(ms);
else if (!parked_or_ignoring && gcode.stepper_inactive_timeout()) {
if (!already_shutdown_steppers) {
already_shutdown_steppers = true; // L6470 SPI will consume 99% of free time without this

// Individual axes will be disabled if configured
if (ENABLED(DISABLE_INACTIVE_X)) DISABLE_AXIS_X();
if (ENABLED(DISABLE_INACTIVE_Y)) DISABLE_AXIS_Y();
if (ENABLED(DISABLE_INACTIVE_Z)) DISABLE_AXIS_Z();
if (ENABLED(DISABLE_INACTIVE_E)) disable_e_steppers();

#if BOTH(HAS_LCD_MENU, AUTO_BED_LEVELING_UBL)
if (ubl.lcd_map_control) {
ubl.lcd_map_control = false;
Expand Down Expand Up @@ -601,7 +610,7 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
}
#endif // !SWITCHING_EXTRUDER

gcode.reset_stepper_timeout();
gcode.reset_stepper_timeout(ms);
}
#endif // EXTRUDER_RUNOUT_PREVENT

Expand Down
3 changes: 0 additions & 3 deletions Marlin/src/MarlinCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ extern bool wait_for_heatup;
void wait_for_user_response(millis_t ms=0, const bool no_sleep=false);
#endif

// Inactivity shutdown timer
extern millis_t max_inactive_time, stepper_inactive_time;

#if ENABLED(PSU_CONTROL)
extern bool powersupply_on;
#define PSU_PIN_ON() do{ OUT_WRITE(PS_ON_PIN, PSU_ACTIVE_HIGH); powersupply_on = true; }while(0)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/bedlevel/ubl/ubl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
if (human) SERIAL_CHAR(is_current ? ']' : ' ');

SERIAL_FLUSHTX();
idle();
idle_no_sleep();
}
if (!lcd) SERIAL_EOL();

Expand Down
4 changes: 3 additions & 1 deletion Marlin/src/gcode/bedlevel/abl/G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@
*/
G29_TYPE GcodeSuite::G29() {

reset_stepper_timeout();

const bool seenQ = EITHER(DEBUG_LEVELING_FEATURE, PROBE_MANUALLY) && parser.seen('Q');

// G29 Q is also available if debugging
Expand Down Expand Up @@ -675,7 +677,7 @@ G29_TYPE GcodeSuite::G29() {
#endif

abl_should_enable = false;
idle();
idle_no_sleep();

} // inner
} // outer
Expand Down
11 changes: 7 additions & 4 deletions Marlin/src/gcode/calibrate/G28.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,15 @@
*/
void GcodeSuite::G28() {

#if ENABLED(LASER_MOVE_G28_OFF)
cutter.set_inline_enabled(false); // turn off laser
#endif

if (DEBUGGING(LEVELING)) {
DEBUG_ECHOLNPGM(">>> G28");
log_machine_info();
}

#if ENABLED(LASER_MOVE_G28_OFF)
cutter.set_inline_enabled(false); // turn off laser
#endif

TERN_(DWIN_CREALITY_LCD, HMI_flag.home_flag = true);

#if ENABLED(DUAL_X_CARRIAGE)
Expand Down Expand Up @@ -251,6 +251,9 @@ void GcodeSuite::G28() {

TERN_(CNC_WORKSPACE_PLANES, workspace_plane = PLANE_XY);

// Count this command as movement / activity
reset_stepper_timeout();

#define HAS_CURRENT_HOME(N) (defined(N##_CURRENT_HOME) && N##_CURRENT_HOME != N##_CURRENT)
#if HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(X2) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Y2)
#define HAS_HOMING_CURRENT 1
Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/gcode/config/M301.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
/**
* M301: Set PID parameters P I D (and optionally C, L)
*
* E[extruder] Default: 0
*
* P[float] Kp term
* I[float] Ki term (unscaled)
* D[float] Kd term (unscaled)
Expand Down Expand Up @@ -65,6 +67,7 @@ void GcodeSuite::M301() {
#endif

thermalManager.updatePID();

SERIAL_ECHO_START();
#if ENABLED(PID_PARAMS_PER_HOTEND)
SERIAL_ECHOPAIR(" e:", e); // specify extruder in serial output
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/gcode/control/M17_M18_M84.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ void GcodeSuite::M17() {
*/
void GcodeSuite::M18_M84() {
if (parser.seenval('S')) {
reset_stepper_timeout();
stepper_inactive_time = parser.value_millis_from_seconds();
}
else {
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/gcode/control/M85.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/

#include "../gcode.h"
#include "../../MarlinCore.h" // for max_inactive_time

/**
* M85: Set inactivity shutdown timer with parameter S<seconds>. To disable set zero (default)
Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/gcode/control/T.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ void GcodeSuite::T(const uint8_t tool_index) {
DEBUG_POS("BEFORE", current_position);
}

// Count this command as movement / activity
reset_stepper_timeout();

#if ENABLED(PRUSA_MMU2)
if (parser.string_arg) {
mmu2.tool_change(parser.string_arg); // Special commands T?/Tx/Tc
Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/gcode/gcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ GcodeSuite gcode;

#include "../MarlinCore.h" // for idle()

millis_t GcodeSuite::previous_move_ms;
// Inactivity shutdown
millis_t GcodeSuite::previous_move_ms = 0,
GcodeSuite::max_inactive_time = 0,
GcodeSuite::stepper_inactive_time = SEC_TO_MS(DEFAULT_STEPPER_DEACTIVE_TIME);

// Relative motion mode for each logical axis
static constexpr xyze_bool_t ar_init = AXIS_RELATIVE_MODES;
Expand Down
10 changes: 8 additions & 2 deletions Marlin/src/gcode/gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,14 @@ class GcodeSuite {
static bool select_coordinate_system(const int8_t _new);
#endif

static millis_t previous_move_ms;
FORCE_INLINE static void reset_stepper_timeout() { previous_move_ms = millis(); }
static millis_t previous_move_ms, max_inactive_time, stepper_inactive_time;
FORCE_INLINE static void reset_stepper_timeout(const millis_t ms=millis()) { previous_move_ms = ms; }
FORCE_INLINE static bool stepper_max_timed_out(const millis_t ms=millis()) {
return max_inactive_time && ELAPSED(ms, previous_move_ms + max_inactive_time);
}
FORCE_INLINE static bool stepper_inactive_timeout(const millis_t ms=millis()) {
return ELAPSED(ms, previous_move_ms + stepper_inactive_time);
}

static int8_t get_target_extruder_from_command();
static int8_t get_target_e_stepper_from_command();
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,8 @@
#define HAS_MULTI_HOTEND 1
#define HAS_HOTEND_OFFSET 1
#endif
#else
#undef PID_PARAMS_PER_HOTEND
#endif

// Helper macros for extruder and hotend arrays
Expand Down
46 changes: 25 additions & 21 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -1629,28 +1629,8 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
#endif

/**
* Test Heater, Temp Sensor, and Extruder Pins; Sensor Type must also be set.
* A Sensor ID has to be set for each heater
*/
#if !HAS_HEATER_0
#error "HEATER_0_PIN not defined for this board."
#elif !ANY_PIN(TEMP_0, MAX6675_SS)
#error "TEMP_0_PIN not defined for this board."
#elif ((defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && !PINS_EXIST(E0_STEP, E0_DIR))
#error "E0_STEP_PIN or E0_DIR_PIN not defined for this board."
#elif ( !(defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && (!PINS_EXIST(E0_STEP, E0_DIR) || !HAS_E0_ENABLE))
#error "E0_STEP_PIN, E0_DIR_PIN, or E0_ENABLE_PIN not defined for this board."
#elif EXTRUDERS && TEMP_SENSOR_0 == 0
#error "TEMP_SENSOR_0 is required with any extruders."
#endif

// Pins are required for heaters
#if ENABLED(HEATER_0_USES_MAX6675) && !PIN_EXISTS(MAX6675_SS)
#error "MAX6675_SS_PIN (required for TEMP_SENSOR_0) not defined for this board."
#elif HAS_HOTEND && !HAS_TEMP_HOTEND
#error "TEMP_0_PIN (required for TEMP_SENSOR_0) not defined for this board."
#elif EITHER(HAS_MULTI_HOTEND, HEATERS_PARALLEL) && !HAS_HEATER_1
#error "HEATER_1_PIN not defined for this board."
#endif

#if HAS_MULTI_HOTEND
#if ENABLED(HEATER_1_USES_MAX6675) && !PIN_EXISTS(MAX6675_SS2)
Expand Down Expand Up @@ -1792,6 +1772,30 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
#error "TEMP_SENSOR_1 is required with TEMP_SENSOR_1_AS_REDUNDANT."
#endif

/**
* Test Heater, Temp Sensor, and Extruder Pins
*/
#if !HAS_HEATER_0
#error "HEATER_0_PIN not defined for this board."
#elif !ANY_PIN(TEMP_0, MAX6675_SS)
#error "TEMP_0_PIN not defined for this board."
#elif ((defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && !PINS_EXIST(E0_STEP, E0_DIR))
#error "E0_STEP_PIN or E0_DIR_PIN not defined for this board."
#elif ( !(defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && (!PINS_EXIST(E0_STEP, E0_DIR) || !HAS_E0_ENABLE))
#error "E0_STEP_PIN, E0_DIR_PIN, or E0_ENABLE_PIN not defined for this board."
#elif EXTRUDERS && TEMP_SENSOR_0 == 0
#error "TEMP_SENSOR_0 is required if there are any extruders."
#endif

// Pins are required for heaters
#if ENABLED(HEATER_0_USES_MAX6675) && !PIN_EXISTS(MAX6675_SS)
#error "MAX6675_SS_PIN (required for TEMP_SENSOR_0) not defined for this board."
#elif HAS_HOTEND && !HAS_TEMP_HOTEND
#error "TEMP_0_PIN (required for TEMP_SENSOR_0) not defined for this board."
#elif EITHER(HAS_MULTI_HOTEND, HEATERS_PARALLEL) && !HAS_HEATER_1
#error "HEATER_1_PIN is not defined. TEMP_SENSOR_1 might not be set, or the board (not EEB / EEF?) doesn't define a pin."
#endif

/**
* Temperature status LEDs
*/
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/inc/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* version was tagged.
*/
#ifndef STRING_DISTRIBUTION_DATE
#define STRING_DISTRIBUTION_DATE "2020-07-01"
#define STRING_DISTRIBUTION_DATE "2020-07-02"
#endif

/**
Expand Down
12 changes: 4 additions & 8 deletions Marlin/src/lcd/menu/menu_advanced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,12 @@ void menu_cancelobject();
// Helpers for editing PID Ki & Kd values
// grab the PID value out of the temp variable; scale it; then update the PID driver
void copy_and_scalePID_i(int16_t e) {
#if DISABLED(PID_PARAMS_PER_HOTEND) || HOTENDS == 1
UNUSED(e);
#endif
TERN(PID_PARAMS_PER_HOTEND,,UNUSED(e));
PID_PARAM(Ki, e) = scalePID_i(raw_Ki);
thermalManager.updatePID();
}
void copy_and_scalePID_d(int16_t e) {
#if DISABLED(PID_PARAMS_PER_HOTEND) || HOTENDS == 1
UNUSED(e);
#endif
TERN(PID_PARAMS_PER_HOTEND,,UNUSED(e));
PID_PARAM(Kd, e) = scalePID_d(raw_Kd);
thermalManager.updatePID();
}
Expand All @@ -239,7 +235,7 @@ void menu_cancelobject();

#if HAS_HOTEND
DEFINE_PIDTEMP_FUNCS(0);
#if BOTH(HAS_MULTI_HOTEND, PID_PARAMS_PER_HOTEND)
#if ENABLED(PID_PARAMS_PER_HOTEND)
REPEAT_S(1, HOTENDS, DEFINE_PIDTEMP_FUNCS)
#endif
#endif
Expand Down Expand Up @@ -314,7 +310,7 @@ void menu_cancelobject();
#endif

PID_EDIT_MENU_ITEMS(0);
#if BOTH(HAS_MULTI_HOTEND, PID_PARAMS_PER_HOTEND)
#if ENABLED(PID_PARAMS_PER_HOTEND)
REPEAT_S(1, HOTENDS, PID_EDIT_MENU_ITEMS)
#endif

Expand Down
59 changes: 53 additions & 6 deletions Marlin/src/module/configuration_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2587,12 +2587,59 @@ void MarlinSettings::reset() {
//

#if ENABLED(PIDTEMP)
#if ENABLED(PID_PARAMS_PER_HOTEND)
constexpr float defKp[] =
#ifdef DEFAULT_Kp_LIST
DEFAULT_Kp_LIST
#else
ARRAY_BY_HOTENDS1(DEFAULT_Kp)
#endif
, defKi[] =
#ifdef DEFAULT_Ki_LIST
DEFAULT_Ki_LIST
#else
ARRAY_BY_HOTENDS1(DEFAULT_Ki)
#endif
, defKd[] =
#ifdef DEFAULT_Kd_LIST
DEFAULT_Kd_LIST
#else
ARRAY_BY_HOTENDS1(DEFAULT_Kd)
#endif
;
static_assert(WITHIN(COUNT(defKp), 1, HOTENDS), "DEFAULT_Kp_LIST must have between 1 and HOTENDS items.");
static_assert(WITHIN(COUNT(defKi), 1, HOTENDS), "DEFAULT_Ki_LIST must have between 1 and HOTENDS items.");
static_assert(WITHIN(COUNT(defKd), 1, HOTENDS), "DEFAULT_Kd_LIST must have between 1 and HOTENDS items.");
#if ENABLED(PID_EXTRUSION_SCALING)
constexpr float defKc[] =
#ifdef DEFAULT_Kc_LIST
DEFAULT_Kc_LIST
#else
ARRAY_BY_HOTENDS1(DEFAULT_Kc)
#endif
;
static_assert(WITHIN(COUNT(defKc), 1, HOTENDS), "DEFAULT_Kc_LIST must have between 1 and HOTENDS items.");
#endif
#if ENABLED(PID_FAN_SCALING)
constexpr float defKf[] =
#ifdef DEFAULT_Kf_LIST
DEFAULT_Kf_LIST
#else
ARRAY_BY_HOTENDS1(DEFAULT_Kf)
#endif
;
static_assert(WITHIN(COUNT(defKf), 1, HOTENDS), "DEFAULT_Kf_LIST must have between 1 and HOTENDS items.");
#endif
#define PID_DEFAULT(N,E) def##N[E]
#else
#define PID_DEFAULT(N,E) DEFAULT_##N
#endif
HOTEND_LOOP() {
PID_PARAM(Kp, e) = float(DEFAULT_Kp);
PID_PARAM(Ki, e) = scalePID_i(DEFAULT_Ki);
PID_PARAM(Kd, e) = scalePID_d(DEFAULT_Kd);
TERN_(PID_EXTRUSION_SCALING, PID_PARAM(Kc, e) = DEFAULT_Kc);
TERN_(PID_FAN_SCALING, PID_PARAM(Kf, e) = DEFAULT_Kf);
PID_PARAM(Kp, e) = float(PID_DEFAULT(Kp, ALIM(e, defKp)));
PID_PARAM(Ki, e) = scalePID_i(PID_DEFAULT(Ki, ALIM(e, defKi)));
PID_PARAM(Kd, e) = scalePID_d(PID_DEFAULT(Kd, ALIM(e, defKd)));
TERN_(PID_EXTRUSION_SCALING, PID_PARAM(Kc, e) = float(PID_DEFAULT(Kc, ALIM(e, defKc))));
TERN_(PID_FAN_SCALING, PID_PARAM(Kf, e) = float(PID_DEFAULT(Kf, ALIM(e, defKf))));
}
#endif

Expand Down Expand Up @@ -3140,7 +3187,7 @@ void MarlinSettings::reset() {
HOTEND_LOOP() {
CONFIG_ECHO_START();
SERIAL_ECHOPAIR_P(
#if BOTH(HAS_MULTI_HOTEND, PID_PARAMS_PER_HOTEND)
#if ENABLED(PID_PARAMS_PER_HOTEND)
PSTR(" M301 E"), e,
SP_P_STR
#else
Expand Down
Loading