Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Squareline Studio example to LVGL 9.1 #31

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
> [!NOTE]
> SquareLine Studio has ended its collaboration with LVGL. It only supports LVGL version 8 and earlier.

# How to run the sketch:
- move the `ui` folder into your `Arduino/libraries` directory
- upload the sketch and see the magic!
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* 1. Create a SquareLine Studio project with the following settings:
* - Resolution: 800x480
* - Color depth: 16-bit
* - LVGL version: 8.3.x (NOTE: It only supports LVGL version 8 and earlier.)
* - LVGL version: 9.x.x
* 2. Design your GUI using the drag-and-drop tool.
* 3. Export the LVGL UI files.
* 4. Open the exported file and copy the 'libraries/ui' folder into your 'Arduino/libraries' directory.
Expand All @@ -29,10 +29,6 @@
Arduino_H7_Video Display(800, 480, GigaDisplayShield);
Arduino_GigaDisplayTouch Touch;

#if (LVGL_VERSION_MAJOR >= 9)
#error "SquareLine Studio has ended its collaboration with LVGL. It only supports LVGL version 8 and earlier."
#endif

void setup() {
Display.begin();
Touch.begin();
Expand Down
14 changes: 14 additions & 0 deletions examples/lvgl/squarelinestudio_lvgl/ui/library.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name=ui
version=1.0
author=SquareLine_Studio
category=Display
url=https://squareline.io
architectures=*
includes=ui.h
sentence=SquareLine_Studio
paragraph=Squareline Studio creates smart, user-friendly LVGL UI solutions.
name=ui
maintainer=Squareline Studio
[email protected]


9 changes: 9 additions & 0 deletions examples/lvgl/squarelinestudio_lvgl/ui/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
SET(SOURCES ui_comp_button.c
ui_comp.c
ui_Screen1.c
ui.c
ui_comp_hook.c
ui_helpers.c
ui_events.c)

add_library(ui ${SOURCES})
7 changes: 7 additions & 0 deletions examples/lvgl/squarelinestudio_lvgl/ui/src/filelist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ui_comp_button.c
ui_comp.c
ui_Screen1.c
ui.c
ui_comp_hook.c
ui_helpers.c
ui_events.c
41 changes: 41 additions & 0 deletions examples/lvgl/squarelinestudio_lvgl/ui/src/ui.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// This file was generated by SquareLine Studio
// SquareLine Studio version: SquareLine Studio 1.4.1
// LVGL version: 9.1.0
// Project name: SquareLine_Project

#include "ui.h"
#include "ui_helpers.h"

///////////////////// VARIABLES ////////////////////


// SCREEN: ui_Screen1
void ui_Screen1_screen_init(void);
lv_obj_t * ui_Screen1;
lv_obj_t * ui_Button;
lv_obj_t * ui_Label1;
lv_obj_t * ui____initial_actions0;

///////////////////// TEST LVGL SETTINGS ////////////////////
#if LV_COLOR_DEPTH != 16
#error "LV_COLOR_DEPTH should be 16bit to match SquareLine Studio's settings"
#endif

///////////////////// ANIMATIONS ////////////////////

///////////////////// FUNCTIONS ////////////////////

///////////////////// SCREENS ////////////////////

void ui_init(void)
{
LV_EVENT_GET_COMP_CHILD = lv_event_register_id();

lv_disp_t * dispp = lv_display_get_default();
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);
lv_disp_set_theme(dispp, theme);
ui_Screen1_screen_init();
ui____initial_actions0 = lv_obj_create(NULL);
lv_disp_load_scr(ui_Screen1);
}
50 changes: 50 additions & 0 deletions examples/lvgl/squarelinestudio_lvgl/ui/src/ui.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// This file was generated by SquareLine Studio
// SquareLine Studio version: SquareLine Studio 1.4.1
// LVGL version: 9.1.0
// Project name: SquareLine_Project

#ifndef _SQUARELINE_PROJECT_UI_H
#define _SQUARELINE_PROJECT_UI_H

