Skip to content

Commit 9214b6c

Browse files
committed
updated waveforms
1 parent e20ed1f commit 9214b6c

File tree

6 files changed

+1093
-4
lines changed

6 files changed

+1093
-4
lines changed

.gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
.cache
1+
.venv/
2+
.cache/
23
.pio/
34
.vscode/c_cpp_properties.json
45
.vscode/launch.json
56
src/config.h
6-
src/config.cpp
7+
src/config.cpp

platformio.ini

+10-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ lib_deps =
2727
; >1.2.3 - any version greater than 1.2.3. >=, <, and <= are also possible
2828
; >0.1.0,!=0.2.0,<0.3.0 - any version greater than 0.1.0, not equal to 0.2.0 and less than 0.3.0
2929

30-
https://github.com/SolderedElectronics/Inkplate-Arduino-library#10.0.0
30+
https://github.com/SolderedElectronics/Inkplate-Arduino-library#10.1.0
3131
arduino-libraries/NTPClient @ 3.2.1 ; NTP client
3232
fbiego/ESP32Time @ 2.0.6 ; for syncing RTC to internal clock
3333
jchristensen/Timezone @ 1.2.4 ; for timezone and DST calculations
@@ -94,7 +94,15 @@ upload_flags =
9494
extends = env:inkplate10
9595
lib_deps =
9696
e-radionicacom/InkplateLibrary#7.0.0
97-
build_src_filter= -<*> +<../vcom_src/>
97+
build_src_filter= -<*> +<../src_vcom/>
98+
99+
100+
[env:Wavefrom_EEPROM]
101+
; if using a different device be sure to change the extended environment
102+
extends = env:inkplate10
103+
lib_deps =
104+
https://github.com/SolderedElectronics/Inkplate-Arduino-library#10.1.0
105+
build_src_filter= -<*> +<../src_eeprom/>
98106

