reading internal temperature sensor of arch max and storing data

Files at this revision

API Documentation at this revision

Comitter:
tifo
Date:
Thu Sep 14 16:44:10 2017 +0000
Parent:
2:e09214e03a1b
Commit message:
another version

Changed in this revision

TempData.cpp Show annotated file Show diff for this revision Revisions of this file
TempData.h Show annotated file Show diff for this revision Revisions of this file
diff -r e09214e03a1b -r e98dbcd4f4e3 TempData.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TempData.cpp	Thu Sep 14 16:44:10 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
diff -r e09214e03a1b -r e98dbcd4f4e3 TempData.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TempData.h	Thu Sep 14 16:44:10 2017 +0000
@@ -0,0 +1,19 @@
+#ifndef TEMPDATA_H
+#define TEMPDATA_H
+ 
+#include "TempData.h"
+ 
+class TempData
+{
+  public:
+    TempData();
+    void PushData(float);
+    float  PopData();
+    float  GetData(int);
+    int GetCount();
+  private:
+    int _count;
+    float _buffer[10];
+};
+ 
+#endif