minimize time to trinket is opened
[trinked.git] / main.c
diff --git a/main.c b/main.c
index 4552672..ff77ec5 100644 (file)
--- a/main.c
+++ b/main.c
@@ -75,8 +75,6 @@ main_loop() {
                return;
        }
 
-       collected = 0;
-
        while(42) {
 
                if (trinketOpen() != ERR_OK) {
@@ -92,6 +90,8 @@ main_loop() {
                        continue;
                }
 
+               trinketClose();
+
                if (collected <= tics) {
                        prevDose[collected++] = curDose;
                } else {
@@ -128,7 +128,6 @@ main_loop() {
                        }
                }
 
-               trinketClose();
                sleep(period);
        }
 }