24 lines
506 B
JavaScript
Raw Normal View History

2020-09-12 11:42:02 +01:00
const { Gpio } = require('onoff');
const poll = require('./poll')
const common = require('./libs/common')
const globalVars = require('./libs/globalVars')
2020-09-14 08:17:22 +01:00
const lcd = require('./libs/lcd')
2020-09-11 12:42:13 +01:00
2020-09-14 08:17:22 +01:00
lcd.heading()
// lcd.time()
2020-09-12 11:42:02 +01:00
poll.setInterval
2020-09-11 12:42:13 +01:00
2020-09-12 11:42:02 +01:00
const switchIn = new Gpio('17', 'in', 'both');
2020-09-11 12:42:13 +01:00
2020-09-14 08:17:22 +01:00
switchIn.watch( async (err, value) => {
2020-09-12 11:42:02 +01:00
if (err) {
console.log('Error', err);
2020-09-11 12:42:13 +01:00
}
2020-09-12 11:42:02 +01:00
if (value === 1) {
if (globalVars.waterOn === 'true') {
common.request(0)
} else {
common.request(1)
}
}
2020-09-12 17:26:47 +01:00
})