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.
Fork of SOFT253_Template_Weather_OS_54 by
Diff: main.cpp
- Revision:
- 38:e626a358e5e3
- Parent:
- 37:00775e368a71
- Child:
- 39:618ad21e2b34
diff -r 00775e368a71 -r e626a358e5e3 main.cpp
--- a/main.cpp Wed Apr 05 13:50:55 2017 +0000
+++ b/main.cpp Wed Apr 05 14:03:27 2017 +0000
@@ -22,8 +22,12 @@
//Threads
Thread *produceThread;
Thread *measureThread;
+
int count= 0;
-//Class type
+
+//
+// CLASSES
+//
class Measure {
public:
float temperature;
@@ -36,11 +40,65 @@
humidity = h;
pressure = p;
}
+ Measure()
+ {
+ temperature = 0;
+ humidity = 0;
+ pressure = 0;
+ }
};
//Mail queue
Mail<Measure, 16> mail_box;
+class LinkedList{
+
+ struct Node {
+ Measure measure;
+ Node *next;
+ };
+
+public:
+ // constructor
+ LinkedList()
+ {
+
+ head = NULL;
+ }
+
+ void addValueFront(Measure _measure){
+ Node *n = new Node();
+ n->measure = _measure;
+ n->next = head;
+
+ head = n;
+ }
+ void addValueEnd(Measure _measure){
+ Node *n = head;
+ while(n->next != NULL)
+ {
+ n = n->next;
+ }
+ Node *aux = new Node();
+ aux->measure = _measure;
+ aux->next = NULL;
+ n->next = aux;
+
+ }
+
+ Measure popValueFRONT(){
+ Node *n = head;
+ Measure _measure = n->measure;
+
+ head = head->next;
+ delete n;
+ return _measure;
+ }
+
+
+private:
+ Node *head;
+};
// Call this on precise intervals
void MeasureThread() {
