From 40910f9bac151bfd4ffbf06f1e80fdc7660dd827 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Wed, 16 Apr 2025 19:25:06 +0200 Subject: fix plot-friendly output --- vote/vote.ino | 39 +++++++++------------------------------ 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/vote/vote.ino b/vote/vote.ino index e695806..6cfca11 100644 --- a/vote/vote.ino +++ b/vote/vote.ino @@ -42,21 +42,6 @@ struct Vote { int measure; }; -bool push(String id, unsigned long timestamp, int measure); -void printStack(); -bool qualifyVote(Vote vote, unsigned long currentTime); - -int _attitude; -int _pin; -bool _boolState; -byte _count; -unsigned long _time; - -// Array to store ID strings -String idStack[STACK_SIZE]; -unsigned long timeStack[STACK_SIZE]; -int measureStack[STACK_SIZE]; - // Index of the top element in the stack, -1 means stack is empty int top = -1; @@ -74,6 +59,15 @@ class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks { && advertisedDevice.getFrameType() == BLE_EDDYSTONE_TLM_FRAME ) { BLEEddystoneTLM EddystoneTLM(&advertisedDevice); + + // misuse error-only log level for plot-friendly output +#if ARDUHAL_LOG_LEVEL == ARDUHAL_LOG_LEVEL_ERROR + String id_mangled = advertisedDevice.getName(); + id_mangled.replace(' ', '_'); + id_mangled.replace(':', '='); + Serial.println(id_mangled + ":" + EddystoneTLM.getTemp()); +#endif + push( advertisedDevice.getName(), millis(), @@ -102,15 +96,6 @@ bool push(String id, unsigned long timestamp, int measure) { return true; } -/// Function to print stack contents -void printStack() { - for (int i = top; i >= 0; i--) { - Serial.print("ID: "); Serial.print(idStack[i]); - Serial.print(", Time: "); Serial.print(timeStack[i]); - Serial.print(", measure: "); Serial.println(measureStack[i]); - } -} - bool qualifyVote(Vote vote, unsigned long currentTime) { // If the measure is 42 (YES), check timestamp validity @@ -154,11 +139,5 @@ void loop() { BLEScanResults *foundDevices = pBLEScan->start(scanTime, false); pBLEScan->clearResults(); - // misuse error-only log level for plot-friendly output -#if ARDUHAL_LOG_LEVEL == ARDUHAL_LOG_LEVEL_ERROR - Serial.printf("pin:%d boolState:%d time:%d count:%d\n", - _pin, _boolState, _time, _count); -#endif - delay(500); } -- cgit v1.2.3