找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1475|回复: 4
打印 上一主题 下一主题
收起左侧

LCD160128中文显示温度与时间 用keil4如何解决问题

[复制链接]
跳转到指定楼层
楼主
用keil 4l代码总是出现这个问题,是代码有误吗?

#include <reg52.h>
#include <stdarg.h>
#include <stdio.h>
#include <math.h>
#include <intrins.h>
#include <absacc.h>
#include <string.h>

  #define ASC_CHR_WIDTH  8
#define ASC_CHR_HEIGHT 12
#define HZ_CHR_HEIGHT 12
#define HZ_CHR_WIDTH 12
uchar code LCD_WIDTH =20
uchar code LCD_HEIGHT=128
uchar code ASC_MSK[96*12]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// ' '
0x00,0x30,0x78,0x78,0x78,0x30,0x30,0x00,0x30,0x30,0x00,0x00,// '!'
0x00,0x66,0x66,0x66,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// '"'
0x00,0x6c,0x6c,0xfe,0x6c,0x6c,0x6c,0xfe,0x6c,0x6c,0x00,0x00,// '#'
0x30,0x30,0x7c,0xc0,0xc0,0x78,0x0c,0x0c,0xf8,0x30,0x30,0x00,// '$'
0x00,0x00,0x00,0xc4,0xcc,0x18,0x30,0x60,0xcc,0x8c,0x00,0x00,// '%'
0x00,0x70,0xd8,0xd8,0x70,0xfa,0xde,0xcc,0xdc,0x76,0x00,0x00,// '&'
0x00,0x30,0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// '''
0x00,0x0c,0x18,0x30,0x60,0x60,0x60,0x30,0x18,0x0c,0x00,0x00,// '('
0x00,0x60,0x30,0x18,0x0c,0x0c,0x0c,0x18,0x30,0x60,0x00,0x00,// ')'
0x00,0x00,0x00,0x66,0x3c,0xff,0x3c,0x66,0x00,0x00,0x00,0x00,// '*'
0x00,0x00,0x00,0x18,0x18,0x7e,0x18,0x18,0x00,0x00,0x00,0x00,// '+'
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x60,0x00,// ','
0x00,0x00,0x00,0x00,0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,// '-'
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x00,0x00,// '.'
0x00,0x00,0x02,0x06,0x0c,0x18,0x30,0x60,0xc0,0x80,0x00,0x00,// '/'
0x00,0x7c,0xc6,0xce,0xde,0xd6,0xf6,0xe6,0xc6,0x7c,0x00,0x00,// '0'
0x00,0x10,0x30,0xf0,0x30,0x30,0x30,0x30,0x30,0xfc,0x00,0x00,// '1'
0x00,0x78,0xcc,0xcc,0x0c,0x18,0x30,0x60,0xcc,0xfc,0x00,0x00,// '2'
0x00,0x78,0xcc,0x0c,0x0c,0x38,0x0c,0x0c,0xcc,0x78,0x00,0x00,// '3'
0x00,0x0c,0x1c,0x3c,0x6c,0xcc,0xfe,0x0c,0x0c,0x1e,0x00,0x00,// '4'
0x00,0xfc,0xc0,0xc0,0xc0,0xf8,0x0c,0x0c,0xcc,0x78,0x00,0x00,// '5'
0x00,0x38,0x60,0xc0,0xc0,0xf8,0xcc,0xcc,0xcc,0x78,0x00,0x00,// '6'
0x00,0xfe,0xc6,0xc6,0x06,0x0c,0x18,0x30,0x30,0x30,0x00,0x00,// '7'
0x00,0x78,0xcc,0xcc,0xec,0x78,0xdc,0xcc,0xcc,0x78,0x00,0x00,// '8'
0x00,0x78,0xcc,0xcc,0xcc,0x7c,0x18,0x18,0x30,0x70,0x00,0x00,// '9'
0x00,0x00,0x00,0x38,0x38,0x00,0x00,0x38,0x38,0x00,0x00,0x00,// ':'
0x00,0x00,0x00,0x38,0x38,0x00,0x00,0x38,0x38,0x18,0x30,0x00,// ';'
0x00,0x0c,0x18,0x30,0x60,0xc0,0x60,0x30,0x18,0x0c,0x00,0x00,// '<'
0x00,0x00,0x00,0x00,0x7e,0x00,0x7e,0x00,0x00,0x00,0x00,0x00,// '='
0x00,0x60,0x30,0x18,0x0c,0x06,0x0c,0x18,0x30,0x60,0x00,0x00,// '>'
0x00,0x78,0xcc,0x0c,0x18,0x30,0x30,0x00,0x30,0x30,0x00,0x00,// '?'
0x00,0x7c,0xc6,0xc6,0xde,0xde,0xde,0xc0,0xc0,0x7c,0x00,0x00,// '@'
0x00,0x30,0x78,0xcc,0xcc,0xcc,0xfc,0xcc,0xcc,0xcc,0x00,0x00,// 'A'
0x00,0xfc,0x66,0x66,0x66,0x7c,0x66,0x66,0x66,0xfc,0x00,0x00,// 'B'
0x00,0x3c,0x66,0xc6,0xc0,0xc0,0xc0,0xc6,0x66,0x3c,0x00,0x00,// 'C'
0x00,0xf8,0x6c,0x66,0x66,0x66,0x66,0x66,0x6c,0xf8,0x00,0x00,// 'D'
0x00,0xfe,0x62,0x60,0x64,0x7c,0x64,0x60,0x62,0xfe,0x00,0x00,// 'E'
0x00,0xfe,0x66,0x62,0x64,0x7c,0x64,0x60,0x60,0xf0,0x00,0x00,// 'F'
0x00,0x3c,0x66,0xc6,0xc0,0xc0,0xce,0xc6,0x66,0x3e,0x00,0x00,// 'G'
0x00,0xcc,0xcc,0xcc,0xcc,0xfc,0xcc,0xcc,0xcc,0xcc,0x00,0x00,// 'H'
0x00,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00,// 'I'
0x00,0x1e,0x0c,0x0c,0x0c,0x0c,0xcc,0xcc,0xcc,0x78,0x00,0x00,// 'J'
0x00,0xe6,0x66,0x6c,0x6c,0x78,0x6c,0x6c,0x66,0xe6,0x00,0x00,// 'K'
0x00,0xf0,0x60,0x60,0x60,0x60,0x62,0x66,0x66,0xfe,0x00,0x00,// 'L'
0x00,0xc6,0xee,0xfe,0xfe,0xd6,0xc6,0xc6,0xc6,0xc6,0x00,0x00,// 'M'
0x00,0xc6,0xc6,0xe6,0xf6,0xfe,0xde,0xce,0xc6,0xc6,0x00,0x00,// 'N'
0x00,0x38,0x6c,0xc6,0xc6,0xc6,0xc6,0xc6,0x6c,0x38,0x00,0x00,// 'O'
0x00,0xfc,0x66,0x66,0x66,0x7c,0x60,0x60,0x60,0xf0,0x00,0x00,// 'P'
0x00,0x38,0x6c,0xc6,0xc6,0xc6,0xce,0xde,0x7c,0x0c,0x1e,0x00,// 'Q'
0x00,0xfc,0x66,0x66,0x66,0x7c,0x6c,0x66,0x66,0xe6,0x00,0x00,// 'R'
0x00,0x78,0xcc,0xcc,0xc0,0x70,0x18,0xcc,0xcc,0x78,0x00,0x00,// 'S'
0x00,0xfc,0xb4,0x30,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00,// 'T'
0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x78,0x00,0x00,// 'U'
0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x78,0x30,0x00,0x00,// 'V'
0x00,0xc6,0xc6,0xc6,0xc6,0xd6,0xd6,0x6c,0x6c,0x6c,0x00,0x00,// 'W'
0x00,0xcc,0xcc,0xcc,0x78,0x30,0x78,0xcc,0xcc,0xcc,0x00,0x00,// 'X'
0x00,0xcc,0xcc,0xcc,0xcc,0x78,0x30,0x30,0x30,0x78,0x00,0x00,// 'Y'
0x00,0xfe,0xce,0x98,0x18,0x30,0x60,0x62,0xc6,0xfe,0x00,0x00,// 'Z'
0x00,0x3c,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x3c,0x00,0x00,// '['
0x00,0x00,0x80,0xc0,0x60,0x30,0x18,0x0c,0x06,0x02,0x00,0x00,// '\'
0x00,0x3c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x3c,0x00,0x00,// ']'
0x10,0x38,0x6c,0xc6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// '^'
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,// '_'
0x30,0x30,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// '`'
0x00,0x00,0x00,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0x76,0x00,0x00,// 'a'
0x00,0xe0,0x60,0x60,0x7c,0x66,0x66,0x66,0x66,0xdc,0x00,0x00,// 'b'
0x00,0x00,0x00,0x00,0x78,0xcc,0xc0,0xc0,0xcc,0x78,0x00,0x00,// 'c'
0x00,0x1c,0x0c,0x0c,0x7c,0xcc,0xcc,0xcc,0xcc,0x76,0x00,0x00,// 'd'
0x00,0x00,0x00,0x00,0x78,0xcc,0xfc,0xc0,0xcc,0x78,0x00,0x00,// 'e'
0x00,0x38,0x6c,0x60,0x60,0xf8,0x60,0x60,0x60,0xf0,0x00,0x00,// 'f'
0x00,0x00,0x00,0x00,0x76,0xcc,0xcc,0xcc,0x7c,0x0c,0xcc,0x78,// 'g'
0x00,0xe0,0x60,0x60,0x6c,0x76,0x66,0x66,0x66,0xe6,0x00,0x00,// 'h'
0x00,0x18,0x18,0x00,0x78,0x18,0x18,0x18,0x18,0x7e,0x00,0x00,// 'i'
0x00,0x0c,0x0c,0x00,0x3c,0x0c,0x0c,0x0c,0x0c,0xcc,0xcc,0x78,// 'j'
0x00,0xe0,0x60,0x60,0x66,0x6c,0x78,0x6c,0x66,0xe6,0x00,0x00,// 'k'
0x00,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x7e,0x00,0x00,// 'l'
0x00,0x00,0x00,0x00,0xfc,0xd6,0xd6,0xd6,0xd6,0xc6,0x00,0x00,// 'm'
0x00,0x00,0x00,0x00,0xf8,0xcc,0xcc,0xcc,0xcc,0xcc,0x00,0x00,// 'n'
0x00,0x00,0x00,0x00,0x78,0xcc,0xcc,0xcc,0xcc,0x78,0x00,0x00,// 'o'
0x00,0x00,0x00,0x00,0xdc,0x66,0x66,0x66,0x66,0x7c,0x60,0xf0,// 'p'
0x00,0x00,0x00,0x00,0x76,0xcc,0xcc,0xcc,0xcc,0x7c,0x0c,0x1e,// 'q'
0x00,0x00,0x00,0x00,0xec,0x6e,0x76,0x60,0x60,0xf0,0x00,0x00,// 'r'
0x00,0x00,0x00,0x00,0x78,0xcc,0x60,0x18,0xcc,0x78,0x00,0x00,// 's'
0x00,0x00,0x20,0x60,0xfc,0x60,0x60,0x60,0x6c,0x38,0x00,0x00,// 't'
0x00,0x00,0x00,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0x76,0x00,0x00,// 'u'
0x00,0x00,0x00,0x00,0xcc,0xcc,0xcc,0xcc,0x78,0x30,0x00,0x00,// 'v'
0x00,0x00,0x00,0x00,0xc6,0xc6,0xd6,0xd6,0x6c,0x6c,0x00,0x00,// 'w'
0x00,0x00,0x00,0x00,0xc6,0x6c,0x38,0x38,0x6c,0xc6,0x00,0x00,// 'x'
0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x3c,0x0c,0x18,0xf0,// 'y'
0x00,0x00,0x00,0x00,0xfc,0x8c,0x18,0x60,0xc4,0xfc,0x00,0x00,// 'z'
0x00,0x1c,0x30,0x30,0x60,0xc0,0x60,0x30,0x30,0x1c,0x00,0x00,// '{'
0x00,0x18,0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x00,0x00,// '|'
0x00,0xe0,0x30,0x30,0x18,0x0c,0x18,0x30,0x30,0xe0,0x00,0x00,// '}'
0x00,0x73,0xda,0xce,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// '~'
};
uchar gCurRow,gCurCol;
uchar tCurRow,tCurCol;
uchar ShowModeSW;
uint txthome,grhome;
//LCD??????????
uchar Status_BIT_01(); // ??λSTA1,STA0?ж????д?????д?????
uchar Status_BIT_3(); // ??λST3?ж?????????д????
uchar GetRow();
uchar GetCol();
uchar LCD_Write_Command_P2(uchar cmd,uchar para1,uchar para2); // д??????????
uchar LCD_Write_Command_P1(uchar cmd,uchar Para1); // д???????????
uchar LCD_Write_Command(uchar cmd); // д??????????
uchar LCD_Write_Data(uchar dat); // д????
uchar LCD_Read_Data(); // ??????
void cls();
char LCD_Initialise;
void Set_LCD_POS(uchar row, uchar col); // ?????????
void charout(uchar*str); //ASCII(8*8) ???????
uchar Display_Str_at_xy(uchar x,uchar y,char *fmt) reentrant;// ASCII(8*16) ?? ????(16*16) ???????
void OutToLCD(uchar Dat,uchar x,uchar y);//???????????  
void Line( unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, uchar Mode) reentrant;
void Pixel(unsigned char PointX,unsigned char PointY, uchar Mode);
typedef struct typFNT_GB16 // ???????????????
{
char Index[2];
char Msk[24];
};
//????????????
const struct typFNT_GB16 GB_16[] ={
/*--  ????:  ??  --*/
/*--  ????9;  ????????????????????x??=12x12   --*/
/*--  ??????8??????????????????x???=16x12  --*/
"??",0x20,0x00,0x3F,0xE0,0x42,0x00,0x82,0x00,0x3F,0xC0,0x22,0x00,
     0x22,0x00,0xFF,0xE0,0x02,0x00,0x02,0x00,0x02,0x00,0x00,0x00,
/*--  ????:  ??  --*/
/*--  ????9;  ????????????????????x??=12x12   --*/
/*--  ??????8??????????????????x???=16x12  --*/
"??",0x1F,0x80,0x10,0x80,0x10,0x80,0x1F,0x80,0x10,0x80,0x10,0x80,
     0x1F,0x80,0x10,0x80,0x10,0x80,0x20,0x80,0x43,0x80,0x00,0x00,
/*--  ????:  ??  --*/
/*--  ????9;  ????????????????????x??=12x12   --*/
/*--  ??????8??????????????????x???=16x12  --*/
"??",0x3F,0xC0,0x20,0x40,0x20,0x40,0x20,0x40,0x3F,0xC0,0x20,0x40,
     0x20,0x40,0x20,0x40,0x20,0x40,0x3F,0xC0,0x20,0x40,0x00,0x00,
/*--  ????:  ?  --*/
/*--  ????9;  ????????????????????x??=12x12   --*/
/*--  ??????8??????????????????x???=16x12  --*/
"?",0x00,0x80,0xF0,0x80,0x9F,0xE0,0x90,0x80,0x94,0x80,0xF2,0x80,
     0x92,0x80,0x90,0x80,0xF0,0x80,0x90,0x80,0x03,0x80,0x00,0x00,
/*--  ????:  ??  --*/
/*--  ????9;  ????????????????????x??=12x12   --*/
/*--  ??????8??????????????????x???=16x12  --*/
"??",0x11,0x00,0x11,0x00,0x20,0x80,0x20,0x80,0x40,0x40,0xBF,0xA0,
     0x08,0x80,0x08,0x80,0x10,0x80,0x20,0x80,0xC7,0x00,0x00,0x00,
/*--  ????:  ??  --*/
/*--  ????9;  ????????????????????x??=12x12   --*/
/*--  ??????8??????????????????x???=16x12  --*/
"??",0x31,0x00,0xE1,0x00,0x25,0x40,0xFD,0x20,0x25,0x20,0x75,0x00,
     0x69,0x40,0xA0,0x40,0xA0,0x80,0x23,0x00,0x3C,0x00,0x00,0x00,
/*--  ????:  ??  --*/
/*--  ????9;  ????????????????????x??=12x12   --*/
/*--  ??????8??????????????????x???=16x12  --*/
"??",0x3F,0xC0,0x20,0x40,0x3F,0xC0,0x20,0x40,0x3F,0xC0,0x24,0x00,
     0x3F,0xC0,0x44,0x00,0xBF,0xC0,0x04,0x00,0xFF,0xE0,0x00,0x00,
/*--  ????:  ??  --*/
/*--  ????9;  ????????????????????x??=12x12   --*/
/*--  ??????8??????????????????x???=16x12  --*/
"??",0x49,0xE0,0xFD,0x20,0x49,0x20,0x79,0xE0,0x49,0x20,0x79,0x20,
     0x49,0xE0,0xFD,0x20,0x29,0x20,0x45,0x20,0x82,0x60,0x00,0x00,
/*--  ????:  ?  --*/
/*--  ????9;  ????????????????????x??=12x12   --*/
/*--  ??????8??????????????????x???=16x12  --*/
"?",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xFF,0xE0,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/*--  ????:  ??  --*/
/*--  ????9;  ????????????????????x??=12x12   --*/
/*--  ??????8??????????????????x???=16x12  --*/
"??",0x00,0x00,0x00,0x80,0x7F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xE0,0x00,0x00,0x00,0x00,
/*--  ????:  ??  --*/
/*--  ????9;  ????????????????????x??=12x12   --*/
/*--  ??????8??????????????????x???=16x12  --*/
"??",0x00,0x80,0x7F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x80,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xFF,0xE0,0x00,0x00,
/*--  ????:  ??  --*/
/*--  ????9;  ????????????????????x??=12x12   --*/
/*--  ??????8??????????????????x???=16x12  --*/
"??",0x7F,0xE0,0x49,0x20,0x49,0x20,0x49,0x20,0x49,0x20,0x49,0x20,
     0x51,0x20,0x61,0xE0,0x40,0x20,0x7F,0xE0,0x40,0x20,0x00,0x00,
/*--  ????:  ??  --*/
/*--  ????9;  ????????????????????x??=12x12   --*/
/*--  ??????8??????????????????x???=16x12  --*/
"??",0x7F,0xC0,0x08,0x00,0x08,0x00,0x08,0x00,0x7F,0x80,0x08,0x80,
     0x08,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0xFF,0xE0,0x00,0x00,
/*--  ????:  ??  --*/
/*--  ????9;  ????????????????????x??=12x12   --*/
/*--  ??????8??????????????????x???=16x12  --*/
"??",0x08,0x00,0x04,0x00,0x04,0x00,0xFF,0xE0,0x00,0x00,0x12,0x00,
     0x11,0x00,0x20,0x80,0x20,0x80,0x40,0x40,0x80,0x40,0x00,0x00,
/*--  ????:  ??  --*/
/*--  ????9;  ????????????????????x??=12x12   --*/
/*--  ??????8??????????????????x???=16x12  --*/
"??",0x3F,0xC0,0x20,0x40,0x20,0x40,0x20,0x40,0x3F,0xC0,0x20,0x40,
     0x20,0x40,0x20,0x40,0x20,0x40,0x3F,0xC0,0x20,0x40,0x00,0x00,
/*--  ????:  ??  --*/
/*--  ????9;  ????????????????????x??=12x12   --*/
/*--  ??????8??????????????????x???=16x12  --*/
"??",0x04,0x00,0x44,0x40,0x24,0x80,0x05,0x00,0xFF,0xC0,0x00,0x40,
     0x00,0x40,0x7F,0xC0,0x00,0x40,0x00,0x40,0xFF,0xC0,0x00,0x00,
/*--  ????:  ?  --*/
/*--  ????9;  ????????????????????x??=12x12   --*/
/*--  ??????8??????????????????x???=16x12  --*/
"?",0x11,0x00,0x0A,0x40,0xFF,0xE0,0x00,0x00,0x79,0x40,0x49,0x40,
     0x79,0x40,0x49,0x40,0x79,0x40,0x48,0x40,0x59,0xC0,0x00,0x00,
/*--  ????:  ??  --*/
/*--  ????9;  ????????????????????x??=12x12   --*/
/*--  ??????8??????????????????x???=16x12  --*/
"??",0x8F,0xC0,0x48,0x40,0x0F,0xC0,0x88,0x40,0x4F,0xC0,0x40,0x00,
     0x5F,0xC0,0x95,0x40,0x95,0x40,0x95,0x40,0xBF,0xE0,0x00,0x00,
/*--  ????:  ??  --*/
/*--  ????9;  ????????????????????x??=12x12   --*/
/*--  ??????8??????????????????x???=16x12  --*/
"??",0x02,0x00,0x7F,0xE0,0x48,0x80,0x7F,0xE0,0x48,0x80,0x4F,0x80,
     0x40,0x00,0x5F,0x80,0x45,0x00,0x87,0x00,0xB8,0xE0,0x00,0x00,
/*--  ????:  ??  --*/
/*--  ????9;  ????????????????????x??=12x12   --*/
/*--  ??????8??????????????????x???=16x12  --*/
"??",0x00,0x00,0x00,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/*--  ????:  ??  --*/
/*--  ????9;  ????????????????????x??=12x12   --*/
/*--  ??????8??????????????????x???=16x12  --*/
"??",0x00,0x00,0xE7,0x40,0xA8,0xC0,0xF0,0x40,0x10,0x00,0x10,0x00,
     0x10,0x00,0x10,0x40,0x08,0x40,0x07,0x80,0x00,0x00,0x00,0x00,
};
uchar Status_BIT_01(void) // ??λSTA1,STA0?ж????д?????д?????
    {
uchar i;
for(i=5;i>0;i--)
{
  if((LCMCW & 0x03)==0x03)
  break;
}
return i; // ??????????????
    }
