初级会员

- 积分
- 73
- 金钱
- 73
- 注册时间
- 2018-4-19
- 在线时间
- 23 小时
|
最近从原子哥那买了个ATK-S1216 GPS+北斗定位模块,想把解析的gps信息输出12864屏里面去,但是不会用ips进行单片机与12864的通信,请问各位大佬有相关的代码吗,lcd12864用串行写的,还有就是我的lcd屏输出每次都只有第一行输出,,,
void SendByte(uchar Dbyte) //按照液晶的串口通讯协议,发送数据
{
uchar i;
for(i=0;i<8;i++)
{
// SCK = 0; ////重要
if((Dbyte<<i) & 0x80)
{
SID = 1;
}
else
{
SID = 0;
}
SCK = 0;
SCK = 1;
}
}
uchar ReceiveByte(void) //
{
uchar i,temp1,temp2;
temp1 = 0;
temp2 = 0;
for(i=0;i<8;i++)
{
temp1=temp1<<1;
SCK = 0;
SCK = 1;
SCK = 0;
if(SID) temp1++;
}
for(i=0;i<8;i++)
{
temp2=temp2<<1;
SCK = 0;
SCK = 1;
SCK = 0;
if(SID) temp2++;
}
return ((0xf0&temp1)+(0x0f&temp2));
}
void CheckBusy( void ) //检测忙标志
{
do SendByte(0xfc);
while(0x80&ReceiveByte());
}
void WriteCommand(uchar Cbyte ) //发送命令到LCD
{
CS = 1;
CheckBusy();
SendByte(0xf8);
SendByte(0xf0&Cbyte);
SendByte(0xf0&Cbyte<<4);
delay_ms(2);
// CS = 0;
}
void WriteData(uchar Dbyte ) //发送显示内容到LCD
{
CS = 1;
CheckBusy();
SendByte(0xfa);
SendByte(0xf0&Dbyte);
SendByte(0xf0&Dbyte<<4);
// CS = 0;
}
uchar ReadData( void ) //读取LCD显示内容
{
CheckBusy();
SendByte(0xfe);
return ReceiveByte();
}
void Delay(uint MS)
{
uchar us,usn;
while(MS!=0)
{
usn = 2;
while(usn!=0)
{
us = 0xf5;
while (us!=0)
{
us--;
};
usn--;
}
MS--;
}
}
void LcmInit( void ) //LCD初始化
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA |RCC_APB2Periph_GPIOC |RCC_APB2Periph_GPIOD, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5; //LED1\2\3-->PC.13\14\15 端口配置
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //IO口速度为50MHz
GPIO_Init(GPIOA, &GPIO_InitStructure); //根据设定参数初始化GPIOC
WriteCommand(0x30); // 8位数据端口、选择基本指令
delay_ms(10);
WriteCommand(0x01); // 显示清屏
delay_ms(10);
WriteCommand(0x0C); // 显示设定:整体显示、游标关、不反白
delay_ms(10);
}
void LcmClearTXT( void ) //清屏
{
uchar i;
WriteCommand(0x30);
WriteCommand(0x80);
for(i=0;i<64;i++)
WriteData(0x20);
}
void Display_LCD_Pos(u8 x,u8 y) // 输入定位
{
switch(x)
{
// case 0: WriteCommand(0x80+y); break;
case 1: WriteCommand(0x80+y); break;
case 2: WriteCommand(0x90+y); break;
case 3: WriteCommand(0xA0+y); break;
case 4: WriteCommand(0xB0+y); break;
case 5: WriteCommand(0x88+y); break;
case 6: WriteCommand(0x98+y); break;
case 7: WriteCommand(0xA8+y); break;
case 8: WriteCommand(0xB8+y); break;
}
WriteCommand(x); //显示地址
}
void PutStr(u8 x,u8 y,u8 *s) //打印输出
{
Display_LCD_Pos(x,y);
while(*s)
{
WriteData(*s);
s++;
delay_ms(50);
}
}
void Lcd12864_DisplayStr(u8 *s)//显示字符串
{
while(*s != '\0')
{
WriteData(*s);
s++;
delay_ms(50); //控制每一个字符之间显示的时间 间隔
}
}
求大佬解答!!!
|
|