mirror of
https://github.com/No-Chicken/Power-Pico.git
synced 2026-04-03 13:02:36 +08:00
添加set page
This commit is contained in:
@@ -485,7 +485,7 @@
|
|||||||
#define LV_FONT_MONTSERRAT_10 0
|
#define LV_FONT_MONTSERRAT_10 0
|
||||||
#define LV_FONT_MONTSERRAT_12 0
|
#define LV_FONT_MONTSERRAT_12 0
|
||||||
#define LV_FONT_MONTSERRAT_14 1
|
#define LV_FONT_MONTSERRAT_14 1
|
||||||
#define LV_FONT_MONTSERRAT_16 0
|
#define LV_FONT_MONTSERRAT_16 1
|
||||||
#define LV_FONT_MONTSERRAT_18 1
|
#define LV_FONT_MONTSERRAT_18 1
|
||||||
#define LV_FONT_MONTSERRAT_20 0
|
#define LV_FONT_MONTSERRAT_20 0
|
||||||
#define LV_FONT_MONTSERRAT_22 0
|
#define LV_FONT_MONTSERRAT_22 0
|
||||||
|
|||||||
@@ -79,10 +79,10 @@ void lv_port_disp_init(void)
|
|||||||
* Two buffers for partial rendering
|
* Two buffers for partial rendering
|
||||||
* In flush_cb DMA or similar hardware should be used to update the display in the background.*/
|
* In flush_cb DMA or similar hardware should be used to update the display in the background.*/
|
||||||
LV_ATTRIBUTE_MEM_ALIGN
|
LV_ATTRIBUTE_MEM_ALIGN
|
||||||
static uint8_t buf_2_1[MY_DISP_HOR_RES * MY_DISP_VER_RES / 10 * BYTE_PER_PIXEL];
|
static uint8_t buf_2_1[MY_DISP_HOR_RES * MY_DISP_VER_RES / 8 * BYTE_PER_PIXEL];
|
||||||
|
|
||||||
LV_ATTRIBUTE_MEM_ALIGN
|
LV_ATTRIBUTE_MEM_ALIGN
|
||||||
static uint8_t buf_2_2[MY_DISP_HOR_RES * MY_DISP_VER_RES / 10 * BYTE_PER_PIXEL];
|
static uint8_t buf_2_2[MY_DISP_HOR_RES * MY_DISP_VER_RES / 8 * BYTE_PER_PIXEL];
|
||||||
lv_display_set_buffers(disp, buf_2_1, buf_2_2, sizeof(buf_2_1), LV_DISPLAY_RENDER_MODE_PARTIAL);
|
lv_display_set_buffers(disp, buf_2_1, buf_2_2, sizeof(buf_2_1), LV_DISPLAY_RENDER_MODE_PARTIAL);
|
||||||
|
|
||||||
#elif BUFFER_METHOD == 3
|
#elif BUFFER_METHOD == 3
|
||||||
@@ -134,6 +134,11 @@ void disp_disable_update(void)
|
|||||||
*'lv_display_flush_ready()' has to be called when it's finished.*/
|
*'lv_display_flush_ready()' has to be called when it's finished.*/
|
||||||
static void disp_flush(lv_display_t * disp_drv, const lv_area_t * area, uint8_t * px_map)
|
static void disp_flush(lv_display_t * disp_drv, const lv_area_t * area, uint8_t * px_map)
|
||||||
{
|
{
|
||||||
|
lv_display_rotation_t rotation = lv_display_get_rotation(disp_drv);
|
||||||
|
lv_area_t rotated_area;
|
||||||
|
if(rotation != LV_DISPLAY_ROTATION_0) {
|
||||||
|
LCD_SetRotation(rotation * 90);
|
||||||
|
}
|
||||||
if(disp_flush_enabled) {
|
if(disp_flush_enabled) {
|
||||||
LCD_Color_Render(area->x1,area->y1,area->x2,area->y2, (uint16_t *)px_map);
|
LCD_Color_Render(area->x1,area->y1,area->x2,area->y2, (uint16_t *)px_map);
|
||||||
}
|
}
|
||||||
|
|||||||
135
Power_Pico/User/GUI/screens/ui_SetPage.c
Normal file
135
Power_Pico/User/GUI/screens/ui_SetPage.c
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
// 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_SetPage = NULL;
|
||||||
|
static lv_obj_t * ui_PanelBL = NULL;
|
||||||
|
static lv_obj_t * ui_SliderBL = NULL;
|
||||||
|
static lv_obj_t * ui_LabelBL = NULL;
|
||||||
|
static lv_obj_t * ui_PanelKS = NULL;
|
||||||
|
static lv_obj_t * ui_SwitchKS = NULL;
|
||||||
|
static lv_obj_t * ui_LabelKS = NULL;
|
||||||
|
static lv_obj_t * ui_PanelLang = NULL;
|
||||||
|
static lv_obj_t * ui_SwitchLang = NULL;
|
||||||
|
static lv_obj_t * ui_LabelLang = NULL;
|
||||||
|
static lv_obj_t * ui_PanelAbout = NULL;
|
||||||
|
static lv_obj_t * ui_LabelAbout = NULL;
|
||||||
|
|
||||||
|
// event funtions
|
||||||
|
|
||||||
|
#include "key.h"
|
||||||
|
void ui_set_page_key_handler(uint8_t key_id)
|
||||||
|
{
|
||||||
|
if(key_id == KEYB_NUM) {
|
||||||
|
PageManager_next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// build funtions
|
||||||
|
|
||||||
|
void ui_SetPage_screen_init(void)
|
||||||
|
{
|
||||||
|
ui_SetPage = lv_obj_create(NULL);
|
||||||
|
|
||||||
|
ui_PanelBL = lv_obj_create(ui_SetPage);
|
||||||
|
lv_obj_set_width(ui_PanelBL, 234);
|
||||||
|
lv_obj_set_height(ui_PanelBL, 65);
|
||||||
|
lv_obj_set_x(ui_PanelBL, 0);
|
||||||
|
lv_obj_set_y(ui_PanelBL, 5);
|
||||||
|
lv_obj_set_align(ui_PanelBL, LV_ALIGN_TOP_MID);
|
||||||
|
lv_obj_add_flag(ui_PanelBL, LV_OBJ_FLAG_CHECKABLE); /// Flags
|
||||||
|
lv_obj_remove_flag(ui_PanelBL, LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
||||||
|
lv_obj_set_style_bg_color(ui_PanelBL, lv_color_hex(0x606060), LV_PART_MAIN | LV_STATE_CHECKED);
|
||||||
|
lv_obj_set_style_bg_opa(ui_PanelBL, 255, LV_PART_MAIN | LV_STATE_CHECKED);
|
||||||
|
|
||||||
|
ui_SliderBL = lv_slider_create(ui_PanelBL);
|
||||||
|
lv_slider_set_value(ui_SliderBL, 50, LV_ANIM_OFF);
|
||||||
|
if(lv_slider_get_mode(ui_SliderBL) == LV_SLIDER_MODE_RANGE) lv_slider_set_left_value(ui_SliderBL, 0, LV_ANIM_OFF);
|
||||||
|
lv_obj_set_width(ui_SliderBL, 200);
|
||||||
|
lv_obj_set_height(ui_SliderBL, 10);
|
||||||
|
lv_obj_set_align(ui_SliderBL, LV_ALIGN_BOTTOM_MID);
|
||||||
|
|
||||||
|
//Compensating for LVGL9.1 draw crash with bar/slider max value when top-padding is nonzero and right-padding is 0
|
||||||
|
if(lv_obj_get_style_pad_top(ui_SliderBL, LV_PART_MAIN) > 0) lv_obj_set_style_pad_right(ui_SliderBL,
|
||||||
|
lv_obj_get_style_pad_right(ui_SliderBL, LV_PART_MAIN) + 1, LV_PART_MAIN);
|
||||||
|
ui_LabelBL = lv_label_create(ui_PanelBL);
|
||||||
|
lv_obj_set_width(ui_LabelBL, LV_SIZE_CONTENT); /// 1
|
||||||
|
lv_obj_set_height(ui_LabelBL, LV_SIZE_CONTENT); /// 1
|
||||||
|
lv_obj_set_x(ui_LabelBL, 0);
|
||||||
|
lv_obj_set_y(ui_LabelBL, -5);
|
||||||
|
lv_label_set_text(ui_LabelBL, "Screen Brightness :");
|
||||||
|
lv_obj_set_style_text_font(ui_LabelBL, &lv_font_montserrat_16, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||||
|
|
||||||
|
ui_PanelKS = lv_obj_create(ui_SetPage);
|
||||||
|
lv_obj_set_width(ui_PanelKS, 234);
|
||||||
|
lv_obj_set_height(ui_PanelKS, 45);
|
||||||
|
lv_obj_set_x(ui_PanelKS, 0);
|
||||||
|
lv_obj_set_y(ui_PanelKS, 75);
|
||||||
|
lv_obj_set_align(ui_PanelKS, LV_ALIGN_TOP_MID);
|
||||||
|
lv_obj_add_flag(ui_PanelKS, LV_OBJ_FLAG_CHECKABLE); /// Flags
|
||||||
|
lv_obj_remove_flag(ui_PanelKS, LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
||||||
|
lv_obj_set_style_bg_color(ui_PanelKS, lv_color_hex(0x606060), LV_PART_MAIN | LV_STATE_CHECKED);
|
||||||
|
lv_obj_set_style_bg_opa(ui_PanelKS, 255, LV_PART_MAIN | LV_STATE_CHECKED);
|
||||||
|
|
||||||
|
ui_SwitchKS = lv_switch_create(ui_PanelKS);
|
||||||
|
lv_obj_set_width(ui_SwitchKS, 50);
|
||||||
|
lv_obj_set_height(ui_SwitchKS, 25);
|
||||||
|
lv_obj_set_align(ui_SwitchKS, LV_ALIGN_RIGHT_MID);
|
||||||
|
lv_obj_add_state(ui_SwitchKS, LV_STATE_CHECKED); /// States
|
||||||
|
|
||||||
|
ui_LabelKS = lv_label_create(ui_PanelKS);
|
||||||
|
lv_obj_set_width(ui_LabelKS, LV_SIZE_CONTENT); /// 1
|
||||||
|
lv_obj_set_height(ui_LabelKS, LV_SIZE_CONTENT); /// 1
|
||||||
|
lv_obj_set_align(ui_LabelKS, LV_ALIGN_LEFT_MID);
|
||||||
|
lv_label_set_text(ui_LabelKS, "Enable key sound");
|
||||||
|
lv_obj_set_style_text_font(ui_LabelKS, &lv_font_montserrat_16, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||||
|
|
||||||
|
ui_PanelLang = lv_obj_create(ui_SetPage);
|
||||||
|
lv_obj_set_width(ui_PanelLang, 234);
|
||||||
|
lv_obj_set_height(ui_PanelLang, 45);
|
||||||
|
lv_obj_set_x(ui_PanelLang, 0);
|
||||||
|
lv_obj_set_y(ui_PanelLang, 125);
|
||||||
|
lv_obj_set_align(ui_PanelLang, LV_ALIGN_TOP_MID);
|
||||||
|
lv_obj_add_flag(ui_PanelLang, LV_OBJ_FLAG_CHECKABLE); /// Flags
|
||||||
|
lv_obj_remove_flag(ui_PanelLang, LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
||||||
|
lv_obj_set_style_bg_color(ui_PanelLang, lv_color_hex(0x606060), LV_PART_MAIN | LV_STATE_CHECKED);
|
||||||
|
lv_obj_set_style_bg_opa(ui_PanelLang, 255, LV_PART_MAIN | LV_STATE_CHECKED);
|
||||||
|
|
||||||
|
ui_SwitchLang = lv_switch_create(ui_PanelLang);
|
||||||
|
lv_obj_set_width(ui_SwitchLang, 50);
|
||||||
|
lv_obj_set_height(ui_SwitchLang, 25);
|
||||||
|
lv_obj_set_align(ui_SwitchLang, LV_ALIGN_RIGHT_MID);
|
||||||
|
|
||||||
|
ui_LabelLang = lv_label_create(ui_PanelLang);
|
||||||
|
lv_obj_set_width(ui_LabelLang, LV_SIZE_CONTENT); /// 1
|
||||||
|
lv_obj_set_height(ui_LabelLang, LV_SIZE_CONTENT); /// 1
|
||||||
|
lv_obj_set_align(ui_LabelLang, LV_ALIGN_LEFT_MID);
|
||||||
|
lv_label_set_text(ui_LabelLang, "Enable Chinese");
|
||||||
|
lv_obj_set_style_text_font(ui_LabelLang, &lv_font_montserrat_16, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||||
|
|
||||||
|
ui_PanelAbout = lv_obj_create(ui_SetPage);
|
||||||
|
lv_obj_set_width(ui_PanelAbout, 234);
|
||||||
|
lv_obj_set_height(ui_PanelAbout, 100);
|
||||||
|
lv_obj_set_x(ui_PanelAbout, 0);
|
||||||
|
lv_obj_set_y(ui_PanelAbout, 175);
|
||||||
|
lv_obj_set_align(ui_PanelAbout, LV_ALIGN_TOP_MID);
|
||||||
|
lv_obj_add_flag(ui_PanelAbout, LV_OBJ_FLAG_CHECKABLE); /// Flags
|
||||||
|
lv_obj_remove_flag(ui_PanelAbout, LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
||||||
|
lv_obj_set_style_bg_color(ui_PanelAbout, lv_color_hex(0x606060), LV_PART_MAIN | LV_STATE_CHECKED);
|
||||||
|
lv_obj_set_style_bg_opa(ui_PanelAbout, 255, LV_PART_MAIN | LV_STATE_CHECKED);
|
||||||
|
|
||||||
|
ui_LabelAbout = lv_label_create(ui_PanelAbout);
|
||||||
|
lv_obj_set_width(ui_LabelAbout, LV_SIZE_CONTENT); /// 1
|
||||||
|
lv_obj_set_height(ui_LabelAbout, LV_SIZE_CONTENT); /// 1
|
||||||
|
lv_label_set_text(ui_LabelAbout, "About\nPower-Pico\nA uA current meter\nV 1.0.0");
|
||||||
|
lv_obj_set_style_text_font(ui_LabelAbout, &lv_font_montserrat_16, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ui_SetPage_screen_destroy(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
26
Power_Pico/User/GUI/screens/ui_SetPage.h
Normal file
26
Power_Pico/User/GUI/screens/ui_SetPage.h
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
// 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_SETPAGE_H
|
||||||
|
#define UI_SETPAGE_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// SCREEN: ui_SetPage
|
||||||
|
extern void ui_SetPage_screen_init(void);
|
||||||
|
extern void ui_SetPage_screen_destroy(void);
|
||||||
|
extern lv_obj_t * ui_SetPage;
|
||||||
|
void ui_set_page_key_handler(uint8_t key_id);
|
||||||
|
|
||||||
|
// CUSTOM VARIABLES
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /*extern "C"*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -36,8 +36,10 @@ static void full_screen_refresh(void) {
|
|||||||
static void set_val_cur_label(float voltage, float current)
|
static void set_val_cur_label(float voltage, float current)
|
||||||
{
|
{
|
||||||
char buf[16];
|
char buf[16];
|
||||||
|
// voltage
|
||||||
sprintf(buf, "%.2f", voltage);
|
sprintf(buf, "%.2f", voltage);
|
||||||
lv_label_set_text(ui_LabelValt, buf);
|
lv_label_set_text(ui_LabelValt, buf);
|
||||||
|
// current
|
||||||
if(current >= 1000000.0) {
|
if(current >= 1000000.0) {
|
||||||
current = current / 1000000.0;
|
current = current / 1000000.0;
|
||||||
sprintf(buf, "%.2f", current);
|
sprintf(buf, "%.2f", current);
|
||||||
@@ -106,7 +108,7 @@ static void set_val_cur_label(float voltage, float current)
|
|||||||
static void _flush_timer_cb()
|
static void _flush_timer_cb()
|
||||||
{
|
{
|
||||||
timecount++;
|
timecount++;
|
||||||
if(timecount >= 4) { // 2s
|
if(timecount >= 2) { // 1s
|
||||||
timecount = 0;
|
timecount = 0;
|
||||||
full_screen_refresh();
|
full_screen_refresh();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "./ui.h"
|
#include "./ui.h"
|
||||||
#include "./screens/ui_mainPage.h"
|
#include "./screens/ui_mainPage.h"
|
||||||
#include "./screens/ui_chartPage.h"
|
#include "./screens/ui_chartPage.h"
|
||||||
|
#include "./screens/ui_SetPage.h"
|
||||||
|
|
||||||
///////////////////// VARIABLES ////////////////////
|
///////////////////// VARIABLES ////////////////////
|
||||||
|
|
||||||
@@ -16,12 +17,19 @@ Page_t pages[] = {
|
|||||||
.key_event_handler = ui_main_page_key_handler,
|
.key_event_handler = ui_main_page_key_handler,
|
||||||
.name = "Main Page"
|
.name = "Main Page"
|
||||||
},
|
},
|
||||||
|
// {
|
||||||
|
// .init = ui_main_screen_init,
|
||||||
|
// .deinit = ui_main_screen_destroy,
|
||||||
|
// .page_obj = &ui_HomeScreen,
|
||||||
|
// .key_event_handler = ui_main_page_key_handler,
|
||||||
|
// .name = "Chart Page"
|
||||||
|
// },
|
||||||
{
|
{
|
||||||
.init = ui_ChartPage_screen_init,
|
.init = ui_SetPage_screen_init,
|
||||||
.deinit = ui_ChartPage_screen_destroy,
|
.deinit = ui_SetPage_screen_destroy,
|
||||||
.page_obj = &ui_ChartPage,
|
.page_obj = &ui_SetPage,
|
||||||
.key_event_handler = ui_chart_page_key_handler,
|
.key_event_handler = ui_set_page_key_handler,
|
||||||
.name = "Chart Page"
|
.name = "Set Page"
|
||||||
},
|
},
|
||||||
// 可以在这里添加更多页面
|
// 可以在这里添加更多页面
|
||||||
};
|
};
|
||||||
@@ -53,6 +61,7 @@ void ui_init(void)
|
|||||||
PageManager_register(&pages[i]);
|
PageManager_register(&pages[i]);
|
||||||
}
|
}
|
||||||
PageManager_load_init_screen();
|
PageManager_load_init_screen();
|
||||||
|
lv_display_set_rotation(dispp, LV_DISP_ROTATION_180);
|
||||||
|
|
||||||
//timer
|
//timer
|
||||||
// lv_timer_t * ui_MainTimer = lv_timer_create(main_timer, 1000, NULL);
|
// lv_timer_t * ui_MainTimer = lv_timer_create(main_timer, 1000, NULL);
|
||||||
|
|||||||
Reference in New Issue
Block a user