@@ -20,8 +20,9 @@ use goxlr_types::{
2020 Button , ChannelName , DisplayModeComponents , EffectBankPresets , EffectKey , EncoderName ,
2121 FaderName , HardTuneSource , InputDevice as BasicInputDevice , MicrophoneParamKey , Mix , MuteState ,
2222 OutputDevice as BasicOutputDevice , RobotRange , SampleBank , SampleButtons , SamplePlaybackMode ,
23- VersionNumber ,
23+ VersionNumber , WaterfallDirection ,
2424} ;
25+ use goxlr_usb:: animation:: { AnimationMode , WaterFallDir } ;
2526use goxlr_usb:: buttonstate:: { ButtonStates , Buttons } ;
2627use goxlr_usb:: channelstate:: ChannelState ;
2728use goxlr_usb:: channelstate:: ChannelState :: { Muted , Unmuted } ;
@@ -209,6 +210,8 @@ impl<'a> Device<'a> {
209210 sample_error. replace ( error. clone ( ) ) ;
210211 }
211212
213+ let is_mini = self . hardware . device_type == DeviceType :: Mini ;
214+
212215 MixerStatus {
213216 hardware : self . hardware . clone ( ) ,
214217 shutdown_commands,
@@ -233,12 +236,10 @@ impl<'a> Device<'a> {
233236 } ,
234237 lighting : self
235238 . profile
236- . get_lighting_ipc ( self . hardware . device_type == DeviceType :: Mini ) ,
237- effects : self
238- . profile
239- . get_effects_ipc ( self . hardware . device_type == DeviceType :: Mini ) ,
239+ . get_lighting_ipc ( is_mini, self . device_supports_animations ( ) ) ,
240+ effects : self . profile . get_effects_ipc ( is_mini) ,
240241 sampler : self . profile . get_sampler_ipc (
241- self . hardware . device_type == DeviceType :: Mini ,
242+ is_mini ,
242243 & self . audio_handler ,
243244 sampler_prerecord,
244245 SampleProcessState {
@@ -1631,6 +1632,39 @@ impl<'a> Device<'a> {
16311632 }
16321633
16331634 // Colouring..
1635+ GoXLRCommand :: SetAnimationMode ( mode) => {
1636+ if !self . device_supports_animations ( ) {
1637+ bail ! ( "Animations not supported on this firmware." ) ;
1638+ }
1639+
1640+ self . profile . set_animation_mode ( mode) ?;
1641+ self . load_animation ( false ) ?;
1642+ }
1643+ GoXLRCommand :: SetAnimationMod1 ( value) => {
1644+ if !self . device_supports_animations ( ) {
1645+ bail ! ( "Animations not supported on this firmware." ) ;
1646+ }
1647+
1648+ self . profile . set_animation_mod1 ( value) ?;
1649+ self . load_animation ( false ) ?;
1650+ }
1651+ GoXLRCommand :: SetAnimationMod2 ( value) => {
1652+ if !self . device_supports_animations ( ) {
1653+ bail ! ( "Animations not supported on this firmware." ) ;
1654+ }
1655+
1656+ self . profile . set_animation_mod2 ( value) ?;
1657+ self . load_animation ( false ) ?;
1658+ }
1659+ GoXLRCommand :: SetAnimationWaterfall ( direction) => {
1660+ if !self . device_supports_animations ( ) {
1661+ bail ! ( "Animations not supported on this firmware." ) ;
1662+ }
1663+
1664+ self . profile . set_animation_waterfall ( direction) ?;
1665+ self . load_animation ( false ) ?;
1666+ }
1667+
16341668 GoXLRCommand :: SetGlobalColour ( colour) => {
16351669 self . profile . set_global_colour ( colour) ?;
16361670 self . load_colour_map ( ) ?;
@@ -2812,18 +2846,7 @@ impl<'a> Device<'a> {
28122846 // The new colour format occurred on different firmware versions depending on device,
28132847 // so do the check here.
28142848
2815- let use_1_3_40_format: bool = match self . hardware . device_type {
2816- DeviceType :: Unknown => true ,
2817- DeviceType :: Full => version_newer_or_equal_to (
2818- & self . hardware . versions . firmware ,
2819- VersionNumber ( 1 , 3 , 40 , 0 ) ,
2820- ) ,
2821- DeviceType :: Mini => version_newer_or_equal_to (
2822- & self . hardware . versions . firmware ,
2823- VersionNumber ( 1 , 1 , 8 , 0 ) ,
2824- ) ,
2825- } ;
2826-
2849+ let use_1_3_40_format = self . device_supports_animations ( ) ;
28272850 let colour_map = self . profile . get_colour_map ( use_1_3_40_format) ;
28282851
28292852 if use_1_3_40_format {
@@ -2837,6 +2860,41 @@ impl<'a> Device<'a> {
28372860 Ok ( ( ) )
28382861 }
28392862
2863+ fn load_animation ( & mut self , map_set : bool ) -> Result < ( ) > {
2864+ let enabled = self . profile . get_animation_mode ( ) != goxlr_types:: AnimationMode :: None ;
2865+
2866+ // This one is kinda weird, we go from profile -> types -> usb..
2867+ let mode = match self . profile . get_animation_mode ( ) {
2868+ goxlr_types:: AnimationMode :: RetroRainbow => AnimationMode :: RetroRainbow ,
2869+ goxlr_types:: AnimationMode :: RainbowDark => AnimationMode :: RainbowDark ,
2870+ goxlr_types:: AnimationMode :: RainbowBright => AnimationMode :: RainbowBright ,
2871+ goxlr_types:: AnimationMode :: Simple => AnimationMode :: Simple ,
2872+ goxlr_types:: AnimationMode :: Ripple => AnimationMode :: Ripple ,
2873+ goxlr_types:: AnimationMode :: None => AnimationMode :: None ,
2874+ } ;
2875+
2876+ let mod1 = self . profile . get_animation_mod1 ( ) ;
2877+ let mod2 = self . profile . get_animation_mod2 ( ) ;
2878+ let waterfall = match self . profile . get_animation_waterfall ( ) {
2879+ WaterfallDirection :: Down => WaterFallDir :: Down ,
2880+ WaterfallDirection :: Up => WaterFallDir :: Up ,
2881+ WaterfallDirection :: Off => WaterFallDir :: Off ,
2882+ } ;
2883+
2884+ self . goxlr
2885+ . set_animation_mode ( enabled, mode, mod1, mod2, waterfall) ?;
2886+
2887+ if !map_set
2888+ && ( mode == AnimationMode :: None
2889+ || mode == AnimationMode :: Ripple
2890+ || mode == AnimationMode :: Simple )
2891+ {
2892+ self . load_colour_map ( ) ?;
2893+ }
2894+
2895+ Ok ( ( ) )
2896+ }
2897+
28402898 async fn apply_profile ( & mut self , current : Option < CurrentState > ) -> Result < ( ) > {
28412899 // Set volumes first, applying mute may modify stuff..
28422900 debug ! ( "Applying Profile.." ) ;
@@ -2913,6 +2971,11 @@ impl<'a> Device<'a> {
29132971 debug ! ( "Loading Colour Map.." ) ;
29142972 self . load_colour_map ( ) ?;
29152973
2974+ if self . device_supports_animations ( ) {
2975+ // Load any animation settings..
2976+ self . load_animation ( true ) ?;
2977+ }
2978+
29162979 debug ! ( "Setting Fader display modes.." ) ;
29172980 for fader in FaderName :: iter ( ) {
29182981 debug ! ( "Setting display for {}" , fader) ;
@@ -3251,6 +3314,20 @@ impl<'a> Device<'a> {
32513314 }
32523315 }
32533316
3317+ fn device_supports_animations ( & self ) -> bool {
3318+ match self . hardware . device_type {
3319+ DeviceType :: Unknown => true ,
3320+ DeviceType :: Full => version_newer_or_equal_to (
3321+ & self . hardware . versions . firmware ,
3322+ VersionNumber ( 1 , 3 , 40 , 0 ) ,
3323+ ) ,
3324+ DeviceType :: Mini => version_newer_or_equal_to (
3325+ & self . hardware . versions . firmware ,
3326+ VersionNumber ( 1 , 1 , 8 , 0 ) ,
3327+ ) ,
3328+ }
3329+ }
3330+
32543331 // Get the current time in millis..
32553332 fn get_epoch_ms ( & self ) -> u128 {
32563333 SystemTime :: now ( )
0 commit comments