aboutsummaryrefslogtreecommitdiff
path: root/vote
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2025-04-16 23:00:29 +0200
committerJonas Smedegaard <dr@jones.dk>2025-04-16 23:00:29 +0200
commit0b595c44705a2587cc139ca922ee5c0804fc026c (patch)
tree6b54859dcee133e264977bad41888bf4b0c6508b /vote
parentfb48424cadc57170d39de0ac0b0450f373ef74fc (diff)
tidy whitespace; shorten comments and log strings
Diffstat (limited to 'vote')
-rw-r--r--vote/vote.ino15
1 files changed, 8 insertions, 7 deletions
diff --git a/vote/vote.ino b/vote/vote.ino
index 6d63b71..ab47e38 100644
--- a/vote/vote.ino
+++ b/vote/vote.ino
@@ -106,7 +106,7 @@ void storeVoteForMussel(
timestamp, id.c_str(), gape_measure);
}
-/// Clean outdated votes from each mussel and remove mussels with no valid votes
+/// Clean outdated votes and mussels with no valid votes
void cleanOldVotes() {
unsigned long now = millis();
@@ -130,7 +130,8 @@ void cleanOldVotes() {
// If all votes are dropped, remove the mussel
if (voter.voteCount == 0) {
- log_i("Removing Mussel %s - No valid votes left", voter.id.c_str());
+ log_i("Removing Mussel %s - No valid votes left",
+ voter.id.c_str());
for (int k = i; k < voterCount - 1; k++) {
voters[k] = voters[k + 1];
@@ -201,7 +202,7 @@ void concludeMusselVote() {
// Use latest vote to determine state
Vote latest = voter.votes[voter.voteCount - 1];
unsigned long now = millis();
-
+
// Check if the vote is valid using the qualify function
const char* validity = qualifyMusselVote(latest.timestamp, now);
@@ -225,12 +226,12 @@ void concludeMusselVote() {
// Determine the threshold (half of total valid votes, rounded down)
int threshold = totalValidVotes / 2;
- // If the number of "Open" votes is greater than or equal to the threshold, water is drinkable
+ // Same or more "Open" votes than the threshold means water is ok
if (openVotes >= threshold) {
- log_i("Final Vote: YES (Water is drinkable) - Open Votes: %d, Total Valid Votes: %d",
+ log_i("YES, water is drinkable (open: %d, valid: %d)",
openVotes, totalValidVotes);
} else {
- log_i("Final Vote: NO (Water is not drinkable) - Open Votes: %d, Total Valid Votes: %d",
+ log_i("NO, water is not drinkable (open: %d, valid: %d)",
openVotes, totalValidVotes);
}
}
@@ -281,7 +282,7 @@ void setup() {
// setup Bluetooth
BLEDevice::init("");
pBLEScan = BLEDevice::getScan();
- pBLEScan->setAdvertisedDeviceCallbacks(
+ pBLEScan->setAdvertisedDeviceCallbacks(
new MyAdvertisedDeviceCallbacks());
pBLEScan->setActiveScan(true);
pBLEScan->setInterval(SCAN_INTERVAL);