Skip to content

Commit 840c6ff

Browse files
committed
examples/sysfsgpio: add active_low attribute to examples
Also expand examples to call methods from the Power and Button protocols Signed-off-by: Perry Melange <[email protected]>
1 parent d6f9dd9 commit 840c6ff

File tree

4 files changed

+67
-4
lines changed

4 files changed

+67
-4
lines changed

examples/sysfsgpio/export-gpio.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
desk:
2-
GpioDigitalOutputDriver:
2+
SysfsGPIO:
33
index: 60
4+
active_low: False

examples/sysfsgpio/import-gpio.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,3 @@ targets:
55
name: gpio
66
drivers:
77
GpioDigitalOutputDriver: {}
8-
options:
9-
coordinator_address: 'labgrid:20408'

examples/sysfsgpio/sysfsgpio.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
StepLogger.start()
1414

1515
t = Target("main")
16-
r = SysfsGPIO(t, name=None, index=60)
16+
r = SysfsGPIO(t, name=None, index=60, active_low=True)
1717
d = GpioDigitalOutputDriver(t, name=None)
1818

1919
p = t.get_driver("DigitalOutputProtocol")
2020
print(t.resources)
21+
print("Testing IO")
2122
p.set(True)
2223
print(p.get())
2324
time.sleep(2)
@@ -26,3 +27,34 @@
2627
time.sleep(2)
2728
p.set(True)
2829
print(p.get())
30+
time.sleep(2)
31+
p.invert()
32+
print(p.get())
33+
time.sleep(2)
34+
p.invert()
35+
print(p.get())
36+
time.sleep(2)
37+
38+
print("Testing Power")
39+
p.off()
40+
print(p.get())
41+
time.sleep(2)
42+
p.on()
43+
print(p.get())
44+
time.sleep(2)
45+
p.cycle()
46+
print(p.get())
47+
time.sleep(2)
48+
49+
print("Testing Button")
50+
p.release()
51+
print(p.get())
52+
time.sleep(2)
53+
p.press()
54+
print(p.get())
55+
time.sleep(2)
56+
p.release()
57+
print(p.get())
58+
time.sleep(2)
59+
p.press_for()
60+
print(p.get())

examples/sysfsgpio/sysfsgpio_remote.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
p = t.get_driver("DigitalOutputProtocol")
1717
print(t.resources)
18+
print("Testing IO")
1819
p.set(True)
1920
print(p.get())
2021
time.sleep(2)
@@ -23,3 +24,34 @@
2324
time.sleep(2)
2425
p.set(True)
2526
print(p.get())
27+
time.sleep(2)
28+
p.invert()
29+
print(p.get())
30+
time.sleep(2)
31+
p.invert()
32+
print(p.get())
33+
time.sleep(2)
34+
35+
print("Testing Power")
36+
p.off()
37+
print(p.get())
38+
time.sleep(2)
39+
p.on()
40+
print(p.get())
41+
time.sleep(2)
42+
p.cycle()
43+
print(p.get())
44+
time.sleep(2)
45+
46+
print("Testing Button")
47+
p.release()
48+
print(p.get())
49+
time.sleep(2)
50+
p.press()
51+
print(p.get())
52+
time.sleep(2)
53+
p.release()
54+
print(p.get())
55+
time.sleep(2)
56+
p.press_for()
57+
print(p.get())

0 commit comments

Comments
 (0)