From c518bfdb73a318a4508353bb463fe380769d259b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sun, 12 Mar 2023 10:53:25 +0000 Subject: [PATCH] PFW-1504 Set cursor position each time to be safe Change in memory: Flash: +18 bytes SRAM: 0 bytes --- Firmware/mmu2.cpp | 4 +++- Firmware/mmu2_reporting.cpp | 6 ++++-- Firmware/mmu2_reporting.h | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Firmware/mmu2.cpp b/Firmware/mmu2.cpp index 1d4e69eb4..ad6a28ba1 100644 --- a/Firmware/mmu2.cpp +++ b/Firmware/mmu2.cpp @@ -240,6 +240,7 @@ bool MMU2::VerifyFilamentEnteredPTFE() { uint8_t fsensorState = 0; uint8_t fsensorStateLCD = 0; + uint8_t 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 @@ -275,7 +276,8 @@ bool MMU2::VerifyFilamentEnteredPTFE() { if ((fabs(stepper_get_machine_position_E_mm() - last_position)) > length_step_mm) { 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 } safe_delay_keep_alive(0); diff --git a/Firmware/mmu2_reporting.cpp b/Firmware/mmu2_reporting.cpp index 647211134..54d7e4fba 100644 --- a/Firmware/mmu2_reporting.cpp +++ b/Firmware/mmu2_reporting.cpp @@ -298,8 +298,10 @@ void TryLoadUnloadProgressbarInit() { lcd_set_cursor(0, 3); } -void TryLoadUnloadProgressbar(bool sensorState) { - lcd_putc(sensorState ? '_' : LCD_STR_SOLID_BLOCK[0]); // Place character +void TryLoadUnloadProgressbar(uint8_t col, bool sensorState) { + // 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(); } diff --git a/Firmware/mmu2_reporting.h b/Firmware/mmu2_reporting.h index 3d5dcff58..8bfa2c978 100644 --- a/Firmware/mmu2_reporting.h +++ b/Firmware/mmu2_reporting.h @@ -36,8 +36,9 @@ void ReportProgressHook(CommandInProgress cip, uint16_t ec); void TryLoadUnloadProgressbarInit(); /// @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 -void TryLoadUnloadProgressbar(bool sensorState); +void TryLoadUnloadProgressbar(uint8_t col, bool sensorState); /// Remders the sensor status line. Also used by the "resume temperature" screen. void ReportErrorHookDynamicRender();