a

Dependencies:   Servo ServoArm mbed

Fork of PES_Official-TestF by zhaw_st16b_pes2_10

Committer:
beacon
Date:
Thu May 18 14:27:09 2017 +0000
Revision:
17:4e1be70bdedb
Si compila.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
beacon 17:4e1be70bdedb 1 #ifndef ULTRASCHALL_H
beacon 17:4e1be70bdedb 2 #define ULTRASCHALL_H
beacon 17:4e1be70bdedb 3
beacon 17:4e1be70bdedb 4 #include "mbed.h"
beacon 17:4e1be70bdedb 5
beacon 17:4e1be70bdedb 6 /** Ultraschall Class(es)
beacon 17:4e1be70bdedb 7 */
beacon 17:4e1be70bdedb 8
beacon 17:4e1be70bdedb 9 class Ultraschall
beacon 17:4e1be70bdedb 10 {
beacon 17:4e1be70bdedb 11 public:
beacon 17:4e1be70bdedb 12 /** Create a Ultraschall object connected to the specified pin
beacon 17:4e1be70bdedb 13 * @param pin i/o pin to connect to
beacon 17:4e1be70bdedb 14 */
beacon 17:4e1be70bdedb 15 Ultraschall();
beacon 17:4e1be70bdedb 16 Ultraschall(PinName TrigPin,PinName EchoPin);
beacon 17:4e1be70bdedb 17 ~Ultraschall();
beacon 17:4e1be70bdedb 18
beacon 17:4e1be70bdedb 19 /** Return the distance from obstacle in cm
beacon 17:4e1be70bdedb 20 * @param distance in cms and returns -1, in case of failure
beacon 17:4e1be70bdedb 21 */
beacon 17:4e1be70bdedb 22 unsigned int get_dist_cm(void);
beacon 17:4e1be70bdedb 23 /** Return the pulse duration equal to sonic waves travelling to obstacle and back to receiver.
beacon 17:4e1be70bdedb 24 * @param pulse duration in microseconds.
beacon 17:4e1be70bdedb 25 */
beacon 17:4e1be70bdedb 26 unsigned int get_pulse_us(void);
beacon 17:4e1be70bdedb 27 /** Generates the trigger pulse of 10us on the trigger PIN.
beacon 17:4e1be70bdedb 28 */
beacon 17:4e1be70bdedb 29 void start(void);
beacon 17:4e1be70bdedb 30 void isr_rise(void);
beacon 17:4e1be70bdedb 31 void isr_fall(void);
beacon 17:4e1be70bdedb 32 void fall (void (*fptr)(void));
beacon 17:4e1be70bdedb 33 void rise (void (*fptr)(void));
beacon 17:4e1be70bdedb 34
beacon 17:4e1be70bdedb 35
beacon 17:4e1be70bdedb 36
beacon 17:4e1be70bdedb 37 private:
beacon 17:4e1be70bdedb 38
beacon 17:4e1be70bdedb 39 Timer pulsetime;
beacon 17:4e1be70bdedb 40 DigitalOut trigger;
beacon 17:4e1be70bdedb 41 InterruptIn echo;
beacon 17:4e1be70bdedb 42 unsigned int pulsedur;
beacon 17:4e1be70bdedb 43 unsigned int distance;
beacon 17:4e1be70bdedb 44 };
beacon 17:4e1be70bdedb 45
beacon 17:4e1be70bdedb 46 #endif
beacon 17:4e1be70bdedb 47