Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
fscherwi committed Dec 29, 2017
1 parent dd6041d commit c4de537
Showing 1 changed file with 47 additions and 39 deletions.
86 changes: 47 additions & 39 deletions src/weather.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,48 +125,56 @@ function error_output(code) {
}
}
/* istanbul ignore next */
exports.get = function tfget(HOST, PORT, WAIT, live) {
get_uid(HOST, PORT);
if (live) {
function simple(HOST, PORT, WAIT) {
setTimeout(function () {
tfinit(HOST, PORT);
ipcon.on(Tinkerforge.IPConnection.CALLBACK_CONNECTED,
function () {
tfdata_get();
}
);
setTimeout(function () {
console.log('\nRelative Humidity:\t' + output_data[0] + '\n' +
'Air pressure:\t\t' + output_data[1] + '\n' +
'Temperature:\t\t' + output_data[2] + '\n' +
'Illuminance:\t\t' + output_data[3] + '\n' +
'\nTime:\t\t\t' + getTime(new Date()) + '\n');
ipcon.disconnect();
tfinit(HOST, PORT);
}, 150);
setTimeout(function () {
process.stdin.on('data',
function () {
ipcon.disconnect();
process.exit();
}
);
process.exit(0);
}, 10);
}, 25);
}
/* istanbul ignore next */
function live(HOST, PORT, WAIT) {
setTimeout(function () {
ipcon.disconnect();
tfinit(HOST, PORT);
}, 150);
setTimeout(function () {
process.stdin.on('data',
function () {
ipcon.disconnect();
process.exit();
}
);
tfdata_get();
setInterval(function () {
tfdata_get();
setInterval(function () {
tfdata_get();
console.log('\033[2J');
console.log('\nRelative Humidity:\t' + output_data[0] + '\n' +
'Air pressure:\t\t' + output_data[1] + '\n' +
'Temperature:\t\t' + output_data[2] + '\n' +
'Illuminance:\t\t' + output_data[3] + '\n' +
'\nTime:\t\t\t' + getTime(new Date()) + '\n');
}, WAIT);
}, 25);
console.log('\033[2J');
console.log('\nRelative Humidity:\t' + output_data[0] + '\n' +
'Air pressure:\t\t' + output_data[1] + '\n' +
'Temperature:\t\t' + output_data[2] + '\n' +
'Illuminance:\t\t' + output_data[3] + '\n' +
'\nTime:\t\t\t' + getTime(new Date()) + '\n');
}, WAIT);
}, 25);
}
/* istanbul ignore next */
exports.get = function tfget(HOST, PORT, WAIT, live) {
get_uid(HOST, PORT);
if (live) {
live(HOST, PORT, WAIT);
} else {
setTimeout(function () {
tfinit(HOST, PORT);
ipcon.on(Tinkerforge.IPConnection.CALLBACK_CONNECTED,
function () {
tfdata_get();
}
);
setTimeout(function () {
console.log('\nRelative Humidity:\t' + output_data[0] + '\n' +
'Air pressure:\t\t' + output_data[1] + '\n' +
'Temperature:\t\t' + output_data[2] + '\n' +
'Illuminance:\t\t' + output_data[3] + '\n' +
'\nTime:\t\t\t' + getTime(new Date()) + '\n');
ipcon.disconnect();
process.exit(0);
}, 10);
}, 25);
simple(HOST, PORT, WAIT);
}
};

0 comments on commit c4de537

Please sign in to comment.