📄 form.c
字号:
//=======================================================================================================
//主要用于处理界面
//=======================================================================================================
#include <system.h>
#include <Typedef.h>
#include <GAL.h>
#include <IAL.h>
#include <button.h>
unsigned char xdata tst[14];
//=======================================================================================================
//显示参数
//=======================================================================================================
void show_para(void);
void draw_scale(void);
//=================================================================================================================================================
//判断该button是否为按下去的button
//==================================================================================================================================================
unsigned int Is_this_butt_activated(Cbutton* butt,unsigned int* notify)
{
if((msg.x>=butt->x1&&msg.x<=butt->x2)&&(msg.y>=butt->y1&&msg.y<=butt->y2))
{
if(msg.up_down=='T')
{
button_down(butt);
*notify=0;
}
else
{
button_up(butt);
*notify=butt->notify_MSG;
}
return yes;
}
return no;
}
//=======================================================================================================
//控件通知码查询,form_NO为窗体索引号
//=======================================================================================================
unsigned int search(unsigned int form_NO)
{
unsigned int notify_msg; //控件通知码
//while(!get_key(&msg)); //等待键值
if(get_key(&msg)==1)
{
switch(form_NO)
{
case MAINFORM: //主界面
IS_YOU_ACTIVATED(btn_para)
IS_YOU_ACTIVATED(btn_data)
IS_YOU_ACTIVATED(btn_NO)
IS_YOU_ACTIVATED(btn_lang)
IS_YOU_ACTIVATED(btn_off)
IS_YOU_ACTIVATED(btn_help)
IS_YOU_ACTIVATED(btn_stop_start)
break;
case PARAFORM: //参数设置界面
IS_YOU_ACTIVATED(btn_para_0)
IS_YOU_ACTIVATED(btn_para_1)
IS_YOU_ACTIVATED(btn_para_2)
IS_YOU_ACTIVATED(btn_para_3)
IS_YOU_ACTIVATED(btn_para_4)
IS_YOU_ACTIVATED(btn_para_5)
IS_YOU_ACTIVATED(btn_para_6)
IS_YOU_ACTIVATED(btn_para_7)
IS_YOU_ACTIVATED(btn_para_8)
IS_YOU_ACTIVATED(btn_para_9)
IS_YOU_ACTIVATED(btn_para_up)
IS_YOU_ACTIVATED(btn_para_left)
IS_YOU_ACTIVATED(btn_para_cancle)
IS_YOU_ACTIVATED(btn_para_next_page)
IS_YOU_ACTIVATED(btn_para_down)
IS_YOU_ACTIVATED(btn_para_right)
IS_YOU_ACTIVATED(btn_para_ok)
IS_YOU_ACTIVATED(btn_para_return)
break;
case PARAEXPFORM:
IS_YOU_ACTIVATED(btn_para_exp_return)
break;
case SAMPLEFORM:
IS_YOU_ACTIVATED(btn_NO_0)
IS_YOU_ACTIVATED(btn_NO_1)
IS_YOU_ACTIVATED(btn_NO_2)
IS_YOU_ACTIVATED(btn_NO_3)
IS_YOU_ACTIVATED(btn_NO_4)
IS_YOU_ACTIVATED(btn_NO_5)
IS_YOU_ACTIVATED(btn_NO_6)
IS_YOU_ACTIVATED(btn_NO_7)
IS_YOU_ACTIVATED(btn_NO_8)
IS_YOU_ACTIVATED(btn_NO_9)
IS_YOU_ACTIVATED(btn_NO_q)
IS_YOU_ACTIVATED(btn_NO_w)
IS_YOU_ACTIVATED(btn_NO_e)
IS_YOU_ACTIVATED(btn_NO_r)
IS_YOU_ACTIVATED(btn_NO_t)
IS_YOU_ACTIVATED(btn_NO_y)
IS_YOU_ACTIVATED(btn_NO_u)
IS_YOU_ACTIVATED(btn_NO_i)
IS_YOU_ACTIVATED(btn_NO_o)
IS_YOU_ACTIVATED(btn_NO_p)
IS_YOU_ACTIVATED(btn_NO_a)
IS_YOU_ACTIVATED(btn_NO_s)
IS_YOU_ACTIVATED(btn_NO_d)
IS_YOU_ACTIVATED(btn_NO_f)
IS_YOU_ACTIVATED(btn_NO_g)
IS_YOU_ACTIVATED(btn_NO_h)
IS_YOU_ACTIVATED(btn_NO_j)
IS_YOU_ACTIVATED(btn_NO_k)
IS_YOU_ACTIVATED(btn_NO_l)
IS_YOU_ACTIVATED(btn_NO_z)
IS_YOU_ACTIVATED(btn_NO_x)
IS_YOU_ACTIVATED(btn_NO_c)
IS_YOU_ACTIVATED(btn_NO_v)
IS_YOU_ACTIVATED(btn_NO_b)
IS_YOU_ACTIVATED(btn_NO_n)
IS_YOU_ACTIVATED(btn_NO_m)
IS_YOU_ACTIVATED(btn_NO_shift)
IS_YOU_ACTIVATED(btn_NO_up)
IS_YOU_ACTIVATED(btn_NO_down)
IS_YOU_ACTIVATED(btn_NO_left)
IS_YOU_ACTIVATED(btn_NO_right)
IS_YOU_ACTIVATED(btn_NO_uppage)
IS_YOU_ACTIVATED(btn_NO_downpage)
IS_YOU_ACTIVATED(btn_NO_new)
IS_YOU_ACTIVATED(btn_NO_ok)
IS_YOU_ACTIVATED(btn_NO_return)
break;
case SEARCHFORM:
IS_YOU_ACTIVATED(btn_search_NO1)
IS_YOU_ACTIVATED(btn_search_NO2)
IS_YOU_ACTIVATED(btn_search_NO3)
IS_YOU_ACTIVATED(btn_search_NO4)
IS_YOU_ACTIVATED(btn_search_NO5)
IS_YOU_ACTIVATED(btn_search_NO6)
IS_YOU_ACTIVATED(btn_search_NO7)
IS_YOU_ACTIVATED(btn_search_NO8)
IS_YOU_ACTIVATED(btn_search_uppage)
IS_YOU_ACTIVATED(btn_search_downpage)
IS_YOU_ACTIVATED(btn_search_return)
IS_YOU_ACTIVATED(btn_search_NO_delete)
break;
default:
return Idel;
break;
}
}
if(message_mail.enable==1)
{
message_mail.enable=0;
return message_mail.event;
}
return Idel;
}
//=============================================================================================================================
//初始化历史数据查询
//=============================================================================================================================
void init_history_search(void)
{
unsigned i,j,a;
languge_mode(English,yes); //切换语言
fs.sum=read_byte(0);
fs.pointer=read_byte(1);
fs.spide=fs.pointer;
for(i=0;i<8;i++)
{
fs.spide--;
if(fs.spide<0)
{
fs.spide=fs.spide-8+i+1;
return;
}
for(j=0;j<10;j++)
{
set_caract_pos(sample_new_table.ins_dot[j].x,sample_new_table.ins_dot[j].y+sample_new_table.v_step*i);
set_window_char(read_byte(2+fs.spide*74+j)); //显示字符
//打两个时间间隔符
set_caract_pos(sample_new_table.ins_dot[5].x+8,sample_new_table.ins_dot[5].y+sample_new_table.v_step*i);
set_window_char('/');
set_caract_pos(sample_new_table.ins_dot[7].x+8,sample_new_table.ins_dot[7].y+sample_new_table.v_step*i);
set_window_char('/');
}
}
a=fs.spide;
a=a+1-1;
//fs.spide+=8;
}
//======================================================================================================
//历史数据查询函数
//======================================================================================================
void history_data_search(unsigned char cmd,unsigned char dat)
{
unsigned char i,j,cha,x,y,b;
languge_mode(English,yes); //切换语言
switch(cmd)
{
case NO:
for(i=0;i<80;i++)
{
if(i<40)
{
y=i/5;
x=i%5;
set_caract_pos(E_table.x+x*8,E_table.y+y*25);
}
else
{
y=(i-40)/5;
x=i%5;
set_caract_pos(E_table.x+x*8+176,E_table.y+y*25);
}
set_window_char(' ');
}
for(i=0;i<60;i++)
{
b=fs.spide;
if(fs.sum==250)
cha=read_byte((fs.spide-dat+8+251)*74+2+2+i);
else
cha=read_byte((fs.spide-dat+8)*74+2+2+i);
if(cha=='\r')
break;
if(i<32)
{
y=i/4;
x=i%4;
if(x==0)
{
set_caract_pos(E_table.x+x*8,E_table.y+y*25);
set_window_char(cha);
set_caract_pos(E_table.x+x*8+8,E_table.y+y*25);
set_window_char('.');
}
else
{
set_caract_pos(E_table.x+x*8+8,E_table.y+y*25);
set_window_char(cha);
}
}
else
{
y=(i-32)/4;
x=i%4;
if(x==0)
{
set_caract_pos(E_table.x+x*8+176,E_table.y+y*25);
set_window_char(cha);
set_caract_pos(E_table.x+x*8+8+176,E_table.y+y*25);
set_window_char('.');
}
else
{
set_caract_pos(E_table.x+x*8+8+176,E_table.y+y*25);
set_window_char(cha);
}
}
}
break;
case uppage:
downpage_enable=1;
fs.spide+=16;
if(fs.spide>=fs.pointer)
fs.spide=fs.pointer;
//show_form(&search_form);
for(i=0;i<8;i++)
{
fs.spide--;
if(fs.spide<0)
return;
for(j=0;j<10;j++)
{
set_caract_pos(sample_new_table.ins_dot[j].x,sample_new_table.ins_dot[j].y+sample_new_table.v_step*i);
if(fs.spide>=0)
set_window_char(read_byte(2+fs.spide*74+j)); //显示字符
else
set_window_char(read_byte(2+(fs.spide+251)*74+j)); //显示字符
//打两个时间间隔符
set_caract_pos(sample_new_table.ins_dot[5].x+8,sample_new_table.ins_dot[5].y+sample_new_table.v_step*i);
set_window_char('/');
set_caract_pos(sample_new_table.ins_dot[7].x+8,sample_new_table.ins_dot[7].y+sample_new_table.v_step*i);
set_window_char('/');
}
}
break;
case downpage:
if(downpage_enable)
{
if(fs.sum<250)
{
if(fs.sum>8)
{
for(i=0;i<8;i++)
{
for(j=0;j<10;j++)
{
set_caract_pos(sample_new_table.ins_dot[j].x,sample_new_table.ins_dot[j].y+sample_new_table.v_step*i);
set_window_char(' '); //显示字符
}
}
}
for(i=0;i<8;i++)
{
fs.spide--;
if(fs.spide<0)
{
fs.spide=fs.spide-8+i+1;
downpage_enable=0;//disable下一页
break;
}
else
{
for(j=0;j<10;j++)
{
set_caract_pos(sample_new_table.ins_dot[j].x,sample_new_table.ins_dot[j].y+sample_new_table.v_step*i);
set_window_char(read_byte(2+fs.spide*74+j)); //显示字符
//打两个时间间隔符
set_caract_pos(sample_new_table.ins_dot[5].x+8,sample_new_table.ins_dot[5].y+sample_new_table.v_step*i);
set_window_char('/');
set_caract_pos(sample_new_table.ins_dot[7].x+8,sample_new_table.ins_dot[7].y+sample_new_table.v_step*i);
set_window_char('/');
}
}
}
}
//如果有250个项目
else if(fs.sum==250)
{
for(i=0;i<8;i++)
{
fs.spide--;
if((fs.spide+251)==fs.pointer)
{
fs.spide=fs.spide-8+i+1;
downpage_enable=0;//disable下一页
break;
}
for(j=0;j<10;j++)
{
set_caract_pos(sample_new_table.ins_dot[j].x,sample_new_table.ins_dot[j].y+sample_new_table.v_step*i);
if(fs.spide>=0)
set_window_char(read_byte(2+fs.spide*74+j)); //显示字符
else
set_window_char(read_byte(2+(fs.spide+251)*74+j)); //显示字符
//打两个时间间隔符
set_caract_pos(sample_new_table.ins_dot[5].x+8,sample_new_table.ins_dot[5].y+sample_new_table.v_step*i);
set_window_char('/');
set_caract_pos(sample_new_table.ins_dot[7].x+8,sample_new_table.ins_dot[7].y+sample_new_table.v_step*i);
set_window_char('/');
}
}
}
}
break;
default:
break;
}
}
//======================================================================================================
//历史数据查询界面
//======================================================================================================
void search_form_sub(void)
{
show_form(&search_form);
init_history_search();
current_form_index=search_form.index;
while(1)
{
current_form_index=search_form.index;
switch(search(search_form.index)) //查询
{
case on_btn_search_NO1:
history_data_search(NO,1);
break;
case on_btn_search_NO2:
history_data_search(NO,2);
break;
case on_btn_search_NO3:
history_data_search(NO,3);
break;
case on_btn_search_NO4:
history_data_search(NO,4);
break;
case on_btn_search_NO5:
history_data_search(NO,5);
break;
case on_btn_search_NO6:
history_data_search(NO,6);
break;
case on_btn_search_NO7:
history_data_search(NO,7);
break;
case on_btn_search_NO8:
history_data_search(NO,8);
break;
case on_btn_search_uppage:
history_data_search(uppage,0);
break;
case on_btn_search_downpage:
history_data_search(downpage,0);
break;
case on_btn_search_return:
show_form(&Main_form);
if(scale_renew==1)
{
//重画刻度和曲线起点
draw_scale();
curve1.x0=45;
curve1.y0=380;
curve2.x0=45;
curve2.y0=200;
}
return;
case on_btn_search_NO_delete:
write_byte(0,1); //项目号加1
write_byte(0,0); //项目号加1
break;
}
}
}
//=======================================================================================================
//显示新建表参数
//=======================================================================================================
void show_new_table_para(void)
{
int i,j;
languge_mode(English,yes); //切换语言
//如果存在数据,则显示
if(sample_new_table.Is_data_exist==yes)
{
for(i=0;i<sample_new_table.colomn;i++)
{
for(j=0;j<10;j++)
{
set_caract_pos(sample_new_table.ins_dot[j].x,sample_new_table.ins_dot[j].y+sample_new_table.v_step*i);
set_window_char(sample_new_table.str[i][j]); //显示字符
//打两个时间间隔符
set_caract_pos(sample_new_table.ins_dot[5].x+8,sample_new_table.ins_dot[5].y+sample_new_table.v_step*i);
set_window_char('/');
set_caract_pos(sample_new_table.ins_dot[7].x+8,sample_new_table.ins_dot[7].y+sample_new_table.v_step*i);
set_window_char('/');
}
}
}
}
//=============================================================================================================================
//新建表的编辑输入
//==============================================================================================================================
void new_table_edit(unsigned int cmd, unsigned char dat)
{
set_caract_color(0x4f,0x00);
if(edit_enable==yes)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -