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

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

sources reformatted with flair-format-dir script

File size: 1.4 KB
RevLine 
[3]1// %flair:license{
[15]2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
[3]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
[15]27namespace flair {
28namespace sensor {
[3]29
[15]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);
[3]35}
36
[15]37BatteryMonitor::~BatteryMonitor() {}
[3]38
[15]39float BatteryMonitor::GetVoltage(void) const { return batteryvalue; }
[3]40
41bool BatteryMonitor::IsBatteryLow(void) const {
[15]42  if (batteryvalue < battery_thresh->Value())
43    return true;
44  else
45    return false;
[3]46}
47
48void BatteryMonitor::SetBatteryValue(float value) {
[15]49  batteryvalue = value;
50  if (value > 0) {
51    battery->SetText("battery: %.1fV", value);
52  } else {
53    battery->SetText("battery: unreadable");
54  }
[3]55}
56
57} // end namespace sensor
58} // end namespace flair
Note: See TracBrowser for help on using the repository browser.