reading internal temperature sensor of arch max and storing data
Diff: TempData.cpp
- Revision:
- 1:b5ed50f9a06b
diff -r 62f36500cd41 -r b5ed50f9a06b TempData.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TempData.cpp Thu Sep 14 15:26:19 2017 +0000 @@ -0,0 +1,36 @@ +#include "TempData.h" + +TempData::TempData() +{ + _count = 0; +} + + // push value +void TempData::PushData(float data) +{ + _buffer[_count] = data; // store data and increment counter + _count++; +} + + // pop value. return either top value, or -999 as error code +float TempData::PopData() +{ + if(_count) // check if buffer not empty + { + _count--; + return _buffer[_count]; // return value + } + return -999; +} + +// get value by index +float TempData::GetData(int index) +{ + return _buffer[index]; // return value +} + +// get number of stored measurings +int TempData::GetCount() +{ + return _count; +} \ No newline at end of file