📄 graph.c
字号:
void loc_xy(unsigned char X,unsigned char Y);
void line(unsigned char pos);
void cls_grap(void);
void cls_grap(void);
extern unsigned char code line_code[16][6];
extern void send_i(unsigned char comm);
extern void send_d(unsigned char data_in);
//写GDRAM地址
void loc_xy(unsigned char X,unsigned char Y)
{
send_i(Y);
send_i(X);
}
/*画直线
当目标位于1、3象限时,直线斜率为45度,pos = 1, 由(0x94,0x9f)开始从下向上画
当目标位于2、4象限时,直线斜率为135度,pos = 0,由(0x8c,0x80)开始从上向下画
*/
void line(bit pos)
{
unsigned char *p;
unsigned char x,y,t_x,t_y;
p = line_code;
if(pos)
y = 0x9F;
else
y = 0x80;
cls_grap();
for(t_y = 0;t_y < 32;t_y ++)
{
if(t_y < 16)
{
if(!pos)
x = 0x8C;
else
x = 0x94;
loc_xy(x,y);
for(t_x = 0;t_x < 6;t_x ++)
{
send_d(*p);
p++;
}
}
else
{
if(t_y == 16)
p = line_code;
if(!pos)
x = 0x91;
else
x = 0x89;
loc_xy(x,y);
for(t_x = 0;t_x < 6;t_x++)
{
send_d(*p);
p++;
}
}
if(pos)
y --;
else
y ++;
}
send_i(0x30);
}
/********************扩充指令集清屏子程序********************/
void cls_grap()
{
unsigned char Disp_Page;
unsigned char i,j;
send_i(0x34);
send_i(0x36);
for(i = 0; i < 64; i ++)/*共32页*/
{
Disp_Page = i | 0x80;/*设置页地址*/
loc_xy(0x80,Disp_Page);/*送入页地址*//*送入起始列地址*/
for(j = 0;j < 32;j ++)
{
send_d(0x00);/*清屏*/
}
}
}
/*
//画点
void dot(unsigned char x,unsigned char y,unsigned char state)
{
unsigned char LCD_X,LCD_Y,old_pic1,old_pic2,temp,dx,kk;
//地址转换,左上角为(0,0)点
LCD_X = x/16;
if(y<=31)
{
LCD_Y = 0x80 + 31 - y;
LCD_X = 0x88 + LCD_X;
}
else
{
LCD_Y = 0x80 + 63 - y;
LCD_X = 0X80 + LCD_X;
}
//读取GDRAM中数据
loc_xy(LCD_X,LCD_Y);
read_ram();
old_pic1 = read_ram();
old_pic2 = read_ram();
dx = x%16;
loc_xy(LCD_X,LCD_Y);
if(dx<=7)
{
temp = 1;
temp = temp<<(7-dx);
if(state==1)
{
kk = old_pic1|temp;
}
else
{
temp = 1;
kk = old_pic1&(~(temp));
}
send_d(kk);
send_d(old_pic2);
}
else
{
temp = 1;
temp = temp<<(15-dx);
if(state==1)
{
kk = old_pic2|temp;
}
else
{
kk = old_pic2&(~(temp));
}
send_d(old_pic1);
send_d(kk);
}
}
void lcd_display(void)
{
send_i(0x34);
send_i(0x36);
send_i(0x30);
}
//全屏画图
void send_grap(unsigned char * pic)
{
unsigned char LCD_X,LCD_Y,x,y;
LCD_Y = 0x80;
LCD_X = 0x80;
for(y = 0;y <= 31;y++)
{
LCD_X = 0x80;
for(x = 0;x <= 7;x++)
{
loc_xy(LCD_X,LCD_Y);
send_d(*pic);
pic++;
send_d(*pic);
pic++;
LCD_X++;
}
LCD_Y++;
}
LCD_Y = 0x80;
for(y = 0;y <= 31;y++)
{
LCD_X = 0x88;
for(x = 0;x <= 7;x++)
{
loc_xy(LCD_X,LCD_Y);
send_d(*pic);
pic++;
send_d(*pic);
pic++;
LCD_X++;
}
LCD_Y++;
}
send_i(0x34);
send_i(0x36);
send_i(0x30);
}
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -