diff --git a/sim/fakes/egpio.py b/sim/fakes/egpio.py new file mode 100644 index 0000000..d36b525 --- /dev/null +++ b/sim/fakes/egpio.py @@ -0,0 +1,45 @@ +from _sim import _sim + +EPIN_BTN_1 = (2, 6) +EPIN_BTN_2 = (2, 7) +EPIN_BTN_3 = (1, 0) +EPIN_BTN_4 = (1, 1) +EPIN_BTN_5 = (1, 2) +EPIN_BTN_6 = (1, 3) + + +class ePin: + def __init__(self, pin): + self.IN = 1 + self.OUT = 3 + self.PWM = 8 + self.pin = pin + + def init(self, mode): + pass + + def on(self): + pass + + def off(self): + pass + + def duty(self, duty): + pass + + def value(self, value=None): + if value == None: + if self.pin == EPIN_BTN_1: + return not _sim.buttons.state()[0] + elif self.pin == EPIN_BTN_2: + return not _sim.buttons.state()[1] + elif self.pin == EPIN_BTN_3: + return not _sim.buttons.state()[2] + elif self.pin == EPIN_BTN_4: + return not _sim.buttons.state()[3] + elif self.pin == EPIN_BTN_5: + return not _sim.buttons.state()[4] + elif self.pin == EPIN_BTN_6: + return not _sim.buttons.state()[5] + else: + return 1 diff --git a/sim/fakes/tildagonos.py b/sim/fakes/tildagonos.py index 6080a33..6819bbe 100644 --- a/sim/fakes/tildagonos.py +++ b/sim/fakes/tildagonos.py @@ -36,29 +36,26 @@ def __init__(self): pass def init_gpio(self): - pass + print( + "Warning init_gpio has been depriciated use system.hexpansion.config HexpansionConfig or tildagon Pin instead" + ) def set_egpio_pin(self, pin, state): - pass + print( + "Warning init_gpio has been depriciated use system.hexpansion.config HexpansionConfig or tildagon Pin instead" + ) def read_egpios(self): - pass + print( + "Warning init_gpio has been depriciated use system.hexpansion.config HexpansionConfig or tildagon Pin instead" + ) def check_egpio_state(self, pin, readgpios=True): - if pin == EPIN_BTN_1: - return not _sim.buttons.state()[0] - elif pin == EPIN_BTN_2: - return not _sim.buttons.state()[1] - elif pin == EPIN_BTN_3: - return not _sim.buttons.state()[2] - elif pin == EPIN_BTN_4: - return not _sim.buttons.state()[3] - elif pin == EPIN_BTN_5: - return not _sim.buttons.state()[4] - elif pin == EPIN_BTN_6: - return not _sim.buttons.state()[5] - else: - return 1 + print( + "Warning init_gpio has been depriciated use system.hexpansion.config HexpansionConfig or tildagon Pin instead" + ) + + return 1 def set_led_power(self, state): pass