Skip to content

Commit b1bf1d9

Browse files
committed
Added micro SD card slot for all Inkplate boards with VCOM programming, fixed micro SD card test code on Inkplate 10, fixed VCOM programming on Inkplate 5 board.
1 parent f3ba880 commit b1bf1d9

File tree

4 files changed

+208
-30
lines changed

4 files changed

+208
-30
lines changed

examples/Inkplate10/Others/Inkplate_Factory_Programming_VCOM/Inkplate_Factory_Programming_VCOM.ino

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -556,18 +556,11 @@ void microSDCardTest()
556556
display.setCursor(100, 100);
557557
display.print("microSD card slot test ");
558558

559-
if (checkMicroSDCard())
560-
{
561-
display.print("OK!");
562-
display.display();
563-
}
564-
else
559+
if (!checkMicroSDCard())
565560
{
566561
display.print("FAIL!");
567562
display.display();
568563
while(1);
569564
}
570-
571565
display.clearDisplay();
572-
delay(2500);
573566
}

examples/Inkplate5/Others/Inkplate_Factory_Programming_VCOM/Inkplate_Factory_Programming_VCOM.ino

Lines changed: 78 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,21 @@ 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
void setup()
1720
{
1821
display.begin();
1922
Serial.begin(115200);
2023
EEPROM.begin(64);
2124

25+
microSDCardTest();
26+
2227
if (EEPROM.read(EEPROMaddress) != 170)
2328
{
24-
display.digitalWriteMCP(3, HIGH);
25-
display.digitalWriteMCP(4, HIGH);
26-
display.digitalWriteMCP(5, HIGH);
27-
display.pinModeMCP(6, INPUT_PULLUP);
29+
display.einkOn();
30+
display.pinModeInternal(MCP23017_INT_ADDR, display.mcpRegsInt, 6, INPUT_PULLUP);
2831
display.display();
2932
display.einkOn();
3033
delay(100);
@@ -421,7 +424,7 @@ void writeToScreen()
421424
double readVCOM()
422425
{
423426
double vcomVolts;
424-
writeReg(0x01, B00111111); // enable all rails
427+
display.einkOn();
425428
writeReg(0x04, (readReg(0x04) | B00100000));
426429
writeToScreen();
427430
writeReg(0x04, (readReg(0x04) | B10000000));
@@ -442,13 +445,12 @@ void writeVCOMToEEPROM(double v)
442445
int vcom = int(abs(v) * 100);
443446
int vcomH = (vcom >> 8) & 1;
444447
int vcomL = vcom & 0xFF;
445-
// First, we have to power up TPS65186
446-
// Pull TPS65186 WAKEUP pin to High
447-
display.digitalWriteMCP(3, HIGH);
448448

449-
// Pull TPS65186 PWR pin to High
450-
display.digitalWriteMCP(4, HIGH);
451-
delay(10);
449+
// Set MCP23017 pin where TPS65186 INT pin is connectet to input pull up
450+
display.pinModeInternal(MCP23017_INT_ADDR, display.mcpRegsInt, 6, INPUT_PULLUP);
451+
452+
// First power up TPS65186 so we can communicate with it
453+
display.einkOn();
452454

453455
// Send to TPS65186 first 8 bits of VCOM
454456
writeReg(0x03, vcomL);
@@ -464,24 +466,20 @@ void writeVCOMToEEPROM(double v)
464466
delay(1);
465467
do
466468
{
467-
delay(1);
468-
} while (display.digitalReadMCP(6));
469+
delay(1);
470+
} while (display.digitalReadInternal(MCP23017_INT_ADDR, display.mcpRegsInt, 6));
469471

470472
// Clear Interrupt flag by reading INT1 register
471473
readReg(0x07);
472474

473475
// Now, power off whole TPS
474-
// Pull TPS65186 WAKEUP pin to Low
475-
display.digitalWriteMCP(3, LOW);
476-
477-
// Pull TPS65186 PWR pin to Low
478-
display.digitalWriteMCP(4, LOW);
476+
display.einkOff();
479477

480478
// Wait a little bit...
481479
delay(1000);
482480

483481
// Power up TPS again
484-
display.digitalWriteMCP(3, HIGH);
482+
display.einkOn();
485483

486484
delay(10);
487485

@@ -491,10 +489,69 @@ void writeVCOMToEEPROM(double v)
491489

492490
if (vcom != (vcomL | (vcomH << 8)))
493491
{
494-
Serial.println("\nVCOM EEPROM PROGRAMMING FAILED!\n");
492+
Serial.println("\nVCOM EEPROM PROGRAMMING FAILED!\n");
495493
}
496494
else
497495
{
498-
Serial.println("\nVCOM EEPROM PROGRAMMING OK\n");
496+
Serial.println("\nVCOM EEPROM PROGRAMMING OK\n");
497+
}
498+
}
499+
500+
int checkMicroSDCard()
501+
{
502+
int sdInitOk = 0;
503+
sdInitOk = display.sdCardInit();
504+
505+
if (sdInitOk)
506+
{
507+
File file;
508+
509+
if (file.open("/testFile.txt", O_CREAT | O_RDWR))
510+
{
511+
file.print(testString);
512+
file.close();
513+
}
514+
else
515+
{
516+
return 0;
517+
}
518+
519+
delay(250);
520+
521+
if (file.open("/testFile.txt", O_RDWR))
522+
{
523+
char sdCardString[sdCardTestStringLength];
524+
file.read(sdCardString, sizeof(sdCardString));
525+
sdCardString[file.fileSize()] = 0;
526+
int stringCompare = strcmp(testString, sdCardString);
527+
file.remove();
528+
file.close();
529+
if (stringCompare != 0)
530+
return 0;
531+
}
532+
else
533+
{
534+
return 0;
535+
}
536+
}
537+
else
538+
{
539+
return 0;
540+
}
541+
return 1;
542+
}
543+
544+
void microSDCardTest()
545+
{
546+
display.setTextSize(4);
547+
display.setCursor(100, 100);
548+
display.print("microSD card slot test ");
549+
550+
if (!checkMicroSDCard())
551+
{
552+
display.print("FAIL!");
553+
display.display();
554+
while(1);
499555
}
556+
display.clearDisplay();
500557
}

examples/Inkplate6/Others/Inkplate_Factory_Programming_VCOM/Inkplate_Factory_Programming_VCOM.ino

Lines changed: 64 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
uint8_t mcpRegsInt[22];
1720

1821
void setup()
@@ -21,6 +24,8 @@ void setup()
2124
Serial.begin(115200);
2225
EEPROM.begin(64);
2326

27+
microSDCardTest();
28+
2429
if (EEPROM.read(EEPROMaddress) != 170)
2530
{
2631
display.digitalWriteInternal(MCP23017_ADDR, mcpRegsInt, 3, HIGH);
@@ -512,3 +517,62 @@ void writeVCOMToEEPROM(double v)
512517
Serial.println("\nVCOM EEPROM PROGRAMMING OK\n");
513518
}
514519
}
520+
521+
int checkMicroSDCard()
522+
{
523+
int sdInitOk = 0;
524+
sdInitOk = display.sdCardInit();
525+
526+
if (sdInitOk)
527+
{
528+
File file;
529+
530+
if (file.open("/testFile.txt", O_CREAT | O_RDWR))
531+
{
532+
file.print(testString);
533+
file.close();
534+
}
535+
else
536+
{
537+
return 0;
538+
}
539+
540+
delay(250);
541+
542+
if (file.open("/testFile.txt", O_RDWR))
543+
{
544+
char sdCardString[sdCardTestStringLength];
545+
file.read(sdCardString, sizeof(sdCardString));
546+
sdCardString[file.fileSize()] = 0;
547+
int stringCompare = strcmp(testString, sdCardString);
548+
file.remove();
549+
file.close();
550+
if (stringCompare != 0)
551+
return 0;
552+
}
553+
else
554+
{
555+
return 0;
556+
}
557+
}
558+
else
559+
{
560+
return 0;
561+
}
562+
return 1;
563+
}
564+
565+
void microSDCardTest()
566+
{
567+
display.setTextSize(4);
568+
display.setCursor(100, 100);
569+
display.print("microSD card slot test ");
570+
571+
if (!checkMicroSDCard())
572+
{
573+
display.print("FAIL!");
574+
display.display();
575+
while(1);
576+
}
577+
display.clearDisplay();
578+
}

examples/Inkplate6PLUS/Others/Inkplate_Factory_Programming_VCOM/Inkplate_Factory_Programming_VCOM.ino

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "image.h"
44
#include <Wire.h>
55

6-
Inkplate display(INKPLATE_3BIT);
6+
Inkplate display(INKPLATE_1BIT);
77

88
double vcomVoltage = -2.95;
99
int EEPROMaddress = 100;
@@ -13,12 +13,17 @@ int EEPROMaddress = 100;
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
void setup()
1720
{
1821
display.begin();
1922
Serial.begin(115200);
2023
EEPROM.begin(64);
2124

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

0 commit comments

Comments
 (0)