单片机 > 单片机程序设计 > 详情

单片机LCD12864滚动和反白显示图片

发布时间:2023-05-31 发布时间:
|

本任务是用单片机实现液晶显示演示效果如图所示。通过编程,学会在单片机上实现液晶显示控制方法,以及不同数据显示的程序编写方法。


单片机源程序如下:

#include "LCD_12864.h"

#include

extern void cls();

extern uchar LCD_Initialise();

extern uchar LCD_Write_Command(uchar cmd);

extern uchar LCD_Write_Command_P2(uchar cmd,uchar para1,uchar para2);

extern uchar LCD_Write_Data(uchar dat);

extern void Set_LCD_POS(uchar row,uchar col);

extern uchar code LCD_WIDTH;

extern uchar code LCD_HEIGHT;

sbit S1 = P1^0;

sbit S2 = P1^1;


uchar code ImageX[] =

{

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00


};


void main()

{

uchar i,j,m;

uint k,x;

LCD_Initialise();

Set_LCD_POS(0,0);

cls();

while(1)

{

if(S1!=0)

{

LCD_Write_Command_P2(LC_GRH_STP,0,0);

for(i=0;i

{

Set_LCD_POS(i,0);

LCD_Write_Command(LC_AUT_WR);

for(j=0;j

{

m = ImageX[i*LCD_WIDTH + j];

if(S2 == 0)

m = ~m;

LCD_Write_Data(m);

}

LCD_Write_Command(LC_AUT_OVR);

}

}

else

{

k = 0;

while(k!=128/8*LCD_HEIGHT)

{

LCD_Write_Command_P2(LC_GRH_STP,k%256,k/256);

for(x=0;x<5000;x++);

k+=LCD_WIDTH;

}

}

}

for(x=0;x<40000;x++);

}



『本文转载自网络,版权归原作者所有,如有侵权请联系删除』

热门文章 更多
MSP430低功耗模式-while循环失效