fix: update GPIO for voltage input

- Removed pull-up resistor since we're receiving voltage
- Changed logic to match voltage input (HIGH = open)
- Updated comments and documentation
This commit is contained in:
Josh Finlay 2025-01-08 09:28:00 +10:00
parent ee437e9f95
commit 96dcdb4c86
1 changed files with 5 additions and 4 deletions

View File

@ -312,7 +312,7 @@ async def update_gate_status():
logger.warning("No settings available, using default settings") logger.warning("No settings available, using default settings")
settings = Settings() settings = Settings()
# Check current status (LOW = closed, HIGH = open) # Check current status (HIGH = open, LOW = closed)
is_open = GPIO.input(settings.gpio.statusPin) == GPIO.HIGH is_open = GPIO.input(settings.gpio.statusPin) == GPIO.HIGH
# Update state machine # Update state machine
@ -437,7 +437,8 @@ async def get_status():
"""Get current gate status""" """Get current gate status"""
try: try:
settings = app.state.current_settings or Settings() settings = app.state.current_settings or Settings()
# LOW (0V) means gate is closed, HIGH (3.3V) means gate is open # HIGH (3.3V) means gate is open (receiving voltage)
# LOW (0V) means gate is closed (no voltage)
is_open = GPIO.input(settings.gpio.statusPin) == GPIO.HIGH is_open = GPIO.input(settings.gpio.statusPin) == GPIO.HIGH
gate_status.update(is_open) gate_status.update(is_open)
@ -563,9 +564,9 @@ def setup_gpio():
GPIO.setup(gate_pin, GPIO.OUT) GPIO.setup(gate_pin, GPIO.OUT)
GPIO.output(gate_pin, GPIO.LOW) GPIO.output(gate_pin, GPIO.LOW)
# Setup status pin if needed # Setup status pin as input without pull-up
status_pin = settings.gpio.statusPin status_pin = settings.gpio.statusPin
GPIO.setup(status_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(status_pin, GPIO.IN)
logger.info(f"GPIO initialized (Gate Pin: Physical {gate_pin}, Status Pin: Physical {status_pin})") logger.info(f"GPIO initialized (Gate Pin: Physical {gate_pin}, Status Pin: Physical {status_pin})")
except Exception as e: except Exception as e: