Skip to content

Rings241Layout

Source: Rings241Layout.h

Rings241Layout

class Rings241Layout
src/light/layouts/Rings241Layout.h:34

Inherits: LayoutBase

Layout of the 241-LED concentric-rings disc.

Author: MoonLight, https://github.com/ewowi/MoonLight/blob/main/src/MoonLight/Nodes/Layouts/L_MoonLight.h

Public Attributes

uint8_t scale = 2 : Scales both the ring radii and the shared center.

bool outside_in = false : Clear puts light 0 at the center with rings outward, set reverses that.

uint16_t angleFirst = 0 : Where light 0 of each ring sits, in degrees from the bottom.

Public Methods

virtual inline const char * tags() const override : The catalog tags this layout carries.

virtual inline Dim dimensions() const override : How many axes this layout places lights on.

virtual inline void defineControls() override : The controls a user sets on the card.

virtual inline nrOfLightsType lightCount() const override : How many lights the current settings place.

virtual inline void placeLights(const CoordSink & sink) const override : Emit every light's coordinate, in wiring order.

More info

The classic 241-LED concentric-ring disc: nine full circles sharing one center, with ring LED counts 1, 8, 12, 16, 24, 32, 40, 48, 60 (sum 241).

Prior art: MoonLight's Rings241Layout, which composes MoonLight's RingLayout once per ring. RingLayout places n LEDs evenly on a circle of radius n / (2π), starting at the bottom (angleRad = π at i=0) and stepping by 2π/n. This port reproduces that exact per-LED math but emits coordinates only. MoonLight's pin/wiring plumbing (doNextPin/nextPin, and RingLayout's angleFirst/rotation/clockwise/nrOfLEDs UI controls) has no place here, since a MoonLight layout hands positions to the driver and the driver owns pins. The one geometry control that survives is scale, RingLayout's spacing multiplier. Every ring is a full circle (MoonLight's rotation = 360), so every LED is emitted; that makes [lightCount()] the fixed constant 241.

The outside-in control is ours, not MoonLight's

outside in is ours, not MoonLight's: it names which end of the wire is light 0. A disc is soldered either from the center LED outward (MoonLight's order, the default) or from the outer 60-LED ring inward. A layout that only knew one of them would light the wrong ring for the other. Only the ring SEQUENCE flips; the direction around each ring stays as wired.

Precision is reproduced statement-for-statement, because the disc's integer coordinates depend on it. MoonLight forms angleRad from the double macros PI / TWO_PI, stores it in a float, then takes float sinf/cosf and multiplies a float radius. Doing the angle wholly in float, or wholly in double, shifts a ring point landing exactly on an integer axis to the wrong side of the truncation. Either way it differs from the source by one unit. The faithful path is MoonLight's own: form the angle in double → narrow to float → float trig → float radius.