From 1e00ba8dc0284356ee6af680b4fbb90e45b9d847 Mon Sep 17 00:00:00 2001 From: philipp schoenberger Date: Fri, 28 Sep 2018 20:23:54 +0200 Subject: [PATCH] possible timing fix --- Multiprotocol/Multiprotocol.ino | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Multiprotocol/Multiprotocol.ino b/Multiprotocol/Multiprotocol.ino index 8b6b29d..3827bd4 100644 --- a/Multiprotocol/Multiprotocol.ino +++ b/Multiprotocol/Multiprotocol.ino @@ -383,7 +383,16 @@ void loop() //debugln("diff = %d", update_end - update_start); //next_abs_call = last_call + next_callback; - delayMilliseconds(next_callback / 1000); + + #if 0 + { // next_callback should not be more than 32767 so we will wait here... + uint16_t temp=(next_callback>>10)-2; + delayMilliseconds(temp); + next_callback-=temp<<10; // between 2-3ms left at this stage + } + #else + delayMicroseconds(next_callback); + #endif } while(diff&0x8000); // Callback did not took more than requested time for next callback // so we can launch Update_All before next callback