trikRuntime
motorLever.h
Go to the documentation of this file.
1 /* Copyright 2014 Roman Kurbatov
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 
19 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
20  #include <QtGui/QWidget>
21  #include <QtGui/QHBoxLayout>
22  #include <QtGui/QLabel>
23  #include <QtGui/QProgressBar>
24 #else
25  #include <QtWidgets/QWidget>
26  #include <QtWidgets/QHBoxLayout>
27  #include <QtWidgets/QLabel>
28  #include <QtWidgets/QProgressBar>
29 #endif
30 
31 #include <QtCore/QString>
32 
33 namespace trikControl {
34  class MotorInterface;
35 }
36 
37 namespace trikGui {
38 
41 class MotorLever : public QFrame
42 {
43  Q_OBJECT
44 
45 public:
50  MotorLever(const QString &port, trikControl::MotorInterface &motor, QWidget *parent = 0);
51 
53  ~MotorLever() override;
54 
55 protected:
56  void keyPressEvent(QKeyEvent *event) override;
57 
58 private:
59  void setPower(int power);
60 
61  void turnOnOff();
62 
64  bool mIsOn;
65  const int mMaxPower;
66  const int mMinPower;
67  const int mPowerStep;
68  int mPower;
69 
70  QHBoxLayout mLayout;
71  QLabel mNameLabel;
72  QProgressBar mPowerBar;
73  QLabel mOnOffLabel;
74 };
75 
76 }
static const int port
Definition: trikCommunicatorTest.cpp:24
Abstract motor. It is differently implemented by different motor types (like servo and power motors)...
Definition: motorInterface.h:26
Definition: abstractIndicator.h:21
Definition: trikCommunicator.h:27
Widget that allows to set power value of a motor and turn it on and off.
Definition: motorLever.h:41