Class Section

Class Documentation

class Section

Public Functions

Section()

Constructor. Initializes an empty Section.

Parameters

Section(uint16_t x, uint16_t y, Section *parent = nullptr)

Constructor. Initializes the Pixel array.

Parameters

~Section()
Animation *get_animation() const

Returns the current animation.

Return

Current animation.

uint8_t get_brightness() const

Returns the Section’s brightness level.

Return

Brightness level.

Canvas *get_canvas() const

Returns the Section’s Canvas.

Return

Section’s Canvas.

Point &get_dimensions() const

Returns the size of the Pixel grid.

Return

Size of the Pixel grid.

Section::Layer *get_layer() const

Returns the Layer (if one exists).

Return

Active Layer.

Maestro &get_maestro() const

Returns the Section’s parent Maestro.

Return

Parent Maestro.

Section::Mirror *get_mirror() const

Returns whether mirroring is enabled across each axis.

Return

Mirror configuration.

Point &get_offset()

Returns the Section’s offset.

Return

Offset.

Section *get_parent_section() const

Returns this Section’s parent (if this is an Layer).

Return

Parent Section.

Pixel &get_pixel(uint16_t x, uint16_t y) const

Returns the Pixel at the specified index.

Return

Pixel.

Parameters

Colors::RGB get_pixel_color(uint16_t x, uint16_t y, Colors::RGB *base_color = nullptr)

Returns the final color of the specified Pixel.

Return

RGB value of the Pixel’s final color.

Parameters
  • x: Pixel x-coordinate.

  • y: Pixel y-coordinate.

  • base_color: The color to use as a base when blending in Layers.

Section::Scroll *get_scroll() const

Returns the Section’s scrolling behavior.

Return

Scrolling behavior.

bool get_wrap() const

Returns whether to wrap Pixels on an offset Section.

Return

If true, Pixels wrap.

void remove_animation(bool clear_pixels)

Deletes the current Animation.

Parameters
  • clear_pixels: If true, Pixels are cleared.

void remove_canvas()

Deletes the current Canvas.

void remove_layer()

Deletes the current Layer.

void remove_scroll()

Deletes the Section’s scrolling behavior.

Animation &set_animation(AnimationType animation_type, bool preserve_settings = true)

Sets a new Animation.

Return

New Animation.

Parameters
  • type: Animation type.

  • palette: The color palette to use.

  • preserve_settings: If true, the generic configurations in the old Animation (Palette, cycle index, orientation, fade, reverse, speed, and pause) are copied to the new Animation.

void set_brightness(uint8_t brightness)

Sets the overall brightness of the Section. 255 is full brightness, and 0 is completely dark.

Parameters
  • brightness: Brightness level (0 - 255).

Canvas &set_canvas(uint16_t num_frames = 1)

Sets a new Canvas of the specified type. This will overwrite the existing Canvas.

Return

The new Canvas.

Parameters
  • num_frames: The number of frames in the Canvas.

void set_dimensions(uint16_t x, uint16_t y)

Sets the size of the Section.

Parameters
  • x: Number of Pixels along the x-coordinate.

  • y: Number of Pixels along the y-coordinate.

Section::Layer &set_layer(Colors::MixMode mix_mode = Colors::MixMode::Alpha, uint8_t alpha = 128)

Sets a new Layer. If an Layer already exists, this updates the existing Layer.

Return

New Layer.

