Core Base Classes for the Light Endpoints
Dependents: mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_ethernet ... more
MBEDTemperature.cpp@192:54b758a8eaaa, 2014-09-26 (annotated)
- Committer:
- ansond
- Date:
- Fri Sep 26 05:16:07 2014 +0000
- Revision:
- 192:54b758a8eaaa
- Parent:
- 158:0cecb265bb18
updates to new logger name
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ansond | 36:73e343ddca7f | 1 | /* Copyright C2013 Doug Anson, MIT License |
ansond | 36:73e343ddca7f | 2 | * |
ansond | 36:73e343ddca7f | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
ansond | 36:73e343ddca7f | 4 | * and associated documentation files the "Software", to deal in the Software without restriction, |
ansond | 36:73e343ddca7f | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
ansond | 36:73e343ddca7f | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
ansond | 36:73e343ddca7f | 7 | * furnished to do so, subject to the following conditions: |
ansond | 36:73e343ddca7f | 8 | * |
ansond | 36:73e343ddca7f | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
ansond | 36:73e343ddca7f | 10 | * substantial portions of the Software. |
ansond | 36:73e343ddca7f | 11 | * |
ansond | 36:73e343ddca7f | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
ansond | 36:73e343ddca7f | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
ansond | 36:73e343ddca7f | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
ansond | 36:73e343ddca7f | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
ansond | 36:73e343ddca7f | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
ansond | 36:73e343ddca7f | 17 | */ |
ansond | 36:73e343ddca7f | 18 | |
ansond | 36:73e343ddca7f | 19 | #include "mbed.h" |
ansond | 36:73e343ddca7f | 20 | |
ansond | 129:6209164ec6cd | 21 | // Definitions |
ansond | 129:6209164ec6cd | 22 | #include "Definitions.h" |
ansond | 129:6209164ec6cd | 23 | |
ansond | 36:73e343ddca7f | 24 | // MBED temperature sensor |
ansond | 36:73e343ddca7f | 25 | #include "LM75B.h" |
ansond | 128:fde8d042a9af | 26 | LM75B temp_sensor(TEMP_SENSOR_PIN1,TEMP_SENSOR_PIN2); |
ansond | 36:73e343ddca7f | 27 | |
ansond | 36:73e343ddca7f | 28 | #include "MBEDTemperature.h" |
ansond | 158:0cecb265bb18 | 29 | |
ansond | 158:0cecb265bb18 | 30 | // Multitech temp probe: if used, probe the LM75B once only... the multitech unit will drive future temp updates... |
ansond | 158:0cecb265bb18 | 31 | #ifdef MULTITECH_TEMP_PROBE |
ansond | 158:0cecb265bb18 | 32 | bool oneshot = false; |
ansond | 158:0cecb265bb18 | 33 | #endif |
ansond | 36:73e343ddca7f | 34 | |
ansond | 36:73e343ddca7f | 35 | // default constructor |
ansond | 192:54b758a8eaaa | 36 | MBEDTemperature::MBEDTemperature(Logger *logger,Resource *resource) : MBEDio(logger,resource) { |
ansond | 36:73e343ddca7f | 37 | } |
ansond | 36:73e343ddca7f | 38 | |
ansond | 36:73e343ddca7f | 39 | // destructor |
ansond | 36:73e343ddca7f | 40 | MBEDTemperature::~MBEDTemperature() { |
ansond | 36:73e343ddca7f | 41 | } |
ansond | 36:73e343ddca7f | 42 | |
ansond | 36:73e343ddca7f | 43 | // update our value |
ansond | 36:73e343ddca7f | 44 | void MBEDTemperature::update() { |
ansond | 158:0cecb265bb18 | 45 | #ifdef MULTITECH_TEMP_PROBE |
ansond | 158:0cecb265bb18 | 46 | if (!oneshot) { if (this->resource() != NULL && this->resource()->getValuePointer() != NULL) sprintf(this->resource()->getValuePointer(),"%.1f",temp_sensor.read()); oneshot = true; } |
ansond | 158:0cecb265bb18 | 47 | #else |
ansond | 135:7f3f963cd159 | 48 | if (this->resource() != NULL && this->resource()->getValuePointer() != NULL) sprintf(this->resource()->getValuePointer(),"%.1f",temp_sensor.read()); |
ansond | 158:0cecb265bb18 | 49 | #endif |
ansond | 36:73e343ddca7f | 50 | } |