Skip to content

Commit

Permalink
Create egpio.py fake
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisDick committed Jun 30, 2024
1 parent e3a09a0 commit 72cef5a
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 17 deletions.
45 changes: 45 additions & 0 deletions sim/fakes/egpio.py
Original file line number Diff line number Diff line change
@@ -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
31 changes: 14 additions & 17 deletions sim/fakes/tildagonos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 72cef5a

Please sign in to comment.