quantum/rgblkght.c add animation sync for split keyboard

pull/5020/head
mtei 6 years ago
parent ea1c2e2415
commit 1d212db88c

@ -39,10 +39,12 @@
#define RGBLIGHT_SPLIT_SET_CHANGE_MODE rgblight_status.change_flags |= RGBLIGHT_STATUS_CHANGE_MODE #define RGBLIGHT_SPLIT_SET_CHANGE_MODE rgblight_status.change_flags |= RGBLIGHT_STATUS_CHANGE_MODE
#define RGBLIGHT_SPLIT_SET_CHANGE_HSVS rgblight_status.change_flags |= RGBLIGHT_STATUS_CHANGE_HSVS #define RGBLIGHT_SPLIT_SET_CHANGE_HSVS rgblight_status.change_flags |= RGBLIGHT_STATUS_CHANGE_HSVS
#define RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE rgblight_status.change_flags |= RGBLIGHT_STATUS_CHANGE_TIMER #define RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE rgblight_status.change_flags |= RGBLIGHT_STATUS_CHANGE_TIMER
#define RGBLIGHT_SPLIT_ANIMATION_TICK rgblight_status.change_flags |= RGBLIGHT_STATUS_ANIMATION_TICK
#else #else
#define RGBLIGHT_SPLIT_SET_CHANGE_MODE #define RGBLIGHT_SPLIT_SET_CHANGE_MODE
#define RGBLIGHT_SPLIT_SET_CHANGE_HSVS #define RGBLIGHT_SPLIT_SET_CHANGE_HSVS
#define RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE #define RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE
#define RGBLIGHT_SPLIT_ANIMATION_TICK
#endif #endif
#define _RGBM_SINGLE_STATIC(sym) RGBLIGHT_MODE_ ## sym, #define _RGBM_SINGLE_STATIC(sym) RGBLIGHT_MODE_ ## sym,
@ -740,6 +742,9 @@ void rgblight_update_sync(rgblight_config_t *config, rgblight_status_t *status,
rgblight_timer_disable(); rgblight_timer_disable();
} }
} }
if (status->change_flags & RGBLIGHT_STATUS_ANIMATION_TICK) {
animation_status.pos = 0;
}
#endif #endif
} }
#endif #endif
@ -858,8 +863,12 @@ void rgblight_task(void) {
} }
#endif #endif
if (timer_elapsed(animation_status.last_timer) >= interval_time) { if (timer_elapsed(animation_status.last_timer) >= interval_time) {
uint8_t old_pos = animation_status.pos;
animation_status.last_timer += interval_time; animation_status.last_timer += interval_time;
effect_func(&animation_status); effect_func(&animation_status);
if ( animation_status.pos == 0 && old_pos != animation_status.pos ) {
RGBLIGHT_SPLIT_ANIMATION_TICK;
}
} }
} }
} }

@ -177,6 +177,7 @@ typedef struct _rgblight_status_t {
#define RGBLIGHT_STATUS_CHANGE_MODE (1<<0) #define RGBLIGHT_STATUS_CHANGE_MODE (1<<0)
#define RGBLIGHT_STATUS_CHANGE_HSVS (1<<1) #define RGBLIGHT_STATUS_CHANGE_HSVS (1<<1)
#define RGBLIGHT_STATUS_CHANGE_TIMER (1<<2) #define RGBLIGHT_STATUS_CHANGE_TIMER (1<<2)
#define RGBLIGHT_STATUS_ANIMATION_TICK (1<<3)
extern rgblight_config_t rgblight_config; extern rgblight_config_t rgblight_config;
extern rgblight_status_t rgblight_status; extern rgblight_status_t rgblight_status;

Loading…
Cancel
Save