Skip to content

Commit 63bc7d3

Browse files
committed
Add direct GPIO test script; implement UP and DOWN movement tests with proper GPIO setup
1 parent 820a59d commit 63bc7d3

2 files changed

Lines changed: 65 additions & 2 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Direct GPIO test script - bypasses import issues
4+
"""
5+
import time
6+
import RPi.GPIO as GPIO
7+
8+
# Pin definitions
9+
UP_PIN = 18
10+
DOWN_PIN = 17
11+
12+
def setup_gpio():
13+
GPIO.setmode(GPIO.BCM)
14+
15+
def press_up():
16+
print("Setting UP pin (18) to HIGH")
17+
GPIO.setup(UP_PIN, GPIO.OUT, initial=GPIO.LOW)
18+
19+
def release_up():
20+
print("Setting UP pin (18) to high-impedance")
21+
GPIO.setup(UP_PIN, GPIO.IN, pull_up_down=GPIO.PUD_OFF)
22+
23+
def press_down():
24+
print("Setting DOWN pin (17) to HIGH")
25+
GPIO.setup(DOWN_PIN, GPIO.OUT, initial=GPIO.LOW)
26+
27+
def release_down():
28+
print("Setting DOWN pin (17) to high-impedance")
29+
GPIO.setup(DOWN_PIN, GPIO.IN, pull_up_down=GPIO.PUD_OFF)
30+
31+
def cleanup_gpio():
32+
release_up()
33+
release_down()
34+
GPIO.cleanup()
35+
36+
if __name__ == "__main__":
37+
print("Starting direct GPIO test...")
38+
setup_gpio()
39+
40+
try:
41+
print("Testing UP movement for 2 seconds...")
42+
release_up()
43+
time.sleep(0.1)
44+
press_up()
45+
time.sleep(2.0)
46+
release_up()
47+
print("UP test complete")
48+
49+
time.sleep(1.0)
50+
51+
print("Testing DOWN movement for 2 seconds...")
52+
release_down()
53+
time.sleep(0.1)
54+
press_down()
55+
time.sleep(2.0)
56+
release_down()
57+
print("DOWN test complete")
58+
59+
except KeyboardInterrupt:
60+
print("Test interrupted")
61+
finally:
62+
cleanup_gpio()
63+
print("GPIO cleaned up")

src/progressive_automations_python/movement_control.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def release_up() -> None:
2727

2828
def press_up() -> None:
2929
"""Set UP pin to drive high (button pressed)"""
30-
GPIO.setup(UP_PIN, GPIO.OUT, initial=GPIO.HIGH)
30+
GPIO.setup(UP_PIN, GPIO.OUT, initial=GPIO.LOW)
3131

3232

3333
def release_down() -> None:
@@ -37,7 +37,7 @@ def release_down() -> None:
3737

3838
def press_down() -> None:
3939
"""Set DOWN pin to drive high (button pressed)"""
40-
GPIO.setup(DOWN_PIN, GPIO.OUT, initial=GPIO.HIGH)
40+
GPIO.setup(DOWN_PIN, GPIO.OUT, initial=GPIO.LOW)
4141

4242

4343
def cleanup_gpio() -> None:

0 commit comments

Comments
 (0)