From 5b75886a55ab558bb7b32c126e2c4726849df7c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Mon, 1 May 2023 12:48:21 +0000 Subject: [PATCH] Fix regression where feedrate can overflow on status screen If the remaining print time is more than 10.9 hours at 100% then increasing the feedrate multiplier to 101% or more will yield an unrealistic time due to overflow occuring. Change in memory: Flash +2 bytes SRAM: 0 bytes --- Firmware/ultralcd.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index a2bfd7bd6..4f3d6f7bd 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -446,9 +446,9 @@ void lcdui_print_time(void) //if remaining print time estimation is available print it else print elapsed time int chars = 0; if (printer_active()) { - uint16_t print_t = PRINT_TIME_REMAINING_INIT; - uint16_t print_tr = PRINT_TIME_REMAINING_INIT; - uint16_t print_tc = PRINT_TIME_REMAINING_INIT; + uint16_t print_t = PRINT_TIME_REMAINING_INIT; // unit: minutes + uint16_t print_tr = PRINT_TIME_REMAINING_INIT; // unit: minutes + uint16_t print_tc = PRINT_TIME_REMAINING_INIT; // unit: minutes char suff = ' '; char suff_doubt = ' '; @@ -491,7 +491,8 @@ void lcdui_print_time(void) if (feedmultiply != 100 && (print_t == print_tr || print_t == print_tc)) { suff_doubt = '?'; - print_t = (100 * print_t) / feedmultiply; + // (print_t * 100) overflows uint16_t at 10.9 hours, uint32_t is required + print_t = (uint16_t)((100UL * (uint32_t)print_t) / feedmultiply); } if (print_t < 6000) //time<100h