📄 _edit.c
字号:
/* this is the _edit.c operation module, all the edit operation is done here. */
/* specification */
/* the system include the following module: */
/* _main.c
_edit.c
_io.c
_rs485.c */
/* define the include file */
#include <reg52.h>
#include "_main.h"
#include "_io.h"
#include "_edit.h"
#include "_prio.h"
#include "_prmain.h"
#include "_hzk.h"
#include "_prrs485.h"
/* define the HZ start X show coordinate in the screen */
uchar code ADHZP_X[8]={0,0,2,2,4,4,6,6};
/* define the HZ start Y show coordinate in the screen. */
uchar code ADHZP_Y[8] = {0,32,0,32,0,32,0,32};
/* define the number start X show coordinate in the screen */
uchar code ADNUP_X[8] = {0,0,2,2,4,4,6,6};
/* define the number start Y show coordinate in the screen */
uchar code ADNUP_Y[8] = {36,4,36,4,36,4,36,4};
/* define the modify flag start X show coordinate in the screen */
uchar code ADMD_X[8] = {0,0,2,2,4,4,6,6};
/* define the modify flag start Y show coordinate in the screen */
uchar code ADMD_Y[8] = {23,55,23,55,23,55,23,55};
/* define the offset address of every page. i.e. define the every
item's offset address in the data structure for every page. */
uchar code ADPAGE0[8] = {0,0,1,0,3,5,7,9};
uchar code ADPAGE1[8] = {11,12,13,0,0,0,0,0};
uchar code ADPAGE2[8] = {18,20,22,24,26,0,15,0};
/* define the hz information show address. */
uchar code HZINFORM[18] = {25,1,20,37,18,40,25,1,44,45,46,47,49,49,49,49,49,49};
uchar code ADHZINFO_X[9] = {4,6,6,6,6,6,4,6,6};
uchar code ADHZINFO_Y[9] = {4,4,4,4,36,36,4,36,4};
/* define the HZ offset address in the hzlib for every screen */
uchar code ADHZC[3][16] = {
5,36,31,10,35,4,15,28,35,32,0,32,35,34,0,34,
35,19,33,7,22,59,15,59,14,13,36,13,11,30,17,27,
42,0,42,0,42,0,42,0,0,21,16,3,8,59,26,6};
/* define the number offset address in the numlib */
uchar code ADNUC[17] = {0,7,14,21,28,35,42,49,56,63,70,77,84,91,98,105,112};
bit g_firstedit; /* the first enter edit status flag. */
bit g_firstmody; /* the first modify flag in edit status. */
bit g_generalbit;/* the general common bit. */
bit g_currentisshort; /* current program is the short wire mode. */
uchar g_transall; /* the communication flag, transfer all data flag. */
uchar g_dotstatus; /* the dot show status flag in float input. */
idata uchar g_dotshow; /* show the dot on/off in start-last mode. */
idata uchar g_deldot; /* the del comd show dot flag. */
idata uint g_uintreg0; /* the general uint register0. */
idata uint g_uintreg1; /* the general uint register1. */
idata uchar g_charreg0; /* the general char register0. */
idata uchar g_charreg1; /* the general char register1. */
idata uchar g_numshow[7]; /* define the number show group. */
/* the program begin here. */
/***************************************************************************
NAME: Init_Edit
FUNCTION: This procedure will initialize the edit status
INPUTS: NONE
OUTPUTS: NONE
***************************************************************************/
void Init_Edit ()
{
g_transall = CN_SEGSET; /* default, all the data is transfer. */
g_dotshow = CN_STARTSHOW; /* only show the start value. */
g_deldot = CN_STARTSHOW; /* the del comd show dot flag. */
g_dotstatus = CN_DOTSTA0;
g_firstedit = TRUE;
g_firstmody = TRUE;
}
/***************************************************************************
NAME: Edit_Refresh
FUNCTION: This procedure will refresh the system flag in edit status.
INPUTS: NONE
OUTPUTS: NONE
***************************************************************************/
void Edit_Refresh()
{
AD_STOPIN = 1; /* key hand signal input enable. */
AD_POSIN = 1; /* the cutter axle position detect signal input enable. */
EX0 = 0; /* EX0 interrupt disable. */
ET0 = 0; /* Timer0 Interruption disabled. */
TR0 = 0;
EA = 1;
}
/***************************************************************************
NAME: Item_Show
FUNCTION: This procedure will show the item in one page.
INPUTS: item counter,reverse flag
OUTPUTS: NONE
***************************************************************************/
void Item_Show(uchar d_itemcnter,bit d_reverse)
{
uchar i,j;
bit flag;
uchar indata;
uchar code *d_hzptr;
if(d_itemcnter%2==0) /* the left side item. i.e. 0,2,4,6 item */
{AD_CR_A2 = 0; AD_CR_A1 = 0;}
else /* the right side item. i.e. 1,3,5,7 item */
{AD_CR_A2 = 0; AD_CR_A1 = 1;}
for(i=0;i<2;i++) /* write 2 hz. */
{
flag = CN_CR_IN;
indata = CN_CR_XSTA+ADHZP_X[d_itemcnter];
Cr_Inst_Data(flag,indata); /* write the x start address. */
indata = CN_CR_YSTA+ADHZP_Y[d_itemcnter]+16*i;
Cr_Inst_Data(flag,indata); /* write the y start address. */
indata = d_itemcnter*2+i;
indata = ADHZC[g_pagecnter][indata];
d_hzptr = &ADHZLIB[(uint)(indata)*32];
Reset_Watchdog();
for(j=0;j<32;)
{
flag = CN_CR_DA;
indata = *d_hzptr;
if(d_reverse==TRUE)
{ indata = indata^0x0FF; } /* reverse the hz. */
Cr_Inst_Data(flag,indata); /* write the hz dot array */
d_hzptr++;
j++;
if(j==16)
{
flag = CN_CR_IN;
indata = CN_CR_XSTA+ADHZP_X[d_itemcnter]+1; /* the next line. */
Cr_Inst_Data(flag,indata);
indata = CN_CR_YSTA+ADHZP_Y[d_itemcnter]+16*i;
Cr_Inst_Data(flag,indata);
}
}
}
}
/***************************************************************************
NAME: Number_Show
FUNCTION: This procedure will show the number in one page.
INPUTS: the item counter,the number group start address
OUTPUTS: NONE
***************************************************************************/
void Number_Show(uchar d_itemcnter)
{
uchar i,j,k;
idata uchar w;
bit flag;
idata uchar indata;
uchar code *d_hzptr;
uchar idata *d_numptr;
d_numptr = g_numshow;
if(d_itemcnter%2==0) /* the left side number. i.e. 0,2,4,6 item number */
{AD_CR_A2 = 0; AD_CR_A1 = 0;}
else /* the right side number. i.e. 1,3,5,7 item number */
{AD_CR_A2 = 1; AD_CR_A1 = 0;}
flag = CN_CR_IN;
indata = CN_CR_XSTA+ADNUP_X[d_itemcnter];
Cr_Inst_Data(flag,indata); /* write the X start address. */
indata = CN_CR_YSTA+ADNUP_Y[d_itemcnter];
Cr_Inst_Data(flag,indata); /* write the Y start address. */
d_numptr = d_numptr+6; /* point to the last number. */
Reset_Watchdog();
for(i=0;i<7;i++)
{
if(*d_numptr==CN_NWHITE) /* it's not a number. */
{
d_numptr--;
}
else
{
break;
}
}
w = i; /* tempory save the i value .*/
for(j=0;j<7;j++)
{
if (d_itemcnter%2==0)
{
if(j==4) /* the 2nd segment. */
{
AD_CR_A2 = 0; AD_CR_A1 = 1;
flag = CN_CR_IN;
indata = CN_CR_XSTA+ADNUP_X[d_itemcnter];
Cr_Inst_Data(flag,indata); /* write the X start address. */
indata = CN_CR_YSTA;
Cr_Inst_Data(flag,indata); /* the 2nd segment Y start address. */
}
}
if(i>=7)
{
d_hzptr=&ADNUMLIBUP[ADNUC[CN_NWHITE]];
}
else
{
d_hzptr=&ADNUMLIBUP[ADNUC[*d_numptr]];
d_numptr--;
i++;
}
for(k=0;k<7;k++)
{
flag = CN_CR_DA;
indata = *d_hzptr;
Cr_Inst_Data(flag,indata);
d_hzptr++;
}
}
i = w;
d_numptr = &g_numshow[6-i];
if(d_itemcnter%2==0) /* the left side number. i.e. 0,2,4,6 item number */
{AD_CR_A2 = 0; AD_CR_A1 = 0;}
else /* the right side number. i.e. 1,3,5,7 item number */
{AD_CR_A2 = 1; AD_CR_A1 = 0;}
flag = CN_CR_IN;
indata = CN_CR_XSTA+ADNUP_X[d_itemcnter]+1;
Cr_Inst_Data(flag,indata); /* write the X start address. */
indata = CN_CR_YSTA+ADNUP_Y[d_itemcnter];
Cr_Inst_Data(flag,indata); /* write the Y start address. */
for(j=0;j<7;j++)
{
if (d_itemcnter%2==0)
{
if(j==4) /* the 2nd segment. */
{
AD_CR_A2 = 0; AD_CR_A1 = 1;
flag = CN_CR_IN;
indata = CN_CR_XSTA+ADNUP_X[d_itemcnter]+1;
Cr_Inst_Data(flag,indata); /* write the X start address. */
indata = CN_CR_YSTA;
Cr_Inst_Data(flag,indata); /* the 2nd segment Y start address. */
}
}
if(i>=7)
{
d_hzptr=&ADNUMLIBDOWN[ADNUC[CN_NWHITE]];
}
else
{
d_hzptr=&ADNUMLIBDOWN[ADNUC[*d_numptr]];
d_numptr--;
i++;
}
for(k=0;k<7;k++)
{
flag = CN_CR_DA;
indata = *d_hzptr;
Cr_Inst_Data(flag,indata);
d_hzptr++;
}
}
}
/***************************************************************************
NAME: Hzinfo_show
FUNCTION: This procedure will show the hz information.
INPUTS: hz select counter
OUTPUTS: NONE
***************************************************************************/
void Hzinfo_Show(uchar d_hzselect)
{
uchar i,j;
bit flag;
uchar indata;
uchar code *d_hzptr;
AD_CR_A2 = 1;
AD_CR_A1 = 0;
for(i=0;i<2;i++) /* write 2 hz. */
{
flag = CN_CR_IN;
indata = CN_CR_XSTA+ADHZINFO_X[d_hzselect];
Cr_Inst_Data(flag,indata); /* write the x start address. */
indata = CN_CR_YSTA+ADHZINFO_Y[d_hzselect]+16*i;
Cr_Inst_Data(flag,indata); /* write the y start address. */
indata = d_hzselect*2+i;
indata = HZINFORM[indata];
d_hzptr = &ADHZLIB[(uint)(indata)*32];
Reset_Watchdog();
for(j=0;j<32;)
{
flag = CN_CR_DA;
indata = *d_hzptr;
Cr_Inst_Data(flag,indata); /* write the hz dot array */
d_hzptr++;
j++;
if(j==16)
{
flag = CN_CR_IN;
indata = CN_CR_XSTA+ADHZINFO_X[d_hzselect]+1; /* the next line. */
Cr_Inst_Data(flag,indata);
indata = CN_CR_YSTA+ADHZINFO_Y[d_hzselect]+16*i;
Cr_Inst_Data(flag,indata);
}
}
}
d_hzptr=&ADNUMLIBDOWN[ADNUC[CN_NWHITE]];
for(i=0;i<17;i++)
{
flag = CN_CR_DA;
indata = *d_hzptr;
Cr_Inst_Data(flag,indata);
}
flag = CN_CR_IN;
indata = CN_CR_XSTA+ADHZINFO_X[d_hzselect]; /* the first line. */
Cr_Inst_Data(flag,indata);
indata = CN_CR_YSTA+ADHZINFO_Y[d_hzselect]+32;
Cr_Inst_Data(flag,indata);
d_hzptr=&ADNUMLIBUP[ADNUC[CN_NWHITE]];
for(i=0;i<17;i++)
{
flag = CN_CR_DA;
indata = *d_hzptr;
Cr_Inst_Data(flag,indata);
}
}
/***************************************************************************
NAME: Trinfo_show
FUNCTION: This procedure will show the transfer OK/Err information.
INPUTS: hz select counter
OUTPUTS: NONE
***************************************************************************/
void Trinfo_Show(uchar d_hzselect)
{
uchar i,j;
bit flag;
uchar indata;
uchar code *d_hzptr;
AD_CR_A2 = 0;
AD_CR_A1 = 0;
for(i=0;i<2;i++) /* write 2 hz. */
{
flag = CN_CR_IN;
indata = CN_CR_XSTA+ADHZINFO_X[d_hzselect];
Cr_Inst_Data(flag,indata); /* write the x start address. */
indata = CN_CR_YSTA+ADHZINFO_Y[d_hzselect]+16*i;
Cr_Inst_Data(flag,indata); /* write the y start address. */
indata = d_hzselect*2+i;
indata = HZINFORM[indata];
d_hzptr = &ADHZLIB[(uint)(indata)*32];
Reset_Watchdog();
for(j=0;j<32;)
{
flag = CN_CR_DA;
indata = *d_hzptr;
Cr_Inst_Data(flag,indata); /* write the hz dot array */
d_hzptr++;
j++;
if(j==12)
{
if(i==1)
{
AD_CR_A2 = 0; AD_CR_A1 = 1;
flag = CN_CR_IN;
indata = CN_CR_XSTA+ADHZINFO_X[d_hzselect];
Cr_Inst_Data(flag,indata); /* write the x start address. */
indata = CN_CR_YSTA;
Cr_Inst_Data(flag,indata);
}
}
if(j==28)
{
if(i==1)
{
AD_CR_A2 = 0; AD_CR_A1 = 1;
flag = CN_CR_IN;
indata = CN_CR_XSTA+ADHZINFO_X[d_hzselect]+1;
Cr_Inst_Data(flag,indata); /* write the x start address. */
indata = CN_CR_YSTA;
Cr_Inst_Data(flag,indata);
}
}
if(j==16)
{
AD_CR_A2 = 0; AD_CR_A1 = 0;
flag = CN_CR_IN;
indata = CN_CR_XSTA+ADHZINFO_X[d_hzselect]+1; /* the next line. */
Cr_Inst_Data(flag,indata);
indata = CN_CR_YSTA+ADHZINFO_Y[d_hzselect]+16*i;
Cr_Inst_Data(flag,indata);
}
}
}
d_hzptr=&ADNUMLIBDOWN[ADNUC[CN_NWHITE]];
for(i=0;i<17;i++)
{
flag = CN_CR_DA;
indata = *d_hzptr;
Cr_Inst_Data(flag,indata);
}
AD_CR_A2 = 0; AD_CR_A1 = 1;
flag = CN_CR_IN;
indata = CN_CR_XSTA+ADHZINFO_X[d_hzselect];
Cr_Inst_Data(flag,indata); /* write the x start address. */
indata = CN_CR_YSTA+4;
Cr_Inst_Data(flag,indata); /* write the y start address. */
d_hzptr=&ADNUMLIBUP[ADNUC[CN_NWHITE]];
for(i=0;i<17;i++)
{
flag = CN_CR_DA;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -