diff options
author | Jonas Smedegaard <dr@jones.dk> | 2025-04-02 16:03:49 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2025-04-08 18:10:58 +0200 |
commit | 84ec943d6df66f8ca404d7cc0babf0ddbd3dbcbe (patch) | |
tree | cd09e2138b9c63785ec5e10ddbcd88c3909cefc6 /Mussel/Mussel.cpp | |
parent | 198285497161a6f6f0eeeeb7721bfe68dec48e80 (diff) |
add function qualifyVote()
Diffstat (limited to 'Mussel/Mussel.cpp')
-rw-r--r-- | Mussel/Mussel.cpp | 23 |
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 |