📄 gal.lst
字号:
C51 COMPILER V7.07 GAL 05/17/2003 12:00:52 PAGE 1
C51 COMPILER V7.07, COMPILATION OF MODULE GAL
OBJECT MODULE PLACED IN GAL.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.exe GAL.c DB OE
stmt level source
1 //********************************************************************************************************
-*******************************************
2 //文件名:GAL.c
3 //作用:图形接口
4 //********************************************************************************************************
-********************************************
5 #include "Typedef.h"
6 #include "system.h"
7 unsigned char test[4];
8 //********************************************************************************************************
-***************************************
9 //测字符串的长度
10 //********************************************************************************************************
-***************************************
11 unsigned int strlen(char* str)
12 {
13 1 unsigned int i=0;
14 1 while(str[i]!='\0')
15 1 {
16 2 i++;
17 2 }
18 1 return i;
19 1 }
20
21 //========================================================================================================
-===================
22 //置前景色
23 //========================================================================================================
-===================
24 void set_fore_color(unsigned char fore_color)
25 {
26 1 send_lcd_byte(0x1b);
27 1 send_lcd_byte(0x42);
28 1 send_lcd_byte(fore_color);
29 1 }
30
31 //=======================================================================================================
32 //显示汉字或英文
33 //=======================================================================================================
34 void languge_mode(unsigned char lan_flag,unsigned char cover_flag)
35 {
36 1 //置西文模式
37 1 send_lcd_byte(0x1b);
38 1 if(lan_flag==English)
39 1 send_lcd_byte(0x24);
40 1 else
41 1 send_lcd_byte(0x23); //中文显示
42 1 //覆盖方式显示
43 1 send_lcd_byte(0x1b);
44 1 send_lcd_byte(0x58);
45 1 if(cover_flag==yes)
46 1 send_lcd_byte(0x01);
47 1 else
48 1 send_lcd_byte(0x00);
49 1 }
C51 COMPILER V7.07 GAL 05/17/2003 12:00:52 PAGE 2
50
51 //********************************************************************************************************
-********************************************
52 //作用:在指定像素处输入字符串
53 //参素:像素x坐标,像素y坐标,要显示字符串指针
54 //********************************************************************************************************
-********************************************
55 void set_window_text(unsigned int x,unsigned int y,unsigned char language_mode,unsigned char cover_flag, c
-har* str)
56 {
57 1 unsigned i,str_len;
58 1 //设置插入点
59 1 send_lcd_byte(0x1b);
60 1 send_lcd_byte(0x48);
61 1 send_lcd_byte((unsigned char)x);
62 1 send_lcd_byte(x>>8);
63 1 send_lcd_byte((unsigned char)y);
64 1 send_lcd_byte(y>>8);
65 1 languge_mode(language_mode,cover_flag);
66 1 //显示字符串
67 1 str_len=strlen(str);
68 1 for(i=0;i<str_len;i++)
69 1 {
70 2 send_lcd_byte(str[i]);
71 2 }
72 1
73 1 }
74
75 //======================================================================================================
76 //显示单个英文字符字符
77 //======================================================================================================
78 void set_window_char(unsigned char Char)
79 {
80 1 send_lcd_byte(Char);
81 1 }
82 //=======================================================================================================
83 //显示一串字符
84 //=======================================================================================================
85 void set_window_str(unsigned char* str)
86 {
87 1 unsigned i,str_len;
88 1 str_len=strlen(str);
89 1 for(i=0;i<str_len;i++)
90 1 {
91 2 send_lcd_byte(str[i]);
92 2 }
93 1 }
94 //========================================================================================================
-===========================
95 //指定光标到特定像素处
96 //========================================================================================================
-=============================
97 void set_caract_pos(unsigned int x,unsigned int y)
98 {
99 1 //光标定位到像素(x,y)处
100 1 send_lcd_byte(0x1b);
101 1 send_lcd_byte(0x48);
102 1 send_lcd_byte((unsigned char)x);
103 1 send_lcd_byte(x>>8);
104 1 send_lcd_byte((unsigned char)y);
105 1 send_lcd_byte(y>>8);
106 1
C51 COMPILER V7.07 GAL 05/17/2003 12:00:52 PAGE 3
107 1 }
108 //========================================================================================================
-=======================================
109 //指定光标的前景色和背景色
110 //========================================================================================================
-=======================================
111 void set_caract_color(unsigned char back_color,unsigned char fore_color)
112 {
113 1 send_lcd_byte(0x1b);
114 1 send_lcd_byte(0x38);
115 1 send_lcd_byte(fore_color);
116 1 send_lcd_byte(back_color);
117 1 }
118 //=======================================================================================================
119 //显示和隐藏光标
120 //======================================================================================================
121 void show_caract(unsigned char show)
122 {
123 1 send_lcd_byte(0x1b);
124 1 send_lcd_byte(0x57);
125 1 if(show==yes)
126 1 send_lcd_byte(1);
127 1 else
128 1 send_lcd_byte(0);
129 1
130 1 }
131
132 //=======================================================================================================
133 //初始化光标,注意:以下设置光标的三种顺序不能打乱
134 //=======================================================================================================
135 void init_caract(unsigned int x,unsigned int y,unsigned char back_color,unsigned char fore_color,unsigned
-char show)
136 {
137 1
138 1 //设置光标的前景色和背景色
139 1 set_caract_color(back_color,fore_color);
140 1 //是否显示光标
141 1 show_caract(show);
142 1 //光标定位到像素(x,y)处
143 1 set_caract_pos(x,y);
144 1 }
145
146
147 //=======================================================================================================
148 //画实心矩阵,(x1,y1),(x2,y2)分别对应矩形左上角和右下角坐标,颜色默认为黑色
149 //=======================================================================================================
150 void draw_full_rect(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2,unsigned char color)
151 {
152 1 send_lcd_byte(0x1b);
153 1 send_lcd_byte(0x41);
154 1 send_lcd_byte(color); //默认颜色为黑色
155 1 send_lcd_byte((unsigned char)x1);
156 1 send_lcd_byte(x1>>8);
157 1 send_lcd_byte((unsigned char)y1);
158 1 send_lcd_byte(y1>>8);
159 1 send_lcd_byte((unsigned char)x2);
160 1 send_lcd_byte(x2>>8);
161 1 send_lcd_byte((unsigned char)y2);
162 1 send_lcd_byte(y2>>8);
163 1
164 1 }
165 //========================================================================================================
C51 COMPILER V7.07 GAL 05/17/2003 12:00:52 PAGE 4
-========
166 //覆盖静态框
167 //========================================================================================================
-=========
168 void cover_static(Cstatic* sta)
169 {
170 1 draw_full_rect(sta->x1,sta->y1,sta->x2,sta->y2,0x4f);
171 1 }
172
173 //=======================================================================================
174 //在闭合曲线里填充颜色
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -