void LCD_Print_Pix(unsigned char x,unsigned char y,unsigned char display_mode);//1/4区域恣意画点程序
unsigned char bank1 Lcd_Buffer0[3][21] = {{0}, {0}}; //LCD显现数据缓存区
unsigned char bank2 Lcd_Buffer1[3][21] = {{0}, {0}}; //LCD显现数据缓存区
///////////////////////LCD恣意方位写点/////////////
//有必要把LCD显现数据缓存,这样才干够恣意画点,RAM需求(48/6)×84个字节才干整个屏幕写
//本程序是1/4 LCD区域内显现恣意点
//x=x轴坐标,y=y轴坐标,display_mode=0不显现;display_mode=1显现点;
void LCD_Print_Pix(unsigned char x,unsigned char y,unsigned char display_mode)
{
unsigned char row;
unsigned char offset;
unsigned char lcd_data;
unsigned char i;
if ( x > 41 ) return; //因为RAM空间问题,对1/4屏幕操作
if ( y > 23 ) return;
if ( display_mode > 1 ) return;
row = y / 8;
offset = y % 8;
if(x<=20)lcd_data = Lcd_Buffer0[row][x]; //从缓冲区读LCD显现数据
if(x>20)lcd_data = Lcd_Buffer1[row][x-21];
if (display_mode == 0)
{
lcd_data &= (~(0x01 << offset));//擦除
}
else if (display_mode== 1)
{
lcd_data|= (0x01 << offset);//画点
}
if(x<=20)Lcd_Buffer0[row][x] = lcd_data; //LCD显现数据保存到缓冲区
if(x>20) Lcd_Buffer1[row][x-21] = lcd_data;
lcd_data=change_char_h_l(lcd_data);//y轴显现时高低位交换
LCD_set_XY(x,row);
////写LCD数据///
LCD_CE=0 ; // 使能LCD
LCD_DC=1 ; // 传送数据
for(i=0;i<8;i++)
{
if((lcd_data>>i)&0x01)
{SPI_MOSI=1;}
else
{SPI_MOSI=0;}
SPI_CLK=0;
NOP();
SPI_CLK=1;
}
LCD_CE=1 ;// 封闭LCD
/////////
}
比如:
LCD_Print_Pix(0,0,1); x显现一个点
画个方块:
for(i=0;i<15;i++)
{
LCD_Print_Pix(i,0,1);
LCD_Print_Pix(i,9,1);
}
for(i=0;i<10;i++)
{
LCD_Print_Pix(0,i,1);
LCD_Print_Pix(14,i,1);
}