source: flair-src/trunk/lib/FlairSensorActuator/src/BatteryMonitor.cpp@ 26

Last change on this file since 26 was 15, checked in by Bayard Gildas, 9 years ago

sources reformatted with flair-format-dir script

File size: 1.4 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5// created: 2014/01/24
6// filename: BatteryMonitor.cpp
7//
8// author: Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: Base class for battery monitor
14//
15//
16/*********************************************************************/
17
18#include "BatteryMonitor.h"
19#include <Layout.h>
20#include <Label.h>
21#include <DoubleSpinBox.h>
22
23using std::string;
24using namespace flair::core;
25using namespace flair::gui;
26
27namespace flair {
28namespace sensor {
29
30BatteryMonitor::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);
35}
36
37BatteryMonitor::~BatteryMonitor() {}
38
39float BatteryMonitor::GetVoltage(void) const { return batteryvalue; }
40
41bool BatteryMonitor::IsBatteryLow(void) const {
42 if (batteryvalue < battery_thresh->Value())
43 return true;
44 else
45 return false;
46}
47
48void BatteryMonitor::SetBatteryValue(float value) {
49 batteryvalue = value;
50 if (value > 0) {
51 battery->SetText("battery: %.1fV", value);
52 } else {
53 battery->SetText("battery: unreadable");
54 }
55}
56
57} // end namespace sensor
58} // end namespace flair
Note: See TracBrowser for help on using the repository browser.