LCD_set_XY(X,Y);
for (n=0; n<83; n++)
{
LCD_write_byte(buffer_h[n],1);
}
LCD_set_XY(X,Y+1);
for (n=0; n<83; n++)
{
LCD_write_byte(buffer_l[n],1);
}
delay_nms(T);
}
}
/*-----------------------------------------------------------------------
LCD_draw_map : 位图绘制函数
输入参数:X、Y :位图绘制的起始X、Y坐标;
*map :位图点阵数据;
Pix_x :位图像素(长)
Pix_y :位图像素(宽)
-----------------------------------------------------------------------*/
void LCD_draw_map(unsigned char X,unsigned char Y,unsigned char *map,
unsigned char Pix_x,unsigned char Pix_y)
{
unsigned int i,n;
unsigned char row;
if (Pix_y%8==0) row=Pix_y/8; //计算位图所占行数
else
row=Pix_y/8+1;
for (n=0;n<row;n++)
{
LCD_set_XY(X,Y);
for(i=0; i<Pix_x; i++)
{
LCD_write_byte(map[i+n*Pix_x], 1);
}
Y++; //换行
}
}
/*-----------------------------------------------------------------------
LCD_write_byte : 使用SPI接口写数据到LCD
输入参数:data :写入的数据;
command :写数据/命令选择;
-----------------------------------------------------------------------*/
void LCD_write_byte(unsigned char data, unsigned char command)
{
PORTB &= ~LCD_CE ; // 使能LCD
if (command == 0)
PORTB &= ~LCD_DC ; // 传送命令
else
PORTB |= LCD_DC ; // 传送数据
SPDR = data; // 传送数据到SPI寄存器
while ((SPSR & 0x80) == 0); // 等待数据传送完毕
PORTB |= LCD_CE ; // 关闭LCD
}
本文关键字:单片机 仪表-仪器,电子制作 - 仪表-仪器