|
|
@@ -42,6 +42,8 @@ async function init() {
|
|
|
);
|
|
|
|
|
|
showHourSelection();
|
|
|
+ document.getElementById('log-entries')
|
|
|
+ .addEventListener('click', () => logReadings(readings));
|
|
|
}
|
|
|
|
|
|
function getHoursAgo():number {
|
|
|
@@ -119,3 +121,32 @@ async function getRecentData(
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+/**
|
|
|
+ * Log readings to the console in a way that can be imported to a spreadsheet.
|
|
|
+ * @param readings The list of readings to log.
|
|
|
+ */
|
|
|
+function logReadings(readings: Reading[]) {
|
|
|
+ const separator = '\t';
|
|
|
+ const header = [
|
|
|
+ 'Time',
|
|
|
+ 'Temperature (C)',
|
|
|
+ 'Humidity (%)',
|
|
|
+ 'Pressure (hPa)',
|
|
|
+ 'Light',
|
|
|
+ 'Delay (minutes)',
|
|
|
+ ].join(separator);
|
|
|
+
|
|
|
+ const lines = readings.map(r => {
|
|
|
+ const time = new Date(r.time);
|
|
|
+ return [
|
|
|
+ `"${time.toLocaleDateString()} ${time.toLocaleTimeString()}"`,
|
|
|
+ r.temperature,
|
|
|
+ r.humidity,
|
|
|
+ r.pressure,
|
|
|
+ r.light,
|
|
|
+ r.delay,
|
|
|
+ ].join(separator);
|
|
|
+ });
|
|
|
+ console.log(header + '\n' + lines.join('\n'));
|
|
|
+}
|