From 812a094e5086c4be39c92004cc437cf86a00c448 Mon Sep 17 00:00:00 2001 From: Marcel Peterkau Date: Mon, 22 Aug 2022 14:29:01 +0200 Subject: [PATCH] prevent Lube if Tank is empty (DryRun-Protection) --- Software/src/lubeapp.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Software/src/lubeapp.cpp b/Software/src/lubeapp.cpp index 3844559..8c4e09d 100644 --- a/Software/src/lubeapp.cpp +++ b/Software/src/lubeapp.cpp @@ -121,9 +121,13 @@ void RunLubeApp(uint32_t add_milimeters) void LubePulse() { - lubePulseTimestamp = millis() + LUBE_PULSE_LENGHT_MS; - if (PersistenceData.tankRemain_µl < LubeConfig.amountPerDose_µl) - PersistenceData.tankRemain_µl = 0; - else - PersistenceData.tankRemain_µl = PersistenceData.tankRemain_µl - LubeConfig.amountPerDose_µl; + if (PersistenceData.tankRemain_µl > 0) // Only Lube if theres Oil remaining! + { + lubePulseTimestamp = millis() + LUBE_PULSE_LENGHT_MS; + + if (PersistenceData.tankRemain_µl < LubeConfig.amountPerDose_µl) // Prevent underrun and shiftover + PersistenceData.tankRemain_µl = 0; + else + PersistenceData.tankRemain_µl = PersistenceData.tankRemain_µl - LubeConfig.amountPerDose_µl; + } } \ No newline at end of file