Skip to content

Commit 679ca77

Browse files
committed
Add CLI for direct GPIO movement control; implement argparse for up/down commands
1 parent 80ca237 commit 679ca77

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

src/progressive_automations_python/movement_control.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,29 @@ def move_down(down_time: float) -> Tuple[float, float, float]:
8383
actual_duration = end_time - start_time
8484

8585
print(f"DOWN movement completed: {actual_duration:.1f}s actual")
86-
return start_time, end_time, actual_duration
86+
return start_time, end_time, actual_duration
87+
88+
89+
if __name__ == "__main__":
90+
# Simple CLI to call move_up/move_down directly without imports elsewhere.
91+
import argparse
92+
93+
parser = argparse.ArgumentParser(description="Direct GPIO movement test")
94+
group = parser.add_mutually_exclusive_group(required=True)
95+
group.add_argument("--up", type=float, help="Move up for N seconds")
96+
group.add_argument("--down", type=float, help="Move down for N seconds")
97+
args = parser.parse_args()
98+
99+
setup_gpio()
100+
try:
101+
if args.up is not None:
102+
print(f"Running move_up({args.up})")
103+
start, end, dur = move_up(args.up)
104+
print(f"Done. Duration: {dur:.3f}s")
105+
else:
106+
print(f"Running move_down({args.down})")
107+
start, end, dur = move_down(args.down)
108+
print(f"Done. Duration: {dur:.3f}s")
109+
finally:
110+
cleanup_gpio()
111+
print("GPIO cleaned up")

0 commit comments

Comments
 (0)