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

📄 program.c

📁 一款收款机C源代码!因为是几年前的代码了
💻 C
📖 第 1 页 / 共 5 页
字号:
    #endif

    if(mode == 0xff)
        Lcd_Reflush_List(0);
    else
        Lcd_Reflush_List(1);
        
    Lcd_Disp_Str_Btn(BUF_ID_TL_SUB, Str_Modify_Step[0]);
    Lcd_Disp_Str_Btn(BUF_ID_TL_INPUT, Str_Dept_Prog_Step_desc[prg_step]);

	Last_Prg_Idx = prg_idx;
	Last_Prg_Step = prg_step;

}

/*****************************************************************
*  Dept ASCII input change to Binary data and update the dept.
*  In:   char idx -- > the index of current dept no.
*****************************************************************/
byte Dasc2bin(word Idx_Step)
{
    const char *Str_ptr[3];
    byte prg_idx;        /* The index department number */
    byte prg_step;       /* The display step */
    byte *p;             /* The temporary point */
    byte bak_flag;
    byte tmp;
    byte Rslt = 0;
    byte len;

	bak_flag = 0 ;
    p = In_Buff;
    prg_idx = ( Idx_Step / MAX_DEPT_STEP );         /* Get the index no. */
    prg_step = ( Idx_Step % MAX_DEPT_STEP );        /* Get the index step */
	
    if(numcnt)
    {
        errorType(ERR_DIGIT_ILLEGAL);
        return NG;
    }
    switch (prg_step)
    {
        case  DEPT_DESC_STEP:                      /* Program the department flag */
            Lcd_Disp_Str_Btn(BUF_ID_TL_SUB, Str_Modify_Step[1]);
            if(Get_Desc(dept[prg_idx].desc,MAX_DESC_LEN_EX,NO) != OK)
                return NG;
            modi_flag = 1;
            last_modi_flag = 1;
            return OK;
            
        case  DEPT_PRICE_STEP:
            Lcd_Disp_Str_Btn(BUF_ID_TL_SUB, Str_Modify_Step[2]);
            if(Get_Num_Input() != OK)
                return NG;
            if( lnum > MAX_DEPT_PRICE )
                {errorType(ERR_DIGIT_OVER);return NG;}
            dept[prg_idx].price=lnum;
            modi_flag = 1;
            last_modi_flag = 1;
            return OK;

        case DEPT_HDLO_STEP:
            Lcd_Disp_Str_Btn(BUF_ID_TL_SUB, Str_Modify_Step[3]);
            if (Get_HDLO() != OK)
                return NG;
            if(numcnt == 0)
                return OK;
            if( lnum > MAX_HALO_LEN ) 
            {
                errorType(ERR_DIGIT_ILLEGAL);
                return(NG);
            }
            dept[prg_idx].Hdlo = lnum;
            modi_flag = 1;
            last_modi_flag = 1;
            return OK;
            
        case  DEPT_TYPE_STEP:
            Lcd_Disp_Str_Btn(BUF_ID_TL_SUB, Str_Modify_Step[3]);
            Str_ptr[0] = Str_Dept_Type[0];
            Str_ptr[1] = Str_Dept_Type[1];
            if(Get_Btn_Choice_Input_Ex(Str_ptr, 0x22, 2, &Rslt) != OK)
                return NG;
            bak_flag = dept[prg_idx].pflag & 0x0F;
            dept[prg_idx].pflag = (Rslt == KD_YES) ? 0 : (1<<4);
            dept[prg_idx].pflag |= bak_flag;
            last_modi_flag = 1;
            modi_flag = 1;
            return OK;

        case  DEPT_KP_STEP:
            Lcd_Disp_Str_Btn(BUF_ID_TL_SUB, Str_Modify_Step[3]);
            Str_ptr[0] = Str_Act_Sel[1];
            Str_ptr[1] = Str_Act_Sel[0];
            if(Get_Btn_Choice_Input_Ex(Str_ptr, 0x22, 2, &Rslt) != OK)
                return NG;
            if(Rslt > 1)
                {errorType(ERR_KEY_ILLEGAL);return NG;}
            dept[prg_idx].send_kp_flag = Rslt ;
            modi_flag = 1;
            last_modi_flag = 1;
            return OK;
            break;

        case  DEPT_GROUP_STEP:
            Lcd_Disp_Str_Btn(BUF_ID_TL_SUB, Str_Modify_Step[2]);
            if(Get_Num_Input() != OK)
                return NG;
            if(lnum >= 10) 
                {errorType(ERR_DIGIT_ILLEGAL);return NG;}
            dept[prg_idx].group = lnum;
            modi_flag = 1;
            last_modi_flag = 1;
            return OK;
            
        case  DEPT_VTAX_STEP :
            if(sysflag->Tax_System == TAX_MODE) //TAX
            {
                Lcd_Disp_Str_Btn(BUF_ID_TL_SUB, Str_Modify_Step[3]);
                if(Get_Tax_Set() == OK)
                {
                    if(lnum >0x0f)
                        {errorType(ERR_KEY_ILLEGAL); return NG;}
                    bak_flag = dept[prg_idx].pflag & 0xF0 ;
                    dept[prg_idx].pflag = (bak_flag|lnum);     
                    modi_flag = 1;
                    last_modi_flag = 1;
                }
                else
                    return NG;
            }
            else if(sysflag->Tax_System == VAT_MODE)//VAT
            {
                Lcd_Disp_Str_Btn(BUF_ID_TL_SUB, Str_Modify_Step[2]);
                if(Get_Num_Input() != OK)
                    return NG;
                if(lnum > MAX_VAT_NUM)
                    {errorType(ERR_DIGIT_ILLEGAL);return(NG);}
                bak_flag = dept[prg_idx].pflag & 0xF0 ;
                dept[prg_idx].pflag = bak_flag | lnum;
                modi_flag = 1;
                last_modi_flag = 1;
                return OK;
            }
            else    //GST
            {
            }
            break;
            
        case DEPT_MODE_STEP:
            Lcd_Disp_Str_Btn(BUF_ID_TL_SUB, Str_Modify_Step[3]);
            Str_ptr[0] = Str_Dept_Mode[0];
            Str_ptr[1] = Str_Dept_Mode[1];
            Str_ptr[2] = Str_Dept_Mode[2];
            if(Get_Btn_Choice_Input(Str_ptr, 0x22, 3) != OK)
                return NG;
            bak_flag = dept[prg_idx].pflag2 & 0xf0 ;
            dept[prg_idx].pflag2 = bak_flag|((byte)lnum);
            modi_flag = 1;
            last_modi_flag = 1;
            return OK;

        case DEPT_SALE_STEP:
            Lcd_Disp_Str_Btn(BUF_ID_TL_SUB, Str_Modify_Step[3]);
            Str_ptr[0] = Str_Dept_Sale[0];
            Str_ptr[1] = Str_Dept_Sale[1];
            if(Get_Btn_Choice_Input_Ex(Str_ptr, 0x22, 2, &Rslt) != OK)
                return NG;
            dept[prg_idx].sale = (Rslt == KD_YES) ? 0 : 1;
            modi_flag = 1;
            last_modi_flag = 1;
            return OK;
            
        case DEPT_AGE_STEP:
            Lcd_Disp_Str_Btn(BUF_ID_TL_SUB, Str_Modify_Step[3]);
            if(Get_Dept_Age_Set() != OK)
                return NG;
            bak_flag = dept[prg_idx].pflag2 & 0x0f ;
            dept[prg_idx].pflag2 = bak_flag|((byte)lnum<<4);
            modi_flag = 1;
            last_modi_flag = 1;
            return OK;
            
     #ifdef AUTO_PER		/* Support the department auto percent function */
        case DEPT_PER_STEP:
            if(p[0] > 1)
            {
                errorType(ERR_DIGIT_ILLEGAL);
                return (NG);
            }
            bak_flag = p[0];
            memmove(In_Buff, In_Buff+1, -- numcnt);
            asc2long();				/* Recalculate the rate */
            if(lnum > 99999)		/* 3 dots */
            {
                errorType(ERR_DIGIT_ILLEGAL);
                return(NG);
            }
            lnum *= getLong(3 - dec_cnt);
            if(lnum > 99999)		/* 3 dots */
            {
                errorType(ERR_DIGIT_ILLEGAL);
                return (NG);
            }
            dept[prg_idx].per_flag = bak_flag;
            dept[prg_idx].per_rate = lnum;
            modi_flag = 1;
            last_modi_flag = 1;
            //last_step = Idx_Step;
            break;
        #endif /* End AUTO_PER */
        case DEPT_DEFAULT_STEP:
            if(Get_Sure_Done(&Rslt) != OK)
                return NG;
            
            if(Rslt != KD_YES)
                return OK;
            if((dept[prg_idx].quantity != 0) || (dept[prg_idx].amount != 0)
                || (dept[prg_idx].PTD_quantity != 0) || (dept[prg_idx].PTD_amount != 0))
            {
                errorType(ERR_RPT_NOT_EMPTY);
                break;
            }
            
            dept[prg_idx].pflag = 0x00;
            dept[prg_idx].pflag2 = 0x00;
            dept[prg_idx].group = 1;
            dept[prg_idx].Hdlo = 7;
            #ifdef AUTO_PER       /* Support the department auto percent function */
            dept[prg_idx].per_flag = 1;
            dept[prg_idx].per_rate = 0;
            #endif /* End AUTO_PER */
            #ifdef VER_RSNT       /* Support the restaurant function */
            dept[prg_idx].send_kp_flag = 0;         /* Allow send the information to the kitchen printer */
            #endif /* End VER_RSNT */
            dept[prg_idx].price = 0L;
            memset(dept[prg_idx].desc, 0x20, MAX_DESC_LEN_EX);
            dept[prg_idx].desc[MAX_DESC_LEN_EX] = 0;
            len = strlen(Str_Dept_Desc);
            xtr_strcpy(dept[prg_idx].desc,Str_Dept_Desc);
            LWordtoAsc(dept[prg_idx].desc+len, prg_idx+1, 3);
            Last_Prg_Idx = IDX_NULL;
            Last_Prg_Step = STEP_NULL;
            return OK;
            
        case DEPT_NEXT_ITEM:
            return OK;
    }
    return (OK);
}

