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++
Raw Normal View History

2017-12-17 11:31:13 +00:00
#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);
}