#ifdef __cplusplus
extern "C" {
#endif

#if defined __has_include
#if __has_include("lvgl.h")
#include "lvgl.h"
#elif __has_include("lvgl/lvgl.h")
#include "lvgl/lvgl.h"
#else
#include "lvgl.h"
#endif
#else
#include "lvgl.h"
#endif

#include "ui_helpers.h"
#include "ui_comp.h"
#include "ui_comp_hook.h"
#include "ui_events.h"

// SCREEN: ui_Screen1
void ui_Screen1_screen_init(void);
extern lv_obj_t * ui_Screen1;
extern lv_obj_t * ui_Button;
extern lv_obj_t * ui_Label1;
extern lv_obj_t * ui____initial_actions0;








void ui_init(void);

#ifdef __cplusplus
} /*extern "C"*/
#endif

#endif
28 changes: 28 additions & 0 deletions examples/lvgl/squarelinestudio_lvgl/ui/src/ui_Screen1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// This file was generated by SquareLine Studio
// SquareLine Studio version: SquareLine Studio 1.4.1
// LVGL version: 9.1.0
// Project name: SquareLine_Project

#include "ui.h"

void ui_Screen1_screen_init(void)
{
ui_Screen1 = lv_obj_create(NULL);
lv_obj_remove_flag(ui_Screen1, LV_OBJ_FLAG_SCROLLABLE); /// Flags

ui_Button = ui_Button_create(ui_Screen1);
lv_obj_set_width(ui_Button, lv_pct(30));
lv_obj_set_height(ui_Button, lv_pct(20));
lv_obj_set_x(ui_Button, 0);
lv_obj_set_y(ui_Button, -3);

ui_Label1 = lv_label_create(ui_Button);
lv_obj_set_width(ui_Label1, lv_pct(100));
lv_obj_set_height(ui_Label1, lv_pct(100));
lv_obj_set_x(ui_Label1, 18);
lv_obj_set_y(ui_Label1, 11);
lv_obj_set_align(ui_Label1, LV_ALIGN_CENTER);
lv_label_set_text(ui_Label1, "Button");
lv_obj_set_style_text_font(ui_Label1, &lv_font_montserrat_14, LV_PART_MAIN | LV_STATE_DEFAULT);

}
37 changes: 37 additions & 0 deletions examples/lvgl/squarelinestudio_lvgl/ui/src/ui_comp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// This file was generated by SquareLine Studio
// SquareLine Studio version: SquareLine Studio 1.4.1
// LVGL version: 9.1.0
// Project name: SquareLine_Project

#include "ui.h"
#include "ui_helpers.h"
#include "ui_comp.h"

uint32_t LV_EVENT_GET_COMP_CHILD;

typedef struct {
uint32_t child_idx;
lv_obj_t * child;
} ui_comp_get_child_t;

lv_obj_t * ui_comp_get_child(lv_obj_t * comp, uint32_t child_idx)
{
ui_comp_get_child_t info;
info.child = NULL;
info.child_idx = child_idx;
lv_obj_send_event(comp, LV_EVENT_GET_COMP_CHILD, &info);
return info.child;
}

void get_component_child_event_cb(lv_event_t * e)
{
lv_obj_t ** c = lv_event_get_user_data(e);
ui_comp_get_child_t * info = lv_event_get_param(e);
info->child = c[info->child_idx];
}

void del_component_child_event_cb(lv_event_t * e)
{
lv_obj_t ** c = lv_event_get_user_data(e);
lv_free(c);
}
26 changes: 26 additions & 0 deletions examples/lvgl/squarelinestudio_lvgl/ui/src/ui_comp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// This file was generated by SquareLine Studio
// SquareLine Studio version: SquareLine Studio 1.4.1
// LVGL version: 9.1.0
// Project name: SquareLine_Project

#ifndef _UI_COMP__H
#define _UI_COMP__H

#include "ui.h"

