Implemented first Hangar-Service
Dependencies: CalibrateMagneto QuaternionMath
Fork of SML2 by
Diff: MotorDriver.cpp
- Revision:
- 12:1632d7391453
- Parent:
- 4:e759b8c756da
- Child:
- 18:f51b1a94a6e2
diff -r d21275e60ebb -r 1632d7391453 MotorDriver.cpp --- a/MotorDriver.cpp Thu Mar 12 10:16:01 2015 +0000 +++ b/MotorDriver.cpp Fri Mar 13 09:12:56 2015 +0000 @@ -4,16 +4,18 @@ #define DEBUG "Motor" #include "Logger.h" -MotorDriver::MotorDriver(I2C &i2c, const uint8_t address) : I2CPeripheral(i2c, address) { +MotorDriver::MotorDriver(I2C &i2c, const uint8_t address) : I2CPeripheral(i2c, address) +{ INFO("Motor driver at addr=%#x ready", address); } -void MotorDriver::setVoltage(const float voltage) { +void MotorDriver::setVoltage(const float voltage) +{ assert(abs(voltage) <= 5.06); - + const bool stop = fabs(voltage) < 0.48; const float Vr = 1.285; // internal reference voltage - + if (stop) { write_reg(0x00, 0x03); // last 2 bits = 11 = "brake" } else { @@ -23,7 +25,8 @@ } } -MotorDriver& MotorDriver::operator=(const float voltage) { +MotorDriver& MotorDriver::operator=(const float voltage) +{ setVoltage(voltage); return *this; } \ No newline at end of file