uchar Status_BIT_3(void) // ??λST3?ж?????????д????
{
uchar i;
for(i=5;i>0;i--)
{
  if((LCMCW & 0x08)==0x08)
  break;
}
return i; // ??????????????
}
uchar LCD_Write_Command_P2(uchar cmd,uchar para1,uchar para2) // д??????????
{
if(Status_BIT_01() ==0) return 1;
LCMDW = para1;
if(Status_BIT_01() == 0) return 2;
LCMDW = para2;
if(Status_BIT_01() == 0) return 3;
LCMCW = cmd;
return 0; // ????0???
}
uchar LCD_Write_Command_P1(uchar cmd,uchar para1) // д???????????
{
if(Status_BIT_01() == 0) return 1;
LCMDW = para1;
if(Status_BIT_01() == 0) return 2;
LCMCW = cmd;
return 0; // ????0???
}
uchar LCD_Write_Command(uchar cmd) // д??????????
{
if(Status_BIT_01() == 0)
return 1;
LCMCW = cmd;
return 0; // ????0???
}
uchar LCD_Write_Data(uchar dat) // д????
{
if(Status_BIT_3() == 0)
return 1;
LCMDW = dat;
return 0; // ????0???
}
uchar LCD_Read_Data() // ??????
{
if(Status_BIT_01() == 0)
return 1;
return LCMDW;
}
void Set_LCD_Pos(uchar row, uchar col) reentrant//?????????
{
uint Pos;

Pos = row * LCD_WIDTH+ col;
LCD_Write_Command_P2(LC_ADD_POS,Pos%256,Pos/256); //???
gCurRow = row;
gCurCol = col;
}
// ????
void cls(void)
{
uint i;

LCD_Write_Command_P2(LC_ADD_POS,0x00,0x00); // ???????
LCD_Write_Command(LC_AUT_WR); // ???д
for(i=0;i<0x2000;i++)
{
  Status_BIT_3();
  LCD_Write_Data(0x00); // д????
}
LCD_Write_Command(LC_AUT_OVR); // ???д????
LCD_Write_Command_P2(LC_ADD_POS,0x00,0x00); // ?????????
gCurRow = 0; // ???????洢????
gCurCol = 0;
}
// LCM ?????
uchar LCD_Initialise()
{
RESET=0;
RESET=1;
LCD_Write_Command_P2(LC_TXT_STP,0x00,0x00); // ????????????
LCD_Write_Command_P2(LC_TXT_WID,LCD_WIDTH,0x00); // ???????????
LCD_Write_Command_P2(LC_GRH_STP,0x00,0x00); // ????????????
LCD_Write_Command_P2(LC_GRH_WID,LCD_WIDTH,0x00); // ???????????
LCD_Write_Command_P1(LC_CGR_POS,CGRAMSTART >> 11);
LCD_Write_Command(LC_CUR_SHP | 0x01); // ??????
LCD_Write_Command(LC_MOD_OR); // ??????????
LCD_Write_Command(LC_DIS_SW |0x08);
grhome = GRSTART;
    txthome = TXTSTART;
return  0;
}

