Giter Club home page Giter Club logo

rpi-ws281x-csharp's Introduction

Nuget Framework License Nuget

rpi-ws281x-csharp

This fork contains the following changes:

Please review latest Release Notes for most recent changes.

This is a C# wrapper for the great C assembly by Jeremy Garff to control WS281X LEDs by a Raspberry PI (https://github.com/jgarff/rpi_ws281x). It uses the P/Invoke calls to access the native assembly.

Usage

It is very easy to use the wrapper in your own C# / .NET project. Just see the example below:

//The default settings uses a frequency of 800000 Hz and the DMA channel 10.
var settings = Settings.CreateDefaultSettings();

//Use 16 LEDs and GPIO Pin 18.
//Set brightness to maximum (255)
//Use Unknown as strip type. Then the type will be set in the native assembly.
var controller = settings.AddController(16, Pin.Gpio18, StripType.WS2812_STRIP, ControllerType.PWM0, 255, false)

using (var rpi = new WS281x(settings))
{
  //Set the color of the first LED of controller 0 to blue
  controller.SetLED(0, Color.Blue);
  //Set the color of the second LED of controller 0 to red
  controller.SetLED(1, Color.Red);
  rpi.Render();
}

Please have a look at the example program and get familiar with the usage.

Installation

The library can be downloaded from NuGet: Nuget

Package Manager

PM> Install-Package kenssamson.rpi-ws281x-csharp

.NET CLI

> dotnet add package kenssamson.rpi-ws281x-csharp

In order to get the wrapper working, you need build the shared C library first. Please refer to the README in the lib folder for more information.

The P/Invoke functionality has a special search pattern to find the required assembly. For my tests, I copied the ws2811.so assembly to /usr/lib folder (as suggested by the link above).

Test status

The wrapper was tested with following setup:

Raspberry model Controller GPIO Pin DMA channel Result
Model B Rev 2 WS2812B 18 5, 10 Success

Please feel free to add some more test cases.

rpi-ws281x-csharp's People

Contributors

kenssamson avatar urmel11 avatar dgorbach avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.