This repository has been archived on 2024-11-17. You can view files and clone it, but cannot push or open issues or pull requests.
zamek-hswro/DoorLock.cpp

30 lines
523 B
C++

#include "DoorLock.h"
#include <Arduino.h>
DoorLock::DoorLock(IGpio &gpio, DoorLock::ActiveState activeState, DoorLock::TMilliseconds openTime):
gpio(gpio),
activeState(activeState),
openTime(openTime)
{
deactivate();
gpio.setMode(IGpio::Mode::Output);
}
void DoorLock::open()
{
activate();
delay(openTime);
deactivate();
}
void DoorLock::activate()
{
gpio.write(activeState == ActiveState::High);
}
void DoorLock::deactivate()
{
gpio.write(activeState != ActiveState::High);
}