163 lines
5.3 KiB
C
163 lines
5.3 KiB
C
/*
|
|
* Copyright 2023 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.
|
|
*/
|
|
|
|
/*********************
|
|
* INCLUDES
|
|
*********************/
|
|
#include <stdio.h>
|
|
#include "lvgl.h"
|
|
#include "custom.h"
|
|
|
|
/*********************
|
|
* DEFINES
|
|
*********************/
|
|
|
|
/**********************
|
|
* TYPEDEFS
|
|
**********************/
|
|
|
|
/**********************
|
|
* STATIC PROTOTYPES
|
|
**********************/
|
|
|
|
/**********************
|
|
* STATIC VARIABLES
|
|
**********************/
|
|
int history_num = 0;
|
|
int min_l=0,max_l=0;
|
|
int x_range = 0;
|
|
const char* str1 = NULL;
|
|
|
|
lv_chart_series_t* ser1;
|
|
lv_timer_t *updata_data_task;
|
|
|
|
extern int finish_flag;
|
|
extern long ads1230_vol;
|
|
|
|
int chart_updata_cnt = 0;
|
|
int chart_updata_finish = 0;
|
|
|
|
int cnt_array[10] = {1,2,3,4,5,6,7,8,9,10};
|
|
|
|
int16_t linearity_num = 0;
|
|
int16_t bias_local_num = 0;
|
|
int16_t point_cnt_num = 0;
|
|
int16_t min_v_num = 0;
|
|
int16_t max_v_num = 0;
|
|
|
|
int16_t start_loca = 0;
|
|
int16_t end_loca = 0;
|
|
|
|
/**
|
|
* Create a demo application
|
|
*/
|
|
|
|
void custom_init(lv_ui *ui)
|
|
{
|
|
/* Add your codes here */
|
|
}
|
|
|
|
void main_screen_updata_data_task_timer_cb(lv_timer_t *t)
|
|
{
|
|
#if USE_ADS1220
|
|
lv_label_set_text_fmt(guider_ui.main_screen_currv_label,"%dmv",ads1220_data);
|
|
#else
|
|
lv_label_set_text_fmt(guider_ui.main_screen_currv_label,"%dmv",ads1230_vol);
|
|
#endif
|
|
|
|
if(finish_flag)
|
|
{
|
|
finish_flag = 0;
|
|
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));
|
|
}
|
|
|
|
lv_bar_set_value(guider_ui.main_screen_power_bar, (ADC_ConvertedValue - 1030.0) / 3.0, LV_ANIM_OFF);
|
|
}
|
|
|
|
void chart_screen_updata_data_task_timer_cb(lv_timer_t *t)
|
|
{
|
|
if(chart_updata_cnt == 100)
|
|
{
|
|
lv_bar_set_value(guider_ui.chart_screen_power_bar, (ADC_ConvertedValue - 1030.0) / 3.0, LV_ANIM_OFF);
|
|
lv_timer_del(updata_data_task);
|
|
updata_data_task = lv_timer_create(chart_screen_updata_data_task_timer_cb,100,&guider_ui);
|
|
chart_updata_cnt = 0;
|
|
}
|
|
|
|
if(!chart_updata_finish)
|
|
{
|
|
chart_updata_finish = 1;
|
|
linearity_num = save_data[0 + (cnt_array[history_num] - 1) * 10] << 8 | save_data[1 + (cnt_array[history_num] - 1) * 10];
|
|
bias_local_num = save_data[2 + (cnt_array[history_num] - 1) * 10] << 8 | save_data[3 + (cnt_array[history_num] - 1) * 10];
|
|
bias_local_num = ((bias_local_num - 10000) / 720.0) * 2540.0;
|
|
point_cnt_num = save_data[4 + (cnt_array[history_num] - 1) * 10] << 8 | save_data[5 + (cnt_array[history_num] - 1) * 10];
|
|
min_v_num = save_data[6 + (cnt_array[history_num] - 1) * 10] << 8 | save_data[7 + (cnt_array[history_num] - 1) * 10];
|
|
max_v_num = save_data[8 + (cnt_array[history_num] - 1) * 10] << 8 | save_data[9 + (cnt_array[history_num] - 1) * 10];
|
|
|
|
int16_t start_loca = vol_loc_data[1000] << 8 | vol_loc_data[1001];
|
|
int16_t end_loca = vol_loc_data[1000 + (point_cnt_num - 1) * 2] << 8 | vol_loc_data[1001 + (point_cnt_num - 1) * 2];
|
|
|
|
if(start_loca < end_loca)
|
|
{
|
|
min_l = start_loca;
|
|
max_l = end_loca;
|
|
str1 = "s->e";
|
|
}
|
|
else
|
|
{
|
|
max_l = start_loca;
|
|
min_l = end_loca;
|
|
str1 = "e->s";
|
|
}
|
|
|
|
x_range = max_l - min_l;
|
|
|
|
if((x_range) < 840 && (x_range) > 280)
|
|
lv_label_set_text_fmt(guider_ui.chart_screen_type_label,"#25",NULL);
|
|
else if((x_range) < 1680)
|
|
lv_label_set_text_fmt(guider_ui.chart_screen_type_label,"#50",NULL);
|
|
else if((x_range) < 3360)
|
|
lv_label_set_text_fmt(guider_ui.chart_screen_type_label,"#100",NULL);
|
|
else if((x_range) < 6160)
|
|
lv_label_set_text_fmt(guider_ui.chart_screen_type_label,"#200",NULL);
|
|
else
|
|
lv_label_set_text_fmt(guider_ui.chart_screen_type_label,"null",NULL);
|
|
|
|
lv_label_set_text_fmt(guider_ui.chart_screen_move_label,str1,NULL);
|
|
lv_label_set_text_fmt(guider_ui.chart_screen_linearity_label,"%.2f",linearity_num / 100.0);
|
|
lv_label_set_text_fmt(guider_ui.chart_screen_mds_label,"%.2fmm",bias_local_num / 100.0);
|
|
|
|
lv_chart_set_point_count(guider_ui.chart_screen_chart,point_cnt_num);
|
|
lv_chart_set_range(guider_ui.chart_screen_chart, LV_CHART_AXIS_PRIMARY_Y, min_v_num, max_v_num);
|
|
lv_chart_set_range(guider_ui.chart_screen_chart, LV_CHART_AXIS_PRIMARY_X, 0, x_range);
|
|
}
|
|
if((chart_updata_cnt < point_cnt_num) && chart_updata_finish == 1)
|
|
{
|
|
lv_chart_set_next_value(guider_ui.chart_screen_chart, ser1,(int16_t)(vol_loc_data[0 + chart_updata_cnt * 2] << 8 | vol_loc_data[1 + chart_updata_cnt * 2]));
|
|
//lv_chart_set_next_value2(guider_ui.chart_screen_chart, ser1, (int16_t)((vol_loc_data[1000 + chart_updata_cnt * 2] << 8 | vol_loc_data[1001 + chart_updata_cnt * 2]) - min_l), (int16_t)(vol_loc_data[0 + chart_updata_cnt * 2] << 8 | vol_loc_data[1 + chart_updata_cnt * 2]));
|
|
}
|
|
if(chart_updata_cnt == point_cnt_num)
|
|
{
|
|
lv_chart_refresh(guider_ui.chart_screen_chart);
|
|
chart_updata_finish = 2;
|
|
}
|
|
chart_updata_cnt++;
|
|
}
|
|
|
|
void history_screen_updata_data_task_timer_cb(lv_timer_t *t)
|
|
{
|
|
chart_updata_cnt = 0;
|
|
chart_updata_finish = 0;
|
|
lv_bar_set_value(guider_ui.history_screen_power_bar, (ADC_ConvertedValue - 1030.0) / 3.0, LV_ANIM_OFF);
|
|
}
|
|
|
|
|
|
|