更新:

1、复位后追加执行保存;
2、取消math.h的使用,采用“(int)(a+0.5)”的形式执行四舍五入;
3、代码整理,注释补充;
This commit is contained in:
吴俊潮 2025-04-02 15:11:39 +08:00
parent d5947108b7
commit 49feec1a9e
5 changed files with 16679 additions and 16745 deletions

View File

@ -126,15 +126,12 @@ void set_item0_value(uint8_t con, int8_t step);
//修改选项卡0的文本 //修改选项卡0的文本
void set_item0_text(uint8_t con); void set_item0_text(uint8_t con);
//修改选项卡0的值 //修改选项卡1的值
void set_item1_value(uint8_t con, int8_t step); void set_item1_value(uint8_t con, int8_t step);
//修改选项卡1的文本 //修改选项卡1的文本
void set_item1_text(uint8_t con); void set_item1_text(uint8_t con);
//此处仅用于修改设置界面的显示内容修改后的内容会在返回主界面时KEY_BACK再更新
void setting_contents_update(uint8_t ite, uint8_t con);
//设置内容的底色 //设置内容的底色
void set_contents_color(uint8_t cursor, uint32_t color); void set_contents_color(uint8_t cursor, uint32_t color);
@ -144,9 +141,6 @@ void scr_setting_recover(void);
//详细设置界面 //详细设置界面
void scr_setting_run(void); void scr_setting_run(void);
//处理弹窗
void tab_window_deal(void);
#endif #endif

View File

@ -57,7 +57,6 @@ extern const lv_img_dsc_t * screen_main_ani_out_sign_imgs[3];
#include "stdio.h" #include "stdio.h"
#include "ip5310_i2c.h" #include "ip5310_i2c.h"
#include "eeprom_spi.h" #include "eeprom_spi.h"
#include "math.h"
//#include "lv_demo_benchmark.h" //#include "lv_demo_benchmark.h"
typedef enum typedef enum

View File

