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
MBEDVoltage.cpp@103:4b97555bbdfa, 2014-03-15 (annotated)
- Committer:
- ansond
- Date:
- Sat Mar 15 05:57:21 2014 +0000
- Revision:
- 103:4b97555bbdfa
- Parent:
- 52:f0b4710c43f9
- Child:
- 128:fde8d042a9af
updates
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 | 36:73e343ddca7f | 21 | #include "MBEDVoltage.h" |
ansond | 36:73e343ddca7f | 22 | |
ansond | 36:73e343ddca7f | 23 | // Voltage Simulator |
ansond | 36:73e343ddca7f | 24 | AnalogIn voltage_pot(p19); |
ansond | 36:73e343ddca7f | 25 | |
ansond | 36:73e343ddca7f | 26 | // default constructor |
ansond | 36:73e343ddca7f | 27 | MBEDVoltage::MBEDVoltage(ErrorHandler *error_handler,Resource *resource) : MBEDio(error_handler,resource) { |
ansond | 36:73e343ddca7f | 28 | } |
ansond | 36:73e343ddca7f | 29 | |
ansond | 36:73e343ddca7f | 30 | // destructor |
ansond | 36:73e343ddca7f | 31 | MBEDVoltage::~MBEDVoltage() { |
ansond | 36:73e343ddca7f | 32 | } |
ansond | 36:73e343ddca7f | 33 | |
ansond | 36:73e343ddca7f | 34 | // update our value |
ansond | 36:73e343ddca7f | 35 | void MBEDVoltage::update() { |
ansond | 52:f0b4710c43f9 | 36 | float voltage = voltage_pot.read() * 120.0; // Scale 0V - 120V |
ansond | 103:4b97555bbdfa | 37 | if (this->m_resource != NULL && this->m_resource->getValuePointer() != NULL) sprintf(this->m_resource->getValuePointer(),"%.1f",voltage); |
ansond | 36:73e343ddca7f | 38 | } |