// ASCII?????????????
uchar Display_Str_at_xy(uchar x,uchar y,char *fmt) reentrant
{
char c1,c2,cData;
uchar i=0,j,uLen;
uchar k;
uLen=strlen(fmt);
while(i<uLen)
{
  c1 = fmt[i];
  c2 = fmt[i+1];

  Set_LCD_Pos(y,x/8);
  if(c1 >= 0)
  {
   // ASCII
      if(c1 < 0x20)
      {
          switch(c1)
          {
              case CR:
              case LF: // ???????
                  i++;
      x=0;
                  if(y < 112)y+=HZ_CHR_HEIGHT;
                  continue;
              case BS: // ???
      i++;
                  if(y>ASC_CHR_WIDTH)y-=ASC_CHR_WIDTH;
                  cData = 0x00;
                  break;
          }
      }
      for(j=0;j<ASC_CHR_HEIGHT;j++)
      {
         
          if(c1 >= 0x1f)
          {
        cData= ASC_MSK[(c1-0x1f)*ASC_CHR_HEIGHT+j];
     Set_LCD_Pos(y+j,x/8);
     if((x%8)==0)
     {
      LCD_Write_Command(LC_AUT_WR); // д????
               LCD_Write_Data(cData);
            LCD_Write_Command(LC_AUT_OVR);
     }
     else
      OutToLCD(cData,x,y+j);
          }
          Set_LCD_Pos(y+j,x/8);
      }
      if(c1 != BS) // ?????
      x+=ASC_CHR_WIDTH;
  }
else
  { // ????
   
      for(j=0;j<sizeof(GB_16)/sizeof(GB_16[0]);j++)
      {
          if(c1 == GB_16[j].Index[0] && c2 == GB_16[j].Index[1])
          break;
      }
      for(k=0;k<HZ_CHR_HEIGHT;k++)
      {
   
          Set_LCD_Pos(y+k,x/8);
          if(j < sizeof(GB_16)/sizeof(GB_16[0]))
          {
     c1=GB_16[j].Msk[k*2];
     c2=GB_16[j].Msk[k*2+1];
    }
    else   
     c1=c2=0;
    if((x%8)==0)
    {
     LCD_Write_Command(LC_AUT_WR);
     LCD_Write_Data(c1);
           LCD_Write_Command(LC_AUT_OVR);
          }
    else
     OutToLCD(c1,x,y+k);
   
    if(((x+2+HZ_CHR_WIDTH/2)%8)==0)
    {
     LCD_Write_Command(LC_AUT_WR);
     LCD_Write_Data(c2);
     LCD_Write_Command(LC_AUT_OVR);
          }
    else
     OutToLCD(c2,x+2+HZ_CHR_WIDTH/2,y+k);
      }
      x+=HZ_CHR_WIDTH;
      i++;
  }
  i++;
}
return uLen;
}
void OutToLCD(uchar Dat,uchar x,uchar y)
{
uchar dat1,dat2,a,b;
b=x%8;a=8-b;
Set_LCD_Pos(y,x/8);
LCD_Write_Command(LC_AUT_RD); // ??????
dat1=LCD_Read_Data();
dat2=LCD_Read_Data();
dat1=(dat1&(0xFF<<a))|(Dat>>b);
dat2=(dat2&(0xFF>>b))|(Dat<<a);
LCD_Write_Command(LC_AUT_OVR);
Set_LCD_POS(y,x/8);
LCD_Write_Command(LC_AUT_WR);
LCD_Write_Data(dat1);
LCD_Write_Data(dat2);
LCD_Write_Command(LC_AUT_OVR);
}
/*void SetShowMode(uchar newShowModeSW)  //??????????
{
ShowModeSW=newShowModeSW;
fnPR12(LC_DIS_SW | newShowModeSW);
} */
/**********************************
//= ???????: Pixel(unsigned char PointX,unsigned char PointY, bit Mode)
//= ??    ??: ?????????λ??????????
//= ??    ??: ????,???????????
//= ?? ?? ?:
//= ???????????к???
//= ??????????????256*256,???????????? PointX,PointY??????
//= Mode 1:??? 0:??????
**********************************/
void Pixel(unsigned char x,unsigned char y, uchar Mode)
{
    unsigned char Start_Addr,dat;
    Start_Addr=7-(x%8);
    dat=LC_BIT_OP|Start_Addr; //????λ???????????????
    if(Mode) dat|=0x08;
Set_LCD_Pos(y,x/8);
LCD_Write_Command(LC_BIT_OP|dat); // д????
}
void Exchange(uchar *a,uchar *b)
{
uchar t;
t = *a;*a = *b;*b =t;
}  

