Files
Maison/ESP32/DCC-Bench/include/RelayController.h
2026-02-10 12:12:11 +01:00

60 lines
1.4 KiB
C++

/**
* @file RelayController.h
* @brief Relay control for switching between 2-rail and 3-rail track configurations
*
* Controls a relay module to switch track wiring between:
* - 2-rail mode: Standard DC/DCC operation
* - 3-rail mode: Center rail + outer rails configuration
*
* @author Locomotive Test Bench Project
* @date 2025
*/
#ifndef RELAY_CONTROLLER_H
#define RELAY_CONTROLLER_H
#include <Arduino.h>
// Pin definition for relay control
#define RELAY_PIN 4 ///< Relay control pin (active HIGH)
/**
* @class RelayController
* @brief Controls relay for track configuration switching
*
* Simple relay control for switching between 2-rail and 3-rail modes.
* Relay energized = 3-rail mode
* Relay de-energized = 2-rail mode
*/
class RelayController {
public:
/**
* @brief Constructor
*/
RelayController();
/**
* @brief Initialize relay controller hardware
*
* Configures GPIO pin and sets to default 2-rail mode.
*/
void begin();
/**
* @brief Set rail mode
* @param is3Rail true = 3-rail mode, false = 2-rail mode
*/
void setRailMode(bool is3Rail);
/**
* @brief Get current rail mode
* @return true if 3-rail mode, false if 2-rail mode
*/
bool is3RailMode() { return is3Rail; }
private:
bool is3Rail; ///< Current rail mode state
};
#endif // RELAY_CONTROLLER_H