All Projects → golemparts → blinkt

golemparts / blinkt

Licence: MIT license
A Rust library for the Pimoroni Blinkt!, and any similar APA102 or SK9822 LED strips or boards, on a Raspberry Pi.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to blinkt

rpi-ws2812-server
Raspberry Pi WS2812 (web) server tool
Stars: ✭ 143 (+694.44%)
Mutual labels:  apa102, sk9822
blinkt go
A Golang library for the Pimoroni Blinkt!
Stars: ✭ 24 (+33.33%)
Mutual labels:  raspberrypi, blinkt
WOWPixelDriver
A hardware based animation library,pixel driver & dynamic led mapping system for addressable LEDs
Stars: ✭ 39 (+116.67%)
Mutual labels:  apa102, sk9822
motor-hat
Node Module to control Adafruits MotorHAT for the RaspberryPi
Stars: ✭ 28 (+55.56%)
Mutual labels:  raspberrypi
wiringpi-tft-tool
TFT Command Line Tool for Raspberry Pi
Stars: ✭ 35 (+94.44%)
Mutual labels:  raspberrypi
Curio
A Blazing Fast HTTP Client
Stars: ✭ 35 (+94.44%)
Mutual labels:  rust-library
telnet-rs
A simple implementation of Telnet in Rust.
Stars: ✭ 35 (+94.44%)
Mutual labels:  rust-library
balena-plant-saver
We're building a plant monitor (and saver) - this is the early stage
Stars: ✭ 68 (+277.78%)
Mutual labels:  raspberrypi
genie-server
The home server version of Almond
Stars: ✭ 237 (+1216.67%)
Mutual labels:  raspberrypi
WebGPIO
A simple web UI for controlling the GPIO pins on a Raspberry Pi
Stars: ✭ 69 (+283.33%)
Mutual labels:  raspberrypi
kvmd
The main Pi-KVM daemon
Stars: ✭ 125 (+594.44%)
Mutual labels:  raspberrypi
Poke-Pi-Dex
Our deep learning for computer vision related project for nostalgic poke weebs (Sistemi digitali, Unibo).
Stars: ✭ 18 (+0%)
Mutual labels:  raspberrypi
rust-pkcs11
Rust PKCS#11 Library
Stars: ✭ 70 (+288.89%)
Mutual labels:  rust-library
enumset
A library for compact bit sets containing enums.
Stars: ✭ 60 (+233.33%)
Mutual labels:  rust-library
swarm-monitor
Monitor a Docker Swarm with Blinkt! LED
Stars: ✭ 48 (+166.67%)
Mutual labels:  blinkt
soap-rs
SOAP client for Rust programming language
Stars: ✭ 37 (+105.56%)
Mutual labels:  rust-library
Report-IP-hourly
📬 Report Linux IP by email hourly.
Stars: ✭ 43 (+138.89%)
Mutual labels:  raspberrypi
comi
ComiGO:Simple, cross-platform manga reader。简单、跨平台的漫画阅读器。シンプルな漫画リーダー。
Stars: ✭ 34 (+88.89%)
Mutual labels:  raspberrypi
Pigrow
Raspberry Pi Grow Box Control Software
Stars: ✭ 98 (+444.44%)
Mutual labels:  raspberrypi
Realtek-USB-Wireless-Adapter-Drivers
Realtek USB Wireless Adapter Drivers [0bda:f179] (Kernel 4.15.x ~ 5.9.x)
Stars: ✭ 34 (+88.89%)
Mutual labels:  raspberrypi

Blinkt

Build Status crates.io MIT licensed Minimum rustc version

Blinkt is a Rust library that provides an interface for the Pimoroni Blinkt!, and any similar APA102 or SK9822 LED strips or boards, on a Raspberry Pi. The library supports bitbanging mode on any GPIO pins, and hardware SPI mode on GPIO 10 (physical pin 19) for data, and GPIO 11 (physical pin 23) for clock.

For bitbanging mode, Blinkt gains access to the BCM283x GPIO peripheral either through /dev/gpiomem or /dev/mem. Hardware SPI mode is controlled through /dev/spidev0.0.

Both the original APA102 and the SK9822 clone are supported. The RGB LED/driver ICs are referred to as pixels throughout the code and documentation.

Backwards compatibility for minor revisions isn't guaranteed until the library reaches v1.0.0.

Blinkt is under active development on the master branch of the repository on GitHub. If you're looking for the README.md or the examples directory for the latest release or any of the earlier releases, visit crates.io, download an archived release from the GitHub releases page, or clone and checkout the relevant release tag.

Documentation

Online documentation is available for the latest release, older releases, and the version currently in development.

Usage

Add a dependency for blinkt to your Cargo.toml.

[dependencies]
blinkt = "0.6.0"

Call Blinkt::new() to create a new Blinkt with the default settings. Alternative configuration options are available through Blinkt::with_settings() and Blinkt::with_spi().

use blinkt::Blinkt;

let mut blinkt = Blinkt::new()?;

Examples

The example below demonstrates swapping all pixels on a Blinkt! board between red, green and blue.

use std::error::Error;
use std::time::Duration;
use std::{mem, thread};

use blinkt::Blinkt;

fn main() -> Result<(), Box<dyn Error>> {
    let mut blinkt = Blinkt::new()?;
    let (red, green, blue) = (&mut 255, &mut 0, &mut 0);

    loop {
        blinkt.set_all_pixels(*red, *green, *blue);
        blinkt.show()?;

        thread::sleep(Duration::from_millis(250));

        mem::swap(red, green);
        mem::swap(red, blue);
    }
}

To control an LED strip consisting of 144 pixels, connected to the Raspberry Pi's hardware SPI pins (data on GPIO 10 (physical pin 19), and clock on GPIO 11 (physical pin 23)), at 16 MHz clock speed, replace the Blinkt::new() line in the above example with the following. You may have to tweak the maximum clock speed based on the number of pixels and the wire quality.

let mut blinkt = Blinkt::with_spi(16_000_000, 144)?;

Additional examples can be found in the examples directory.

Cross compilation

If you're not working directly on a Raspberry Pi, you'll have to cross-compile your code for the appropriate ARM architecture. Check out this guide for more information, or try the cross project for "zero setup" cross compilation.

Cargo

While additional steps may be necessary to cross-compile binaries on your platform, checking your code with cargo check only requires the installation of an appropriate target. Most Raspberry Pi models need the armv7-unknown-linux-gnueabihf target. For some models, like the Raspberry Pi Zero, a different target triple is required.

Install the relevant target using rustup.

rustup target install armv7-unknown-linux-gnueabihf

In the root directory of your project, create a .cargo subdirectory, and then save the following snippet to .cargo/config.

[build]
target = "armv7-unknown-linux-gnueabihf"

RLS

RLS needs to be made aware of the target platform by setting the rust.target configuration option. The location of this option is IDE-specific.

Visual Studio Code

In the root directory of your project, create a .vscode subdirectory, and then save the following snippet to .vscode/settings.json.

{
    "rust.target": "armv7-unknown-linux-gnueabihf"
}

Copyright and license

Copyright (c) 2016-2021 Rene van der Meer. Released under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].