-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsdhandler.ino
43 lines (41 loc) · 1.07 KB
/
sdhandler.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
int checkSD() {
SD_INSERTED = SD.begin(SD_CS);
SD_INSERTED &= (SD.totalBytes() - SD.usedBytes() > 1024 * 1000 * 100);
SD_INSERTED &= SD.cardType() != CARD_NONE;
return SD_INSERTED ? 1 : 2;
}
void ejectSD() {
TFT.fillScreen(TFT_BLACK);
drawBmp("/sdicon.bmp", 0, 0);
TFT.setTextDatum(MC_DATUM);
if (SD_INSERTED) {
SD.end();
SD_INSERTED = false;
TFT.setCursor(70, 120, 4);
TFT.setTextColor(TFT_GREEN, TFT_WHITE);
TFT.println("EJECTED");
} else {
if (checkSD() == 1) {
SD_INSERTED = true;
TFT.setTextColor(TFT_GREEN, TFT_WHITE);
TFT.setCursor(100, 120, 4);
TFT.println("OK");
TFT.setCursor(56, 177, 4);
TFT.printf("Size: %llu GiB", SD.cardSize() / (1073741824));
csv_prepare();
} else {
SD_INSERTED = false;
TFT.setTextColor(TFT_RED, TFT_WHITE);
TFT.setCursor(115, 120, 4);
TFT.println("?");
}
}
delay(3000);
TFT.fillScreen(TFT_BLACK);
TFT.setCursor(0, 0, 4);
drawBmp("/background.bmp", 0, 0);
SD_EJECT_REQEST = false;
}
void ejectISR() {
SD_EJECT_REQEST = true;
}