1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-12-22 18:34:25 +01:00
doorlockd-mirror/door.cpp

43 lines
561 B
C++
Raw Normal View History

2015-05-11 00:18:22 +02:00
#include <iostream>
#include <wiringPi.h>
#include "logger.h"
#include "door.h"
using namespace std;
constexpr int LOCKPIN = 10;
Door::Door() : _l(Logger::get())
{
_l(LogLevel::info, "Initializing Raspberry Pi GPIOs");
wiringPiSetup();
pinMode(LOCKPIN, OUTPUT);
lock();
}
Door::~Door()
{
}
Door &Door::get()
{
static Door d;
return d;
}
void Door::lock()
{
_l(LogLevel::info, "Door closed");
digitalWrite(LOCKPIN, HIGH);
}
void Door::unlock()
{
_l(LogLevel::info, "Door opened");
digitalWrite(LOCKPIN, LOW);
}