#ifdef __cplusplus
extern "C" {
#endif

void get_component_child_event_cb(lv_event_t * e);
void del_component_child_event_cb(lv_event_t * e);

lv_obj_t * ui_comp_get_child(lv_obj_t * comp, uint32_t child_idx);
extern uint32_t LV_EVENT_GET_COMP_CHILD;
#include "ui_comp_button.h"

#ifdef __cplusplus
} /*extern "C"*/
#endif

#endif
31 changes: 31 additions & 0 deletions examples/lvgl/squarelinestudio_lvgl/ui/src/ui_comp_button.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// This file was generated by SquareLine Studio
// SquareLine Studio version: SquareLine Studio 1.4.1
// LVGL version: 9.1.0
// Project name: SquareLine_Project

#include "ui.h"


// COMPONENT Button

lv_obj_t * ui_Button_create(lv_obj_t * comp_parent)
{

lv_obj_t * cui_Button;
cui_Button = lv_button_create(comp_parent);
lv_obj_set_width(cui_Button, 100);
lv_obj_set_height(cui_Button, 50);
lv_obj_set_x(cui_Button, 0);
lv_obj_set_y(cui_Button, -3);
lv_obj_set_align(cui_Button, LV_ALIGN_CENTER);
lv_obj_add_flag(cui_Button, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags
lv_obj_remove_flag(cui_Button, LV_OBJ_FLAG_SCROLLABLE); /// Flags

lv_obj_t ** children = lv_malloc(sizeof(lv_obj_t *) * _UI_COMP_BUTTON_NUM);
children[UI_COMP_BUTTON_BUTTON] = cui_Button;
lv_obj_add_event_cb(cui_Button, get_component_child_event_cb, LV_EVENT_GET_COMP_CHILD, children);
lv_obj_add_event_cb(cui_Button, del_component_child_event_cb, LV_EVENT_DELETE, children);
ui_comp_Button_create_hook(cui_Button);
return cui_Button;
}

24 changes: 24 additions & 0 deletions examples/lvgl/squarelinestudio_lvgl/ui/src/ui_comp_button.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// This file was generated by SquareLine Studio
// SquareLine Studio version: SquareLine Studio 1.4.1
// LVGL version: 9.1.0
// Project name: SquareLine_Project

#ifndef _UI_COMP_BUTTON_H
#define _UI_COMP_BUTTON_H

#include "ui.h"

#ifdef __cplusplus
extern "C" {
#endif

// COMPONENT Button
#define UI_COMP_BUTTON_BUTTON 0
#define _UI_COMP_BUTTON_NUM 1
lv_obj_t * ui_Button_create(lv_obj_t * comp_parent);

#ifdef __cplusplus
} /*extern "C"*/
#endif

#endif
10 changes: 10 additions & 0 deletions examples/lvgl/squarelinestudio_lvgl/ui/src/ui_comp_hook.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// This file was generated by SquareLine Studio
// SquareLine Studio version: SquareLine Studio 1.4.1
// LVGL version: 9.1.0
// Project name: SquareLine_Project

#include "ui.h"

void ui_comp_Button_create_hook(lv_obj_t * comp)
{
}
19 changes: 19 additions & 0 deletions examples/lvgl/squarelinestudio_lvgl/ui/src/ui_comp_hook.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// This file was generated by SquareLine Studio
// SquareLine Studio version: SquareLine Studio 1.4.1
// LVGL version: 9.1.0
// Project name: SquareLine_Project

#ifndef _SQUARELINE_PROJECT_UI_COMP_HOOK_H
#define _SQUARELINE_PROJECT_UI_COMP_HOOK_H

#ifdef __cplusplus
extern "C" {
#endif

void ui_comp_Button_create_hook(lv_obj_t * comp);

#ifdef __cplusplus
} /*extern "C"*/
#endif

#endif
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This file was generated by SquareLine Studio
// SquareLine Studio version: SquareLine Studio 1.3.2
// LVGL version: 8.3.6
// Project name: ButtonTest
// SquareLine Studio version: SquareLine Studio 1.4.1
// LVGL version: 9.1.0
// Project name: SquareLine_Project

#ifndef _UI_EVENTS_H
#define _UI_EVENTS_H
Expand Down
Loading
Loading