PH test
Fork of LinearAnalogSensors by
Revision 3:c749fbcf2acb, committed 2016-08-11
- Comitter:
- Dengjj
- Date:
- Thu Aug 11 14:14:49 2016 +0000
- Parent:
- 2:989048937c77
- Commit message:
- working for PH test
Changed in this revision
LinearTemp.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/LinearTemp.cpp Sun Dec 23 07:32:24 2012 +0000 +++ b/LinearTemp.cpp Thu Aug 11 14:14:49 2016 +0000 @@ -27,6 +27,7 @@ _multiplier = (temp2 - temp1) / (read2 - read1); // Calculate multiplier as slope _offset = temp1 - (_multiplier * read1); // Calculate offset } + // Constructor using user defined multiplier and offset LinearTemp::LinearTemp(PinName pin, float multiplier, float offset):_pin(pin) { _temp = 0.0; // Zero the temperature @@ -36,6 +37,7 @@ // Populates an array with temperature readings, sorts, and returns median float LinearTemp::readTemp() { + /* _tempArr[0] = _pin.read_u16(); for (int i = 1; i < 9; i++) { _tempArr[i] = _pin.read_u16(); @@ -47,7 +49,10 @@ } _tempArr[j + 1] = tmp; } - _temp = (_tempArr[4] * _multiplier) + _offset; + //_temp = (_tempArr[4] * _multiplier) + _offset; + */ + _temp = (float)_pin.read_u16(); + _temp = _temp*3/(16*4096); return _temp; } // Returns last calculated temperature value