// 
// Relais.cpp
// 

#include "Relais.h"
#include "Globals.h"

void RelaisClass::begin(RelaisState state) {
  _State = state;
  digitalWrite(_Pin, _State == RelaisState::on ? HIGH : LOW);
  pinMode(_Pin, OUTPUT);
  RelaisStateChangedCallback(_State);
}

void RelaisClass::setState(RelaisState state) {
  if (_State != state) { // Nur, wenn wirklich eine Änderung vorliegt
    _State = state;
    digitalWrite(_Pin, _State == RelaisState::on ? HIGH : LOW);
    if (RelaisStateChangedCallback)
      RelaisStateChangedCallback(_State);
  }
}

RelaisClass Relais(RELAIS_PIN);

