Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP
Fork of SystemManagement by
Diff: TemperatureRead/TemperatureRead.cpp
- Revision:
- 18:915a235bc099
- Parent:
- 17:c9ce210f6654
- Child:
- 19:3a817d2cef11
diff -r c9ce210f6654 -r 915a235bc099 TemperatureRead/TemperatureRead.cpp
--- a/TemperatureRead/TemperatureRead.cpp Sat Oct 25 03:28:55 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-#include "TemperatureRead.h"
-
-TemperatureRead::TemperatureRead(PinName pin, struct TempTable _table) : ana(pin) {
- usingAna = true;
- table = _table;
- temperature = 0;
-}
-TemperatureRead::TemperatureRead(struct TempTable _table) {
- usingAna = false;
- table = _table;
- temperature = 0;
-}
-
-float TemperatureRead::convert(float in) {
- if (in < table.input[0]) { temperature = -INFINITY; return temperature; } // Out of range of the table
- if (in > table.input[table.numEntries-1]) { temperaure = -INFINITY; return temperature; } // Out of range of the table
- int lowerIndex = 0;
- int upperIndex = table.numEntries-1;
- for (int i = 0; i < table.numEntries; i++) { // Converge on the entries that surround the input
- if (in >= table.input[lowerIndex]) { lowerIndex = i; }
- if (in <= table.input[upperIndex]) { upperIndex = table.numEntries-1 - i; }
- }
- // Interpolate and return
- temperature = table.output[lowerIndex] + (table.output[upperIndex] - table.output[lowerIndex]) * ((in - table.input[lowerIndex]) / (table.input[upperIndex] - table.input[lowerIndex]));
- return temperature;
-}
-float TemperatureRead::read() {
- if (!usingAna) { temperature = 0; return temperature;
- else return convert(ana.read());
-}
\ No newline at end of file
