Skip to content

Commit f3ba880

Browse files
committed
Added microSD card test on Inkplate10
1 parent 94571e2 commit f3ba880

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

examples/Inkplate10/Others/Inkplate_Factory_Programming_VCOM/Inkplate_Factory_Programming_VCOM.ino

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ int EEPROMaddress = 0;
1313
char commandBuffer[BUFFER_SIZE + 1];
1414
char strTemp[2001];
1515

16+
const char sdCardTestStringLength = 100;
17+
const char *testString = {"This is some test string..."};
18+
1619
// Internal registers of MCP
1720
uint8_t mcpRegsInt[22];
1821

@@ -22,6 +25,8 @@ void setup()
2225
Serial.begin(115200);
2326
EEPROM.begin(64);
2427

28+
microSDCardTest();
29+
2530
vcomVoltage = -1.19;
2631

2732
if (EEPROM.read(EEPROMaddress) != 170)
@@ -500,3 +505,69 @@ void writeVCOMToEEPROM(double v)
500505
Serial.println("\nVCOM EEPROM PROGRAMMING OK\n");
501506
}
502507
}
508+
509+
int checkMicroSDCard()
510+
{
511+
int sdInitOk = 0;
512+
sdInitOk = display.sdCardInit();
513+
514+
if (sdInitOk)
515+
{
516+
File file;
517+
518+
if (file.open("/testFile.txt", O_CREAT | O_RDWR))
519+
{
520+
file.print(testString);
521+
file.close();
522+
}
523+
else
524+
{
525+
return 0;
526+
}
527+
528+
delay(250);
529+
530+
if (file.open("/testFile.txt", O_RDWR))
531+
{
532+
char sdCardString[sdCardTestStringLength];
533+
file.read(sdCardString, sizeof(sdCardString));
534+
sdCardString[file.fileSize()] = 0;
535+
int stringCompare = strcmp(testString, sdCardString);
536+
file.remove();
537+
file.close();
538+
if (stringCompare != 0)
539+
return 0;
540+
}
541+
else
542+
{
543+
return 0;
544+
}
545+
}
546+
else
547+
{
548+
return 0;
549+
}
550+
return 1;
551+
}
552+
553+
void microSDCardTest()
554+
{
555+
display.setTextSize(5);
556+
display.setCursor(100, 100);
557+
display.print("microSD card slot test ");
558+
559+
if (checkMicroSDCard())
560+
{
561+
display.print("OK!");
562+
display.display();
563+
}
564+
else
565+
{
566+
display.print("FAIL!");
567+
display.display();
568+
while(1);
569+
}
570+
571+
display.clearDisplay();
572+
delay(2500);
573+
}

0 commit comments

Comments
 (0)