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

New Wipe Effect for stairs = "WipeStairs" #3918

Open
aLAN-LDZ opened this issue Apr 19, 2024 · 3 comments
Open

New Wipe Effect for stairs = "WipeStairs" #3918

aLAN-LDZ opened this issue Apr 19, 2024 · 3 comments
Labels

Comments

@aLAN-LDZ
Copy link

Is your feature request related to a problem? Please describe.
It's not a problem, but I'm missing an effect that I wanted to write myself, but unfortunately I'm having a little problem with it.

Describe the solution you'd like
I would like to create a new effect based on the wipe effect that will be useful as a basic effect for the staircase. The effect would turn on individual LEDs just like the wipe effect. Then he left the LEDs on for some time. Then he turned off the LEDs individually like a wipe, only in the opposite direction

Additional context
The easiest way to explain it is with this piece of code:

for ( int i = 0; i < SEGLEN; i++)
{
  SEGMENT.setPixelColor(index, WHITE);
  delay(x)
}
delay(10000)
for ( int i = SEGLEN; i > 0; i--)
{
  SEGMENT.setPixelColor(index, BLACK);
  delay(x)
}

So far, I have managed to write an effect that lights up all the LEDs. I'm missing the next two steps:

  1. leaving the LEDs on for some time
  2. turning the LEDs off in the reverse order of turning them on
uint16_t stairs(void)
{
  uint32_t mainColor = SEGCOLOR(0);
  uint32_t secondColor = SEGCOLOR(1);

  SEGMENT.fill(secondColor);

  uint32_t cycleTime = 750 + (255 - SEGMENT.speed)*150;
  uint32_t perc = strip.now % cycleTime;
  uint16_t prog = (perc * 65535) / cycleTime;
  uint16_t ledIndex = (prog * SEGLEN) >> 15;

  for (int i = 0; i < SEGLEN; i++)
  {
    if (i < ledIndex)
    {
      SEGMENT.setPixelColor(i, mainColor);
    }
  }

  return FRAMETIME;
}
static const char _data_FX_MODE_STAIRS[] PROGMEM = "Stairs@!,!;!,!;!";

This seems to me quite an interesting idea for an effect that can be used for stairs. If you can, help me finish it. Thank you for any advice

@blazoncek
Copy link
Collaborator

There is a usermod for staircase which does what you require.

@aLAN-LDZ
Copy link
Author

Are you sure? because when I looked at it, I only saw whole segments lighting up at once, not wipe style

@aLAN-LDZ
Copy link
Author

aLAN-LDZ commented Apr 21, 2024

@blazoncek I managed to write working code. This could probably be improved further. If you don't mind, you can add it to the effects.

//StairsEffect
uint16_t stairs(void)
{
  const uint16_t delayTime = 5000;
  uint32_t startTime = 0;

  uint32_t mainColor = SEGCOLOR(0);
  uint32_t secondColor = SEGCOLOR(1);

  uint32_t cycleTime = 750 + (255 - SEGMENT.speed)*150;
  uint32_t perc = strip.now % cycleTime;
  uint16_t prog = (perc * 65535) / cycleTime;

  uint16_t ledIndex = (((prog * SEGLEN) >> 15) < SEGLEN) ? ((prog * SEGLEN) >> 15) : (SEGLEN - 1);
  uint16_t ledIndex2 = (SEGLEN - 1) - ledIndex;

  switch (SEGMENT.step)
  {
  case 0:
    SEGMENT.setPixelColor(ledIndex, mainColor);

    if (ledIndex == SEGLEN - 1)
    {
      SEGMENT.step = 1;
      startTime = strip.now;
    }
    break;
  case 1:
    if (strip.now - startTime >= delayTime)
    {
      SEGMENT.step = 2;
    }
    break;
  case 2:
    if (ledIndex2 != 0 && SEGMENT.aux0 == 0)
    {
      SEGMENT.aux0 = 1;
    }

    if (SEGMENT.aux0 == 1)
    {
      SEGMENT.setPixelColor(ledIndex2, secondColor);
    }

    if (ledIndex2 == 0 && SEGMENT.aux0 == 1)
    {
      SEGMENT.step = 3;
      SEGMENT.aux0 = 0;
    }  
    break;
  case 3:
      if(ledIndex == 0)
      {
        SEGMENT.step = 0;
      }
    break; 
  default:
    break;
  }

  return FRAMETIME;
}
static const char _data_FX_MODE_STAIRS[] PROGMEM = "Stairs@!,!;!,!;!";
//StairsEffectEnd

"Stairs@!,!;!,!;!"; - Can someone explain to me exactly what all chars are responsible for?

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

No branches or pull requests

2 participants