📄 lcd_pop.c
字号:
#include "ecrsys.h"
#include "data.h"
#include "ftype.h"
#include "lcd2.h"
#include "tft.h"
#include "font.h"
#include "tft_disp.h"
#include "stdlib.h"
#include <string.h>
#include "sysdata.h"
#define MAX_PROG_POP_LINE 3
#define MAX_PROG_POP_BTN (MAX_PROG_POP_LINE*LINE_KEY_NUM)
BUTTON_DEF Pop_Btn[MAX_PROG_POP_BTN];
void Pop_Btn_Init(void)
{
BYTE i;
for (i=0;i<MAX_PROG_POP_BTN;i++)
{
Pop_Btn[i].size = Ts_KeyMap_Prog_Main_Size[i]; /*normal size*/
Pop_Btn[i].posi = i;
Pop_Btn[i].fill_color = BLACK;
Pop_Btn[i].font_color = GRAY;
memset(Pop_Btn[i].desc,0x20,MAX_BTN_DESC_LEN);
Pop_Btn[i].desc[MAX_BTN_DESC_LEN] = 0x00;
}
}
void Rst_ProgPop_Key_LayOut(void)
{
byte i;
Lcd_Pop_Flag = 0;
for(i = 0; i < MAX_PROG_POP_BTN; i++)
{
Pop_Btn[i].fill_color = GRAY;
Pop_Btn[i].font_color = BLACK;
Pop_Btn[i].posi = i;
Pop_Btn[i].size = Ts_KeyMap_Prog_Main_Size[i];
memset(Pop_Btn[i].desc,0x20, MAX_BTN_DESC_LEN);
Pop_Btn[i].desc[MAX_BTN_DESC_LEN] = 0;
Lcd_Draw_Button(Pop_Btn[i]);
}
}
byte HDLO_To_Asc(char *str, byte HDLO, byte dots)
{
long num;
byte len;
if((HDLO <= 1)||(HDLO> MAX_HDLO_NUM))
return 0;
*str++ = '0';
*str++ = '-';
num = getLong(HDLO-1) - 1;
len = LnumToTextBuff(str, num, dots);
return len+2;
}
byte VTAX_to_Asc(char *str, byte VTax)
{
byte i = 0;
byte len = 0;
if (sysflag->Tax_System == TAX_MODE)
{ /* Tax mode */
while(!(VTax&0x01))
{
VTax = VTax>>1;
i++;
if(i >= MAX_TAX_NUM)
{
len = strlen(Str_None_Tax);
memcpy(str, Str_None_Tax, len);
return len;
}
}
VTax = VTax>>1;
i++;
memcpy(str, "TAX", 3);
str += 3;
*str++ = 0x20;
*str++ = i+'0';
len += 5;
for(; i < MAX_TAX_NUM; i++)
{
if(VTax&0x01)
{*str++ = '&'; *str++ = i+'1';len += 2;}
VTax = VTax>>1;
}
}
else
{ /* VAT mode */
if(VTax == 0)
{
len = strlen(Str_None_VAT);
memcpy(str, Str_None_VAT, len);
return len;
}
if(VTax <= MAX_VAT_NUM)
{
*str++ = VTax + '0';
len += 1;
}
}
return len;
}
byte Get_HDLO(void)
{
char text_buf[MAX_TEXT];
byte len;
byte posi_tab[] = {0, 2, 4, 6, 8,10, 12, };
byte posi;
byte hdlo = 2;
word key;
Lcd_Pop_Flag = 1;
for(; hdlo <= MAX_HDLO_NUM; hdlo++)
{
posi = posi_tab[hdlo-2];
Pop_Btn[posi].posi = posi;
Pop_Btn[posi].fill_color = DARKGREEN;
Pop_Btn[posi].font_color = YELLOW;
Pop_Btn[posi].size = 0x12; //注意如果不是单键, 需要对旁边相关按键的size 进行更新
Pop_Btn[posi+1].size = 0x10;
memset(text_buf, 0x20, MAX_TEXT);
memset(Pop_Btn[posi].desc, 0x20, MAX_BTN_DESC_LEN);
len = HDLO_To_Asc(Pop_Btn[posi].desc, hdlo, sysflag->sysdots);;
Pop_Btn[posi].desc[MAX_BTN_DESC_LEN] = 0;
Lcd_Draw_Button_Ex(Pop_Btn[posi], Pop_Btn[posi].desc, Get_Desc_Len(Pop_Btn[posi].desc,MAX_BTN_DESC_LEN), ALIGN_MID);
}
InCmd = KD_NULL;
lnum = 0;
numcnt = 0;
while(1)
{
key = GetKey();
if(GetMainMode() != CurrMode)
{
Rst_ProgPop_Key_LayOut();
return NG;
}
if((Ts_Key.curr_logi/10 < 3)&&(Ts_Key.curr_logi%10 >= 4))//Pop 区域内
{
key = (Ts_Key.curr_logi/10)*6 + (Ts_Key.curr_logi%10 - 4); //取按键的逻辑代码转换值
if(key >= 14) continue;
numcnt = 1;
lnum = key/2 + 2;
Rst_ProgPop_Key_LayOut();
return OK;
}
else if(key == KD_CANCEL)
{
Rst_ProgPop_Key_LayOut();
return NG;
}
bellcnt = 0x01;
}
Rst_ProgPop_Key_LayOut();
return NG;
}
byte Get_Tax_Set(void)
{
const char Tax_Idx[] = {0x00, 0x01, 0x02, 0x04, 0x08, 0x03, 0x05, 0x09, 0x06, 0x0a, 0x0c,
0x07, 0x0b, 0x0d, 0x0e, 0x0f, };
char text_buf[MAX_TEXT];
byte len;
byte i;
byte posi = 0;
word key;
if(sysflag->Tax_System != TAX_MODE)
return OK;
Lcd_Pop_Flag = 1;
for(i = 0; i < 0x10; i++,posi ++)
{
Pop_Btn[posi].posi = posi;
Pop_Btn[posi].fill_color = DARKGREEN;
Pop_Btn[posi].font_color = YELLOW;
if(i == 0)
{
Pop_Btn[posi].size = 0x12; //注意如果不是单键, 需要对旁边相关按键的size 进行更新
Pop_Btn[posi+1].size = 0x10;
}
else
Pop_Btn[posi].size = 0x11; //注意如果不是单键, 需要对旁边相关按键的size 进行更新
memset(Pop_Btn[posi].desc, 0x20, MAX_BTN_DESC_LEN);
len = VTAX_to_Asc(Pop_Btn[posi].desc, Tax_Idx[i]);
Pop_Btn[posi].desc[MAX_BTN_DESC_LEN] = 0;
Lcd_Draw_Button(Pop_Btn[posi]);
if(i == 0)
posi++;
}
InCmd = KD_NULL;
lnum = 0;
numcnt = 0;
while(1)
{
key = GetKey();
if(GetMainMode() != CurrMode)
{
Rst_ProgPop_Key_LayOut();
return NG;
}
if((Ts_Key.curr_logi/10 < 3)&&(Ts_Key.curr_logi%10 >= 4))//Pop 区域内
{
key = (Ts_Key.curr_logi/10)*6 + (Ts_Key.curr_logi%10 - 4); //取按键的逻辑代码转换值
numcnt = 1;
if(key < 2)
lnum = 0;
else
lnum = key-1;
lnum = Tax_Idx[lnum];
Rst_ProgPop_Key_LayOut();
return OK;
}
else if(key == KD_CANCEL)
{
Rst_ProgPop_Key_LayOut();
return NG;
}
bellcnt = 0x01;
}
Rst_ProgPop_Key_LayOut();
return NG;
}
byte Get_Dept_Age_Set(void)
{
byte i;
byte posi = 0;
word key;
Lcd_Pop_Flag = 1;
for(i = 0; i <= 2 ; i++,posi ++)
{
Pop_Btn[posi].posi = posi*2;
Pop_Btn[posi].fill_color = DARKGREEN;
Pop_Btn[posi].font_color = YELLOW;
Pop_Btn[posi].size = 0x22; //注意如果不是单键, 需要对旁边相关按键的size 进行更新
memset(Pop_Btn[posi].desc, 0x20, MAX_BTN_DESC_LEN);
if(i == 0)
{
memcpy(Pop_Btn[posi].desc, Str_None, strlen(Str_None));
}
else
{
memcpy(Pop_Btn[posi].desc,"AGE_", strlen("AGE_"));
LnumToTextBuff(Pop_Btn[posi].desc+4, Age_Limit[i-1], 0);
}
Pop_Btn[posi].desc[MAX_BTN_DESC_LEN] = 0;
Lcd_Draw_Button_Ex(Pop_Btn[posi],Pop_Btn[posi].desc, Get_Desc_Len(Pop_Btn[posi].desc,MAX_BTN_DESC_LEN), ALIGN_MID);
}
InCmd = KD_NULL;
lnum = 0;
numcnt = 0;
while(1)
{
key = GetKey();
if(GetMainMode() != CurrMode)
{
Rst_ProgPop_Key_LayOut();
return NG;
}
if((Ts_Key.curr_logi/10 < 3)&&(Ts_Key.curr_logi%10 >= 4))//Pop 区域内
{
key = (Ts_Key.curr_logi/10)*6 + (Ts_Key.curr_logi%10 - 4); //取按键的逻辑代码转换值
key = (key/6/2)*(6/2) + (key%6)/2;
if(key > 3)
continue;
numcnt = 1;
lnum = key;
Rst_ProgPop_Key_LayOut();
return OK;
}
else if(key == KD_CANCEL)
{
Rst_ProgPop_Key_LayOut();
return NG;
}
bellcnt = 0x01;
}
Rst_ProgPop_Key_LayOut();
return NG;
}
byte Get_Num_Input(void)
{
while(1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -