⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tool.c

📁 一款收款机C源代码!因为是几年前的代码了
💻 C
📖 第 1 页 / 共 5 页
字号:
                    if(sysflag->tax_shift_mode)			/* When return, set the tax flag when the shift function is stay-down */
                	    Do_Tax_Flag();
					Rst_Tl_Sub();
					Lcd_Disp_Text_Buff(BUF_ID_TL_SUB);
                    return;

                case KD_XTIME:
                    DateTime = !DateTime;		/* Reverse the flag */
                    break;

				case KD_RCPT_ON:
					GetKey();
					sysflag->Rcpt_prn = !sysflag->Rcpt_prn;
					disp_receipt_prn_mode();
					Clr_Dsp_Data();
					RightDisp(0, sysflag->sysdots);
                    if(sysflag->tax_shift_mode)			/* When return, set the tax flag when the shift function is stay-down */
               	        Do_Tax_Flag();
					Rst_Tl_Sub();
					Lcd_Disp_Text_Buff(BUF_ID_TL_SUB);
					return;
                case KD_FEED:
                    break;

                default:				/* Default key, not to clear the key buffer */
                    Clr_Dsp_Data();
                    RightDisp(0L,sysflag->sysdots);
                    if(sysflag->tax_shift_mode)			/* When return, set the tax flag when the shift function is stay-down */
               	        Do_Tax_Flag();
					Rst_Tl_Sub();
					Lcd_Disp_Text_Buff(BUF_ID_TL_SUB);
                    return;
            }
            GetKey();
        }
   	    if(key_fd)			/* If the FEED key continuous pressing, feed the paper */
   		    Key_Feed();

        GetMainMode();
        if(MainMode!=CurrMode) 
        {
			Rst_Tl_Sub();
			Lcd_Disp_Text_Buff(BUF_ID_TL_SUB);
            return;
        }
    }   /* end while */    
}	/* end DisTime() */
#else
void DisTime(void)	/* Display thte time to the LCD */
{
   byte month, day, year;
	byte hour, minute, second;

	word key;			/* The press key code */
	byte time_buff[MAX_LCD_NUM];
	byte time_bak[MAX_LCD_NUM];
	byte date_buff[9];
	byte date_bak[9];
	byte mon_posi_1, mon_posi_2;
	byte day_posi_1, day_posi_2;
	byte year_posi_1, year_posi_2;

	char lcd2_buff[MAX_LCD2_LEN+1];
	char bak_lcd2_buff[MAX_LCD2_LEN+1];
		/* The display style: [12/10/05  15:43:30] */
		/*                     12345678901234567890123456  */

   Clr_Period();		/* Clear the decimal point display */
	Disp_Spec_Period();
	Lcm_Disp_Clr(LCM_LINE_1 ,FALSE);
	//Clr_Dsp_Data();	/* Clear the last display to the LCD */
	RM_flag = 0;		/* If the flag is 1, clear it */

	if (sysflag->datefmt == 0) {	/* MDY */
		mon_posi_1 = 0;
		mon_posi_2 = 1;
		day_posi_1 = 3;
		day_posi_2= 4;
		year_posi_1 = 6;
		year_posi_2= 7;
	}
	else if (sysflag->datefmt == 1) {	/* DMY */
		mon_posi_1 = 3;
		mon_posi_2= 4;
		day_posi_1 = 0;
		day_posi_2= 1;
		year_posi_1 = 6;
		year_posi_2= 7;
	}
	else {	/* YMD */
		mon_posi_1 = 3;
		mon_posi_2= 4;
		day_posi_1 = 6;
		day_posi_2= 7;
		year_posi_1 = 0;
		year_posi_2= 1;
	}

	while(1)
   {
			disint();
			year = GetYear();
			month = GetMonth();
			day = GetDay();
			hour = GetHour();
			minute = GetMinute();
			second = GetSecond();
			enint();

         memset(time_buff, ' ', MAX_LCD_NUM);
         memset(time_buff, ':', 6);
         time_buff[0]=(char)(hour/10+'0');			/* hour */
         time_buff[1]=(char)(hour%10+'0');
         time_buff[3]=(char)(minute/10+'0');		/* minute */
         time_buff[4]=(char)(minute%10+'0');
         time_buff[6]=(char)(second/10+'0');		/* second */
         time_buff[7]=(char)(second%10+'0');


         if(memcmp(time_buff, time_bak, MAX_LCD_NUM) != 0)
         {
         	memcpy(time_bak, time_buff, MAX_LCD_NUM);
         	VFDDisplay(time_buff, NOTCLEARD, 3-1+3);

				memset(lcd2_buff, ' ', MAX_LCD2_LEN);
				lcd2_buff[mon_posi_1] = month/10 + '0';
				lcd2_buff[mon_posi_2] = month%10 + '0';
				lcd2_buff[2] = '/';
				lcd2_buff[day_posi_1] = day/10 + '0';
				lcd2_buff[day_posi_2] = day%10 + '0';
				lcd2_buff[5] = '/';
				lcd2_buff[year_posi_1] = year/10 + '0';
				lcd2_buff[year_posi_2] = year%10 + '0';
				lcd2_buff[10] = hour/10 + '0';
				lcd2_buff[11] = hour%10 + '0';
				lcd2_buff[12] = ':';
				lcd2_buff[13] = minute/10 + '0';
				lcd2_buff[14] = minute%10 + '0';
				lcd2_buff[15] = '\0';
				if (memcmp(lcd2_buff, bak_lcd2_buff, 15) != 0) {
					memcpy(bak_lcd2_buff, lcd2_buff, 15);
					Lcd_Send_Text_Buff_Str(BUF_ID_TL_SUB, 1, lcd2_buff, ALIGN_MID);
					Lcd_Disp_Text_Buff(BUF_ID_TL_SUB);
				}
//				lcd2_buff[15] = ':';
//				lcd2_buff[16] = second/10 + '0';
//				lcd2_buff[17] = second%10 + '0';
				#if 0
				Lcd_Send_Text_Buff_Mem(BUF_ID_TL_SUB, 1, lcd2_buff, 18, ALIGN_MID);
//				Lcd_Send_Text_Buff_Str(BUF_ID_TL_SUB, 1, lcd2_buff, ALIGN_MID);
				Lcd_Disp_Text_Buff(BUF_ID_TL_SUB);
				#endif
      	}

         memset(date_buff,'/',8);
        // disp_buff[0] = ' ';

         if(sysflag->datefmt==2)				/* Chinese date format YY-MM-DD */
         { 
            date_buff[1-1] = year /10 + '0';				/* year */
            date_buff[2-1] = year % 10 + '0';
            date_buff[4-1] = month / 10 + '0';       	/* month */
            date_buff[5-1] = month % 10 + '0';
            date_buff[7-1] = day / 10 + '0';         	/* day */
            date_buff[8-1] = day % 10 + '0';
         }

         else if(sysflag->datefmt==0)		/* American date format MM-DD-YY */
         {
            date_buff[1-1] = month / 10 + '0';        /* month */
            date_buff[2-1] = month % 10 + '0';
            date_buff[4-1] = day / 10 + '0';          /* day */
            date_buff[5-1] = day % 10 + '0';
            date_buff[7-1] = year / 10 + '0';			/* year */
            date_buff[8-1] = year % 10 + '0';
         }

         else if(sysflag->datefmt == 1)	/* English date format DD-MM-YY */
         {
             date_buff[1-1] = day / 10 + '0';         /* day */
             date_buff[2-1] = day % 10 + '0';
             date_buff[4-1] = month / 10 + '0';       /* month */
             date_buff[5-1] = month % 10 + '0';
             date_buff[7-1] = year / 10 + '0';        /* year */ 		
             date_buff[8-1] = year % 10 + '0';
         }
         else
   			sysflag->datefmt = 1;				/* When the other format, set it to the English format */
//        	VFDDisplay(disp_buff, NOTCLEARD, LEFT);		/* Display the year to the LCD */
			date_buff[8]='\0';
			if(memcmp(date_buff, date_bak, 8) != 0)
         {
         	memcpy(date_bak, date_buff, 9);
         	//VFDDisplay(disp_buff, NOTCLEARD, LEFT);		/* Display the year to the LCD */
         	Lcm_Disp_Str( date_buff ,LCM_LINE_2 ,ALIGN_MID, FALSE);
      	}
      
	
      if(KBPress())           /* Judge one key perssed */
      {
         key = Rcode(KBCheck());		/* Get the key code */
         switch(key)
         {
            case KD_CASH:
					#ifdef RCPT_REPRN				/* Support the receipt reprint function */
					if(Rcpt_RePrn_Cnt != 0)		/* Reprint the receipt */
					{
						Clr_Dsp_Data();			/* Clear the last disp */
	               RightDisp(0L,sysflag->sysdots);
//						RePrn_Rcpt(1);
						Rst_Tl_Sub();
						Lcd_Disp_Text_Buff(BUF_ID_TL_SUB);
						return;
					}
					#endif /* End RCPT_REPRN */
            case KD_CHECK:		/* Do nothing */
            case KD_CHARGE:
            case KD_SUBTTL:
               break;

            case KD_CLEAR:
               GetKey();		/* Clear the key buffer */
               Clr_Dsp_Data();
               RightDisp(0L,sysflag->sysdots);
               if(sysflag->tax_shift_mode)			/* When return, set the tax flag when the shift function is stay-down */
               	Do_Tax_Flag();
					Rst_Tl_Sub();
					Lcd_Disp_Text_Buff(BUF_ID_TL_SUB);
               return;

            case KD_XTIME:
               //DateTime = !DateTime;		/* Reverse the flag */
               break;

				case KD_RCPT_ON:
					GetKey();
					sysflag->Rcpt_prn = !sysflag->Rcpt_prn;
					disp_receipt_prn_mode();
					Clr_Dsp_Data();
					RightDisp(0, sysflag->sysdots);
               if(sysflag->tax_shift_mode)			/* When return, set the tax flag when the shift function is stay-down */
               	Do_Tax_Flag();
					Rst_Tl_Sub();
					Lcd_Disp_Text_Buff(BUF_ID_TL_SUB);
					return;
            case KD_FEED:
//            	Key_Feed();
               break;

            default:				/* Default key, not to clear the key buffer */
               Clr_Dsp_Data();
               RightDisp(0L,sysflag->sysdots);
               if(sysflag->tax_shift_mode)			/* When return, set the tax flag when the shift function is stay-down */
               	Do_Tax_Flag();
					Rst_Tl_Sub();
					Lcd_Disp_Text_Buff(BUF_ID_TL_SUB);
               return;
         }
         GetKey();
      }
   	if(key_fd)			/* If the FEED key continuous pressing, feed the paper */
   		Key_Feed();
//   	else					/* Not the FEED key press, delay 20ms */
//   		Delay(20);

      GetMainMode();
      if(MainMode!=CurrMode) {
			Rst_Tl_Sub();
			Lcd_Disp_Text_Buff(BUF_ID_TL_SUB);
         return;
      }
   }   /* end while */    
}	/* end DisTime() */
#endif


