📄 lcm.c
字号:
if (tmpCnt == 0)
tmpCnt = funcNum - 1;
else
tmpCnt--;
}
input = 0;
}
break;
case KD_PGDOWN:
{
byte k;
for (k=0; k<4; k++)
{
if (tmpCnt >= (funcNum - 1))
tmpCnt = 0;
else
tmpCnt++;
}
input = 0;
}
break;
default:
Lcm_ClrLineCn(0, 4, 0);
Do_Clear();
return 0;
}
if (flag == 1)
{
if (tmpCnt >= funcNum)
{
bellcnt = 0xfe;
tmpCnt = 0;
flag = 0;
continue;
}
else
break;
}
}
Lcm_ClrLineCn(0, 4, 0);
return tmpCnt + 1;
}
/******************************************************************************/
void PopIn_Disp(void)
{
byte len = strlen(popInStrBuf);
if (len > 13) // 暂最大支持13位输入.
{
len = 13;
}
Lcm_Disp(popInStrBuf, 4*8, POP_OFFSET+110-len*8, len, FONT_16, FALSE, FALSE);
}
/******************************************************************************
* Get tenkey input.
* return the long data which input by user.
*
* The input number can store in the input buffer 'popIn...Buf'(BCD code), also this function
* can changed it to the long data stored in variable 'lnum'.
*******************************************************************************/
byte GetInPop(byte len, byte decEn)
{
byte i;
char key, keybak;
while (!Key_Poll_Chk());
Lcm_ClrInputDisp();
memset(popInStrBuf, 0, MAX_CHAR_POPIN);
popInStrCnt = 0;
memset(popInNumBuf, 0, MAX_CHAR_POPIN);
popInNumCnt = 0;
popInDecFlag = 0;
popInDecCnt = 0;
/* do keyin circle */
while (TRUE)
{
PopIn_Disp();
key = GetKey();
switch (key)
{
case KD_DEC : /* Is dot, set dot flag */
if (popInNumCnt >= len)
{
Message(0, "Input Digit Over!", FONT_5, "\0");
continue;
}
if (decEn == FALSE)
{
//errorType(ERR_DEC_MODE);
Message(0, "Error Dec Mode!", FONT_5, "\0");
continue;
}
if (popInDecFlag == 1)
{
Message(0, "Error Dec Press!", FONT_5, "\0");
continue;
}
else
{
popInDecFlag = 1;
if (popInNumCnt == 0)
{
popInStrBuf[popInStrCnt++] = '0';
popInNumBuf[popInNumCnt++] = 0;
}
popInStrBuf[popInStrCnt++] = '.';
PopIn_Disp();
}
break;
case KD_0:
if (popInNumCnt >= len)
{
Message(0, "Input Digit Over!", FONT_5, "\0");
continue;
}
if (popInDecFlag)
{
popInDecCnt++;
}
popInStrBuf[popInStrCnt++] = '0';
popInNumBuf[popInNumCnt++] = 0;
PopIn_Disp();
break;
case KD_D0 : /* For '00' key in */
if (popInNumCnt >= len)
{
Message(0, "Input Digit Over!", FONT_5, "\0");
continue;
}
if (popInDecFlag)
{
popInDecCnt += 2;
}
popInStrBuf[popInStrCnt++] = '0';
popInNumBuf[popInNumCnt++] = 0;
popInStrBuf[popInStrCnt++] = '0';
popInNumBuf[popInNumCnt++] = 0;
PopIn_Disp();
break;
case KD_T0: /* For '000' key in */
if (popInNumCnt >= len)
{
Message(0, "Input Digit Over!", FONT_5, "\0");
continue;
}
if (popInDecFlag)
{
popInDecCnt += 3;
}
popInStrBuf[popInStrCnt++] = '0';
popInNumBuf[popInNumCnt++] = 0;
popInStrBuf[popInStrCnt++] = '0';
popInNumBuf[popInNumCnt++] = 0;
popInStrBuf[popInStrCnt++] = '0';
popInNumBuf[popInNumCnt++] = 0;
PopIn_Disp();
break;
#ifdef SCANNER /* Support the scanner function */
case SPLU:
if (SC_TranToBcd() == OK)
{
SC_TransBcd();
lastincmd = InCmd;
InCmd = SPLU;
return (OK);
}
else
{
//errorType(ERR_BAR_FORMAT);
Message(0, "Error Bar Format!", FONT_5, "\0");
Lcm_ClrInputDisp();
memset(popInStrBuf, 0, MAX_CHAR_POPIN);
memset(popInNumBuf, 0, MAX_CHAR_POPIN);
popInStrCnt = 0;
popInNumCnt = 0;
popInDecFlag = 0;
popInDecCnt = 0;
continue;
}
break;
#endif /* End SCANNER */
case 0xFF : /* Control lock changed */
InCmd = NULLKEY;
return NG;
case KD_CLEAR:
Lcm_ClrInputDisp();
memset(popInStrBuf, 0, MAX_CHAR_POPIN);
memset(popInNumBuf, 0, MAX_CHAR_POPIN);
popInStrCnt = 0;
popInNumCnt = 0;
popInDecFlag = 0;
popInDecCnt = 0;
break;
default :
keybak = key;
key = Isdigit(key); /* Isdigit() returns 0xFF for not digit */
if (key != 0xFF) /* Is the digit key */
{
if (popInNumCnt >= len)
{
Message(0, "Input Digit Over!", FONT_5, "\0");
continue;
}
if (popInDecFlag)
{
popInDecCnt ++;
}
popInStrBuf[popInStrCnt++] = key + '0';
popInNumBuf[popInNumCnt++] = key;
PopIn_Disp();
}
else /* do for command */
{
lastincmd = InCmd; /** this place will change **/
InCmd = keybak;
if (popInNumCnt)
{
popInNumBuf[popInNumCnt] = 0xff;
lnum = 0L;
for (i=0; i < popInNumCnt; i++) /* Change the BCD code number to the long data, store in 'lnum' */
{
lnum = lnum * 10 + popInNumBuf[i];
}
}
else
{
lnum = 0L;
}
if (InCmd == KD_SUBTTL)
{
return (OK);
}
else
{
return NG;
}
}
break;
}
}
return (OK);
}
/*
清除用户输入区显示.
*/
void Lcm_ClrInputDisp(void)
{
Lcm_Disp(" ", 4*8, POP_OFFSET+1*6, 13, FONT_16, FALSE, FALSE);
}
/******************************************************************************
* 窗口中最多可有6行,其中前3行为提示信息和长输入显示区,4,5行为双高输入区,6行为帮助信息.
* decEn -- 是否允许输入小数点.
*******************************************************************************/
byte Menu_PopIn(byte len, byte decEn)
{
byte result;
result = GetInPop(len, decEn);
Lcm_Cursor(4*8, POP_OFFSET+18*6, 1, FALSE);
if (InCmd != KD_SUBTTL)
{
return NG;
}
return result;
}
/****************************************************************************
* Get a key but not clear it from keybuffer.
******************************************************************************/
byte GetKeyNoClr( void )
{
byte key;
while(1)
{
if( Ktail != Khead)
{
key = KeyBuffer[Ktail];
if( key != 0 )
{
#ifdef SCANNER /* Support the scanner function */
if(key == SPLU)
{
BarCnt_bak = BarCnt;
SC_ClrFlag();
memcpy(CodeBuf_Bak,CodeBuf,32);
return(key);
}
#endif /* Support the scanner function */
key = key_logi_get(key_logic,key,MAX_KEY_CNT); /* Return the logical key code. */
if(FFkey_Flag || Calc_Flag)
{
FFkey_Code = key; /* Store the logic code for the use in the free function key. */
Calc_Logi_Code = key + 1; /* Get the logical code */
}
return ( FF_Key_Get(key));
}
}
else
{
GetMainMode();
if(key_fd&&(!FFkey_Flag)&&(MainMode!=X_OFF))
/* If the feed key flag is true and not in the free function key mode */
Key_Feed();
if( MainMode == CurrMode ) /* The control lock did't change, scan the key again */
continue;
/* 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 (0xFF); /* The control changed, return 0FFH */
}/* end else */
} /* end while */
return(OK); /* Pesuedo return */
}
/*
输入式窗口,显示提示信息和帮助信息,并显示光标,提示用户可输入.
type -- 类型,
*/
void Menu_PopMsg(byte type, ...)
{
// #define POP_DISP_CHAR (MAX_CHAR57-1) // 窗口最大显示字符数.
// #define POP_DISP_CHAR_16 (MAX_CHAR16-2) // 窗口最大显示16*8字符数.
#define POP_DISP_CHAR (20-1) // 窗口最大显示字符数.
#define POP_DISP_CHAR_16 (16-2) // 窗口最大显示16*8字符数.
byte stLine, endLine;
byte disp[3][MAX_CHAR57+1];
byte dispFont[3];
byte lines = 0; // 窗口最大提示显示,不超过3行.
byte cnt = 0;
byte tmpLen;
byte i;
va_list argp; // 定义保存函数参数的结构.
byte *para1; // 存放取出的字符串参数.
byte para2;
byte helpInfoFlag = 0; // 帮助信息.
byte helpInfo[MAX_CHAR57+1];
byte inputInfoFlag = 0; // 用户输入区显示内容.
byte inputInfo[MAX_CHAR57+1];
// 从参数中读取需要显示的字符串.
memset(disp[0], 0, 4 * (MAX_CHAR57+1));
va_start(argp, type); // argp指向传入的第一个可选参数,type是最后一个确定的参数.
while (1)
{
para1 = va_arg(argp, byte *); // 取出当前的参数,类型为byte *.
if (strcmp(para1, "\0") == 0)
{
break;
}
para2 = va_arg(argp, byte); // 取出当前的参数,类型为byte.
tmpLen = strlen(para1);
if (tmpLen > POP_DISP_CHAR)
{
tmpLen = POP_DISP_CHAR; // 超出部分,自动截去.
}
if (para2 == FONT_16)
{
memcpy(disp[cnt], para1, tmpLen);
dispFont[cnt] = para2;
lines += 2; // 16*8字体,占两行显示.
if (tmpLen > POP_DISP_CHAR_16)
{
disp[cnt][POP_DISP_CHAR_16] = 0; // 若显示超出长度,自动截去.
}
}
else if (para2 == FONT_5)
{
memcpy(disp[cnt], para1, tmpLen);
dispFont[cnt] = para2;
lines++;
}
else if (para2 == HELP_INFO) // 帮助信息用5*7字体.
{
if (helpInfoFlag != 0) // 目前只允许一行帮助信息.
{
continue;
}
helpInfoFlag = 1;
memcpy(helpInfo, para1, tmpLen);
helpInfo[tmpLen] = 0;
}
else if (para2 == INPUT_INFO) // 用户输入区显示信息用16*8字体.
{
if (inputInfoFlag != 0) // 目前只允许一行帮助信息.
{
continue;
}
inputInfoFlag = 1;
if (tmpLen > POP_DISP_CHAR_16 - 1) // 目前最多显示13位,保留一位给光标.
{
tmpLen = POP_DISP_CHAR_16-1; // 若显示超出长度,自动截去.
}
memcpy(inputInfo, para1, tmpLen);
inputInfo[tmpLen] = 0;
}
cnt++;
if (lines >= 3)
{
break;
}
}
va_end(argp); // 将argp置为NULL.
stLine = (lines == 1) ? 2 : 1;
endLine = (helpInfoFlag == 1) ? 7 : 6;
Lcm_PopUp(stLine*8, POP_OFFSET+1*6, (endLine-stLine)*8, POP_DISP_CHAR*6, 0, TRUE);
for (i=0,lines=0; i < cnt; i++)
{
Lcm_Disp(disp[i], (stLine+lines)*8, POP_OFFSET+1*6, 0, dispFont[i], FALSE, FALSE);
if (dispFont[i] == 0)
{
lines++;
}
else
{
lines += 2;
}
}
if (inputInfoFlag)
{
Lcm_Disp(inputInfo, 4*8, POP_OFFSET+1*6 + (13-strlen(inputInfo))*8/2, 0, FONT_16, FALSE, FALSE);
}
if (helpInfoFlag)
{
Lcm_Disp(helpInfo, 6*8, POP_OFFSET+1*6, 0, FONT_5, TRUE, FALSE); // 帮助信息反显.
}
Lcm_Cursor(4*8, POP_OFFSET+(POP_DISP_CHAR-1)*6+3, 1, TRUE);
}
void Flush_Prn_Ex(byte flag1, byte flag2, word idx, long price, long quantity, long total)
{
byte len1, len2, len3, len4;
byte plink;
byte desc_len;
byte temp[20];
byte locate;
byte disStr[50];
byte i;
memset(disStr, ' ', 50);
if ((flag1 == DEPT) || (flag1 == PLU))
{
if (flag1 == DEPT)
{
memcpy(disStr, dept24[idx].desc, MAX_DESC_LEN);
}
else
{
memcpy(disStr, plu[idx].desc, MAX_DESC_LEN);
}
len1 = Str_LongTolen(temp, total, sysflag->sysdots, 0);
memcpy(&disStr[MAX_CHAR57+1-len1], temp, len1);
for (i=0; i<LCM_MAX_DEPT_DISP-1; i++)
{
memcpy(Lcm_dispDeptBuf[i], Lcm_dispDeptBuf[i+1], MAX_CHAR57+1);
}
memcpy(Lcm_dispDeptBuf[LCM_MAX_DEPT_DISP-1], disStr, MAX_CHAR57+1);
#if LCM == LCM_12832
for (i=0; i<LCM_MAX_DEPT_DISP; i++)
{
Lcm_Disp(Lcm_dispDeptBuf[i], i*8, 0, MAX_CHAR57+1, FONT_5, FALSE, FALSE);
}
#elif LCM == LCM_12864
Lcm_Disp(" ITEM NAME PRICE", 0, 0, MAX_CHAR57+1, FONT_5, TRUE, FALSE);
for (i=0; i<LCM_MAX_DEPT_DISP; i++)
{
Lcm_Disp(Lcm_dispDeptBuf[i], (i+1)*8, 0, MAX_CHAR57+1, FONT_5, FALSE, FALSE);
}
#elif LCM == LCM_19264
Lcm_Disp("
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -