-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSDcard.h
63 lines (55 loc) · 1.49 KB
/
SDcard.h
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
58
59
60
61
62
63
#ifndef SDcard_H_
#define SDcard_H_
#include <SPI.h> // SD card & FAT filesystem library
#include <SD.h>
Sd2Card card;
File dataFile;
void Variables_init();
void Write_to_file();
void Variables_init(){
char File_Name[15]="main.txt";
String cmd;
String subString;
uint16_t variable_index;
//Make sure the file exist
if (SD.exists(File_Name)) ;
else{
Serial.println("Error 3");
lcd.clear();
lcd.setCursor(0,3);
lcd.print("Error 3");
while (1);
}
dataFile = SD.open(File_Name, FILE_READ); //open the file
//available_data = dataFile.available();
/*
* Variables decleration shoud be like this
* FillingTime=5
* The space seperation between the variable and the number is paramount
*/
while ( dataFile.available() > 0 ) {
cmd = dataFile.readStringUntil('\n');
if(cmd.startsWith("FillingTime"))
{
variable_index = cmd.indexOf('=')+1;
subString=cmd.substring(variable_index);
Filling.Time=subString.toFloat();
Serial.println(Filling.Time);
}
else if(cmd.startsWith("WaitingTime"))
{
variable_index = cmd.indexOf('=')+1;
subString=cmd.substring(variable_index);
wait.Time=subString.toFloat();
Serial.println(wait.Time);
}
else if(cmd.startsWith("FillingSpeed"))
{
variable_index = cmd.indexOf('=')+1;
subString=cmd.substring(variable_index);
fillSpeed=subString.toInt();
Serial.println(fillSpeed);
}
}
}
#endif