Refactor ChipUnlocker
This commit is contained in:
19
chip_unlocker.py
Normal file
19
chip_unlocker.py
Normal 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)
|
Reference in New Issue
Block a user