/*---------------------------------------------------------------------------------
*  Program the department attribute.
*  Input :  Idx  -- the start index no. of the dept. ( 0 -- Max_Dept_Num. )
*  Out   :  None.
*---------------------------------------------------------------------------------*/
void pDept( word Idx_Step )
{
   byte idx;
   word max_oper_dept_no;//当前可操作的部门数

	Lcd_Send_Text_Buff_Str(BUF_ID_TL_TITLE, 1, Str_ProgMain_Menu[0], ALIGN_MID);
	Lcd_Disp_Text_Buff(BUF_ID_TL_TITLE);

    if(Max_Dept_No <= MAX_REL_DEPT_CNT)
   	    max_oper_dept_no = Max_Dept_No;
    else
   	    max_oper_dept_no = MAX_REL_DEPT_CNT;


	Idx_Step = MAX_DEPT_STEP * Idx_Step ;
    Last_Prg_Idx = IDX_NULL;
    Last_Prg_Step = STEP_NULL;
    while(TRUE)
    {
        Dbin2asc(Idx_Step);                    /* Display the current department attribute. */
	  #ifdef AUTO_PER 			/* Support the department auto percent function */
		if((sysflag->Auto_Per_Use_Flag == 0) && (Idx_Step % MAX_DEPT_STEP == (DEPT_PER_STEP) && (InCmd == KD_ENTER)))
															/* When system flag not support the auto percent, produce a virtual key */
			Make_Virtual_Key(KD_ENTER);
	  #endif /* End AUTO_PER */
        
        if( GetIn() == NG )
            continue;

        if(( Idx_Step%MAX_DEPT_STEP == DEPT_PRICE_STEP ) && (sysflag->sysdots != 0))
            VFDSetPeriod(MAX_LCD_NUM - sysflag->sysdots - 1,CLR);    /* Clear the period display when the value has inputed */

      #ifdef AUTO_PER			/* Support the department auto percent function */
        Prog_en_dec_input_flag = 0;
      #endif /* End AUTO_PER */

        GetMainMode();    
        if (MainMode != CurrMode)
            return;

        switch (InCmd )
        {
            case KD_ENTER: //弹出选择窗口,  读取用户选择信息, 并退出.
                if(numcnt)
                {
                    if((Idx_Step%MAX_DEPT_STEP == DEPT_START_STEP)||(Idx_Step%MAX_DEPT_STEP == DEPT_NEXT_ITEM))
                    {
                        if((lnum > max_oper_dept_no)||(lnum == 0))
                            {errorType(ERR_DIGIT_OVER); break;}
                        Idx_Step = (lnum-1)*MAX_DEPT_STEP;
                    }
                    break;
                }
                if(Dasc2bin(Idx_Step) != OK)
                   break;
                Idx_Step = ( (Idx_Step + 1) % ( max_oper_dept_no * MAX_DEPT_STEP ) );
                break;
                
            case KD_CANCEL:
                return;

            case KD_PAGE_UP:
            case KD_PAGE_DOWN:
            case KD_UP:
            case KD_DOWN:
            	Do_Dept_Roll(InCmd, &Idx_Step);
            	break;
            default:
                bellcnt = 0x01;
                break;
        } /* End switch */
    } /* End while */
} /* End pDept */

