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