93 lines
2.9 KiB
JavaScript
Raw Normal View History

2020-09-14 08:17:22 +01:00
const LCD = require('raspberrypi-liquid-crystal');
2020-09-14 12:11:37 +01:00
const common = require('./common')
const globalVars = require('./globalVars')
const clock = require('./clock');
2020-09-14 08:17:22 +01:00
const lcd = new LCD(1, 0x27, 20, 4);
lcd.beginSync();
module.exports = {
2020-09-14 12:11:37 +01:00
clearScreen: async () => {
2020-09-14 08:17:22 +01:00
lcd.clearSync();
2020-09-14 12:11:37 +01:00
},
clearLine: async (line) => {
line = line - 1
lcd.setCursorSync(0, line);
lcd.printSync(' ')
},
intro: async () => {
lcd.clearSync();
lcd.printLineSync(1, 'MiGenie Status')
2020-09-21 21:38:46 +01:00
lcd.setCursorSync(13, 2);
lcd.printSync('By Karl')
2020-09-14 12:11:37 +01:00
await common.pause(3000)
2020-09-14 18:42:09 +01:00
lcd.clearSync();
2020-09-14 12:11:37 +01:00
},
heading: async (title) => {
2020-09-14 18:42:09 +01:00
lcd.setCursorSync(0, 0);
lcd.printSync(title)
2020-09-14 08:17:22 +01:00
},
time: async () => {
2020-09-21 21:38:46 +01:00
console.log('get time')
2020-09-14 12:11:37 +01:00
lcd.setCursorSync(15, 0);
2020-09-21 21:38:46 +01:00
lcd.printSync(await clock.time())
2020-09-14 08:17:22 +01:00
},
2020-09-14 13:47:23 +01:00
waterStatus: async (input) => {
2020-09-14 18:42:09 +01:00
lcd.printLineSync(2, 'Water=')
2020-09-14 13:47:23 +01:00
lcd.setCursorSync(6, 2);
2020-09-14 12:11:37 +01:00
lcd.printSync(' ')
2020-09-14 13:47:23 +01:00
lcd.setCursorSync(6, 2);
lcd.printSync(input)
},
2020-09-21 21:53:55 +01:00
heatingStatus: async (input) => {
2020-09-21 21:38:46 +01:00
lcd.printLineSync(2, 'Heating=')
lcd.setCursorSync(8, 2);
2020-09-22 11:40:06 +01:00
lcd.printSync(' ')
2020-09-21 21:38:46 +01:00
lcd.setCursorSync(8, 2);
lcd.printSync(input)
},
NextEvent: async (input) => {
2020-09-14 18:42:09 +01:00
if (globalVars.waterOn === "true") {
2020-09-22 11:40:06 +01:00
lcd.setCursorSync(0, 3)
lcd.printSync("Switch Off=")
2020-09-14 18:42:09 +01:00
lcd.setCursorSync(11, 3);
lcd.printSync(' ')
lcd.setCursorSync(11, 3);
lcd.printSync(input)
} else {
2020-09-22 11:40:06 +01:00
lcd.setCursorSync(0, 3)
lcd.printSync("Switch On=")
2020-09-14 18:42:09 +01:00
lcd.setCursorSync(10, 3);
lcd.printSync(' ')
lcd.setCursorSync(10, 3);
lcd.printSync(input)
}
2020-09-14 08:17:22 +01:00
},
2020-09-21 21:53:55 +01:00
currentRoomTemp: async (temp) => {
2020-09-22 11:40:06 +01:00
lcd.setCursorSync(0, 1);
let icon = '\xDF'
2020-09-21 21:53:55 +01:00
temp = temp + icon
2020-09-22 11:40:06 +01:00
lcd.printSync('CT:' + temp);
2020-09-21 21:53:55 +01:00
},
lastSetTemp: async (temp) => {
2020-09-22 11:40:06 +01:00
lcd.setCursorSync(14, 1);
let icon = '\xDF'
2020-09-21 21:53:55 +01:00
temp = temp + icon
2020-09-22 11:40:06 +01:00
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)
},
2020-09-22 11:49:55 +01:00
heatingPageTwo: async (measuredRoomTemp, lastTimerSetPoint) => {
module.exports.currentRoomTemp(measuredRoomTemp)
module.exports.lastSetTemp(lastTimerSetPoint)
},
2020-09-22 11:40:06 +01:00
waterPageOne: async (waterStatus, waterNextEvent) => {
module.exports.NextEvent(waterNextEvent)
module.exports.waterStatus(waterStatus)
2020-09-21 21:38:46 +01:00
}
2020-09-14 08:17:22 +01:00
}