Implemented first Hangar-Service
Dependencies: CalibrateMagneto QuaternionMath
Fork of SML2 by
Diff: LEDDriver.cpp
- Revision:
- 12:1632d7391453
- Parent:
- 4:e759b8c756da
- Child:
- 18:f51b1a94a6e2
diff -r d21275e60ebb -r 1632d7391453 LEDDriver.cpp --- a/LEDDriver.cpp Thu Mar 12 10:16:01 2015 +0000 +++ b/LEDDriver.cpp Fri Mar 13 09:12:56 2015 +0000 @@ -4,7 +4,8 @@ #include "Logger.h" #include <cassert> -LEDDriver::LEDDriver(I2C &i2c) : I2CPeripheral(i2c, 0x60 /* I2C address of the LED controller */) { +LEDDriver::LEDDriver(I2C &i2c) : I2CPeripheral(i2c, 0x60 /* I2C address of the LED controller */) +{ // cf. LP5562TME/NOPB datasheet page 14 // Supply 3.6V to VDD (hardware - done) // Supply 1.8V to EN (hardware - done) @@ -13,13 +14,14 @@ wait_us(500); // wait 500 usec write_reg(0x08, 0x61); // set PWM freq high, enable power save mode, start internal clock write_reg(0x70, 0x00); // configure all LEDs to be controlled from I2C registers - + setColor(Colors::black); - + INFO("LED driver ready"); } -void LEDDriver::setColor(const uint8_t r, const uint8_t g, const uint8_t b) { +void LEDDriver::setColor(const uint8_t r, const uint8_t g, const uint8_t b) +{ write_reg(0x04, r); write_reg(0x03, g); write_reg(0x02, b); @@ -38,12 +40,14 @@ setColor(r, g, b); } -LEDDriver& LEDDriver::operator=(const Color& c) { +LEDDriver& LEDDriver::operator=(const Color& c) +{ setColor(c); return *this; } -void LEDDriver::setOutputCurrent(const float mA) { +void LEDDriver::setOutputCurrent(const float mA) +{ assert(mA <= 25.5); assert(mA >= 0.1); write_reg(0x05, mA * 10);