/******************************************************************************/
void TransDis(byte ch)
{
   char  i;
   #ifdef SCANNER			/* Support the scanner function */
   char j;
   #endif /* End SCANNER */

	if(pass_flag == 1)	/* Not to dispaly the input digit data */
	{
		if(mode_disp_flag)		/* Dispalying the mode */
		{
			Clr_Dsp_Data();
			VFDDisplay(Disp_Input_Pass, NOTCLEARD, LEFT);			/* Dispaly the information */
			mode_disp_flag = 0;
		}
		return;
	}
	if(MainMode == X_OFF)		/* Lock mode, not display anything */
		return;
    if ( ((MainMode == REGISTER)||(MainMode == TRAINING)) && (currclerk == NUL_VLU) 
   			&& (sysflag->clerk_mode)/* || (MainMode == ZREPORT && z_scrt_flag) */)
    {
   	    Clr_Dsp_Data();
        VFDDisplay(Disp_Sale_Clerk_Assign,NOTCLEARD,LEFT);		/* Display OP in the left position */
        return;
    }
    #ifdef VER_RSNT 				/* Support the restaurant function */
    if(waiter_input_flag)
    {
   	    Clr_Dsp_Data();
   	    VFDDisplay(Disp_Sale_Waiter_Assign, NOTCLEARD, LEFT);
   	    return;
    }
    #endif /* End VER_RSNT */

	Clr_Dsp_Data();
	#ifdef SCANNER			/* Support the scanner function */
	j = MAX_LCD_NUM;
	for(i = ch; (i > 0)&&(j > 0); i --)
		Insert_Num(In_Buff[i-1], -- j);
	#else /* Else SCANNER */
    for(i = 0 ; i < ch ; i ++)
        Insert_Num(In_Buff[i],MAX_LCD_NUM-ch+i);
    #endif /* End SCANNER */
    if( dec_flag == 1 )
    {
   	    VFDSetPeriod(MAX_LCD_NUM - sysflag->sysdots - 1,CLR);		/* Clear the sysdots display */
   	    Insert_Period(MAX_LCD_NUM - dec_cnt - 1);						/* Set the input dots display */
    }

	Lcd_Tl_Input_Disp(TL_INPUT_INPUTING, 0);
}

