Skip to content

Commit 71d7349

Browse files
committed
Added touchpads for Inkplate 6COLOR
1 parent 5572259 commit 71d7349

File tree

6 files changed

+87
-6
lines changed

6 files changed

+87
-6
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
Inkplate6COLOR_Read_Touchpads example for Soldered Inkplate6COLOR
3+
For this example you will need only a micro USB cable and Inkplate6COLOR.
4+
Select "e-radionica Inkplate6COLOR" or "Soldered Inkplate6COLOR" from Tools -> Board menu.
5+
Don't have "e-radionica Inkplate6COLOR" or "Soldered Inkplate6COLOR" 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 show you how you can use the built-in touchpads (on PCB marked with numbers 1, 2 and 3).
9+
These are basically touch sensitive switches. You can read state each of these with function readTouchpad()
10+
and the argument you need to pass to this function is PAD1 if you want to read the state of touchpad marked
11+
as "1" on PCB, PAD2 for second touchpad, PAD3 for third. You can also use numbers as arguments.
12+
For that you need to pass number 0 for touchpad that is marked as 1 on the PCB, 1 for the second touchpad and 2 for
13+
the third. The function readTouchpad() will return 1 if selected touchpad is pressed, zero if not.
14+
15+
In this example, if you touch the first pad, it will decrese the number printed on serial, if you touch the third
16+
touch pad, it will increase the number, if you touch second touchpad, it will reset the number to zero.
17+
18+
NOTE: You can not use touch pads when an enclosure is fitted on the Inkplate - they are not that sensitive!
19+
20+
Want to learn more about Inkplate? Visit www.inkplate.io
21+
Looking to get support? Write on our forums: https://forum.soldered.com/
22+
6 June 2023 by Soldered
23+
*/
24+
25+
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
26+
#ifndef ARDUINO_INKPLATECOLOR
27+
#error "Wrong board selection for this example, please select Soldered Inkplate 6COLOR in the boards menu."
28+
#endif
29+
30+
#include "Inkplate.h" // Include Inkplate library to the sketch
31+
Inkplate display; // Create an object on Inkplate library
32+
33+
int number = 0; // Variable that stores our number
34+
int n = 0; // Variable that keeps track on how many times display is partially updated
35+
36+
void setup()
37+
{
38+
Serial.begin(115200); // Start serial to print the number
39+
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
40+
display.clearDisplay(); // Clear frame buffer of display
41+
42+
// Display text
43+
display.setCursor(100, 212);
44+
display.setTextColor(INKPLATE_RED);
45+
display.setTextSize(2);
46+
display.print("Open Serial monitor at 115200 baud!");
47+
display.display();
48+
}
49+
50+
void loop()
51+
{
52+
53+
if (display.readTouchpad(PAD1))
54+
{ // Check if first pad has been touched. If it is, decrement the number and print to serial
55+
number--;
56+
Serial.print("The number is: ");
57+
Serial.println(number);
58+
}
59+
60+
if (display.readTouchpad(PAD2))
61+
{ // If you touched second touchpad, set number to zero and print to serial
62+
number = 0;
63+
Serial.print("The number is: ");
64+
Serial.println(number);
65+
}
66+
67+
if (display.readTouchpad(PAD3))
68+
{ // If you touched third touchpad, incerement the number and print to serial
69+
number++;
70+
Serial.print("The number is: ");
71+
Serial.println(number);
72+
}
73+
delay(100); // Wait a little bit between readings.
74+
}

examples/Inkplate7/Basic/Inkplate7_Black_White_Red/Inkplate7_Black_White_Red.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void setup()
3030
display.begin(); // Init library (you should call this function ONLY ONCE)
3131
display.clearDisplay(); // Clear any data that may have been in (software) frame buffer.
3232
//(NOTE! This does not clean image on screen, it only clears it in the frame buffer inside ESP32).
33-
display.setTextSize(4); // Set text size to be 4 times bigger than original (5x7 pix)
33+
display.setTextSize(4); // Set text size to be 4 times bigger than original (5x7 px)
3434
display.drawTextWithShadow(50, 175, "Welcome to Inkplate 7!", INKPLATE7_BLACK, INKPLATE7_RED); // Draw a text with shadow
3535
display.setTextColor(INKPLATE7_BLACK, INKPLATE7_WHITE); // Set text color to black and background to white
3636
display.display(); // This line actually drawing on the Inkplate screen, previous lines just drawing into the frame

examples/Inkplate7/Basic/Inkplate7_Text_With_Shadow/Inkplate7_Text_With_Shadow.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void setup()
4949

5050
// Draw a text with shadow with swapped colors
5151
display.setTextSize(3);
52-
display.drawTextWithShadow(300, 280, "By soldered.com", INKPLATE7_BLACK, INKPLATE7_RED);
52+
display.drawTextWithShadow(330, 280, "By Soldered", INKPLATE7_BLACK, INKPLATE7_RED);
5353

5454
// Other basic drawing functions supported
5555
display.drawLine(70, 250, 300, 350, INKPLATE7_RED);

src/include/System.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ uint8_t System::getPanelState()
4343
return _panelOn;
4444
}
4545

46-
#if !defined(ARDUINO_INKPLATE2) && !defined(ARDUINO_INKPLATECOLOR)
46+
#if !defined(ARDUINO_INKPLATE2)
4747

4848
/**
4949
* @brief readTemperature reads panel temperature

src/include/System.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class System : public Esp,
112112
void setPanelState(uint8_t s);
113113
uint8_t getPanelState();
114114

115-
#if !defined(ARDUINO_INKPLATE2) && !defined(ARDUINO_INKPLATECOLOR)
115+
#if !defined(ARDUINO_INKPLATE2)
116116

117117
int8_t readTemperature();
118118
uint8_t readTouchpad(uint8_t _pad);

src/include/defines.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,18 @@
5959

6060
#endif
6161

62-
#define INKPLATE_1BIT 0
63-
#define INKPLATE_3BIT 1
62+
#ifndef INKPLATE_6COLOR
63+
#define PAD1 10
64+
#define PAD2 11
65+
#define PAD3 12
66+
#else
6467
#define PAD1 10
6568
#define PAD2 11
6669
#define PAD3 12
70+
#endif
71+
72+
#define INKPLATE_1BIT 0
73+
#define INKPLATE_3BIT 1
6774
#define PWR_GOOD_OK 0b11111010
6875
#define INKPLATE_FORCE_PARTIAL true
6976

0 commit comments

Comments
 (0)