RGB Pixel Array with rendering features. Designed to be used with WS2812 library

Dependents:   ChrisRGB-Ring ChrisRGB-Ring WS2812_Example WS2812_Example_fade ... more

Committer:
chris
Date:
Wed Aug 13 20:26:32 2014 +0000
Revision:
2:b45a70faaa83
Parent:
1:41b9f8ec0b6a
Added a call in the constructor to clear the memory before its used

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chris 0:bdce2379bd67 1 /* Copyright (c) 2012 cstyles, MIT License
chris 0:bdce2379bd67 2 *
chris 0:bdce2379bd67 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
chris 0:bdce2379bd67 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
chris 0:bdce2379bd67 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
chris 0:bdce2379bd67 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
chris 0:bdce2379bd67 7 * furnished to do so, subject to the following conditions:
chris 0:bdce2379bd67 8 *
chris 0:bdce2379bd67 9 * The above copyright notice and this permission notice shall be included in all copies or
chris 0:bdce2379bd67 10 * substantial portions of the Software.
chris 0:bdce2379bd67 11 *
chris 0:bdce2379bd67 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
chris 0:bdce2379bd67 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
chris 0:bdce2379bd67 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
chris 0:bdce2379bd67 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
chris 0:bdce2379bd67 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
chris 0:bdce2379bd67 17 */
chris 0:bdce2379bd67 18
chris 0:bdce2379bd67 19 #ifndef PixelArray_H
chris 0:bdce2379bd67 20 #define PixelArray_H
chris 0:bdce2379bd67 21
chris 0:bdce2379bd67 22 #include "mbed.h"
chris 0:bdce2379bd67 23
chris 0:bdce2379bd67 24 //!Library for the WS2812 RGB LED with integrated controller
chris 0:bdce2379bd67 25 /*!
chris 0:bdce2379bd67 26 PixelArray
chris 0:bdce2379bd67 27 */
chris 0:bdce2379bd67 28 class PixelArray
chris 0:bdce2379bd67 29 {
chris 0:bdce2379bd67 30 public:
chris 0:bdce2379bd67 31 //!Creates an instance of the class.
chris 0:bdce2379bd67 32 /*!
chris 0:bdce2379bd67 33 Pixel Array
chris 0:bdce2379bd67 34 */
chris 0:bdce2379bd67 35 PixelArray(int);
chris 0:bdce2379bd67 36
chris 0:bdce2379bd67 37 /*!
chris 0:bdce2379bd67 38 Destroys instance.
chris 0:bdce2379bd67 39 */
chris 0:bdce2379bd67 40 ~PixelArray();
chris 0:bdce2379bd67 41
chris 0:bdce2379bd67 42 int* getBuf();
chris 0:bdce2379bd67 43
chris 0:bdce2379bd67 44 void SetAll(unsigned int);
chris 0:bdce2379bd67 45 void SetAllI(unsigned char);
chris 0:bdce2379bd67 46 void SetAllR(unsigned char);
chris 0:bdce2379bd67 47 void SetAllG(unsigned char);
chris 0:bdce2379bd67 48 void SetAllB(unsigned char);
chris 0:bdce2379bd67 49
chris 0:bdce2379bd67 50 // location, value
chris 0:bdce2379bd67 51 void Set(int, unsigned int);
chris 0:bdce2379bd67 52 void SetI(int, unsigned char);
chris 0:bdce2379bd67 53 void SetR(int, unsigned char);
chris 0:bdce2379bd67 54 void SetG(int, unsigned char);
chris 0:bdce2379bd67 55 void SetB(int, unsigned char);
chris 0:bdce2379bd67 56
chris 0:bdce2379bd67 57 private:
chris 0:bdce2379bd67 58
chris 1:41b9f8ec0b6a 59 int *pbuf;
chris 1:41b9f8ec0b6a 60 int pbufsize;
chris 0:bdce2379bd67 61
chris 0:bdce2379bd67 62 void __set_pixel_component(int index, int channel, int value);
chris 0:bdce2379bd67 63 void __set_pixel(int index, int value);
chris 0:bdce2379bd67 64
chris 0:bdce2379bd67 65 };
chris 0:bdce2379bd67 66
chris 0:bdce2379bd67 67 #endif
chris 0:bdce2379bd67 68