Files
Power-Pico/Power_Pico/User/GUI/screens/ui_ChartPage.c
不吃油炸鸡 d3fb3bd7af 更新API
2025-12-03 18:31:07 +08:00

354 lines
16 KiB
C

// 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_ChartPage = NULL;
static lv_obj_t * ui_ContainChart = NULL;
static lv_obj_t * row_line1 = NULL;
static lv_obj_t * row_line2 = NULL;
static lv_obj_t * row_line3 = NULL;
static lv_obj_t * row_line4 = NULL;
static lv_obj_t * col_line1 = NULL;
static lv_obj_t * col_line2 = NULL;
static lv_obj_t * col_line3 = NULL;
static lv_obj_t * col_line4 = NULL;
static lv_obj_t * ui_AxisV5 = NULL;
static lv_obj_t * ui_AxisV4 = NULL;
static lv_obj_t * ui_AxisV3 = NULL;
static lv_obj_t * ui_AxisV2 = NULL;
static lv_obj_t * ui_AxisV1 = NULL;
static lv_obj_t * ui_AxisV = NULL;
static lv_obj_t * ui_AxisC = NULL;
static lv_obj_t * ui_AxisC1 = NULL;
static lv_obj_t * ui_AxisC2 = NULL;
static lv_obj_t * ui_AxisC3 = NULL;
static lv_obj_t * ui_AxisC4 = NULL;
static lv_obj_t * ui_AxisC5 = NULL;
static lv_obj_t * ui_PanelVol = NULL;
static lv_obj_t * ui_LabelVol = NULL;
static lv_obj_t * ui_LabelVolUnit = NULL;
static lv_obj_t * ui_PanelCur = NULL;
static lv_obj_t * ui_LabelCur1 = NULL;
static lv_obj_t * ui_LabelCurUnit = NULL;
static lv_obj_t * ui_ButState = NULL;
static lv_obj_t * ui_LabelState = NULL;
static lv_obj_t * ui_LineVol = NULL; // 电压波形
static lv_obj_t * ui_LineCur = NULL; // 电流波形
static lv_timer_t * chart_update_timer = NULL; // 定时器
static bool is_chart_running = true;
static lv_point_precise_t line_points[4][2] = {{{-170, 36}, {170, 36}}, {{-170, 72},{170, 72}}, {{-170,108},{170,108}}, {{-170, 144},{170, 144}}};
static lv_point_precise_t col_points[4][2] = {{{34, -180}, {34, 180}}, {{68, -180},{68, 180}}, {{102, -180},{102, 180}}, {{136, -180},{136, 180}}};
#define POINTS_NUM 32
// 模拟数据数组
// 数据数组
static lv_point_precise_t vol_points[POINTS_NUM]; // 电压波形点
static lv_point_precise_t cur_points[POINTS_NUM]; // 电流波形点
static uint8_t data_index = 0;
// event funtions
// 定时器回调函数:更新图表数据
static void _chart_update_cb(lv_timer_t * timer) {
}
#include "key.h"
void ui_chart_page_key_handler(void* key_event)
{
if ( ((key_event_t*)key_event)->id == KEY_ID_B && ((key_event_t*)key_event)->type == KEY_EVT_CLICK )
{
lv_lib_pm_next();
}
}
// build funtions
void ui_ChartPage_screen_init(void)
{
ui_ChartPage = lv_obj_create(NULL);
lv_obj_remove_flag(ui_ChartPage, LV_OBJ_FLAG_SCROLLABLE); /// Flags
ui_ContainChart = lv_obj_create(ui_ChartPage);
lv_obj_remove_style_all(ui_ContainChart);
lv_obj_set_width(ui_ContainChart, 170);
lv_obj_set_height(ui_ContainChart, 180);
lv_obj_set_x(ui_ContainChart, 0);
lv_obj_set_y(ui_ContainChart, -15);
lv_obj_set_align(ui_ContainChart, LV_ALIGN_CENTER);
lv_obj_remove_flag(ui_ContainChart, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_SCROLLABLE); /// Flags
lv_obj_set_style_bg_color(ui_ContainChart, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui_ContainChart, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_color(ui_ContainChart, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_opa(ui_ContainChart, 64, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_width(ui_ContainChart, 2, LV_PART_MAIN | LV_STATE_DEFAULT);
row_line1 = lv_line_create(ui_ContainChart);
lv_line_set_points(row_line1, line_points[0], 2);
lv_obj_set_style_line_color(row_line1, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_line_width(row_line1, 1, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_line_opa(row_line1, 64, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_align(row_line1, LV_ALIGN_TOP_MID);
row_line2 = lv_line_create(ui_ContainChart);
lv_line_set_points(row_line2, line_points[1], 2);
lv_obj_set_style_line_color(row_line2, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_line_width(row_line2, 1, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_line_opa(row_line2, 64, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_align(row_line2, LV_ALIGN_TOP_MID);
row_line3 = lv_line_create(ui_ContainChart);
lv_line_set_points(row_line3, line_points[2], 2);
lv_obj_set_style_line_color(row_line3, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_line_width(row_line3, 1, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_line_opa(row_line3, 64, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_align(row_line3, LV_ALIGN_TOP_MID);
row_line4 = lv_line_create(ui_ContainChart);
lv_line_set_points(row_line4, line_points[3], 2);
lv_obj_set_style_line_color(row_line4, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_line_width(row_line4, 1, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_line_opa(row_line4, 64, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_align(row_line4, LV_ALIGN_TOP_MID);
col_line1 = lv_line_create(ui_ContainChart);
lv_line_set_points(col_line1, col_points[0], 2);
lv_obj_set_style_line_color(col_line1, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_line_width(col_line1, 1, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_line_opa(col_line1, 64, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_align(col_line1, LV_ALIGN_LEFT_MID);
col_line2 = lv_line_create(ui_ContainChart);
lv_line_set_points(col_line2, col_points[1], 2);
lv_obj_set_style_line_color(col_line2, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_line_width(col_line2, 1, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_line_opa(col_line2, 64, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_align(col_line2, LV_ALIGN_LEFT_MID);
col_line3 = lv_line_create(ui_ContainChart);
lv_line_set_points(col_line3, col_points[2], 2);
lv_obj_set_style_line_color(col_line3, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_line_width(col_line3, 1, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_line_opa(col_line3, 64, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_align(col_line3, LV_ALIGN_LEFT_MID);
col_line4 = lv_line_create(ui_ContainChart);
lv_line_set_points(col_line4, col_points[3], 2);
lv_obj_set_style_line_color(col_line4, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_line_width(col_line4, 1, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_line_opa(col_line4, 64, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_align(col_line4, LV_ALIGN_LEFT_MID);
ui_AxisV5 = lv_label_create(ui_ChartPage);
lv_obj_set_width(ui_AxisV5, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_AxisV5, LV_SIZE_CONTENT); /// 1
lv_obj_set_x(ui_AxisV5, 100);
lv_obj_set_y(ui_AxisV5, -104);
lv_obj_set_align(ui_AxisV5, LV_ALIGN_CENTER);
lv_label_set_text(ui_AxisV5, "5.0");
lv_obj_set_style_text_color(ui_AxisV5, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui_AxisV5, 200, LV_PART_MAIN | LV_STATE_DEFAULT);
ui_AxisV4 = lv_label_create(ui_ChartPage);
lv_obj_set_width(ui_AxisV4, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_AxisV4, LV_SIZE_CONTENT); /// 1
lv_obj_set_x(ui_AxisV4, 100);
lv_obj_set_y(ui_AxisV4, -68);
lv_obj_set_align(ui_AxisV4, LV_ALIGN_CENTER);
lv_label_set_text(ui_AxisV4, "4.0");
lv_obj_set_style_text_color(ui_AxisV4, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui_AxisV4, 200, LV_PART_MAIN | LV_STATE_DEFAULT);
ui_AxisV3 = lv_label_create(ui_ChartPage);
lv_obj_set_width(ui_AxisV3, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_AxisV3, LV_SIZE_CONTENT); /// 1
lv_obj_set_x(ui_AxisV3, 100);
lv_obj_set_y(ui_AxisV3, -32);
lv_obj_set_align(ui_AxisV3, LV_ALIGN_CENTER);
lv_label_set_text(ui_AxisV3, "3.0");
lv_obj_set_style_text_color(ui_AxisV3, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui_AxisV3, 200, LV_PART_MAIN | LV_STATE_DEFAULT);
ui_AxisV2 = lv_label_create(ui_ChartPage);
lv_obj_set_width(ui_AxisV2, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_AxisV2, LV_SIZE_CONTENT); /// 1
lv_obj_set_x(ui_AxisV2, 100);
lv_obj_set_y(ui_AxisV2, 4);
lv_obj_set_align(ui_AxisV2, LV_ALIGN_CENTER);
lv_label_set_text(ui_AxisV2, "2.0");
lv_obj_set_style_text_color(ui_AxisV2, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui_AxisV2, 200, LV_PART_MAIN | LV_STATE_DEFAULT);
ui_AxisV1 = lv_label_create(ui_ChartPage);
lv_obj_set_width(ui_AxisV1, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_AxisV1, LV_SIZE_CONTENT); /// 1
lv_obj_set_x(ui_AxisV1, 100);
lv_obj_set_y(ui_AxisV1, 39);
lv_obj_set_align(ui_AxisV1, LV_ALIGN_CENTER);
lv_label_set_text(ui_AxisV1, "1.0");
lv_obj_set_style_text_color(ui_AxisV1, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui_AxisV1, 200, LV_PART_MAIN | LV_STATE_DEFAULT);
ui_AxisV = lv_label_create(ui_ChartPage);
lv_obj_set_width(ui_AxisV, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_AxisV, LV_SIZE_CONTENT); /// 1
lv_obj_set_x(ui_AxisV, 100);
lv_obj_set_y(ui_AxisV, 70);
lv_obj_set_align(ui_AxisV, LV_ALIGN_CENTER);
lv_label_set_text(ui_AxisV, "V");
lv_obj_set_style_text_color(ui_AxisV, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui_AxisV, 200, LV_PART_MAIN | LV_STATE_DEFAULT);
ui_AxisC = lv_label_create(ui_ChartPage);
lv_obj_set_width(ui_AxisC, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_AxisC, LV_SIZE_CONTENT); /// 1
lv_obj_set_x(ui_AxisC, -100);
lv_obj_set_y(ui_AxisC, 70);
lv_obj_set_align(ui_AxisC, LV_ALIGN_CENTER);
lv_label_set_text(ui_AxisC, "A");
lv_obj_set_style_text_color(ui_AxisC, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui_AxisC, 200, LV_PART_MAIN | LV_STATE_DEFAULT);
ui_AxisC1 = lv_label_create(ui_ChartPage);
lv_obj_set_width(ui_AxisC1, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_AxisC1, LV_SIZE_CONTENT); /// 1
lv_obj_set_x(ui_AxisC1, -100);
lv_obj_set_y(ui_AxisC1, 39);
lv_obj_set_align(ui_AxisC1, LV_ALIGN_CENTER);
lv_label_set_text(ui_AxisC1, "0.4");
lv_obj_set_style_text_color(ui_AxisC1, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui_AxisC1, 200, LV_PART_MAIN | LV_STATE_DEFAULT);
ui_AxisC2 = lv_label_create(ui_ChartPage);
lv_obj_set_width(ui_AxisC2, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_AxisC2, LV_SIZE_CONTENT); /// 1
lv_obj_set_x(ui_AxisC2, -100);
lv_obj_set_y(ui_AxisC2, 4);
lv_obj_set_align(ui_AxisC2, LV_ALIGN_CENTER);
lv_label_set_text(ui_AxisC2, "0.8");
lv_obj_set_style_text_color(ui_AxisC2, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui_AxisC2, 200, LV_PART_MAIN | LV_STATE_DEFAULT);
ui_AxisC3 = lv_label_create(ui_ChartPage);
lv_obj_set_width(ui_AxisC3, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_AxisC3, LV_SIZE_CONTENT); /// 1
lv_obj_set_x(ui_AxisC3, -100);
lv_obj_set_y(ui_AxisC3, -32);
lv_obj_set_align(ui_AxisC3, LV_ALIGN_CENTER);
lv_label_set_text(ui_AxisC3, "1.2");
lv_obj_set_style_text_color(ui_AxisC3, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui_AxisC3, 200, LV_PART_MAIN | LV_STATE_DEFAULT);
ui_AxisC4 = lv_label_create(ui_ChartPage);
lv_obj_set_width(ui_AxisC4, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_AxisC4, LV_SIZE_CONTENT); /// 1
lv_obj_set_x(ui_AxisC4, -100);
lv_obj_set_y(ui_AxisC4, -68);
lv_obj_set_align(ui_AxisC4, LV_ALIGN_CENTER);
lv_label_set_text(ui_AxisC4, "1.6");
lv_obj_set_style_text_color(ui_AxisC4, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui_AxisC4, 200, LV_PART_MAIN | LV_STATE_DEFAULT);
ui_AxisC5 = lv_label_create(ui_ChartPage);
lv_obj_set_width(ui_AxisC5, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_AxisC5, LV_SIZE_CONTENT); /// 1
lv_obj_set_x(ui_AxisC5, -100);
lv_obj_set_y(ui_AxisC5, -104);
lv_obj_set_align(ui_AxisC5, LV_ALIGN_CENTER);
lv_label_set_text(ui_AxisC5, "2.0");
lv_obj_set_style_text_color(ui_AxisC5, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui_AxisC5, 200, LV_PART_MAIN | LV_STATE_DEFAULT);
ui_PanelVol = lv_obj_create(ui_ChartPage);
lv_obj_set_width(ui_PanelVol, 80);
lv_obj_set_height(ui_PanelVol, 35);
lv_obj_set_x(ui_PanelVol, -30);
lv_obj_set_y(ui_PanelVol, -5);
lv_obj_set_align(ui_PanelVol, LV_ALIGN_BOTTOM_MID);
lv_obj_remove_flag(ui_PanelVol, LV_OBJ_FLAG_SCROLLABLE); /// Flags
lv_obj_set_style_bg_color(ui_PanelVol, lv_color_hex(0xE36666), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui_PanelVol, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
ui_LabelVol = lv_label_create(ui_PanelVol);
lv_obj_set_width(ui_LabelVol, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_LabelVol, LV_SIZE_CONTENT); /// 1
lv_obj_set_x(ui_LabelVol, -12);
lv_obj_set_y(ui_LabelVol, 0);
lv_obj_set_align(ui_LabelVol, LV_ALIGN_RIGHT_MID);
lv_label_set_text(ui_LabelVol, "5.42");
lv_obj_set_style_text_font(ui_LabelVol, &lv_font_montserrat_18, LV_PART_MAIN | LV_STATE_DEFAULT);
ui_LabelVolUnit = lv_label_create(ui_PanelVol);
lv_obj_set_width(ui_LabelVolUnit, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_LabelVolUnit, LV_SIZE_CONTENT); /// 1
lv_obj_set_x(ui_LabelVolUnit, 5);
lv_obj_set_y(ui_LabelVolUnit, 0);
lv_obj_set_align(ui_LabelVolUnit, LV_ALIGN_RIGHT_MID);
lv_label_set_text(ui_LabelVolUnit, "V");
lv_obj_set_style_text_font(ui_LabelVolUnit, &lv_font_montserrat_18, LV_PART_MAIN | LV_STATE_DEFAULT);
ui_PanelCur = lv_obj_create(ui_ChartPage);
lv_obj_set_width(ui_PanelCur, 100);
lv_obj_set_height(ui_PanelCur, 35);
lv_obj_set_x(ui_PanelCur, 60);
lv_obj_set_y(ui_PanelCur, -5);
lv_obj_set_align(ui_PanelCur, LV_ALIGN_BOTTOM_MID);
lv_obj_remove_flag(ui_PanelCur, LV_OBJ_FLAG_SCROLLABLE); /// Flags
lv_obj_set_style_bg_color(ui_PanelCur, lv_color_hex(0x42AA49), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui_PanelCur, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
ui_LabelCur1 = lv_label_create(ui_PanelCur);
lv_obj_set_width(ui_LabelCur1, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_LabelCur1, LV_SIZE_CONTENT); /// 1
lv_obj_set_x(ui_LabelCur1, -30);
lv_obj_set_y(ui_LabelCur1, 0);
lv_obj_set_align(ui_LabelCur1, LV_ALIGN_RIGHT_MID);
lv_label_set_text(ui_LabelCur1, "15.23");
lv_obj_set_style_text_font(ui_LabelCur1, &lv_font_montserrat_18, LV_PART_MAIN | LV_STATE_DEFAULT);
ui_LabelCurUnit = lv_label_create(ui_PanelCur);
lv_obj_set_width(ui_LabelCurUnit, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_LabelCurUnit, LV_SIZE_CONTENT); /// 1
lv_obj_set_x(ui_LabelCurUnit, 5);
lv_obj_set_y(ui_LabelCurUnit, 0);
lv_obj_set_align(ui_LabelCurUnit, LV_ALIGN_RIGHT_MID);
lv_label_set_text(ui_LabelCurUnit, "mA");
lv_obj_set_style_text_font(ui_LabelCurUnit, &lv_font_montserrat_18, LV_PART_MAIN | LV_STATE_DEFAULT);
ui_ButState = lv_button_create(ui_ChartPage);
lv_obj_set_width(ui_ButState, 35);
lv_obj_set_height(ui_ButState, 32);
lv_obj_set_x(ui_ButState, -90);
lv_obj_set_y(ui_ButState, -7);
lv_obj_set_align(ui_ButState, LV_ALIGN_BOTTOM_MID);
lv_obj_add_flag(ui_ButState, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags
lv_obj_remove_flag(ui_ButState, LV_OBJ_FLAG_SCROLLABLE); /// Flags
lv_obj_set_style_bg_color(ui_ButState, lv_color_hex(0xF03737), LV_PART_MAIN | LV_STATE_CHECKED);
lv_obj_set_style_bg_opa(ui_ButState, 255, LV_PART_MAIN | LV_STATE_CHECKED);
ui_LabelState = lv_label_create(ui_ButState);
lv_obj_set_width(ui_LabelState, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_LabelState, LV_SIZE_CONTENT); /// 1
lv_obj_set_align(ui_LabelState, LV_ALIGN_CENTER);
lv_label_set_text(ui_LabelState, LV_SYMBOL_PLAY);
// timer
chart_update_timer = lv_timer_create(_chart_update_cb, 100, NULL); // 每100ms更新一次数据
}
void ui_ChartPage_screen_destroy(void)
{
if (chart_update_timer) {
lv_timer_delete(chart_update_timer);
chart_update_timer = NULL;
}
}