edit app.js for file storage
parent
de7d6e8293
commit
f6e172b616
|
|
@ -128,7 +128,7 @@ function drawScreen(message) {
|
||||||
g.drawString(' BPM', g.getWidth() / 2 + 42, g.getHeight() / 2 + 12);
|
g.drawString(' BPM', g.getWidth() / 2 + 42, g.getHeight() / 2 + 12);
|
||||||
} else {
|
} else {
|
||||||
g.setFont('6x8', 2);
|
g.setFont('6x8', 2);
|
||||||
g.drawString('No data', g.getWidth() / 2, g.getHeight() / 2 + 10);
|
g.drawString('No data', g.getWidth() / 2, g.getHeight() / 2 + 5);
|
||||||
g.setFont('6x8', 1);
|
g.setFont('6x8', 1);
|
||||||
g.drawString(message || 'Press button to start', g.getWidth() / 2, g.getHeight() / 2 + 30);
|
g.drawString(message || 'Press button to start', g.getWidth() / 2, g.getHeight() / 2 + 30);
|
||||||
}
|
}
|
||||||
|
|
@ -139,19 +139,22 @@ function drawScreen(message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveDataToCSV() {
|
function saveDataToCSV() {
|
||||||
let csvContent = "Timestamp,Heart Rate(bpm),HRV(ms)\n";
|
let fileName = "heart_rate_data.csv";
|
||||||
|
let file = require("Storage").open(fileName, "a"); // Open the file for appending
|
||||||
|
|
||||||
|
// Check if the file is empty (i.e., newly created)
|
||||||
|
if (file.getLength() === 0) {
|
||||||
|
// Write the header if the file is empty
|
||||||
|
file.write("Timestamp,Heart Rate(bpm),HRV(ms)\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Append the data
|
||||||
logData.forEach(entry => {
|
logData.forEach(entry => {
|
||||||
// Scale HRV - placeholder
|
file.write(`${entry.timestamp},${entry.heartRate},${entry.hrv}\n`);
|
||||||
let scaledHRV = entry.hrv * 13.16;
|
|
||||||
csvContent += `${entry.timestamp},${entry.heartRate},${scaledHRV}\n`;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Write data to the CSV file with the desired file name
|
|
||||||
let fileName = "heart_rate_data.csv";
|
|
||||||
require("Storage").write(fileName, csvContent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
setWatch(function() {
|
setWatch(function() {
|
||||||
if (!isMeasuring) {
|
if (!isMeasuring) {
|
||||||
startMeasure();
|
startMeasure();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue