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
Copy file name to clipboardExpand all lines: content/hardware/10.mega/shields/giga-display-shield/tutorials/10.square-line-tutorial/assets/button_label_gui.svg
Copy file name to clipboardExpand all lines: content/hardware/10.mega/shields/giga-display-shield/tutorials/10.square-line-tutorial/assets/names_highlight.svg
Copy file name to clipboardExpand all lines: content/hardware/10.mega/shields/giga-display-shield/tutorials/10.square-line-tutorial/content.md
+124-2Lines changed: 124 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ author: Benjamin Dannegård
5
5
tags: [Display, squareline, LVGL]
6
6
---
7
7
8
-
The GIGA Display Shield with the GIGA R1 WiFi board can run LVGL which allows for the creation of GUIs. To make the design of the GUI easier we can use the software SquareLine Studio. This will allow us to drag and drop different elements and then export it for usage on the display shield.
8
+
The GIGA Display Shield with the GIGA R1 WiFi board can run LVGL which allows for the creation of advanced GUIs. To make the design of the GUI easier we can use the software SquareLine Studio. This will allow us to drag and drop different elements and then export it for usage on the display shield.
9
9
10
10
## Hardware & Software Needed
11
11
@@ -53,7 +53,7 @@ In the folder that you exported the files to, go into the "libraries" folder and
53
53
54
54

55
55
56
-
Place this folder in your **Arduino->Libraries** folder.
56
+
Place this folder in your **Libraries** folder found inside your **Arduino** folder. This is the same **Arduino** folder that contains your Arduino IDE sketches.
57
57
58
58
Now to run the SquareLine Studio project, use this sketch:
59
59
@@ -82,6 +82,128 @@ void loop() {
82
82
}
83
83
```
84
84
85
+
## Using SquareLine Studio Widgets in Arduino IDE
86
+
87
+
The project from SquareLine Studio is exported as a library, let's take a look at how we can reference a specific element in the GUI. To demonstrate this we will first create a simple GUI with a increase button, a decrease button and a label. The label will show the number that will decrease or increase depending on what button is pressed. Our GUI will look like this:
88
+
89
+

90
+
91
+
Pay attention to the names of the button and the label, which can be seen on the right side and the upper left side here:
92
+
93
+

94
+
95
+
Name the widgets accordingly:
96
+
97
+
-**Increase Button**: ui_ButtonInc
98
+
-**Decrease Button**: ui_ButtonDec
99
+
-**Number Label**: ui_LabelNum
100
+
101
+
Now export the project and put the library in the Arduino libraries folder, as shown in the previous section.
102
+
103
+
Download this [lv_conf.h]() file and put it in your */mbed/libraries/Arduino_H7_Video/src folder. After setting this up we can go ahead and link the buttons to the label in our sketch.
104
+
105
+
First declare the libraries and set up the screen, this will be the same as the sketch above.
106
+
107
+
```arduino
108
+
#include "Arduino_H7_Video.h"
109
+
#include "Arduino_GigaDisplayTouch.h"
110
+
111
+
#include "lvgl.h"
112
+
#include "ui.h"
113
+
114
+
/* Insert resolution WxH according to your SquareLine studio project settings */
Then it is as simple as using the names of the widgets in a LVGL function. For example, when a function like `lv_label_set_text_fmt(NAME_OF_LABEL, "Label");` needs a reference to a label object, we can enter the name of the label that we created in SquareLine Studio. Same goes for the button widgets, like this in the `setup()` function:
120
+
121
+
```arduino
122
+
void setup() {
123
+
Display.begin();
124
+
Touch.begin();
125
+
126
+
/* Initialize the user interface designed with SquareLine Studio */
The last important part of the sketch are the callback functions that will run when a button is pressed. In the segment above you can see how the callback functions are tied to the buttons. The function will check when the button is pressed and increase the count on the label:
0 commit comments