diff options
author | Jonas Smedegaard <dr@jones.dk> | 2025-04-17 00:00:04 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2025-04-17 00:00:04 +0200 |
commit | 410a67b51d58ef3373ddfd9cfa08589a462cb046 (patch) | |
tree | 20023772d2157f849b058a525014d1fc89a1481f /vote | |
parent | babebedcb6ec82bc53424b567a45f843745c8b87 (diff) |
rephrase comments and log strings to clarify vote -> ballot common confusion
Diffstat (limited to 'vote')
-rw-r--r-- | vote/vote.ino | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/vote/vote.ino b/vote/vote.ino index 9eea591..e658f0b 100644 --- a/vote/vote.ino +++ b/vote/vote.ino @@ -72,7 +72,7 @@ int findVoterIndex(const String& id) { return -1; // Not found } -/// Add or update vote for a mussel ID +/// Add or update data for a mussel voting ballot void collectBallotData( const String& id, unsigned long timestamp, int gape_measure ) { @@ -92,7 +92,7 @@ void collectBallotData( Voter &voter = voters[index]; - // Maintain a fixed number of stored votes (FIFO logic) + // Maintain a fixed number of stored ballots (FIFO logic) if (voter.voteCount >= BALLOT_MAX) { for (int i = 1; i < BALLOT_MAX; i++) { voter.votes[i - 1] = voter.votes[i]; @@ -100,13 +100,13 @@ void collectBallotData( voter.voteCount = BALLOT_MAX - 1; } - // Store the new vote at the end + // Store the new draft ballot at the end voter.votes[voter.voteCount++] = {timestamp, gape_measure}; log_i("Vote stored: Time: %lu, Mussel: %s, Gape: %d", timestamp, id.c_str(), gape_measure); } -/// Clean outdated votes and mussels with no valid votes +/// Clean outdated voting ballots and mussels with no valid ballots void cleanOldBallotData() { unsigned long now = millis(); @@ -114,23 +114,23 @@ void cleanOldBallotData() { Voter &voter = voters[i]; int newCount = 0; - // Shift valid votes to the front + // Shift valid ballots to the front for (int j = 0; j < voter.voteCount; j++) { unsigned long age = now - voter.votes[j].timestamp; if (age < VOTE_TIME_TOLERANCE) { voter.votes[newCount++] = voter.votes[j]; } else { - log_i("Dropped old vote for Mussel %s | Age: %lu ms", + log_i("Dropped old ballot for Mussel %s (age: %lums)", voter.id.c_str(), age); } } voter.voteCount = newCount; - // If all votes are dropped, remove the mussel + // If all ballots are dropped, remove the mussel if (voter.voteCount == 0) { - log_i("Removing Mussel %s - No valid votes left", + log_i("Removing Mussel %s - No valid ballots left", voter.id.c_str()); for (int k = i; k < voterCount - 1; k++) { @@ -169,24 +169,24 @@ void alignVotes() { } } -/// Decide whether a vote is valid based on age +/// Decide whether a voting ballot is valid based on age const char* qualifyBallot( unsigned long voteTimestamp, unsigned long now ) { unsigned long age = now - voteTimestamp; if (age <= VOTE_TIME_TOLERANCE) { - log_i("VALID: Vote is within 1 minute (age: %lums)", + log_i("VALID: Ballot is within 1 minute (age: %lums)", age); return "valid"; } else { - log_i("INVALID: Vote is older than 1 minute (age: %lums)", + log_i("INVALID: Ballot is older than 1 minute (age: %lums)", age); return "invalid"; } } -/// Output the final vote decision for mussels +/// Resolve the outcome of the voting procedure void concludeVote() { int openVotes = 0; int totalValidVotes = 0; @@ -284,7 +284,7 @@ void loop() { alignVotes(); concludeVote(); - cleanOldBallotData(); // Keeps the voter stack tidy + cleanOldBallotData(); // Tidy the voter stack delay(500); } |