From a8b247bb0e80c70bd7a7f3ba93cb697c99401e4f Mon Sep 17 00:00:00 2001 From: Daniel Kao Date: Sat, 16 Nov 2019 03:57:33 -0800 Subject: [PATCH] Change polling interval to a regular 1ms Motion burst + analog reads takes around 408us. The total 408us + 870us wait doesn't seem necessary. --- firmware/production/production.ino | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/firmware/production/production.ino b/firmware/production/production.ino index fb31de4..1350e0f 100644 --- a/firmware/production/production.ino +++ b/firmware/production/production.ino @@ -416,12 +416,13 @@ void loop() { } byte burstBuffer[12]; - unsigned long elapsed = micros() - lastTS; + unsigned long curTime = micros(); + unsigned long elapsed = curTime - lastTS; checkButtonState(); // polling interval : more than > 0.5 ms. - if (elapsed > 870) { // 870...whut? + if (elapsed >= 1000) { adnsComBegin(); SPI.beginTransaction(SPISettings(SPIMAXIMUMSPEED, MSBFIRST, SPI_MODE3)); @@ -460,6 +461,6 @@ void loop() { dy = 0; } - lastTS = micros(); + lastTS = curTime; } }