mirror of
https://github.com/No-Chicken/Power-Pico.git
synced 2026-04-03 13:02:36 +08:00
update
This commit is contained in:
@@ -2,11 +2,53 @@
|
||||
// Project name: PowerPico
|
||||
|
||||
#include "BL24C02.h" // system settings
|
||||
#include "rtc.h" // elapsed time
|
||||
#include "./ui.h"
|
||||
#include "./screens/ui_StartPage.h"
|
||||
#include "./screens/ui_mainPage.h"
|
||||
#include "./screens/ui_chartPage.h"
|
||||
#include "./screens/ui_SetPage.h"
|
||||
|
||||
|
||||
//////////// interface for system hw settings ///////////
|
||||
|
||||
// get functions
|
||||
|
||||
void ui_GetElapsedTime_HMS(uint8_t *hours, uint8_t *minutes, uint8_t *seconds) {
|
||||
GetElapsedTime_HMS(hours, minutes, seconds);
|
||||
}
|
||||
|
||||
uint8_t ui_get_back_light_level(void) {
|
||||
return Sys_Get_BacklightLevel();
|
||||
}
|
||||
|
||||
bool ui_get_key_sound_enable(void) {
|
||||
return Sys_Get_KeySoundEnable();
|
||||
}
|
||||
|
||||
uint16_t ui_get_display_rotation(void) {
|
||||
return Sys_Get_Rotation();
|
||||
}
|
||||
|
||||
// set functions
|
||||
|
||||
void ui_set_back_light_level(uint8_t level) {
|
||||
Sys_Set_BacklightLevel(level);
|
||||
}
|
||||
|
||||
void ui_set_key_sound_enable(bool enable) {
|
||||
Sys_Set_KeySoundEnable(enable);
|
||||
}
|
||||
|
||||
void ui_set_display_rotation(uint16_t rotation) {
|
||||
Sys_Set_Rotation(rotation);
|
||||
}
|
||||
|
||||
// sys save function
|
||||
void ui_system_settings_save(void) {
|
||||
EEPROM_SysSetting_Save();
|
||||
}
|
||||
|
||||
///////////////////// VARIABLES ////////////////////
|
||||
|
||||
// pages
|
||||
@@ -49,15 +91,39 @@ void ui_full_screen_refresh(lv_obj_t * screen) {
|
||||
lv_refr_now(NULL);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////// Timer //////////////////////
|
||||
|
||||
/**
|
||||
* Main timer for Refreshing the screens
|
||||
*/
|
||||
static void main_timer(lv_timer_t * timer)
|
||||
{
|
||||
// do nothing
|
||||
// LV_LOG_WARN("Main timer");
|
||||
static uint8_t first_time_in = 0;
|
||||
static uint8_t count = 0;
|
||||
static uint8_t backlight_level = 0; // 初始亮度为 0%
|
||||
static uint8_t target_backlight_level = 0; // 目标亮度
|
||||
|
||||
if (first_time_in == 0) {
|
||||
// 获取目标亮度
|
||||
target_backlight_level = ui_get_back_light_level();
|
||||
first_time_in = 1;
|
||||
}
|
||||
|
||||
// 调整背光亮度
|
||||
if (backlight_level < target_backlight_level) {
|
||||
backlight_level++;
|
||||
ui_set_back_light_level(backlight_level); // 设置当前亮度
|
||||
} else {
|
||||
// 初始化页面并加载主要界面
|
||||
PageManager_init();
|
||||
for (uint8_t i = 0; i < sizeof(pages) / sizeof(pages[0]); i++) {
|
||||
PageManager_register(&pages[i]);
|
||||
}
|
||||
PageManager_load_init_screen();
|
||||
|
||||
// 停止定时器,避免重复初始化
|
||||
lv_timer_del(timer);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////// ui_initialize //////////////////////
|
||||
@@ -67,13 +133,14 @@ void ui_init(void)
|
||||
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);
|
||||
lv_disp_set_theme(dispp, theme);
|
||||
PageManager_init();
|
||||
for(uint8_t i = 0; i < sizeof(pages)/sizeof(pages[0]); i++) {
|
||||
PageManager_register(&pages[i]);
|
||||
}
|
||||
PageManager_load_init_screen();
|
||||
lv_display_set_rotation(dispp, Sys_Get_Rotation() / 90);
|
||||
|
||||
//timer
|
||||
// lv_timer_t * ui_MainTimer = lv_timer_create(main_timer, 1000, NULL);
|
||||
// set system settings
|
||||
ui_set_display_rotation(ui_get_display_rotation());
|
||||
|
||||
// timer
|
||||
lv_timer_t * ui_MainTimer = lv_timer_create(main_timer, 50, NULL);
|
||||
|
||||
// start up, just load one time only
|
||||
ui_StartPage_screen_init();
|
||||
lv_scr_load(ui_StartPage);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user