Merge upstream changes from Marlin 2.1.2

This commit is contained in:
Stefan Kalscheuer
2022-12-19 15:23:45 +01:00
parent fe9ea826a5
commit 67c7ce7b79
427 changed files with 10732 additions and 7834 deletions

View File

@@ -96,22 +96,23 @@ void BDS_Leveling::process() {
const float z_sensor = (tmp & 0x3FF) / 100.0f;
if (cur_z < 0) config_state = 0;
//float abs_z = current_position.z > cur_z ? (current_position.z - cur_z) : (cur_z - current_position.z);
if ( cur_z < config_state * 0.1f
&& config_state > 0
&& old_cur_z == cur_z
&& old_buf_z == current_position.z
&& z_sensor < (MAX_BD_HEIGHT)
) {
babystep.set_mm(Z_AXIS, cur_z - z_sensor);
#if ENABLED(DEBUG_OUT_BD)
SERIAL_ECHOLNPGM("BD:", z_sensor, ", Z:", cur_z, "|", current_position.z);
#endif
}
else {
babystep.set_mm(Z_AXIS, 0);
//if (old_cur_z <= cur_z) Z_DIR_WRITE(!INVERT_Z_DIR);
stepper.set_directions();
}
#if ENABLED(BABYSTEPPING)
if (cur_z < config_state * 0.1f
&& config_state > 0
&& old_cur_z == cur_z
&& old_buf_z == current_position.z
&& z_sensor < (MAX_BD_HEIGHT)
) {
babystep.set_mm(Z_AXIS, cur_z - z_sensor);
#if ENABLED(DEBUG_OUT_BD)
SERIAL_ECHOLNPGM("BD:", z_sensor, ", Z:", cur_z, "|", current_position.z);
#endif
}
else {
babystep.set_mm(Z_AXIS, 0); //if (old_cur_z <= cur_z) Z_DIR_WRITE(!INVERT_Z_DIR);
stepper.set_directions();
}
#endif
old_cur_z = cur_z;
old_buf_z = current_position.z;
endstops.bdp_state_update(z_sensor <= 0.01f);

View File

@@ -57,6 +57,7 @@ bool leveling_is_valid() {
* Enable: Current position = "unleveled" physical position
*/
void set_bed_leveling_enabled(const bool enable/*=true*/) {
DEBUG_SECTION(log_sble, "set_bed_leveling_enabled", DEBUGGING(LEVELING));
const bool can_change = TERN1(AUTO_BED_LEVELING_BILINEAR, !enable || leveling_is_valid());
@@ -75,9 +76,9 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) {
planner.synchronize();
// Get the corrected leveled / unleveled position
planner.apply_modifiers(current_position); // Physical position with all modifiers
planner.leveling_active ^= true; // Toggle leveling between apply and unapply
planner.unapply_modifiers(current_position); // Logical position with modifiers removed
planner.apply_modifiers(current_position, true); // Physical position with all modifiers
planner.leveling_active ^= true; // Toggle leveling between apply and unapply
planner.unapply_modifiers(current_position, true); // Logical position with modifiers removed
sync_plan_position();
_report_leveling();

View File

@@ -260,7 +260,7 @@ bool unified_bed_leveling::sanity_check() {
*/
void GcodeSuite::M1004() {
#define ALIGN_GCODE TERN(Z_STEPPER_AUTO_ALIGN, "G34", "")
#define ALIGN_GCODE TERN(Z_STEPPER_AUTO_ALIGN, "G34\n", "")
#define PROBE_GCODE TERN(HAS_BED_PROBE, "G29P1\nG29P3", "G29P4R")
#if HAS_HOTEND
@@ -280,7 +280,7 @@ bool unified_bed_leveling::sanity_check() {
#endif
process_subcommands_now(FPSTR(G28_STR)); // Home
process_subcommands_now(F(ALIGN_GCODE "\n" // Align multi z axis if available
process_subcommands_now(F(ALIGN_GCODE // Align multi z axis if available
PROBE_GCODE "\n" // Build mesh with available hardware
"G29P3\nG29P3")); // Ensure mesh is complete by running smart fill twice

View File

@@ -407,7 +407,7 @@ void unified_bed_leveling::G29() {
z_values[x][x2] += 9.999f; // We want the altered line several mesh points thick
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onMeshUpdate(x, x, z_values[x][x]);
ExtUI::onMeshUpdate(x, (x2), z_values[x][x2]);
ExtUI::onMeshUpdate(x, x2, z_values[x][x2]);
#endif
}
break;

View File

@@ -336,9 +336,9 @@
#if IS_SCARA
#define DELTA_SEGMENT_MIN_LENGTH 0.25 // SCARA minimum segment size is 0.25mm
#elif ENABLED(DELTA)
#define DELTA_SEGMENT_MIN_LENGTH 0.10 // mm (still subject to DELTA_SEGMENTS_PER_SECOND)
#define DELTA_SEGMENT_MIN_LENGTH 0.10 // mm (still subject to DEFAULT_SEGMENTS_PER_SECOND)
#elif ENABLED(POLARGRAPH)
#define DELTA_SEGMENT_MIN_LENGTH 0.10 // mm (still subject to DELTA_SEGMENTS_PER_SECOND)
#define DELTA_SEGMENT_MIN_LENGTH 0.10 // mm (still subject to DEFAULT_SEGMENTS_PER_SECOND)
#else // CARTESIAN
#ifdef LEVELED_SEGMENT_LENGTH
#define DELTA_SEGMENT_MIN_LENGTH LEVELED_SEGMENT_LENGTH
@@ -423,10 +423,12 @@
LIMIT(icell.x, 0, GRID_MAX_CELLS_X);
LIMIT(icell.y, 0, GRID_MAX_CELLS_Y);
float z_x0y0 = z_values[icell.x ][icell.y ], // z at lower left corner
z_x1y0 = z_values[icell.x+1][icell.y ], // z at upper left corner
z_x0y1 = z_values[icell.x ][icell.y+1], // z at lower right corner
z_x1y1 = z_values[icell.x+1][icell.y+1]; // z at upper right corner
const int8_t ncellx = _MIN(icell.x+1, GRID_MAX_CELLS_X),
ncelly = _MIN(icell.y+1, GRID_MAX_CELLS_Y);
float z_x0y0 = z_values[icell.x][icell.y], // z at lower left corner
z_x1y0 = z_values[ncellx ][icell.y], // z at upper left corner
z_x0y1 = z_values[icell.x][ncelly ], // z at lower right corner
z_x1y1 = z_values[ncellx ][ncelly ]; // z at upper right corner
if (isnan(z_x0y0)) z_x0y0 = 0; // ideally activating planner.leveling_active (G29 A)
if (isnan(z_x1y0)) z_x1y0 = 0; // should refuse if any invalid mesh points

View File

@@ -38,8 +38,6 @@ bool BLTouch::od_5v_mode; // Initialized by settings.load, 0 = Open Drai
#include "../module/servo.h"
#include "../module/probe.h"
void stop();
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../core/debug_out.h"

View File

@@ -40,6 +40,9 @@ uint8_t ControllerFan::speed;
void ControllerFan::setup() {
SET_OUTPUT(CONTROLLER_FAN_PIN);
#ifdef CONTROLLER_FAN2_PIN
SET_OUTPUT(CONTROLLER_FAN2_PIN);
#endif
init();
}
@@ -72,6 +75,22 @@ void ControllerFan::update() {
? settings.active_speed : settings.idle_speed
);
speed = CALC_FAN_SPEED(speed);
#if FAN_KICKSTART_TIME
static millis_t fan_kick_end = 0;
if (speed > FAN_OFF_PWM) {
if (!fan_kick_end) {
fan_kick_end = ms + FAN_KICKSTART_TIME; // May be longer based on slow update interval for controller fn check. Sets minimum
speed = FAN_KICKSTART_POWER;
}
else if (PENDING(ms, fan_kick_end))
speed = FAN_KICKSTART_POWER;
}
else
fan_kick_end = 0;
#endif
#if ENABLED(FAN_SOFT_PWM)
thermalManager.soft_pwm_controller_speed = speed;
#else
@@ -79,6 +98,13 @@ void ControllerFan::update() {
hal.set_pwm_duty(pin_t(CONTROLLER_FAN_PIN), speed);
else
WRITE(CONTROLLER_FAN_PIN, speed > 0);
#ifdef CONTROLLER_FAN2_PIN
if (PWM_PIN(CONTROLLER_FAN2_PIN))
hal.set_pwm_duty(pin_t(CONTROLLER_FAN2_PIN), speed);
else
WRITE(CONTROLLER_FAN2_PIN, speed > 0);
#endif
#endif
}
}

View File

@@ -33,6 +33,9 @@
// Static data members
bool EmergencyParser::killed_by_M112, // = false
EmergencyParser::quickstop_by_M410,
#if ENABLED(SDSUPPORT)
EmergencyParser::sd_abort_by_M524,
#endif
EmergencyParser::enabled;
#if ENABLED(HOST_PROMPT_SUPPORT)

View File

@@ -49,7 +49,7 @@ class EmergencyParser {
public:
// Currently looking for: M108, M112, M410, M876 S[0-9], S000, P000, R000
// Currently looking for: M108, M112, M410, M524, M876 S[0-9], S000, P000, R000
enum State : uint8_t {
EP_RESET,
EP_N,
@@ -58,6 +58,9 @@ public:
EP_M10, EP_M108,
EP_M11, EP_M112,
EP_M4, EP_M41, EP_M410,
#if ENABLED(SDSUPPORT)
EP_M5, EP_M52, EP_M524,
#endif
#if ENABLED(HOST_PROMPT_SUPPORT)
EP_M8, EP_M87, EP_M876, EP_M876S, EP_M876SN,
#endif
@@ -76,6 +79,10 @@ public:
static bool killed_by_M112;
static bool quickstop_by_M410;
#if ENABLED(SDSUPPORT)
static bool sd_abort_by_M524;
#endif
#if ENABLED(HOST_PROMPT_SUPPORT)
static uint8_t M876_reason;
#endif
@@ -145,6 +152,9 @@ public:
case ' ': break;
case '1': state = EP_M1; break;
case '4': state = EP_M4; break;
#if ENABLED(SDSUPPORT)
case '5': state = EP_M5; break;
#endif
#if ENABLED(HOST_PROMPT_SUPPORT)
case '8': state = EP_M8; break;
#endif
@@ -165,6 +175,11 @@ public:
case EP_M4: state = (c == '1') ? EP_M41 : EP_IGNORE; break;
case EP_M41: state = (c == '0') ? EP_M410 : EP_IGNORE; break;
#if ENABLED(SDSUPPORT)
case EP_M5: state = (c == '2') ? EP_M52 : EP_IGNORE; break;
case EP_M52: state = (c == '4') ? EP_M524 : EP_IGNORE; break;
#endif
#if ENABLED(HOST_PROMPT_SUPPORT)
case EP_M8: state = (c == '7') ? EP_M87 : EP_IGNORE; break;
@@ -200,6 +215,9 @@ public:
case EP_M108: wait_for_user = wait_for_heatup = false; break;
case EP_M112: killed_by_M112 = true; break;
case EP_M410: quickstop_by_M410 = true; break;
#if ENABLED(SDSUPPORT)
case EP_M524: sd_abort_by_M524 = true; break;
#endif
#if ENABLED(HOST_PROMPT_SUPPORT)
case EP_M876SN: hostui.handle_response(M876_reason); break;
#endif

View File

@@ -111,20 +111,29 @@ void HostUI::action(FSTR_P const fstr, const bool eol) {
if (eol) SERIAL_EOL();
}
void HostUI::prompt_plus(FSTR_P const ptype, FSTR_P const fstr, const char extra_char/*='\0'*/) {
void HostUI::prompt_plus(const bool pgm, FSTR_P const ptype, const char * const str, const char extra_char/*='\0'*/) {
prompt(ptype, false);
PORT_REDIRECT(SerialMask::All);
SERIAL_CHAR(' ');
SERIAL_ECHOF(fstr);
if (pgm)
SERIAL_ECHOPGM_P(str);
else
SERIAL_ECHO(str);
if (extra_char != '\0') SERIAL_CHAR(extra_char);
SERIAL_EOL();
}
void HostUI::prompt_begin(const PromptReason reason, FSTR_P const fstr, const char extra_char/*='\0'*/) {
prompt_end();
host_prompt_reason = reason;
prompt_plus(F("begin"), fstr, extra_char);
}
void HostUI::prompt_button(FSTR_P const fstr) { prompt_plus(F("button"), fstr); }
void HostUI::prompt_begin(const PromptReason reason, const char * const cstr, const char extra_char/*='\0'*/) {
prompt_end();
host_prompt_reason = reason;
prompt_plus(F("begin"), cstr, extra_char);
}
void HostUI::prompt_end() { prompt(F("end")); }
void HostUI::prompt_show() { prompt(F("show")); }
@@ -133,14 +142,26 @@ void HostUI::action(FSTR_P const fstr, const bool eol) {
if (btn2) prompt_button(btn2);
prompt_show();
}
void HostUI::prompt_button(FSTR_P const fstr) { prompt_plus(F("button"), fstr); }
void HostUI::prompt_button(const char * const cstr) { prompt_plus(F("button"), cstr); }
void HostUI::prompt_do(const PromptReason reason, FSTR_P const fstr, FSTR_P const btn1/*=nullptr*/, FSTR_P const btn2/*=nullptr*/) {
prompt_begin(reason, fstr);
_prompt_show(btn1, btn2);
}
void HostUI::prompt_do(const PromptReason reason, const char * const cstr, FSTR_P const btn1/*=nullptr*/, FSTR_P const btn2/*=nullptr*/) {
prompt_begin(reason, cstr);
_prompt_show(btn1, btn2);
}
void HostUI::prompt_do(const PromptReason reason, FSTR_P const fstr, const char extra_char, FSTR_P const btn1/*=nullptr*/, FSTR_P const btn2/*=nullptr*/) {
prompt_begin(reason, fstr, extra_char);
_prompt_show(btn1, btn2);
}
void HostUI::prompt_do(const PromptReason reason, const char * const cstr, const char extra_char, FSTR_P const btn1/*=nullptr*/, FSTR_P const btn2/*=nullptr*/) {
prompt_begin(reason, cstr, extra_char);
_prompt_show(btn1, btn2);
}
#if ENABLED(ADVANCED_PAUSE_FEATURE)
void HostUI::filament_load_prompt() {

View File

@@ -79,7 +79,14 @@ class HostUI {
#if ENABLED(HOST_PROMPT_SUPPORT)
private:
static void prompt(FSTR_P const ptype, const bool eol=true);
static void prompt_plus(FSTR_P const ptype, FSTR_P const fstr, const char extra_char='\0');
static void prompt_plus(const bool pgm, FSTR_P const ptype, const char * const str, const char extra_char='\0');
static void prompt_plus(FSTR_P const ptype, FSTR_P const fstr, const char extra_char='\0') {
prompt_plus(true, ptype, FTOP(fstr), extra_char);
}
static void prompt_plus(FSTR_P const ptype, const char * const cstr, const char extra_char='\0') {
prompt_plus(false, ptype, cstr, extra_char);
}
static void prompt_show();
static void _prompt_show(FSTR_P const btn1, FSTR_P const btn2);
@@ -93,10 +100,17 @@ class HostUI {
static void notify(const char * const message);
static void prompt_begin(const PromptReason reason, FSTR_P const fstr, const char extra_char='\0');
static void prompt_button(FSTR_P const fstr);
static void prompt_begin(const PromptReason reason, const char * const cstr, const char extra_char='\0');
static void prompt_end();
static void prompt_button(FSTR_P const fstr);
static void prompt_button(const char * const cstr);
static void prompt_do(const PromptReason reason, FSTR_P const pstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr);
static void prompt_do(const PromptReason reason, const char * const cstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr);
static void prompt_do(const PromptReason reason, FSTR_P const pstr, const char extra_char, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr);
static void prompt_do(const PromptReason reason, const char * const cstr, const char extra_char, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr);
static void prompt_open(const PromptReason reason, FSTR_P const pstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr) {
if (host_prompt_reason == PROMPT_NOT_DEFINED) prompt_do(reason, pstr, btn1, btn2);
}

View File

@@ -30,18 +30,6 @@
#include "leds.h"
#if ENABLED(BLINKM)
#include "blinkm.h"
#endif
#if ENABLED(PCA9632)
#include "pca9632.h"
#endif
#if ENABLED(PCA9533)
#include "pca9533.h"
#endif
#if EITHER(CASE_LIGHT_USE_RGB_LED, CASE_LIGHT_USE_NEOPIXEL)
#include "../../feature/caselight.h"
#endif
@@ -69,6 +57,44 @@ void LEDLights::setup() {
#if ENABLED(RGBW_LED)
if (PWM_PIN(RGB_LED_W_PIN)) SET_PWM(RGB_LED_W_PIN); else SET_OUTPUT(RGB_LED_W_PIN);
#endif
#if ENABLED(RGB_STARTUP_TEST)
int8_t led_pin_count = 0;
if (PWM_PIN(RGB_LED_R_PIN) && PWM_PIN(RGB_LED_G_PIN) && PWM_PIN(RGB_LED_B_PIN)) led_pin_count = 3;
#if ENABLED(RGBW_LED)
if (PWM_PIN(RGB_LED_W_PIN) && led_pin_count) led_pin_count++;
#endif
// Startup animation
if (led_pin_count) {
// blackout
if (PWM_PIN(RGB_LED_R_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_R_PIN), 0); else WRITE(RGB_LED_R_PIN, LOW);
if (PWM_PIN(RGB_LED_G_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_G_PIN), 0); else WRITE(RGB_LED_G_PIN, LOW);
if (PWM_PIN(RGB_LED_B_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_B_PIN), 0); else WRITE(RGB_LED_B_PIN, LOW);
#if ENABLED(RGBW_LED)
if (PWM_PIN(RGB_LED_W_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_W_PIN), 0);
else WRITE(RGB_LED_W_PIN, LOW);
#endif
delay(200);
LOOP_L_N(i, led_pin_count) {
LOOP_LE_N(b, 200) {
const uint16_t led_pwm = b <= 100 ? b : 200 - b;
if (i == 0 && PWM_PIN(RGB_LED_R_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_R_PIN), led_pwm); else WRITE(RGB_LED_R_PIN, b < 100 ? HIGH : LOW);
if (i == 1 && PWM_PIN(RGB_LED_G_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_G_PIN), led_pwm); else WRITE(RGB_LED_G_PIN, b < 100 ? HIGH : LOW);
if (i == 2 && PWM_PIN(RGB_LED_B_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_B_PIN), led_pwm); else WRITE(RGB_LED_B_PIN, b < 100 ? HIGH : LOW);
#if ENABLED(RGBW_LED)
if (i == 3){
if (PWM_PIN(RGB_LED_W_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_W_PIN), led_pwm);
else WRITE(RGB_LED_W_PIN, b < 100 ? HIGH : LOW);
delay(RGB_STARTUP_TEST_INNER_MS);//More slowing for ending
}
#endif
delay(RGB_STARTUP_TEST_INNER_MS);
}
}
delay(500);
}
#endif // RGB_STARTUP_TEST
#endif
TERN_(NEOPIXEL_LED, neo.init());
TERN_(PCA9533, PCA9533_init());

View File

@@ -40,6 +40,18 @@
#undef _NEOPIXEL_INCLUDE_
#endif
#if ENABLED(BLINKM)
#include "blinkm.h"
#endif
#if ENABLED(PCA9533)
#include "pca9533.h"
#endif
#if ENABLED(PCA9632)
#include "pca9632.h"
#endif
/**
* LEDcolor type for use with leds.set_color
*/
@@ -107,6 +119,13 @@ typedef struct LEDColor {
class LEDLights {
public:
#if ANY(LED_CONTROL_MENU, PRINTER_EVENT_LEDS, CASE_LIGHT_IS_COLOR_LED)
static LEDColor color; // last non-off color
static bool lights_on; // the last set color was "on"
#else
static constexpr bool lights_on = true;
#endif
LEDLights() {} // ctor
static void setup(); // init()
@@ -142,15 +161,10 @@ public:
static LEDColor get_color() { return lights_on ? color : LEDColorOff(); }
#endif
#if ANY(LED_CONTROL_MENU, PRINTER_EVENT_LEDS, CASE_LIGHT_IS_COLOR_LED)
static LEDColor color; // last non-off color
static bool lights_on; // the last set color was "on"
#endif
#if ENABLED(LED_CONTROL_MENU)
static void toggle(); // swap "off" with color
#endif
#if EITHER(LED_CONTROL_MENU, CASE_LIGHT_USE_RGB_LED)
#if EITHER(LED_CONTROL_MENU, CASE_LIGHT_USE_RGB_LED) || LED_POWEROFF_TIMEOUT > 0
static void update() { set_color(color); }
#endif

View File

@@ -54,7 +54,8 @@ MMU2 mmu2;
#define MMU_CMD_TIMEOUT 45000UL // 45s timeout for mmu commands (except P0)
#define MMU_P0_TIMEOUT 3000UL // Timeout for P0 command: 3seconds
#define MMU2_COMMAND(S) tx_str(F(S "\n"))
#define MMU2_SEND(S) tx_str(F(S "\n"))
#define MMU2_RECV(S) rx_str(F(S "\n"))
#if ENABLED(MMU_EXTRUDER_SENSOR)
uint8_t mmu_idl_sens = 0;
@@ -131,7 +132,7 @@ void MMU2::reset() {
safe_delay(20);
WRITE(MMU2_RST_PIN, HIGH);
#else
MMU2_COMMAND("X0"); // Send soft reset
MMU2_SEND("X0"); // Send soft reset
#endif
}
@@ -157,11 +158,9 @@ void MMU2::mmu_loop() {
case -1:
if (rx_start()) {
prev_P0_request = millis(); // Initialize finda sensor timeout
DEBUG_ECHOLNPGM("MMU => 'start'");
DEBUG_ECHOLNPGM("MMU <= 'S1'");
MMU2_COMMAND("S1"); // Read Version
MMU2_SEND("S1"); // Read Version
state = -2;
}
else if (millis() > 30000) { // 30sec after reset disable MMU
@@ -173,10 +172,8 @@ void MMU2::mmu_loop() {
case -2:
if (rx_ok()) {
sscanf(rx_buffer, "%huok\n", &version);
DEBUG_ECHOLNPGM("MMU => ", version, "\nMMU <= 'S2'");
MMU2_COMMAND("S2"); // Read Build Number
MMU2_SEND("S2"); // Read Build Number
state = -3;
}
break;
@@ -191,14 +188,12 @@ void MMU2::mmu_loop() {
#if ENABLED(MMU2_MODE_12V)
DEBUG_ECHOLNPGM("MMU <= 'M1'");
MMU2_COMMAND("M1"); // Stealth Mode
MMU2_SEND("M1"); // Stealth Mode
state = -5;
#else
DEBUG_ECHOLNPGM("MMU <= 'P0'");
MMU2_COMMAND("P0"); // Read FINDA
MMU2_SEND("P0"); // Read FINDA
state = -4;
#endif
}
@@ -209,10 +204,8 @@ void MMU2::mmu_loop() {
// response to M1
if (rx_ok()) {
DEBUG_ECHOLNPGM("MMU => ok");
DEBUG_ECHOLNPGM("MMU <= 'P0'");
MMU2_COMMAND("P0"); // Read FINDA
MMU2_SEND("P0"); // Read FINDA
state = -4;
}
break;
@@ -250,14 +243,13 @@ void MMU2::mmu_loop() {
else if (cmd == MMU_CMD_C0) {
// continue loading
DEBUG_ECHOLNPGM("MMU <= 'C0'");
MMU2_COMMAND("C0");
MMU2_SEND("C0");
state = 3; // wait for response
}
else if (cmd == MMU_CMD_U0) {
// unload current
DEBUG_ECHOLNPGM("MMU <= 'U0'");
MMU2_COMMAND("U0");
MMU2_SEND("U0");
state = 3; // wait for response
}
else if (WITHIN(cmd, MMU_CMD_E0, MMU_CMD_E0 + EXTRUDERS - 1)) {
@@ -270,7 +262,7 @@ void MMU2::mmu_loop() {
else if (cmd == MMU_CMD_R0) {
// recover after eject
DEBUG_ECHOLNPGM("MMU <= 'R0'");
MMU2_COMMAND("R0");
MMU2_SEND("R0");
state = 3; // wait for response
}
else if (WITHIN(cmd, MMU_CMD_F0, MMU_CMD_F0 + EXTRUDERS - 1)) {
@@ -285,7 +277,7 @@ void MMU2::mmu_loop() {
cmd = MMU_CMD_NONE;
}
else if (ELAPSED(millis(), prev_P0_request + 300)) {
MMU2_COMMAND("P0"); // Read FINDA
MMU2_SEND("P0"); // Read FINDA
state = 2; // wait for response
}
@@ -314,7 +306,7 @@ void MMU2::mmu_loop() {
if (mmu_idl_sens) {
if (FILAMENT_PRESENT() && mmu_loading_flag) {
DEBUG_ECHOLNPGM("MMU <= 'A'");
MMU2_COMMAND("A"); // send 'abort' request
MMU2_SEND("A"); // send 'abort' request
mmu_idl_sens = 0;
DEBUG_ECHOLNPGM("MMU IDLER_SENSOR = 0 - ABORT");
}
@@ -327,9 +319,9 @@ void MMU2::mmu_loop() {
const bool keep_trying = !mmu2s_triggered && last_cmd == MMU_CMD_C0;
if (keep_trying) {
// MMU ok received but filament sensor not triggered, retrying...
DEBUG_ECHOLNPGM("MMU => 'ok' (filament not present in gears)");
DEBUG_ECHOLNPGM("MMU => 'ok' (no filament in gears)");
DEBUG_ECHOLNPGM("MMU <= 'C0' (keep trying)");
MMU2_COMMAND("C0");
MMU2_SEND("C0");
}
#else
constexpr bool keep_trying = false;
@@ -361,7 +353,7 @@ void MMU2::mmu_loop() {
*/
bool MMU2::rx_start() {
// check for start message
return rx_str(F("start\n"));
return MMU2_RECV("start");
}
/**
@@ -440,7 +432,7 @@ void MMU2::clear_rx_buffer() {
* Check if we received 'ok' from MMU
*/
bool MMU2::rx_ok() {
if (rx_str(F("ok\n"))) {
if (MMU2_RECV("ok")) {
prev_P0_request = millis();
return true;
}
@@ -585,7 +577,7 @@ static void mmu2_not_responding() {
command(MMU_CMD_T0 + index);
manage_response(true, true);
mmu_continue_loading();
command(MMU_CMD_C0);
//command(MMU_CMD_C0);
extruder = index;
active_extruder = 0;
@@ -653,13 +645,34 @@ static void mmu2_not_responding() {
}
void MMU2::mmu_continue_loading() {
// Try to load the filament a limited number of times
bool fil_present = 0;
for (uint8_t i = 0; i < MMU_LOADING_ATTEMPTS_NR; i++) {
DEBUG_ECHOLNPGM("Additional load attempt #", i);
if (FILAMENT_PRESENT()) break;
DEBUG_ECHOLNPGM("Load attempt #", i + 1);
// Done as soon as filament is present
fil_present = FILAMENT_PRESENT();
if (fil_present) break;
// Attempt to load the filament, 1mm at a time, for 3s
command(MMU_CMD_C0);
stepper.enable_extruder();
const millis_t expire_ms = millis() + 3000;
do {
current_position.e += 1;
line_to_current_position(MMU_LOAD_FEEDRATE);
planner.synchronize();
// When (T0 rx->ok) load is ready, but in fact it did not load
// successfully or an overload created pressure in the extruder.
// Send (C0) to load more and move E_AXIS a little to release pressure.
if ((fil_present = FILAMENT_PRESENT())) MMU2_SEND("A");
} while (!fil_present && PENDING(millis(), expire_ms));
stepper.disable_extruder();
manage_response(true, true);
}
if (!FILAMENT_PRESENT()) {
// Was the filament still missing in the last check?
if (!fil_present) {
DEBUG_ECHOLNPGM("Filament never reached sensor, runout");
filament_runout();
}
@@ -682,7 +695,7 @@ static void mmu2_not_responding() {
command(MMU_CMD_T0 + index);
manage_response(true, true);
command(MMU_CMD_C0);
extruder = index; //filament change is finished
extruder = index; // Filament change is finished
active_extruder = 0;
stepper.enable_extruder();
SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, extruder);
@@ -861,7 +874,7 @@ void MMU2::filament_runout() {
if (cmd == MMU_CMD_NONE && last_cmd == MMU_CMD_C0) {
if (present && !mmu2s_triggered) {
DEBUG_ECHOLNPGM("MMU <= 'A'");
tx_str(F("A\n"));
MMU2_SEND("A");
}
// Slowly spin the extruder during C0
else {

View File

@@ -86,6 +86,7 @@ private:
#endif
#if ENABLED(MMU_EXTRUDER_SENSOR)
#define MMU_LOAD_FEEDRATE 19.02f // (mm/s)
static void mmu_continue_loading();
#endif

View File

@@ -474,9 +474,7 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool
if (unload_length)
unload_filament(unload_length, show_lcd, PAUSE_MODE_CHANGE_FILAMENT);
#if ENABLED(DUAL_X_CARRIAGE)
set_duplication_enabled(saved_ext_dup_mode, saved_ext);
#endif
TERN_(DUAL_X_CARRIAGE, set_duplication_enabled(saved_ext_dup_mode, saved_ext));
// Disable the Extruder for manual change
disable_active_extruder();
@@ -593,9 +591,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
}
idle_no_sleep();
}
#if ENABLED(DUAL_X_CARRIAGE)
set_duplication_enabled(saved_ext_dup_mode, saved_ext);
#endif
TERN_(DUAL_X_CARRIAGE, set_duplication_enabled(saved_ext_dup_mode, saved_ext));
}
/**

View File

@@ -53,7 +53,7 @@ PowerMonitor power_monitor; // Single instance - this calls the constructor
void PowerMonitor::draw_current() {
const float amps = getAmps();
lcd_put_u8str(amps < 100 ? ftostr31ns(amps) : ui16tostr4rj((uint16_t)amps));
lcd_put_lchar('A');
lcd_put_u8str(F("A"));
}
#endif
@@ -61,7 +61,7 @@ PowerMonitor power_monitor; // Single instance - this calls the constructor
void PowerMonitor::draw_voltage() {
const float volts = getVolts();
lcd_put_u8str(volts < 100 ? ftostr31ns(volts) : ui16tostr4rj((uint16_t)volts));
lcd_put_lchar('V');
lcd_put_u8str(F("V"));
}
#endif
@@ -69,7 +69,7 @@ PowerMonitor power_monitor; // Single instance - this calls the constructor
void PowerMonitor::draw_power() {
const float power = getPower();
lcd_put_u8str(power < 100 ? ftostr31ns(power) : ui16tostr4rj((uint16_t)power));
lcd_put_lchar('W');
lcd_put_u8str(F("W"));
}
#endif

View File

@@ -153,6 +153,9 @@ class PrintJobRecovery {
static void prepare();
static void setup() {
#if PIN_EXISTS(OUTAGECON)
OUT_WRITE(OUTAGECON_PIN, HIGH);
#endif
#if PIN_EXISTS(POWER_LOSS)
#if ENABLED(POWER_LOSS_PULLUP)
SET_INPUT_PULLUP(POWER_LOSS_PIN);

View File

@@ -42,7 +42,7 @@ void Repeat::add_marker(const uint32_t sdpos, const uint16_t count) {
SERIAL_ECHO_MSG("!Too many markers.");
else {
marker[index].sdpos = sdpos;
marker[index].counter = count ?: -1;
marker[index].counter = count ? count - 1 : -1;
index++;
DEBUG_ECHOLNPGM("Add Marker ", index, " at ", sdpos, " (", count, ")");
}

View File

@@ -30,9 +30,7 @@
#include "spindle_laser_types.h"
#if HAS_BEEPER
#include "../libs/buzzer.h"
#endif
#include "../libs/buzzer.h"
// Inline laser power
#include "../module/planner.h"
@@ -285,7 +283,7 @@ public:
if (!menuPower) menuPower = cpwr_to_upwr(SPEED_POWER_STARTUP);
power = upower_to_ocr(menuPower);
apply_power(power);
} else
} else
apply_power(0);
}