PFW-1504 initial commit

Change in memory:
Flash: +162 bytes
SRAM: 0 bytes
This commit is contained in:
Guðni Már Gilbert 2023-03-05 11:17:21 +00:00 committed by DRracer
parent 04d440a9c8
commit bbfc4b9f78
8 changed files with 48 additions and 4 deletions

View File

@ -239,15 +239,30 @@ bool MMU2::VerifyFilamentEnteredPTFE() {
return false;
uint8_t fsensorState = 0;
uint8_t fsensorStateLCD = 0;
uint8_t fsensor_pixel = 0;
// MMU has finished its load, push the filament further by some defined constant length
// If the filament sensor reads 0 at any moment, then report FAILURE
MoveE(MMU2_EXTRUDER_PTFE_LENGTH + MMU2_EXTRUDER_HEATBREAK_LENGTH + MMU2_VERIFY_LOAD_TO_NOZZLE_TWEAK - (logic.ExtraLoadDistance() - MMU2_FILAMENT_SENSOR_POSITION), MMU2_VERIFY_LOAD_TO_NOZZLE_FEED_RATE);
MoveE(-(MMU2_EXTRUDER_PTFE_LENGTH + MMU2_EXTRUDER_HEATBREAK_LENGTH + MMU2_VERIFY_LOAD_TO_NOZZLE_TWEAK - (logic.ExtraLoadDistance() - MMU2_FILAMENT_SENSOR_POSITION)), MMU2_VERIFY_LOAD_TO_NOZZLE_FEED_RATE);
const float delta_mm = MMU2_CHECK_FILAMENT_PRESENCE_EXTRUSION_LENGTH - logic.ExtraLoadDistance();
const float length_step_mm = 2 * (delta_mm) / (LCD_WIDTH + 1);
// reset current position to whatever the planner thinks it is
float last_position = planner_get_machine_position_E_mm();
MoveE(delta_mm, MMU2_VERIFY_LOAD_TO_NOZZLE_FEED_RATE);
MoveE(-delta_mm, MMU2_VERIFY_LOAD_TO_NOZZLE_FEED_RATE);
while (planner_any_moves()) {
// Wait for move to finish and monitor the fsensor the entire time
// A single 0 reading will set the bit.
fsensorState |= (WhereIsFilament() == FilamentState::NOT_PRESENT);
fsensorStateLCD |= (WhereIsFilament() == FilamentState::NOT_PRESENT);
fsensorState |= fsensorStateLCD; // No need to do the above comparison twice, just bitwise OR
if ((fabs(planner_get_machine_position_E_mm() - last_position)) > length_step_mm) {
if (fsensor_pixel > 19) fsensor_pixel = 19;
TryLoadUnloadProgressbar(fsensor_pixel++, 3, fsensorStateLCD);
fsensorStateLCD = 0; // Clear temporary bit
last_position = planner_get_machine_position_E_mm(); // Reset
}
safe_delay_keep_alive(0);
}

View File

@ -40,6 +40,11 @@ static constexpr float MMU2_VERIFY_LOAD_TO_NOZZLE_TWEAK = -5.F; // mm used to sh
static constexpr float MMU2_RETRY_UNLOAD_TO_FINDA_LENGTH = 80.0f; // mm
static constexpr float MMU2_RETRY_UNLOAD_TO_FINDA_FEED_RATE = 80.0f; // mm/s
// After loading a new filament, the printer will extrude the filament by this distance
// and then retract it back to the original position. This is used to check if the
// filament sensor reading flickers or filament is jammed.
static constexpr float MMU2_CHECK_FILAMENT_PRESENCE_EXTRUSION_LENGTH = MMU2_EXTRUDER_PTFE_LENGTH + MMU2_EXTRUDER_HEATBREAK_LENGTH + MMU2_VERIFY_LOAD_TO_NOZZLE_TWEAK - MMU2_FILAMENT_SENSOR_POSITION;
static constexpr uint8_t MMU2_NO_TOOL = 99;
static constexpr uint32_t MMU_BAUD = 115200;

View File

@ -40,6 +40,11 @@ static constexpr float MMU2_VERIFY_LOAD_TO_NOZZLE_TWEAK = -5.F; // mm used to sh
static constexpr float MMU2_RETRY_UNLOAD_TO_FINDA_LENGTH = 80.0f; // mm
static constexpr float MMU2_RETRY_UNLOAD_TO_FINDA_FEED_RATE = 80.0f; // mm/s
// After loading a new filament, the printer will extrude the filament by this distance
// and then retract it back to the original position. This is used to check if the
// filament sensor reading flickers or filament is jammed.
static constexpr float MMU2_CHECK_FILAMENT_PRESENCE_EXTRUSION_LENGTH = MMU2_EXTRUDER_PTFE_LENGTH + MMU2_EXTRUDER_HEATBREAK_LENGTH + MMU2_VERIFY_LOAD_TO_NOZZLE_TWEAK - MMU2_FILAMENT_SENSOR_POSITION;
static constexpr uint8_t MMU2_NO_TOOL = 99;
static constexpr uint32_t MMU_BAUD = 115200;

View File

@ -27,7 +27,7 @@ bool planner_any_moves() {
}
float planner_get_machine_position_E_mm(){
return current_position[E_AXIS];
return st_get_position_mm(E_AXIS);
}
float planner_get_current_position_E(){

View File

@ -289,6 +289,11 @@ void ReportProgressHook(CommandInProgress cip, uint16_t ec) {
}
}
void TryLoadUnloadProgressbar(uint8_t column, uint8_t row, bool sensorState) {
lcd_putc_at(column, row, sensorState ? '_' : LCD_STR_SOLID_BLOCK[0]); // Place character
lcd_reset_status_message_timeout();
}
void IncrementLoadFails(){
eeprom_increment_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL);
eeprom_increment_word((uint16_t *)EEPROM_MMU_LOAD_FAIL_TOT);

View File

@ -32,6 +32,8 @@ void ReportErrorHook(CommandInProgress cip, uint16_t ec, uint8_t es);
/// Called when the MMU sends operation progress update
void ReportProgressHook(CommandInProgress cip, uint16_t ec);
void TryLoadUnloadProgressbar(uint8_t column, uint8_t row, bool sensorState);
/// Remders the sensor status line. Also used by the "resume temperature" screen.
void ReportErrorHookDynamicRender();

View File

@ -562,6 +562,11 @@ void lcdui_print_status_line(void) {
scrollstuff = 0;
}
} else { // Otherwise check for other special events
if (!lcd_status_message_timeout.expired_cont(LCD_STATUS_DELAYED_TIMEOUT))
{
return; // Nothing to do, waiting for delay to expire
}
switch (custom_message_type) {
case CustomMsg::M117: // M117 Set the status line message on the LCD
case CustomMsg::Status: // Nothing special, print status message normally
@ -7398,6 +7403,11 @@ void lcd_setstatus_serial(const char* message)
SERIAL_ECHOLN(message);
}
void lcd_reset_status_message_timeout()
{
lcd_status_message_timeout.start();
}
void lcd_setalertstatus_(const char* message, uint8_t severity, bool progmem)
{
if (lcd_message_check(severity)) {

View File

@ -17,11 +17,13 @@ void ultralcd_init();
#define LCD_STATUS_NONE 0 //< No alert message set
#define LCD_STATUS_INFO_TIMEOUT 20000
#define LCD_STATUS_DELAYED_TIMEOUT 4000
// Set the current status message (equivalent to LCD_STATUS_NONE)
void lcd_setstatus(const char* message);
void lcd_setstatuspgm(const char* message);
void lcd_setstatus_serial(const char* message);
void lcd_reset_status_message_timeout();
//! return to the main status screen and display the alert message
//! Beware - it has sideeffects: