How can I use the battery sensor
Posted: Sun Aug 02, 2020 8:14 am
Hey, I try to use the battery sensor and show the Time left in seconds. I have added the sensor. But when I try to print out the variable of Timeleft, it shows there are infinite time. It is more likely that this battery does not enable. So how can I enable this battery sensors.
Code: Select all
m_pcBattery = GetSensor <CBatteryDefaultSensor >("battery");
const CCI_BatterySensor::SReading & tBatteryReads = m_pcBattery->GetReading();
Real timeleft = tBatteryReads.AvailableCharge;
std::cout<<" TimeLeft:" << timeleft <<"\n";