Changeset 15 in flair-src for trunk/lib/FlairSensorActuator/src/BatteryMonitor.cpp
- Timestamp:
- 04/08/16 15:40:57 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairSensorActuator/src/BatteryMonitor.cpp
r3 r15 16 16 /*********************************************************************/ 17 17 18 19 18 #include "BatteryMonitor.h" 20 19 #include <Layout.h> … … 26 25 using namespace flair::gui; 27 26 28 namespace flair { namespace sensor { 27 namespace flair { 28 namespace sensor { 29 29 30 BatteryMonitor::BatteryMonitor(const gui::LayoutPosition* position,string name) : GroupBox(position,name) { 31 battery=new Label(this->NewRow(),"battery"); 32 battery_thresh=new DoubleSpinBox(this->LastRowLastCol(),"threshold"," V",0,24,.1,1); 30 BatteryMonitor::BatteryMonitor(const gui::LayoutPosition *position, string name) 31 : GroupBox(position, name) { 32 battery = new Label(this->NewRow(), "battery"); 33 battery_thresh = new DoubleSpinBox(this->LastRowLastCol(), "threshold", " V", 34 0, 24, .1, 1); 33 35 } 34 36 35 BatteryMonitor::~BatteryMonitor() { 37 BatteryMonitor::~BatteryMonitor() {} 36 38 37 } 38 39 float BatteryMonitor::GetVoltage(void) const { 40 return batteryvalue; 41 } 39 float BatteryMonitor::GetVoltage(void) const { return batteryvalue; } 42 40 43 41 bool BatteryMonitor::IsBatteryLow(void) const { 44 if(batteryvalue<battery_thresh->Value())45 46 47 42 if (batteryvalue < battery_thresh->Value()) 43 return true; 44 else 45 return false; 48 46 } 49 47 50 48 void BatteryMonitor::SetBatteryValue(float value) { 51 batteryvalue=value;52 if(value>0) {53 battery->SetText("battery: %.1fV",value);54 55 56 49 batteryvalue = value; 50 if (value > 0) { 51 battery->SetText("battery: %.1fV", value); 52 } else { 53 battery->SetText("battery: unreadable"); 54 } 57 55 } 58 56
Note:
See TracChangeset
for help on using the changeset viewer.