Code required to drive the microcontroller of the NMF Atlantis

Dependencies:   mbed WakeUp DHT

Committer:
nmf_atlantis
Date:
Mon Jan 20 15:47:07 2020 +0000
Revision:
0:dbaef09f6d82
NMF Atlantis final version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nmf_atlantis 0:dbaef09f6d82 1 /* Copyright (c) 2012 Nick Ryder, University of Oxford
nmf_atlantis 0:dbaef09f6d82 2 * nick.ryder@physics.ox.ac.uk
nmf_atlantis 0:dbaef09f6d82 3 *
nmf_atlantis 0:dbaef09f6d82 4 * MIT License
nmf_atlantis 0:dbaef09f6d82 5 *
nmf_atlantis 0:dbaef09f6d82 6 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
nmf_atlantis 0:dbaef09f6d82 7 * and associated documentation files (the "Software"), to deal in the Software without restriction,
nmf_atlantis 0:dbaef09f6d82 8 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
nmf_atlantis 0:dbaef09f6d82 9 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
nmf_atlantis 0:dbaef09f6d82 10 * furnished to do so, subject to the following conditions:
nmf_atlantis 0:dbaef09f6d82 11 *
nmf_atlantis 0:dbaef09f6d82 12 * The above copyright notice and this permission notice shall be included in all copies or
nmf_atlantis 0:dbaef09f6d82 13 * substantial portions of the Software.
nmf_atlantis 0:dbaef09f6d82 14 *
nmf_atlantis 0:dbaef09f6d82 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
nmf_atlantis 0:dbaef09f6d82 16 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
nmf_atlantis 0:dbaef09f6d82 17 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
nmf_atlantis 0:dbaef09f6d82 18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
nmf_atlantis 0:dbaef09f6d82 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
nmf_atlantis 0:dbaef09f6d82 20 */
nmf_atlantis 0:dbaef09f6d82 21
nmf_atlantis 0:dbaef09f6d82 22 #ifndef MBED_RANGEFINDER_H
nmf_atlantis 0:dbaef09f6d82 23 #define MBED_RANGEFINDER_H
nmf_atlantis 0:dbaef09f6d82 24
nmf_atlantis 0:dbaef09f6d82 25 #include "Pulse.h"
nmf_atlantis 0:dbaef09f6d82 26
nmf_atlantis 0:dbaef09f6d82 27 /** Range Finder class
nmf_atlantis 0:dbaef09f6d82 28 */
nmf_atlantis 0:dbaef09f6d82 29
nmf_atlantis 0:dbaef09f6d82 30 class RangeFinder {
nmf_atlantis 0:dbaef09f6d82 31 public:
nmf_atlantis 0:dbaef09f6d82 32 /** Create a RangeFinder object
nmf_atlantis 0:dbaef09f6d82 33 * @param pin Digital I/O pin the range finder is connected to.
nmf_atlantis 0:dbaef09f6d82 34 * @param pulsetime Time of pulse to send to the rangefinder to trigger a measurement, in microseconds.
nmf_atlantis 0:dbaef09f6d82 35 * @param scale Scaling of the range finder's output pulse from microseconds to metres.
nmf_atlantis 0:dbaef09f6d82 36 * @param timeout Time to wait for a pulse from the range finder before giving up.
nmf_atlantis 0:dbaef09f6d82 37 */
nmf_atlantis 0:dbaef09f6d82 38 RangeFinder(PinName pin, int pulsetime, float scale, int timeout);
nmf_atlantis 0:dbaef09f6d82 39 ~RangeFinder();
nmf_atlantis 0:dbaef09f6d82 40 /** Return the distance to the nearest object, or -1.0 if reading the pulse timed out.
nmf_atlantis 0:dbaef09f6d82 41 */
nmf_atlantis 0:dbaef09f6d82 42 float read_m();
nmf_atlantis 0:dbaef09f6d82 43 private:
nmf_atlantis 0:dbaef09f6d82 44 PulseInOut pio;
nmf_atlantis 0:dbaef09f6d82 45 float scale;
nmf_atlantis 0:dbaef09f6d82 46 int pulsetime, timeout;
nmf_atlantis 0:dbaef09f6d82 47 };
nmf_atlantis 0:dbaef09f6d82 48
nmf_atlantis 0:dbaef09f6d82 49 #endif