use classes for ui
This commit is contained in:
@@ -28,7 +28,9 @@ void setup()
|
||||
lv_i18n_set_locale("de-DE");
|
||||
|
||||
lv_begin();
|
||||
ui_LaunchScreen_open();
|
||||
|
||||
LaunchScreen launchScreen;
|
||||
launchScreen.show();
|
||||
}
|
||||
|
||||
void loop()
|
||||
|
@@ -16,25 +16,30 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
#include "ui/launch_screen.h"
|
||||
#include "launch_screen.h"
|
||||
|
||||
#include <lvgl.h>
|
||||
#include "lv_i18n/lv_i18n.h"
|
||||
|
||||
void ui_LaunchScreen_open()
|
||||
lv_obj_t *screen;
|
||||
|
||||
LaunchScreen::LaunchScreen()
|
||||
{
|
||||
auto ui_SplashScreen = lv_obj_create(NULL);
|
||||
lv_obj_clear_flag(ui_SplashScreen, LV_OBJ_FLAG_SCROLLABLE);
|
||||
lv_obj_set_style_bg_color(ui_SplashScreen, lv_color_make(0x78, 0x94, 0xa7), 0);
|
||||
screen = lv_obj_create(NULL);
|
||||
lv_obj_clear_flag(screen, LV_OBJ_FLAG_SCROLLABLE);
|
||||
lv_obj_set_style_bg_color(screen, lv_color_make(0x78, 0x94, 0xa7), 0);
|
||||
|
||||
LV_IMG_DECLARE(os_railway_icon_lvgl);
|
||||
auto *img = lv_img_create(ui_SplashScreen);
|
||||
lv_img_set_src(img, &os_railway_icon_lvgl);
|
||||
lv_obj_align(img, LV_ALIGN_CENTER, 0, 0);
|
||||
auto *logo = lv_img_create(screen);
|
||||
lv_img_set_src(logo, &os_railway_icon_lvgl);
|
||||
lv_obj_align(logo, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
auto *label = lv_label_create(ui_SplashScreen);
|
||||
auto *label = lv_label_create(screen);
|
||||
lv_label_set_text(label, _("appName"));
|
||||
lv_obj_align(label, LV_ALIGN_BOTTOM_MID, 0, -25);
|
||||
|
||||
lv_disp_load_scr(ui_SplashScreen);
|
||||
}
|
||||
|
||||
void LaunchScreen::show()
|
||||
{
|
||||
lv_disp_load_scr(screen);
|
||||
}
|
||||
|
@@ -18,4 +18,9 @@
|
||||
//----------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
void ui_LaunchScreen_open();
|
||||
class LaunchScreen
|
||||
{
|
||||
public:
|
||||
LaunchScreen();
|
||||
void show();
|
||||
};
|
||||
|
Reference in New Issue
Block a user