📄 tool.c
字号:
/******************************************************************************/
void Do_TaxEmp(void)
{
if(Tax_Emp_Flag)
VFDSetPeriod(5,SET);
else
VFDSetPeriod(5,CLR);
}
/******************************************************************************/
void Clr_Shift(void)
{
memset(shift_flag, 0, MAX_TAX_NUM);
Do_Shift(0);
Do_Shift(1);
Do_Shift(2);
Do_Shift(3);
// shift1_flag = 0;
// Do_Shift1();
// shift2_flag = 0;
// Do_Shift2();
// shift3_flag = 0;
// Do_Shift3();
}
/******************************************************************************/
void Clr_Tax_Flag(void) /* Clear the shift display */
{
if(!sysflag->Tax_System)
return;
Clr_Shift();
Tax_Emp_Flag = 0;
Do_TaxEmp();
}
/******************************************************************************/
void Do_Tax_Flag(void)
{
byte i;
if(!sysflag->Tax_System)
return;
for(i =0; i< MAX_TAX_NUM; i++)
Do_Shift(i);
// Do_Shift1();
// Do_Shift2();
// Do_Shift3();
Do_TaxEmp();
}
/****************************************************************************
* Get a key from keybuffer.
******************************************************************************/
word GetKey( void )
{
word key;
while(1)
{
if ( KPRP_BusyChk() != OK ) return(KD_CLEAR); /* Return a CLEAR key */
if( Ktail != Khead)
{
key = KeyBuffer[Ktail];
Ktail++;
if(Ktail == KEY_BUFF_SIZE)
Ktail = 0;
if( key != 0 )
{
#ifdef SCANNER /* Support the scanner function */
if(key == SPLU)
{
SpluKeyIn = SC_TranToBcd();
Logi_Code = key; /* Set the logical code SPLU */
return(key);
}
#endif /* Support the scanner function */
if (key == KD_PCLINK)
{
Logi_Code = key;
return (key);
}
if (key <= TS_LOGI_OFFSET) //硬键盘读入, 此处为POS 键盘输入
{
key = key_logi_get(key_logic,key,MAX_EXTEND_KEY); /* Return the logical key code. */
Logi_Code = key + 1; /* Get the logical key code, for the other use */
if (Ts_Key.last_logi != KD_NULL_LOGI)
Lcd_Draw_Button_REV(Ts_Key.last_logi, TS_KEY_IDLE);
return ( FF_Key_Get(key));
}
else //触摸屏键盘读入
{ // The touch screen key code
key = ts_get_logi(key); // The touch screen key logical from 1 to LCD_LAYOUT_MAX_KEY
Logi_Code = key + 1; // No use?
DEBUG_SET(Logi_Code = key;);
Ts_Key.last_logi = Ts_Key.curr_logi;
Ts_Key.curr_logi = key;
Ts_Key.key = TS_Key_Get(Ts_Key.curr_logi);
if (Ts_Key.last_logi != KD_NULL_LOGI)
Lcd_Draw_Button_REV(Ts_Key.last_logi, TS_KEY_IDLE);
if (Ts_Key.curr_logi != KD_NULL_LOGI)
Lcd_Draw_Button_REV(Ts_Key.curr_logi, TS_KEY_PRESS);
return (Ts_Key.key);
}
}
}
else
{
GetMainMode();
if (key_fd && Feed_Flag && (MainMode!=X_OFF) ) {
Key_Feed();
// Delay(10);
}
if( MainMode == CurrMode ) /* The control lock did't change, scan the key again */
continue;
if(sysflag->soft_lock_flag == 1)
return (CTRL_LOCK_CHG);
/* The next indicate the control lock has changed */
if((CurrMode == REGISTER) || (CurrMode == TRAINING)) /* Sale check */
{
if(NewTrans) /* The transaction not end, error */
{
bellcnt = 0xFF;
while ( GetMainMode() != CurrMode );
Clr_Key_Buff();
bellcnt = 0x00;
continue;
}
}
else if(CurrMode == PROGRAM) /* Program check */
{
if(progflag) /* The programing not end, error */
{
bellcnt = 0xFF;
while ( GetMainMode() != CurrMode );
Clr_Key_Buff();
bellcnt = 0x00;
continue;
}
}
else if((CurrMode == XREPORT) && (CurrMode == ZREPORT))
{
/* continue; */
}
return (CTRL_LOCK_CHG); /* The control changed, return 0FFH */
}/* end else */
} /* end while */
return(KD_NULL); /* Pesuedo return */
}
/*------------------------------------------------------------------------------
Delay routine used by APP.
The max delay time is 10S,
if want to delay more, should be use a circulation.
*-----------------------------------------------------------------------------*/
void Delay(int ms)
{
delay_cnt = 0;
while((int)delay_cnt<(int)ms);
}
/* The condition delay function, condition: when press a key or the control key lock is changed */
void CndtDelay(int ms)
{
delay_cnt = 0;
while((int)delay_cnt<(int)ms)
{
if(Chk_KeyPrs_LockChg(0) == NOTOK) /* One key has pressed, or the control lock is changed */
return;
}
}
/* The condition delay function, condition: when press a key or the control key lock is changed */
BOOL CndtDelay2(int ms)
{
delay_cnt = 0;
while((int)delay_cnt<(int)ms)
{
if(Chk_KeyPrs_LockChg(0) == NOTOK) /* One key has pressed, or the control lock is changed */
return FALSE;
}
return TRUE;
}
/*------------------------------------------------------------------------------
* system data initialize
*-----------------------------------------------------------------------------*/
void Data_Initial(void)
{
byte i;
Trng_Flag = 0; /*Only for sample*/
Lcd_Pop_Flag = 0;
Rpt_Disp_Roll_flag = 0;
Pop_Btn_Init();
LastMode = X_OFF; /* Set it is the lock mode */
#if 0 /*Only for sample*/
if(GetMainMode() == X_OFF) /* The lock mode, not to open the LCD backlight */
{
g_LCDBLCnt = 0;
LCD_Back(OFF);
}
else
LCD_Back_Set(); /* Set the LCD backlight along with the flag */
#endif
Calc_Flag = 0; /* Not in the calculation function */
#ifdef VER_RSNT /* Support the restaurant function */
prn_LstSpndAmt_flag = 1;
if(Trng_Flag == 1) /* If the flag is 1, indicate the last operation is TRAINING, so clear the buffer */
{
for(i = 0; i < Max_Table_No; i ++)
Clr_Table(i);
}
waiter_input_flag = 0;
send_ec_flag = 0;
prn_rm_flag = 0;
#endif /* End VER_RSNT */
// Trng_Flag = 0;
#ifdef SCANNER /* Support the scanner function */
ProgBar = 0;
#endif /* End SCANNER */
#ifdef AUTO_PER /* Support the department auto percent function */
Auto_Per_Flag = 0;
#endif /* End AUTO_PER */
Head_Prn_Flag = 1;
PPLU_Group_Flag = 0;
#ifdef RCPT_REPRN /* Support the receipt reprint function */
Rcpt_Reprn_Flag = 0;
#endif /* End RCPT_REPRN */
prn_tab_pre_flag = 0;
Logo_Prn_Flag = 1;
pass_flag = 0;
Feed_Flag = 1;
en_long_dec_input_flag = 0;
// if((save_flag&0x01) != 0)
// Push_Pop_Port_Status(POP, 0xFF, PORT0);
// if((save_flag&0x10) != 0)
// Push_Pop_Port_Status(POP, 0xFF, PORT1);
Idvul_Head_Prn_Flag = NOTPRINTD;
ra_flag = po_flag = 0;
#ifdef REST_PLU_FUNC
PPLU_Menu_Flag = 0;
prn_gift_symbol_flag = 0;
#endif
TS_keyenable =1;
TS_Init_Flag = 0;
// Line_Feed(2); /* Print one blank line */
// Lcm_Plus();
Lcd_Set_Mode(LCD_10_INCH);
Lcd_Set_Color(LCD_COLORFUL);
Rst_Ts_Lcd();
}
/**********************************************************
Get the work mode and set the LCD backlight
when the mode is changed.
**********************************************************/
byte GetMainMode(void)
{
if(LastMode != currmodeInt)
{
if(currmodeInt != X_OFF) /* When the current mode is change, set the LCD backlignt */
LCD_Back_Set();
else
{
g_LCDBLCnt = 0;
LCD_Back (OFF); /* In the lock mode, clear the LCD backlight */
}
LastMode = currmodeInt;
}
MainMode = currmodeInt;
if((Trng_Flag == 1) && (MainMode == REGISTER))
MainMode = TRAINING;
if (LCD_7_INCH == Lcd_Mode) /* In the 7 inch mode */
MainMode = REGISTER;
return (MainMode); /* Return the current main mode. */
}
/*-----------------------------------------------------------------*
* Function: Format the print number(long) in the print buffer
* Parameter: num: the long number.
* dots: the radix point position.
* Location: the start position in the print buffer
* Direction: The put direction in the print buffer.
* Return: void.
*-----------------------------------------------------------------*/
void LongPrnFmt(long num, char dots, byte Location, byte Direction)
{
byte tmp[MAX_LENGTH_15];
byte len;
byte sto_dot = 0;
byte sto_aster = 0;
byte adj = 0;
if((Location > MAX_PRN_LEN) || (Location < 1)) /* When the locate position is illegal, return */
return;
Get_Sto_Flag(&sto_dot, &adj, &sto_aster);
#if SW_VER == SW_NE2
len = LongAndDot2Str(num, dots, tmp, sto_dot, adj, sto_aster, 1);
#else
len = LongAndDot2Str(num, dots, tmp, sto_dot, adj, sto_aster, 0);
#endif
/* Store the data in the print buffer */
if(Direction == LEFTFLUSH) /* LEFTFLUSH */
{
if(len+Location > MAX_PRN_LEN) /* When the length is over the array. */
len = MAX_PRN_LEN - Location + 1;
memcpy(prn_Buf+Location, tmp+MAX_LENGTH_15-len, len);
}
else if(Direction == RIGHTFLUSH) /* RIGHTFLUSH */
{
if(len > Location)
len = Location;
memcpy(prn_Buf+Location-len+1, tmp+MAX_LENGTH_15-len, len);
}
}
/*-----------------------------------------------------------------*
* Function: Format the print number(long) in the destination buffer
* Parameter: dst: The destination buffer.
* num: the long number.
* dots: the radix point position.
* Location: the start position in the print buffer.
* Direction: The put direction in the print buffer.
* Return: void.
*-----------------------------------------------------------------*/
byte LongPrnFmt_Plus(byte *dst, long num, char dots, byte Location, byte Direction)
{
byte tmp[MAX_LENGTH_15];
byte len;
byte sto_dot = 0;
byte sto_aster = 0;
byte adj = 0;
if((Location < 1)) /* When the locate position is illegal, return */
return (0);
SetNoAsterPrn(); /* Not to print the aster and split character */
SetNoSplitPrn();
Get_Sto_Flag(&sto_dot, &adj, &sto_aster);
#if SW_VER == SW_NE2
len = LongAndDot2Str(num, dots, tmp, sto_dot, adj, sto_aster, 1);
#else
len = LongAndDot2Str(num, dots, tmp, sto_dot, adj, sto_aster, 0);
#endif
/* Store the data in the print buffer */
if(Direction == LEFTFLUSH) /* LEFTFLUSH */
{
memcpy(dst+Location, tmp+MAX_LENGTH_15-len, len);
}
else if(Direction == RIGHTFLUSH) /* RIGHTFLUSH */
{
memcpy(dst+Location-len+1, tmp+MAX_LENGTH_15-len, len);
}
return (len);
}
/*设置打印'*'符号*/
void SetAsterPrn(void)
{
aster_prn_flag = TRUE;/**/
}
/*************************/
void ClrAsterPrn(void)
{
aster_prn_flag = FALSE;
}
/*************************/
BOOL ChkAsterPrn(void)
{
#if SW_VER == SW_NE2
return (aster_prn_flag);
#else /* SW_VER */
return 0;
#endif /* SW_VER */
}
/*************************/
void SetSplitPrn(void)
{
split_prn_flag = TRUE;
}
/*************************/
void ClrSplitPrn(void)
{
split_prn_flag = FALSE;
}
/*************************/
BOOL ChkSplitPrn(void)
{
#if SW_VER == SW_NE2
return (split_prn_flag);
#else /* SW_VER */
return 0;
#endif /* SW_VER */
}
/*----------------------------------------------------------------------------------------*
* Check the sale mode is right or not *
*----------------------------------------------------------------------------------------*/
void Cont_Sale_Check(void)
{
if(Trng_Flag == 1) /* The trainings mode power down */
{
prn_Line('*');
// memcpy(prn_Buf+1, Str_Trng_Pwr_Dwn, MAX_PRN_LEN);
xtr_strcpy(prn_Buf+1, Str_Trng_Pwr_Dwn);
print();
prn_Line('*');
prn_Line('-');
prn_Stamp();
return;
}
if(continue_sale_flag == 0xAA)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -