diff options
-rw-r--r-- | vote/vote.ino | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/vote/vote.ino b/vote/vote.ino index a805ea6..caa4fbc 100644 --- a/vote/vote.ino +++ b/vote/vote.ino @@ -53,9 +53,9 @@ struct Vote { }; struct Voter { - String id; // Mussel ID - Vote votes[BALLOT_MAX]; // Last 5 sensor readings - int voteCount = 0; // Number of readings stored + String id; // Mussel ID + Vote votes[BALLOT_MAX]; // Last 5 sensor readings + int voteCount = 0; // Number of readings stored }; // Global array of mussel voters @@ -74,7 +74,9 @@ int findVoterIndex(const String& id) { } /// Add or update vote for a mussel ID -void storeVoteForMussel(const String& id, unsigned long timestamp, int gape_measure) { +void storeVoteForMussel( + const String& id, unsigned long timestamp, int gape_measure +) { int index = findVoterIndex(id); // If mussel not found, add new @@ -119,9 +121,11 @@ void alignVotes() { // Use latest vote to determine state Vote latest = voter.votes[voter.voteCount - 1]; - String state = (latest.measure >= 0 && latest.measure < 40) ? "Closed" : - (latest.measure >= 40 && latest.measure <= 90) ? "Open" : - "Invalid reading"; + String state = (latest.measure >= 0 && latest.measure < 40) + ? "Closed" + : (latest.measure >= 40 && latest.measure <= 90) + ? "Open" + : "Invalid reading"; log_i("Mussel ID: %s | Latest Gape: %d | State: %s", voter.id.c_str(), latest.measure, state.c_str()); @@ -129,7 +133,9 @@ void alignVotes() { } /// Decide whether a vote is valid based on gape and age -const char* qualifyMusselVote(int gape, unsigned long voteTimestamp, unsigned long now) { +const char* qualifyMusselVote( + int gape, unsigned long voteTimestamp, unsigned long now +) { // Determine state based on gape MusselGapState gapState = gape >= 40 && gape <= 90 ? Open : Closed; @@ -190,7 +196,7 @@ class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks { unsigned long now = millis(); String musselID = advertisedDevice.getName(); - int gape = EddystoneTLM.getTemp(); // Referring to gape_measure + int gape = EddystoneTLM.getTemp(); // 1. Store vote storeVoteForMussel(musselID, now, gape); |