aboutsummaryrefslogtreecommitdiff
path: root/Mussel/Mussel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Mussel/Mussel.cpp')
-rw-r--r--Mussel/Mussel.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/Mussel/Mussel.cpp b/Mussel/Mussel.cpp
index 568030a..1d5c2b0 100644
--- a/Mussel/Mussel.cpp
+++ b/Mussel/Mussel.cpp
@@ -258,6 +258,29 @@ void Mussel::printStack() {
}
}
+bool qualifyVote(Vote vote, unsigned long currentTime) {
+
+ // If the measure is 42 (YES), check timestamp validity
+ if (vote.measure == 42) {
+ // If the vote's timestamp is within 1 minute, count it as YES
+ if (currentTime - vote.timestamp <= MUSSEL_VOTE_TIME_AHEAD) {
+ return true;
+ }
+ // If the vote's timestamp is older than 2 minutes, count it as NO
+ else if (currentTime - vote.timestamp > MUSSEL_VOTE_TIME_BEHIND) {
+ return false;
+ }
+ }
+
+ // If the measure is 2, always count the vote as NO
+ if (vote.measure == 2) {
+ return false;
+ }
+
+ // Default case: vote is invalid if no conditions are met
+ return false;
+}
+
/// Dump internal variables, formatted for use with Serial Plotter
///
/// @return internal variables as String