📄 lcd2.h
字号:
/*
* Module: Lcd2.h
* Modified by: X.C.Zheng WeiHua, Kyd Weihua, XXC Weihua
* Modified on: Date: 05-11-26 14:13
* Copyright(c) WeiHua Tech Ltd.
* Tab width: 3
* Edit Font: Courier New
*/
#ifndef LCD2_H
#define LCD2_H
#include "ecrsys.h"
#include "data.h"
#include "ftype.h"
#include "tft.h"
#define LCD_COLORFUL 1 /* 彩色 */
#define LCD_GRAY 2 /* 单色灰度 */
#if 0
#define LCD_COLOR LCD_COLORFUL
//#define LCD_COLOR LCD_GRAY
#endif
typedef struct{
byte id; /* The button id */
int x1; /* 可以有负坐标 */
int x2; /* 可以有负坐标 */
int y1; /* 可以有负坐标 */
int y2; /* 可以有负坐标 */
byte fill_color; /* The fill index color */
byte left_margin;
byte right_margin;
byte top_margin;
byte toe_margin;
byte margin_color; /* The margin index color */
char *text; /* The button text, for the name */
byte text_color; /* The text index color */
} LCD_BTN_LAY;
// 在样机中, 这里所有的属性都是一样的, 故用宏定义
#define KEY_LEFT_MARGIN 2
#define KEY_RIGHT_MARGIN 2
#define KEY_TOP_MARGIN 2
#define KEY_TOE_MARGIN 2
//#define KEY_FILL_COLOR BLACK
#define KEY_MARGIN_COLOR WHITE
#define TEXT_AVER_WIDTH 9 /* 字体平均宽度, 主要针对大写字母和数字 */
#define TEXT_NORM_HEIGHT 13 /* 字体普通的高度,主要针对大写字母和数字,有一些特殊字符的高度很高,需加小心 */
typedef struct{
word key; /* The key code */
word curr_logi; /* The current pressing logical code */
word last_logi; /* The last pressing logical code */
}TS_KEY_DEF;
#define BTN_ID_KEY 0 /* The key display id */
#define BTN_ID_TEXT 1 /* The text display id */
#define BTN_ID_LOGO_TEXT 2 /* The logo text display id */
#define BTN_ID_KEY_EX 3 /* The key like dept Key, DPLU key and so on*/
#define BTN_ID_KEY_RPT 4 /* The key for report */
//typedef
#define MAX_LINE_POSI 4 /* 一行内最多仅允许四个可以定位的内容 */
#define TEXT_LINE_SPACING 3 /* The line spacing */
#if TEXT_AVER_WIDTH == 9
#define MAX_LCD_TEXT 32 /* 最大可显示的字符为 (320/9), 同时这里再考虑旁边的边框多加一点,故仅用32个字符 */
#define MAX_STAT_TEXT 32
#define MAX_INPUT_TEXT 32
#define MAX_SUB_TEXT 32
#define MAX_POP_TEXT 32 /* 为了统一,这个也是设置成了32个字符的宽度 */
#define MAX_TEXT MAX_LCD_TEXT
#if MAX_LCD_TEXT == MAX_STAT_TEXT && MAX_LCD_TEXT == MAX_INPUT_TEXT && MAX_LCD_TEXT == MAX_SUB_TEXT
#define MAX_LCD2_LEN MAX_LCD_TEXT
#endif
#endif // TEXT_AVER_WIDTH
#if LCD_LAYOUT_VRT_LINE == 13 /*纵向为13个按键*/
#define LCD_TEXT_BTN_HEIGHT 9 // 显示文本区所占的按键的高度
#define DISP_SGN_BTN_HEIGHT 46 // 每一个最薄的按键的高度
#define DISP_LCD_TEXT_LINE 24 // (8*37-1-2-2-2)/(13+3) = 18,
#define MAX_LCD_TEXT_LINE 200 // 仅开辟200行的空间用于显示
#define POP_TEXT_BTN_HEIGHT 4 // 弹出文本区所占的按键的高度
// #define DISP_SGN_BTN_HEIGHT 37 // 每一个最薄的按键的高度
#define DISP_POP_TEXT_LINE 8 // (4*37-1-2-2-2)/(13+3) = 8,
#define MAX_POP_TEXT_LINE 20 // 有20行已经足够用于显示了
#elif LCD_LAYOUT_VRT_LINE == 10 /*纵向为10个按键*/
#define LCD_TEXT_BTN_HEIGHT 6 // 显示文本区所占的按键的高度
#define DISP_SGN_BTN_HEIGHT 48 // 每一个最薄的按键的高度
#define DISP_LCD_TEXT_LINE 16 // (6*48-1-2-2-2)/(13+3) = 17,
#define MAX_LCD_TEXT_LINE 200 // 仅开辟200行的空间用于显示
#define POP_TEXT_BTN_HEIGHT 3 // 弹出文本区所占的按键的高度
// #define DISP_SGN_BTN_HEIGHT 37 // 每一个最薄的按键的高度
#define DISP_POP_TEXT_LINE 8 // (4*37-1-2-2-2)/(13+3) = 8,
#define MAX_POP_TEXT_LINE 20 // 有20行已经足够用于显示了
#else /*暂时没有使用这种布局*/
#define LCD_TEXT_BTN_HEIGHT 9 // 显示文本区所占的按键的高度
#define DISP_SGN_BTN_HEIGHT 46 // 每一个最薄的按键的高度
#define DISP_LCD_TEXT_LINE 17 // (9*46-1-2-2-2)/(13+3) = 17,
#define MAX_LCD_TEXT_LINE 200 // 仅开辟200行的空间用于显示
#define POP_TEXT_BTN_HEIGHT 3 // 弹出文本区所占的按键的高度
// #define DISP_SGN_BTN_HEIGHT 37 // 每一个最薄的按键的高度
#define DISP_POP_TEXT_LINE 8 // (4*37-1-2-2-2)/(13+3) = 8,
#define MAX_POP_TEXT_LINE 20 // 有20行已经足够用于显示了
#endif // LCD_LAYOUT_VRT_LINE
typedef struct{
byte FirstLine; //可选起始行号.
byte StartLine; //当前页显示的起始位置
byte EndLine; //当前缓冲区所保存的有效信息最大长度
byte LastLine; //刚才光标所在的位置
byte CurrLine; //光标所移到的当前所选行
char text[DISP_LCD_TEXT_LINE*3][MAX_TEXT];//最大可以显示48行, 每行显示32个字符
}TEXT_LCD_DEF;
typedef struct{ /* The lcd text line definition */
byte align; /* Left Align, Right Align, Center Align */
byte text_color; /* Text color */
byte posi_max; /* 当前起始点的个数, 也即字符串段数*/
byte posi[MAX_LINE_POSI];
byte len[MAX_LINE_POSI];
char text[MAX_TEXT];
}LCD_LINE_TEXT_DEF; /* 1+1+4+4+26 = 36 bytes */
/*
当选择了居中对齐的时候, 就必须保证posi_max = 1, 否则进行处理时将得不到所要求的结果
*/
typedef struct{ /* The lcd text definition */
LCD_LINE_TEXT_DEF line[MAX_LCD_TEXT_LINE];
byte max_line; /* The maximum line (1~MAX_LCD_TEXT_LINE) */
byte cur_line; /* Current line (1~MAX_LCD_TEXT_LINE) */
byte dsp_line_st; /* The start display line (0~MAX_LCD_TEXT_LINE-1) */
byte dsp_line_end;/* The endi dispaly end (0~MAX_LCD_TEXT_LINE-1) */
byte dsp_line_new;/* The new display line (0~MAX_LCD_TEXT_LINE-1) */
}LCD_TEXT_DEF; /* 7205 bytes */
/*
Note: The dsp_line_end may be smaller than the
说明: 这里面的数组部能够开到255个字节,因为在程序的算法中,因为在程序的某些地方还
采用了一种快速特殊算法,是直接相加而后判断的。
*/
typedef struct{ /* The lcd text definition */
LCD_LINE_TEXT_DEF line[MAX_LCD_TEXT_LINE]; /* 如果这里的数组过大,则下面的指针需要另外做一些处理 */
byte max_line; /* The maximum line (1~MAX_LCD_TEXT_LINE) */
byte cur_line; /* Current line (1~MAX_LCD_TEXT_LINE) */
byte dsp_line_st; /* The start display line (0~MAX_LCD_TEXT_LINE-1) */
byte dsp_line_end;/* The endi dispaly end (0~MAX_LCD_TEXT_LINE-1) */
byte dsp_line_new;/* The new display line (0~MAX_LCD_TEXT_LINE-1) */
}POP_TEXT_DEF; /* 7205 bytes */
enum{
BUF_ID_TL_TITLE = 0,
KD_UP_TEXT,
PGUP_TEXT,
PGDN_TEXT,
KD_DOWN_TEXT,
BUF_ID_LCD_TEXT,
BUF_ID_TL_SUB,
BUF_ID_TL_INPUT,
CLR_RPT_TEXT,
PRN_RPT_TEXT,
BUF_ID_POP_TEXT,
};
#define DFT_ALING_LCD_TEXT ALIGN_LEFT
#define DFT_ALIGN_TL_STAT ALIGN_MID
#define DFT_ALIGN_TL_INPUT ALIGN_MID
#define DFT_ALIGN_TL_SUB ALIGN_MID
#define DFT_ALIGN_POP_TEXT ALIGN_LEFT /* The align left pop up window */
#define TS_KEY_IDLE 0
#define TS_KEY_PRESS 1
#define BTN_SIZE_1_1 0
#define BTN_SIZE_1_2 1
#define BTN_SIZE_2_1 2
#define BTN_SIZE_2_2 3
#define BTN_SIZE_4_1 4
#define BTN_SAME_SIZE 6
#define BTN_SALE_MAIN_SAME (9+4+1) /* The maximum of same button */
#define BTN_ERR_SAME 2
#define BTN_SEL_SAME 3
#define BTN_HARDPLU_SAME (3+4+1) /* The hard PLU */
#define BTN_REPORT_SAME (11+5)
#define BTN_PROG_MAIN_SAME (9+4+1)
#define BTN_SALE_MAIN_SAME7 4
typedef struct{ /* The rectangle define structure */
int x1;
int x2;
int y1;
int y2;
byte color;
BOOL fill; /* Fill the area or not */
}RECT_DEF;
typedef struct{
int x;
int y;
char *text;
byte text_len;
byte text_color;
}TEXT_DEF;
typedef struct
{
byte color;
int x;
int y;
byte radius;
BOOL fill;
}ROUND_DEF;
typedef struct
{
int x;
int y;
byte mode;
DWORD Addr;
DWORD Size;
}LOGOSTR_DEF;
typedef struct
{
byte mode;
DWORD Addr;
DWORD FileSize;
byte *File;
}BMPFILE_DEF;
#define LCD_PORT PORT1
//#define LCD_PORT PORT4
#define TS_LOGI_OFFSET 0xff//1000 /* 触摸屏Logical Key的偏移量 */
#define SYS_ID_SALE_MAIN 0 /* The sale main mode system ID */
#define SYS_ID_SALE_DPLU 1 /* The hard PLU mode system ID */
#define SYS_ID_SALE_DEPT 2 /* The shift dept mode system ID */
#define SYS_ID_PROG_MAIN 3 /* The program mode system ID */
#define SYS_ID_XZRPT 8
// 正在输入与输入完毕后的显示是不一样的, 需要进行注意的 */
#define TL_INPUT_CLEAR 0 /* 清除显示, 这里一般只按下CLEAR键后的显示 */
#define TL_INPUT_INPUTING 1 /* 正在输入 */
#define TL_INPUT_INPUTED 2 /* 输入完毕 */
#define POP_TEXT_HOR_OFFSET 11 /* The horizontal offset */
#define POP_TEXT_VRT_OFFSET 8 /* The vertical offset */
#define LCD_POSI_SALE_ITEM 1
#define LCD_POSI_SALE_QTY 15
#define LCD_POSI_SALE_PRICE 23
#define LCD_POSI_CASH_INFO 16 /* The cash information position */
#define LCD_POSI_NOR 16 /* The normal position */
#define LCD_POSI_NOR2 12 /* The normal position */
#define LCD_POSI_NOR3 22 /* The normal position */
#define POP_ID_NOR 0 /* The normal pop text ID */
#define POP_ID_SEL 1 /* The select text pop ID */
#define LCD_10_INCH 0 /* 10" */
#define LCD_7_INCH 1 /* 7" */
#define DISP_LCD_TEXT_LINE7 9 // (4*39-1-2-2-2)/(13+3) = 9,
#define LCD_TEXT_BTN_HEIGHT7 4
#define MAX_LCD_TEXT7 26
#define MAX_STAT_TEXT7 13
#define MAX_INPUT_TEXT7 13
#define MAX_SUB_TEXT7 13
#define MAX_POP_TEXT7 19 /* 由于空间不够,这里仅仅用了3个宽度 */
#define LCD_POSI_CASH_INFO7 10
#define LCD_TEXT_BTN_WIDTH7 4 // 显示文本去所占的按键的宽度
#define POP_TEXT_BTN_WIDTH7 3 // 显示文本去所占的按键的宽度
#define TL_STAT_BTN_WIDTH7 2
#define TL_INPUT_BTN_WIDTH7 2
#define TL_SUB_BTN_WIDTH7 2
#define DISP_SGN_BTN_WIDTH7 60 // 每一个最薄按键的宽度
#define DISP_SGN_BTN_HEIGHT7 39 // 每一个最薄的按键的高度
#define POP_TEXT_BTN_HEIGHT7 3 // 弹出文本区所占的按键的高度
#define DISP_POP_TEXT_LINE7 6
#define LOGI_BTN_INPUT7 42 /* The input display button logical position */
#define LOGI_BTN_TEXT7 8 /* The normal text dispaly button logical positon */
#define LOGI_BTN_POP_TEXT7 12 /* The pop up text window */
#define LOGI_BTN_TEXT_STAT7 1 /* The system status display button logical poisition */
#define LOGI_BTN_TEXT_SUB7 40 /* The logo text display button logical position */
#define X_OFFSET_7INCH 60
#define Y_OFFSET_7INCH 117
// The internal function
void Lcd_Draw_Rect(RECT_DEF *rect);
void Lcd_Draw_Round(ROUND_DEF *Round);
#define order_rev(opr, len) byte_rev(opr, len)
void order_rev_eva(byte *dst, byte *src, byte len);
void Lcd_Draw_Text(TEXT_DEF *text);
void Lcd_Draw_Cls(void);
#endif // LCD2_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -