supla-device
Loading...
Searching...
No Matches
src
supla
sensor
HC_SR04.h
1
// SPDX-FileCopyrightText: AC SOFTWARE SP. Z O.O.
2
// SPDX-License-Identifier: GPL-2.0-or-later
3
4
#ifndef SRC_SUPLA_SENSOR_HC_SR04_H_
5
#define SRC_SUPLA_SENSOR_HC_SR04_H_
6
7
#include "supla/channel.h"
8
#include "supla/io.h"
9
#include "supla/sensor/distance.h"
10
11
#define DURATION_COUNT 2
12
13
namespace
Supla {
14
namespace
Sensor {
15
class
HC_SR04
:
public
Distance
{
16
public
:
17
HC_SR04
(int8_t trigPin,
18
int8_t echoPin,
19
int16_t minIn = 0,
20
int16_t maxIn = 500,
21
int16_t minOut = 0,
22
int16_t maxOut = 500,
23
Supla::Io::Base
*io =
nullptr
);
24
void
onInit
();
25
virtual
double
getValue();
26
void
setMinMaxIn(int16_t minIn, int16_t maxIn);
27
void
setMinMaxOut(int16_t minOut, int16_t maxOut);
28
29
protected
:
30
int8_t _trigPin;
31
int8_t _echoPin;
32
int16_t _minIn;
33
int16_t _maxIn;
34
int16_t _minOut;
35
int16_t _maxOut;
36
char
failCount;
37
uint64_t readouts[5];
38
int
index;
39
Supla::Io::Base
*io;
40
};
41
42
};
// namespace Sensor
43
};
// namespace Supla
44
45
#endif
// SRC_SUPLA_SENSOR_HC_SR04_H_
Supla::Io::Base
Definition
io.h:23
Supla::Sensor::Distance
Definition
distance.h:13
Supla::Sensor::HC_SR04
Definition
HC_SR04.h:15
Supla::Sensor::HC_SR04::onInit
void onInit()
Third method called on element in SuplaDevice.begin()
Definition
HC_SR04.cpp:27
Generated by
1.12.0