Skip to content

Commit 160ea2f

Browse files
authored
Merge dev into master
Merge pull request #141 from e-radionicacom/dev - Added Inkplate2 board - Fixing Inkplate6PLUS compile - External address of MCP23017 fix - Inkplate 10 waveform - waveform is stored in ESP32 EEPROM - Added new examples for waveform on Inkplate 10, modified VCOM factory programming
2 parents 38845de + a0dd222 commit 160ea2f

File tree

20 files changed

+948
-65
lines changed

20 files changed

+948
-65
lines changed

.github/workflows/compile.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ jobs:
2727
fqbn: Inkplate_Boards:esp32:Inkplate6COLOR
2828
additional-sketch-paths: |
2929
- examples/Inkplate6COLOR
30+
- board:
31+
fqbn: Inkplate_Boards:esp32:Inkplate2
32+
additional-sketch-paths: |
33+
- examples/Inkplate2
3034
steps:
3135
- name: Checkout
3236
uses: actions/checkout@v2
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
Inkplate_EEPROM_Usage example for e-radionica.com Inkplate 10
3+
For this example, you will need only USB cable and Inkplate 10.
4+
Select "Inkplate 10(ESP32)" from Tools -> Board menu.
5+
Don't have "Inkplate 10(ESP32)" option? Follow our tutorial and add it:
6+
https://e-radionica.com/en/blog/add-inkplate-6-to-arduino-ide/
7+
8+
This example will show you how to use EEPROM with Inkplate board.
9+
It shows how to use basic operations with EEPROM like clearing, writing, and reading.
10+
CAUTION! Changing EEPROM size can wipe waveform data.
11+
CAUTION! EEPROM addresses from 0 to 75 are used for waveform. DO NOT WRITE OR MODIFY DATA ON THESE ADDRESSES!
12+
13+
Want to learn more about Inkplate? Visit www.inkplate.io
14+
Looking to get support? Write on our forums: http://forum.e-radionica.com/en/
15+
13 March 2022 by e-radionica.com
16+
*/
17+
18+
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
19+
#ifndef ARDUINO_INKPLATE10
20+
#error "Wrong board selection for this example, please select Inkplate 10 in the boards menu."
21+
#endif
22+
23+
#include "EEPROM.h" // Include ESP32 EEPROM library
24+
#include "Inkplate.h" // Include Inkplate library to the sketch
25+
26+
#define EEPROM_START_ADDR 76 // Start EEPROM address for user data. Addresses below address 76 are waveform data!
27+
#define EEPROM_SIZE 128 // How much data to write to EEPROM in this example
28+
29+
Inkplate display(INKPLATE_1BIT); // Create object on Inkplate library and set library to work in monochrome mode
30+
31+
void setup()
32+
{
33+
display.begin(); // Init library (you should call this function ONLY ONCE)
34+
35+
// Init EEPROM library with 512 of EEPROM size. Do not change this value, it can wipe waveform data!
36+
EEPROM.begin(512);
37+
38+
display.setTextSize(4); // Set text size
39+
display.println("Clearing EEPROM...\n"); // Print message
40+
display.partialUpdate(); // Use partial updates for refreshing the display
41+
clearEEPROM(); // Clear user EEPROM data
42+
delay(500); // Wait a little bit...
43+
44+
display.println("Writing data to EEPROM...\n"); // Print message
45+
display.partialUpdate(); // Use partial updates for refreshing the display
46+
writeEEPROM(); // Write some data to EEPROM
47+
delay(500); // Wait a little bit...
48+
49+
display.println("Reading data from EEPROM:\n"); // Print message
50+
display.partialUpdate(); // Use partial updates for refreshing the display
51+
display.setTextSize(1); // Use smaller text so everything can fit on display
52+
printEEPROM(); // Read data from EEPROM and display it on screen
53+
delay(500); // Wait a little bit...
54+
}
55+
56+
void loop()
57+
{
58+
// Empty...
59+
}
60+
61+
// Function for clearing EEPROM data (it will NOT clear waveform data)
62+
void clearEEPROM()
63+
{
64+
for (int i = 0; i < EEPROM_SIZE; i++)
65+
{
66+
EEPROM.write(i + EEPROM_START_ADDR,
67+
0); // Start writing from address 76 (anything below that address number is waveform data!)
68+
}
69+
EEPROM.commit();
70+
}
71+
72+
// Function writes data to EEPROM
73+
void writeEEPROM()
74+
{
75+
for (int i = 0; i < EEPROM_SIZE; i++)
76+
{
77+
EEPROM.write(i + EEPROM_START_ADDR,
78+
i); // Start reading from address 76 (anything below that address number is waveform data!)
79+
}
80+
EEPROM.commit();
81+
}
82+
83+
// Function reads back previously written data and displays it on screen.
84+
void printEEPROM()
85+
{
86+
for (int i = 0; i < EEPROM_SIZE; i++)
87+
{
88+
display.print(EEPROM.read(i + EEPROM_START_ADDR), DEC);
89+
if (i != EEPROM_SIZE - 1)
90+
display.print(", ");
91+
}
92+
display.partialUpdate();
93+
}

