led_matrix
Chained LED panels: turning (x, y) into a position along the chain.
A panel is a strip someone folded. The LEDs are wired in one line, and the only thing separating a 5×5 grid from a 25-LED strip is knowing where the line doubles back. Vendors fold them differently, so that knowledge is the whole content of this crate.
Not a driver
Section titled “Not a driver”This lives in lib/, not drivers/. A driver knows a part number and its
output is destined for a pin: ws2812 knows GRB order and 350 ns pulses,
bme280 knows a humidity register. This knows no chip, no bus and no pin,
and its output is an integer. The same layouts describe APA102, SK9822 and
anything else wired as a chain.
It depends on nothing — not even api, which the layer check now enforces
for lib/ crates rather than merely describing. Calling it a driver would
have been a false statement about what it is.
Coordinates
Section titled “Coordinates”x increases to the right, y increases downward, both from zero at
the top-left of the panel as you look at it. Screen convention, not
Cartesian, because it matches how anyone writing a font or a bitmap will
already be thinking.
Measure your panel, do not guess it
Section titled “Measure your panel, do not guess it”There are 16 layouts and they all look plausible. Getting it wrong lights the wrong pixel, which reads as a broken panel rather than a wrong constant.
apps/examples/blink --features atom-matrix walks the chain one LED at a time and
logs each index. Watch which cell lights, and you have measured it:
- where index 0 sits → [
Origin] - whether index 1 is beside or below it → [
Axis] - whether each line restarts at the same edge or reverses → [
Order]
Where a measured layout belongs
Section titled “Where a measured layout belongs”Not here. A panel’s geometry is a fact about a board, in the same way a
pin number is, and the board manifest is the single place those live so
that applications do not carry datasheet knowledge. board::active
declares the layout for a board that physically has a panel — see
board/src/m5_atom_matrix.rs.
For a panel that is not part of any board, a strip you wired up yourself, the application declares it. That is honest: nobody has measured it for you.
Structs
Section titled “Structs”Layout
Section titled “Layout”struct Layout { pub width: usize, pub height: usize, pub origin: Origin, pub axis: Axis, pub order: Order,}How a panel is folded.
Implements: Clone, Copy, Debug, Eq, PartialEq, StructuralPartialEq
References: Axis, Order, Origin
enum Axis { Rows, Columns,}Whether consecutive indices run along a row or down a column.
Implements: Clone, Copy, Debug, Eq, PartialEq, StructuralPartialEq
enum Order { Progressive, Zigzag,}Whether alternate lines reverse direction.
Implements: Clone, Copy, Debug, Eq, PartialEq, StructuralPartialEq
Origin
Section titled “Origin”enum Origin { TopLeft, TopRight, BottomLeft, BottomRight,}Which corner holds index 0.
Implements: Clone, Copy, Debug, Eq, PartialEq, StructuralPartialEq