JM9 XRCU Board 0.1.2
Libraries API Reference
Loading...
Searching...
No Matches
Uts_general.h
Go to the documentation of this file.
1
8
9#ifndef UTS_GENERAL_H
10#define UTS_GENERAL_H
11
12#include <Arduino.h>
13
14#include <Supported_sensor.h>
15
25 private:
30 volatile bool beginned;
31
35 volatile uint16_t prev_dist_mm;
36
37 protected:
41 static const uint16_t ERROR_DIST_MM = 8888;
42
48 virtual void set_beginned (bool is_beginned);
49
55 inline bool is_beginned () { return beginned; }
56
62 inline void store_prev_dist_mm (uint16_t dist_mm) { prev_dist_mm = dist_mm; }
63
69 inline uint16_t get_prev_dist_mm () { return prev_dist_mm; }
70
74 Uts_general ();
75
76 public:
85 virtual bool begin ();
86
93 virtual void end ();
94
100 virtual uint16_t read_dist_mm ();
101
107 inline uint16_t read_dist_cm () { return read_dist_mm() / 10; }
108};
109
110#endif // #ifndef UTS_GENERAL_H
Supported_sensor()
Creates an object of a supported sensor.
Definition Supported_sensor.h:23
virtual uint16_t read_dist_mm()
Reads the distance between this ultrasonic sensor and the obstacle in front of it.
Definition Uts_general.cpp:28
uint16_t get_prev_dist_mm()
Gets the previous measured distance.
Definition Uts_general.h:69
bool is_beginned()
Checks if this ultrasonic sensor is already activated.
Definition Uts_general.h:55
Uts_general()
Constructor for a generic ultrasonic sensor driver.
Definition Uts_general.cpp:8
static const uint16_t ERROR_DIST_MM
The distance representing a measurement error (in millimeters).
Definition Uts_general.h:41
virtual bool begin()
Activates this ultrasonic sensor.
Definition Uts_general.cpp:19
virtual void set_beginned(bool is_beginned)
Sets whether this ultrasonic sensor is activated.
Definition Uts_general.cpp:15
uint16_t read_dist_cm()
Reads the distance between this ultrasonic sensor and the obstacle in front of it.
Definition Uts_general.h:107
void store_prev_dist_mm(uint16_t dist_mm)
Stores the previous measured distance.
Definition Uts_general.h:62
virtual void end()
Deactivates this ultrasonic sensor.
Definition Uts_general.cpp:24