Skip to content

Commit 3da1a3c

Browse files
added touchpad examples+header comments
1 parent 550a172 commit 3da1a3c

File tree

3 files changed

+214
-0
lines changed

3 files changed

+214
-0
lines changed

examples/Inkplate10/Advanced/IO/Inkplate10_Read_Touchpads/Inkplate10_Read_Touchpads.ino

Whitespace-only changes.
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/**
2+
**************************************************
3+
* @file Inkplate6_Read_Touchpads.ino
4+
* @brief Uses the built-in capacitive touchpads on Inkplate 6 to control
5+
* a counter displayed on the screen.
6+
*
7+
* @details This example demonstrates how to use the three capacitive
8+
* touchpads integrated on the Inkplate 6 PCB. These pads are
9+
* labeled 1, 2, and 3 and function as simple touch-sensitive
10+
* switches that can be used for user input.
11+
*
12+
* The sketch continuously reads the state of the touchpads using
13+
* display.touchpad.read(). Each pad performs a specific action on
14+
* a counter displayed on the screen:
15+
*
16+
* - Pad 1 decreases the number
17+
* - Pad 2 resets the number to zero
18+
* - Pad 3 increases the number
19+
*
20+
* The example uses 1-bit display mode and partial updates to keep
21+
* screen refreshes fast. After several partial updates, a full
22+
* refresh is automatically performed to maintain display quality.
23+
*
24+
* Requirements:
25+
* - Board: Soldered Inkplate 6
26+
* - Hardware: Inkplate 6, USB cable
27+
* - Extra: none
28+
*
29+
* Configuration:
30+
* - Boards Manager -> Inkplate Boards -> Soldered Inkplate6
31+
* - Serial settings: not used in this example
32+
*
33+
* Don't have Inkplate Boards in Arduino Boards Manager?
34+
* See https://docs.soldered.com/inkplate/10/quick-start-guide/
35+
*
36+
* How to use:
37+
* 1) Select Soldered Inkplate6 in Arduino IDE and upload the sketch.
38+
* 2) After startup, a number appears in the center of the display.
39+
* 3) Touch the pads on the bottom of the PCB:
40+
* - Touch pad 1 to decrease the number.
41+
* - Touch pad 2 to reset the number to zero.
42+
* - Touch pad 3 to increase the number.
43+
* 4) The display updates each time a pad is touched.
44+
*
45+
* Expected output:
46+
* - Display: A large number that changes according to touchpad input.
47+
* - Display: Symbols "-", "0", and "+" printed above the touchpads as visual
48+
* indicators of their functions.
49+
*
50+
* Notes:
51+
* - Display mode: 1-bit black-and-white (INKPLATE_1BIT).
52+
* - Partial updates are used for faster refresh. After ~20 partial updates,
53+
* a full refresh is performed automatically.
54+
* - Capacitive touchpads are sensitive to environment and grounding and may
55+
* behave differently depending on humidity, grounding, or enclosures.
56+
* - touchpad.read() returns 1 when the pad is touched and 0 when it is not.
57+
*
58+
* Docs: https://docs.soldered.com/inkplate
59+
* Support: https://forum.soldered.com/
60+
*
61+
* @author Soldered
62+
* @date 2020-07-15
63+
* @license GNU GPL V3
64+
**************************************************/
65+
66+
67+
#include "Inkplate.h" //Include Inkplate library to the sketch
68+
Inkplate display(INKPLATE_1BIT); // Create an object on Inkplate library and also set library into 1 Bit mode (BW)
69+
70+
int number = 0; // Variable that stores our number
71+
int n = 0; // Variable that keeps track on how many times display is partially updated
72+
void setup()
73+
{
74+
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
75+
display.clearDisplay(); // Clear frame buffer of display
76+
display.display(); // Put clear image on display
77+
display.setTextSize(5); // Set text scaling to five (text will be five times bigger)
78+
display.setTextColor(BLACK, WHITE); // Set text color to black and background color to white
79+
displayNumber(); // Call our function to display nubmer on screen
80+
}
81+
82+
void loop()
83+
{
84+
if (display.touchpad.read(1))
85+
{ // Check if first pad has been touched. If it is, decrement the number and refresh the screen.
86+
number--;
87+
displayNumber();
88+
}
89+
90+
if (display.touchpad.read(2))
91+
{ // If you touched second touchpad, set number to zero and refresh screen by calling our displayNumber() function
92+
number = 0;
93+
displayNumber();
94+
}
95+
96+
if (display.touchpad.read(3))
97+
{ // If you touched third touchpad, incerement the number and refresh the screen.
98+
number++;
99+
displayNumber();
100+
}
101+
delay(100); // Wait a little bit between readings.
102+
}
103+
104+
// Function that will write you number to screen
105+
void displayNumber()
106+
{
107+
display.clearDisplay(); // First, lets delete everything from frame buffer
108+
display.setCursor(385, 280); // Set print cursor at X=385, Y=280 (roughly in the middle of the screen)
109+
display.print(number, DEC); // Print the number
110+
display.setCursor(255, 560); // Set new print position (right above first touchpad)
111+
display.print('-'); // Print minus sign
112+
display.setCursor(385, 560); // Set new print position (right above second touchpad)
113+
display.print('0'); // Print zero
114+
display.setCursor(520, 560); // Set new print position (right above third touchpad)
115+
display.print('+'); // Print plus sign
116+
if (n > 20)
117+
{ // Chech if screen has been partially refreshed more than 20 times. If it is, do a full refresh. If is not, do a
118+
// partial refresh
119+
display.display();
120+
n = 0;
121+
}
122+
else
123+
{
124+
display.partialUpdate();
125+
n++;
126+
}
127+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/**
2+
**************************************************
3+
* @file Inkplate6COLOR_Read_Touchpads.ino
4+
* @brief Reads the built-in capacitive touchpads on Inkplate 6COLOR and
5+
* reports their state via Serial.
6+
*
7+
* @details This example demonstrates how to use the three capacitive
8+
* touchpads integrated on the Inkplate 6COLOR PCB. These pads,
9+
* labeled 1, 2, and 3 on the board, function as simple
10+
* touch-sensitive input buttons.
11+
*
12+
* The sketch continuously checks the state of each touchpad using
13+
* the display.touchpad.read() function. When a pad is touched,
14+
* a message is printed to the Serial Monitor indicating which pad
15+
* was activated.
16+
*
17+
* This example is useful as a starting point for implementing
18+
* touch-based user interfaces such as menu navigation, simple
19+
* controls, or interactive displays.
20+
*
21+
* Requirements:
22+
* - Board: Soldered Inkplate 6COLOR
23+
* - Hardware: Inkplate 6COLOR, USB cable
24+
* - Extra: none
25+
*
26+
* Configuration:
27+
* - Boards Manager -> Inkplate Boards -> Soldered Inkplate6COLOR
28+
* - Serial Monitor: 115200 baud
29+
*
30+
* Don't have Inkplate Boards in Arduino Boards Manager?
31+
* See https://docs.soldered.com/inkplate/10/quick-start-guide/
32+
*
33+
* How to use:
34+
* 1) Select Soldered Inkplate6COLOR in Arduino IDE and upload the sketch.
35+
* 2) Open Serial Monitor at 115200 baud.
36+
* 3) Touch the capacitive pads labeled 1, 2, or 3 on the Inkplate PCB.
37+
* 4) The Serial Monitor prints which pad has been touched.
38+
*
39+
* Expected output:
40+
* - Serial Monitor: Messages such as "Pad 1 pressed!", "Pad 2 pressed!",
41+
* or "Pad 3 pressed!" when the corresponding touchpad is activated.
42+
*
43+
* Notes:
44+
* - Display mode: not used in this example (no screen updates occur).
45+
* - The function touchpad.read() returns 1 when a pad is touched and 0 when
46+
* it is not.
47+
* - Capacitive touchpads can be affected by environmental conditions such as
48+
* humidity, grounding, or thick enclosures placed over the PCB.
49+
* - This example uses a short delay between reads to prevent excessive Serial
50+
* output.
51+
*
52+
* Docs: https://docs.soldered.com/inkplate
53+
* Support: https://forum.soldered.com/
54+
*
55+
* @author Soldered
56+
* @date 2020-07-15
57+
* @license GNU GPL V3
58+
**************************************************/
59+
60+
61+
#include "Inkplate.h" //Include Inkplate library to the sketch
62+
Inkplate display; // Create an object on Inkplate library
63+
64+
void setup()
65+
{
66+
Serial.begin(115200); // Init Serial documentation
67+
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
68+
}
69+
70+
void loop()
71+
{
72+
if (display.touchpad.read(1))
73+
{
74+
Serial.println("Pad 1 pressed!");
75+
}
76+
77+
if (display.touchpad.read(2))
78+
{
79+
Serial.println("Pad 2 pressed!");
80+
}
81+
82+
if (display.touchpad.read(3))
83+
{
84+
Serial.println("Pad 3 pressed!");
85+
}
86+
delay(100); // Wait a little bit between readings.
87+
}

0 commit comments

Comments
 (0)