From 661395a3b228a344cbf44a239c400ed59fbf760d Mon Sep 17 00:00:00 2001
From: Elton Law <eltonlaw296@gmail.com>
Date: Sun, 2 May 2021 03:06:55 -0400
Subject: [PATCH] Allow disable of POWER_TIMEOUT (#21771)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
---
 Marlin/src/feature/power.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Marlin/src/feature/power.cpp b/Marlin/src/feature/power.cpp
index 2f19dae7a6b..fb2f1312e06 100644
--- a/Marlin/src/feature/power.cpp
+++ b/Marlin/src/feature/power.cpp
@@ -99,6 +99,10 @@ bool Power::is_power_needed() {
   return false;
 }
 
+#ifndef POWER_TIMEOUT
+  #define POWER_TIMEOUT 0
+#endif
+
 void Power::check() {
   static millis_t nextPowerCheck = 0;
   millis_t ms = millis();
@@ -106,7 +110,7 @@ void Power::check() {
     nextPowerCheck = ms + 2500UL;
     if (is_power_needed())
       power_on();
-    else if (!lastPowerOn || ELAPSED(ms, lastPowerOn + SEC_TO_MS(POWER_TIMEOUT)))
+    else if (!lastPowerOn || (POWER_TIMEOUT > 0 && ELAPSED(ms, lastPowerOn + SEC_TO_MS(POWER_TIMEOUT))))
       power_off();
   }
 }