Deprecate public `LEDControl.syncDelay` variable

It is now replaced with `LEDControl.setSyncInterval()` to set the LED refresh
rate.

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
pull/1024/head
Michael Richters 4 years ago
parent f6e9896697
commit 26f1972976
No known key found for this signature in database
GPG Key ID: 1288FD13E4EEF0C0

@ -30,12 +30,16 @@ static constexpr uint8_t uninitialized_mode_id = 255;
uint8_t LEDControl::mode_id = uninitialized_mode_id; uint8_t LEDControl::mode_id = uninitialized_mode_id;
uint8_t LEDControl::num_led_modes_ = LEDModeManager::numLEDModes(); uint8_t LEDControl::num_led_modes_ = LEDModeManager::numLEDModes();
LEDMode *LEDControl::cur_led_mode_ = nullptr; LEDMode *LEDControl::cur_led_mode_ = nullptr;
uint8_t LEDControl::syncDelay = 32;
uint16_t LEDControl::syncTimer = 0;
bool LEDControl::enabled_ = true; bool LEDControl::enabled_ = true;
LEDControl::LEDControl(void) { LEDControl::LEDControl(void) {
} }
uint8_t LEDControl::sync_interval_ = 32;
uint16_t LEDControl::last_sync_time_ = 0;
#ifndef NDEPRECATED
uint8_t LEDControl::syncDelay = LEDControl::sync_interval_;
#endif
void LEDControl::next_mode(void) { void LEDControl::next_mode(void) {
mode_id++; mode_id++;
@ -197,9 +201,15 @@ EventHandlerResult LEDControl::afterEachCycle() {
if (!enabled_) if (!enabled_)
return EventHandlerResult::OK; return EventHandlerResult::OK;
if (Runtime.hasTimeExpired(syncTimer, syncDelay)) { if (Runtime.hasTimeExpired(last_sync_time_, sync_interval_)) {
#ifndef NDEPRECATED
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
sync_interval_ = syncDelay;
#pragma GCC diagnostic pop
#endif
syncLeds(); syncLeds();
syncTimer += syncDelay; last_sync_time_ += sync_interval_;
update(); update();
} }

@ -19,6 +19,14 @@
#include "kaleidoscope/Runtime.h" #include "kaleidoscope/Runtime.h"
#include "kaleidoscope/plugin/LEDMode.h" #include "kaleidoscope/plugin/LEDMode.h"
#ifndef NDEPRECATED
#define _DEPRECATED_MESSAGE_LEDCONTROL_SYNCDELAY __NL__ \
"The `LEDControl.syncDelay` variable has been deprecated.\n" __NL__ \
"Please use the `LEDControl.setInterval()` function instead."
#endif
#define LED_TOGGLE B00000001 // Synthetic, internal #define LED_TOGGLE B00000001 // Synthetic, internal
#define Key_LEDEffectNext Key(0, KEY_FLAGS | SYNTHETIC | IS_INTERNAL | LED_TOGGLE) #define Key_LEDEffectNext Key(0, KEY_FLAGS | SYNTHETIC | IS_INTERNAL | LED_TOGGLE)
@ -92,7 +100,20 @@ class LEDControl : public kaleidoscope::Plugin {
// //
static void activate(LEDModeInterface *plugin); static void activate(LEDModeInterface *plugin);
#ifndef NDEPRECATED
DEPRECATED(LEDCONTROL_SYNCDELAY)
static uint8_t syncDelay; static uint8_t syncDelay;
#endif
static void setSyncInterval(uint8_t interval) {
sync_interval_ = interval;
#ifndef NDEPRECATED
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
syncDelay = interval;
#pragma GCC diagnostic pop
#endif
}
EventHandlerResult onSetup(); EventHandlerResult onSetup();
EventHandlerResult onKeyEvent(KeyEvent &event); EventHandlerResult onKeyEvent(KeyEvent &event);
@ -112,8 +133,9 @@ class LEDControl : public kaleidoscope::Plugin {
} }
private: private:
static uint16_t syncTimer;
static uint8_t mode_id; static uint8_t mode_id;
static uint16_t last_sync_time_;
static uint8_t sync_interval_;
static uint8_t num_led_modes_; static uint8_t num_led_modes_;
static LEDMode *cur_led_mode_; static LEDMode *cur_led_mode_;
static bool enabled_; static bool enabled_;

Loading…
Cancel
Save