This commit is contained in:
不吃油炸鸡
2025-11-26 19:16:32 +08:00
parent 488a497ba6
commit 0fa51a923b
15 changed files with 831 additions and 39 deletions

View File

@@ -56,7 +56,6 @@ static uint8_t data_index = 0;
// 定时器回调函数:更新图表数据
static void _chart_update_cb(lv_timer_t * timer) {
}
#include "key.h"

View File

@@ -4,7 +4,6 @@
// Project name: PowerPico
#include "../ui.h"
#include "BL24C02.h" // system settings
lv_obj_t * ui_SetPage = NULL;
// backlight
@@ -57,23 +56,23 @@ void ui_set_page_key_handler(uint8_t key_id)
slider_value += 10;
if(slider_value > 100) slider_value = 100;
lv_slider_set_value(ui_SliderBL, slider_value, LV_ANIM_ON);
Sys_Set_BacklightLevel(slider_value);
ui_set_back_light_level(slider_value);
} else if (key_id == KEYN_NUM) {
int16_t slider_value = lv_slider_get_value(ui_SliderBL);
slider_value -= 10;
if(slider_value < 10) slider_value = 10;
lv_slider_set_value(ui_SliderBL, slider_value, LV_ANIM_ON);
Sys_Set_BacklightLevel(slider_value);
ui_set_back_light_level(slider_value);
}
break;
// key sound
case 1:
if (key_id == KEYY_NUM) {
lv_obj_add_state(ui_SwitchKS, LV_STATE_CHECKED);
Sys_Set_KeySoundEnable(1);
ui_set_key_sound_enable(1);
} else if(key_id == KEYN_NUM) {
lv_obj_clear_state(ui_SwitchKS, LV_STATE_CHECKED);
Sys_Set_KeySoundEnable(0);
ui_set_key_sound_enable(0);
}
break;
@@ -84,7 +83,7 @@ void ui_set_page_key_handler(uint8_t key_id)
// chose rotation
case 3:
uint16_t rotation = Sys_Get_Rotation();
uint16_t rotation = ui_get_display_rotation();
if (key_id == KEYY_NUM) {
rotation = (rotation + 360 + 90) % 360;
} else if(key_id == KEYN_NUM) {
@@ -99,7 +98,7 @@ void ui_set_page_key_handler(uint8_t key_id)
} else if (rotation == 270) {
lv_label_set_text(ui_LabelRotNum, "< 270 >");
}
Sys_Set_Rotation(rotation);
ui_set_display_rotation(rotation);
ui_full_screen_refresh(ui_SetPage);
break;
@@ -110,23 +109,23 @@ void ui_set_page_key_handler(uint8_t key_id)
}
// save settings to eeprom
EEPROM_SysSetting_Save();
ui_system_settings_save();
}
}
static void _setting_init(void) {
// backlight
lv_slider_set_value(ui_SliderBL, Sys_Get_BacklightLevel(), LV_ANIM_OFF);
lv_slider_set_value(ui_SliderBL, ui_get_back_light_level(), LV_ANIM_OFF);
// key sound
if(Sys_Get_KeySoundEnable())
if(ui_get_key_sound_enable())
lv_obj_add_state(ui_SwitchKS, LV_STATE_CHECKED);
else
lv_obj_clear_state(ui_SwitchKS, LV_STATE_CHECKED);
// lcd rotation
uint16_t rotation = Sys_Get_Rotation();
uint16_t rotation = ui_get_display_rotation();
if (rotation == 0) {
lv_label_set_text(ui_LabelRotNum, "< 0 >");
} else if (rotation == 90) {

View File

@@ -0,0 +1,66 @@
// This file was generated by SquareLine Studio
// SquareLine Studio version: SquareLine Studio 1.5.3
// LVGL version: 9.2.2
// Project name: PowerPico
#include "../ui.h"
lv_obj_t * ui_StartPage = NULL;
static lv_obj_t * ui_Panel1 = NULL;
static lv_obj_t * ui_Image2 = NULL;
static lv_obj_t * ui_Label1 = NULL;
// event funtions
// build funtions
void ui_StartPage_screen_init(void)
{
ui_StartPage = lv_obj_create(NULL);
lv_obj_remove_flag(ui_StartPage, LV_OBJ_FLAG_SCROLLABLE); /// Flags
ui_Panel1 = lv_obj_create(ui_StartPage);
lv_obj_set_width(ui_Panel1, 120);
lv_obj_set_height(ui_Panel1, 120);
lv_obj_set_x(ui_Panel1, 0);
lv_obj_set_y(ui_Panel1, -35);
lv_obj_set_align(ui_Panel1, LV_ALIGN_CENTER);
lv_obj_remove_flag(ui_Panel1, LV_OBJ_FLAG_SCROLLABLE); /// Flags
lv_obj_set_style_radius(ui_Panel1, 128, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui_Panel1, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui_Panel1, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_color(ui_Panel1, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_opa(ui_Panel1, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
ui_Image2 = lv_image_create(ui_Panel1);
lv_image_set_src(ui_Image2, &ui_img_chicken_png);
lv_obj_set_width(ui_Image2, LV_SIZE_CONTENT); /// 128
lv_obj_set_height(ui_Image2, LV_SIZE_CONTENT); /// 128
lv_obj_set_x(ui_Image2, -4);
lv_obj_set_y(ui_Image2, -2);
lv_obj_set_align(ui_Image2, LV_ALIGN_CENTER);
lv_obj_add_flag(ui_Image2, LV_OBJ_FLAG_CLICKABLE); /// Flags
lv_obj_remove_flag(ui_Image2, LV_OBJ_FLAG_SCROLLABLE); /// Flags
lv_image_set_scale(ui_Image2, 196);
ui_Label1 = lv_label_create(ui_StartPage);
lv_obj_set_width(ui_Label1, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_Label1, LV_SIZE_CONTENT); /// 1
lv_obj_set_x(ui_Label1, 0);
lv_obj_set_y(ui_Label1, 60);
lv_obj_set_align(ui_Label1, LV_ALIGN_CENTER);
lv_label_set_text(ui_Label1, "Power-Pico");
lv_obj_set_style_text_font(ui_Label1, &lv_font_montserrat_28, LV_PART_MAIN | LV_STATE_DEFAULT);
}
void ui_StartPage_screen_destroy(void)
{
if(ui_StartPage) lv_obj_del(ui_StartPage);
// NULL screen variables
ui_StartPage = NULL;
ui_Panel1 = NULL;
ui_Image2 = NULL;
ui_Label1 = NULL;
}

View File

@@ -0,0 +1,25 @@
// This file was generated by SquareLine Studio
// SquareLine Studio version: SquareLine Studio 1.5.3
// LVGL version: 9.2.2
// Project name: PowerPico
#ifndef UI_STARTPAGE_H
#define UI_STARTPAGE_H
#ifdef __cplusplus
extern "C" {
#endif
// SCREEN: ui_StartPage
extern void ui_StartPage_screen_init(void);
extern void ui_StartPage_screen_destroy(void);
extern lv_obj_t * ui_StartPage;
// CUSTOM VARIABLES
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif

View File

@@ -7,8 +7,6 @@
#include "ui_mainPage.h"
#include "data_queue.h"
#include "math.h"
#include "BL24C02.h" // system settings
#include "rtc.h" // elapsed time
lv_obj_t * ui_HomeScreen = NULL;
static lv_obj_t * ui_ButVal = NULL;
@@ -36,21 +34,21 @@ void ui_main_page_key_handler(uint8_t key_id)
} else if (key_id == KEYL_NUM) {
// rotation - 90 degrees
// rotation LV_DISPLAY_ROTATION_0/90/180/270
uint16_t rotation = Sys_Get_Rotation();
uint16_t rotation = ui_get_display_rotation();
rotation = (rotation + 360 - 90) % 360;
// set rotation value
Sys_Set_Rotation(rotation);
ui_set_display_rotation(rotation);
// save settings to eeprom
EEPROM_SysSetting_Save();
ui_system_settings_save();
ui_full_screen_refresh(ui_HomeScreen);
} else if (key_id == KEYR_NUM) {
// rotation + 90 degrees
uint16_t rotation = Sys_Get_Rotation();
uint16_t rotation = ui_get_display_rotation();
rotation = (rotation + 360 + 90) % 360;
// set rotation value
Sys_Set_Rotation(rotation);
ui_set_display_rotation(rotation);
// save settings to eeprom
EEPROM_SysSetting_Save();
ui_system_settings_save();
ui_full_screen_refresh(ui_HomeScreen);
}
}
@@ -119,7 +117,7 @@ static void set_val_cur_label(float voltage, float current)
// time
uint8_t hours = 0, minutes = 0, seconds = 0;
GetElapsedTime_HMS(&hours, &minutes, &seconds);
ui_GetElapsedTime_HMS(&hours, &minutes, &seconds);
snprintf(buf, sizeof(buf), "%02d:%02d:%02d", hours, minutes, seconds);
lv_label_set_text(ui_LabelTime, buf);
}