Save 82B flash and 1B RAM, fix compiler warning:

sketch/ultralcd.cpp:7212:61: warning: integer overflow in expression [-Woverflow]
  lcd_next_update_millis = millis() + (LCD_UPDATE_INTERVAL * 10000);
This commit is contained in:
Marek Bel 2018-07-13 17:21:22 +02:00
parent 070e6f49e8
commit 9d72062cd7
2 changed files with 12 additions and 10 deletions

View File

@ -344,7 +344,7 @@ bool lcd_oldcardstatus;
#endif //ULTIPANEL #endif //ULTIPANEL
menuFunc_t currentMenu = lcd_status_screen; /* function pointer to the currently active menu */ menuFunc_t currentMenu = lcd_status_screen; /* function pointer to the currently active menu */
uint32_t lcd_next_update_millis; ShortTimer lcd_next_update_millis;
uint8_t lcd_status_update_delay; uint8_t lcd_status_update_delay;
bool ignore_click = false; bool ignore_click = false;
bool wait_for_unclick; bool wait_for_unclick;
@ -6500,7 +6500,7 @@ bool lcd_selftest()
lcd_reset_alert_level(); lcd_reset_alert_level();
enquecommand_P(PSTR("M84")); enquecommand_P(PSTR("M84"));
lcd_implementation_clear(); lcd_implementation_clear();
lcd_next_update_millis = millis() + LCD_UPDATE_INTERVAL; lcd_next_update_millis.start();
if (_result) if (_result)
{ {
@ -7209,7 +7209,7 @@ static bool lcd_selftest_fan_dialog(int _fan)
static int lcd_selftest_screen(int _step, int _progress, int _progress_scale, bool _clear, int _delay) static int lcd_selftest_screen(int _step, int _progress, int _progress_scale, bool _clear, int _delay)
{ {
lcd_next_update_millis = millis() + (LCD_UPDATE_INTERVAL * 10000); lcd_next_update_millis.stop();
int _step_block = 0; int _step_block = 0;
const char *_indicator = (_progress > _progress_scale) ? "-" : "|"; const char *_indicator = (_progress > _progress_scale) ? "-" : "|";
@ -7410,6 +7410,7 @@ static void menu_action_setting_edit_callback_bool(const char* pstr, bool* ptr,
void lcd_init() void lcd_init()
{ {
lcd_implementation_init(); lcd_implementation_init();
lcd_next_update_millis.start();
#ifdef NEWPANEL #ifdef NEWPANEL
SET_INPUT(BTN_EN1); SET_INPUT(BTN_EN1);
@ -7479,8 +7480,6 @@ void lcd_update_enable(bool enabled)
// Enabling the normal LCD update procedure. // Enabling the normal LCD update procedure.
// Reset the timeout interval. // Reset the timeout interval.
lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS;
// Force the keypad update now.
lcd_next_update_millis = millis() - 1;
// Full update. // Full update.
lcd_implementation_clear(); lcd_implementation_clear();
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT) #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
@ -7491,14 +7490,15 @@ void lcd_update_enable(bool enabled)
else else
lcd_set_custom_characters_arrows(); lcd_set_custom_characters_arrows();
#endif #endif
lcd_update(2); // Force the keypad update now.
lcd_update(2,true);
} else { } else {
// Clear the LCD always, or let it to the caller? // Clear the LCD always, or let it to the caller?
} }
} }
} }
void lcd_update(uint8_t lcdDrawUpdateOverride) void lcd_update(uint8_t lcdDrawUpdateOverride, bool forceRedraw)
{ {
if (lcdDrawUpdate < lcdDrawUpdateOverride) if (lcdDrawUpdate < lcdDrawUpdateOverride)
@ -7513,6 +7513,7 @@ void lcd_update(uint8_t lcdDrawUpdateOverride)
lcd_buttons_update(); lcd_buttons_update();
#if (SDCARDDETECT > 0) #if (SDCARDDETECT > 0)
if ((IS_SD_INSERTED != lcd_oldcardstatus && lcd_detected())) if ((IS_SD_INSERTED != lcd_oldcardstatus && lcd_detected()))
{ {
@ -7538,8 +7539,9 @@ void lcd_update(uint8_t lcdDrawUpdateOverride)
} }
#endif//CARDINSERTED #endif//CARDINSERTED
if (lcd_next_update_millis < millis()) if (lcd_next_update_millis.expired(LCD_UPDATE_INTERVAL) || forceRedraw)
{ {
lcd_next_update_millis.start();
#ifdef DEBUG_BLINK_ACTIVE #ifdef DEBUG_BLINK_ACTIVE
static bool active_led = false; static bool active_led = false;
active_led = !active_led; active_led = !active_led;
@ -7547,6 +7549,7 @@ void lcd_update(uint8_t lcdDrawUpdateOverride)
digitalWrite(LED_PIN, active_led?HIGH:LOW); digitalWrite(LED_PIN, active_led?HIGH:LOW);
#endif //DEBUG_BLINK_ACTIVE #endif //DEBUG_BLINK_ACTIVE
#ifdef ULTIPANEL #ifdef ULTIPANEL
#ifdef REPRAPWORLD_KEYPAD #ifdef REPRAPWORLD_KEYPAD
if (REPRAPWORLD_KEYPAD_MOVE_Z_UP) { if (REPRAPWORLD_KEYPAD_MOVE_Z_UP) {
@ -7607,7 +7610,6 @@ void lcd_update(uint8_t lcdDrawUpdateOverride)
#endif//ULTIPANEL #endif//ULTIPANEL
if (lcdDrawUpdate == 2) lcd_implementation_clear(); if (lcdDrawUpdate == 2) lcd_implementation_clear();
if (lcdDrawUpdate) lcdDrawUpdate--; if (lcdDrawUpdate) lcdDrawUpdate--;
lcd_next_update_millis = millis() + LCD_UPDATE_INTERVAL;
} }
if (!SdFatUtil::test_stack_integrity()) stack_error(); if (!SdFatUtil::test_stack_integrity()) stack_error();
#ifdef DEBUG_STEPPER_TIMER_MISSED #ifdef DEBUG_STEPPER_TIMER_MISSED

View File

@ -11,7 +11,7 @@ extern int lcd_printf_P(const char* format, ...);
static void lcd_language_menu(); static void lcd_language_menu();
void lcd_update(uint8_t lcdDrawUpdateOverride = 0); void lcd_update(uint8_t lcdDrawUpdateOverride = 0, bool forceRedraw = false);
// Call with a false parameter to suppress the LCD update from various places like the planner or the temp control. // Call with a false parameter to suppress the LCD update from various places like the planner or the temp control.
void lcd_update_enable(bool enable); void lcd_update_enable(bool enable);
void lcd_init(); void lcd_init();