Penn Electric Racing / Mbed 2 deprecated REVO_Updated_Steering

Dependencies:   CANBuffer KS0108_fork mbed-rtos mbed CAN Addresses

Fork of REVO_Updated_Steering by Penn Electric

Revision:
35:b42afc973902
diff -r 9a4103f39042 -r b42afc973902 variables.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/variables.h	Sat Nov 22 22:24:53 2014 +0000
@@ -0,0 +1,117 @@
+#include "node.h"
+
+class variables{
+    
+    public:
+    
+        variables();
+        ~variables();
+        void add(int i, int s);
+        int get_screen(int i);
+        char get_value(int i);
+        int set_value(int i, char v);
+        node * get_node(int i);
+        
+    
+        int size;
+        node * head;
+        node * tail;
+
+};
+
+variables::variables(){
+    size = 0;
+    head = NULL;
+    tail = NULL;
+}
+
+variables::~variables(){
+
+    node * curr = head;
+    node * next = head;
+    
+    while(curr != NULL){
+        next = curr->next;
+        delete(curr);
+        curr = next;
+    }
+    
+    head =  NULL;
+    tail = NULL;
+    size = 0;
+}
+
+void variables::add(int i, int s){
+    
+    if(head == NULL){
+        head = new node(i, s);
+        tail = head;
+    }
+    
+    else{
+        tail->next = new node(i,s);
+        tail = tail->next;
+    }
+    size++;
+}
+
+node * variables::get_node(int i){
+
+    node * curr = head;
+    
+    while(curr != NULL){
+        if(curr->id == i){
+            return curr;
+        }
+        else{
+            curr = curr->next;
+        }
+    }
+    return NULL;
+}    
+
+int variables::get_screen(int i){
+
+    node * curr = head;
+    
+    while(curr != NULL){
+        if(curr->id == i){
+            return curr->screen;
+        }
+        else{
+            curr = curr->next;
+        }
+    }
+    return -1;
+}
+
+int variables::set_value(int i, char v){
+
+    node * curr = head;
+    
+    while(curr != NULL){
+        if(curr->id == i){
+            curr->set_val(v);
+            return 0;
+        }
+        else{
+            curr = curr->next;
+        }
+    }
+    return -1;
+}
+
+char variables::get_value(int i){
+
+    node * curr = head;
+    
+    while(curr != NULL){
+        if(curr->id == i){
+            return curr->value;
+        }
+        else{
+            curr = curr->next;
+        }
+    }
+    return 0;
+}
\ No newline at end of file