Giter VIP home page Giter VIP logo

mongoose-ws2812b's Introduction

mongoose-ws2812b

Mongoose OS driver for the WS2812B (aka NeoPixel) RGB LED strip.

Overview

This driver enables control of the WS2812B (aka NeoPixel) RGB LED strip on Mongoose OS.

Setup

  1. Copy the ws2812b directory into the firmware's src directory and add it to the sources section of mos.yml
  2. Include the header "ws2812b/ws2812b.h" in the appropriate places.

Usage

Initialization

The ws2812b struct represents an instance of an LED strip and once initialized is used for controlling the LEDs.

struct ws2812b strip = {
	// GPIO pin for the LED strip
	.pin = 0,
	// Total number of LEDs
	.count = 8,
	// Colour order of the LED: RGB, GRB, or BGR
	.order = WS2812B_ORDER_GRB
};

ws2812b_init(&strip);

Clearing the LED color (switching all LEDs off)

// Set each LED colour to 0 red, 0 green, 0 blue (off)
ws2812b_clear(&strip);

// Show the updated colours
ws2812b_show(&strip);

Setting the LED color

// LED number to set
uint16_t led = 0;

// RGB colour value
uint8_t r = 0xFF;
uint8_t g = 0xFF;
uint8_t b = 0xFF;

ws2812b_set_led(&strip, led, r, g, b);

// Refresh the LEDs
ws2812b_show(&strip);

Freeing

Once finished with the device, allocated memory for the data member of the ws2812b struct must be freed accordingly.

ws2812b_free(&strip);

mongoose-ws2812b's People

Contributors

ollieday avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.