RKTK API Docs RKTK Home Repo

Module layout

Source
Expand description

§LED Layouts

A layout defines the physical or logical positions of the LEDs in your setup, as arrangements in 1D, 2D, and 3D space.

The layout traits provide a PIXEL_COUNT constant, which is the number of LEDs, and a .points(). method, which maps each LED pixel into a 1D, 2D, or soon 3D space between -1.0 and 1.0.

§1D Layouts

For simple linear arrangements, use the layout1d! macro:

use blinksy::layout1d;

// Define a strip with 60 LEDs
layout1d!(Layout, 60);

§2D Layouts

For 2D layouts, use the layout2d! macro with one or more Shape2d definitions:

use blinksy::{layout2d, layout::Shape2d, layout::Vec2};

// Define a 16x16 LED grid
layout2d!(
    Layout,
    [Shape2d::Grid {
        start: Vec2::new(-1., -1.),
        horizontal_end: Vec2::new(1., -1.),
        vertical_end: Vec2::new(-1., 1.),
        horizontal_pixel_count: 16,
        vertical_pixel_count: 16,
        serpentine: true,
    }]
);

Structs§

GridStepIterator
Iterator for grid points with support for serpentine (zigzag) patterns.
StepIterator
Iterator that produces values by stepping from a start point.
Vec2
A 2-dimensional vector.

Enums§

Shape2d
Enumeration of two-dimensional shape primitives.
Shape2dPointsIterator
Iterator over points in a 2D shape.

Traits§

Layout1d
Trait for one-dimensional LED layouts.
Layout2d
Trait for two-dimensional LED layouts.