forked from compAIR/libcreate
Convert units to base units
This commit is contained in:
parent
fbef2e2c88
commit
76e5ac8816
2 changed files with 16 additions and 16 deletions
|
@ -354,15 +354,15 @@ namespace create {
|
|||
bool isSpotButtonPressed() const;
|
||||
|
||||
/* Get battery voltage.
|
||||
* \return value in millivolts
|
||||
* \return value in volts
|
||||
*/
|
||||
uint16_t getVoltage() const;
|
||||
float getVoltage() const;
|
||||
|
||||
/* Get current flowing in/out of battery.
|
||||
* A positive current implies Create is charging.
|
||||
* \return value in milliamps
|
||||
* \return value in amps
|
||||
*/
|
||||
int16_t getCurrent() const;
|
||||
float getCurrent() const;
|
||||
|
||||
/* Get the temperature of battery.
|
||||
* \return value in Celsius
|
||||
|
@ -370,14 +370,14 @@ namespace create {
|
|||
int8_t getTemperature() const;
|
||||
|
||||
/* Get battery's remaining charge.
|
||||
* \return value in milliamp-hours
|
||||
* \return value in amp-hours
|
||||
*/
|
||||
uint16_t getBatteryCharge() const;
|
||||
float getBatteryCharge() const;
|
||||
|
||||
/* Get estimated battery charge capacity.
|
||||
* \return in milliamp-hours
|
||||
* \return in amp-hours
|
||||
*/
|
||||
uint16_t getBatteryCapacity() const;
|
||||
float getBatteryCapacity() const;
|
||||
|
||||
/* Return true if farthest left light sensor detects an obstacle, false otherwise.
|
||||
*/
|
||||
|
|
|
@ -567,9 +567,9 @@ namespace create {
|
|||
}
|
||||
}
|
||||
|
||||
uint16_t Create::getVoltage() const {
|
||||
float Create::getVoltage() const {
|
||||
if (data->isValidPacketID(ID_VOLTAGE)) {
|
||||
return GET_DATA(ID_VOLTAGE);
|
||||
return (GET_DATA(ID_VOLTAGE) / 1000.0);
|
||||
}
|
||||
else {
|
||||
CERR("[create::Create] ", "Voltage sensor not supported!");
|
||||
|
@ -577,9 +577,9 @@ namespace create {
|
|||
}
|
||||
}
|
||||
|
||||
int16_t Create::getCurrent() const {
|
||||
float Create::getCurrent() const {
|
||||
if (data->isValidPacketID(ID_VOLTAGE)) {
|
||||
return (int16_t) GET_DATA(ID_CURRENT);
|
||||
return (((int16_t)GET_DATA(ID_CURRENT)) / 1000.0);
|
||||
}
|
||||
else {
|
||||
CERR("[create::Create] ", "Current sensor not supported!");
|
||||
|
@ -597,9 +597,9 @@ namespace create {
|
|||
}
|
||||
}
|
||||
|
||||
uint16_t Create::getBatteryCharge() const {
|
||||
float Create::getBatteryCharge() const {
|
||||
if (data->isValidPacketID(ID_CHARGE)) {
|
||||
return GET_DATA(ID_CHARGE);
|
||||
return (GET_DATA(ID_CHARGE) / 1000.0);
|
||||
}
|
||||
else {
|
||||
CERR("[create::Create] ", "Battery charge not supported!");
|
||||
|
@ -607,9 +607,9 @@ namespace create {
|
|||
}
|
||||
}
|
||||
|
||||
uint16_t Create::getBatteryCapacity() const {
|
||||
float Create::getBatteryCapacity() const {
|
||||
if (data->isValidPacketID(ID_CAPACITY)) {
|
||||
return GET_DATA(ID_CAPACITY);
|
||||
return (GET_DATA(ID_CAPACITY) / 1000.0);
|
||||
}
|
||||
else {
|
||||
CERR("[create::Create] ", "Battery capacity not supported!");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue