Skip to content

Commit 28f3128

Browse files
committed
Add examples for drawTextBox function
1 parent cb3ae23 commit 28f3128

File tree

20 files changed

+2550
-0
lines changed

20 files changed

+2550
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
Inkplate10_TextBox example for Soldered Inkplate 10
3+
For this example you will need a micro USB cable and an Inkplate 10.
4+
Select "Soldered Inkplate 10" from Tools -> Board menu.
5+
6+
This example will show you how to use the TextBox function with and without special parameters
7+
8+
Want to learn more about Inkplate? Visit www.inkplate.io
9+
Looking to get support? Write on our forums: https://forum.soldered.com/
10+
24 April 2025 by Soldered
11+
*/
12+
13+
#include "Inkplate.h" //Include Inkplate library to the sketch
14+
#include "Roboto_Light_36.h"
15+
Inkplate display(INKPLATE_1BIT); // Create an object on Inkplate library and also set library into 1 Bit mode (BW)
16+
17+
// Define the text you will show in the text box
18+
const char* text="This is an example of a text written in a textbox. When a word doesn't fit into the current row, it goes to the next one."\
19+
" If the text reaches the lower bound, it ends with three dots (...) to mark that the text isnt displayed fully";
20+
21+
void setup()
22+
{
23+
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
24+
display.clearDisplay(); // Clear frame buffer of display
25+
display.display(); // Put clear image on display
26+
27+
// Create a text box without any optional parameters
28+
// x0- x coordinate of upper left corner
29+
// y0- y coordinate of upper left corner
30+
// x1- x coordinate of bottom right corner
31+
// y1- y coordinate of bottom right corner
32+
// text - text we want to display
33+
display.drawTextBox(100,100,300,300,text);
34+
35+
// Create a text box with all parameters
36+
// x0- x coordinate of upper left corner
37+
// y0- y coordinate of upper left corner
38+
// x1- x coordinate of bottom right corner
39+
// y1- y coordinate of bottom right corner
40+
// text - text we want to display
41+
// textSizeMultiplier - by what factor we want to enlarge the size of a font
42+
// font - address of selected custom font
43+
// verticalSpacing - how many pixels between each row of text
44+
// showBorder - Create a visible rectangle around the box
45+
// fontSize - size of the used font in pt
46+
int offset=32; // Note - some custom fonts are drawn from bottom-to-top which requires an offset, use an offset that best suits the font you use
47+
display.drawTextBox(400,100+offset,600,300,text,1,&Roboto_Light_36,27,false,36);
48+
49+
// Display both text boxes
50+
display.display();
51+
}
52+
53+
void loop()
54+
{
55+
// Nothing...
56+
}

examples/Inkplate10/Advanced/Other/Inkplate10_TextBox/Roboto_Light_36.h

Lines changed: 199 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
Inkplate4_TextBox example for Soldered Inkplate 4
3+
For this example you will need a micro USB cable and an Inkplate 4.
4+
Select "Soldered Inkplate 4" from Tools -> Board menu.
5+
6+
This example will show you how to use the TextBox function with and without special parameters
7+
8+
Want to learn more about Inkplate? Visit www.inkplate.io
9+
Looking to get support? Write on our forums: https://forum.soldered.com/
10+
24 April 2025 by Soldered
11+
*/
12+
13+
#include "Inkplate.h" //Include Inkplate library to the sketch
14+
#include "Roboto_Light_36.h"
15+
Inkplate display(INKPLATE_1BIT); // Create an object on Inkplate library and also set library into 1 Bit mode (BW)
16+
17+
// Define the text you will show in the text box
18+
const char* text="This is an example of a text written in a textbox. When a word doesn't fit into the current row, it goes to the next one."\
19+
" If the text reaches the lower bound, it ends with three dots (...) to mark that the text isnt displayed fully";
20+
21+
void setup()
22+
{
23+
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
24+
display.clearDisplay(); // Clear frame buffer of display
25+
display.display(); // Put clear image on display
26+
27+
// Create a text box without any optional parameters
28+
// x0- x coordinate of upper left corner
29+
// y0- y coordinate of upper left corner
30+
// x1- x coordinate of bottom right corner
31+
// y1- y coordinate of bottom right corner
32+
// text - text we want to display
33+
display.drawTextBox(100,100,300,300,text);
34+
35+
// Create a text box with all parameters
36+
// x0- x coordinate of upper left corner
37+
// y0- y coordinate of upper left corner
38+
// x1- x coordinate of bottom right corner
39+
// y1- y coordinate of bottom right corner
40+
// text - text we want to display
41+
// textSizeMultiplier - by what factor we want to enlarge the size of a font
42+
// font - address of selected custom font
43+
// verticalSpacing - how many pixels between each row of text
44+
// showBorder - Create a visible rectangle around the box
45+
// fontSize - size of the used font in pt
46+
int offset=32; // Note - some custom fonts are drawn from bottom-to-top which requires an offset, use an offset that best suits the font you use
47+
display.drawTextBox(400,100+offset,600,300,text,1,&Roboto_Light_36,27,false,36);
48+
49+
// Display both text boxes
50+
display.display();
51+
}
52+
53+
void loop()
54+
{
55+
// Nothing...
56+
}

0 commit comments

Comments
 (0)