Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Nucleo_UltrasonicHelloWorld xxx_Sonar-HC-SR04_Lsg
Diff: ultrasonic.h
- Revision:
- 0:6aa04a8c8d4c
- Child:
- 1:114e0698a5d2
diff -r 000000000000 -r 6aa04a8c8d4c ultrasonic.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ultrasonic.h Sun Nov 23 20:27:09 2014 +0000
@@ -0,0 +1,43 @@
+#ifndef MBED_ULTRASONIC_H
+#define MBED_ULTRASONIC_H
+
+#include "mbed.h"
+
+class ultrasonic
+{
+ public:
+ ultrasonic(PinName trigPin, PinName echoPin, float updateSpeed, float timeout);
+ ultrasonic(PinName trigPin, PinName echoPin, float updateSpeed, float timeout, void onUpdate(int), void onTrig(void),void onStartTimer(void)/*, Timer *t*/ );
+ int getCurrentDistance(void);
+ void pauseUpdates(void);
+ void startUpdates(void);
+ void attachOnUpdate(void method(int));
+ void attachOnTrigger(void method(void));
+ void attachOnStartTimer(void method(void));
+ void changeUpdateSpeed(float updateSpeed);
+ int isUpdated(void);
+ float getUpdateSpeed();
+ private:
+ DigitalOut _trig;
+ InterruptIn _echo;
+ Timer _t;
+ Timeout _tout;
+ int _distance;
+ float _updateSpeed;
+ int start;
+ int end;
+ volatile int done;
+ void (*_onUpdateMethod)(int);
+ void (*_onTriggerMethod)(void);
+ void (*_onStartTimerMethod)(void);
+ void _startT(void);
+ void _updateDist(void);
+ void _startTrig(void);
+ float _timeout;
+
+ int d;
+ /*unsigned int tickcount;
+ Ticker _ticker;
+ void ticktock(void);*/
+};
+#endif
\ No newline at end of file