-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlvglCounter.ino
43 lines (31 loc) · 996 Bytes
/
lvglCounter.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
Using LVGL v7.11
*/
#include "Portenta_lvgl.h"
static lv_obj_t *label;
int counter = 0;
static void updateCounterTask(lv_task_t *task) {
// Print the count to the Serial monitor
Serial.println(counter);
// Update the text of the label
lv_label_set_text_fmt(label, "%d" , counter);
// Increase the count number
counter++;
}
void setup() {
Serial.begin(9600);
// Initialize Portenta's video interface
portenta_init_video();
// Setting up the label making it a child of the screen
label = lv_label_create(lv_scr_act(), NULL);
// Set the label's text
lv_label_set_text(label , "Counter");
// We move it to the center of the screen and align it centered
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
// Create a task to update the counter
lv_task_create(updateCounterTask, 1000, LV_TASK_PRIO_MID, NULL);
}
void loop() {
// put your main code here, to run repeatedly:
lv_task_handler();
}