Files
IOT-recept-printer/print.js
2018-07-17 14:57:52 +01:00

35 lines
1.0 KiB
JavaScript

const PythonShell = require('python-shell');
const Result = require('./resultbuilder');
const WeatherAPI = require('./weatherAPI');
module.exports.print = async function(name, coords) {
let text = Result.genCompilerSettings({
padding: 2,
lineBreaks: 1,
lines: [
{
content: `Hello, ${name}!`,
align: `center`,
size: `large`
},
{
content: `The weather at ${coords} is:`,
align: `left`,
size: `small`
},
{
content: `${await WeatherAPI.getWeather(1, coords)}`,
align: `left`,
size: `small`
},
{
content: `The forcast for today is ${await WeatherAPI.getWeather(2, coords)}`,
align: `left`,
size: `small`
}
]
});
PythonShell.run('printer/write.py', text, function (err, results) {
if (err) throw err;
});
}