ECE 4180 - Final Project Team / Mbed 2 deprecated WalkieTalkie

Dependencies:   mbed 4DGL-uLCD-SE mbed-rtos nRF24L01P

Revision:
20:e068469ffb89
Parent:
17:604f9c4bd6d3
Child:
29:0c6f3c0c992a
--- a/CircularBuf.h	Fri Apr 20 16:12:01 2018 +0000
+++ b/CircularBuf.h	Fri Apr 20 18:39:20 2018 +0000
@@ -1,17 +1,39 @@
-template <class T>
-class CircularBuff {
+#pragma once
+// Simple "queue" type data structure
+// Data is pushed onto the queue to add it to the FIFO buffer
+// It is then popped off the queue to remove it from the FIFO buffer
+// (It really should be enqueue and dequeue, but it's too late now)
+//
+// The circular buffer uses an array as the base and acts just like the name
+// suggests
+// You can push data on one side and remove from the other
+// As you add and remove data, the location of the data "moves" around the circle
+// https://en.wikipedia.org/wiki/Circular_buffer
+
+template <typename T>
+class CircularBuf {
 public:
     // Arguement:
     //          size, The size of the underlying array to use
-    CircularBuff(unsigned int size);
-    ~CircularBuff();
+    CircularBuf(unsigned int size);
+    ~CircularBuf();
     
     // Pushes data onto the buffer
+    // (Adds data to the buffer)
     // Arguement:
-    //          data, The array of data to push
+    //          data, The array of data to add
     //          size, The amount of data in the array
     // Return:
     //          Amount of data actually written
+    //
+    // Example Code:
+    //
+    // int dataToAdd[2];
+    // dataToAdd[0] = 15;
+    // dataToAdd[1] = 23;
+    // buffer.push(dataToAdd, 2);
+    //
+    // buffer now contains [15, 23]
     unsigned int push(T* data, unsigned int size);
     
     
@@ -21,6 +43,13 @@
     //          size, The amount of data to pop
     // Return:
     //          Amount of data actually popped
+    //
+    // Example Code:
+    //
+    // int dataToRemove[2];
+    // buffer.pop(dataToRemove, 2);
+    //
+    // dataToRemove now contains the 2 oldest values that were in buffer
     unsigned int pop(T* data, unsigned int size);
     
     // Amount of data in the buffer