fix: use physical pin numbers

- Changed GPIO mode from BCM to BOARD
- Now using physical pin numbers (15 for relay, 7 for status)
- Updated pin documentation
- Made logging clearer about physical pin numbers
This commit is contained in:
Josh Finlay 2025-01-08 09:23:22 +10:00
parent ef770dde37
commit ee437e9f95
1 changed files with 4 additions and 4 deletions

View File

@ -38,8 +38,8 @@ class MQTTSettings(BaseModel):
enabled: bool = False enabled: bool = False
class GPIOSettings(BaseModel): class GPIOSettings(BaseModel):
gatePin: int = 15 # Relay control pin gatePin: int = 15 # Physical Pin 15 - Relay control pin
statusPin: int = 7 # Gate open status pin statusPin: int = 7 # Physical Pin 7 - Gate open status pin
class LoggingSettings(BaseModel): class LoggingSettings(BaseModel):
level: str = "INFO" # Default to INFO level level: str = "INFO" # Default to INFO level
@ -550,7 +550,7 @@ app.mount("/", StaticFiles(directory="../public", html=True), name="static")
def setup_gpio(): def setup_gpio():
"""Initialize GPIO pins based on settings""" """Initialize GPIO pins based on settings"""
GPIO.setwarnings(False) GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM) GPIO.setmode(GPIO.BOARD) # Use physical pin numbers instead of BCM
try: try:
settings = app.state.current_settings settings = app.state.current_settings
@ -567,7 +567,7 @@ def setup_gpio():
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, pull_up_down=GPIO.PUD_UP)
logger.info(f"GPIO initialized (Gate Pin: {gate_pin}, Status Pin: {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:
logger.error(f"Failed to setup GPIO: {e}", exc_info=True) logger.error(f"Failed to setup GPIO: {e}", exc_info=True)
raise raise