@ -682,7 +682,7 @@ void scr_main_run(void)
//num_twinkle(); //1000ms //num_twinkle(); //1000ms
} }
//eeprom状态监控 //eeprom状态监控,置于运行时间显示内部
uint8_t ee_status_test = 0; uint8_t ee_status_test = 0;
void eep_status_monitor(void) void eep_status_monitor(void)
{ {
@ -1132,7 +1132,9 @@ void set_output(float32 sto)
//乘以1000用于绕开 int32 和 float32 之间的转换 //乘以1000用于绕开 int32 和 float32 之间的转换
sto *= 1000; sto *= 1000;
sto = round(sto);
//配合 set_output_array(int32_t) 进行四舍五入取整
sto += (float32)0.5;
//更新缓存 //更新缓存
set_output_array(sto); set_output_array(sto);

View File

@ -47,7 +47,7 @@ void item0_data_init(void)
} }
//eeprom_rd_error_flag = 1; //eeprom_rd_error_flag = 1;
//读取过程中出现过错误 //读取过程中出现过错误,或者触发复位
if( (eeprom_rd_error_flag == 1)||(tabdata.item1_page0_resetflag == 1) ) if( (eeprom_rd_error_flag == 1)||(tabdata.item1_page0_resetflag == 1) )
{ {
tabdata.item0_page0_vup[0] = VOL[0].up; //电压V上限 tabdata.item0_page0_vup[0] = VOL[0].up; //电压V上限
@ -78,6 +78,16 @@ void item0_data_init(void)
tabdata.item0_page1_TClow[7] = TC[7].low; //TCT下限 tabdata.item0_page1_TClow[7] = TC[7].low; //TCT下限
tabdata.item0_page2_RTDup = RTD.up; //RTD上限 tabdata.item0_page2_RTDup = RTD.up; //RTD上限
tabdata.item0_page2_RTDlow = RTD.low; //RTD下限 tabdata.item0_page2_RTDlow = RTD.low; //RTD下限
//针对复位的情况追加进行保存
if(tabdata.item1_page0_resetflag == 1)
{
eeprom_datasave();
//保存状态更改为“已保存”
tabdata.item1_page0_saveflag = 0;
set_item1_text(DATA_SAVE);
}
} }
} }
@ -86,6 +96,7 @@ void key_functions_setting(void)
{ {
if( (tabdata.item1_page0_saveflag == 1) || (tabdata.item1_page0_resetflag == 1) ) if( (tabdata.item1_page0_saveflag == 1) || (tabdata.item1_page0_resetflag == 1) )
{ {
//复位和保存过程中禁用按键
return; return;
} }
@ -95,7 +106,7 @@ void key_functions_setting(void)
{ {
key = 0; key = 0;
//所有选项卡均未选中时,返回主界面,否则熄灭当前选中 //从设置界面返回主界面
if(tabdata.content_cursor == 99) if(tabdata.content_cursor == 99)
{ {
//下次进入设置页面时从选项卡0开始 //下次进入设置页面时从选项卡0开始
@ -117,11 +128,10 @@ void key_functions_setting(void)
} }
else else
{ {
//当不存在焦点时,从内容选择返回选项卡选择
if(tabdata.content_focus == 0) if(tabdata.content_focus == 0)
{ {
//当不存在焦点时 //熄灭当前选中的内容
//某个选项卡被选中时,熄灭内部选中的内容
//熄灭当前内容
setting_contents_check(99, tabdata.content_cursor); setting_contents_check(99, tabdata.content_cursor);
//取消内容选中与焦点 //取消内容选中与焦点
@ -133,13 +143,13 @@ void key_functions_setting(void)
} }
else else
{ {
//当存在焦点时 //当存在焦点时,取消焦点,返回内容选择
tabdata.content_focus = 0; tabdata.content_focus = 0;
setting_contents_check(tabdata.content_cursor, 99); setting_contents_check(tabdata.content_cursor, 99);
//更新当前游标所在内容的文本(焦点前后不一致)
uint8_t inner_cursor = 0; uint8_t inner_cursor = 0;
inner_cursor = tabdata.content_cursor + (tabdata.item_page - 1) * 6; inner_cursor = tabdata.content_cursor + (tabdata.item_page - 1) * 6;
switch (tabdata.item_cursor) switch (tabdata.item_cursor)
{ {
case ITEMS_0: case ITEMS_0:
@ -198,7 +208,7 @@ void key_functions_setting(void)
} }
else else
{ {
//某个内容被焦点前,在此处选择内容值 //某个选项卡被选中后,某个内容被焦点前,在此处选择内容值
if(tabdata.content_focus == 0) if(tabdata.content_focus == 0)
{ {
switch (tabdata.item_cursor) switch (tabdata.item_cursor)
@ -229,7 +239,7 @@ void key_functions_setting(void)
} }
else else
{ {
//某个内容被焦点后,使用 KEY_LEFT 和 KEY_RIGHT 修改内容 //某个内容被焦点后,使用 KEY_LEFT 和 KEY_RIGHT 修改内容,禁用 KEY_UP 和 KEY_DOWN
return; return;
} }
} }
@ -279,7 +289,7 @@ void key_functions_setting(void)
} }
else else
{ {
//某个内容被焦点后,使用 KEY_LEFT 和 KEY_RIGHT 修改内容 //某个内容被焦点后,使用 KEY_LEFT 和 KEY_RIGHT 修改内容,禁用 KEY_UP 和 KEY_DOWN
return; return;
} }
} }
@ -290,26 +300,22 @@ void key_functions_setting(void)
{ {
key = 0; key = 0;
if(tabdata.content_cursor == 99) if(tabdata.content_cursor == 99)
{ {
//选中某个选项卡后点亮第一个内容 //进入某个选项卡,点亮第一个内容
tabdata.content_cursor = 0; tabdata.content_cursor = 0;
tabdata.content_cursor_prv = 99; tabdata.content_cursor_prv = 99;
setting_contents_check(tabdata.content_cursor, tabdata.content_cursor_prv); setting_contents_check(tabdata.content_cursor, tabdata.content_cursor_prv);
} }
else else
{ {
//进入此处说明选项卡已被选中 //进入某个选项卡后,焦点当前选中内容
//内容焦点后通过KEY_LEFT和KEY_RIGHT修改
//KEY_BACK按下后取消焦点
tabdata.content_focus = 1; tabdata.content_focus = 1;
setting_contents_check(tabdata.content_cursor, tabdata.content_cursor_prv); setting_contents_check(tabdata.content_cursor, tabdata.content_cursor_prv);
//焦点后更新所选内容的文本
uint8_t inner_cursor = 0; uint8_t inner_cursor = 0;
inner_cursor = tabdata.content_cursor + (tabdata.item_page - 1) * 6; inner_cursor = tabdata.content_cursor + (tabdata.item_page - 1) * 6;
switch (tabdata.item_cursor) switch (tabdata.item_cursor)
{ {
case ITEMS_0: case ITEMS_0:
@ -341,7 +347,6 @@ void key_functions_setting(void)
} }
break; break;
//仅用于修改内容
case KEY_LEFT: case KEY_LEFT:
{ {
key = 0; key = 0;
@ -354,7 +359,7 @@ void key_functions_setting(void)
if(tabdata.content_focus == 0) if(tabdata.content_focus == 0)
{ {
//翻页 //不存在焦点时,执行翻页操作
switch (tabdata.item_cursor) switch (tabdata.item_cursor)
{ {
case ITEMS_0: case ITEMS_0:
@ -391,7 +396,7 @@ void key_functions_setting(void)
} }
else else
{ {
//修改内容 //存在焦点后,修改内容
uint8_t inner_cursor = 0; uint8_t inner_cursor = 0;
switch (tabdata.item_cursor) switch (tabdata.item_cursor)
{ {
@ -426,7 +431,6 @@ void key_functions_setting(void)
} }
break; break;
//仅用于修改内容
case KEY_RIGHT: case KEY_RIGHT:
{ {
key = 0; key = 0;
@ -559,7 +563,7 @@ void setting_items_check(uint8_t cursor, uint8_t cursor_prv)
break; break;
} }
switch (cursor_prv) //熄灭前一时刻选项卡,并隐藏选项卡内容 switch (cursor_prv) //熄灭前一时刻选项卡,并隐藏选项卡内容(已在 setting_items_page 中实现)
{ {
case ITEMS_0: case ITEMS_0:
{ {
@ -1513,7 +1517,7 @@ void set_item0_text(uint8_t con)
} }
} }
//修改选项卡0的值 //修改选项卡1的值
int16_t save_cnt = 0, reset_cnt = 0; int16_t save_cnt = 0, reset_cnt = 0;
void set_item1_value(uint8_t con, int8_t step) void set_item1_value(uint8_t con, int8_t step)
{ {
@ -1726,34 +1730,6 @@ void set_item1_text(uint8_t con)
} }
} }
void setting_contents_update(uint8_t ite, uint8_t con)
{
switch (ite)
{
case ITEMS_0:
{
}
break;
case ITEMS_1:
{
}
break;
case ITEMS_2:
{}
break;
case ITEMS_3:
{}
break;
default:
break;
}
}
//设置内容的底色 //设置内容的底色
void set_contents_color(uint8_t cursor, uint32_t color) void set_contents_color(uint8_t cursor, uint32_t color)
{ {
@ -1814,12 +1790,6 @@ void scr_setting_recover(void)
set_item0_text(PAGE_PV); set_item0_text(PAGE_PV);
} }
//处理弹窗
void tab_window_deal(void)
{
}
// uint8_t eep_test_flag = 0; // uint8_t eep_test_flag = 0;
// uint8_t tx = 0, rx = 0; // uint8_t tx = 0, rx = 0;
// uint8_t addr_test[3] = {0}; // uint8_t addr_test[3] = {0};
@ -1852,16 +1822,12 @@ void scr_setting_run(void) //详细设置界面
if(tabdata.item1_page0_resetflag == 1) if(tabdata.item1_page0_resetflag == 1)
{ {
reset_cnt++; reset_cnt++;
if(reset_cnt > 10) if(reset_cnt > 5)
{ {
reset_cnt = 0; reset_cnt = 0;
tabdata.item1_page0_resetflag = 2; tabdata.item1_page0_resetflag = 2;
set_item1_text(DATA_RESET); set_item1_text(DATA_RESET);
tabdata.item1_page0_saveflag = 0;
set_item1_text(DATA_SAVE);
} }
} }

File diff suppressed because it is too large Load Diff