Added Lock Button

Signed-off-by: Ralf Ramsauer <ralf@ramses-pyramidenbau.de>
This commit is contained in:
Ralf Ramsauer 2015-08-03 21:01:58 +02:00
parent bebe258d7b
commit 7f86ca8ccb
2 changed files with 10 additions and 1 deletions

View File

@ -16,6 +16,8 @@ Door::Door() :
wiringPiSetup();
pinMode(_HEARTBEATPIN, OUTPUT);
pinMode(_SCHNAPPERPIN, OUTPUT);
pinMode(_LOCKPIN, INPUT);
pullUpDnControl(_LOCKPIN, PUD_UP);
lock();
}
@ -70,11 +72,17 @@ void Door::unlock()
_heartbeat = std::thread([this] () {
// One "beat" is one complete cycle of the heartbeat clock
auto beat = [] () {
auto beat = [this] () {
digitalWrite(_HEARTBEATPIN, HIGH);
usleep(10000);
digitalWrite(_HEARTBEATPIN, LOW);
usleep(10000);
if (digitalRead(_LOCKPIN)) {
std::thread([this] () {
lock();
}).detach();
}
};
// The default of the Schnapperpin: always high

View File

@ -52,6 +52,7 @@ private:
// WiringPi GPIO Pins
static constexpr int _HEARTBEATPIN = 10;
static constexpr int _SCHNAPPERPIN = 7;
static constexpr int _LOCKPIN = 15;
};
#endif