- if (rgblight_timer_enabled) {
- // mode = 1, static light, do nothing here
- if (rgblight_config.mode >= 2 && rgblight_config.mode <= 5) {
- // mode = 2 to 5, breathing mode
- rgblight_effect_breathing(rgblight_config.mode - 2);
- } else if (rgblight_config.mode >= 6 && rgblight_config.mode <= 8) {
- // mode = 6 to 8, rainbow mood mod
- rgblight_effect_rainbow_mood(rgblight_config.mode - 6);
- } else if (rgblight_config.mode >= 9 && rgblight_config.mode <= 14) {
- // mode = 9 to 14, rainbow swirl mode
- rgblight_effect_rainbow_swirl(rgblight_config.mode - 9);
- } else if (rgblight_config.mode >= 15 && rgblight_config.mode <= 20) {
- // mode = 15 to 20, snake mode
- rgblight_effect_snake(rgblight_config.mode - 15);
- } else if (rgblight_config.mode >= 21 && rgblight_config.mode <= 23) {
- // mode = 21 to 23, knight mode
- rgblight_effect_knight(rgblight_config.mode - 21);
- } else if (rgblight_config.mode == 24) {
- // mode = 24, christmas mode
- rgblight_effect_christmas();
+ if (rgblight_status.timer_enabled) {
+ effect_func_t effect_func = rgblight_effect_dummy;
+ uint16_t interval_time = 2000; // dummy interval
+ uint8_t delta = rgblight_config.mode - rgblight_status.base_mode;
+ animation_status.delta = delta;
+
+ // static light mode, do nothing here
+ if ( 1 == 0 ) { //dummy
+ }
+#ifdef RGBLIGHT_EFFECT_BREATHING
+ else if (rgblight_status.base_mode == RGBLIGHT_MODE_BREATHING) {
+ // breathing mode
+ interval_time = get_interval_time(&RGBLED_BREATHING_INTERVALS[delta], 1, 100);
+ effect_func = rgblight_effect_breathing;
+ }
+#endif
+#ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
+ else if (rgblight_status.base_mode == RGBLIGHT_MODE_RAINBOW_MOOD) {
+ // rainbow mood mode
+ interval_time = get_interval_time(&RGBLED_RAINBOW_MOOD_INTERVALS[delta], 5, 100);
+ effect_func = rgblight_effect_rainbow_mood;
+ }
+#endif
+#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
+ else if (rgblight_status.base_mode == RGBLIGHT_MODE_RAINBOW_SWIRL) {
+ // rainbow swirl mode
+ interval_time = get_interval_time(&RGBLED_RAINBOW_SWIRL_INTERVALS[delta / 2], 1, 100);
+ effect_func = rgblight_effect_rainbow_swirl;
+ }
+#endif
+#ifdef RGBLIGHT_EFFECT_SNAKE
+ else if (rgblight_status.base_mode == RGBLIGHT_MODE_SNAKE) {
+ // snake mode
+ interval_time = get_interval_time(&RGBLED_SNAKE_INTERVALS[delta / 2], 1, 200);
+ effect_func = rgblight_effect_snake;
+ }
+#endif
+#ifdef RGBLIGHT_EFFECT_KNIGHT
+ else if (rgblight_status.base_mode == RGBLIGHT_MODE_KNIGHT) {
+ // knight mode
+ interval_time = get_interval_time(&RGBLED_KNIGHT_INTERVALS[delta], 5, 100);
+ effect_func = rgblight_effect_knight;
+ }
+#endif
+#ifdef RGBLIGHT_EFFECT_CHRISTMAS
+ else if (rgblight_status.base_mode == RGBLIGHT_MODE_CHRISTMAS) {
+ // christmas mode
+ interval_time = RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL;
+ effect_func = (effect_func_t)rgblight_effect_christmas;
+ }
+#endif
+#ifdef RGBLIGHT_EFFECT_RGB_TEST
+ else if (rgblight_status.base_mode == RGBLIGHT_MODE_RGB_TEST) {
+ // RGB test mode
+ interval_time = pgm_read_word(&RGBLED_RGBTEST_INTERVALS[0]);
+ effect_func = (effect_func_t)rgblight_effect_rgbtest;
+ }
+#endif
+#ifdef RGBLIGHT_EFFECT_ALTERNATING
+ else if (rgblight_status.base_mode == RGBLIGHT_MODE_ALTERNATING){
+ interval_time = 500;
+ effect_func = (effect_func_t)rgblight_effect_alternating;
+ }
+#endif
+ if (animation_status.restart) {
+ animation_status.restart = false;
+ animation_status.last_timer = timer_read() - interval_time - 1;
+ animation_status.pos16 = 0; // restart signal to local each effect
+ }
+ if (timer_elapsed(animation_status.last_timer) >= interval_time) {
+#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;
+ //dprintf("rgblight animation tick\n");
+ if (timer_elapsed(report_last_timer) >= 30000) {
+ report_last_timer = timer_read();
+ dprintf("rgblight animation tick report to slave\n");
+ RGBLIGHT_SPLIT_ANIMATION_TICK;
+ }
+ }
+ oldpos16 = animation_status.pos16;
+ //dprintf("call effect function\n");
+#endif
+ animation_status.last_timer += interval_time;
+ effect_func(&animation_status);
+#if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC)
+ //dprintf("pos16, oldpos16 = %d %d\n",
+ // animation_status.pos16,oldpos16);
+ if (animation_status.pos16 == 0 && oldpos16 != 0) {
+ //dprintf("flag on\n");
+ tick_flag = true;
+ }
+#endif