/*---------------------------------------------------------------------------------------
*  Get the department key sequence accorind to the input key code.
*  Input    :  None
*              
*  Output   :  Dept index ( 1 -- 24 )
*  
*  When the department shift mode is one shot mode, clear the flag.
I
*  03-8-13 10:52
*--------------------------------------------------------------------------------------*/
byte getDept(void)
{
   word i;
   
   if((InCmd >= KD_DP_ST)&&(InCmd <= KD_DP_END))
        i = InCmd - KD_DP_ST;
   else
        i = MAX_DEPT_CNT;
   
   i += (word)DeptShiftFlag *( sysflag->Dept_Shift_Inc);
   if(i >  MAX_DEPT_CNT)
        i = MAX_DEPT_CNT;
   return ( i );
}
word getDPLU(void)
{
   word i;

   if((InCmd >= KD_DPLU_ST)&&(InCmd <= KD_DPLU_END))
        i = InCmd - KD_DPLU_ST;
   else
        i = MAX_DPLU_KEY;
   
   i += (word)DPLUShiftFlag *( sysflag->DPLU_Shift_Inc);

   return ( i );
}

#ifdef	REST_PLU_FUNC
byte getmenu(void)
{
	byte i;
   for (i = 0; i < MAX_MENU_KEY_CNTR; i ++)
   { 
      if ( InCmd == menutab[i] )
         break;
   }
   return(i);
}	
#endif

