Go bindings for Raspberry Pi PWM library for WS281X LEDs

go-rpi-ws281x GoDoc

golang binding for rpi_ws281x, userspace Raspberry Pi PWM library for WS281X LEDs. Supports any Raspberry and WS2812, SK6812RGB and SK6812RGBW LEDs strips, this includes Unicorn pHAT and NeoPixels

Installation

The recommended way to install go-rpi-ws281x is:

go get github.com/mcuadros/go-rpi-ws281x
cd $GOPATH/src/github.com/mcuadros/go-rpi-ws281x/vendor/rpi_ws281x
scons

Requires having install golang and scons (on raspbian, apt-get install scons).

Examples

// create a new canvas with the given width and height, and the config, in this
// case the configuration is for a Unicorn pHAT (8x4 pixels matrix) with the
// default configuration
c, _ := ws281x.NewCanvas(8, 4, &ws281x.DefaultConfig)


// initialize the canvas and the matrix
c.Initialize()

// since ws281x implements image.Image any function like draw.Draw from the std
// library may be used with it.
// 
// now we copy a white image into the ws281x.Canvas, this turn on all the leds
// to white
draw.Draw(c, c.Bounds(), image.NewUniform(color.White), image.ZP, draw.Over)

// render and sleep to see the leds on
c.Render()
time.Sleep(time.Second * 5)

// don't forget close the canvas, if not you leds may remain on
c.Close()

Check the folder examples folder for more examples

License

MIT, see LICENSE

Similar Resources

Automated configuration documentation library for Go Projects.

Cato Cato is an automated documentation generation library for Go Projects. Through the use of custom tags for struct fields, Cato can extract informa

Aug 28, 2020

Gohalt 👮‍♀🛑: Fast; Simple; Powerful; Go Throttler library

Gohalt 👮‍♀🛑: Fast; Simple; Powerful; Go Throttler library

Gohalt 👮‍♀ 🛑 : Fast; Simple; Powerful; Go Throttler library go get -u github.com/1pkg/gohalt Introduction Gohalt is simple and convenient yet powerf

Nov 27, 2022

A K8s ClusterIP HTTP monitoring library based on eBPF

Owlk8s Seamless RED monitoring of k8s ClusterIP HTTP services. This library provides RED (rate,error,duration) monitoring for all(by default but exclu

Jun 16, 2022

library to make building things with bitclout easy

cloutcli library to make building things with bitclout easy quick start demo cmd $ ./clout demo clout demo visualizegraph # make clout.gv graph fi

Jul 27, 2022

A Go library for the Linux Landlock sandboxing feature

Go landlock library The Go landlock library provides an interface to Linux 5.13's Landlock kernel sandboxing features. The library provides access to

Dec 27, 2022

A simple and flexible health check library for Go.

Health A simple and flexible health check library for Go. Documentation · Report Bug · Request Feature Table of Contents Getting started Synchronous v

Jan 4, 2023

The DGL Operator makes it easy to run Deep Graph Library (DGL) graph neural network training on Kubernetes

DGL Operator The DGL Operator makes it easy to run Deep Graph Library (DGL) graph neural network distributed or non-distributed training on Kubernetes

Dec 19, 2022

The k8s-generic-webhook is a library to simplify the implementation of webhooks for arbitrary customer resources (CR) in the operator-sdk or controller-runtime.

k8s-generic-webhook The k8s-generic-webhook is a library to simplify the implementation of webhooks for arbitrary customer resources (CR) in the opera

Nov 24, 2022

ghcr images - Fetched from docker-library

ghcri ghcri is the repo for Github Container Registry Images. Just like docker-library for Docker Registry. Usage Replace all docker library from dock

Aug 15, 2022
Comments
  • Support Fixes

    Support Fixes

    Fixed:

    • Brightness data type changed at some point, so I've changed it.
    • Defaulting to DMA Channel 5 it not very good idea, since on RPi 3 it causes file system corruption issue. I've changed default channel to 10, since for now it's considered safe.
  • No such file or directory: ws2811.h

    No such file or directory: ws2811.h

    Hey @mcuadros, I'm trying to use your module to get my led matrix attached to a rpi zero w running with golang.

    Unfortunatly I run into this error when I run go get github.com/mcuadros/go-rpi-ws281x:

    # github.com/mcuadros/go-rpi-ws281x
    ../go/pkg/mod/github.com/mcuadros/[email protected]/matrix.go:8:10: fatal error: ws2811.h: No such file or directory
     #include <ws2811.h>
              ^~~~~~~~~~
    compilation terminated.
    

    golang and scons are installed.

    Would be nice if you could push me in the right direction to solve this issue. 👍

Network scanner for Raspberry Pi
Network scanner for Raspberry Pi

╔═╗╦═╗╔═╗╦ ╠═╣╠╦╝╠═╝║ ╩ ╩╩╚═╩ ╩ Basic network scanner for Raspberry Pi Install Note: Prebuilt binaries (32-bit) doesn't require Go. Prereq

Jun 13, 2022
Raspberry Pi Archlinux Automated Offline Installer with Wi-Fi. Windows, Mac and more features coming.
Raspberry Pi Archlinux Automated Offline Installer with Wi-Fi. Windows, Mac and more features coming.

Raspberry Pi Archlinux Automated Installer with Wi-Fi. Windows, Mac and more features coming. Download Go to releases page and download the zip file f

Nov 22, 2022
[WIP] Cheap, portable and secure NAS based on the Raspberry Pi Zero - with encryption, backups, and more

PortaDisk - Affordable Raspberry Pi Portable & Secure NAS Project Project Status: Early work in progress. web-unlock is still not ready for production

Nov 23, 2022
Turn your Go program(s) into an appliance running on the Raspberry Pi 3 or 4 (or on amd64 PCs!)

Overview gokrazy packs your Go application(s) into an SD card image for the Raspberry Pi 3 or 4 which — aside from the Linux kernel and proprietary Ra

Jan 3, 2023
Serves images taken on a FLIR Lepton connected to a Raspberry Pi SPI port to over HTTP.

go-lepton Streams images taken on a FLIR Lepton connected to a Raspberry Pi SPI port to over via WebSockets via embedded HTTP server. It sends the raw

Oct 29, 2022
Capture the stream of Images for a Raspberry Pi Camera in GoLang

piCamera This package is a wrapper for the raspivid command on the Raspberry Pi. To make development easier on a PC, there is are different Start() me

Mar 5, 2022
HTTP load testing tool and library. It's over 9000!
HTTP load testing tool and library. It's over 9000!

Vegeta Vegeta is a versatile HTTP load testing tool built out of a need to drill HTTP services with a constant request rate. It can be used both as a

Dec 30, 2022
Go library to create resilient feedback loop/control controllers.

Gontroller A Go library to create feedback loop/control controllers, or in other words... a Go library to create controllers without Kubernetes resour

Jan 1, 2023
Orchestra is a library to manage long running go processes.

Orchestra Orchestra is a library to manage long running go processes. At the heart of the library is an interface called Player // Player is a long ru

Oct 21, 2022
Testcontainers is a Golang library that providing a friendly API to run Docker container. It is designed to create runtime environment to use during your automatic tests.

When I was working on a Zipkin PR I discovered a nice Java library called Testcontainers. It provides an easy and clean API over the go docker sdk to

Jan 7, 2023