|
@@ -67,6 +67,8 @@ Atm_fade_WS2812& Atm_fade_WS2812::pause( uint32_t duration ) {
|
|
|
return *this;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
Atm_fade_WS2812& Atm_fade_WS2812::fade( int fade_length){
|
|
|
if(fade_length>=0){
|
|
|
fade_duration = fade_length ;
|
|
@@ -93,6 +95,19 @@ Atm_fade_WS2812& Atm_fade_WS2812::fade( int fade_length, bool fade_light, int fa
|
|
|
return *this;
|
|
|
}
|
|
|
|
|
|
+Atm_fade_WS2812& Atm_fade_WS2812::fadeSpeed( float fade_speed){
|
|
|
+
|
|
|
+ fade((num_leds/fade_speed)*1000);
|
|
|
+ return *this;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+Atm_fade_WS2812& Atm_fade_WS2812::fadeSpeed( float fade_speed, bool fade_light, int fade_chase){
|
|
|
+
|
|
|
+ fade((num_leds/fade_speed)*1000, fade_light, fade_chase);
|
|
|
+ return *this;
|
|
|
+}
|
|
|
+
|
|
|
Atm_fade_WS2812& Atm_fade_WS2812::repeat( uint16_t repeat ) {
|
|
|
counter_repeat.set( repeat_count = repeat );
|
|
|
return *this;
|
|
@@ -214,6 +229,11 @@ Atm_fade_WS2812& Atm_fade_WS2812::update(){
|
|
|
return *this;
|
|
|
}
|
|
|
|
|
|
+Atm_fade_WS2812& Atm_fade_WS2812::reversed(bool _reverse){
|
|
|
+ reverse = _reverse ;
|
|
|
+ return *this ;
|
|
|
+}
|
|
|
+
|
|
|
Atm_fade_WS2812& Atm_fade_WS2812::trace( Stream& stream ) {
|
|
|
setTrace( &stream, atm_serial_debug::trace,
|
|
|
"FADE\0EVT_CNT_FADE\0EVT_TM_FADE\0EVT_TM_ON\0EVT_TM_OFF\0EVT_CNT_RPT\0EVT_ON\0EVT_OFF\0EVT_BLINK\0EVT_TOGGLE\0EVT_TOGGLE_BLINK\0ELSE\0"
|
|
@@ -226,72 +246,175 @@ Atm_fade_WS2812& Atm_fade_WS2812::trace( Stream& stream ) {
|
|
|
void Atm_fade_WS2812::update_leds(float fade_value){
|
|
|
|
|
|
if(update_flag){
|
|
|
-
|
|
|
- int current_step = fade_value * FADE_STEPS ;
|
|
|
|
|
|
CHSV temp_led[this->num_leds] ;
|
|
|
- int current_value = color.val;
|
|
|
-
|
|
|
- if(_fade_light){ current_value *= fade_value ;}
|
|
|
-
|
|
|
- current_value = constrain(current_value, 0, 255 ) ;
|
|
|
-
|
|
|
- int chase_led = num_leds;
|
|
|
- for(int led=0; led<num_leds; led++){
|
|
|
-
|
|
|
- fade_value = _fade_chase ? fade_value : 1. ;
|
|
|
- if(led<fade_value*num_leds){
|
|
|
- temp_led[led].value = current_value ;
|
|
|
- temp_led[led].saturation = color.saturation ;
|
|
|
- temp_led[led].hue = color.hue ;
|
|
|
- }
|
|
|
- else{
|
|
|
- temp_led[led].value = 0 ;
|
|
|
- temp_led[led].saturation = color.saturation ;
|
|
|
- temp_led[led].hue = color.hue ;
|
|
|
+ int current_value = color.val ;
|
|
|
+
|
|
|
+ if(_replace_array){
|
|
|
+ if(_fade_light){ current_value = color.val*fade_value ;}
|
|
|
+ current_value = constrain(current_value, 0, 255 ) ;
|
|
|
+ for(int led=0; led<num_leds; led++){
|
|
|
+
|
|
|
+ fade_value = _fade_chase ? fade_value : 1. ;
|
|
|
+ if(led<fade_value*num_leds){
|
|
|
+ temp_led[led].value = current_value ;
|
|
|
+ temp_led[led].saturation = color.saturation ;
|
|
|
+ temp_led[led].hue = color.hue ;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ temp_led[led].value = 0 ;
|
|
|
+ temp_led[led].saturation = color.saturation ;
|
|
|
+ temp_led[led].hue = color.hue ;
|
|
|
+ }
|
|
|
+ if(reverse){leds[num_leds-led-1] = CRGB(temp_led[led]);}
|
|
|
+ else{leds[led] = CRGB(temp_led[led]);}
|
|
|
}
|
|
|
-
|
|
|
- if(_replace_array){leds[led] = CRGB(temp_led[led]);}
|
|
|
- if(!_replace_array){
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if(update_flag){
|
|
|
- CRGB rgb_step = CRGB(temp_led[led]);
|
|
|
+ }
|
|
|
+ if(!_replace_array){
|
|
|
+ CRGB colorRGB = CRGB(color);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ CRGB temp_led_RGB[num_leds] ;
|
|
|
+ for(int led=0; led<num_leds; led++){
|
|
|
+ if(_fade_light){ colorRGB = colorRGB*fade_value/(FADE_STEPS*(1-led/num_leds));}
|
|
|
+ fade_value = _fade_chase ? fade_value : 1. ;
|
|
|
+
|
|
|
+ if(led<fade_value*num_leds){
|
|
|
+ int current_led = reverse ? num_leds-led-1 : led ;
|
|
|
if(this->state() == DOWN || this->state() == ODOWN) {
|
|
|
- Serial.println("down");
|
|
|
- leds[led].r = qsub8 (leds[led].r, rgb_step.r);
|
|
|
- leds[led].g = qsub8 (leds[led].g, rgb_step.g);
|
|
|
- leds[led].b = qsub8 (leds[led].b, rgb_step.b);
|
|
|
+ leds[current_led].r = qsub8 (leds[current_led].r, colorRGB.r+1);
|
|
|
+ leds[current_led].g = qsub8 (leds[current_led].g, colorRGB.g+1);
|
|
|
+ leds[current_led].b = qsub8 (leds[current_led].b, colorRGB.b+1);
|
|
|
}
|
|
|
else{
|
|
|
- leds[led].r = qadd8 (leds[led].r, rgb_step.r);
|
|
|
- leds[led].g = qadd8 (leds[led].g, rgb_step.g);
|
|
|
- leds[led].b = qadd8 (leds[led].b, rgb_step.b);
|
|
|
+ leds[current_led].r = qadd8 (leds[current_led].r, colorRGB.r);
|
|
|
+ leds[current_led].g = qadd8 (leds[current_led].g, colorRGB.g);
|
|
|
+ leds[current_led].b = qadd8 (leds[current_led].b, colorRGB.b);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|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