96 lines
3.2 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-28 10:50:23 +01:00
var commaNumber = require('comma-number')
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();
2020-09-28 10:50:23 +01:00
lcd.printLineSync(1, 'House 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-28 10:50:23 +01:00
let t = new Date().toUTCString()
console.log(t + ' 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-28 10:50:23 +01:00
if (input === 'Not Set') {
2020-09-22 11:40:06 +01:00
lcd.setCursorSync(0, 3)
2020-09-28 10:50:23 +01:00
lcd.printSync("Always Off")
2020-09-14 18:42:09 +01:00
} else {
2020-09-28 10:50:23 +01:00
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)
}
2020-09-14 18:42:09 +01:00
}
2020-09-14 08:17:22 +01:00
},
2020-09-21 21:53:55 +01:00
currentRoomTemp: async (temp) => {
2020-09-28 10:50:23 +01:00
lcd.printLineSync(2, 'Current Temp:' + temp + '\xDF')
2020-09-21 21:53:55 +01:00
},
lastSetTemp: async (temp) => {
2020-09-28 10:50:23 +01:00
lcd.printLineSync(3, 'Last Set Temp:' + temp + '\xDF')
2020-09-22 11:40:06 +01:00
},
2020-09-28 10:50:23 +01:00
heatingPageOne: async (heatingStatus, heatingNextEvent) => {
await module.exports.NextEvent(heatingNextEvent)
await module.exports.heatingStatus(heatingStatus)
2020-09-22 11:40:06 +01:00
},
2020-09-22 11:49:55 +01:00
heatingPageTwo: async (measuredRoomTemp, lastTimerSetPoint) => {
2020-09-28 10:50:23 +01:00
await module.exports.currentRoomTemp(measuredRoomTemp)
await module.exports.lastSetTemp(lastTimerSetPoint)
2020-09-22 11:49:55 +01:00
},
2020-09-22 11:40:06 +01:00
waterPageOne: async (waterStatus, waterNextEvent) => {
2020-09-28 10:50:23 +01:00
await module.exports.NextEvent(waterNextEvent)
await module.exports.waterStatus(waterStatus)
},
piHolePage: async (domainsBeingBlocked, queriesToday, queriesBlockedToday, percentageBlocked) => {
lcd.printLineSync(2, 'Queries=' + commaNumber(queriesToday))
lcd.printLineSync(3, 'Blocked=' + commaNumber(queriesBlockedToday) + ' (' + percentageBlocked.toFixed() + '%)')
2020-09-21 21:38:46 +01:00
}
2020-09-14 08:17:22 +01:00
}