aboutsummaryrefslogtreecommitdiff
path: root/Mussel/Mussel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Mussel/Mussel.cpp')
-rw-r--r--Mussel/Mussel.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/Mussel/Mussel.cpp b/Mussel/Mussel.cpp
index 7cd7cf4..67fd10d 100644
--- a/Mussel/Mussel.cpp
+++ b/Mussel/Mussel.cpp
@@ -109,6 +109,9 @@ String Mussel::desc() {
case 6:
_str = "changes state on ON/OFF command";
break;
+ case 10:
+ _str = "handles voting";
+ break;
default:
_str = "undefined [" + static_cast<String>(_attitude) + "]";
break;
@@ -223,6 +226,34 @@ byte Mussel::read() {
return _byte;
}
+/// Function to push data onto the stack
+bool Mussel::push(String id, unsigned long timestamp, int measure) {
+
+ // Check if stack is full
+ if (top >= STACK_SIZE - 1) {
+ Serial.println("Stack Full");
+
+ // Return false if stack is full
+ return false;
+ }
+ top++;
+ idStack[top] = id;
+ timeStack[top] = timestamp;
+ measureStack[top] = measure;
+
+ // Return true on successful push
+ return true;
+}
+
+/// Function to print stack contents
+void Mussel::printStack() {
+ for (int i = top; i >= 0; i--) {
+ Serial.print("ID: "); Serial.print(idStack[i]);
+ Serial.print(", Time: "); Serial.print(timeStack[i]);
+ Serial.print(", measure: "); Serial.println(measureStack[i]);
+ }
+}
+
/// Dump internal variables, formatted for use with Serial Plotter
///
/// @return internal variables as String