feat: added some features
This commit is contained in:
42
control/mockGpio.py
Normal file
42
control/mockGpio.py
Normal file
@@ -0,0 +1,42 @@
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class GPIO:
|
||||
BCM = 1
|
||||
IN = 1
|
||||
OUT = 2
|
||||
LOW = 0
|
||||
HIGH = 1
|
||||
|
||||
class PWM:
|
||||
def __init__(self, pin, freq):
|
||||
self.pin = pin
|
||||
self.freq = freq
|
||||
self.dc: Optional[float] = None
|
||||
self.name = None
|
||||
|
||||
def start(self, dc: float):
|
||||
self.dc = dc
|
||||
|
||||
def ChangeDutyCycle(self, dc):
|
||||
self.dc = dc
|
||||
print(f'[{self.pin}@{self.freq}Hz]{" " + self.name if self.name else ""} => {self.dc}')
|
||||
|
||||
def stop(self):
|
||||
print("stop pwm")
|
||||
|
||||
@staticmethod
|
||||
def setup(pin, mode):
|
||||
print(f"setup {pin} -> {mode}")
|
||||
|
||||
@staticmethod
|
||||
def output(pin, value):
|
||||
print(f"output {pin} -> {value}")
|
||||
|
||||
@staticmethod
|
||||
def setmode(mode):
|
||||
print(f"setmode {mode}")
|
||||
|
||||
@staticmethod
|
||||
def cleanup():
|
||||
print("cleanup")
|
||||
Reference in New Issue
Block a user