Skip to content

Commit

Permalink
examples/sysfsgpio: add invert (active-low) attribute to examples
Browse files Browse the repository at this point in the history
Also expand examples to call methods from the Power and Button protocols

Signed-off-by: Perry Melange <isprotejesvalkata@gmail.com>
  • Loading branch information
pmelange committed Feb 13, 2025
1 parent c4f564c commit 986f807
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 4 deletions.
3 changes: 2 additions & 1 deletion examples/sysfsgpio/export-gpio.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
desk:
GpioDigitalOutputDriver:
SysfsGPIO:
index: 60
invert: False
2 changes: 0 additions & 2 deletions examples/sysfsgpio/import-gpio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ targets:
name: gpio
drivers:
GpioDigitalOutputDriver: {}
options:
coordinator_address: 'labgrid:20408'
34 changes: 33 additions & 1 deletion examples/sysfsgpio/sysfsgpio.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
StepLogger.start()

t = Target("main")
r = SysfsGPIO(t, name=None, index=60)
r = SysfsGPIO(t, name=None, index=60, invert=True)
d = GpioDigitalOutputDriver(t, name=None)

p = t.get_driver("DigitalOutputProtocol")
print(t.resources)
print("Testing IO")
p.set(True)
print(p.get())
time.sleep(2)
Expand All @@ -26,3 +27,34 @@
time.sleep(2)
p.set(True)
print(p.get())
time.sleep(2)
p.invert()
print(p.get())
time.sleep(2)
p.invert()
print(p.get())
time.sleep(2)

print("Testing Power")
p.off()
print(p.get())
time.sleep(2)
p.on()
print(p.get())
time.sleep(2)
p.cycle()
print(p.get())
time.sleep(2)

print("Testing Button")
p.release()
print(p.get())
time.sleep(2)
p.press()
print(p.get())
time.sleep(2)
p.release()
print(p.get())
time.sleep(2)
p.press_for()
print(p.get())
32 changes: 32 additions & 0 deletions examples/sysfsgpio/sysfsgpio_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

p = t.get_driver("DigitalOutputProtocol")
print(t.resources)
print("Testing IO")
p.set(True)
print(p.get())
time.sleep(2)
Expand All @@ -23,3 +24,34 @@
time.sleep(2)
p.set(True)
print(p.get())
time.sleep(2)
p.invert()
print(p.get())
time.sleep(2)
p.invert()
print(p.get())
time.sleep(2)

print("Testing Power")
p.off()
print(p.get())
time.sleep(2)
p.on()
print(p.get())
time.sleep(2)
p.cycle()
print(p.get())
time.sleep(2)

print("Testing Button")
p.release()
print(p.get())
time.sleep(2)
p.press()
print(p.get())
time.sleep(2)
p.release()
print(p.get())
time.sleep(2)
p.press_for()
print(p.get())

0 comments on commit 986f807

Please sign in to comment.