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)