Reconsidered input pin and NC pin for SPI. Modified several functions interface and its contents.
Dependents: WS2812_out_of_specification_demo
WS2812.h@3:d56ffdf7beeb, 2014-08-04 (annotated)
- Committer:
- chris
- Date:
- Mon Aug 04 16:22:40 2014 +0000
- Revision:
- 3:d56ffdf7beeb
- Parent:
- 2:fa7ac5632be4
- Child:
- 4:b230e85fc5e7
renamed "update" to "write"
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chris | 0:be22a9d4df5f | 1 | /* Copyright (c) 2012 cstyles, MIT License |
chris | 0:be22a9d4df5f | 2 | * |
chris | 0:be22a9d4df5f | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
chris | 0:be22a9d4df5f | 4 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
chris | 0:be22a9d4df5f | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
chris | 0:be22a9d4df5f | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
chris | 0:be22a9d4df5f | 7 | * furnished to do so, subject to the following conditions: |
chris | 0:be22a9d4df5f | 8 | * |
chris | 0:be22a9d4df5f | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
chris | 0:be22a9d4df5f | 10 | * substantial portions of the Software. |
chris | 0:be22a9d4df5f | 11 | * |
chris | 0:be22a9d4df5f | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
chris | 0:be22a9d4df5f | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
chris | 0:be22a9d4df5f | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
chris | 0:be22a9d4df5f | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
chris | 0:be22a9d4df5f | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
chris | 0:be22a9d4df5f | 17 | */ |
chris | 0:be22a9d4df5f | 18 | |
chris | 0:be22a9d4df5f | 19 | #ifndef WS2812_H |
chris | 0:be22a9d4df5f | 20 | #define WS2812_H |
chris | 0:be22a9d4df5f | 21 | |
chris | 0:be22a9d4df5f | 22 | #include "mbed.h" |
chris | 0:be22a9d4df5f | 23 | |
chris | 0:be22a9d4df5f | 24 | #define WS1 0x38 |
chris | 0:be22a9d4df5f | 25 | #define WS0 0x30 |
chris | 0:be22a9d4df5f | 26 | #define SPICLK 5000000 |
chris | 0:be22a9d4df5f | 27 | #define SPIBPF 6 |
chris | 0:be22a9d4df5f | 28 | |
chris | 2:fa7ac5632be4 | 29 | // alternate settings for potential higher resoltion |
chris | 1:c278c3d136bb | 30 | //#define WS1 0xfc0 |
chris | 1:c278c3d136bb | 31 | //#define WS0 0xf00 |
chris | 1:c278c3d136bb | 32 | //#define SPICLK 10000000 |
chris | 1:c278c3d136bb | 33 | //#define SPIBPF 12 |
chris | 1:c278c3d136bb | 34 | |
chris | 1:c278c3d136bb | 35 | |
chris | 1:c278c3d136bb | 36 | |
chris | 0:be22a9d4df5f | 37 | //!Library for the WS2812 RGB LED with integrated controller |
chris | 0:be22a9d4df5f | 38 | /*! |
chris | 0:be22a9d4df5f | 39 | The WS2812 is controller that is built into a range of LEDs |
chris | 0:be22a9d4df5f | 40 | */ |
chris | 0:be22a9d4df5f | 41 | class WS2812 |
chris | 0:be22a9d4df5f | 42 | { |
chris | 0:be22a9d4df5f | 43 | public: |
chris | 0:be22a9d4df5f | 44 | //!Creates an instance of the class. |
chris | 0:be22a9d4df5f | 45 | /*! |
chris | 0:be22a9d4df5f | 46 | Connect WS2812 address addr using SPI MOSI pins |
chris | 0:be22a9d4df5f | 47 | */ |
chris | 0:be22a9d4df5f | 48 | WS2812(PinName d, int size); |
chris | 0:be22a9d4df5f | 49 | |
chris | 0:be22a9d4df5f | 50 | /*! |
chris | 0:be22a9d4df5f | 51 | Destroys instance. |
chris | 0:be22a9d4df5f | 52 | */ |
chris | 0:be22a9d4df5f | 53 | ~WS2812(); |
chris | 0:be22a9d4df5f | 54 | |
chris | 0:be22a9d4df5f | 55 | //!Reads the current temperature. |
chris | 0:be22a9d4df5f | 56 | /*! |
chris | 0:be22a9d4df5f | 57 | Reads the temperature register of the LM75B and converts it to a useable value. |
chris | 0:be22a9d4df5f | 58 | */ |
chris | 3:d56ffdf7beeb | 59 | void write (int buf[]); |
chris | 0:be22a9d4df5f | 60 | void setAll (int color); |
chris | 0:be22a9d4df5f | 61 | void useII (int d); |
chris | 0:be22a9d4df5f | 62 | void setII (unsigned char d); |
chris | 0:be22a9d4df5f | 63 | |
chris | 0:be22a9d4df5f | 64 | |
chris | 0:be22a9d4df5f | 65 | private: |
chris | 0:be22a9d4df5f | 66 | |
chris | 0:be22a9d4df5f | 67 | int __size; |
chris | 0:be22a9d4df5f | 68 | unsigned char __II; |
chris | 0:be22a9d4df5f | 69 | int __use_II; |
chris | 0:be22a9d4df5f | 70 | SPI __spi; |
chris | 0:be22a9d4df5f | 71 | |
chris | 0:be22a9d4df5f | 72 | void __write (int color); |
chris | 0:be22a9d4df5f | 73 | |
chris | 0:be22a9d4df5f | 74 | |
chris | 0:be22a9d4df5f | 75 | }; |
chris | 0:be22a9d4df5f | 76 | |
chris | 0:be22a9d4df5f | 77 | #endif |