Parameters
  • mix_mode: The method for blending the Layer.

  • alpha: The Layer’s transparency (0 - 255.

void set_maestro(Maestro &maestro)

Sets the Section’s parent Maestro.

Parameters

Section::Mirror *set_mirror(bool x, bool y)

Mirrors the Section across the axes. If both x and y are false, mirroring is disabled.

Parameters

Point &set_offset(uint16_t x, uint16_t y)

Sets the Section’s offset, which shifts the Section’s output along the Pixel grid.

Return

Offset.

Parameters
  • x: Offset along the x axis.

  • y: Offset along the y axis.

void set_pixel_color(uint16_t x, uint16_t y, const Colors::RGB &color)

Sets the specified Pixel to a new color.

Parameters
  • x: The Pixel’s column.

  • y: The Pixel’s row.

  • color: New color.

  • step_count: Number of intermediate steps until the new color is reached.

Section::Scroll &set_scroll(uint16_t x, uint16_t y, bool reverse_x = false, bool reverse_y = false)

Sets the direction and rate that the Section will scroll. The values determine the amount of time until the Section completes a single scroll along the respective axis. Using a negative value reverses the scrolling direction. Setting either axis to 0 disables scrolling on that axis.

Parameters
  • x: Scrolling interval along the x axis.

  • y: Scrolling interval along the y axis.

  • reverse_x: If true, reverses the scrolling direction along the x axis.

  • reverse_y: If true, reverses the scrolling direction along the y axis.

void set_step_count(uint8_t step_count)

Sets the number of steps for fading Pixels.

Parameters
  • step_count: When > 0, gradually fades Pixels from their current color to their next color.

void set_wrap(bool wrap)

Sets whether to wrap Pixels across an offset Section.

Parameters
  • wrap: If true, Pixels wrap. If not, Pixels display black.

void sync(const uint32_t &new_time)

Sets the last update time of each component’s timer.

Parameters
  • new_time: New last refresh time.

void update(const uint32_t &current_time)

Main update routine.

Parameters
  • current_time: Program runtime.

void update_scroll(const uint32_t &current_time)

Scrolls the Section.

Parameters
  • current_time: The program’s current runtime.

struct Layer

Layers a second Section on top of the current one. When getting color output, use get_pixel_color(). This returns RGB values after blending the two Sections together.

Public Functions

Layer(Section &parent, Colors::MixMode mix_mode, uint8_t alpha = 0)

Constructor.

Parameters
  • section: Section to use as the Layer.

  • mix_mode: Color mixing method to use.

  • alpha: For The amount of transparency that the Layer will have (0 - 255).

~Layer()

Public Members

Section *section = nullptr

The Section to use as the layer.

Colors::MixMode mix_mode = Colors::MixMode::None

Method of blending the output from the Layer with the base Section.

uint8_t alpha

Transparency level of the overlaid Section.

struct Mirror

Controls mirroring across the x and y axes.

Public Functions

void set(bool x, bool y, const Point &dimensions)

Public Members

bool x = false
bool y = false
uint16_t mid_x = 0
uint16_t mid_y = 0
struct Scroll

Sets the Section’s scrolling behavior.

Public Functions

void remove_timer_x()

Removes the x axis timer.

void remove_timer_y()

Removes the y axis timer.

void set(uint16_t refresh_interval, Point *dimensions, uint16_t interval_x, uint16_t interval_y, bool reverse_x = false, bool reverse_y = false)

Sets the scrolling behavior. The step count is calculated by factoring in the Pixel grid size and Maestro refresh rate.

Parameters
  • refresh_interval: Amount of time between Maestro refreshes.

  • dimensions: The dimensions of the parent Section.

  • interval_x: The amount of time to complete a scroll along the x axis.

  • interval_y: The amount of time to complete a scroll along the y axis.

  • reverse_x: If true, reverses the scrolling direction along the x axis.

  • reverse_y: If true, reverses the scrolling direction along the y axis.

~Scroll()

Public Members

uint16_t interval_x = 0

The original x interval. This is really just storage for use in Cues.

uint16_t interval_y = 0

The original y interval.

bool reverse_x = false

If true, reverses the scrolling direction along the x axis.

bool reverse_y = false

If true, reverses the scrolling direction along the y axis.

Timer *timer_x = nullptr

Sets the amount of time between a single x-axis step. Overrides step_x when step_x is less than 1.

Timer *timer_y = nullptr

Sets the amount of time between a single y-axis step. Overrides step_y when step_y is less than 1.

uint16_t step_x = 0

Sets the number of y-axis steps to take with each update. Overridden by timer_x when this is calculated to be less than 1.

uint16_t step_y = 0

Sets the number of y-axis steps to take with each update. Overridden by timer_y when this is calculated to be less than 1.