@@ -41,7 +41,11 @@ led_strip.initialize = function (callback, scrollPosition) {
4141 }
4242
4343 function load_led_mode_colors ( ) {
44- MSP . send_message ( MSPCodes . MSP_LED_STRIP_MODECOLOR , false , false , load_html ) ;
44+ MSP . send_message ( MSPCodes . MSP_LED_STRIP_MODECOLOR , false , false , semver . gte ( FC . CONFIG . apiVersion , API_VERSION_1_46 ) ? load_led_config_values : load_html ) ;
45+ }
46+
47+ function load_led_config_values ( ) {
48+ MSP . send_message ( MSPCodes . MSP2_GET_LED_STRIP_CONFIG_VALUES , false , false , load_html ) ;
4549 }
4650
4751 function load_html ( ) {
@@ -378,6 +382,8 @@ led_strip.initialize = function (callback, scrollPosition) {
378382 if ( feature_o . is ( ':checked' ) !== newVal ) {
379383 feature_o . prop ( 'checked' , newVal ) ;
380384 feature_o . trigger ( 'change' ) ;
385+
386+ $ ( '.rainbowSlidersDiv' ) . toggle ( $ ( '.checkbox.rainbowOverlay' ) . find ( 'input' ) . is ( ':checked' ) ) ; //rainbow slider visibility
381387 }
382388 } ) ;
383389
@@ -504,6 +510,11 @@ led_strip.initialize = function (callback, scrollPosition) {
504510 }
505511 }
506512
513+ //Change Rainbow slider visibility
514+ if ( that . is ( '.function-y' ) ) {
515+ $ ( '.rainbowSlidersDiv' ) . toggle ( that . is ( ':checked' ) ) ;
516+ }
517+
507518 if ( $ ( '.ui-selected' ) . length > 0 ) {
508519 TABS . led_strip . overlays . forEach ( function ( letter ) {
509520 if ( $ ( that ) . is ( functionTag + letter ) ) {
@@ -555,6 +566,78 @@ led_strip.initialize = function (callback, scrollPosition) {
555566 $ ( this ) . addClass ( `color-${ led . color } ` ) ;
556567 } ) ;
557568
569+ //default slider values
570+ $ ( 'div.brightnessSlider input' ) . first ( ) . prop ( 'value' , FC . LED_CONFIG_VALUES . brightness ) ;
571+ $ ( 'div.brightnessSlider label' ) . first ( ) . text ( $ ( 'div.brightnessSlider input' ) . first ( ) . val ( ) ) ;
572+ $ ( 'div.rainbowDeltaSlider input' ) . first ( ) . prop ( 'value' , FC . LED_CONFIG_VALUES . rainbow_delta ) ;
573+ $ ( 'div.rainbowDeltaSlider label' ) . first ( ) . text ( $ ( 'div.rainbowDeltaSlider input' ) . first ( ) . val ( ) ) ;
574+ $ ( 'div.rainbowFreqSlider input' ) . first ( ) . prop ( 'value' , FC . LED_CONFIG_VALUES . rainbow_freq ) ;
575+ $ ( 'div.rainbowFreqSlider label' ) . first ( ) . text ( $ ( 'div.rainbowFreqSlider input' ) . first ( ) . val ( ) ) ;
576+
577+ //Brightness slider
578+ let bufferingBrightness = [ ] ,
579+ buffer_delay_brightness = false ;
580+
581+ $ ( 'div.brightnessSlider input' ) . on ( 'input' , function ( ) {
582+ const val = $ ( this ) . val ( ) ;
583+ bufferingBrightness . push ( val ) ;
584+
585+ if ( ! buffer_delay_brightness ) {
586+ buffer_delay_brightness = setTimeout ( function ( ) {
587+ FC . LED_CONFIG_VALUES . brightness = bufferingBrightness . pop ( ) ;
588+ mspHelper . sendLedStripConfigValues ( ) ;
589+
590+ bufferingBrightness = [ ] ;
591+ buffer_delay_brightness = false ;
592+ } , 10 ) ;
593+ }
594+
595+ $ ( 'div.brightnessSlider label' ) . first ( ) . text ( val ) ;
596+ } ) ;
597+
598+ //Rainbow Delta slider
599+ let bufferingRainbowDelta = [ ] ,
600+ buffer_delay_rainbow_delta = false ;
601+
602+ $ ( 'div.rainbowDeltaSlider input' ) . on ( 'input' , function ( ) {
603+ const val = $ ( this ) . val ( ) ;
604+ bufferingRainbowDelta . push ( val ) ;
605+
606+ if ( ! buffer_delay_rainbow_delta ) {
607+ buffer_delay_rainbow_delta = setTimeout ( function ( ) {
608+ FC . LED_CONFIG_VALUES . rainbow_delta = bufferingRainbowDelta . pop ( ) ;
609+ mspHelper . sendLedStripConfigValues ( ) ;
610+
611+ bufferingRainbowDelta = [ ] ;
612+ buffer_delay_rainbow_delta = false ;
613+ } , 10 ) ;
614+ }
615+
616+ $ ( 'div.rainbowDeltaSlider label' ) . first ( ) . text ( val ) ;
617+ } ) ;
618+
619+ //Rainbow Frequency slider
620+ let bufferingRainbowFreq = [ ] ,
621+ buffer_delay_rainbow_freq = false ;
622+
623+ $ ( 'div.rainbowFreqSlider input' ) . on ( 'input' , function ( ) {
624+ const val = $ ( this ) . val ( ) ;
625+ bufferingRainbowFreq . push ( val ) ;
626+
627+ if ( ! buffer_delay_rainbow_freq ) {
628+ buffer_delay_rainbow_freq = setTimeout ( function ( ) {
629+ FC . LED_CONFIG_VALUES . rainbow_freq = bufferingRainbowFreq . pop ( ) ;
630+ mspHelper . sendLedStripConfigValues ( ) ;
631+
632+ bufferingRainbowFreq = [ ] ;
633+ buffer_delay_rainbow_freq = false ;
634+ } , 10 ) ;
635+ }
636+
637+ $ ( 'div.rainbowFreqSlider label' ) . first ( ) . text ( val ) ;
638+ } ) ;
639+
640+
558641 $ ( 'a.save' ) . on ( 'click' , function ( ) {
559642 mspHelper . sendLedStripConfig ( send_led_strip_colors ) ;
560643
@@ -786,6 +869,8 @@ led_strip.initialize = function (callback, scrollPosition) {
786869
787870 $ ( '.vtxOverlay' ) . toggle ( isVtxActive ( activeFunction ) ) ;
788871
872+ $ ( '.brightnessSliderDiv' ) . toggle ( semver . gte ( FC . CONFIG . apiVersion , API_VERSION_1_46 ) ) ;
873+
789874 // set mode colors visibility
790875 if ( activeFunction === "function-f" ) {
791876 $ ( '.mode_colors' ) . show ( ) ;
0 commit comments