supla-device
Loading...
Searching...
No Matches
src
supla
sensor
HC_SR04.h
1
/*
2
Copyright (C) AC SOFTWARE SP. Z O.O.
3
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License
6
as published by the Free Software Foundation; either version 2
7
of the License, or (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, write to the Free Software
16
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
*/
18
19
#ifndef SRC_SUPLA_SENSOR_HC_SR04_H_
20
#define SRC_SUPLA_SENSOR_HC_SR04_H_
21
22
#include "supla/channel.h"
23
#include "supla/sensor/distance.h"
24
25
#define DURATION_COUNT 2
26
27
namespace
Supla {
28
namespace
Sensor {
29
class
HC_SR04 :
public
Distance {
30
public
:
31
HC_SR04(int8_t trigPin,
32
int8_t echoPin,
33
int16_t minIn = 0,
34
int16_t maxIn = 500,
35
int16_t minOut = 0,
36
int16_t maxOut = 500);
37
void
onInit
();
38
virtual
double
getValue();
39
void
setMinMaxIn(int16_t minIn, int16_t maxIn);
40
void
setMinMaxOut(int16_t minOut, int16_t maxOut);
41
42
protected
:
43
int8_t _trigPin;
44
int8_t _echoPin;
45
int16_t _minIn;
46
int16_t _maxIn;
47
int16_t _minOut;
48
int16_t _maxOut;
49
char
failCount;
50
uint64_t readouts[5];
51
int
index;
52
};
53
54
};
// namespace Sensor
55
};
// namespace Supla
56
57
#endif
// SRC_SUPLA_SENSOR_HC_SR04_H_
Supla::Sensor::HC_SR04::onInit
void onInit()
Third method called on element in SuplaDevice.begin()
Definition
HC_SR04.cpp:39
Generated by
1.13.2