examples/Inkplate10/Others/Inkplate_Factory_Programming_VCOM/Inkplate_Factory_Programming_VCOM.ino

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

88
double vcomVoltage;
9-
int EEPROMaddress = 0;
9+
10+
// EEPROMOffset must be between 0 and 20
11+
const int EEPROMOffset = 0;
12+
int EEPROMaddress = sizeof(waveformData) + EEPROMOffset;
1013

1114
// Peripheral mode variables and arrays
1215
#define BUFFER_SIZE 1000
@@ -19,36 +22,89 @@ const char *testString = {"This is some test string..."};
1922
// Internal registers of MCP
2023
uint8_t mcpRegsInt[22];
2124

25+
// All waveforms for Inkplate 10 boards
26+
uint8_t waveform1[8][9] = {{0, 0, 0, 0, 0, 0, 0, 1, 0}, {0, 0, 0, 2, 2, 2, 1, 1, 0}, {0, 0, 2, 1, 1, 2, 2, 1, 0},
27+
{0, 1, 2, 2, 1, 2, 2, 1, 0}, {0, 0, 2, 1, 2, 2, 2, 1, 0}, {0, 2, 2, 2, 2, 2, 2, 1, 0},
28+
{0, 0, 0, 0, 0, 2, 1, 2, 0}, {0, 0, 0, 2, 2, 2, 2, 2, 0}};
29+
uint8_t waveform2[8][9] = {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 2, 1, 2, 1, 1, 0}, {0, 0, 0, 2, 2, 1, 2, 1, 0},
30+
{0, 0, 2, 2, 1, 2, 2, 1, 0}, {0, 0, 0, 2, 1, 1, 1, 2, 0}, {0, 0, 2, 2, 2, 1, 1, 2, 0},
31+
{0, 0, 0, 0, 0, 1, 2, 2, 0}, {0, 0, 0, 0, 2, 2, 2, 2, 0}};
32+
uint8_t waveform3[8][9] = {{0, 3, 3, 3, 3, 3, 3, 3, 0}, {0, 1, 2, 1, 1, 2, 2, 1, 0}, {0, 2, 2, 2, 1, 2, 2, 1, 0},
33+
{0, 0, 2, 2, 2, 2, 2, 1, 0}, {0, 3, 3, 2, 1, 1, 1, 2, 0}, {0, 3, 3, 2, 2, 1, 1, 2, 0},
34+
{0, 2, 1, 2, 1, 2, 1, 2, 0}, {0, 3, 3, 3, 2, 2, 2, 2, 0}};
35+
uint8_t *waveformList[] = {&waveform1[0][0], &waveform2[0][0], &waveform3[0][0]};
36+
37+
// Calculate number of possible waveforms
38+
uint8_t waveformListSize = (sizeof(waveformList) / sizeof(uint8_t *));
39+
40+
// Struct for reading waveform from EEPROM memory of ESP32
41+
struct waveformData waveformEEPROM;
42+
43+
int currentWaveform = 0;
44+
2245
void setup()
2346
{
24-
display.begin();
2547
Serial.begin(115200);
26-
EEPROM.begin(64);
48+
display.begin();
49+
EEPROM.begin(512);
2750

28-
vcomVoltage = -1.19;
51+
vcomVoltage = -1.3;
2952

53+
// Check if VCOM and waveform programming is not already done
3054
if (EEPROM.read(EEPROMaddress) != 170)
3155
{
3256
microSDCardTest();
3357
display.pinModeInternal(MCP23017_INT_ADDR, mcpRegsInt, 6, INPUT_PULLUP);
3458
writeVCOMToEEPROM(vcomVoltage);
3559
EEPROM.write(EEPROMaddress, 170);
3660
EEPROM.commit();
37-
display.selectDisplayMode(INKPLATE_1BIT);
61+
display.selectDisplayMode(INKPLATE_3BIT);
62+
63+
// Display all shades of gray on epaper with first waveform
64+
showGradient(currentWaveform);
65+
66+
// Until "Load" key is not pressed, user can select one of the waveforms
67+
while (!display.readTouchpad(PAD2))
68+
{
69+
// Select and show next waveform
70+
if (display.readTouchpad(PAD3))
71+
{
72+
currentWaveform++;
73+
if (currentWaveform > waveformListSize - 1)
74+
currentWaveform = 0;
75+
showGradient(currentWaveform);
76+
}
77+
78+
// Select and show prev. waveform
79+
if (display.readTouchpad(PAD1))
80+
{
81+
currentWaveform--;
82+
if (currentWaveform < 0)
83+
currentWaveform = waveformListSize - 1;
84+
showGradient(currentWaveform);
85+
}
86+
}
87+
88+
// Load waveform in EEPROM memory of ESP32
89+
waveformEEPROM.waveformId = INKPLATE10_WAVEFORM1 + currentWaveform;
90+
memcpy(&waveformEEPROM.waveform, waveformList[currentWaveform], sizeof(waveformEEPROM.waveform));
91+
waveformEEPROM.checksum = display.calculateChecksum(waveformEEPROM);
92+
display.burnWaveformToEEPROM(waveformEEPROM);
3893
}
3994
else
4095
{
41-
Serial.println("Vcom already set!");
42-
// vcomVoltage = (double)EEPROM.read(EEPROMaddress) / 100;
96+
Serial.println("Vcom and waveform already set!");
97+
display.einkOn();
98+
vcomVoltage = (double)(readReg(0x03) | ((uint16_t)(readReg(0x04 & 1) << 8))) / -100;
99+
display.getWaveformFromEEPROM(&waveformEEPROM) ? waveformEEPROM.waveformId : -1;
43100
}
44101
memset(commandBuffer, 0, BUFFER_SIZE);
45102

46-
showSplashScreen();
103+
showSplashScreen(waveformEEPROM);
47104
}
48105

