Skip to content

Commit bf06eba

Browse files
authored
Merge pull request #190 from SolderedElectronics/Inkplate2-DrawImage3Color-And-Examples
Inkplate2 branch to dev
2 parents 1a23ee7 + 98c7028 commit bf06eba

File tree

197 files changed

+13364
-93
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+13364
-93
lines changed

.github/workflows/compile.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,13 @@ jobs:
3939
fqbn: Inkplate_Boards:esp32:Inkplate5
4040
additional-sketch-paths: |
4141
- examples/Inkplate5
42+
- board:
43+
fqbn: Inkplate_Boards:esp32:Inkplate2
44+
additional-sketch-paths: |
45+
- examples/Inkplate2
4246
steps:
4347
- name: Checkout
44-
uses: actions/checkout@v2
48+
uses: actions/checkout@v3
4549
- name: Install ESP32 platform dependencies
4650
run: pip3 install pyserial
4751
- name: Compile examples

examples/Inkplate10/Advanced/DeepSleep/Inkplate10_Wake_Up_On_Touchpads/Inkplate10_Wake_Up_On_Touchpads.ino

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
https://soldered.com/learn/add-inkplate-6-board-definition-to-arduino-ide/
77
88
Here is shown how to use I/O Expander and ESP interrupts to wake up the MCU from deepsleep when touchpad is pressed.
9-
10-
NOTE: This is an example for the old Inkplates that have touchpads.
11-
If you select new Inkplate boards, you won't be able to compile the example.
9+
10+
NOTE: This is an example for the old Inkplates that have touchpads.
1211
1312
Want to learn more about Inkplate? Visit www.inkplate.io
1413
Looking to get support? Write on our forums: https://forum.soldered.com/
1514
15 March 2023 by Soldered
1615
*/
1716

1817
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
19-
#if !defined(ARDUINO_INKPLATE10)
20-
#error "Wrong board selection for this example, please select e-radionica Inkplate10 in the boards menu."
18+
#if !defined(ARDUINO_INKPLATE10) && !defined(ARDUINO_INKPLATE10V2)
19+
#error \
20+
"Wrong board selection for this example, please select e-radionica Inkplate10 or Soldered Inkplate10 in the boards menu."
2121
#endif
2222

2323
#include <Inkplate.h>
@@ -44,10 +44,16 @@ void setup()
4444
display.begin();
4545

4646
// Set interrupt pins
47+
#if defined(ARDUINO_INKPLATE10)
4748
display.setIntOutput(1, false, false, HIGH, IO_INT_ADDR);
4849
display.setIntPin(PAD1, RISING, IO_INT_ADDR);
4950
display.setIntPin(PAD2, RISING, IO_INT_ADDR);
5051
display.setIntPin(PAD3, RISING, IO_INT_ADDR);
52+
#elif defined(ARDUINO_INKPLATE10V2)
53+
display.setIntPin(PAD1, IO_INT_ADDR);
54+
display.setIntPin(PAD2, IO_INT_ADDR);
55+
display.setIntPin(PAD3, IO_INT_ADDR);
56+
#endif
5157

5258
++bootCount;
5359

@@ -58,8 +64,14 @@ void setup()
5864
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
5965

