aboutsummaryrefslogtreecommitdiff
path: root/Mussel/Mussel.cpp
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2025-04-02 16:03:49 +0200
committerJonas Smedegaard <dr@jones.dk>2025-04-08 18:10:58 +0200
commit84ec943d6df66f8ca404d7cc0babf0ddbd3dbcbe (patch)
treecd09e2138b9c63785ec5e10ddbcd88c3909cefc6 /Mussel/Mussel.cpp
parent198285497161a6f6f0eeeeb7721bfe68dec48e80 (diff)
add function qualifyVote()
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