Define segments by code

Hi all,

I am trying to do an advanced animation on my staircase which requires me to add segments on the fly in code. I can add the segments without problems by calling strip.setSegment but somehow when I set the parameters like speed or color they are not saved.
My code looks like this:

//We have a single segment over the full length before
strip.setSegment(0, 0, currentLed);
strip.setSegment(1, currentLed, ledCount);
applyValuesToSeg(1);

void applyValuesToSeg(int segNumber)
{
  WS2812FX::Segment seg = strip.getSegment(segNumber);
  seg.speed = effectSpeed; //effectSpeed is 200 for example
}

//Now if I read the speed, the values are incorrect and the animation is slower than expected
WS2812FX::Segment& segAnimated = strip.getSegment(1);
segAnimated.speed //is the default value of 128 instead of 200

What is going on?
Thanks

Missing & :sweat_smile:

  void applyValuesToSeg(int segNumber)
  {
    WS2812FX::Segment& seg = strip.getSegment(segNumber);
    seg.speed = effectSpeed;
  }