working time cleanup
This commit is contained in:
parent
db5597d702
commit
cc06dfb78c
4
app.js
4
app.js
@ -9,8 +9,8 @@ const lcd = require('./libs/lcd')
|
||||
async function main() {
|
||||
lcd.clearScreen()
|
||||
await lcd.intro()
|
||||
lcd.time()
|
||||
hotwater.setInterval
|
||||
setInterval(lcd.time, 55000)
|
||||
setInterval(hotwater.getStatus, 5000)
|
||||
|
||||
const heatingSwitch = new Gpio('17', 'in', 'both');
|
||||
const appSwitch = new Gpio('23', 'in', 'both');
|
||||
|
@ -1,10 +1,10 @@
|
||||
const moment = require('moment'); // require
|
||||
|
||||
module.exports = {
|
||||
time: () => {
|
||||
try {
|
||||
t = moment().format('HH:MM');
|
||||
return t
|
||||
var time = new Date();
|
||||
currentTime = ("0" + time.getHours()).slice(-2) + ":" +
|
||||
("0" + time.getMinutes()).slice(-2)
|
||||
return currentTime
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
|
@ -29,19 +29,10 @@ module.exports = {
|
||||
lcd.printLineSync(2, title)
|
||||
},
|
||||
time: async () => {
|
||||
// set interval
|
||||
var tid = setInterval(mycode, 60000);
|
||||
async function mycode() {
|
||||
|
||||
lcd.setCursorSync(15, 0);
|
||||
let f
|
||||
f = await clock.time()
|
||||
lcd.printSync(f)
|
||||
|
||||
}
|
||||
function abortTimer() { // to be called when you want to stop the timer
|
||||
clearInterval(tid);
|
||||
}
|
||||
},
|
||||
heatingStatus: async (input) => {
|
||||
lcd.setCursorSync(0, 3);
|
||||
|
@ -1,16 +1,12 @@
|
||||
const http = require('http')
|
||||
const { Gpio } = require('onoff');
|
||||
const globalVars = require('../libs/globalVars')
|
||||
const led = require('../libs/led')
|
||||
|
||||
const redLED = new Gpio('4', 'out');
|
||||
const blueLED = new Gpio('27', 'out')
|
||||
const greenLED = new Gpio('22', 'out')
|
||||
|
||||
const lcd = require('../libs/lcd')
|
||||
|
||||
setInterval(function () {
|
||||
module.exports = {
|
||||
|
||||
getStatus: () => {
|
||||
var rest_options = {
|
||||
host: '192.168.4.5',
|
||||
port: 2020,
|
||||
@ -65,8 +61,5 @@ setInterval(function () {
|
||||
});
|
||||
|
||||
request.end();
|
||||
}, 5000);
|
||||
|
||||
module.exports = {
|
||||
setInterval
|
||||
}
|
||||
}
|
@ -12,7 +12,6 @@
|
||||
"fs": "0.0.1-security",
|
||||
"got": "^11.6.2",
|
||||
"http": "0.0.1-security",
|
||||
"moment": "^2.28.0",
|
||||
"onoff": "^6.0.0",
|
||||
"pigpio": "^3.2.3",
|
||||
"raspberrypi-liquid-crystal": "^1.15.0",
|
||||
|
13
test.js
13
test.js
@ -1,5 +1,12 @@
|
||||
const moment = require('moment'); // require
|
||||
// const moment = require('moment'); // require
|
||||
|
||||
|
||||
t = moment().format('HH:MM:ss');
|
||||
console.log(t)
|
||||
// t = moment().format('HH:MM:ss');
|
||||
// console.log(t)
|
||||
|
||||
|
||||
|
||||
var time = new Date();
|
||||
currentTime = ("0" + time.getHours()).slice(-2) + ":" +
|
||||
("0" + time.getMinutes()).slice(-2)
|
||||
console.log(currentTime)
|
||||
|
Loading…
x
Reference in New Issue
Block a user