Seeed Grove Temperature sensor component library
Dependents: Hello-grove-temperature-sensor Wio_3G_HTTP-POST-example Wio_3G_example sgam-lib ... more
Grove_temperature.h@1:aee37a51ccbb, 2018-08-06 (annotated)
- Committer:
- MACRUM
- Date:
- Mon Aug 06 09:24:54 2018 +0000
- Revision:
- 1:aee37a51ccbb
- Parent:
- 0:d4056a86ef8c
Code clean up
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MACRUM | 0:d4056a86ef8c | 1 | /** |
MACRUM | 0:d4056a86ef8c | 2 | ****************************************************************************** |
MACRUM | 0:d4056a86ef8c | 3 | * @file Grove_temperature.h |
MACRUM | 0:d4056a86ef8c | 4 | * @author Toyomasa Watarai |
MACRUM | 0:d4056a86ef8c | 5 | * @version V1.0.0 |
MACRUM | 0:d4056a86ef8c | 6 | * @date 6 Aug 2018 |
MACRUM | 0:d4056a86ef8c | 7 | * @brief This file contains the class of a grove temperature sensor with AnalogIn interface |
MACRUM | 0:d4056a86ef8c | 8 | ****************************************************************************** |
MACRUM | 0:d4056a86ef8c | 9 | * @attention |
MACRUM | 0:d4056a86ef8c | 10 | * |
MACRUM | 0:d4056a86ef8c | 11 | * Licensed under the Apache License, Version 2.0 (the "License"); |
MACRUM | 0:d4056a86ef8c | 12 | * you may not use this file except in compliance with the License. |
MACRUM | 0:d4056a86ef8c | 13 | * You may obtain a copy of the License at |
MACRUM | 0:d4056a86ef8c | 14 | * |
MACRUM | 0:d4056a86ef8c | 15 | * http://www.apache.org/licenses/LICENSE-2.0 |
MACRUM | 0:d4056a86ef8c | 16 | * |
MACRUM | 0:d4056a86ef8c | 17 | * Unless required by applicable law or agreed to in writing, software |
MACRUM | 0:d4056a86ef8c | 18 | * distributed under the License is distributed on an "AS IS" BASIS, |
MACRUM | 0:d4056a86ef8c | 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
MACRUM | 0:d4056a86ef8c | 20 | * See the License for the specific language governing permissions and |
MACRUM | 0:d4056a86ef8c | 21 | * limitations under the License. |
MACRUM | 0:d4056a86ef8c | 22 | */ |
MACRUM | 1:aee37a51ccbb | 23 | |
MACRUM | 1:aee37a51ccbb | 24 | |
MACRUM | 0:d4056a86ef8c | 25 | #ifndef MBED_GROVE_TEMPERATURE_H |
MACRUM | 0:d4056a86ef8c | 26 | #define MBED_GROVE_TEMPERATURE_H |
MACRUM | 1:aee37a51ccbb | 27 | |
MACRUM | 0:d4056a86ef8c | 28 | #include "mbed.h" |
MACRUM | 1:aee37a51ccbb | 29 | |
MACRUM | 0:d4056a86ef8c | 30 | /** Interface for controlling grove temerature sensor |
MACRUM | 0:d4056a86ef8c | 31 | * |
MACRUM | 0:d4056a86ef8c | 32 | * @code |
MACRUM | 0:d4056a86ef8c | 33 | * #include "mbed.h" |
MACRUM | 0:d4056a86ef8c | 34 | * #include "Grove_temperature.h" |
MACRUM | 0:d4056a86ef8c | 35 | * |
MACRUM | 0:d4056a86ef8c | 36 | * Serial pc(USBTX, USBRX); |
MACRUM | 0:d4056a86ef8c | 37 | * Grove_temperature temp(A4); |
MACRUM | 0:d4056a86ef8c | 38 | * |
MACRUM | 0:d4056a86ef8c | 39 | * int main() { |
MACRUM | 0:d4056a86ef8c | 40 | * |
MACRUM | 0:d4056a86ef8c | 41 | * while(1) { |
MACRUM | 0:d4056a86ef8c | 42 | * pc.printf("%2.2f degC\n", sensor.getTemperature()); |
MACRUM | 0:d4056a86ef8c | 43 | * wait(1); |
MACRUM | 0:d4056a86ef8c | 44 | * } |
MACRUM | 0:d4056a86ef8c | 45 | * } |
MACRUM | 0:d4056a86ef8c | 46 | * |
MACRUM | 0:d4056a86ef8c | 47 | * @endcode |
MACRUM | 0:d4056a86ef8c | 48 | */ |
MACRUM | 1:aee37a51ccbb | 49 | |
MACRUM | 0:d4056a86ef8c | 50 | /** Grove_temperature class |
MACRUM | 0:d4056a86ef8c | 51 | * |
MACRUM | 0:d4056a86ef8c | 52 | * Grove_temperature: A library to correct data using Seeed Grove temperature sensor device |
MACRUM | 0:d4056a86ef8c | 53 | * |
MACRUM | 0:d4056a86ef8c | 54 | */ |
MACRUM | 0:d4056a86ef8c | 55 | class Grove_temperature |
MACRUM | 0:d4056a86ef8c | 56 | { |
MACRUM | 0:d4056a86ef8c | 57 | public: |
MACRUM | 1:aee37a51ccbb | 58 | |
MACRUM | 0:d4056a86ef8c | 59 | /** Create a Grove_temperature instance |
MACRUM | 0:d4056a86ef8c | 60 | * which is connected to specified AnalogIn pins |
MACRUM | 0:d4056a86ef8c | 61 | * |
MACRUM | 0:d4056a86ef8c | 62 | * @param ain AnalogIn pin |
MACRUM | 0:d4056a86ef8c | 63 | */ |
MACRUM | 0:d4056a86ef8c | 64 | Grove_temperature(PinName ain); |
MACRUM | 1:aee37a51ccbb | 65 | |
MACRUM | 0:d4056a86ef8c | 66 | /** Destructor of Grove_temperature |
MACRUM | 0:d4056a86ef8c | 67 | */ |
MACRUM | 0:d4056a86ef8c | 68 | virtual ~Grove_temperature(); |
MACRUM | 1:aee37a51ccbb | 69 | |
MACRUM | 1:aee37a51ccbb | 70 | |
MACRUM | 0:d4056a86ef8c | 71 | /** Read the current temperature value (degree Celsius) from Grove temperature sensor |
MACRUM | 0:d4056a86ef8c | 72 | * |
MACRUM | 0:d4056a86ef8c | 73 | * @return Temperature value (degree Celsius) |
MACRUM | 0:d4056a86ef8c | 74 | */ |
MACRUM | 0:d4056a86ef8c | 75 | float getTemperature(void); |
MACRUM | 1:aee37a51ccbb | 76 | |
MACRUM | 1:aee37a51ccbb | 77 | |
MACRUM | 0:d4056a86ef8c | 78 | private: |
MACRUM | 1:aee37a51ccbb | 79 | |
MACRUM | 0:d4056a86ef8c | 80 | AnalogIn _ain; |
MACRUM | 1:aee37a51ccbb | 81 | |
MACRUM | 0:d4056a86ef8c | 82 | }; |
MACRUM | 1:aee37a51ccbb | 83 | |
MACRUM | 0:d4056a86ef8c | 84 | #endif // MBED_GROVE_TEMPERATURE_H |