🚸 More frequent button polling (#27797)

This commit is contained in:
Scott Lahteine 2025-04-15 15:49:23 -05:00 committed by GitHub
parent 1d4c002c2a
commit 1242e875aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 3 deletions

View file

@ -2268,6 +2268,8 @@
#define ADC_BUTTON_DEBOUNCE_DELAY 16 // (count) Increase if buttons bounce or repeat too fast
#endif
//#define FAST_BUTTON_POLLING // Poll buttons at ~1kHz on 8-bit AVR. Set to 'false' for slow polling on 32-bit.
// @section safety
/**

View file

@ -3557,6 +3557,10 @@
#define HAS_ROTARY_ENCODER 1
#endif
#if defined(CPU_32_BIT) && !defined(FAST_BUTTON_POLLING)
#define FAST_BUTTON_POLLING
#endif
#if PIN_EXISTS(SAFE_POWER) && DISABLED(DISABLE_DRIVER_SAFE_POWER_PROTECT)
#define HAS_DRIVER_SAFE_POWER_PROTECT 1
#endif

View file

@ -4283,10 +4283,15 @@ void Temperature::isr() {
#endif // SLOW_PWM_HEATERS
//
// Update lcd buttons 488 times per second
// Update lcd buttons at ~488Hz or ~976Hz
//
static bool do_buttons;
if ((do_buttons ^= true)) ui.update_buttons();
#if ENABLED(FAST_BUTTON_POLLING)
constexpr bool do_buttons = true;
#else
static bool do_buttons;
do_buttons ^= true;
#endif
if (do_buttons) ui.update_buttons();
/**
* One sensor is sampled on every other call of the ISR.