trikRuntime
batteryIndicator.h
Go to the documentation of this file.
1 /* Copyright 2014 CyberTech Labs Ltd.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License. */
14 
15 #pragma once
16 
17 #include <QtCore/qglobal.h>
18 #include <QtCore/QTimer>
19 
20 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
21  #include <QtGui/QLabel>
22 #else
23  #include <QtWidgets/QLabel>
24 #endif
25 
27 #include "powerLevel.h"
28 
29 namespace trikGui {
30 
32 class BatteryIndicator : public QLabel
33 {
34  Q_OBJECT
35 
36 public:
40  explicit BatteryIndicator(trikControl::BrickInterface &brick, QWidget *parent = 0);
41 
42 private slots:
43  void renew();
44 
45 private:
47  float warningThreshold() const;
48 
50  float shutdownThreshold() const;
51 
54 
56  QTimer mRenewTimer;
57 
59  const int mRenewInterval = 60 * 1000;
60 
62  PowerLevel::Level mCurrentLevel;
63 
66  const float m12VWarningThreshold = 10.9;
67 
70  const float m12VShutdownThreshold = 10.4;
71 
74  const float m6VWarningThreshold = 7.1;
75 
78  const float m6VShutdownThreshold = 6.8;
79 
82  const float mSanityThreshold = 1.0;
83 };
84 
85 }
BatteryIndicator(trikControl::BrickInterface &brick, QWidget *parent=0)
Constructor.
Definition: batteryIndicator.cpp:22
Level
Contains values indicating settings for power threshold.
Definition: powerLevel.h:25
Definition: abstractIndicator.h:21
Label showing battery voltage.
Definition: batteryIndicator.h:32
Interface representing TRIK controller board and devices installed on it, also provides access to per...
Definition: brickInterface.h:46