Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create egpio.py fake #182

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading