const LCD = require('raspberrypi-liquid-crystal'); const common = require('./common') const globalVars = require('./globalVars') const clock = require('./clock'); const lcd = new LCD(1, 0x27, 20, 4); lcd.beginSync(); module.exports = { clearScreen: async () => { lcd.clearSync(); }, clearLine: async (line) => { line = line - 1 lcd.setCursorSync(0, line); lcd.printSync(' ') }, intro: async () => { lcd.clearSync(); lcd.printLineSync(1, 'MiGenie Status') lcd.setCursorSync(13, 2); lcd.printSync('By Karl') await common.pause(3000) lcd.clearSync(); }, heading: async (title) => { lcd.setCursorSync(0, 0); lcd.printSync(title) }, time: async () => { console.log('get time') lcd.setCursorSync(15, 0); lcd.printSync(await clock.time()) }, waterStatus: async (input) => { lcd.printLineSync(2, 'Water=') lcd.setCursorSync(6, 2); lcd.printSync(' ') lcd.setCursorSync(6, 2); lcd.printSync(input) }, heatingStatus: async (input) => { lcd.printLineSync(2, 'Heating=') lcd.setCursorSync(8, 2); lcd.printSync(' ') lcd.setCursorSync(8, 2); lcd.printSync(input) }, NextEvent: async (input) => { if (globalVars.waterOn === "true") { lcd.setCursorSync(0, 3) lcd.printSync("Switch Off=") lcd.setCursorSync(11, 3); lcd.printSync(' ') lcd.setCursorSync(11, 3); lcd.printSync(input) } else { lcd.setCursorSync(0, 3) lcd.printSync("Switch On=") lcd.setCursorSync(10, 3); lcd.printSync(' ') lcd.setCursorSync(10, 3); lcd.printSync(input) } }, currentRoomTemp: async (temp) => { lcd.setCursorSync(0, 1); let icon = '\xDF' temp = temp + icon lcd.printSync('CT:' + temp); }, lastSetTemp: async (temp) => { lcd.setCursorSync(14, 1); let icon = '\xDF' temp = temp + icon lcd.printSync('LT:' + temp); }, heatingPageOne: async (heatingStatus, measuredRoomTemp, lastTimerSetPoint, heatingNextEvent) => { module.exports.currentRoomTemp(measuredRoomTemp) module.exports.lastSetTemp(lastTimerSetPoint) module.exports.NextEvent(heatingNextEvent) module.exports.heatingStatus(heatingStatus) }, waterPageOne: async (waterStatus, waterNextEvent) => { module.exports.NextEvent(waterNextEvent) module.exports.waterStatus(waterStatus) } }