Class Segment

Inheritance Relationships

Base Type

Class Documentation

class Segment : public AnimatableObject

Single segment class definition. used to store which LEDs belong to one segment and applying animations on it.

Public Types

enum direction

Direction in which the LED strip is wired in.

Values:

enumerator LEFT_TO_RIGHT
enumerator RIGHT_TO_LEFT
enumerator TOP_TO_BOTTTOM
enumerator BOTTOM_TO_TOP

Public Functions

Segment(CRGB LEDBuffer[], uint16_t indexOfFirstLEDInSegment, uint8_t segmentLength, direction Direction, CRGB segmentColor = CRGB::Black)

Construct a new Segment object.

Parameters:
  • LEDBuffer – Array of all LEDs connected in one string. Substitution of this buffer is done internally

  • indexOfFirstLEDInSegment – Index of the first LED in the whole LED string that belongs to this segment

  • segmentLength – Number of LEDs which belong to this segment

  • Direction – Defines which way the LED segment is wired in

  • segmentColor – initial color of the segment

~Segment()

Destroy the Segment object.

virtual void tick(int32_t currentState)

Set the current animation state of the segment to a defined value.

Parameters:

currentState – The current state of the animation starting at 0, relative to it’s absolute animation length. Over and undershoot is also possible.

void setColor(CRGB SegmentColor)

sets the color of the segment without displaying the change

void updateColor(CRGB SegmentColor)

sets the color of the segment and updates it automatically in case the segment is turned on

void display()

Write the current animation color to all LEDs that belong to this segment. Writes to the LED buffer but relies on an external FastLED.show() call to actually write that change to the LEDs.

void off()

Turns off the leds of this segment but doesn’t change the stored color of the segment.

void updateAnimationColor(CRGB newColor)

Change tha animation color, also possible to do while an animation is in progress.

Parameters:

newColor – new color to use in for the current segment and animation