source: rtos_arduino/trunk/examples/NCESIoT_RTOS/ChainableLED/ChainableLED.h@ 243

Last change on this file since 243 was 243, checked in by ertl-honda, 8 years ago

IoTパッケージの内容に合わせて更新

File size: 2.1 KB
Line 
1/*
2Copyright (C) 2012 Paulo Marques (pjp.marques@gmail.com)
3
4Permission is hereby granted, free of charge, to any person obtaining a copy of
5this software and associated documentation files (the "Software"), to deal in
6the Software without restriction, including without limitation the rights to
7use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8the Software, and to permit persons to whom the Software is furnished to do so,
9subject to the following conditions:
10
11The above copyright notice and this permission notice shall be included in all
12copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20*/
21
22/*
23 * Library for controlling a chain of RGB LEDs based on the P9813 protocol.
24 * E.g., supports the Grove Chainable RGB LED product.
25 *
26 * Information about the P9813 protocol obtained from:
27 * http://www.seeedstudio.com/wiki/index.php?title=Twig_-_Chainable_RGB_LED
28 */
29
30
31
32#ifndef __ChainableLED_h__
33#define __ChainableLED_h__
34
35#if defined (SPARK)
36 #include "application.h"
37#else
38 #include "Arduino.h"
39#endif
40
41#define _CL_RED 0
42#define _CL_GREEN 1
43#define _CL_BLUE 2
44#define _CLK_PULSE_DELAY 20
45
46class ChainableLED
47{
48public:
49 ChainableLED(byte clk_pin, byte data_pin, byte number_of_leds);
50 ~ChainableLED();
51
52 void init();
53 void setColorRGB(byte led, byte red, byte green, byte blue);
54 void setColorHSB(byte led, float hue, float saturation, float brightness);
55
56private:
57 byte _clk_pin;
58 byte _data_pin;
59 byte _num_leds;
60
61 byte* _led_state;
62
63 void clk(void);
64 void sendByte(byte b);
65 void sendColor(byte red, byte green, byte blue);
66};
67
68#endif
69
Note: See TracBrowser for help on using the repository browser.