Easyuino  1.2.0
DistanceMeterAccurate.h
1 /*
2 MIT License
3 
4 Copyright (c) 2017 André Pires
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12 
13 The above copyright notice and this permission notice shall be included in all
14 copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 SOFTWARE.
23 */
24 /*
25 DistanceMeterAccurate.h
26 */
27 #ifndef _EASYUINO_DISTANCE_METER_ACCURATE_h
28 #define _EASYUINO_DISTANCE_METER_ACCURATE_h
29 
30 #include "Utilities.h"
31 #include "DistanceMeterNonBlock.h"
32 
33 namespace Easyuino {
34 
36  enum TemperatureScale : uint8_t {
37  CELSIUS, KELVIN, FAHRENHEIT
38  };
39 
51 
52  private:
54  float _airTemperature;
56  TemperatureScale _temperatureScale;
57 
58  public:
63  DistanceMeterAccurate(IN uint8_t triggerPin, IN uint8_t echoPin);
64 
68  DistanceMeterAccurate(IN uint8_t triggerEchoPin);
69 
72 
73  float getDistanceCentimeters();
74 
79  void updateDistance(IN float airTemperature = DEFAULT_AIR_TEMPERATURE_CELSIUS, IN TemperatureScale temperatureScale = CELSIUS);
80 
88  void updateDistanceNonBlock(IN float airTemperature = DEFAULT_AIR_TEMPERATURE_CELSIUS, IN TemperatureScale temperatureScale = CELSIUS);
89 
90  private:
96  static float CalculateSoundSpeed(IN float airTemperature = DEFAULT_AIR_TEMPERATURE_CELSIUS, IN TemperatureScale temperatureScale = CELSIUS);
97 
98  };
99 
100 };
101 
102 #endif
virtual void updateDistanceNonBlock()
Updates the distance of the Ultrasonic Module to the objects in a non-blocking way.
void updateDistance()
Updates the distance of the Ultrasonic Module to the objects in a blocking way.
DistanceMeterAccurate(IN uint8_t triggerPin, IN uint8_t echoPin)
Constructor.
Definition: Button.h:38
float getDistanceCentimeters()
Gets the last value that the API measured using the Ultrasonic Module.
DistanceMeterNonBlock offers an API to interact with an Ultrasonic Module to measure distance in a no...
Definition: DistanceMeterNonBlock.h:47
DistanceMeterAccurate offers an API to interact with an Ultrasonic Module to measure distances consid...
Definition: DistanceMeterAccurate.h:50