Skip to content

Commit a9e7db2

Browse files
authored
Merge pull request #13 from leonardocavagnis/ex_squarelinestudio_lvgl
Add LVGL SquareLine Studio example
2 parents 0a081c9 + e31ccf9 commit a9e7db2

File tree

14 files changed

+613
-0
lines changed

14 files changed

+613
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# How to run the sketch:
2+
- copy the `ui` folder into your `Arduino/libraries` directory
3+
- upload the sketch and see the magic!
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* squarelinestudio_lvgl
3+
*
4+
* This example demonstrates the integration of a SquareLine Studio project with the Arduino GIGA Display Shield.
5+
* SquareLine Studio is an easy-to-use drag-and-drop UI editor tool for LVGL.
6+
*
7+
* Instructions:
8+
* 1. Create a SquareLine Studio project with the following settings:
9+
* - Resolution: 800x480
10+
* - Color depth: 16-bit
11+
* - LVGL version: 8.3.x
12+
* 2. Design your GUI using the drag-and-drop tool.
13+
* 3. Export the LVGL UI files.
14+
* 4. Open the exported file and copy the 'libraries/ui' folder into your 'Arduino/libraries' directory.
15+
*
16+
* Inside the sketch folder, you will find a preconfigured example of the 'ui' folder, exported from SquareLine Studio.
17+
* This example displays a white screen with a clickable blue button in the center.
18+
*
19+
* Initial author: Leonardo Cavagnis @leonardocavagnis
20+
*/
21+
22+
#include "Arduino_H7_Video.h"
23+
#include "Arduino_GigaDisplayTouch.h"
24+
25+
#include "lvgl.h"
26+
#include "ui.h"
27+
28+
/* Initialize the GIGA Display Shield with a resolution of 800x480 pixels */
29+
Arduino_H7_Video Display(800, 480, GigaDisplayShield);
30+
Arduino_GigaDisplayTouch Touch;
31+
32+
void setup() {
33+
Display.begin();
34+
Touch.begin();
35+
36+
/* Initialize the user interface designed with SquareLine Studio */
37+
ui_init();
38+
}
39+
40+
void loop() {
41+
/* Feed LVGL engine */
42+
lv_timer_handler();
43+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name=ui
2+
version=1.0
3+
author=SquareLine_Studio
4+
category=Display
5+
url=https://squareline.io
6+
architectures=*
7+
includes=ui.h
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SET(SOURCES screens/ui_Screen1.c
2+
ui.c
3+
components/ui_comp_hook.c
4+
ui_helpers.c)
5+
6+
add_library(ui ${SOURCES})
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// This file was generated by SquareLine Studio
2+
// SquareLine Studio version: SquareLine Studio 1.3.2
3+
// LVGL version: 8.3.6
4+
// Project name: ButtonTest
5+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
screens/ui_Screen1.c
2+
ui.c
3+
components/ui_comp_hook.c
4+
ui_helpers.c
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The UI files will be exported here
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// This file was generated by SquareLine Studio
2+
// SquareLine Studio version: SquareLine Studio 1.3.2
3+
// LVGL version: 8.3.6
4+
// Project name: ButtonTest
5+
6+
#include "../ui.h"
7+
8+
void ui_Screen1_screen_init(void)
9+
{
10+
ui_Screen1 = lv_obj_create(NULL);
11+
lv_obj_clear_flag( ui_Screen1, LV_OBJ_FLAG_SCROLLABLE ); /// Flags
12+
13+
ui_Button1 = lv_btn_create(ui_Screen1);
14+
lv_obj_set_width( ui_Button1, 150);
15+
lv_obj_set_height( ui_Button1, 125);
16+
lv_obj_set_x( ui_Button1, -5 );
17+
lv_obj_set_y( ui_Button1, -3 );
18+
lv_obj_set_align( ui_Button1, LV_ALIGN_CENTER );
19+
lv_obj_add_flag( ui_Button1, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags
20+
lv_obj_clear_flag( ui_Button1, LV_OBJ_FLAG_SCROLLABLE ); /// Flags
21+
22+
ui_Label1 = lv_label_create(ui_Button1);
23+
lv_obj_set_width( ui_Label1, LV_SIZE_CONTENT); /// 1
24+
lv_obj_set_height( ui_Label1, LV_SIZE_CONTENT); /// 1
25+
lv_obj_set_align( ui_Label1, LV_ALIGN_CENTER );
26+
lv_label_set_text(ui_Label1,"Button");
27+
28+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// This file was generated by SquareLine Studio
2+
// SquareLine Studio version: SquareLine Studio 1.3.2
3+
// LVGL version: 8.3.6
4+
// Project name: ButtonTest
5+
6+
#include "ui.h"
7+
#include "ui_helpers.h"
8+
9+
///////////////////// VARIABLES ////////////////////
10+
11+
12+
// SCREEN: ui_Screen1
13+
void ui_Screen1_screen_init(void);
14+
lv_obj_t *ui_Screen1;
15+
lv_obj_t *ui_Button1;
16+
lv_obj_t *ui_Label1;
17+
lv_obj_t *ui____initial_actions0;
18+
19+
///////////////////// TEST LVGL SETTINGS ////////////////////
20+
#if LV_COLOR_DEPTH != 16
21+
#error "LV_COLOR_DEPTH should be 16bit to match SquareLine Studio's settings"
22+
#endif
23+
#if LV_COLOR_16_SWAP !=0
24+
#error "LV_COLOR_16_SWAP should be 0 to match SquareLine Studio's settings"
25+
#endif
26+
27+
///////////////////// ANIMATIONS ////////////////////
28+
29+
///////////////////// FUNCTIONS ////////////////////
30+
31+
///////////////////// SCREENS ////////////////////
32+
33+
void ui_init( void )
34+
{
35+
lv_disp_t *dispp = lv_disp_get_default();
36+
lv_theme_t *theme = lv_theme_default_init(dispp, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED), false, LV_FONT_DEFAULT);
37+
lv_disp_set_theme(dispp, theme);
38+
ui_Screen1_screen_init();
39+
ui____initial_actions0 = lv_obj_create(NULL);
40+
lv_disp_load_scr( ui_Screen1);
41+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// This file was generated by SquareLine Studio
2+
// SquareLine Studio version: SquareLine Studio 1.3.2
3+
// LVGL version: 8.3.6
4+
// Project name: ButtonTest
5+
6+
#ifndef _BUTTONTEST_UI_H
7+
#define _BUTTONTEST_UI_H
8+
9+
#ifdef __cplusplus
10+
extern "C" {
11+
#endif
12+
13+
#if defined __has_include
14+
#if __has_include("lvgl.h")
15+
#include "lvgl.h"
16+
#elif __has_include("lvgl/lvgl.h")
17+
#include "lvgl/lvgl.h"
18+
#else
19+
#include "lvgl.h"
20+
#endif
21+
#else
22+
#include "lvgl.h"
23+
#endif
24+
25+
#include "ui_helpers.h"
26+
#include "ui_events.h"
27+
// SCREEN: ui_Screen1
28+
void ui_Screen1_screen_init(void);
29+
extern lv_obj_t *ui_Screen1;
30+
extern lv_obj_t *ui_Button1;
31+
extern lv_obj_t *ui_Label1;
32+
extern lv_obj_t *ui____initial_actions0;
33+
34+
35+
36+
37+
void ui_init(void);
38+
39+
#ifdef __cplusplus
40+
} /*extern "C"*/
41+
#endif
42+
43+
#endif
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// This file was generated by SquareLine Studio
2+
// SquareLine Studio version: SquareLine Studio 1.3.2
3+
// LVGL version: 8.3.6
4+
// Project name: ButtonTest
5+
6+
#ifndef _UI_EVENTS_H
7+
#define _UI_EVENTS_H
8+
9+
#ifdef __cplusplus
10+
extern "C" {
11+
#endif
12+
13+
#ifdef __cplusplus
14+
} /*extern "C"*/
15+
#endif
16+
17+
#endif

0 commit comments

Comments
 (0)