50 lines
988 B
JavaScript

const { Gpio } = require('onoff');
const hotwater = require('./modules/hotwater')
const common = require('./libs/common')
const globalVars = require('./libs/globalVars')
const led = require('./libs/led')
const lcd = require('./libs/lcd')
async function main() {
lcd.clearScreen()
await lcd.intro()
lcd.time()
hotwater.setInterval
const heatingSwitch = new Gpio('17', 'in', 'both');
const appSwitch = new Gpio('23', 'in', 'both');
heatingSwitch.watch(async (err, value) => {
if (err) {
console.log('Error', err);
}
if (value === 1) {
if (globalVars.waterOn === 'true') {
common.request(0)
} else {
common.request(1)
}
}
})
appSwitch.watch(async (err, value) => {
if (err) {
console.log('Error', err);
}
if (value === 1) {
console.log('pressed')
}
})
}
process.stdin.resume();
process.on('SIGINT', function () {
lcd.clearScreen()
led.set('off')
process.exit(1)
});
main()