Skip to content

Commit 4a02213

Browse files
authored
Merge pull request #243 from SolderedElectronics/Inkplate6FLICKTouchSupport
Inkplate6 flick touch support
2 parents 9896245 + 6ec4362 commit 4a02213

File tree

25 files changed

+4089
-660
lines changed

25 files changed

+4089
-660
lines changed

.github/workflows/compile.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ jobs:
77
strategy:
88
matrix:
99
include:
10+
- board:
11+
fqbn: Inkplate_Boards:esp32:Inkplate5
12+
additional-sketch-paths: |
13+
- examples/Inkplate5
1014
- board:
1115
fqbn: Inkplate_Boards:esp32:Inkplate6
1216
additional-sketch-paths: |
@@ -31,6 +35,10 @@ jobs:
3135
fqbn: Inkplate_Boards:esp32:Inkplate6plusV2
3236
additional-sketch-paths: |
3337
- examples/Inkplate6PLUS
38+
- board:
39+
fqbn: Inkplate_Boards:esp32:Inkplate6Flick
40+
additional-sketch-paths: |
41+
- examples/Inkplate_6_FLICK
3442
- board:
3543
fqbn: Inkplate_Boards:esp32:Inkplate6COLOR
3644
additional-sketch-paths: |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
Inkplate_6_FLICK_Simple_Frontlight example for Soldered Inkplate 6 FLICK
3+
For this example you will need a micro USB cable, Inkplate 6 FLICK and a device with WiFi and Internet brower (PC,
4+
Laptop, Smartphone, ...). Select "Soldered Inkplate 6 FLICK" from Tools -> Board menu.
5+
Don't have "Soldered Inkplate 6 FLICK" option?
6+
Follow our tutorial and add it: https://soldered.com/learn/add-inkplate-6-board-definition-to-arduino-ide/
7+
8+
This example will show you how to use Inkplate 6 FLICK frontlight.
9+
10+
Want to learn more about Inkplate? Visit www.inkplate.io
11+
Looking to get support? Write on our forums: https://forum.soldered.com/
12+
14 March 2024 by Soldered
13+
*/
14+
15+
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
16+
#ifndef ARDUINO_INKPLATE6FLICK
17+
#error "Wrong board selection for this example, please select Soldered Inkplate 6 FLICK"
18+
#endif
19+
20+
#include "Inkplate.h" //Include Inkplate library
21+
22+
Inkplate display(INKPLATE_1BIT); // Create an object on Inkplate class
23+
24+
int b = 31; // Variable that holds intensity of the frontlight
25+
26+
void setup()
27+
{
28+
Serial.begin(115200); // Set up a serial communication of 115200 baud
29+
display.begin(); // Init Inkplate library
30+
display.frontlight(true); // Enable frontlight circuit
31+
display.setFrontlight(b); // Set frontlight intensity
32+
}
33+
34+
void loop()
35+
{
36+
if (Serial.available()) // Change frontlight value by sending "+" sign into serial monitor to increase frontlight or
37+
// "-" sign to decrese frontlight
38+
// try to find hidden lightshow ;)
39+
{
40+
bool change = false; // Variable that indicates that frontlight value has changed and intessity has to be updated
41+
char c = Serial.read(); // Read incomming serial data
42+
43+
if (c == '+' && b < 63) // If is received +, increase frontlight
44+
{
45+
b++;
46+
change = true;
47+
}
48+
if (c == '-' && b > 0) // If is received -, decrease frontlight
49+
{
50+
b--;
51+
change = true;
52+
}
53+
54+
if (c == 's')
55+
{
56+
for (int j = 0; j < 4; ++j)
57+
{
58+
for (int i = 0; i < 64; ++i)
59+
{
60+
display.setFrontlight(i);
61+
delay(30);
62+
}
63+
64+
for (int i = 63; i >= 0; --i)
65+
{
66+
display.setFrontlight(i);
67+
delay(30);
68+
}
69+
}
70+
71+
change = true;
72+
}
73+
74+
if (change) // If frontlight valuse has changed, update the intensity and show current value of frontlight
75+
{
76+
display.setFrontlight(b);
77+
Serial.print("Frontlight:");
78+
Serial.print(b, DEC);
79+
Serial.println("/63");
80+
}
81+
}
82+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
Inkplate_6_FLICK_Touch_In_Area example for Soldered Inkplate 6 FLICK
3+
For this example you will need only USB cable and Inkplate 6 FLICK
4+
Select "Soldered Inkplate 6 FLICK" from Tools -> Board menu.
5+
Don't have "Soldered Inkplate 6 FLICK" option? Follow our tutorial and add it:
6+
https://soldered.com/learn/add-inkplate-6-board-definition-to-arduino-ide/
7+
8+
This example shows you how to use Inkplate 6 FLICK touchscreen.
9+
Once the code is uploaded, try to touch the rectangle on the screen :)
10+
11+
Want to learn more about Inkplate? Visit www.inkplate.io
12+
Looking to get support? Write on our forums: https://forum.soldered.com/
13+
14 March 2024 by Soldered
14+
*/
15+
16+
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
17+
#ifndef ARDUINO_INKPLATE6FLICK
18+
#error "Wrong board selection for this example, please select Soldered Inkplate 6 FLICK"
19+
#endif
20+
21+
#include "Inkplate.h"
22+
23+
int x_position = 50;
24+
int y_position = 50;
25+
26+
Inkplate display(INKPLATE_1BIT);
27+
28+
void setup()
29+
{
30+
// put your setup code here, to run once:
31+
Serial.begin(115200);
32+
display.begin();
33+
display.clearDisplay();
34+
display.setCursor(100, 300);
35+
display.setTextSize(3);
36+
display.print("Touch button example. Touch the black button.");
37+
display.display();
38+
delay(3000);
39+
display.clearDisplay();
40+
// Init touchscreen and power it on after init (send false as argument to put it in deep sleep right after init)
41+
if (display.tsInit(true))
42+
{
43+
Serial.println("Touchscreen init ok");
44+
}
45+
else
46+
{
47+
Serial.println("Touchscreen init fail");
48+
while (true);
49+
}
50+
51+
//Draw initial rectangle
52+
display.fillRect(x_position, y_position, 100, 50, BLACK);
53+
display.display();
54+
}
55+
56+
void loop()
57+
{
58+
//Touch in area checks if touch ocured in given coordinates
59+
if(display.touchInArea(x_position, y_position, 100, 50))
60+
{
61+
x_position += 100;
62+
y_position += 100;
63+
64+
if(y_position < 660)
65+
{
66+
display.clearDisplay();
67+
display.fillRect(x_position, y_position, 100, 50, BLACK);
68+
69+
display.partialUpdate();
70+
delay(100);
71+
}
72+
else//Reseting rectangle position and doing full refresh
73+
{
74+
x_position = 50;
75+
y_position = 50;
76+
77+
display.clearDisplay();
78+
display.fillRect(x_position, y_position, 100, 50, BLACK);
79+
display.display();
80+
}
81+
}
82+
83+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
Inkplate_6_FLICK_Touchscreen_Draw example for Soldered Inkplate 6 FLICK
3+
For this example you will need only USB cable and Inkplate 6 FLICK
4+
Select "Soldered Inkplate 6 FLICK" from Tools -> Board menu.
5+
Don't have "Soldered Inkplate 6 FLICK" option? Follow our tutorial and add it:
6+
https://soldered.com/learn/add-inkplate-6-board-definition-to-arduino-ide/
7+
8+
This example shows you how to use Inkplate 6 FLICK touchscreen.
9+
Once the code is uploaded, try drawing on the screen :)
10+
11+
Want to learn more about Inkplate? Visit www.inkplate.io
12+
Looking to get support? Write on our forums: https://forum.soldered.com/
13+
14 March 2024 by Soldered
14+
*/
15+
16+
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
17+
#ifndef ARDUINO_INKPLATE6FLICK
18+
#error "Wrong board selection for this example, please select Soldered Inkplate 6 FLICK"
19+
#endif
20+
21+
#include "Inkplate.h"
22+
23+
// Select to draw a line on screen or filled circle
24+
#define DRAW_LINE
25+
// #define DRAW_CIRCLE
26+
27+
Inkplate display(INKPLATE_1BIT);
28+
29+
#ifdef DRAW_LINE
30+
uint16_t xOld, yOld;
31+
#endif
32+
33+
void setup()
34+
{
35+
// put your setup code here, to run once:
36+
Serial.begin(115200);
37+
display.begin();
38+
display.display();
39+
// Init touchscreen and power it on after init (send false as argument to put it in deep sleep right after init)
40+
if (display.tsInit(true))
41+
{
42+
Serial.println("Touchscreen init ok");
43+
}
44+
else
45+
{
46+
Serial.println("Touchscreen init fail");
47+
while (true)
48+
;
49+
}
50+
}
51+
52+
void loop()
53+
{
54+
// Check if there is any touch detected
55+
if (display.tsAvailable())
56+
{
57+
uint8_t n;
58+
uint16_t x[2], y[2];
59+
// See how many fingers are detected (max 2) and copy x and y position of each finger on touchscreen
60+
n = display.tsGetData(x, y);
61+
if (n != 0)
62+
{
63+
#ifdef DRAW_LINE // Draw line from old point to new
64+
display.drawLine(xOld, yOld, x[0], y[0], BLACK);
65+
66+
// Save coordinates to use as old next time
67+
xOld = x[0];
68+
yOld = y[0];
69+
#endif
70+
71+
#ifdef DRAW_CIRCLE // Draw circle on touch event coordinates
72+
display.fillCircle(x[0], y[0], 20, BLACK);
73+
#endif
74+
display.partialUpdate();
75+
}
76+
}
77+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
Inkplate_6_FLICK_Touchscreen_Serial example for Soldered Inkplate 6 FLICK
3+
For this example you will need only USB cable and Inkplate 6 FLICK
4+
Select "Soldered Inkplate 6 FLICK" from Tools -> Board menu.
5+
Don't have "Soldered Inkplate 6 FLICK" option? Follow our tutorial and add it:
6+
https://soldered.com/learn/add-inkplate-6-board-definition-to-arduino-ide/
7+
8+
This example shows you how to use Inkplate 6 FLICK touchscreen.
9+
Once the code is uploaded, open the serial monitor in Arduino IDE and you'll see touchscreen events there.
10+
11+
Want to learn more about Inkplate? Visit www.inkplate.io
12+
Looking to get support? Write on our forums: https://forum.soldered.com/
13+
14 March 2024 by Soldered
14+
*/
15+
16+
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
17+
#ifndef ARDUINO_INKPLATE6FLICK
18+
#error "Wrong board selection for this example, please select Soldered Inkplate 6 FLICK"
19+
#endif
20+
21+
#include "Inkplate.h"
22+
Inkplate display(INKPLATE_1BIT);
23+
24+
void setup()
25+
{
26+
// put your setup code here, to run once:
27+
Serial.begin(115200);
28+
display.begin();
29+
display.clearDisplay();
30+
display.display();
31+
// Init touchscreen and power it on after init (send false as argument to put it in deep sleep right after init)
32+
if (display.tsInit(true))
33+
{
34+
Serial.println("Touchscreen init ok");
35+
}
36+
else
37+
{
38+
Serial.println("Touchscreen init fail");
39+
while (true)
40+
;
41+
}
42+
43+
// NOTE!!!
44+
// Touchscreen cooridinates are automatically swapped and adjusted when screen is rotated
45+
display.setRotation(2);
46+
display.fillTriangle(10, 10, 20, 40, 40, 20, BLACK);
47+
display.setTextSize(3);
48+
display.setCursor(60, 60);
49+
display.print("(0,0) position");
50+
display.display();
51+
}
52+
53+
void loop()
54+
{
55+
// Check if there is any touch detected
56+
if (display.tsAvailable())
57+
{
58+
uint8_t n;
59+
uint16_t x[2], y[2];
60+
61+
// See how many fingers are detected (max 2) and copy x and y position of each finger on touchscreen
62+
n = display.tsGetData(x, y);
63+
if (n != 0)
64+
{
65+
// Print number of fingers to serial monitor, along with their coordinates
66+
Serial.printf("%d finger%c ", n, n > 1 ? 's' : NULL);
67+
for (int i = 0; i < n; i++)
68+
Serial.printf("X=%d Y=%d ", x[i], y[i]);
69+
Serial.println();
70+
}
71+
else
72+
{
73+
// If touchscreen driver returns us a zero, it means that there are no more touch events pressent on the
74+
// screen
75+
x[0] = 0;
76+
x[1] = 0;
77+
y[0] = 0;
78+
y[1] = 0;
79+
Serial.println("Release");
80+
}
81+
}
82+
}

0 commit comments

Comments
 (0)