msg_pt100/LVGL/generated/events_init.c

394 lines
13 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* Copyright 2024 NXP
* NXP Confidential and Proprietary. This software is owned or controlled by NXP and may only be used strictly in
* accordance with the applicable license terms. By expressly accepting such terms or by downloading, installing,
* activating and/or otherwise using the software, you are agreeing that you have read, and that you agree to
* comply with and are bound by, such license terms. If you do not agree to be bound by the applicable license
* terms, then you may not retain, install, activate or otherwise use the software.
*/
#include "events_init.h"
#include <stdio.h>
#include "lvgl.h"
#include "custom.h"
#if LV_USE_FREEMASTER
#include "freemaster_client.h"
#endif
int screen_id = 0;//启动界面为0主界面为1图表界面为2历史界面为3
int test_status = 0;//待机状态为0点击开始测试后变为1测试中变为2点击结束测试变为3.
int test_btn_click_flag = 0;
static void start_screen_event_handler (lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
switch (code) {
case LV_EVENT_SCREEN_LOADED:
{
screen_id = 0;
ui_load_scr_animation(&guider_ui, &guider_ui.main_screen, guider_ui.main_screen_del, &guider_ui.start_screen_del, setup_scr_main_screen, LV_SCR_LOAD_ANIM_NONE, 200, 2000, false, true);
HAL_GPIO_WritePin(LCD_LEDA_GPIO_Port, LCD_LEDA_Pin, GPIO_PIN_RESET);
break;
}
default:
break;
}
}
void events_init_start_screen(lv_ui *ui)
{
lv_obj_add_event_cb(ui->start_screen, start_screen_event_handler, LV_EVENT_ALL, ui);
}
static void main_screen_event_handler (lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
switch (code) {
case LV_EVENT_SCREEN_LOADED:
{
screen_id = 1;
updata_data_task = lv_timer_create(main_screen_updata_data_task_timer_cb,100,&guider_ui);
lv_label_set_text_fmt(guider_ui.main_screen_type_label,type_str,NULL);
lv_label_set_text_fmt(guider_ui.main_screen_linear_label,"%.2f",(linearity * 100.0f));
break;
}
default:
break;
}
}
static void main_screen_history_btn_event_handler (lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
switch (code) {
case LV_EVENT_CLICKED:
{
lv_timer_del(updata_data_task);
ui_load_scr_animation(&guider_ui, &guider_ui.history_screen, guider_ui.history_screen_del, &guider_ui.main_screen_del, setup_scr_history_screen, LV_SCR_LOAD_ANIM_NONE, 200, 200, false, true);
break;
}
default:
break;
}
}
static void main_screen_test_btn_event_handler (lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
switch (code) {
case LV_EVENT_CLICKED:
{
if(test_btn_click_flag == 0)
{
lv_label_set_text_fmt(guider_ui.main_screen_type_label,"null",NULL);
//lv_label_set_text_fmt(guider_ui.main_screen_mbp_label,"0mm",NULL);
lv_label_set_text_fmt(guider_ui.main_screen_linear_label,"0.00",NULL);
//lv_label_set_text_fmt(guider_ui.main_screen_move_label,"start to end",NULL);
lv_label_set_text(guider_ui.main_screen_test_btn_label, "finish");
test_btn_click_flag = 1;
test_status = 1;
}
else
{
lv_label_set_text(guider_ui.main_screen_test_btn_label,"start");
test_btn_click_flag = 0;
test_status = 3;
}
break;
}
default:
break;
}
}
void events_init_main_screen(lv_ui *ui)
{
lv_obj_add_event_cb(ui->main_screen, main_screen_event_handler, LV_EVENT_ALL, ui);
lv_obj_add_event_cb(ui->main_screen_history_btn, main_screen_history_btn_event_handler, LV_EVENT_ALL, ui);
lv_obj_add_event_cb(ui->main_screen_test_btn, main_screen_test_btn_event_handler, LV_EVENT_ALL, ui);
}
static void history_screen_event_handler (lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
switch (code) {
case LV_EVENT_SCREEN_LOADED:
{
screen_id = 3;
//
for(int i = 0;i < 10;i++)
{
if((test_cnt - i) > 0)
cnt_array[i] = test_cnt - i;
else
cnt_array[i] = 10 + test_cnt - i;
}
//
lv_label_set_text_fmt(guider_ui.history_screen_no1_label, "%.2f",((save_data[0 + (cnt_array[0] - 1) * 10] * 256 + save_data[1 + (cnt_array[0] - 1) * 10]) / 100.0));
lv_label_set_text_fmt(guider_ui.history_screen_no2_label, "%.2f",((save_data[0 + (cnt_array[1] - 1) * 10] * 256 + save_data[1 + (cnt_array[1] - 1) * 10]) / 100.0));
lv_label_set_text_fmt(guider_ui.history_screen_no3_label, "%.2f",((save_data[0 + (cnt_array[2] - 1) * 10] * 256 + save_data[1 + (cnt_array[2] - 1) * 10]) / 100.0));
lv_label_set_text_fmt(guider_ui.history_screen_no4_label, "%.2f",((save_data[0 + (cnt_array[3] - 1) * 10] * 256 + save_data[1 + (cnt_array[3] - 1) * 10]) / 100.0));
lv_label_set_text_fmt(guider_ui.history_screen_no5_label, "%.2f",((save_data[0 + (cnt_array[4] - 1) * 10] * 256 + save_data[1 + (cnt_array[4] - 1) * 10]) / 100.0));
lv_label_set_text_fmt(guider_ui.history_screen_no6_label, "%.2f",((save_data[0 + (cnt_array[5] - 1) * 10] * 256 + save_data[1 + (cnt_array[5] - 1) * 10]) / 100.0));
lv_label_set_text_fmt(guider_ui.history_screen_no7_label, "%.2f",((save_data[0 + (cnt_array[6] - 1) * 10] * 256 + save_data[1 + (cnt_array[6] - 1) * 10]) / 100.0));
lv_label_set_text_fmt(guider_ui.history_screen_no8_label, "%.2f",((save_data[0 + (cnt_array[7] - 1) * 10] * 256 + save_data[1 + (cnt_array[7] - 1) * 10]) / 100.0));
lv_label_set_text_fmt(guider_ui.history_screen_no9_label, "%.2f",((save_data[0 + (cnt_array[8] - 1) * 10] * 256 + save_data[1 + (cnt_array[8] - 1) * 10]) / 100.0));
lv_label_set_text_fmt(guider_ui.history_screen_no10_label,"%.2f",((save_data[0 + (cnt_array[9] - 1) * 10] * 256 + save_data[1 + (cnt_array[9] - 1) * 10]) / 100.0));
updata_data_task = lv_timer_create(history_screen_updata_data_task_timer_cb,1000,&guider_ui);
break;
}
default:
break;
}
}
static void history_screen_test_btn_event_handler (lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
switch (code) {
case LV_EVENT_CLICKED:
{
lv_timer_del(updata_data_task);
ui_load_scr_animation(&guider_ui, &guider_ui.main_screen, guider_ui.main_screen_del, &guider_ui.history_screen_del, setup_scr_main_screen, LV_SCR_LOAD_ANIM_NONE, 200, 200, false, true);
break;
}
default:
break;
}
}
static void history_screen_no1_label_event_handler (lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
switch (code) {
case LV_EVENT_CLICKED:
{
lv_timer_del(updata_data_task);
history_num = 0;
at24cxx_read((2 * cnt_array[history_num] - 1) * 1000,vol_loc_data,2000);
ui_load_scr_animation(&guider_ui, &guider_ui.chart_screen, guider_ui.chart_screen_del, &guider_ui.history_screen_del, setup_scr_chart_screen, LV_SCR_LOAD_ANIM_NONE, 200, 200, false, true);
break;
}
default:
break;
}
}
static void history_screen_no2_label_event_handler (lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
switch (code) {
case LV_EVENT_CLICKED:
{
lv_timer_del(updata_data_task);
history_num = 1;
at24cxx_read((2 * cnt_array[history_num] - 1) * 1000,vol_loc_data,2000);
ui_load_scr_animation(&guider_ui, &guider_ui.chart_screen, guider_ui.chart_screen_del, &guider_ui.history_screen_del, setup_scr_chart_screen, LV_SCR_LOAD_ANIM_NONE, 200, 200, false, true);
break;
}
default:
break;
}
}
static void history_screen_no3_label_event_handler (lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
switch (code) {
case LV_EVENT_CLICKED:
{
lv_timer_del(updata_data_task);
history_num = 2;
at24cxx_read((2 * cnt_array[history_num] - 1) * 1000,vol_loc_data,2000);
ui_load_scr_animation(&guider_ui, &guider_ui.chart_screen, guider_ui.chart_screen_del, &guider_ui.history_screen_del, setup_scr_chart_screen, LV_SCR_LOAD_ANIM_NONE, 200, 200, false, true);
break;
}
default:
break;
}
}
static void history_screen_no4_label_event_handler (lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
switch (code) {
case LV_EVENT_CLICKED:
{
lv_timer_del(updata_data_task);
history_num = 3;
at24cxx_read((2 * cnt_array[history_num] - 1) * 1000,vol_loc_data,2000);
ui_load_scr_animation(&guider_ui, &guider_ui.chart_screen, guider_ui.chart_screen_del, &guider_ui.history_screen_del, setup_scr_chart_screen, LV_SCR_LOAD_ANIM_NONE, 200, 200, false, true);
break;
}
default:
break;
}
}
static void history_screen_no5_label_event_handler (lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
switch (code) {
case LV_EVENT_CLICKED:
{
lv_timer_del(updata_data_task);
history_num = 4;
at24cxx_read((2 * cnt_array[history_num] - 1) * 1000,vol_loc_data,2000);
ui_load_scr_animation(&guider_ui, &guider_ui.chart_screen, guider_ui.chart_screen_del, &guider_ui.history_screen_del, setup_scr_chart_screen, LV_SCR_LOAD_ANIM_NONE, 200, 200, false, true);
break;
}
default:
break;
}
}
static void history_screen_no6_label_event_handler (lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
switch (code) {
case LV_EVENT_CLICKED:
{
lv_timer_del(updata_data_task);
history_num = 5;
at24cxx_read((2 * cnt_array[history_num] - 1) * 1000,vol_loc_data,2000);
ui_load_scr_animation(&guider_ui, &guider_ui.chart_screen, guider_ui.chart_screen_del, &guider_ui.history_screen_del, setup_scr_chart_screen, LV_SCR_LOAD_ANIM_NONE, 200, 200, false, true);
break;
}
default:
break;
}
}
static void history_screen_no7_label_event_handler (lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
switch (code) {
case LV_EVENT_CLICKED:
{
lv_timer_del(updata_data_task);
history_num = 6;
at24cxx_read((2 * cnt_array[history_num] - 1) * 1000,vol_loc_data,2000);
ui_load_scr_animation(&guider_ui, &guider_ui.chart_screen, guider_ui.chart_screen_del, &guider_ui.history_screen_del, setup_scr_chart_screen, LV_SCR_LOAD_ANIM_NONE, 200, 200, false, true);
break;
}
default:
break;
}
}
static void history_screen_no8_label_event_handler (lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
switch (code) {
case LV_EVENT_CLICKED:
{
lv_timer_del(updata_data_task);
history_num = 7;
at24cxx_read((2 * cnt_array[history_num] - 1) * 1000,vol_loc_data,2000);
ui_load_scr_animation(&guider_ui, &guider_ui.chart_screen, guider_ui.chart_screen_del, &guider_ui.history_screen_del, setup_scr_chart_screen, LV_SCR_LOAD_ANIM_NONE, 200, 200, false, true);
break;
}
default:
break;
}
}
static void history_screen_no9_label_event_handler (lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
switch (code) {
case LV_EVENT_CLICKED:
{
lv_timer_del(updata_data_task);
history_num = 8;
at24cxx_read((2 * cnt_array[history_num] - 1) * 1000,vol_loc_data,2000);
ui_load_scr_animation(&guider_ui, &guider_ui.chart_screen, guider_ui.chart_screen_del, &guider_ui.history_screen_del, setup_scr_chart_screen, LV_SCR_LOAD_ANIM_NONE, 200, 200, false, true);
break;
}
default:
break;
}
}
static void history_screen_no10_label_event_handler (lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
switch (code) {
case LV_EVENT_CLICKED:
{
lv_timer_del(updata_data_task);
history_num = 9;
at24cxx_read((2 * cnt_array[history_num] - 1) * 1000,vol_loc_data,2000);
ui_load_scr_animation(&guider_ui, &guider_ui.chart_screen, guider_ui.chart_screen_del, &guider_ui.history_screen_del, setup_scr_chart_screen, LV_SCR_LOAD_ANIM_NONE, 200, 200, false, true);
break;
}
default:
break;
}
}
void events_init_history_screen(lv_ui *ui)
{
lv_obj_add_event_cb(ui->history_screen, history_screen_event_handler, LV_EVENT_ALL, ui);
lv_obj_add_event_cb(ui->history_screen_test_btn, history_screen_test_btn_event_handler, LV_EVENT_ALL, ui);
lv_obj_add_event_cb(ui->history_screen_no1_label, history_screen_no1_label_event_handler, LV_EVENT_ALL, ui);
lv_obj_add_event_cb(ui->history_screen_no2_label, history_screen_no2_label_event_handler, LV_EVENT_ALL, ui);
lv_obj_add_event_cb(ui->history_screen_no3_label, history_screen_no3_label_event_handler, LV_EVENT_ALL, ui);
lv_obj_add_event_cb(ui->history_screen_no4_label, history_screen_no4_label_event_handler, LV_EVENT_ALL, ui);
lv_obj_add_event_cb(ui->history_screen_no5_label, history_screen_no5_label_event_handler, LV_EVENT_ALL, ui);
lv_obj_add_event_cb(ui->history_screen_no6_label, history_screen_no6_label_event_handler, LV_EVENT_ALL, ui);
lv_obj_add_event_cb(ui->history_screen_no7_label, history_screen_no7_label_event_handler, LV_EVENT_ALL, ui);
lv_obj_add_event_cb(ui->history_screen_no8_label, history_screen_no8_label_event_handler, LV_EVENT_ALL, ui);
lv_obj_add_event_cb(ui->history_screen_no9_label, history_screen_no9_label_event_handler, LV_EVENT_ALL, ui);
lv_obj_add_event_cb(ui->history_screen_no10_label, history_screen_no10_label_event_handler, LV_EVENT_ALL, ui);
}
int step = 0;
static void chart_screen_event_handler (lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
switch (code) {
case LV_EVENT_SCREEN_LOADED:
{
screen_id = 2;
updata_data_task = lv_timer_create(chart_screen_updata_data_task_timer_cb,1,&guider_ui);
break;
}
default:
break;
}
}
static void chart_screen_return_img_event_handler (lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
switch (code) {
case LV_EVENT_CLICKED:
{
step = 0;
lv_timer_del(updata_data_task);
ui_load_scr_animation(&guider_ui, &guider_ui.history_screen, guider_ui.history_screen_del, &guider_ui.chart_screen_del, setup_scr_history_screen, LV_SCR_LOAD_ANIM_NONE, 200, 200, false, true);
break;
}
default:
break;
}
}
void events_init_chart_screen(lv_ui *ui)
{
ser1 = lv_chart_add_series(guider_ui.chart_screen_chart, lv_palette_main(LV_PALETTE_RED), LV_CHART_AXIS_PRIMARY_Y);
lv_chart_set_update_mode(guider_ui.chart_screen_chart, LV_CHART_UPDATE_MODE_CIRCULAR);
lv_obj_add_event_cb(ui->chart_screen, chart_screen_event_handler, LV_EVENT_ALL, ui);
lv_obj_add_event_cb(ui->chart_screen_return_img, chart_screen_return_img_event_handler, LV_EVENT_ALL, ui);
}
void events_init(lv_ui *ui)
{
}