ws281x.Net 1.0.6

A .Net Standard wrapper for the rxpi_ws281x library

Install-Package ws281x.Net -Version 1.0.6
dotnet add package ws281x.Net --version 1.0.6
<PackageReference Include="ws281x.Net" Version="1.0.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ws281x.Net --version 1.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

ws281x.Net

AppVeyor
NuGet

A .Net Standard 2.0 wrapper for the rpi_ws281x library for controlling WS281X LEDs on a Raspberry Pi. This library has been tested on a Raspberry Pi 3 B+.

Usage

This library adapts to the python wrapper of rpi_ws281x. The API is almost the same.

// Initialize a new instance of the wrapper
var neopixel = new ws281x.Net.Neopixel(ledCount: 42, pin: 18);

// You can also choose a custom color order
neopixel = new ws281x.Net.Neopixel(ledCount: 42, pin: 18, stripType: rpi_ws281x.WS2811_STRIP_RBG);

// Always initialize the wrapper first
neopixel.Begin();

// Set color of all LEDs to red
for (var i = 0; i < neopixel.GetNumberOfPixels(); i++)
{
    neopixel.SetPixelColor(i, System.Drawing.Color.Red);
}

// Apply changes to the led
neopixel.Show();

// Dispose after use
neopixel.Dispose();

The application has to be run in sudo mode to be able to access the GPIO pins.

Installation

As this is just a wrapper for a native library you have to put the native binary into the lib order of your Raspberry Pi (which should be /usr/local/lib in most cases).

Prebuild binary

Take the prebuild binary from src/ws281x.Net/Native/librpi_ws281x.so and copy it to the library path of your Pi.

Afterwards make sure to update the library links:

sudo ldconfig

Compile by yourself

Make sure gcc is installed on your Pi.

sudo apt-get install -y gcc

Copy all files from src/ws281x.Net/Native to a temporary build folder on your pi.

Compile the sources first:

gcc -c -fpic ws2811.c rpi_ws281x_wrap.c

Then link them to a library

gcc -shared ws2811.o rpi_ws281x_wrap.o -o librpi_ws281x.so

Copy the output library librpi_ws281x.so to your lib folder. Afterwards make sure to update the library links:

sudo ldconfig

Troubleshooting

ws2811_init failed with code -5 (mmap() failed)

Make sure you started your program is started with sudo. Afterwards check the connections to your LED strip.

Library rpi_ws281x is not found

This is the most annoying error as debugging is quite difficult. Ensure you placed the native library at the right place (usually /usr/local/lib), it is named librpi_ws281x.so and run sudo ldconfig to update the library links.

Projects

This projects are using ws281x.Net:

If you want your project to be added to this list just create an issue.

Building this library

The native interface is generated by swig. The wrapper classes are already created. If you change one of the native libraries or the wrapper interface rpi_ws281x.i you have to run swig -csharp rpi_ws281x.i and then copy the output C# classes to the Types folder.
Afterwards, a normal compile will do the job.

dotnet build -c Release

ws281x.Net

AppVeyor
NuGet

A .Net Standard 2.0 wrapper for the rpi_ws281x library for controlling WS281X LEDs on a Raspberry Pi. This library has been tested on a Raspberry Pi 3 B+.

Usage

This library adapts to the python wrapper of rpi_ws281x. The API is almost the same.

// Initialize a new instance of the wrapper
var neopixel = new ws281x.Net.Neopixel(ledCount: 42, pin: 18);

// You can also choose a custom color order
neopixel = new ws281x.Net.Neopixel(ledCount: 42, pin: 18, stripType: rpi_ws281x.WS2811_STRIP_RBG);

// Always initialize the wrapper first
neopixel.Begin();

// Set color of all LEDs to red
for (var i = 0; i < neopixel.GetNumberOfPixels(); i++)
{
    neopixel.SetPixelColor(i, System.Drawing.Color.Red);
}

// Apply changes to the led
neopixel.Show();

// Dispose after use
neopixel.Dispose();

The application has to be run in sudo mode to be able to access the GPIO pins.

Installation

As this is just a wrapper for a native library you have to put the native binary into the lib order of your Raspberry Pi (which should be /usr/local/lib in most cases).

Prebuild binary

Take the prebuild binary from src/ws281x.Net/Native/librpi_ws281x.so and copy it to the library path of your Pi.

Afterwards make sure to update the library links:

sudo ldconfig

Compile by yourself

Make sure gcc is installed on your Pi.

sudo apt-get install -y gcc

Copy all files from src/ws281x.Net/Native to a temporary build folder on your pi.

Compile the sources first:

gcc -c -fpic ws2811.c rpi_ws281x_wrap.c

Then link them to a library

gcc -shared ws2811.o rpi_ws281x_wrap.o -o librpi_ws281x.so

Copy the output library librpi_ws281x.so to your lib folder. Afterwards make sure to update the library links:

sudo ldconfig

Troubleshooting

ws2811_init failed with code -5 (mmap() failed)

Make sure you started your program is started with sudo. Afterwards check the connections to your LED strip.

Library rpi_ws281x is not found

This is the most annoying error as debugging is quite difficult. Ensure you placed the native library at the right place (usually /usr/local/lib), it is named librpi_ws281x.so and run sudo ldconfig to update the library links.

Projects

This projects are using ws281x.Net:

If you want your project to be added to this list just create an issue.

Building this library

The native interface is generated by swig. The wrapper classes are already created. If you change one of the native libraries or the wrapper interface rpi_ws281x.i you have to run swig -csharp rpi_ws281x.i and then copy the output C# classes to the Types folder.
Afterwards, a normal compile will do the job.

dotnet build -c Release

  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.6 608 9/8/2018
1.0.4 227 9/8/2018