📄 program.c
字号:
}
// 1. Display the clerk description
if((mode == 0xff)||(mode == j*MAX_CLERK_STEP))
{
memset(Text_Lcd.text[j*4+1], 0x20, MAX_TEXT);
len = strlen(Str_Name);
xtr_strcpy(Text_Lcd.text[j*4+1]+SUB_STEP_POSI, Str_Name);
memcpy(Text_Lcd.text[j*4+1]+ LCD_POSI_NOR, clerk[i].desc, Get_Desc_Len(clerk[i].desc, MAX_DESC_LEN));
}
// 2. Display the clerk password
if((mode == 0xff)||(mode == j*MAX_CLERK_STEP+1))
{
memset(Text_Lcd.text[j*4 +2], 0x20, MAX_TEXT);
len = strlen(Str_PassCode);
xtr_strcpy(Text_Lcd.text[j*4 +2]+SUB_STEP_POSI, Str_PassCode);
LongtoAsc(Text_Lcd.text[j*4 +2]+ LCD_POSI_NOR, clerk[i].secret, 4);
}
// Display a blank line
if(mode == 0xff)
{
memset(Text_Lcd.text[j*4 +3], 0x20, MAX_TEXT);
}
}
Lcd_Reflush_List((mode == 0xff) ? 0 : 1);
// Display the note information
Lcd_Disp_Str_Btn(BUF_ID_TL_SUB, Str_Clerk_Prog_Step_desc[Idx%MAX_CLERK_STEP]);
Last_Prg_Idx = clerk_idx;
Last_Prg_Step = (clerk_idx - screen_idx)*MAX_CLERK_STEP + Idx%MAX_CLERK_STEP;
}
/* Update the clerk attribute */
byte PMD_Updt_Clerk(byte Idx)
{
byte clerk_idx;
byte prg_step;
clerk_idx = Idx/MAX_CLERK_STEP;
prg_step = Idx%MAX_CLERK_STEP;
switch(prg_step)
{
case CLERK_DESC_STEP:
Lcd_Disp_Str_Btn(BUF_ID_TL_SUB, Str_Modify_Step[1]);
if(Get_Desc(clerk[clerk_idx].desc,MAX_DESC_LEN_EX,NO) == OK)
// modi_flag = 1;
return OK;
return NG;
case CLERK_PAWD_STEP:
Lcd_Disp_Str_Btn(BUF_ID_TL_SUB, Str_Modify_Step[2]);
if(Get_Num_Input() != OK)
return NG;
if (numcnt > 4)
{errorType(ERR_DIGIT_ILLEGAL);return NG;}
clerk[clerk_idx].secret = lnum;
return OK;
}
return NG;
}
/* Program the clerk attribute */
void pClerk(byte Idx_Step)
{
word key;
Lcd_Send_Text_Buff_Str(BUF_ID_TL_TITLE, 1, Str_ProgMain_Menu[2], ALIGN_MID);
Lcd_Disp_Text_Buff(BUF_ID_TL_TITLE);
Idx_Step = MAX_CLERK_STEP * Idx_Step ;
Last_Prg_Idx = IDX_NULL;
Last_Prg_Step = STEP_NULL;
while(1)
{
PMD_Disp_Clerk(Idx_Step);
// key = GetKey();
if (GetIn() == NG)
continue;
GetMainMode();
if (MainMode != CurrMode) // Change the control lock
{
return;
}
switch(InCmd)
{
case KD_CLEAR: // Clear the current information of inputing.
break;
case KD_ENTER: // Change the clerk attribute.
if(numcnt)
{
if((lnum >0)&&(lnum <= Max_Clerk_No)&&(Idx_Step%MAX_CLERK_STEP ==0))
{
Idx_Step = (lnum-1)*MAX_CLERK_STEP;
break;
}
else
{
errorType(ERR_DIGIT_ILLEGAL);
break;
}
}
if (PMD_Updt_Clerk(Idx_Step) == NG)
continue;
Idx_Step = (Idx_Step + 1)%(MAX_CLERK_CNT * MAX_CLERK_STEP);
break;
case KD_UP: // Display the previous attribute or previous clerk.
case KD_DOWN: // Display the next attribute or next clerk.
case KD_PAGE_UP: // Display the previous page clerk
case KD_PAGE_DOWN: // Display the next page clerk
Do_Clerk_Roll(InCmd, &Idx_Step);
break;
case KD_CANCEL: // Exit the program operation.
return;
default :
bellcnt = 0x01;
break;
}
}
}
/*Get the chioce of YES or NO,
if failed to get the choice , return oxff,
else return KD_YES or KD_NO
*/
byte Get_Sure_Done(byte *ret)
{
const char *Str_ptr[2];
Str_ptr[0] = STR_YES_No[1];
Str_ptr[1] = STR_YES_No[0];
Lcd_Disp_Str_Btn(BUF_ID_TL_SUB, Str_Modify_Step[4]);
return Get_Btn_Choice_Input_Ex(Str_ptr, 0x22, 2, ret);
}
/* Check the plu refresh or not */
BOOL Chk_Text_Refresh(byte prg_idx)
{
if (Last_Prg_Idx == IDX_NULL) /* The first programming */
return 0xff;
return Last_Prg_Step;
}
/* Do the PLU roll */
void Do_Text_Roll(word key, byte *idx_step)
{
long max_step = MSG_HEAD_LINES;
long step = *idx_step + max_step;
if(( key == KD_PAGE_UP)||(key == KD_PAGE_DOWN))
{
return;
}
else if (key == KD_DOWN)
{
step += 1;
}
else if (key == KD_UP)
{
step -= 1;
}
step %= max_step; /* Get the true step */
*idx_step = step;
}
/* Dispaly the header message information */
/*
flag == 0 ==> Header Message
flag == 1 ==> Footer Message
*/
void PMD_Disp_Header_Footer(byte line, byte flag)
{
byte i,j,k;
byte mode;
byte Max_Line;
byte str[MAX_TEXT+1];
byte len;
Max_Line = (flag)? MSG_BTM_LINES : MSG_HEAD_LINES;
mode = Chk_Text_Refresh(line);
if(mode == 0xff)
{
Rst_Lcd_Text(); /* Reset the text */
}
Text_Lcd.CurrLine = line*2+1;
for(i = 0; i < Max_Line; i++)
{
if(mode == 0xff)
{
memset(Text_Lcd.text[i*2], 0x20, MAX_TEXT);
len = strlen(Str_Head_Foot_Msg_Step[3]);
xtr_strcpy(Text_Lcd.text[i*2], Str_Head_Foot_Msg_Step[3]);
Text_Lcd.text[i*2][len] = i+'1';
}
if((mode == 0xff)||(mode == i))
{
memset(Text_Lcd.text[i*2+1], 0x20, MAX_TEXT);
for (j=0; j<MAX_PRN_LEN; j++)
{
if(flag == 0)
Text_Lcd.text[i*2+1][j] = Wlcm_Msg[i][3+2*j];
else
Text_Lcd.text[i*2+1][j] = Btm_Msg[i][3+2*j];
}
}
}
Lcd_Disp_Str_Btn(BUF_ID_TL_SUB, Str_Modify_Step[0]);
Lcd_Reflush_List((mode== 0xff)?0:1);
Last_Prg_Idx = 0;
Last_Prg_Step = line;
}
/* Update weclome message information */
/*
flag == 0 ==> Header Message
flag == 1 ==> Footer Message
*/
byte PMD_Updt_Header_Footer(byte line, byte flag)
{
Lcd_Disp_Str_Btn(BUF_ID_TL_SUB,Str_Text_Msg_Desc);
Lcd_Disp_Str_Btn(BUF_ID_TL_INPUT, Str_Modify_Step[1]);
if(flag == 0)
{
if(Get_Desc(&Wlcm_Msg[line][2],MAX_PRN_LEN,YES) == OK);
return OK;
}
else
{
if(Get_Desc(&Btm_Msg[line][2],MAX_PRN_LEN,YES) == OK);
return OK;
}
return NG;
}
/* Program welcome message */
/*
flag == 0 ==> Header Message
flag == 1 ==> Footer Message
*/
void pWlcm_Btm_Msg(byte line, byte flag)
{
byte length;
Lcd_Send_Text_Buff_Str(BUF_ID_TL_TITLE, 1, Str_Head_Foot_Msg_Step[flag], ALIGN_MID);
Lcd_Disp_Text_Buff(BUF_ID_TL_TITLE);
Last_Prg_Idx = IDX_NULL;
Last_Prg_Step = STEP_NULL;
while(1)
{
PMD_Disp_Header_Footer(line, flag);// Display the welcome message.
if (GetIn() == NG)
continue;
if(GetMainMode() != CurrMode)
return;
switch(InCmd)
{
case KD_CLEAR:
break;
case KD_UP:
case KD_PAGE_UP:
case KD_DOWN:
case KD_PAGE_DOWN:
Do_Text_Roll(InCmd, &line);
break;
case KD_ENTER:
if(PMD_Updt_Header_Footer(line, flag) != OK)// Update the welcome message
break;
line = (line + 1) % MSG_HEAD_LINES;
break;
case KD_CANCEL:
return;
}
}
}
void pText_Msg(void)
{
byte step_Idx = 0;
byte Update_Menu_flag = 0;
byte rsult;
while(1)
{
if(GetMainMode() != CurrMode)
return;
if(Update_Menu_flag == 0)
{
Lcd_Send_Text_Buff_Str(BUF_ID_TL_TITLE, 1, Str_ProgMain_Menu[4], ALIGN_MID);
Lcd_Disp_Text_Buff(BUF_ID_TL_TITLE);
Lcd_Disp_Str_Btn(BUF_ID_TL_SUB, Str_Prog_Enter);
}
rsult = Get_Prog_Menu(Str_Head_Foot_Msg_Step,&step_Idx, TEXT_SET_MENU, 1, Update_Menu_flag, 0);
Update_Menu_flag = 1;
if(rsult != OK)
{
step_Idx =0;
return;
}
if(step_Idx > TEXT_SET_MENU)
step_Idx = 0;
Update_Menu_flag = 0;
if(step_Idx != TEXT_SET_MENU-1)
pWlcm_Btm_Msg(0, step_Idx);
else
{
byte j;
byte ret;
if(Get_Sure_Done(&ret) != OK)
continue;
step_Idx = 0;
if(ret != KD_YES)
continue;
for(j = 0; j < MSG_HEAD_LINES; j ++)
Prn_InitDesc(&Wlcm_Msg[j][2], MAX_PRN_LEN, Str_RoyalMsg[j], NM_FONT_PRN, NM_FONT_PRN);
for(j = 0; j < MSG_BTM_LINES; j ++)
Prn_InitDesc(&Btm_Msg[j][2], MAX_PRN_LEN, Str_Null, NM_FONT_PRN, NM_FONT_PRN);
}
}
}
void pOptions(void)
{
byte reflush_flag = 0;
byte step_Idx = 0;
byte rsult;
Last_Prg_Idx = IDX_NULL;
Last_Prg_Step = STEP_NULL;
while(1)
{
if(GetMainMode() != CurrMode)
return;
if(reflush_flag == 0)
{
Lcd_Send_Text_Buff_Str(BUF_ID_TL_TITLE, 1, Str_ProgMain_Menu[5], ALIGN_MID);
Lcd_Disp_Text_Buff(BUF_ID_TL_TITLE);
Lcd_Disp_Str_Btn(BUF_ID_TL_SUB, Str_Prog_Enter);
}
rsult = Get_Prog_Menu(Str_Option_Menu,&step_Idx, 3, 1, reflush_flag, 0);
reflush_flag = 1;
if(rsult != OK)
return;
switch(step_Idx)
{
case 0: reflush_flag =0; pPrn_flag(); break;
case 1: reflush_flag =0; pSysPara_flag(); break;
case 2: reflush_flag =0; pSys_Config(); break;
default:
step_Idx = 0;
break;
}
}
}
void Update_Prnflag_Get(BYTE Idx, DWORD *ret)
{
switch(Idx)
{
case 0: *ret = (DWORD)(BYTE*)&sys_flag.date_prn; break;
case 1: *ret = (DWORD)(BYTE*)&sys_flag.time_prn; break;
case 2: *ret = (DWORD)(BYTE*)&sys_flag.clerk_prn; break;
case 3: *ret = (DWORD)(BYTE*)&sys_flag.Header_prn; break;
case 4: *ret = (DWORD)(BYTE*)&sys_flag.footer_prn; break;
case 5: *ret = (DWORD)(BYTE*)&sys_flag.Tax_prn; break;
case 6: *ret = (DWORD)(BYTE*)&sys_flag.Tax_Ttl_prn; break;
case 7: *ret = (DWORD)(BYTE*)&sys_flag.Blank_Line_prn;break;
case 8: *ret = (DWORD)(BYTE*)&sys_flag.Subt_PressPrn; break;
case 9: *ret = (DWORD)(BYTE*)&sys_flag.Subt_Prn; break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -