aboutsummaryrefslogtreecommitdiffstats
path: root/quantum/rgblight.h
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/rgblight.h')
-rw-r--r--quantum/rgblight.h134
1 files changed, 56 insertions, 78 deletions
diff --git a/quantum/rgblight.h b/quantum/rgblight.h
index 1769f719d..748d009dc 100644
--- a/quantum/rgblight.h
+++ b/quantum/rgblight.h
@@ -68,11 +68,11 @@
#define _RGBM_SINGLE_DYNAMIC(sym) RGBLIGHT_MODE_ ## sym,
#define _RGBM_MULTI_STATIC(sym) RGBLIGHT_MODE_ ## sym,
#define _RGBM_MULTI_DYNAMIC(sym) RGBLIGHT_MODE_ ## sym,
-#define _RGBM_TMP_STATIC(sym) RGBLIGHT_MODE_ ## sym,
-#define _RGBM_TMP_DYNAMIC(sym) RGBLIGHT_MODE_ ## sym,
+#define _RGBM_TMP_STATIC(sym, msym) RGBLIGHT_MODE_ ## sym,
+#define _RGBM_TMP_DYNAMIC(sym, msym) RGBLIGHT_MODE_ ## sym,
enum RGBLIGHT_EFFECT_MODE {
RGBLIGHT_MODE_zero = 0,
-#include "rgblight.h"
+#include "rgblight_modes.h"
RGBLIGHT_MODE_last
};
@@ -163,6 +163,33 @@ typedef union {
};
} rgblight_config_t;
+typedef struct _rgblight_status_t {
+ uint8_t base_mode;
+ bool timer_enabled;
+#ifdef RGBLIGHT_SPLIT
+ uint8_t change_flags;
+#endif
+} rgblight_status_t;
+
+#ifdef RGBLIGHT_SPLIT
+ #define RGBLIGHT_STATUS_CHANGE_MODE (1<<0)
+ #define RGBLIGHT_STATUS_CHANGE_HSVS (1<<1)
+ #define RGBLIGHT_STATUS_CHANGE_TIMER (1<<2)
+ #define RGBLIGHT_STATUS_ANIMATION_TICK (1<<3)
+
+ typedef struct _rgblight_syncinfo_t {
+ rgblight_config_t config;
+ rgblight_status_t status;
+ } rgblight_syncinfo_t;
+
+ /* for split keyboard master side */
+ uint8_t rgblight_get_change_flags(void);
+ void rgblight_clear_change_flags(void);
+ void rgblight_get_syncinfo(rgblight_syncinfo_t *syncinfo);
+ /* for split keyboard slave side */
+ void rgblight_update_sync(rgblight_syncinfo_t *syncinfo, bool write_to_eeprom);
+#endif
+
void rgblight_init(void);
void rgblight_increase(void);
void rgblight_decrease(void);
@@ -237,82 +264,33 @@ void rgblight_timer_init(void);
void rgblight_timer_enable(void);
void rgblight_timer_disable(void);
void rgblight_timer_toggle(void);
-void rgblight_effect_breathing(uint8_t interval);
-void rgblight_effect_rainbow_mood(uint8_t interval);
-void rgblight_effect_rainbow_swirl(uint8_t interval);
-void rgblight_effect_snake(uint8_t interval);
-void rgblight_effect_knight(uint8_t interval);
-void rgblight_effect_christmas(void);
-void rgblight_effect_rgbtest(void);
-void rgblight_effect_alternating(void);
-#endif // #ifndef RGBLIGHT_H_DUMMY_DEFINE
-#endif // RGBLIGHT_H
+#ifdef RGBLIGHT_USE_TIMER
+
+typedef struct _animation_status_t {
+ uint16_t last_timer;
+ uint8_t delta; /* mode - base_mode */
+ bool restart;
+ union {
+ uint16_t pos16;
+ uint8_t pos;
+ int16_t current_hue;
+ uint16_t current_offset;
+ };
+} animation_status_t;
+
+extern animation_status_t animation_status;
+
+void rgblight_effect_breathing(animation_status_t *anim);
+void rgblight_effect_rainbow_mood(animation_status_t *anim);
+void rgblight_effect_rainbow_swirl(animation_status_t *anim);
+void rgblight_effect_snake(animation_status_t *anim);
+void rgblight_effect_knight(animation_status_t *anim);
+void rgblight_effect_christmas(animation_status_t *anim);
+void rgblight_effect_rgbtest(animation_status_t *anim);
+void rgblight_effect_alternating(animation_status_t *anim);
-#ifdef _RGBM_SINGLE_STATIC
- _RGBM_SINGLE_STATIC( STATIC_LIGHT )
- #ifdef RGBLIGHT_EFFECT_BREATHING
- _RGBM_MULTI_DYNAMIC( BREATHING )
- _RGBM_TMP_DYNAMIC( breathing_3 )
- _RGBM_TMP_DYNAMIC( breathing_4 )
- _RGBM_TMP_DYNAMIC( BREATHING_end )
- #endif
- #ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
- _RGBM_MULTI_DYNAMIC( RAINBOW_MOOD )
- _RGBM_TMP_DYNAMIC( rainbow_mood_7 )
- _RGBM_TMP_DYNAMIC( RAINBOW_MOOD_end )
- #endif
- #ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
- _RGBM_MULTI_DYNAMIC( RAINBOW_SWIRL )
- _RGBM_TMP_DYNAMIC( rainbow_swirl_10 )
- _RGBM_TMP_DYNAMIC( rainbow_swirl_11 )
- _RGBM_TMP_DYNAMIC( rainbow_swirl_12 )
- _RGBM_TMP_DYNAMIC( rainbow_swirl_13 )
- _RGBM_TMP_DYNAMIC( RAINBOW_SWIRL_end )
- #endif
- #ifdef RGBLIGHT_EFFECT_SNAKE
- _RGBM_MULTI_DYNAMIC( SNAKE )
- _RGBM_TMP_DYNAMIC( snake_16 )
- _RGBM_TMP_DYNAMIC( snake_17 )
- _RGBM_TMP_DYNAMIC( snake_18 )
- _RGBM_TMP_DYNAMIC( snake_19 )
- _RGBM_TMP_DYNAMIC( SNAKE_end )
- #endif
- #ifdef RGBLIGHT_EFFECT_KNIGHT
- _RGBM_MULTI_DYNAMIC( KNIGHT )
- _RGBM_TMP_DYNAMIC( knight_22 )
- _RGBM_TMP_DYNAMIC( KNIGHT_end )
- #endif
- #ifdef RGBLIGHT_EFFECT_CHRISTMAS
- _RGBM_SINGLE_DYNAMIC( CHRISTMAS )
- #endif
- #ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
- _RGBM_MULTI_STATIC( STATIC_GRADIENT )
- _RGBM_TMP_STATIC( static_gradient_26 )
- _RGBM_TMP_STATIC( static_gradient_27 )
- _RGBM_TMP_STATIC( static_gradient_28 )
- _RGBM_TMP_STATIC( static_gradient_29 )
- _RGBM_TMP_STATIC( static_gradient_30 )
- _RGBM_TMP_STATIC( static_gradient_31 )
- _RGBM_TMP_STATIC( static_gradient_32 )
- _RGBM_TMP_STATIC( static_gradient_33 )
- _RGBM_TMP_STATIC( STATIC_GRADIENT_end )
- #endif
- #ifdef RGBLIGHT_EFFECT_RGB_TEST
- _RGBM_SINGLE_DYNAMIC( RGB_TEST )
- #endif
- #ifdef RGBLIGHT_EFFECT_ALTERNATING
- _RGBM_SINGLE_DYNAMIC( ALTERNATING )
- #endif
- //// Add a new mode here.
- // #ifdef RGBLIGHT_EFFECT_<name>
- // _RGBM_<SINGLE|MULTI>_<STATIC|DYNAMIC>( <name> )
- // #endif
#endif
-#undef _RGBM_SINGLE_STATIC
-#undef _RGBM_SINGLE_DYNAMIC
-#undef _RGBM_MULTI_STATIC
-#undef _RGBM_MULTI_DYNAMIC
-#undef _RGBM_TMP_STATIC
-#undef _RGBM_TMP_DYNAMIC
+#endif // #ifndef RGBLIGHT_H_DUMMY_DEFINE
+#endif // RGBLIGHT_H