Add door opening code

This commit is contained in:
Dana Woodman 2018-08-12 13:52:15 -07:00
parent 6af3ffc380
commit c2733a83b3
2 changed files with 15 additions and 2 deletions

View File

@ -1,6 +1,19 @@
const { Board } = require('easy-usb-relay')
const DELAY = 6000
module.exports = class Door { module.exports = class Door {
static open() { static open() {
console.log('OPEN DOOR!!!!!!!!!!!!!!') return new Promise(success => {
console.log('OPEN DOOR!')
const board = new Board(2)
board.allOn()
setTimeout(() => {
console.log('CLOSING DOOR!')
board.allOff()
success()
}, DELAY)
})
} }
// static close() { // static close() {

View File

@ -10,10 +10,10 @@ module.exports = (req, res) => {
console.log('CARD:', card) console.log('CARD:', card)
if (!card) return res.redirect('/failure') if (!card) return res.redirect('/failure')
Door.open()
res.redirect('/success?name=' + card.name) res.redirect('/success?name=' + card.name)
Logs.log({ timestamp: new Date().getTime(), card }).then(() => Logs.log({ timestamp: new Date().getTime(), card }).then(() =>
console.log('Logged!') console.log('Logged!')
) )
Door.open()
}) })
} }