mirror of
https://github.com/binary-kitchen/doorlockd
synced 2024-12-22 18:34:25 +01:00
Added Lock Button
Signed-off-by: Ralf Ramsauer <ralf@ramses-pyramidenbau.de>
This commit is contained in:
parent
33df5aa8f9
commit
6a8e917ede
@ -16,6 +16,8 @@ Door::Door() :
|
|||||||
wiringPiSetup();
|
wiringPiSetup();
|
||||||
pinMode(_HEARTBEATPIN, OUTPUT);
|
pinMode(_HEARTBEATPIN, OUTPUT);
|
||||||
pinMode(_SCHNAPPERPIN, OUTPUT);
|
pinMode(_SCHNAPPERPIN, OUTPUT);
|
||||||
|
pinMode(_LOCKPIN, INPUT);
|
||||||
|
pullUpDnControl(_LOCKPIN, PUD_UP);
|
||||||
lock();
|
lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,11 +72,17 @@ void Door::unlock()
|
|||||||
_heartbeat = std::thread([this] () {
|
_heartbeat = std::thread([this] () {
|
||||||
|
|
||||||
// One "beat" is one complete cycle of the heartbeat clock
|
// One "beat" is one complete cycle of the heartbeat clock
|
||||||
auto beat = [] () {
|
auto beat = [this] () {
|
||||||
digitalWrite(_HEARTBEATPIN, HIGH);
|
digitalWrite(_HEARTBEATPIN, HIGH);
|
||||||
usleep(10000);
|
usleep(10000);
|
||||||
digitalWrite(_HEARTBEATPIN, LOW);
|
digitalWrite(_HEARTBEATPIN, LOW);
|
||||||
usleep(10000);
|
usleep(10000);
|
||||||
|
|
||||||
|
if (digitalRead(_LOCKPIN)) {
|
||||||
|
std::thread([this] () {
|
||||||
|
lock();
|
||||||
|
}).detach();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// The default of the Schnapperpin: always high
|
// The default of the Schnapperpin: always high
|
||||||
|
@ -52,6 +52,7 @@ private:
|
|||||||
// WiringPi GPIO Pins
|
// WiringPi GPIO Pins
|
||||||
static constexpr int _HEARTBEATPIN = 10;
|
static constexpr int _HEARTBEATPIN = 10;
|
||||||
static constexpr int _SCHNAPPERPIN = 7;
|
static constexpr int _SCHNAPPERPIN = 7;
|
||||||
|
static constexpr int _LOCKPIN = 15;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user