99107
[env:native]
100108
platform = native
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
/*
2+
Inkplate10_Wavefrom_EEPROM_Programming example for e-radionica.com Inkplate 10
3+
For this example you will need only USB cable and Inkplate 10.
4+
Select "e-radionica Inkplate10" or "Soldered Inkplate10" from Tools -> Board menu.
5+
Don't have "e-radionica Inkplate10" or "Soldered Inkplate10" option? Follow our tutorial and add it:
6+
https://soldered.com/learn/add-inkplate-6-board-definition-to-arduino-ide/
7+
8+
This example will program a new waveform in ESP32 EEPROM if the waveform has been accidentally overwritten.
9+
Upload code and open Serial Monitor. Send numbers form 1 to 4 to display selected waveform.
10+
They should go from dark to light. Select the one that looks the best to you.
11+
Send "ok" to select waveform and burn it into ESP32 EEPROM or send "test" to display a an test image.
12+
CAUTION! Changing EEPROM size can wipe waveform data.
13+
Waveform data is stored in EEPROM on address range form address 0 to address 75.
14+
15+
Want to learn more about Inkplate? Visit www.inkplate.io
16+
Looking to get support? Write on our forums: https://forum.soldered.com/
17+
18 January 2023 by Soldered
18+
*/
19+
20+
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
21+
#if !defined(ARDUINO_INKPLATE10) && !defined(ARDUINO_INKPLATE10V2)
22+
#error \
23+
"Wrong board selection for this example, please select e-radionica Inkplate10 or Soldered Inkplate10 in the boards menu."
24+
#endif
25+
26+
#include "EEPROM.h" // Include ESP32 EEPROM library
27+
#include "Inkplate.h" // Include Inkplate library to the sketch
28+
#include "image.h" // Include the demo image for test
29+
30+
// added definitions to compile with platformio
31+
void showGradient(int _selected);
32+
int getWaveformNumer();
33+
34+
35+
Inkplate display(INKPLATE_3BIT); // Create object on Inkplate library and set library to work in grayscale mode
36+
37+
// All waveforms for Inkplate 10 board
38+
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},
39+
{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},
40+
{0, 0, 0, 0, 0, 2, 1, 2, 0}, {0, 0, 0, 2, 2, 2, 2, 2, 0}};
41+
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},
42+
{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},
43+
{0, 0, 0, 0, 0, 1, 2, 2, 0}, {0, 0, 0, 0, 2, 2, 2, 2, 0}};
44+
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},
45+
{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},
46+
{0, 2, 1, 2, 1, 2, 1, 2, 0}, {0, 3, 3, 3, 2, 2, 2, 2, 0}};
47+
uint8_t waveform4[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},
48+
{1, 1, 2, 2, 1, 2, 2, 1, 0}, {0, 0, 2, 1, 2, 2, 2, 1, 0}, {0, 1, 2, 2, 2, 2, 2, 1, 0},
49+
{0, 0, 0, 2, 2, 2, 1, 2, 0}, {0, 0, 0, 2, 2, 2, 2, 2, 0}};
50+
uint8_t waveform5[8][9] = {{0, 0, 0, 0, 0, 0, 0, 1, 0}, {0, 0, 0, 2, 2, 2, 1, 1, 0}, {2, 2, 2, 1, 0, 2, 1, 0, 0},
51+
{2, 1, 1, 2, 1, 1, 1, 2, 0}, {2, 2, 2, 1, 1, 1, 0, 2, 0}, {2, 2, 2, 1, 1, 2, 1, 2, 0},
52+
{0, 0, 0, 0, 2, 1, 2, 2, 0}, {0, 0, 0, 0, 2, 2, 2, 2, 0}};
53+
uint8_t *waveformList[] = {&waveform1[0][0], &waveform2[0][0], &waveform3[0][0], &waveform4[0][0], &waveform5[0][0]};
54+
55+
// Calculate number of possible waveforms
56+
uint8_t waveformListSize = (sizeof(waveformList) / sizeof(uint8_t *));
57+
58+
// Struct for reading waveform from EEPROM memory of ESP32
59+
struct waveformData waveformEEPROM;
60+
61+
int currentWaveform = 0;
62+
63+
void setup()
64+
{
65+
// Start up a Serial monitor @ 115200 bauds.
66+
Serial.begin(115200);
67+
68+
display.begin(); // Init library (you should call this function ONLY ONCE)
69+
EEPROM.begin(512); // Init EEPROM library with 512 of EEPROM size.
70+
71+
// Display all shades of gray on e-paper with first waveform
72+
showGradient(currentWaveform);
73+
74+
// Flag for programming
75+
int progFlag = 0;
76+
77+
// Flag for data receive
78+
int uartFlag = 0;
79+
80+
// Until "ok" is not send, user can select one of the waveforms
81+
while (uartFlag != 255)
82+
{
83+
// Check if user send waveform number (or request for waveform programming).
84+
uartFlag = getWaveformNumer();
85+
86+
// Got waveform number? Show it!
87+
if (uartFlag > 0 && uartFlag <= waveformListSize)
88+
{
89+
currentWaveform = uartFlag - 1;
90+
showGradient(currentWaveform);
91+
}
92+
93+
// If function returns 254, show test image
94+
if (uartFlag == 254)
95+
{
96+
display.clearDisplay();
97+
display.drawBitmap3Bit(0, 0, demo_image, demo_image_w, demo_image_h);
98+
99+
display.fillRect(0, 0, 300, 40, 7);
100+
display.setTextSize(4);
101+
display.setTextColor(0);
102+
display.setCursor(10, 10);
103+
display.printf("WAVEFORM: %d", currentWaveform);
104+
105+
display.display();
106+
}
107+
}
108+
109+
// Load waveform in EEPROM memory of ESP32
110+
waveformEEPROM.waveformId = INKPLATE10_WAVEFORM1 + currentWaveform;
111+
memcpy(&waveformEEPROM.waveform, waveformList[currentWaveform], sizeof(waveformEEPROM.waveform));
112+
waveformEEPROM.checksum = display.calculateChecksum(waveformEEPROM);
113+
display.burnWaveformToEEPROM(waveformEEPROM);
114+
115+
// Show message on the display
116+
display.clearDisplay();
117+
display.setCursor(10, 100);
118+
display.print("Waveform");
119+
display.print(currentWaveform + 1, DEC);
120+
display.print(" selected & programmed into ESP32 EEPROM");
121+
display.display();
122+
}
123+
124+
void loop()
125+
{
126+
// Empty...
127+
}
128+
129+
// Prints gradient lines and currently selected waveform
130+
void showGradient(int _selected)
131+
{
132+
display.clearDisplay();
133+
134+
int w = display.width() / 8;
135+
int h = display.height() - 100;
136+
137+
display.changeWaveform(waveformList[currentWaveform]);
138+
139+
display.fillRect(0, 725, 1200, 100, 7);
140+
141+
display.setTextSize(4);
142+
display.setTextColor(0);
143+
display.setCursor(10, 743);
144+
display.print("Waveform select: ");
145+
146+
display.setCursor(432, 743);
147+
// Display waveform numbers.
148+
for (int i = 1; i <= waveformListSize; i++)
149+
{
150+
display.print(i, DEC);
151+
display.print(' ');
152+
}
153+
display.drawRect((_selected * 6 * 4 * 2) + 432 - 3, 740, (6 * 4) + 2, (8 * 4) + 2, 0);
154+
155+
for (int i = 0; i < 8; i++)
156+
{
157+
display.fillRect(i * w, 0, w, h, i);
158+
}
159+
160+
display.setTextSize(3);
161+
display.setCursor(10, 792);
162+
display.print("Send wavefrom number, or send \"ok\" to burn it, \"test\" for image");
163+
164+
display.display();
165+
}
166+
167+
/**
168+
* @brief Get the command from the serial.
169+
*
170+
* @return Returns 0 for no captured data on serial, 255 for wavefrom programming, 254 for test image show.
171+
*/
172+
int getWaveformNumer()
173+
{
174+
// Buffer for the serial data.
175+
char _buffer[20];
176+
177+
// Variable for array indexing (serial buffer).
178+
int _n = 0;
179+
180+
// Number for storing current waveform.
181+
int _waveform = 0;
182+
183+
// Check if something has been sent to the Inkplate.
184+
if (Serial.available())
185+
{
186+
// Capture the time!
187+
unsigned long _timeout = millis();
188+
189+
// Wait until 250 milliseconds have passed from last received char from UART.
190+
while ((unsigned long)(millis() - _timeout) < 250)
191+
{
192+
// Got some space in the buffer? Get the chars!
193+
if (Serial.available() && _n < 19)
194+
{
195+
_buffer[_n++] = Serial.read();
196+
}
197+
else
198+
{
199+
// Drop the data from the UART (buffer is full).
200+
Serial.read();
201+
}
202+
}
203+
204+
// Add null-terminating character at the end.
205+
_buffer[_n] = '\0';
206+
}
207+
208+
// Convert whole string to the lowercase
209+
for (int i = 0; _buffer[i] != '\0'; i++)
210+
{
211+
_buffer[i] = tolower(_buffer[i]);
212+
}
213+
214+
// Check if you got something.
215+
if (_n != 0)
216+
{
217+
// Try to parse it.
218+
219+
// First check for the keyword for programming or show test image.
220+
if (strstr("ok\r\n", _buffer) != NULL)
221+
{
222+
return 255;
223+
}
224+
else if (strstr("test\r\n", _buffer))
225+
{
226+
return 254;
227+
}
228+
else if (sscanf(_buffer, "%d", &_waveform))
229+
{
230+
// Check bounds.
231+
if ((_waveform > 0) && _waveform <= (waveformListSize))
232+
{
233+
return _waveform;
234+
}
235+
}
236+
}
237+
return 0;
238+
}

src_eeprom/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Wavefrom_EEPROM Programming
2+
3+
copied from: [Inkplate10_Wavefrom_EEPROM_Programming](https://github.com/SolderedElectronics/Inkplate-Arduino-library/tree/master/examples/Inkplate10/Diagnostics/Inkplate10_Wavefrom_EEPROM_Programming)
4+
5+
updated for platformio build
6+
7+
```shell
8+
pio run -e Wavefrom_EEPROM
9+
```
10+
11+
## Custom Test Image
12+
13+
Replace `image.h` with the output from the [Inkplate-image-converter](https://solderedelectronics.github.io/Inkplate-image-converter/)

0 commit comments

Comments
 (0)