But I thought it would be nice if we can represent each NeoPixel as a class object named NeoPixel, with three values that represent the R G and B color intensities. I used overloads so you can create an instance of NeoPixel using many data types.
I then created another class that organizes a chain of NeoPixels, named it "NeoPixelChain". It inherits from a generic list interface, so you can access it as it was an array of NeoPixels. You can then call "Write" on the entire chain, and the byte sequence will be automatically rearranged into the GRB sequence that the WS2812 expects, then sent out of the output pin using our native function.
(note: this is just to illustrate "inheritance", which is a feature of object oriented programming languages such as C#, Java, C++, and many more)
I also wrote a few more wrapper functions under the class name "NeoPixelWriter". The most impressive one can directly draw a bitmap image directly onto a grid of NeoPixels (such as the NeoPixel 8x8)
(note: NeoPixelWriter makes heavy use of "overloading")
(note: although "NeoPixelWriter" has the word "Writer" in it, it is does not inherit from "Stream" or even resemble "Stream" at all, sorry about that)
Remember, on the Netduino, you can easily load a bitmap from a SD card or download from the network, or draw one during runtime using graphic functions. Have fun with this one!
All the files are provided on the download page, see the navigation panel.
All documentation about the API is done within the code, which means Visual Studio can automatically show you the documentation when:
- you use "Intellisense" (aka autocomplete)
- use "Object Browser"
Below is a class diagram of my "NeoPixel" namespace.