From 6af6de6292051eaaa77b8152baf00f1806786681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lino?= Date: Wed, 12 Aug 2015 10:35:13 +0100 Subject: [PATCH] added debug to xCountTheTime to fix clockIgnore. --- brew.ino | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/brew.ino b/brew.ino index 32b7602..3b15415 100644 --- a/brew.ino +++ b/brew.ino @@ -92,6 +92,11 @@ template void debugPrintVar( char *name, const T& value ) { Serial.print(value); Serial.println("]"); } +void debugPrintFunction( char *name ) { + Serial.print("++++++++++++++++++++++++ "); + Serial.print(name); + Serial.println("++++++++++++++++++++++++"); +} // ######################### VARIABLES ######################### // ++++++++++++++++++++++++ State Machine ++++++++++++++++++++++++ @@ -893,19 +898,26 @@ void MainMenu_Back() { } void xCountTheTime( int temperatureRange ) { + unsigned long now = millis(); +#ifdef DEBUG + debugPrintFunction("xCountTheTime"); + debugPrintVar("millis()", now); + debugPrintVar("clockStartTime", clockStartTime); +#endif + // Check if the machine is in the right temperature range, for the current mode, if(!(basePT100.getCurrentTemperature() > (cookTemperature - temperatureRange) && basePT100.getCurrentTemperature() < (cookTemperature + temperatureRange))) { - clockIgnore += millis() - clockStartTime - clockCounter; + clockIgnore += now - clockStartTime - clockCounter; #ifdef DEBUG - Serial.print("[clockIgnore:"); - Serial.print(clockIgnore); - Serial.println("]"); debugPrintVar("clockIgnore", clockIgnore); #endif } // Calculate the remaining time on the clock - clockCounter = cookTime - ((millis() - clockStartTime - clockIgnore) / 1000); + clockCounter = cookTime - (now - clockStartTime - clockIgnore); + #ifdef DEBUG + debugPrintVar("clockCounter", clockCounter); +#endif } bool isTimeLeft() { -- 2.24.1