6
6
Inkplate display (INKPLATE_1BIT);
7
7
8
8
double vcomVoltage = -2.95 ;
9
- int EEPROMaddress = 100 ;
9
+
10
+ // EEPROMAddress must be smaller than 64.
11
+ int EEPROMaddress = 10 ;
10
12
11
13
// Peripheral mode variables and arrays
12
14
#define BUFFER_SIZE 1000
@@ -22,30 +24,35 @@ void setup()
22
24
Serial.begin (115200 );
23
25
EEPROM.begin (64 );
24
26
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
+
25
46
if (EEPROM.read (EEPROMaddress) != 170 )
26
47
{
27
48
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\n Starting VCOM measurment..." );
37
- Serial.print (" \n VCOM: " );
38
- Serial.print (vcomVoltage, 2 );
39
- Serial.println (" V" );
40
- delay (1000 );
41
49
writeVCOMToEEPROM (vcomVoltage);
42
50
EEPROM.write (EEPROMaddress, 170 );
43
51
EEPROM.commit ();
44
- display.selectDisplayMode (INKPLATE_1BIT);
45
52
}
46
53
else
47
54
{
48
- vcomVoltage = ( double )EEPROM. read (EEPROMaddress) / 100 ;
55
+ vcomVoltage = getVCOM () ;
49
56
}
50
57
memset (commandBuffer, 0 , BUFFER_SIZE);
51
58
@@ -445,6 +452,15 @@ double readVCOM()
445
452
return -vcomVolts;
446
453
}
447
454
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
+
448
464
void writeVCOMToEEPROM (double v)
449
465
{
450
466
int vcom = int (abs (v) * 100 );
@@ -559,4 +575,4 @@ void microSDCardTest()
559
575
while (1 );
560
576
}
561
577
display.clearDisplay ();
562
- }
578
+ }
0 commit comments