2025-08-05 16:06:46 +08:00
|
|
|
|
// LVGL version: 9.2
|
|
|
|
|
|
// Project name: PowerPico
|
|
|
|
|
|
|
2025-09-22 21:45:02 +08:00
|
|
|
|
#include "./ui.h"
|
2025-11-26 19:16:32 +08:00
|
|
|
|
#include "./screens/ui_StartPage.h"
|
2025-09-22 21:45:02 +08:00
|
|
|
|
#include "./screens/ui_mainPage.h"
|
2025-10-07 10:29:31 +08:00
|
|
|
|
#include "./screens/ui_chartPage.h"
|
2025-10-09 19:54:56 +08:00
|
|
|
|
#include "./screens/ui_SetPage.h"
|
2025-12-03 18:30:15 +08:00
|
|
|
|
#include "./screens/ui_PPSPage.h"
|
2025-11-26 19:16:32 +08:00
|
|
|
|
|
2025-08-05 16:06:46 +08:00
|
|
|
|
///////////////////// VARIABLES ////////////////////
|
|
|
|
|
|
|
2025-08-12 18:43:38 +08:00
|
|
|
|
// pages
|
2025-09-22 21:45:02 +08:00
|
|
|
|
Page_t pages[] = {
|
|
|
|
|
|
{
|
|
|
|
|
|
.init = ui_main_screen_init,
|
|
|
|
|
|
.deinit = ui_main_screen_destroy,
|
|
|
|
|
|
.page_obj = &ui_HomeScreen,
|
2025-09-27 10:51:54 +08:00
|
|
|
|
.key_event_handler = ui_main_page_key_handler,
|
2025-09-22 21:45:02 +08:00
|
|
|
|
.name = "Main Page"
|
|
|
|
|
|
},
|
2025-11-25 19:53:37 +08:00
|
|
|
|
// {
|
|
|
|
|
|
// .init = ui_ChartPage_screen_init,
|
|
|
|
|
|
// .deinit = ui_ChartPage_screen_destroy,
|
|
|
|
|
|
// .page_obj = &ui_ChartPage,
|
|
|
|
|
|
// .key_event_handler = ui_chart_page_key_handler,
|
|
|
|
|
|
// .name = "Chart Page"
|
|
|
|
|
|
// },
|
2025-10-07 10:29:31 +08:00
|
|
|
|
{
|
2025-10-09 19:54:56 +08:00
|
|
|
|
.init = ui_SetPage_screen_init,
|
|
|
|
|
|
.deinit = ui_SetPage_screen_destroy,
|
|
|
|
|
|
.page_obj = &ui_SetPage,
|
|
|
|
|
|
.key_event_handler = ui_set_page_key_handler,
|
|
|
|
|
|
.name = "Set Page"
|
2025-10-07 10:29:31 +08:00
|
|
|
|
},
|
2025-12-03 18:30:15 +08:00
|
|
|
|
{
|
|
|
|
|
|
.init = ui_PPSPage_screen_init,
|
|
|
|
|
|
.deinit = ui_PPSPage_screen_destroy,
|
|
|
|
|
|
.page_obj = &ui_PPSPage,
|
|
|
|
|
|
.key_event_handler = ui_pps_page_key_handler,
|
|
|
|
|
|
.name = "PPS Page"
|
|
|
|
|
|
},
|
2025-09-22 21:45:02 +08:00
|
|
|
|
// 可以在这里添加更多页面
|
|
|
|
|
|
};
|
2025-08-05 16:06:46 +08:00
|
|
|
|
|
|
|
|
|
|
///////////////////// TEST LVGL SETTINGS ////////////////////
|
|
|
|
|
|
#if LV_COLOR_DEPTH != 16
|
|
|
|
|
|
#error "LV_COLOR_DEPTH should be 16bit to match SquareLine Studio's settings"
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////// Timer //////////////////////
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Main timer for Refreshing the screens
|
|
|
|
|
|
*/
|
2025-11-27 10:02:13 +08:00
|
|
|
|
static void main_timer_cb(lv_timer_t * timer)
|
2025-08-05 16:06:46 +08:00
|
|
|
|
{
|
2025-12-06 16:35:02 +08:00
|
|
|
|
// 1s 刷新一次全屏,防止有时候不知什么原因的LCD刷新错误(需要后续找到问题从根本解决)
|
2025-12-06 17:17:34 +08:00
|
|
|
|
ui_full_screen_refresh(lv_screen_active());
|
2025-11-27 10:02:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////// Animation //////////////////////
|
2025-11-26 19:16:32 +08:00
|
|
|
|
|
2025-11-27 10:02:13 +08:00
|
|
|
|
void ui_start_animation_done() {
|
|
|
|
|
|
// 初始化页面并加载主要界面
|
|
|
|
|
|
lv_lib_pm_Init();
|
|
|
|
|
|
for (uint8_t i = 0; i < sizeof(pages) / sizeof(pages[0]); i++) {
|
|
|
|
|
|
lv_lib_pm_register(&pages[i]);
|
2025-11-26 19:16:32 +08:00
|
|
|
|
}
|
2025-11-27 10:02:13 +08:00
|
|
|
|
lv_lib_pm_load_init_screen();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ui_anima_set_light_level(void * var, int32_t v) {
|
|
|
|
|
|
ui_set_back_light_level(v);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void _ui_Start_animation(void) {
|
|
|
|
|
|
uint8_t target_level = ui_get_back_light_level();
|
|
|
|
|
|
lv_lib_anim_user_animation(NULL, 0, 2000, 0, target_level, 0, 0, 0, 0, lv_anim_path_ease_in, ui_anima_set_light_level, ui_start_animation_done);
|
2025-08-05 16:06:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////// ui_initialize //////////////////////
|
|
|
|
|
|
void ui_init(void)
|
|
|
|
|
|
{
|
|
|
|
|
|
lv_disp_t * dispp = lv_display_get_default();
|
2025-12-01 18:44:12 +08:00
|
|
|
|
lv_theme_t * theme = lv_theme_default_init(dispp, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED), true, LV_FONT_DEFAULT);
|
2025-08-05 16:06:46 +08:00
|
|
|
|
lv_disp_set_theme(dispp, theme);
|
2025-08-12 18:43:38 +08:00
|
|
|
|
|
2025-11-26 19:16:32 +08:00
|
|
|
|
// set system settings
|
|
|
|
|
|
ui_set_display_rotation(ui_get_display_rotation());
|
|
|
|
|
|
|
2025-11-27 10:02:13 +08:00
|
|
|
|
// main timer (you can add someting to do in the timer_cb if needed)
|
2025-12-06 17:17:34 +08:00
|
|
|
|
lv_timer_t * ui_MainTimer = lv_timer_create(main_timer_cb, 2000, NULL);
|
2025-11-26 19:16:32 +08:00
|
|
|
|
|
|
|
|
|
|
// start up, just load one time only
|
|
|
|
|
|
ui_StartPage_screen_init();
|
2025-12-03 18:30:15 +08:00
|
|
|
|
lv_screen_load(ui_StartPage);
|
2025-11-27 10:02:13 +08:00
|
|
|
|
_ui_Start_animation();
|
2025-08-05 16:06:46 +08:00
|
|
|
|
}
|