[shutdown] fix bugs
This commit is contained in:
parent
bf2b8c2625
commit
800724cb54
|
@ -2,6 +2,7 @@ from takway.board.base_hd import BaseHardware
|
||||||
import threading
|
import threading
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import time
|
import time
|
||||||
|
import subprocess
|
||||||
try:
|
try:
|
||||||
import wiringpi
|
import wiringpi
|
||||||
from wiringpi import GPIO
|
from wiringpi import GPIO
|
||||||
|
@ -78,7 +79,6 @@ class OrangePi(BaseHardware):
|
||||||
press_duration = (datetime.now() - press_time_1).total_seconds()
|
press_duration = (datetime.now() - press_time_1).total_seconds()
|
||||||
# if press_duration > 0.01:
|
# if press_duration > 0.01:
|
||||||
if press_duration > 5:
|
if press_duration > 5:
|
||||||
time.sleep(1) # 防止短按误触发
|
|
||||||
subprocess.Popen('sudo shutdown now', shell=True)
|
subprocess.Popen('sudo shutdown now', shell=True)
|
||||||
else:
|
else:
|
||||||
self.long_power_status = not self.long_power_status
|
self.long_power_status = not self.long_power_status
|
||||||
|
|
Loading…
Reference in New Issue