Skip to content

Commit 2b56268

Browse files
committed
Added LVGL sketch
1 parent 5498060 commit 2b56268

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include "Portenta_LittleVGL.h"
2+
3+
static lv_obj_t *label;
4+
int counter = 0;
5+
6+
static void updateCounterTask(lv_task_t *task) {
7+
// Print the count to the Serial monitor
8+
Serial.println(counter);
9+
10+
// Update the text of the label
11+
lv_label_set_text_fmt(label, "%d" , counter);
12+
13+
// Increase the count number
14+
counter++;
15+
}
16+
17+
void setup() {
18+
Serial.begin(9600);
19+
20+
// Initialize Portenta's video interface
21+
portenta_init_video();
22+
23+
// Setting up the label making it a child of the screen
24+
label = lv_label_create(lv_scr_act(), NULL);
25+
26+
// Set the label's text
27+
lv_label_set_text(label , "Counter");
28+
29+
// We move it to the center of the screen and align it centered
30+
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
31+
32+
// Create a task to update the counter
33+
lv_task_create(updateCounterTask, 1000, LV_TASK_PRIO_MID, NULL);
34+
}
35+
36+
void loop() {
37+
// put your main code here, to run repeatedly:
38+
lv_task_handler();
39+
}

0 commit comments

Comments
 (0)