MCPcopy Index your code
hub / github.com/ahdinosaur/blinksy

github.com/ahdinosaur/blinksy @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
325 symbols 516 edges 68 files 161 documented · 50%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Blinksy simulation of 2D grid with noise pattern

Blinksy 🟥🟩🟦

A Rust no-std no-alloc LED control library.

For 1D, 2D, and 3D layouts.

Inspired by FastLED and WLED.

GitHub Repo stars GitHub Sponsors Chat License

How Blinksy works

  • Define your LED layout in 1D, 2D, or 3D space
  • Create your visual pattern (effect), or choose from our built-in patterns library
  • The pattern will compute colors for each LED based on its position in space
  • Setup a [driver] to send each frame of colors to your [leds]

Features

  • No-std, no-alloc: Designed for embedded targets.
  • Spatial in 1D, 2D, or 3D: Map out the shape of your LEDs in space.
  • Async support: Supports blocking or asynchronous execution.
  • Full color support: Supports modern and classic color spaces.
  • Global settings: Control overall brightness and color correction.
  • Desktop simulation: Simulate your LEDs on your desktop to play with ideas.
  • RGB+W support: Supports RGB + White color channels

LED Support

Clockless: One-wire (only data, no clock)

Clocked: Two-wire (data and clock)

  • APA102: High-FPS RGB LED, aka DotStar

If you want help to support a new LED chipset, make an issue!

Pattern (Effect) Library:

  • Rainbow: A basic scrolling rainbow
  • Noise: A flow through random noise functions

If you want help to port a pattern from FastLED / WLED to Rust, make an issue!

Microcontroller Family Support

Clocked LED support (e.g. APA102):

Micro HAL Blinksy Recommended Driver Backup Driver
ALL embedded-hal blinksy Spi Delay

Clockless LED support (e.g. WS2812)

Micro HAL Blinksy Recommended Driver Backup Driver
ALL embedded-hal blinksy - TODO Spi #12
ESP32 esp-hal blinksy-esp Rmt -
RP (2040 or 2350) rp-hal TODO TODO #36 -
STM32 stm32-hal TODO TODO #78 -
nRF nrf-hal TODO TODO #77 -
atsamd atsamd TODO TODO #67 -
AVR (Arduino) avr-hal TODO TODO #79 -
CH32 ch32-hal TODO TODO #80 -
??? - - - -

If you want help to support a new microcontroller family, make an issue!

Board Support

These are ready-to-go LED controllers with board support crates to make things even easier:

If you want help to support a new target, make an issue!

Quick Start

To quickstart a project, see:

To start using the library, see control.

Modules

CI status

Examples

For all examples, see:

Embedded Gledopto: 3D Cube with Noise Pattern

https://github.com/user-attachments/assets/36a2c6ad-7ae6-4498-85b3-ed76d0b62264

Click to see code
#![no_std]
#![no_main]

use blinksy::{
    layout::{Layout3d, Shape3d, Vec3},
    layout3d,
    leds::Ws2812,
    patterns::noise::{noise_fns, Noise3d, NoiseParams},
    ControlBuilder,
};
use gledopto::{board, bootloader, elapsed, main, ws2812};

bootloader!();