49106
void loop()
50107
{
51-
52108
if (Serial.available())
53109
{
54110
while (Serial.available())
@@ -396,9 +452,9 @@ uint8_t readReg(uint8_t _reg)
396452
return Wire.read();
397453
}
398454

399-
void showSplashScreen()
455+
void showSplashScreen(struct waveformData _w)
400456
{
401-
display.clean(0, 1);
457+
display.clearDisplay();
402458
display.display();
403459
display.selectDisplayMode(INKPLATE_3BIT);
404460
display.drawBitmap3Bit(0, 0, demo_image, demo_image_w, demo_image_h);
@@ -407,6 +463,9 @@ void showSplashScreen()
407463
display.setCursor(10, 10);
408464
display.print(vcomVoltage, 2);
409465
display.print("V");
466+
display.setCursor(10, 20);
467+
display.print("Waveform");
468+
display.print(_w.waveformId - 20 + 1, DEC);
410469
display.display();
411470
}
412471

@@ -559,7 +618,35 @@ void microSDCardTest()
559618
{
560619
display.print("FAIL!");
561620
display.display();
562-
while(1);
621+
while (1)
622+
;
563623
}
564624
display.clearDisplay();
565625
}
626+
627+
void showGradient(int _selected)
628+
{
629+
int w = display.width() / 8;
630+
int h = display.height() - 100;
631+
632+
display.changeWaveform(waveformList[currentWaveform]);
633+
634+
display.fillRect(0, 725, 1200, 100, 7);
635+
636+
display.setTextSize(4);
637+
display.setTextColor(0);
638+
display.setCursor(420, 743);
639+
display.print("Waveform select");
640+
display.setCursor(432, 792);
641+
display.print("Prev Load Next");
642+
643+
display.setCursor(800, 743);
644+
display.print("1 2 3");
645+
display.drawRect((_selected * 6 * 4 * 2) + 800 - 3, 740, (6 * 4) + 2, (8 * 4) + 2, 0);
646+
647+
for (int i = 0; i < 8; i++)
648+
{
649+
display.fillRect(i * w, 0, w, h, i);
650+
}
651+
display.display();
652+
}

0 commit comments

Comments
 (0)