PFW-1504 Set cursor position each time to be safe

Change in memory:
Flash: +18 bytes
SRAM: 0 bytes
This commit is contained in:
Guðni Már Gilbert 2023-03-12 10:53:25 +00:00 committed by DRracer
parent 59e1ac0396
commit c518bfdb73
3 changed files with 9 additions and 4 deletions

View File

@ -240,6 +240,7 @@ bool MMU2::VerifyFilamentEnteredPTFE() {
uint8_t fsensorState = 0; uint8_t fsensorState = 0;
uint8_t fsensorStateLCD = 0; uint8_t fsensorStateLCD = 0;
uint8_t pixel = 0;
// MMU has finished its load, push the filament further by some defined constant length // 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 // If the filament sensor reads 0 at any moment, then report FAILURE
@ -275,7 +276,8 @@ bool MMU2::VerifyFilamentEnteredPTFE() {
if ((fabs(stepper_get_machine_position_E_mm() - last_position)) > length_step_mm) { if ((fabs(stepper_get_machine_position_E_mm() - last_position)) > length_step_mm) {
last_position = stepper_get_machine_position_E_mm(); // Reset last_position = stepper_get_machine_position_E_mm(); // Reset
TryLoadUnloadProgressbar(fsensorStateLCD); if (pixel > (LCD_WIDTH - 1)) pixel = LCD_WIDTH - 1;
TryLoadUnloadProgressbar(pixel++, fsensorStateLCD);
fsensorStateLCD = 0; // Clear temporary bit fsensorStateLCD = 0; // Clear temporary bit
} }
safe_delay_keep_alive(0); safe_delay_keep_alive(0);

View File

@ -298,8 +298,10 @@ void TryLoadUnloadProgressbarInit() {
lcd_set_cursor(0, 3); lcd_set_cursor(0, 3);
} }
void TryLoadUnloadProgressbar(bool sensorState) { void TryLoadUnloadProgressbar(uint8_t col, bool sensorState) {
lcd_putc(sensorState ? '_' : LCD_STR_SOLID_BLOCK[0]); // Place character // Set the cursor position each time in case some other
// part of the firmware changes the cursor position
lcd_putc_at(col, 3, sensorState ? '_' : LCD_STR_SOLID_BLOCK[0]);
lcd_reset_status_message_timeout(); lcd_reset_status_message_timeout();
} }

View File

@ -36,8 +36,9 @@ void ReportProgressHook(CommandInProgress cip, uint16_t ec);
void TryLoadUnloadProgressbarInit(); void TryLoadUnloadProgressbarInit();
/// @brief Add one block to the progress bar /// @brief Add one block to the progress bar
/// @param col pixel position on the LCD status line, should range from 0 to (LCD_WIDTH - 1)
/// @param sensorState if true, filament is not present, else filament is present. This controls which character to render /// @param sensorState if true, filament is not present, else filament is present. This controls which character to render
void TryLoadUnloadProgressbar(bool sensorState); void TryLoadUnloadProgressbar(uint8_t col, bool sensorState);
/// Remders the sensor status line. Also used by the "resume temperature" screen. /// Remders the sensor status line. Also used by the "resume temperature" screen.
void ReportErrorHookDynamicRender(); void ReportErrorHookDynamicRender();