/**********************************
//= ???????: void line( unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, bit Mode)
//= ??    ??: ???????
//= ??    ??: ????1,????2,???????????
//= ?? ?? ?:
//= ???????????к???
//= ????:???????????255*255
/**********************************/

void Line( unsigned char x1,unsigned char y1, unsigned char x2,unsigned char y2,  uchar Mode) reentrant
{
    unsigned char x,y;
    float k,b;
    if( abs(y1-y2) <= abs(x1-x2) ) // |k|<=1
    {
        k=(float)(y2-y1) / (float)(x2-x1) ;
        b=y1-k*x1;
        if( x1 > x2 )
        Exchange(&x1,&x2);
        for(x=x1;x<=x2;x++)
        {
         y=(uchar)(k*x+b);
            Pixel(x, y, Mode);
        }
}
     else
{
  k = (float)(x2-x1) / (float)(y2-y1);
  b = x1 - k*y1;
  if(y1 > y2)
  Exchange(&y1,&y2);
        for(y=y1;y<=y2;y++)
        {
         x=(uchar)(k*y+b);
            Pixel(x, y, Mode);
        }
}
}
//-------------------------------Main.c---------------------------------------------------------------------------
      #include <intrins.h>
      #include <string.h>
      #include <lcd_160128.h>
      extern void LCD_Initialise();
      extern void Display_Str_at_xy(uchar x,uchar y,char *Buffer) reentrant;
      extern void Read_Temperature();
      extern void Delay (uint num);
      extern float Build_Temperature_float();
      extern uchar Current_Temp_Display_Buffer[];
      extern bit DS18B20_IS_OK;
      sbit SDA = P1^0;//DS1302??????
      sbit CLK = P1^1;//DS1302?????
      sbit RST = P1^2;//DS1302??λ??
      uchar tCount = 0;
      //?????????????
      char code *WeeksTable[] ={"??","?","??","??","??","??","??"};
      //??????????????
      uchar DateTime[7];
      char dat_str[13];
      //-------------------------------------------------------------
      //??DS1302д??????
      //-------------------------------------------------------------
      void Write_A_Byte_To_DS1302(uchar x)
      {
         uchar i;
         for (i = 0;i < 8;i + +)
         {
            SDA=x&1;CLK=1;CLK =0;x>>=1;
          }
      }
      //-------------------------------------------------------------
      //??DS1302???????
      //-------------------------------------------------------------
      uchar Get_A_Byte_FROM_DS1302()
      {
         uchar i,b,t;
         for(i=0;i<8;i++)
         {
            b>>=1;t=SDA;b|=t<<7;CLK =1;CLK=0;
         }
          //BCD?????
          Return b/16*10+b*%16;
       }
      //-------------------------------------------------------------
      //??DS1302???λ???????
      //-------------------------------------------------------------
      uchar Read_Date(uchar addr)
      {
         uchar dat;
         RST=0;CLK=0;RST=1;
         Write_A_Byte_To_DS1302(addr);
         dat = Get_A_Byte_FROM_DS1302();
         CLK = 1;RST = 0;
         return dat;
      }
      //-------------------------------------------------------------
      //?????????????
      //-------------------------------------------------------------
      Void GetTime ()
      {
         uchar i;
         for (i = 0;i < 7;i + +)
         {
             DateTime[i] = Read_Date(0x81 + 2*1);
          }
       }
       //-------------------------------------------------------------
      //?????0??????LCD???
      //-------------------------------------------------------------
      void T0_INT() interrupt 1
      {
         TH0 = - 50000 / 256;
         TL0 = - 50000 % 256;
         if (++tCount ! = 20) return;
         GetTime();
         tCount = 0;
         //?????????
         sprintf(dat_str,"20%c%c??%c%c??%c%c??",DateTime[6]/10+'0',   
   DateTime[6]%10+'0',DateTime[4]/10+'0',DateTime[4]%10+'0',
   Datetime[3]/10+'0',Datetime[3]%10+'0');
         Display_Str_at_xy(16,24,dat_str);
         //???????
         sprintf(dat_str,"????%s",WeeksTable[DateTime[5]-1]);
         Display_Str_at_xy(16,44,dat_str);
         //?????????              
         sprintf(dat_str,"%c%c?%c%c??%c%c??",DateTime[2]/10+'0',
   DateTime[2]%10+'0',DateTime[1]/10+'0',DateTime[1]%10+'0',
   Datetime[0]/10+'0',Datetime[0]%10+'0');
         Display_Str_at_xy(16,64,dat_str);
         //??????????????
         Read_Temperature();
         if(DS18B20_IS_OK)
         {   
            sprintf (dat_str,"%4.1f",Build_Temperature_float());
            Display_Str_at_xy(16,104,dat_str);
          }
      }
      //-------------------------------------------------------------
      //??????
      //-------------------------------------------------------------
      Void main()
      {  
          LCD_Initialise();                 //????????
          Read_Temperature();               //??????
          Delay(50000);
          Delay(50000);
          IE = 0x82;                        //????T0?ж??
          TH0 = - 50000 / 256;
          TL0 = - 50000 % 256;
          TR0 = 1;
          Display_Str_at_xy(16,88,"??????:");
          Display_Str_at_xy(60,104,"??");
          while(1);
      }

51hei图片20191213130526.jpg (6.45 MB, 下载次数: 24)

51hei图片20191213130526.jpg

IMG_20191213_125853.jpg (6.29 MB, 下载次数: 25)

IMG_20191213_125853.jpg

IMG_20191213_125840.jpg (6.2 MB, 下载次数: 22)

IMG_20191213_125840.jpg
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏1 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:660788 发表于 2019-12-13 13:10 | 只看该作者
大神们帮忙解决一哈
回复

使用道具 举报

板凳
ID:648281 发表于 2019-12-14 08:27 | 只看该作者
你好!
错误是缺少头文件
回复

使用道具 举报

地板
ID:777610 发表于 2020-6-12 20:21 | 只看该作者
你好,我目前正在做这个,你可有keil编程源文件吗?能否分享一下
回复

使用道具 举报

5#
ID:419968 发表于 2020-6-12 23:28 | 只看该作者
少LCD_160128.H头文件
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表