Skip to content

Commit 65a54f6

Browse files
committed
2 parents 4249244 + 58eb77a commit 65a54f6

File tree

1 file changed

+33
-17
lines changed

1 file changed

+33
-17
lines changed

examples/Inkplate6PLUS/Others/Inkplate_Factory_Programming_VCOM/Inkplate_Factory_Programming_VCOM.ino

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
Inkplate display(INKPLATE_1BIT);
77

88
double vcomVoltage = -2.95;
9-
int EEPROMaddress = 100;
9+
10+
// EEPROMAddress must be smaller than 64.
11+
int EEPROMaddress = 10;
1012

1113
// Peripheral mode variables and arrays
1214
#define BUFFER_SIZE 1000
@@ -22,30 +24,35 @@ void setup()
2224
Serial.begin(115200);
2325
EEPROM.begin(64);
2426

27+
// Init the touchscreen - you need to touch the bottom right edge to activate it
28+
if (display.tsInit(true))
29+
{
30+
Serial.println("Touchscreen init ok");
31+
}
32+
else
33+
{
34+
Serial.println("Touchscreen init fail");
35+
display.setTextSize(4);
36+
display.setTextColor(0, 7);
37+
display.setCursor(300, 300);
38+
display.print("Touch error");
39+
display.display();
40+
while (true);
41+
}
42+
43+
// Turn on the frontlight
44+
display.frontlight(true);
45+
2546
if (EEPROM.read(EEPROMaddress) != 170)
2647
{
2748
microSDCardTest();
28-
display.einkOn();
29-
display.pinModeInternal(MCP23017_INT_ADDR, display.mcpRegsInt, 6, INPUT_PULLUP);
30-
display.display();
31-
display.einkOn();
32-
delay(100);
33-
vcomVoltage = readVCOM();
34-
display.einkOff();
35-
delay(1000);
36-
Serial.print("\n\nStarting VCOM measurment...");
37-
Serial.print("\nVCOM: ");
38-
Serial.print(vcomVoltage, 2);
39-
Serial.println("V");
40-
delay(1000);
4149
writeVCOMToEEPROM(vcomVoltage);
4250
EEPROM.write(EEPROMaddress, 170);
4351
EEPROM.commit();
44-
display.selectDisplayMode(INKPLATE_1BIT);
4552
}
4653
else
4754
{
48-
vcomVoltage = (double)EEPROM.read(EEPROMaddress) / 100;
55+
vcomVoltage = getVCOM();
4956
}
5057
memset(commandBuffer, 0, BUFFER_SIZE);
5158

@@ -445,6 +452,15 @@ double readVCOM()
445452
return -vcomVolts;
446453
}
447454

455+
double getVCOM()
456+
{
457+
display.einkOn();
458+
uint16_t vcom = ((readReg(0x04) & 1) << 8) | readReg(0x03);
459+
double vcomVolts = vcom * 10.0 / 1000.0;
460+
display.einkOff();
461+
return vcomVolts;
462+
}
463+
448464
void writeVCOMToEEPROM(double v)
449465
{
450466
int vcom = int(abs(v) * 100);
@@ -559,4 +575,4 @@ void microSDCardTest()
559575
while(1);
560576
}
561577
display.clearDisplay();
562-
}
578+
}

0 commit comments

Comments
 (0)