Level measurement using range finder and lora technology

Dependencies:   Cayenne-LPP SDBlockDevice

Committer:
wamae
Date:
Wed Jun 26 10:35:50 2019 +0000
Revision:
0:f930f0440fd5
better copy

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wamae 0:f930f0440fd5 1 /* Copyright (c) 2013 Prabhu Desai
wamae 0:f930f0440fd5 2 * pdtechworld@gmail.com
wamae 0:f930f0440fd5 3 *
wamae 0:f930f0440fd5 4 *
wamae 0:f930f0440fd5 5 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
wamae 0:f930f0440fd5 6 * and associated documentation files (the "Software"), to deal in the Software without restriction,
wamae 0:f930f0440fd5 7 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
wamae 0:f930f0440fd5 8 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
wamae 0:f930f0440fd5 9 * furnished to do so, subject to the following conditions:
wamae 0:f930f0440fd5 10 *
wamae 0:f930f0440fd5 11 * The above copyright notice and this permission notice shall be included in all copies or
wamae 0:f930f0440fd5 12 * substantial portions of the Software.
wamae 0:f930f0440fd5 13 *
wamae 0:f930f0440fd5 14 * For more details on the sensor :
wamae 0:f930f0440fd5 15 * http://www.elecfreaks.com/store/hcsr04-ultrasonic-sensor-distance-measuring-module-p-91.html?zenid=pgm8pgnvaodbe36dibq5s1soi3
wamae 0:f930f0440fd5 16 *
wamae 0:f930f0440fd5 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
wamae 0:f930f0440fd5 18 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
wamae 0:f930f0440fd5 19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
wamae 0:f930f0440fd5 20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
wamae 0:f930f0440fd5 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
wamae 0:f930f0440fd5 22 */
wamae 0:f930f0440fd5 23
wamae 0:f930f0440fd5 24 #ifndef MBED_HCSR04_H
wamae 0:f930f0440fd5 25 #define MBED_HCSR04_H
wamae 0:f930f0440fd5 26
wamae 0:f930f0440fd5 27 #include "mbed.h"
wamae 0:f930f0440fd5 28
wamae 0:f930f0440fd5 29 /** HCSR04 Class(es)
wamae 0:f930f0440fd5 30 */
wamae 0:f930f0440fd5 31
wamae 0:f930f0440fd5 32 class HCSR04
wamae 0:f930f0440fd5 33 {
wamae 0:f930f0440fd5 34 public:
wamae 0:f930f0440fd5 35 /** Create a HCSR04 object connected to the specified pin
wamae 0:f930f0440fd5 36 * @param pin i/o pin to connect to
wamae 0:f930f0440fd5 37 */
wamae 0:f930f0440fd5 38 HCSR04(PinName TrigPin,PinName EchoPin);
wamae 0:f930f0440fd5 39 ~HCSR04();
wamae 0:f930f0440fd5 40
wamae 0:f930f0440fd5 41 /** Return the distance from obstacle in cm
wamae 0:f930f0440fd5 42 * @param distance in cms and returns -1, in case of failure
wamae 0:f930f0440fd5 43 */
wamae 0:f930f0440fd5 44 unsigned int get_dist_cm(void);
wamae 0:f930f0440fd5 45 /** Return the pulse duration equal to sonic waves travelling to obstacle and back to receiver.
wamae 0:f930f0440fd5 46 * @param pulse duration in microseconds.
wamae 0:f930f0440fd5 47 */
wamae 0:f930f0440fd5 48 unsigned int get_pulse_us(void);
wamae 0:f930f0440fd5 49 /** Generates the trigger pulse of 10us on the trigger PIN.
wamae 0:f930f0440fd5 50 */
wamae 0:f930f0440fd5 51 void start(void );
wamae 0:f930f0440fd5 52 void isr_rise(void);
wamae 0:f930f0440fd5 53 void isr_fall(void);
wamae 0:f930f0440fd5 54 void fall (void (*fptr)(void));
wamae 0:f930f0440fd5 55 void rise (void (*fptr)(void));
wamae 0:f930f0440fd5 56
wamae 0:f930f0440fd5 57
wamae 0:f930f0440fd5 58
wamae 0:f930f0440fd5 59 private:
wamae 0:f930f0440fd5 60
wamae 0:f930f0440fd5 61 Timer pulsetime;
wamae 0:f930f0440fd5 62 DigitalOut trigger;
wamae 0:f930f0440fd5 63 InterruptIn echo;
wamae 0:f930f0440fd5 64 unsigned int pulsedur;
wamae 0:f930f0440fd5 65 unsigned int distance;
wamae 0:f930f0440fd5 66 };
wamae 0:f930f0440fd5 67
wamae 0:f930f0440fd5 68 #endif