Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meteor Rain color changing #2

Open
Viktus04 opened this issue Aug 15, 2018 · 2 comments
Open

Meteor Rain color changing #2

Viktus04 opened this issue Aug 15, 2018 · 2 comments

Comments

@Viktus04
Copy link

Viktus04 commented Aug 15, 2018

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);
  }
@toblum
Copy link
Collaborator

toblum commented Aug 16, 2018

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

@debsahu
Copy link
Owner

debsahu commented Aug 16, 2018

@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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants