SRF08 Libraray
Dependents: mbedDemoDisplay mbedDemoDisplay Roaming SRF08HelloWorld ... more
SRF08.h@2:aeec981d1d2a, 2017-10-31 (annotated)
- Committer:
- chris
- Date:
- Tue Oct 31 17:59:10 2017 +0000
- Revision:
- 2:aeec981d1d2a
- Parent:
- 0:752fc2753b90
Remove mbed.bld
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chris | 0:752fc2753b90 | 1 | |
chris | 0:752fc2753b90 | 2 | /* |
chris | 0:752fc2753b90 | 3 | Copyright (c) 2010 Chris Styles (chris dot styles at mbed dot org) |
chris | 0:752fc2753b90 | 4 | |
chris | 0:752fc2753b90 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy |
chris | 0:752fc2753b90 | 6 | of this software and associated documentation files (the "Software"), to deal |
chris | 0:752fc2753b90 | 7 | in the Software without restriction, including without limitation the rights |
chris | 0:752fc2753b90 | 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
chris | 0:752fc2753b90 | 9 | copies of the Software, and to permit persons to whom the Software is |
chris | 0:752fc2753b90 | 10 | furnished to do so, subject to the following conditions: |
chris | 0:752fc2753b90 | 11 | |
chris | 0:752fc2753b90 | 12 | The above copyright notice and this permission notice shall be included in |
chris | 0:752fc2753b90 | 13 | all copies or substantial portions of the Software. |
chris | 0:752fc2753b90 | 14 | |
chris | 0:752fc2753b90 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
chris | 0:752fc2753b90 | 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
chris | 0:752fc2753b90 | 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
chris | 0:752fc2753b90 | 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
chris | 0:752fc2753b90 | 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
chris | 0:752fc2753b90 | 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
chris | 0:752fc2753b90 | 21 | THE SOFTWARE. |
chris | 0:752fc2753b90 | 22 | */ |
chris | 0:752fc2753b90 | 23 | |
chris | 0:752fc2753b90 | 24 | #ifndef SRF08_H |
chris | 0:752fc2753b90 | 25 | #define SRF08_H |
chris | 0:752fc2753b90 | 26 | |
chris | 0:752fc2753b90 | 27 | #include "mbed.h" |
chris | 0:752fc2753b90 | 28 | |
chris | 0:752fc2753b90 | 29 | //!Library for the SRF08 Ultrasonic Ranger |
chris | 0:752fc2753b90 | 30 | /*! |
chris | 0:752fc2753b90 | 31 | The SRF08 is an Ultrasonic range finder, with an I2C interface that allows the measurement to be read directly in centimetres |
chris | 0:752fc2753b90 | 32 | */ |
chris | 0:752fc2753b90 | 33 | class SRF08 |
chris | 0:752fc2753b90 | 34 | { |
chris | 0:752fc2753b90 | 35 | public: |
chris | 0:752fc2753b90 | 36 | //!Creates an instance of the class. |
chris | 0:752fc2753b90 | 37 | /*! |
chris | 0:752fc2753b90 | 38 | Connect module at I2C address addr using I2C port pins sda and scl. |
chris | 0:752fc2753b90 | 39 | SRF08 |
chris | 0:752fc2753b90 | 40 | */ |
chris | 0:752fc2753b90 | 41 | SRF08(PinName sda, PinName scl, int addr); |
chris | 0:752fc2753b90 | 42 | |
chris | 0:752fc2753b90 | 43 | /*! |
chris | 0:752fc2753b90 | 44 | Destroys instance. |
chris | 0:752fc2753b90 | 45 | */ |
chris | 0:752fc2753b90 | 46 | ~SRF08(); |
chris | 0:752fc2753b90 | 47 | |
chris | 0:752fc2753b90 | 48 | //!Reads the current temperature. |
chris | 0:752fc2753b90 | 49 | /*! |
chris | 0:752fc2753b90 | 50 | Reads the temperature register of the TMP102 and converts it to a useable value. |
chris | 0:752fc2753b90 | 51 | */ |
chris | 0:752fc2753b90 | 52 | float read(); |
chris | 0:752fc2753b90 | 53 | |
chris | 0:752fc2753b90 | 54 | private: |
chris | 0:752fc2753b90 | 55 | I2C m_i2c; |
chris | 0:752fc2753b90 | 56 | int m_addr; |
chris | 0:752fc2753b90 | 57 | |
chris | 0:752fc2753b90 | 58 | }; |
chris | 0:752fc2753b90 | 59 | |
chris | 0:752fc2753b90 | 60 | #endif |