NeoAnimationFX icon indicating copy to clipboard operation
NeoAnimationFX copied to clipboard

Meteor Rain color changing

Open Viktus04 opened this issue 7 years ago • 2 comments

Hello,

I am totally new to programming and I already talked to Tobias Blum because I'm using the Mc Lighting platform for my Wemos D1, he said that maybe you could help me. I want the Meteor Rain Effect to change the color after every cycle. I already tried to do it by myself but I'm not getting to the point where it works like this, I added the color_wheel the color is changing extremely fast and not after every cycle. but maybe I'm wrong with that. maybe you have a quick solution for me?

Thank you very much for your great work!

  uint16_t meteorRain(uint8_t meteorTrailDecay, boolean meteorRandomDecay) {  
    uint16_t meteorSize = SEGMENT_LENGTH * 0.20;
    
    SEGMENT_RUNTIME.aux_param = get_random_wheel_index(SEGMENT_RUNTIME.aux_param);
	RgbColor color = color_wheel(SEGMENT_RUNTIME.aux_param);
	
	
	
	if(SEGMENT_RUNTIME.counter_mode_step == 0){
      _strip.ClearTo(rgbcolor_black);
	}
  
    if( SEGMENT_RUNTIME.counter_mode_step <= SEGMENT_LENGTH*2 ) {
      // fade brightness all LEDs one step
      for(uint16_t i=0; i <= SEGMENT_LENGTH; i++) {
        if( (!meteorRandomDecay) || (random(10)>5) ) {
          fadeToBlackVal(i, meteorTrailDecay );        
        }
      }
      // draw meteor
  for(uint16_t i = 0; i <= meteorSize; i++) {
        if( ( (SEGMENT_RUNTIME.counter_mode_step)-i <= SEGMENT_LENGTH) && ((SEGMENT_RUNTIME.counter_mode_step)-i >= 0) ) {
          if(!SEGMENT.reverse){
            this->setPixelColor(SEGMENT_RUNTIME.counter_mode_step - i, color);
		  } else {
		    this->setPixelColor(SEGMENT_LENGTH - SEGMENT_RUNTIME.counter_mode_step + i, color);
          }
        } 
      }
    } 

	SEGMENT_RUNTIME.counter_mode_step = (SEGMENT_RUNTIME.counter_mode_step + 1) % SEGMENT_LENGTH;
    return
    (SEGMENT.speed / SEGMENT_LENGTH);
  }
  
  uint16_t mode_meteor_rain(void) {
    return meteorRain(64, true);
  }

Viktus04 avatar Aug 15 '18 22:08 Viktus04

Hi @Viktus04,

you mentioned the comet effect. That is a bit easier to read. The meteor effect is more complex to understand for me, without trying it out. Honestly I didn't look in detail how the effects work, so far. I think the goal is to find the position in code where the effect starts again. I couldn't try it out, but maybe after "_strip.ClearTo(rgbcolor_black);" could be the right position to reset the color.

Best regards Tobias

toblum avatar Aug 16 '18 19:08 toblum

@Viktus04 @toblum Sorry dont have my computer and setup to test it. @toblum is right, all you have to do is set a SEGMENT.colors[0] to some color you like after _strip.ClearTo(rgbcolor_black);

debsahu avatar Aug 16 '18 19:08 debsahu