Refactor ChipUnlocker

This commit is contained in:
2019-10-02 15:26:09 +08:00
parent f435e8d9e0
commit 99d850a305
3 changed files with 23 additions and 20 deletions

19
chip_unlocker.py Normal file
View File

@ -0,0 +1,19 @@
import time
import CHIP_IO.GPIO as GPIO
class ChipUnlocker:
def __init__(self, unlock_pin: str):
self.unlock_pin = unlock_pin
def unlock(self):
# 設定接腳
GPIO.setup(self.unlock_pin, GPIO.OUT)
# 送出低電位 0.4 秒後回復到高電位
GPIO.output(self.unlock_pin, GPIO.LOW)
time.sleep(0.4)
GPIO.output(self.unlock_pin, GPIO.HIGH)
# 復歸接腳
GPIO.cleanup(self.unlock_pin)