You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Guide for Using LVGL With the GIGA Display Shield
2
+
title: GIGA Display Shield LVGL Guide
3
3
description: 'Learn how to use LVGL with the GIGA Display Shield.'
4
4
author: Benjamin Dannegård
5
5
tags: [Display, LVGL]
6
6
---
7
7
8
8
## Introduction
9
9
10
-
LVGL is a very powerful graphical framework that is compatible with the GIGA Display Shield. It will allow you to put components on the screen like buttons, images, loading bars, sliders, checkboxes, etc. It also allows you to fully customize the screenspace on the display. This guide will go through the different components in detail so you can learn how to best implement it to your project.
10
+
[LVGL](https://lvgl.io/) is a graphical framework for building powerful UIs, and is fully compatible with the GIGA Display Shield. It allows you to build UIs, using pre-made widgets like buttons, images, loading bars, sliders, checkboxes, etc. It also allows you to fully customize the screenspace on the display. In this guide, we will go through some of the different components, so you can learn how to best implement it in your projects.
11
+
12
+
***LVGL is a large framework, and the aim of this guide is to get you familiar with it. For much more information, visit the [LVGL documentation](https://docs.lvgl.io/master/)***
11
13
12
14
## Hardware & Software Needed
13
15
@@ -19,50 +21,61 @@ LVGL is a very powerful graphical framework that is compatible with the GIGA Dis
19
21
20
22
## Downloading the Library and Core
21
23
22
-
The GIGA core includes a library that will help us handle the display, so make sure you have the latest version of the core.
24
+
The GIGA R1 core includes the [Arduino_H7_Video](https://github.com/arduino/ArduinoCore-mbed/tree/main/libraries/Arduino_H7_Video)library that handles the display.
23
25
24
26
In this guide, we will be using three different libraries:
25
-
-**[Arduino_H7_Video](https://github.com/arduino/ArduinoCore-mbed/tree/main/libraries/Arduino_H7_Video)**, this one is bundled with the core, so make sure you have the latest version of the [Mbed core](https://github.com/arduino/ArduinoCore-mbed)
26
-
-**Arduino_GigaDisplayTouch**
27
-
-**LVGL**
27
+
-[Arduino_H7_Video](https://github.com/arduino/ArduinoCore-mbed/tree/main/libraries/Arduino_H7_Video), this one is bundled with the core, so make sure you have the latest version of the [Mbed core](https://github.com/arduino/ArduinoCore-mbed) installed.
Open the library manager and install the latest version of **Arduino_GigaDisplayTouch** and **lvgl**.
31
+
To install them, open the library manager and install the latest version by searching for **"Arduino_GigaDisplayTouch"** and **"lvgl"**.
30
32
31
33
In the sketch include the libraries like this:
32
34
33
35
```arduino
34
36
#include "Arduino_H7_Video.h"
35
37
#include "lvgl.h"
36
-
37
38
#include "Arduino_GigaDisplayTouch.h"
38
39
```
39
40
40
41
## General Set Up
41
42
43
+
In this section, we will go through the fundamental elements of an LVGL sketch:
44
+
- How to define & configure the display,
45
+
- how to create a grid layout,
46
+
- how to add an object to the grid,
47
+
- how to update the display.
48
+
49
+
***At the end of this section, you will find a complete example which implements a grid layout. You can [skip directly to the example](#minimal-example), but if you have no prior experience with lvgl, we recommend you follow the information below.***
50
+
42
51
### Display Shield Configuration
43
52
44
-
We then will also need to define the screen we are using, do this by adding this line of code after the library inclusions. This function will use the **Arduino_H7_Video** library:
53
+
The first thing we need to do is to define the display we are using, by creating a object using the `Arduino_H7_Video` class, specifying the height, width and type of display.
And if you want to use touch with your application call the following to use the **Arduino_GigaDisplayTouch** library:
59
+
And if you want to use touch with your application, we need to create an object using the `Arduino_GigaDisplayTouch` class.
51
60
52
61
```arduino
53
62
Arduino_GigaDisplayTouch TouchDetector;
54
63
```
55
64
56
-
Then we have to start these functions by putting these lines in the `setup()` function:
65
+
In the `setup()`, we begin by initializing the display and the touch detector.
57
66
58
67
```arduino
59
-
Display.begin();
60
-
TouchDetector.begin();
68
+
void setup(){
69
+
Display.begin();
70
+
TouchDetector.begin();
71
+
}
61
72
```
62
73
74
+
With these things set up, we can go on to configure the LVGL elements.
75
+
63
76
### LVGL Screen Configuration
64
77
65
-
When creating elements, information about the screen and placement needs to be provided. Let's create a pointer variable that can be used whenever the screenspace needs to be used. The pointer variable will be named `screen` and to use the current screen for the pointer use `lv_scr_act()`.
78
+
When creating elements, information about the screen and placement needs to be provided. Let's create a pointer variable that can be used whenever the screenspace needs to be used. The pointer variable will be named `screen` and to use the current screen for the pointer use `lv_scr_act()`. This code should also be added inside `setup()`.
66
79
67
80
```arduino
68
81
lv_obj_t * screen = lv_obj_create(lv_scr_act());
@@ -101,12 +114,24 @@ Now that the columns and rows have been defined the overall screen needs to be t
The `lv_obj_set_grid_cell())` have a set of parameters related to how the object is positioned and aligned. In this case, we have created a 2x2 grid, where the `0` (column) and `0` (row) indicates where on the grid it should go.
130
+
131
+
Take a look at this graphic to understand it better:
132
+
133
+

134
+
110
135
### Update Loop
111
136
112
137
Include this in the loop of your sketch to make sure the LVGL engine is running and updating the screen.
@@ -117,6 +142,59 @@ void loop() {
117
142
}
118
143
```
119
144
145
+
### Minimal Example
146
+
147
+
The summary of all code snippets in this section can be found in the example below. It implements a 2x2 grid, as well as adds an object in each slot.

634
-

711
+

712
+

635
713
636
-
### Full Example
714
+
**Full Example:**
637
715
638
716
```arduino
639
717
#include "Arduino_H7_Video.h"
@@ -695,7 +773,7 @@ void loop() {
695
773
696
774
This guide went through the building blocks of the different components that can be implemented with LVGL. To see these examples in a full running example sketch go to **File > Examples > Arduino_H7_Video > LVGLDemo**.
697
775
698
-

776
+

699
777
700
778
This example sketch will show the different components in a 2x2 grid.
Copy file name to clipboardExpand all lines: content/hardware/10.mega/shields/giga-display-shield/tutorials/microphone-tutorial/assets/pdm-test-sketch.svg
description: "Learn how to use the GIGA Display Shield's microphone with LVGL."
4
4
author: Benjamin Dannegård
5
5
tags: [Display, microphone, LVGL]
6
6
---
@@ -20,11 +20,11 @@ Make sure the latest GIGA core is installed in the Arduino IDE. **Tools > Board
20
20
21
21
## Microphone Readings With The Shield
22
22
23
-
### Microphone Test Sketch
23
+
### Test Microphone
24
24
25
25
To test the microphone we can use the **PDMSerialPlotter** example sketch. This sketch can be found in **File > Examples > PDM** in the Arduino IDE. This sketch will print readings in the serial monitor. Upload the sketch and check so that readings are appearing in the serial monitor.
26
26
27
-

27
+

28
28
29
29
### Using the Microphone Readings
30
30
@@ -103,6 +103,8 @@ In the section below you can find the full sketch. If you upload it to your GIGA
103
103
104
104
### Full Sketch
105
105
106
+
You will find the full sketch in the example below:
0 commit comments