//包含所需头文件
#include <ioM16v.h>
#include <macros.h>
//*
//*
/***************************************************************************************************
宏定义
****************************************************************************************************/
#define uchar unsigned char
#define uint unsigned int
//串行通信
#define PORT PORTA //选择引脚口
#define setRS PORT|=(1<<1) //串行的片选信号
#define clearRS PORT&=~(1<<1)
#define setRW PORT|=(1<<2) //串行的数据口
#define clearRW PORT&=~(1<<2)
#define setCKL PORT|=(1<<3),delay_nus(1) //串行的同步时钟
#define clearCKL PORT&=~(1<<3),delay_nus(1)
#define Clear WriteCommand(0x01),delay_nms(5) //清屏
#define hanzishu 18 //输入汉字数
#define howmany0 1 //在开始显示汉字前填入多少个相同的汉字 (一般填空字)
#define position 6 //填什么样的相同汉字(一般填空字)
#define homMHZPosition 8 //以多少个汉字位来显示移动汉字
/***************************************************************************************************
宏定义
****************************************************************************************************/
//全局变量
uchar temp[17][(howmany0+hanzishu)*2+2];
bn=0;
char lin1[]={"时间:00:00:00 A"};
char lin2[]={"经度:00000.0000"};
char lin3[]={"纬度:0000.0000"};
char lin4[]={" 东经 北纬 "};
uchar data_item=0; //接收到第几个字节
uchar g_Ptr = 0; //所要提取的一节信息的字节数
uchar g_Class = 0; //提取信息节数
uchar g_DataVari = 0;
uint rece_num = 0; //
uchar g_DisTime[6]={"000000"}; //时间
uchar g_Diss [1]={" "}; //定位状态
uchar g_Diswie [9]={"0000.1111"}; //纬度
uchar g_Disns [1]={"N"}; //北纬N/南纬S
uchar g_Disjing[10]={"00000.0000"};//经度
uchar g_Disew [1]={"E"}; //东经E/西经W
/***************************************************************************************************
下面是 全局函数
****************************************************************************************************/
void delay_1us(void) ;//
void delay_nus(unsigned int n);
void delay_1ms(void);
void delay_nms(unsigned int n);
void send_8bit(uchar ch);//发送8位数据
void WriteData(uchar data);//写数据
void WriteCommand(uchar command);//写地址
void guangbiao(uchar x); //光标开关,1开,0关
void lcd12864_init(void); //液晶初始化程序
void Set_display_Adress(uchar y,uchar x);//设置显示坐标:y行,x列
void display_Char(uchar y, uchar x,uchar);
void display_String(uchar y,uchar x,uchar *s) ; //显示字符串
void display_Num(uchar y,uchar x,uint num,char N);//可以显示 N 位的的整数num,(从个位起)最多显示6位
void Display_Picture(const uchar *tab );//全屏显示图形子程序 128*64
void Display_Picture32( uchar *tab );//显示图形子程序 32*32
void display_hanzi();
void leftmove32x32(uchar *tu );
void putin (uchar point);
void clearRAM (void);
void left_move(void);
void zaihanzi(void);
void left_movedisplay(void);
shownum( unsigned char i,unsigned char j, float num);//LCD显示 显示带有数码包括整数,浮点
/***************************************************************************************************
上述为 全局函数
****************************************************************************************************/
/*-----------------------------------------------------------------------
延时函数
系统时钟:8M
-----------------------------------------------------------------------*/
void delay_1us(void) //1us延时函数
{
asm("nop");
}
void delay_nus(unsigned int n) //N us延时函数
{
unsigned int i=0;
for (i=0;i<n;i++)
delay_1us();
}
void delay_1ms(void) //1ms延时函数
{
unsigned int i;
for (i=0;i<1140;i++);
}
void delay_nms(unsigned int n) //N ms延时函数
{
unsigned int i=0;
for (i=0;i<n;i++)
delay_1ms();
}
/*-----------------------------------------------------------------------
延时函数
系统时钟:8M
-----------------------------------------------------------------------*/
/***************************************************************************************************
下面为12864液晶模块驱动程序
****************************************************************************************************/
//汉字图像 若将其用另文件存放则显示汉字不正常
const uchar HZ[19][32]={
/*-- 文字: 过 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x40,0x10,0x20,0x10,0x30,0x10,0x20,0x10,0x07,0xFE,0x00,0x10,0x02,0x10,0xE1,0x10,
0x21,0x90,0x21,0x10,0x20,0x10,0x20,0x50,0x20,0x20,0x58,0x00,0x87,0xFE,0x00,0x00,
//下面是数字10: 构造分法,用1与0的数码,把0的数码交替地放在1代码后面
//0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x18,0x70,0x24,0x10,0x42,0x10,0x42,0x10,0x42,
//0x10,0x42,0x10,0x42,0x10,0x42,0x10,0x42,0x10,0x42,0x7c,0x18,0x00,0x00,0x00,0x00,
/*-- 文字: 去 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x01,0x00,0x01,0x00,0x01,0x00,0x3F,0xFC,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
0x7F,0xFE,0x02,0x00,0x06,0x00,0x08,0x20,0x10,0x10,0x3F,0xF8,0x10,0x10,0x00,0x00,
/*-- 文字: 属 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x3F,0xFC,0x20,0x04,0x3F,0xFC,0x20,0x00,0x2F,0xF8,0x20,0x80,0x27,0xF8,0x24,0x88,
0x27,0xF8,0x20,0x80,0x2F,0xFC,0x28,0xA4,0x48,0xF4,0x4B,0x14,0x88,0x04,0x08,0x0C,
/*-- 文字: 于 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x3F,0xFC,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,0x01,0x00,
0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x09,0x00,0x05,0x00,0x02,0x00,
/*-- 文字: 死 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x7F,0xFE,0x08,0x40,0x08,0x40,0x1F,0x40,0x11,0x46,0x21,0x58,0x32,0x60,
0x4A,0x40,0x8A,0x40,0x04,0x40,0x04,0x42,0x08,0x42,0x30,0x42,0xC0,0x3E,0x00,0x00,
/*-- 文字: 神 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x20,0x20,0x10,0x20,0x10,0x20,0xFD,0xFC,0x05,0x24,0x09,0x24,0x11,0xFC,0x39,0x24,
0x55,0x24,0x95,0xFC,0x11,0x24,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,
/*-- 11文字: 空字 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//11
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/*-- 文字: 现 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0xFF,0xF8,0x12,0x08,0x12,0x48,0x12,0x48,0x12,0x48,0x7E,0x48,0x12,0x48,
0x12,0x48,0x12,0xA8,0x1C,0xA0,0xE1,0x22,0x01,0x22,0x02,0x22,0x04,0x1E,0x08,0x00,
/*-- 文字: 在 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x02,0x00,0x02,0x00,0x7F,0xFE,0x04,0x00,0x04,0x00,0x08,0x40,0x18,0x40,0x17,0xFC,
0x30,0x40,0x50,0x40,0x90,0x40,0x10,0x40,0x10,0x40,0x17,0xFE,0x10,0x00,0x00,0x00,
/*-- 文字: 与 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x08,0x00,0x08,0x04,0x0F,0xFE,0x08,0x00,0x08,0x00,0x0F,0xFC,0x00,0x04,
0x00,0x04,0x00,0x24,0x7F,0xF4,0x00,0x04,0x00,0x04,0x00,0x48,0x00,0x30,0x00,0x00,
/*-- 文字: 未 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x01,0x00,0x01,0x00,0x01,0x00,0x3F,0xF8,0x01,0x00,0x01,0x00,0xFF,0xFE,0x03,0x00,
0x03,0x80,0x05,0x40,0x05,0x20,0x09,0x18,0x31,0x0E,0xC1,0x04,0x01,0x00,0x01,0x00,
/*-- 文字: 来 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x01,0x00,0x01,0x00,0x3F,0xFC,0x01,0x00,0x09,0x30,0x05,0x20,0x03,0x40,0x7F,0xFE,
0x01,0x80,0x03,0x40,0x05,0x20,0x09,0x18,0x31,0x0E,0xC1,0x04,0x01,0x00,0x01,0x00,
/*-- 文字: 却 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x08,0x00,0x08,0x7C,0x08,0x44,0x7F,0x44,0x08,0x44,0x08,0x44,0x08,0x44,0xFF,0x44,
0x10,0x44,0x12,0x44,0x21,0x44,0x27,0xD4,0x79,0x48,0x20,0x40,0x00,0x