6066
// Enable wakup from deep sleep on gpio 34
67+
#if defined(ARDUINO_INKPLATE10)
68+
// MCP I/O expander sends logic HIGH pulse signal as interrupt.
6169
esp_sleep_enable_ext1_wakeup(TOUCHPAD_WAKE_MASK, ESP_EXT1_WAKEUP_ANY_HIGH);
62-
70+
#elif defined(ARDUINO_INKPLATE10V2)
71+
// PCAL I/O expander sends logic LOW pulse signal as interrupt.
72+
esp_sleep_enable_ext1_wakeup(TOUCHPAD_WAKE_MASK, ESP_EXT1_WAKEUP_ALL_LOW);
73+
#endif
74+
6375
// Go to sleep
6476
esp_deep_sleep_start();
6577
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
Inkplate2_Bluetooth_Peripheral_Mode example for Soldered Inkplate 2
3+
For this example you will need USB cable, an Inkplate 2 and bluetooth supporting device
4+
like phone or laptop. If you are using phone, you will need to download app which
5+
allows you to send commands via bluetooth like "Bluetooth serial monitor".
6+
Select "Soldered Inkplate2" from Tools -> Board menu.
7+
Don't have "Soldered Inkplate2" option? Follow our tutorial and add it:
8+
https://soldered.com/learn/add-inkplate-6-board-definition-to-arduino-ide/
9+
10+
This example shows how to use Inkplate as a peripheral device over Bluetooth.
11+
12+
Want to learn more about Inkplate? Visit www.inkplate.io
13+
Looking to get support? Write on our forums: https://forum.soldered.com/
14+
29 March 2022 by Soldered
15+
*/
16+
17+
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
18+
#ifndef ARDUINO_INKPLATE2
19+
#error "Wrong board selection for this example, please select Soldered Inkplate2 in the boards menu."
20+
#endif
21+
22+
#include "Inkplate.h"
23+
24+
#include "BluetoothSerial.h"
25+
26+
// Size of the receive buffer for commands (in bytes).
27+
#define BUFFER_SIZE 1000
28+
29+
#include "Peripheral.h"
30+
31+
// Declare Inkplate and SerialBluetooth objects
32+
Inkplate display;
33+
BluetoothSerial SerialBT;
34+
35+
// Temporary data buffer for Peripheral mode code
36+
char commandBuffer[BUFFER_SIZE + 1];
37+
38+
void setup() // Initialize everything
39+
{
40+
Serial.begin(115200); // Initialize UART communication with PC
41+
42+
if (!SerialBT.begin("Inkplate2")) // Check if bluetooth is initialized successfully
43+
{
44+
Serial.println("An error occurred initializing Bluetooth"); // If not, print error message
45+
}
46+
47+
display.begin(); // Initialize Inkplate library.
48+
}
49+
50+
void loop()
51+
{
52+
while (SerialBT.available()) // When there is some data available save it and pass to Peripheral.h code
53+
{
54+
for (int i = 0; i < (BUFFER_SIZE - 1); i++) // Loop through all commands
55+
{
56+
commandBuffer[i] = commandBuffer[i + 1];
57+
}
58+
commandBuffer[BUFFER_SIZE - 1] = SerialBT.read(); // Save incoming command in buffer
59+
Serial.print(commandBuffer[BUFFER_SIZE - 1]);
60+
}
61+
62+
// Function in peripheral.h
63+
run(commandBuffer, BUFFER_SIZE);
64+
65+
delay(50);
66+
}
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
/*
2+
Inkplate_Peripheral_Mode sketch for e-radionica.com Inkplate 2
3+
Select "Soldered Inkplate 2" from Tools -> Board menu.
4+
Don't have "Soldered Inkplate 2" option? Follow our tutorial and add it:
5+
https://e-radionica.com/en/blog/add-inkplate-6-to-arduino-ide/
6+
7+
Using this sketch, you don't have to program and control e-paper using Arduino code.
8+
Instead, you can send UART command (explained in documentation that can be found inside folder of this sketch).
9+
This give you flexibility that you can use this Inkplate 2 on any platform!
10+
11+
Because it uses UART, it's little bit slower and it's not recommended to send bunch of
12+
drawPixel command to draw some image. Instead, load bitmaps and pictures on SD card and load image from SD.
13+
If we missed some function, you can modify this and make yor own.
14+
Also, every Inkplate comes with this peripheral mode right from the factory.
15+
16+
Learn more about Peripheral Mode in this update:
17+
https://www.crowdsupply.com/e-radionica/inkplate-6/updates/successfully-funded-also-third-party-master-controllers-and-partial-updates
18+
19+
UART settings are: 115200 baud, standard parity, ending with "\n\r" (both)
20+
You can send commands via USB port or by directly connecting to ESP32 TX and RX pins.
21+
Don't forget you need to send #L(1)* after each command to show it on the display
22+
(equal to display.display()).
23+
24+
Want to learn more about Inkplate? Visit www.inkplate.io
25+
Looking to get support? Write on our forums: http://forum.e-radionica.com/en/
26+
29 March 2022 by Soldered
27+
*/
28+
29+
#include "Inkplate.h"
30+
31+
extern Inkplate display;
32+
33+
char strTemp[2001];
34+
35+
int hexToChar(char c)
36+
{
37+
if (c >= '0' && c <= '9')
38+
return c - '0';
39+
if (c >= 'A' && c <= 'F')
40+
return c - 'A' + 10;
41+
if (c >= 'a' && c <= 'f')
42+
return c - 'a' + 10;
43+
return -1;
44+
}
45+
46+
void run(char commandBuffer[], size_t n)
47+
{
48+
char *s = NULL;
49+
char *e = NULL;
50+
for (int i = 0; i < n; i++)
51+
{
52+
if (commandBuffer[i] == '#' && s == NULL)
53+
s = &commandBuffer[i];
54+
if (commandBuffer[i] == '*' && e == NULL)
55+
e = &commandBuffer[i];
56+
}
57+
if (s != NULL && e != NULL)
58+
{
59+
if ((e - s) > 0)
60+
{
61+
int x, x1, x2, y, y1, y2, x3, y3, l, c, w, h, r, n, rx, ry, xc, yc;
62+
char b;
63+
char temp[150];
64+
switch (*(s + 1))
65+
{
66+
case '?':
67+
Serial.print("OK");
68+
break;
69+
70+
case '0':
71+
// Draw pixel
72+
sscanf(s + 3, "%d,%d,%d", &x, &y, &c);
73+
display.drawPixel(x, y, c);
74+
break;
75+
76+
case '1':
77+
// Draw line
78+
sscanf(s + 3, "%d,%d,%d,%d,%d", &x1, &y1, &x2, &y2, &c);
79+
display.drawLine(x1, y1, x2, y2, c);
80+
break;
81+
82+
case '2':
83+
// Draw fast vertical line
84+
sscanf(s + 3, "%d,%d,%d,%d", &x, &y, &l, &c);
85+
display.drawFastVLine(x, y, l, c);
86+
break;
87+
88+
case '3':
89+
// Draw fast horizontal line
90+
sscanf(s + 3, "%d,%d,%d,%d", &x, &y, &l, &c);
91+
display.drawFastHLine(x, y, l, c);
92+
break;
93+
94+
case '4':
95+
// Draw rect.
96+
sscanf(s + 3, "%d,%d,%d,%d,%d", &x, &y, &w, &h, &c);
97+
display.drawRect(x, y, w, h, c);
98+
break;
99+
100+
case '5':
101+
// Draw circle
102+
sscanf(s + 3, "%d,%d,%d,%d", &x, &y, &r, &c);
103+
display.drawCircle(x, y, r, c);
104+
break;
105+
106+
case '6':
107+
// Draw triangle
108+
sscanf(s + 3, "%d,%d,%d,%d,%d,%d,%d", &x1, &y1, &x2, &y2, &x3, &y3, &c);
109+
display.drawTriangle(x1, y1, x2, y2, x3, y3, c);
110+
break;
111+
112+
case '7':
113+
// Draw round rect.
114+
sscanf(s + 3, "%d,%d,%d,%d,%d,%d", &x, &y, &w, &h, &r, &c);
115+
display.drawRoundRect(x, y, w, h, r, c);
116+
break;
117+
118+
case '8':
119+
// Draw filled rect.
120+
sscanf(s + 3, "%d,%d,%d,%d,%d", &x, &y, &w, &h, &c);
121+
display.fillRect(x, y, w, h, c);
122+
break;
123+
124+
case '9':
125+
// Draw filled circle
126+
sscanf(s + 3, "%d,%d,%d,%d", &x, &y, &r, &c);
127+
display.fillCircle(x, y, r, c);
128+
break;
129+
130+
case 'A':
131+
// Draw filled triangle
132+
sscanf(s + 3, "%d,%d,%d,%d,%d,%d,%d", &x1, &y1, &x2, &y2, &x3, &y3, &c);
133+
display.fillTriangle(x1, y1, x2, y2, x3, y3, c);
134+
break;
135+
136+
case 'B':
137+
// Draw filled round rect.
138+
sscanf(s + 3, "%d,%d,%d,%d,%d,%d", &x, &y, &w, &h, &r, &c);
139+
display.fillRoundRect(x, y, w, h, r, c);
140+
break;
141+
142+
case 'C':
143+
// Draw a string.
144+
sscanf(s + 3, "\"%2000[^\"]\"", strTemp);
145+
n = strlen(strTemp);
146+
for (int i = 0; i < n; i++)
147+
{
148+
strTemp[i] = toupper(strTemp[i]);
149+
}
150+
for (int i = 0; i < n; i += 2)
151+
{
152+
strTemp[i / 2] = (hexToChar(strTemp[i]) << 4) | (hexToChar(strTemp[i + 1]) & 0x0F);
153+
}
154+
strTemp[n / 2] = 0;
155+
display.print(strTemp);
156+
break;
157+
158+
case 'D':
159+
// Set text size
160+
sscanf(s + 3, "%d", &c);
161+
display.setTextSize(c);
162+
break;
163+
164+
case 'E':
165+
// Set print cursor position
166+
sscanf(s + 3, "%d,%d", &x, &y);
167+
display.setCursor(x, y);
168+
break;
169+
170+
case 'F':
171+
// Enable or disable text wrapping.
172+
sscanf(s + 3, "%c", &b);
173+
if (b == 'T')
174+
display.setTextWrap(true);
175+
if (b == 'F')
176+
display.setTextWrap(false);
177+
break;
178+
179+
case 'G':
180+
// Set screen rotation
181+
sscanf(s + 3, "%d", &c);
182+
c &= 3;
183+
display.setRotation(c);
184+
break;
185+
186+
case 'K':
187+
// Clear the display (frame buffer only)
188+
sscanf(s + 3, "%c", &b);
189+
if (b == '1')
190+
{
191+
display.clearDisplay();
192+
}
193+
break;
194+
195+
case 'L':
196+
// Display image from the frame buffer
197+
sscanf(s + 3, "%c", &b);
198+
if (b == '1')
199+
{
200+
display.display();
201+
}
202+
break;
203+
204+
case 'T':
205+
// Draw thick line.
206+
int t;
207+
sscanf(s + 3, "%d,%d,%d,%d,%d,%d", &x1, &y1, &x2, &y2, &c, &t);
208+
display.drawThickLine(x1, y1, x2, y2, c, t);
209+
break;
210+
case 'U':
211+
// Draw elipse.
212+
sscanf(s + 3, "%d,%d,%d,%d,%d", &rx, &ry, &xc, &yc, &c);
213+
display.drawElipse(rx, ry, xc, yc, c);
214+
break;
215+
case 'V':
216+
// Draw filled elipse
217+
sscanf(s + 3, "%d,%d,%d,%d,%d", &rx, &ry, &xc, &yc, &c);
218+
display.fillElipse(rx, ry, xc, yc, c);
219+
break;
220+
}
221+
*s = 0;
222+
*e = 0;
223+
}
224+
}
225+
}

0 commit comments

Comments
 (0)