From 96330c25cecf9f0ca5de9d395db1d3ef3c0d7e6c Mon Sep 17 00:00:00 2001 From: dragonpilot Date: Tue, 27 Aug 2019 11:49:00 +1000 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8B=95=E9=97=9C=E6=A9=9F=E6=94=B9?= =?UTF-8?q?=E7=82=BA=E5=8F=AF=E8=AA=BF=E6=99=82=E9=95=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- selfdrive/dragonpilot/shutdownd/shutdownd.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/selfdrive/dragonpilot/shutdownd/shutdownd.py b/selfdrive/dragonpilot/shutdownd/shutdownd.py index b99b1b287..40fd07720 100644 --- a/selfdrive/dragonpilot/shutdownd/shutdownd.py +++ b/selfdrive/dragonpilot/shutdownd/shutdownd.py @@ -8,21 +8,25 @@ params = Params() def main(gctx=None): shutdown_count = 0 - autoShutdownAt = get_shutdown_val() + auto_shutdown_at = get_shutdown_val() + frame = 0 while 1: with open("/sys/class/power_supply/usb/present") as f: usb_online = bool(int(f.read())) if not usb_online: + # we update the value every 3 seconds in case of user updates it + if frame % 3 == 0: + auto_shutdown_at = get_shutdown_val() shutdown_count += 1 else: shutdown_count = 0 - if autoShutdownAt is None: - autoShutdownAt = get_shutdown_val() + if auto_shutdown_at is None: + auto_shutdown_at = get_shutdown_val() else: - if shutdown_count >= autoShutdownAt > 0: + if shutdown_count >= auto_shutdown_at > 0: os.system('LD_LIBRARY_PATH="" svc power shutdown') time.sleep(1)