Abstract class for 'constant current (CC)' LED driver component. Including "LedPwmOutCC API" class.

Dependents:   PCA995xA

Committer:
nxp_ip
Date:
Wed Mar 04 10:14:02 2015 +0000
Revision:
0:6d2f6c0fcc40
Initial version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nxp_ip 0:6d2f6c0fcc40 1 /** LedPwmOutCC class for LED driver component
nxp_ip 0:6d2f6c0fcc40 2 *
nxp_ip 0:6d2f6c0fcc40 3 * @author Akifumi (Tedd) OKANO, NXP Semiconductors
nxp_ip 0:6d2f6c0fcc40 4 * @version 0.5
nxp_ip 0:6d2f6c0fcc40 5 * @date 04-Mar-2015
nxp_ip 0:6d2f6c0fcc40 6 *
nxp_ip 0:6d2f6c0fcc40 7 * Released under the Apache 2 license
nxp_ip 0:6d2f6c0fcc40 8 */
nxp_ip 0:6d2f6c0fcc40 9
nxp_ip 0:6d2f6c0fcc40 10 #ifndef MBED_LedPwmOutCC
nxp_ip 0:6d2f6c0fcc40 11 #define MBED_LedPwmOutCC
nxp_ip 0:6d2f6c0fcc40 12
nxp_ip 0:6d2f6c0fcc40 13 #include "mbed.h"
nxp_ip 0:6d2f6c0fcc40 14 #include "CompLedDvrCC.h"
nxp_ip 0:6d2f6c0fcc40 15
nxp_ip 0:6d2f6c0fcc40 16 /** LedPwmOutCC class
nxp_ip 0:6d2f6c0fcc40 17 *
nxp_ip 0:6d2f6c0fcc40 18 * @class LedPwmOutCC
nxp_ip 0:6d2f6c0fcc40 19 *
nxp_ip 0:6d2f6c0fcc40 20 * "LedPwmOutCC" class works like "PwmOut" class of mbed-SDK.
nxp_ip 0:6d2f6c0fcc40 21 * This class provides API on device's pin level with abstracting the LED controller.
nxp_ip 0:6d2f6c0fcc40 22 *
nxp_ip 0:6d2f6c0fcc40 23 * Example:
nxp_ip 0:6d2f6c0fcc40 24 * @code
nxp_ip 0:6d2f6c0fcc40 25 * #include "mbed.h"
nxp_ip 0:6d2f6c0fcc40 26 * #include "PCA9956A.h"
nxp_ip 0:6d2f6c0fcc40 27 *
nxp_ip 0:6d2f6c0fcc40 28 * PCA9956A led_cntlr( p28, p27, 0xC4 ); // SDA, SCL, Slave_address(option)
nxp_ip 0:6d2f6c0fcc40 29 * LedPwmOutCC led( led_cntlr, L0 );
nxp_ip 0:6d2f6c0fcc40 30 *
nxp_ip 0:6d2f6c0fcc40 31 * int main()
nxp_ip 0:6d2f6c0fcc40 32 * {
nxp_ip 0:6d2f6c0fcc40 33 * while( 1 ) {
nxp_ip 0:6d2f6c0fcc40 34 * for( float p = 0.0f; p < 1.0f; p += 0.1f ) {
nxp_ip 0:6d2f6c0fcc40 35 * led = p;
nxp_ip 0:6d2f6c0fcc40 36 * wait( 0.1 );
nxp_ip 0:6d2f6c0fcc40 37 * }
nxp_ip 0:6d2f6c0fcc40 38 * }
nxp_ip 0:6d2f6c0fcc40 39 * }
nxp_ip 0:6d2f6c0fcc40 40 * @endcode
nxp_ip 0:6d2f6c0fcc40 41 */
nxp_ip 0:6d2f6c0fcc40 42 class LedPwmOutCC
nxp_ip 0:6d2f6c0fcc40 43 {
nxp_ip 0:6d2f6c0fcc40 44 public:
nxp_ip 0:6d2f6c0fcc40 45
nxp_ip 0:6d2f6c0fcc40 46 /** Create a LedPwmOutCC instance connected to a pin on the LED driver
nxp_ip 0:6d2f6c0fcc40 47 * A pin which performs PWM and constant current sink
nxp_ip 0:6d2f6c0fcc40 48 *
nxp_ip 0:6d2f6c0fcc40 49 * @param ledp Instance of a device (LED driver)
nxp_ip 0:6d2f6c0fcc40 50 * @param pin_name Specifying pin by LedPinName like 'L7'.
nxp_ip 0:6d2f6c0fcc40 51 *
nxp_ip 0:6d2f6c0fcc40 52 * @note
nxp_ip 0:6d2f6c0fcc40 53 * Pin names of LED driver are defined like L0, L1, L2.. It is not like "LED0".
nxp_ip 0:6d2f6c0fcc40 54 * Because we cannot use mbed reserved symbols.
nxp_ip 0:6d2f6c0fcc40 55 */
nxp_ip 0:6d2f6c0fcc40 56 LedPwmOutCC( CompLedDvrCC &ledp, LedPinName pin_name );
nxp_ip 0:6d2f6c0fcc40 57
nxp_ip 0:6d2f6c0fcc40 58 /** Destractor
nxp_ip 0:6d2f6c0fcc40 59 */
nxp_ip 0:6d2f6c0fcc40 60 virtual ~LedPwmOutCC();
nxp_ip 0:6d2f6c0fcc40 61
nxp_ip 0:6d2f6c0fcc40 62 /** Set PWM duty-cycle
nxp_ip 0:6d2f6c0fcc40 63 *
nxp_ip 0:6d2f6c0fcc40 64 * @param v Ratio of duty-cycle. '0.0' for 0 %. '1.0' for 99.6 % on PCA9956A and 100 % for PCA9955A.
nxp_ip 0:6d2f6c0fcc40 65 */
nxp_ip 0:6d2f6c0fcc40 66 virtual void pwm( float v );
nxp_ip 0:6d2f6c0fcc40 67
nxp_ip 0:6d2f6c0fcc40 68 /** Set output current
nxp_ip 0:6d2f6c0fcc40 69 *
nxp_ip 0:6d2f6c0fcc40 70 * @param v Ratio of output current. 1.0 for 100 % output of hardware setting
nxp_ip 0:6d2f6c0fcc40 71 */
nxp_ip 0:6d2f6c0fcc40 72 virtual void current( float v );
nxp_ip 0:6d2f6c0fcc40 73
nxp_ip 0:6d2f6c0fcc40 74 /** A shorthand for pwm()
nxp_ip 0:6d2f6c0fcc40 75 */
nxp_ip 0:6d2f6c0fcc40 76 LedPwmOutCC& operator= ( float rhs );
nxp_ip 0:6d2f6c0fcc40 77
nxp_ip 0:6d2f6c0fcc40 78 private:
nxp_ip 0:6d2f6c0fcc40 79 CompLedDvrCC *leddvrp;
nxp_ip 0:6d2f6c0fcc40 80 LedPinName pin;
nxp_ip 0:6d2f6c0fcc40 81
nxp_ip 0:6d2f6c0fcc40 82 void pwm( int pin, float value );
nxp_ip 0:6d2f6c0fcc40 83 }
nxp_ip 0:6d2f6c0fcc40 84 ;
nxp_ip 0:6d2f6c0fcc40 85
nxp_ip 0:6d2f6c0fcc40 86 #endif // MBED_LedPwmOutCC