trikRuntime
encoder.h
Go to the documentation of this file.
1 /* Copyright 2013 - 2015 Matvey Bryksin, Yurii Litvinov and CyberTech Labs Ltd.
2  * and CyberTech Labs Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License. */
15 
16 #pragma once
17 
18 #include "encoderInterface.h"
19 #include "deviceState.h"
20 
21 namespace trikKernel {
22 class Configurer;
23 }
24 
25 namespace trikControl {
26 
27 class MspCommunicatorInterface;
28 
30 class Encoder : public EncoderInterface
31 {
32  Q_OBJECT
33 
34 public:
39  Encoder(const QString &port, const trikKernel::Configurer &configurer
41 
42  Status status() const override;
43 
44 public slots:
45  int read() override;
46 
47  int readRawData() override;
48 
49  void reset() override;
50 
51 private:
52  MspCommunicatorInterface &mCommunicator;
53  int mI2cCommandNumber;
54  int mPassedTicks;
55  int mPassedDegrees;
56  const bool mInvert;
57  DeviceState mState;
58 };
59 
60 }
Definition: analogSensor.h:23
Generic configuration helper, parses configuration XML files and presents configuration as a set of a...
Definition: configurer.h:28
static const int port
Definition: trikCommunicatorTest.cpp:24
Helper class to track device state (off, starting, ready, stopping, fail).
Definition: deviceState.h:26
Implementation of encoder for real robot.
Definition: encoder.h:30
Encoder of power motor.
Definition: encoderInterface.h:26
Status
Device status.
Definition: deviceInterface.h:33
Abstract interface for communication with MSP, may be implemented by I2C or USB buses, depending on current MSP configuration.
Definition: mspCommunicatorInterface.h:26
Definition: trikCommunicator.h:27