web server sugma
This commit is contained in:
parent
c4b29be20f
commit
1de8ba78a7
10
main.js
10
main.js
@ -3,8 +3,10 @@
|
||||
* v0.2
|
||||
*
|
||||
* TODO:
|
||||
* Add logic for other sensors
|
||||
* More documentation?
|
||||
* Update documentation
|
||||
* Move some of these functions to the functions file so they can be called from the web server
|
||||
* Or move the web server here and remove the first init
|
||||
* Or just remove the first init call and start the init elsewhere after main() is called
|
||||
*/
|
||||
|
||||
// Custom functions module to keep main script clean
|
||||
@ -156,4 +158,6 @@ function statusCheck(fn, gpio) {
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = main;
|
1
package-lock.json
generated
1
package-lock.json
generated
@ -8,6 +8,7 @@
|
||||
"name": "pscontrolpanel",
|
||||
"version": "0.2.1",
|
||||
"dependencies": {
|
||||
"body-parser": "^1.20.1",
|
||||
"dotenv": "^16.0.3",
|
||||
"ejs": "^3.1.8",
|
||||
"express": "^4.18.2",
|
||||
|
@ -4,6 +4,7 @@
|
||||
"requires": true,
|
||||
"packages": {},
|
||||
"dependencies": {
|
||||
"body-parser": "^1.20.1",
|
||||
"dotenv": "^16.0.3",
|
||||
"ejs": "^3.1.8",
|
||||
"express": "^4.18.2",
|
||||
|
17
websvr.js
17
websvr.js
@ -13,6 +13,12 @@ const http = require('http');
|
||||
const server = http.createServer(app);
|
||||
const config = require('./config.json');
|
||||
const fs = require('fs');
|
||||
// const bodyParser = require('body-parser');
|
||||
const core = require('./main.js');
|
||||
const fn = require('./functions.js');
|
||||
const gpio = require('rpi-gpio');
|
||||
|
||||
app.use(express.urlencoded());
|
||||
|
||||
app.use(express.static(__dirname + '/www/public'));
|
||||
app.set('views', __dirname + '/www/views');
|
||||
@ -29,8 +35,15 @@ app.get('/', (req, res) => {
|
||||
});
|
||||
|
||||
app.post('/', (req, res) => {
|
||||
if (config.debugMode) console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] I: ${req.body}`);
|
||||
// oop
|
||||
fs.readFile(__dirname + '/config.json', (err, data) => {
|
||||
// console.log(JSON.parse(data));
|
||||
res.render('index', JSON.parse(data));
|
||||
if (req.body.start != undefined) {
|
||||
core.main(fn, gpio);
|
||||
}
|
||||
// res.send(200);
|
||||
});
|
||||
console.log(req.body);
|
||||
});
|
||||
|
||||
server.listen(config.web.port, config.web.ip);
|
@ -10,10 +10,10 @@
|
||||
<div id="status">Auger: <%= status.auger %> | Igniter: <%= status.igniter %> | Combustion Blower: <%= status.blower %></div>
|
||||
<div id="safeties">Vacuum: <%= status.vacuum %> | Proof of Fire: <%= status.pof %></div>
|
||||
<div id="controls-container">
|
||||
<form>
|
||||
<form action="/" method="post">
|
||||
<!-- Start | Shutdown | Reload Settings -->
|
||||
<div id="buttons">
|
||||
<button id="ignite" onclick="">Start</button><button id="shutdown">Shutdown</button><button id="reload">Reload Settings</button><br>
|
||||
<input type="submit" id="ignite" value="Start" name="start"><input type="submit" id="shutdown" value="Shutdown" name="shutdown"><input type="submit" id="reload" value="Reload" name="reload"><br>
|
||||
</div>
|
||||
<!-- Set feed rates -->
|
||||
<label for="augerOn">Auger On Interval: </label><input type="number" id="augerOn" name="augerOn" min="500" max="1000" value="<%= intervals.augerOn %>">ms<br>
|
||||
|
Loading…
Reference in New Issue
Block a user