课程实验
#include "lcd12864.h"
void delay(uint x)
{
uint i, j;
for(i = x; i > 0; i--)
for(j = 1500; j > 0; j--);
}
void send_command(uchar date)
{
uchar i;
uchar date2;
date2 = 0xf8;
CS = 1;
//SCLK = 0;
for(i = 0; i < 8; i++)
{
SID = (bit)(date2 & 0x80);
SCLK = 0;
SCLK = 1;
date2 = date2 << 1;
}
date2 = date;
date2 &= 0xf0;
for(i = 0; i < 8; i++)
{
SID = (bit)(date2 & 0x80);
SCLK = 0;
SCLK = 1;
date2 = date2 << 1;
}
date2 = date;
date2 <<= 4;
for(i = 0; i < 8; i++)
{
SID = (bit)(date2 & 0x80);
SCLK = 0;
SCLK = 1;
date2 = date2 << 1;
}
CS = 0;
delay(10);
}
void send_date(uchar date)
{
uchar i;
uchar date2;
date2 = 0xfa;
CS = 1;
SCLK = 0;
for(i = 0; i < 8; i++)
{
SID = (bit)(date2 & 0x80);
SCLK = 0;
SCLK = 1;
date2 = date2 << 1;
}
date2 = date;
date2 &= 0xf0;
for(i = 0; i < 8; i++)
{
SID = (bit)(date2 & 0x80);
SCLK = 0;
SCLK = 1;
date2 = date2 << 1;
}
date2 = date;
date2 <<= 4;
for(i = 0; i < 8; i++)
{
SID = (bit)(date2 & 0x80);
SCLK = 0;
SCLK = 1;
date2 = date2 << 1;
}
CS = 0;
delay(10);
}
void lcd_pos(uchar x, uchar y)
{
uchar pos;
if(x == 0)
x = 0x80;
else
if(x == 1)
x = 0x90;
else
if(x == 2)
x = 0x88;
else
if(x == 3)
x = 0x98;
pos = x + y;
send_command(pos);
}
void init()
{
delay(100);
PSB = 0;
send_command(0x30);
send_command(0x02);
send_command(0x06);
send_command(0x0c);
send_command(0x01);
lcd_pos(0, 0);
}
一般程序架构也很重要的~~~~
不太了解 学习一下
gp2y10au 是什么玩意,没玩过
灰尘传感器