/*------------------------------------------------------------------*
   功能:
   1. 清除LCD, VFD 的输入显示
   2. 清除输入框的字符显示
*------------------------------------------------------------------*/
void Do_Clear(void)
{
	if((CurrMode == REGISTER) || (CurrMode == TRAINING))		/* Sale mode, clear the flag */
	{
       	if(!sysflag->tax_shift_mode)
       		Clr_Tax_Flag();
       	Clr_Staus_Flag();
  	}

	//Disp_Mode();
  	Clr_Dsp_Data();
  	RightDisp(0L, sysflag->sysdots);
	Lcd_Tl_Input_Disp(TL_INPUT_CLEAR, 0);
}

/******************************************************************************/
void Do_Shift(byte Idx)
{
	if(shift_flag[Idx])
      VFDSetPeriod(3+Idx,SET);
	else
      VFDSetPeriod(3+Idx,CLR);
}
void Do_Shift1(void)
{
	if(shift1_flag)
      VFDSetPeriod(3,SET);
	else
      VFDSetPeriod(3,CLR);
}

/******************************************************************************/
void Do_Shift2(void)
{
   if(shift2_flag)
      VFDSetPeriod(4,SET);
   else
      VFDSetPeriod(4,CLR);
}

/******************************************************************************/
void Do_Shift3(void)
{
   if(shift3_flag)
      VFDSetPeriod(VIRTUAL_POSI_TAX3,SET);
   else
      VFDSetPeriod(VIRTUAL_POSI_TAX3,CLR);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -