QuadroCopter  0.1.4
LVMaxSonarEZ.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2017 Michael Brookes
3 
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 #ifndef ANALOGDEVICE_LVMAXSONAREZ_H
19 #define ANALOGDEVICE_LVMAXSONAREZ_H
20 
21 #include "../../analogBase.h"
22 #include <sstream>
23 
24 namespace quadro {
25 
26  namespace analog {
27 
28  class LVMaxSonarEZ : public analogBase {
29 
30  public:
31 
32  const float SONIC_INCH_MODIFIER = 9.8f;
33  const float SONIC_CM_MODIFIER = 2.54f;
34 
35  static const unsigned int SONIC_DATATIMER = 50000;
36 
37  const int MAX_OPERATING_HEIGHT_IN_INCES = 255;
38  const int MIN_OPERATING_HEIGHT_IN_INCES = 6;
39 
44  LVMaxSonarEZ();
45 
52  int start();
53 
60  int stop();
61 
67  double getDistance();
68 
70  __useconds_t dataTimer = SONIC_DATATIMER;
71 
75  enum deviceMode {
76  Inches = 0,
77  Cm = 1
78  };
79 
83  enum deviceStatus {
84  On = 1,
85  Off = 0,
86  Error = 2
87  };
88 
90  deviceStatus currentStatus;
91 
94 
100  void setMode( deviceMode _mode );
101 
107  int getStatus();
108 
114  void setStatus( deviceStatus _status );
115 
116  pthread_t threadHandle;
117 
118  private:
119 
125  static void* runMainSensorUpdateThread( void* static_inst );
126 
133  double convertReadingToDistance( int _reading );
134 
135  int reading;
136 
137  int threadRet;
138  };
139 
140  }
141 }
142 #endif //ANALOGDEVICE_LVMAXSONAREZ_H
void setMode(deviceMode _mode)
Definition: LVMaxSonarEZ.cpp:120
Definition: LVMaxSonarEZ.h:76
Definition: LVMaxSonarEZ.h:77
int stop()
Definition: LVMaxSonarEZ.cpp:74
Definition: analogBase.h:41
deviceMode
Definition: LVMaxSonarEZ.h:75
Definition: LVMaxSonarEZ.h:28
double getDistance()
Storage of the timer for the sensors main thread, based on the data rate of the sensor.
Definition: LVMaxSonarEZ.cpp:135
int start()
Definition: LVMaxSonarEZ.cpp:30
Status Off (thread is disabled)
Definition: LVMaxSonarEZ.h:85
Definition: aeronautics.h:23
Status Error (thread is disabled)
Definition: LVMaxSonarEZ.h:86
Status On (thread is active)
Definition: LVMaxSonarEZ.h:84
deviceStatus
Definition: LVMaxSonarEZ.h:83
deviceMode currentMode
Definition: LVMaxSonarEZ.h:92
int getStatus()
Definition: LVMaxSonarEZ.cpp:130
__useconds_t dataTimer
Definition: LVMaxSonarEZ.h:70
LVMaxSonarEZ()
Definition: LVMaxSonarEZ.cpp:23
void setStatus(deviceStatus _status)
Definition: LVMaxSonarEZ.cpp:125