-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrite_data.ino
59 lines (57 loc) · 1.59 KB
/
write_data.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
void writeperformancetosd() {
Serial.println("writing to SD");
int totaltime = ((minute() * 60) + second());
String dataString;
String splitsdatastring;
dataString += datestring;
dataString += ",";
//dataString += minute();
//dataString += ":";
//dataString += second();
dataString += totaltime;
dataString += ",";
dataString += meters;
dataString += ",";
float average = (float) meters / totaltime;
average = average * 60;
dataString += average;
if (FileSystem.begin()) {
Serial.println("filesystem begin OK");
}
else {
Serial.println("filesystem begin error");
}
String clickstring;
clickstring += datestring;
clickstring += ",";
clickstring += clicks;
String splitsfilename;
splitsfilename += "/mnt/sda1/arduino/www/";
splitsfilename += datestring;
splitsfilename += ".csv";
char splitschar[50];
splitsfilename.toCharArray(splitschar, 50);
File dataFile = FileSystem.open("/mnt/sda1/arduino/www/datalog.csv", FILE_APPEND);
File clicksFile = FileSystem.open("/mnt/sda1/arduino/www/clicks.csv", FILE_APPEND);
File splitfile = FileSystem.open(splitschar, FILE_WRITE);
if (dataFile) {
dataFile.println(dataString);
dataFile.close();
Serial.println(dataString);
clicksFile.println(clickstring);
clicksFile.close();
Serial.println(clickstring);
Serial.println(splitschar);
splitfile.println("splits");
for (int x = 0; x < 16; x++) {
if (!splits.isEmpty()) {
splitfile.println(splits.pop());
}
}
splitfile.close();
}
else {
Serial.println("error datafile");
}
delay(1000);
}