/*----------------------------------------------------------------------------*
*  检查Clerk刷新切换的条件
*   1> 如果刚才的操作有信息的更新, 需要刷新
*   2> 如果跳转到上一page或下一page, 需要刷新
*----------------------------------------------------------------------------*/
#define LCD_CLERK_NUM       4
BOOL Chk_Clerk_Refresh(byte prg_idx)
{
	if (Last_Prg_Idx == IDX_NULL)		/* The first programming */
		return 0xff;//需要全部刷新
	if (prg_idx/LCD_CLERK_NUM != Last_Prg_Idx/LCD_CLERK_NUM)		/* 显示了不同的page */
		return 0xff;//需要全部刷新
    return Last_Prg_Step;
}


/* Do the clerk roll */
void Do_Clerk_Roll(word key, byte *idx_step)
{
	byte max_step;
	byte step;

    max_step = MAX_CLERK_CNT*MAX_CLERK_STEP;
    step = *idx_step + max_step;
    switch(key)
    {
        case KD_PAGE_UP:
            step -= LCD_CLERK_NUM*MAX_CLERK_STEP;
            break;
        case KD_PAGE_DOWN:
            step += LCD_CLERK_NUM*MAX_CLERK_STEP;
            break;
        case KD_UP:
            step -= 1;
            break;
        case KD_DOWN:
            step += 1;
            break;
    }
	step %= max_step;	/* Get the true step */

	*idx_step = step;
}