#[main]
fn main() -> ! {
    let p = board!();

    layout3d!(
        Layout,
        [
            // bottom face
            Shape3d::Grid {
                start: Vec3::new(1., -1., 1.),           // right bottom front
                horizontal_end: Vec3::new(-1., -1., 1.), // left bottom front
                vertical_end: Vec3::new(1., -1., -1.),   // right bottom back
                horizontal_pixel_count: 16,
                vertical_pixel_count: 16,
                serpentine: true,
            },
            // back face
            Shape3d::Grid {
                start: Vec3::new(-1., -1., -1.),         // left bottom back
                horizontal_end: Vec3::new(-1., 1., -1.), // left top back
                vertical_end: Vec3::new(1., -1., -1.),   // right bottom back
                horizontal_pixel_count: 16,
                vertical_pixel_count: 16,
                serpentine: true,
            },
            // right face
            Shape3d::Grid {
                start: Vec3::new(1., 1., -1.),         // right top back
                horizontal_end: Vec3::new(1., 1., 1.), // right top front
                vertical_end: Vec3::new(1., -1., -1.), // right bottom back
                horizontal_pixel_count: 16,
                vertical_pixel_count: 16,
                serpentine: true,
            },
            // front face
            Shape3d::Grid {
                start: Vec3::new(-1., -1., 1.),         // left bottom front
                horizontal_end: Vec3::new(1., -1., 1.), // right bottom front
                vertical_end: Vec3::new(-1., 1., 1.),   // left top front
                horizontal_pixel_count: 16,
                vertical_pixel_count: 16,
                serpentine: true,
            },
            // left face
            Shape3d::Grid {
                start: Vec3::new(-1., 1., -1.),           // left top back
                horizontal_end: Vec3::new(-1., -1., -1.), // left bottom back
                vertical_end: Vec3::new(-1., 1., 1.),     // left top front
                horizontal_pixel_count: 16,
                vertical_pixel_count: 16,
                serpentine: true,
            },
            // top face
            Shape3d::Grid {
                start: Vec3::new(1., 1., 1.),           // right top front
                horizontal_end: Vec3::new(1., 1., -1.), // right top back
                vertical_end: Vec3::new(-1., 1., 1.),   // left top front
                horizontal_pixel_count: 16,
                vertical_pixel_count: 16,
                serpentine: true,
            }
        ]
    );

    let mut control = ControlBuilder::new_3d()
        .with_layout::<Layout, { Layout::PIXEL_COUNT }>()
        .with_pattern::<Noise3d<noise_fns::Perlin>>(NoiseParams {
            ..Default::default()
        })
        .with_driver(ws2812!(p, Layout::PIXEL_COUNT))
        .with_frame_buffer_size::<{ Ws2812::frame_buffer_size(Layout::PIXEL_COUNT) }>()
        .build();

    control.set_brightness(0.2);

    loop {
        let elapsed_in_ms = elapsed().as_millis();
        control.tick(elapsed_in_ms).unwrap();
    }
}

Desktop Simulation: 2D Grid with Noise Pattern

https://github.com/user-attachments/assets/22f388d0-189e-44bd-acbf-186a142b956d

Click to see code

```rust use blinksy::{ layout::{Layout2d, Shape2d, Vec2}, layout2d, patterns::noise::{noise_fns, Noise2d, NoiseParams}, ControlBuilder, }; use blinksy_desktop::{ driver::{Desktop, DesktopError}, time::elapsed_in_ms, }; use std::{thread::sleep, time::Duration};

layout2d!( PanelLayout, [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, }] );

fn main() { Desktop::new_2d::().start(|driver| { let mut control = ControlBuilder::new_2d() .with_layout::() .with_pattern::>(NoiseParams { ..Default::default() })

Extension points exported contracts — how you extend this code

Pattern (Interface)
Trait for creating visual effects on LED layouts. Patterns generate colors for each LED in a layout based on time and p [6 …
blinksy/src/pattern.rs
FromColor (Interface)
Trait for converting from another color type [9 implementers]
blinksy/src/color/convert.rs
LayoutForDim (Interface)
Trait for associating layout types with dimension markers. This trait creates the relationship between a layout type an [3 …
blinksy/src/layout/mod.rs
Layout3d (Interface)
Trait for three-dimensional LED layouts. Implementors of this trait represent a 3D arrangement of LEDs using one or mor [3 …
blinksy/src/layout/layout3d.rs
Driver (Interface)
Core trait for all blocking LED drivers. This trait defines the common interface for sending color data to LED hardware [3 …
blinksy/src/driver/mod.rs

Core symbols most depended-on inside this repo

tick
called by 16
blinksy/src/control.rs
with_driver
called by 15
blinksy/src/control.rs
map
called by 12
blinksy-desktop/examples/3d-cube-volume-noise.rs
into_iter
called by 10
blinksy/src/color/led.rs
build
called by 9
esp/blinksy-esp/src/rmt.rs
set_brightness
called by 8
blinksy/src/control.rs
elapsed
called by 8
esp/blinksy-esp/src/time.rs
build
called by 7
blinksy/src/control.rs

Shape

Method 196
Class 60
Function 37
Interface 18
Enum 14

Languages

Rust100%

Modules by API surface

blinksy-desktop/src/driver.rs60 symbols
esp/blinksy-esp/src/rmt.rs17 symbols
blinksy/src/control.rs17 symbols
blinksy/src/color/led.rs14 symbols
blinksy/src/leds/apa102.rs11 symbols
blinksy/src/driver/clockless/mod.rs11 symbols
blinksy/src/driver/clocked/delay.rs11 symbols
blinksy/src/color/hsv.rs11 symbols
blinksy/src/driver/clocked/mod.rs10 symbols
blinksy/src/driver/clockless/delay.rs9 symbols
blinksy/src/util/bits.rs8 symbols
blinksy/src/layout/layout3d.rs8 symbols

For agents

$ claude mcp add blinksy \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact