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.
Dependents: BLENano_RGB_Demo BLENano_RGB_Demo_DAP ble-devicelink-example connected-lights
ChainableLED.h
00001 /* 00002 Copyright (C) 2013 Seeed Technology Inc. 00003 Copyright (C) 2012 Paulo Marques (pjp.marques@gmail.com) 00004 00005 Permission is hereby granted, free of charge, to any person obtaining a copy of 00006 this software and associated documentation files (the "Software"), to deal in 00007 the Software without restriction, including without limitation the rights to 00008 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 00009 the Software, and to permit persons to whom the Software is furnished to do so, 00010 subject to the following conditions: 00011 00012 The above copyright notice and this permission notice shall be included in all 00013 copies or substantial portions of the Software. 00014 00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 00017 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 00018 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 00019 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00020 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00021 */ 00022 00023 /* 00024 * Library for controlling a chain of RGB LEDs based on the P9813 protocol. 00025 * E.g., supports the Grove Chainable RGB LED product. 00026 * 00027 * Information about the P9813 protocol obtained from: 00028 * http://www.seeedstudio.com/wiki/index.php?title=Twig_-_Chainable_RGB_LED 00029 */ 00030 00031 00032 00033 #ifndef __ChainableLED_h__ 00034 #define __ChainableLED_h__ 00035 00036 #include "mbed.h" 00037 00038 #define _CL_RED 0 00039 #define _CL_GREEN 1 00040 #define _CL_BLUE 2 00041 #define _CLK_PULSE_DELAY 20 00042 00043 class ChainableLED 00044 { 00045 public: 00046 ChainableLED(PinName clk_pin, PinName data_pin, unsigned int number_of_leds); 00047 ~ChainableLED(); 00048 00049 void setColorRGB(unsigned int led, uint8_t red, uint8_t green, uint8_t blue); 00050 void setColorHSB(unsigned int led, float hue, float saturation, float brightness); 00051 00052 private: 00053 DigitalOut _clk_pin; 00054 DigitalOut _data_pin; 00055 unsigned int _num_leds; 00056 00057 uint8_t _led_state[3]; 00058 00059 void clk(void); 00060 void sendByte(uint8_t b); 00061 void sendColor(uint8_t red, uint8_t green, uint8_t blue); 00062 }; 00063 00064 #endif
Generated on Thu Jul 14 2022 16:55:12 by
1.7.2