Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
WS2812.h
00001 /* Copyright (c) 2012 cstyles, MIT License 00002 * 00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00004 * and associated documentation files (the "Software"), to deal in the Software without restriction, 00005 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 00006 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00007 * furnished to do so, subject to the following conditions: 00008 * 00009 * The above copyright notice and this permission notice shall be included in all copies or 00010 * substantial portions of the Software. 00011 * 00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00017 */ 00018 00019 #ifndef WS2812_H 00020 #define WS2812_H 00021 00022 #include "mbed.h" 00023 00024 #define WS1 0x38 00025 #define WS0 0x30 00026 #define SPICLK 5000000 00027 #define SPIBPF 6 00028 00029 00030 //!Library for the WS2812 RGB LED with integrated controller 00031 /*! 00032 The WS2812 is controller that is built into a range of LEDs 00033 */ 00034 class WS2812 00035 { 00036 public: 00037 //!Creates an instance of the class. 00038 /*! 00039 Connect WS2812 address addr using SPI MOSI pins 00040 */ 00041 WS2812(PinName d, int size); 00042 00043 /*! 00044 Destroys instance. 00045 */ 00046 ~WS2812 (); 00047 00048 //!Reads the current temperature. 00049 /*! 00050 Reads the temperature register of the LM75B and converts it to a useable value. 00051 */ 00052 void write (int buf[]); 00053 void write_offsets (int buf[],int r_offset=0, int g_offset=0, int b_offset=0); 00054 void setAll(int colour); 00055 00056 void useII(int d); 00057 void setII(unsigned char II); 00058 00059 00060 00061 private: 00062 00063 int __size; 00064 unsigned char __II; 00065 int __use_II; 00066 SPI __spi; 00067 void __write (int color); 00068 00069 00070 }; 00071 00072 #endif
Generated on Sun Jul 24 2022 15:30:33 by
1.7.2