Skip to content

Commit 2fb7d27

Browse files
committed
Update exampels
1 parent 1574d20 commit 2fb7d27

File tree

2 files changed

+117
-33
lines changed

2 files changed

+117
-33
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/**
2+
**************************************************
3+
*
4+
* @file Frontlight.ino
5+
* @brief This example will show you how to use frontlight feature on Inkplate 6FLICK.
6+
*
7+
* For info on how to quickly get started with Inkplate 6FLICK visit
8+
* https://soldered.com/documentation/inkplate/6flick/overview/
9+
*
10+
* @authors Soldered
11+
* @date November 2025
12+
***************************************************/
13+
14+
// Include the Inkplate LVGL Library
15+
#include <Inkplate-LVGL.h>
16+
17+
// Create an instance of Inkplate display in 1-bit mode (change to INKPLATE_3BIT if you want grayscale)
18+
Inkplate inkplate(INKPLATE_1BIT);
19+
20+
// Set initial brightness value
21+
int b = 31;
22+
23+
void setup()
24+
{
25+
Serial.begin(115200);
26+
27+
// Initialize inkplate
28+
inkplate.begin(LV_DISPLAY_RENDER_MODE_PARTIAL);
29+
30+
// Turn frontlight ON
31+
inkplate.frontlight.setState(true);
32+
// Set initial frontlight brightness intensity
33+
inkplate.frontlight.setBrightness(b);
34+
}
35+
36+
void loop()
37+
{
38+
// Change frontlight value by sending "+" sign into serial monitor to increase frontlight or
39+
// "-" sign to decrese frontlight, try to find hidden lightshow ;)
40+
if (Serial.available())
41+
{
42+
bool change = false; // Variable that indicates that frontlight value has changed and intessity has to be updated
43+
char c = Serial.read(); // Read incomming serial data
44+
45+
if (c == '+' && b < 63) // If '+' received, increase frontlight
46+
{
47+
b++;
48+
change = true;
49+
}
50+
if (c == '-' && b > 0) // If '-' received, decrease frontlight
51+
{
52+
b--;
53+
change = true;
54+
}
55+
56+
if (c == 's')
57+
{
58+
for (int j = 0; j < 4; ++j)
59+
{
60+
for (int i = 0; i < 64; ++i)
61+
{
62+
inkplate.frontlight.setBrightness(i);
63+
delay(30);
64+
}
65+
for (int i = 63; i >= 0; --i)
66+
{
67+
inkplate.frontlight.setBrightness(i);
68+
delay(30);
69+
}
70+
}
71+
72+
change = true;
73+
}
74+
75+
if (change) // If frontlight valuse has changed, update the intensity and show current value of frontlight
76+
{
77+
inkplate.frontlight.setBrightness(b);
78+
Serial.print("Frontlight:");
79+
Serial.print(b, DEC);
80+
Serial.println("/63");
81+
}
82+
}
83+
}

examples/Inkplate6FLICK/Basic/SimpleTouchscreen/SimpleTouchscreen.ino

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -41,60 +41,35 @@ int y_position = 50;
4141

4242
static void btn_event_cb(lv_event_t *e)
4343
{
44+
// Get the event code
4445
lv_event_code_t code = lv_event_get_code(e);
4546

47+
// If click event detected, update the position
4648
if (code == LV_EVENT_CLICKED)
4749
{
4850
if (rect)
4951
{
52+
// Update coordinates
5053
x_position += 100;
5154
y_position += 100;
52-
55+
5356
if (y_position < 660)
5457
{
58+
// Set new position of an object
5559
lv_obj_set_pos(rect, x_position, y_position);
60+
// Mark the object to redraw it in next refresh
5661
lv_obj_invalidate(rect);
5762
isRectangleClicked = true;
5863
}
5964
else
6065
{
6166
x_position = 50;
6267
y_position = 50;
63-
64-
inkplate.clearDisplay();
65-
lv_obj_clean(lv_scr_act());
66-
lv_draw_initials();
67-
lv_obj_invalidate(lv_scr_act());
68-
for (int i = 0; i < 5; i++)
69-
{
70-
lv_timer_handler();
71-
delay(10);
72-
}
73-
inkplate.display();
7468
}
7569
}
7670
}
7771
}
7872

79-
static void lv_draw_initials()
80-
{
81-
/* Create a black label, set its text and font and align it to the center */
82-
lv_obj_t *label = lv_label_create(lv_screen_active());
83-
lv_label_set_text(label, "Touch the rectangles on screen!");
84-
lv_obj_set_style_text_color(lv_screen_active(), lv_color_hex(0x000000), LV_PART_MAIN);
85-
lv_obj_set_style_text_font(label, &lv_font_montserrat_48, 0);
86-
lv_obj_align(label, LV_ALIGN_TOP_MID, 0, 0);
87-
88-
/* Create a black rectangle */
89-
rect = lv_obj_create(lv_scr_act());
90-
lv_obj_set_style_bg_color(rect, lv_color_hex(0x000000), 0);
91-
lv_obj_set_size(rect, 100, 50);
92-
lv_obj_set_pos(rect, x_position, y_position);
93-
94-
// Add event callback function
95-
lv_obj_add_event_cb(rect, btn_event_cb, LV_EVENT_ALL, NULL);
96-
}
97-
9873
void setup()
9974
{
10075
Serial.begin(115200);
@@ -112,6 +87,25 @@ void setup()
11287
while (true);
11388
}
11489

90+
/* Create a black label, set its text and font and align it to the center */
91+
lv_obj_t *label = lv_label_create(lv_screen_active());
92+
lv_label_set_text(label, "Touch the rectangles on screen!");
93+
lv_obj_set_style_text_color(lv_screen_active(), lv_color_hex(0x000000), LV_PART_MAIN);
94+
lv_obj_set_style_text_font(label, &lv_font_montserrat_48, 0);
95+
lv_obj_center(label);
96+
97+
// Render text on screen
98+
lv_timer_handler();
99+
inkplate.display();
100+
101+
// Wait for 2 seconds
102+
delay(2000);
103+
104+
// Delete the label object and clear the display
105+
lv_obj_del(label);
106+
label = NULL;
107+
inkplate.clearDisplay();
108+
115109
// Create LVGL task on core 1 to run independently from the rest of the sketch
116110
xTaskCreatePinnedToCore(
117111
lvgl_task, // Function which will be pinned
@@ -123,14 +117,22 @@ void setup()
123117
1 // core used
124118
);
125119

126-
lv_draw_initials();
120+
/* Create a black rectangle and add a callback event function to it */
121+
rect = lv_obj_create(lv_scr_act());
122+
lv_obj_set_style_bg_color(rect, lv_color_hex(0x000000), 0);
123+
lv_obj_set_size(rect, 100, 50);
124+
lv_obj_set_pos(rect, x_position, y_position);
125+
126+
// Add event callback function
127+
lv_obj_add_event_cb(rect, btn_event_cb, LV_EVENT_ALL, NULL);
127128

128129
// Force initial render
129130
for (int i = 0; i < 5; i++)
130131
{
131132
lv_timer_handler();
132133
delay(10);
133134
}
135+
134136
// Display content from buffer
135137
inkplate.display();
136138
}
@@ -143,4 +145,3 @@ void loop()
143145
isRectangleClicked = false;
144146
}
145147
}
146-

0 commit comments

Comments
 (0)