Merge pull request #3191 from wavexx/fix_longpress_isr

Handle Long-Press in the main loop
This commit is contained in:
DRracer 2021-06-22 07:09:01 +02:00 committed by GitHub
commit f36b9173da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 3 deletions

View File

@ -9928,6 +9928,18 @@ if(0)
#endif #endif
check_axes_activity(); check_axes_activity();
mmu_loop(); mmu_loop();
// handle longpress
if(lcd_longpress_trigger)
{
// long press is not possible in modal mode, wait until ready
if (lcd_longpress_func && lcd_update_enabled)
{
lcd_longpress_func();
lcd_longpress_trigger = 0;
}
}
#if defined(AUTO_REPORT) #if defined(AUTO_REPORT)
host_autoreport(); host_autoreport();
#endif //AUTO_REPORT #endif //AUTO_REPORT

View File

@ -728,6 +728,10 @@ void lcd_update_enable(uint8_t enabled)
} }
} }
bool lcd_longpress_trigger = 0;
// WARNING: this function is called from the temperature ISR.
// Only update flags, but do not perform any menu/lcd operation!
void lcd_buttons_update(void) void lcd_buttons_update(void)
{ {
static uint8_t lcd_long_press_active = 0; static uint8_t lcd_long_press_active = 0;
@ -749,9 +753,7 @@ void lcd_buttons_update(void)
else if (longPressTimer.expired(LONG_PRESS_TIME)) else if (longPressTimer.expired(LONG_PRESS_TIME))
{ {
lcd_long_press_active = 1; lcd_long_press_active = 1;
//long press is not possible in modal mode lcd_longpress_trigger = 1;
if (lcd_longpress_func && lcd_update_enabled)
lcd_longpress_func();
} }
} }
} }

View File

@ -110,6 +110,7 @@ extern uint32_t lcd_next_update_millis;
extern uint8_t lcd_status_update_delay; extern uint8_t lcd_status_update_delay;
extern lcd_longpress_func_t lcd_longpress_func; extern lcd_longpress_func_t lcd_longpress_func;
extern bool lcd_longpress_trigger;
extern lcd_charsetup_func_t lcd_charsetup_func; extern lcd_charsetup_func_t lcd_charsetup_func;