/* Display the clerk attribute */
void PMD_Disp_Clerk(byte Idx)
{
    byte i, j;
    byte clerk_idx;
    byte screen_idx;
    byte step;
    byte mode;
    byte str[MAX_TEXT];
    byte len;

    clerk_idx = Idx/MAX_CLERK_STEP;
    screen_idx = (clerk_idx/LCD_CLERK_NUM)*LCD_CLERK_NUM;//当前屏clerk的起始编号

    mode = Chk_Clerk_Refresh(clerk_idx);
    if(mode == 0xff)
    {
        Rst_Lcd_Text();     /* Reset the tax */
    }
    Text_Lcd.CurrLine = (clerk_idx%LCD_CLERK_NUM)*(MAX_CLERK_STEP + 2) + Idx%MAX_CLERK_STEP+1;

    for (i = screen_idx; i < screen_idx + LCD_CLERK_NUM; i++)   // Display 8 clerks information
    {
        if (i >= MAX_CLERK_CNT)    // 最多只有40个收银员
            break;

        j = i-screen_idx;
        // Display clerk number
        if(mode == 0xff)
        {
            memset(Text_Lcd.text[j*4], 0x20, MAX_TEXT);
            len = strlen(Str_Clerk_Desc);
            xtr_strcpy(Text_Lcd.text[j*4], Str_Clerk_Desc);
            Text_Lcd.text[j*4][len] = '#';
            LWordtoAsc(Text_Lcd.text[j*4]+len+1, i+1, 2);

⌨️ 快捷键说明

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