summaryrefslogtreecommitdiff
path: root/quantum/rgblight.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/rgblight.c')
-rw-r--r--quantum/rgblight.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/quantum/rgblight.c b/quantum/rgblight.c
index 7f9e330d37..65308572db 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -29,7 +29,7 @@
#endif
#include "wait.h"
#include "progmem.h"
-#include "timer.h"
+#include "sync_timer.h"
#include "rgblight.h"
#include "color.h"
#include "debug.h"
@@ -684,18 +684,16 @@ static void rgblight_layers_write(void) {
# ifdef RGBLIGHT_LAYER_BLINK
rgblight_layer_mask_t _blinked_layer_mask = 0;
-uint16_t _blink_duration = 0;
static uint16_t _blink_timer;
void rgblight_blink_layer(uint8_t layer, uint16_t duration_ms) {
rgblight_set_layer_state(layer, true);
_blinked_layer_mask |= 1 << layer;
- _blink_timer = timer_read();
- _blink_duration = duration_ms;
+ _blink_timer = sync_timer_read() + duration_ms;
}
void rgblight_unblink_layers(void) {
- if (_blinked_layer_mask != 0 && timer_elapsed(_blink_timer) > _blink_duration) {
+ if (_blinked_layer_mask != 0 && timer_expired(sync_timer_read(), _blink_timer)) {
for (uint8_t layer = 0; layer < RGBLIGHT_MAX_LAYERS; layer++) {
if ((_blinked_layer_mask & 1 << layer) != 0) {
rgblight_set_layer_state(layer, false);
@@ -799,7 +797,7 @@ void rgblight_update_sync(rgblight_syncinfo_t *syncinfo, bool write_to_eeprom) {
animation_status.restart = true;
}
# endif /* RGBLIGHT_SPLIT_NO_ANIMATION_SYNC */
-# endif /* RGBLIGHT_USE_TIMER */
+# endif /* RGBLIGHT_USE_TIMER */
}
#endif /* RGBLIGHT_SPLIT */
@@ -832,7 +830,7 @@ void rgblight_timer_enable(void) {
if (!is_static_effect(rgblight_config.mode)) {
rgblight_status.timer_enabled = true;
}
- animation_status.last_timer = timer_read();
+ animation_status.last_timer = sync_timer_read();
RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE;
dprintf("rgblight timer enabled.\n");
}
@@ -941,18 +939,19 @@ void rgblight_task(void) {
# endif
if (animation_status.restart) {
animation_status.restart = false;
- animation_status.last_timer = timer_read() - interval_time - 1;
+ animation_status.last_timer = sync_timer_read();
animation_status.pos16 = 0; // restart signal to local each effect
}
- if (timer_elapsed(animation_status.last_timer) >= interval_time) {
+ uint16_t now = sync_timer_read();
+ if (timer_expired(now, animation_status.last_timer)) {
# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC)
static uint16_t report_last_timer = 0;
static bool tick_flag = false;
uint16_t oldpos16;
if (tick_flag) {
tick_flag = false;
- if (timer_elapsed(report_last_timer) >= 30000) {
- report_last_timer = timer_read();
+ if (timer_expired(now, report_last_timer)) {
+ report_last_timer += 30000;
dprintf("rgblight animation tick report to slave\n");
RGBLIGHT_SPLIT_ANIMATION_TICK;
}