Giter Club home page Giter Club logo

xcore_neopixel_leds's Introduction

#Driving NeoPixel LEDs from XMOS

###Please Note: You can find an XCore to Adafruit NeoPixel strip driver that is designed to be familiar to users of the Adafruit Arduino library here: https://github.com/teachop/xcore_neopixel_buffered

###Introduction This repo demonstrates rendering on-the-fly from XCore startKIT to the Adafruit NeoPixel strips. No pre-loaded RAM frame buffer required! It employs a two-task per strip approach to driving an Adafruit NeoPixel LED Strip, and is configured for 4 simultaneous independent strips. The source is in XC, an extension of C with concurrency and support for high speed timing synchronized I/O capability at the language level.

For a view of how XCore I/O works compare the driver code in neopixel_led_task() to some other NeoPixel waveform generator code. An example would be the Adafruit_NeoPixel::show() routine.

This particular code is able to do precise timing on AVR CPUs by employing cycle-counted assembly language that requires full attention of the CPU. In the XCore case outputs are handled by ports that precisely synchronize the outputs themselves.

This application is designed for and tested on the XMOS startKIT, but it should be possible to change the XMOS target in the makefile (alter "TARGET = STARTKIT").

This project demonstrates that the xCore is capable of generating color data on the fly without any buffering due to the concurrency and speed features of the xCore. Most actual applications, however, will want to generate color data into a compete frame/strip buffer ahead of the actual hardware output like this program does.

###xcore_neopixel_leds Two tasks make up the application, a pattern generator task and a driver task. These are exchanging data through a channel, which is a language and hardware communication feature. These two tasks are started in main using par. Main connects them together with a channel passed to the tasks.

The task communication uses "streaming channels" - their high performance is important in this application (see the wiki).

In the example, 4 sets of paired tasks execute in parallel, each pair driving its own NeoPixel strip pattern. While this is likely not the only or best approach (4 bit wide port?) it is easy and tests multi-tasking on the XCore chip.

Note that the driver tasks use extra test output pins for timing measurements. These were used to evaluate channels vs. streaming channels vs. interfaces for performance. The test outputs can be eliminated if desired.

####blinky_task

The pattern generator task presents a "wheel" rolling multi-color pattern on the RGB LEDs. This pattern code came from an Adafruit or PJRC source but I lost track which - both have some nice code for driving NeoPixels!

####neopixel_led_task

The driver task uses the timed port output feature of the xCore processors. This generates the serialized data pattern with the precise timing needed for the serial NeoPixel strip.

xcore_neopixel_leds's People

Contributors

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