温度显示程序.docx

上传人:b****6 文档编号:16156105 上传时间:2023-07-10 格式:DOCX 页数:24 大小:23.18KB
下载 相关 举报
温度显示程序.docx_第1页
第1页 / 共24页
温度显示程序.docx_第2页
第2页 / 共24页
温度显示程序.docx_第3页
第3页 / 共24页
温度显示程序.docx_第4页
第4页 / 共24页
温度显示程序.docx_第5页
第5页 / 共24页
温度显示程序.docx_第6页
第6页 / 共24页
温度显示程序.docx_第7页
第7页 / 共24页
温度显示程序.docx_第8页
第8页 / 共24页
温度显示程序.docx_第9页
第9页 / 共24页
温度显示程序.docx_第10页
第10页 / 共24页
温度显示程序.docx_第11页
第11页 / 共24页
温度显示程序.docx_第12页
第12页 / 共24页
温度显示程序.docx_第13页
第13页 / 共24页
温度显示程序.docx_第14页
第14页 / 共24页
温度显示程序.docx_第15页
第15页 / 共24页
温度显示程序.docx_第16页
第16页 / 共24页
温度显示程序.docx_第17页
第17页 / 共24页
温度显示程序.docx_第18页
第18页 / 共24页
温度显示程序.docx_第19页
第19页 / 共24页
温度显示程序.docx_第20页
第20页 / 共24页
亲,该文档总共24页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

温度显示程序.docx

《温度显示程序.docx》由会员分享,可在线阅读,更多相关《温度显示程序.docx(24页珍藏版)》请在冰点文库上搜索。

温度显示程序.docx

温度显示程序

1./*--------------------------------------------------------------------------  

2.;     温度显示程序  

3.;     程序最后修改于:

2004年2月29日  21:

20  

4.----------------------------------------------------------------------------*/   

5.   

6./*------------------------------头文件说明----------------------------------*/   

7.#include    

8.#include    

9.#include       //_nop_()   

10.#include        // XBYTE   

11.#include    

12.   

13.#define uchar unsigned char   

14.#define uint unsigned int   

15.   

16.#define N     10   

17.//#define TMAX  100   

18.//#define TMIN   0   

19.#define Umax   0x7fff   

20.#define Uf    0x8000   

21.#define a1    1.114e-12   

22.#define a2    -3.8071e-8   

23.#define a3    0.0023857   

24.#define a4    0.092139   

25./*------------------------------CPU引脚定义---------------------------------*/   

26.//t6963引脚分配   

27.#define CWADD XBYTE[0x8100]                  //写指令代码地址   

28.#define DWADD XBYTE[0x8000]                  //写数据通道地址   

29.//MAX1169引脚分配   

30.sbit SCL = P1^0; //定义串行时钟线所在口 使用时根据自己的需要来定义   

31.sbit SDA = P1^1; //定义串行数据线所在口 使用时根据自己的需要来定义   

32.//MAX5541引脚分配   

33.sbit SCLK = P1^3; //定义串行时钟线所在口 使用时根据自己的需要来定义   

34.sbit DIN  = P1^4; //定义串行数据线所在口 使用时根据自己的需要来定义   

35.sbit DA_CS= P1^5; //MAX5541片选端   

36.   

37.   

38./*----------------------------全局变量定义---------------------------------*/   

39. uchar SystemError;   

40. uint  counter;           //中断次数   

41. float temp_data;   

42. float s;   

43. uint yk;   

44. signed int ek;   

45.   

46.   

47./*----------------------------功能子程序段---------------------------------*/   

48./*-------------------------------------------------------------------------  

49.;定时器中断服务子程序  

50.---------------------------------------------------------------------------*/   

51.//定时器计数初值为50000   

52.//定时100ms,中断30次   

53.timer0() interrupt 1 using 1                

54.{   

55.  counter++;   

56.  TH0 = -100000/256;   

57.  TL0 = -100000%256;   

58.}   

59.   

60./*--------------------------------------------------------------------------  

61.;t6963  

62.---------------------------------------------------------------------------*/   

63.//液晶显示器地址:

p27--CS  P26--C/D  WR--WR  RD--RD 则   

64.//                00 00 0000 0000 0000(数据通道)   

65.//                01 00 0000 0000 0000(指令通道)   

66.//               ;   

67.//g6963.c--图形方式下的汉字、字符显示程序   

68.   

69.void sta01(void)                           //判断状态位   

70.{   

71.   while((CWADD&3)!

=3);   

72.   

73.    }   

74.   

75.void sta3(void)   

76.{   

77.   

78.while((CWADD&8)!

=8);   

79.   

80.     }   

81.   

82.   

83.//写指令和写数据子程序   

84.   

85.void writecode(unsigned char com)             //写无参数指令   

86.{     

87.   sta01();   

88.   CWADD=com;   

89.   }   

90.void write1byte(unsigned char dat1,unsigned char com)    //写单字节参数指令   

91.{     

92.   sta01();   

93.   DWADD=dat1;   

94.   sta01();   

95.   CWADD=com;   

96.   }   

97.   

98.void write2byte(unsigned char dat1,unsigned char dat2,unsigned char com)   

99.{                                                        //写双字节参数指令    

100.      

101.   sta01();   

102.   DWADD=dat1;   

103.   

104.   sta01();   

105.   DWADD=dat2;   

106.   

107.   sta01();   

108.   CWADD=com;   

109.   }   

110.   

111.   

112.void disp_ini(void)                //显示屏初始化子程序   

113.{   

114.    write2byte(0x00,0x00,0x40);//设置显示区域首地址0000h   

115.    write2byte(0x10,0x00,0x41);//设置文本显示的宽度,即一行所占的字节数(12864t,16个8X8点阵字符)   

116.    write2byte(0x00,0x08,0x42);//设置图形显示区域首地址0800h,或为文本属性区域首地址   

117.    write2byte(0x10,0x00,0x43);//设置图形显示区域宽度,或为文本属性区域宽度(12864t,16个8x8点阵字符)   

118.   

119.    writecode(0xa7);//光标形状设置   

120.    writecode(0x9c);//显示开关设置,g\t all on!

   

121.    writecode(0x80);//显示方式设置,逻辑或合成   

122.   

123.    }   

124.   

125.void clearram(void)                //清屏程序   

126.{      

127.    unsigned int  i;   

128.   

129.    write2byte(0x00,0x00,0x24);//设置显示ram首地址0000h   

130.   

131.    writecode(0xb0);           //设置自动写方式   

132.   

133.    for(i=8192;i>0;i--)   //往显示区域写0;区域大小8k   

134.    {   

135.       sta3();   

136.       DWADD=0;   

137.       };   

138.   

139.    writecode(0xb2);              //关闭自动写指令   

140.   

141.    }   

142.   

143./*-----------------------------------------------------------------------------------------------------  

144.   汉字点阵,存储在程序存储器中  

145.   点阵:

16x16  

146.   提取点阵方向:

横向(先上->下, 再左->右)  

147.   字节掉转:

否  

148.   字节方式:

C语言   

149.-------------------------------------------------------------------------------------------------------*/   

150.   

151.unsigned char code wen[32]={   

152.0x00,0x43,0x32,0x12,0x83,0x62,0x22,0x0B,    // 温   

153.0x10,0x27,0xE4,0x24,0x24,0x24,0x2F,0x20,   

154.0x08,0xFC,0x08,0x08,0xF8,0x08,0x08,0xF8,   

155.0x00,0xFC,0xA4,0xA4,0xA4,0xA4,0xFE,0x00};   

156.   

157.unsigned char code du[32]={   

158.0x01,0x00,0x3F,0x22,0x22,0x3F,0x22,0x23,    // 度   

159.0x20,0x2F,0x22,0x21,0x20,0x43,0x8C,0x30,   

160.0x00,0x84,0xFE,0x20,0x28,0xFC,0x20,0xE0,   

161.0x00,0xF0,0x20,0x40,0x80,0x60,0x1E,0x04};   

162.   

163.unsigned char code wei[32]={   

164.0x00,0x10,0x0C,0x04,0x00,0xFF,0x01,0x01,    // 为   

165.0x02,0x02,0x04,0x08,0x10,0x20,0x40,0x00,   

166.0x80,0x80,0x80,0x80,0x84,0xFE,0x04,0x04,   

167.0x04,0x84,0x64,0x24,0x04,0x04,0x28,0x10};   

168.   

169.unsigned char code clearchar[16] = {            //擦除一个字符   

170.0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,   

171.0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,   

172.};   

173.   

174.unsigned char code dot[16]={    

175.0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,   

176.0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00   

177.};   

178.   

179.//本文件为8×16点阵西文字库文件,字的横向8点构成一字节,左边点在字节的高位,字符点阵四角按左上角→右上角→左下角→右下角取字*/   

180./*0    */   

181.unsigned char code ch0[16]={   

182.0x00,0x00,0x7C,0xC6,0xC6,0xCE,0xD6,0xD6,   

183.0xE6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00};   

184.   

185./*1    */   

186.unsigned char code ch1[16]={   

187.0x00,0x00,0x18,0x38,0x78,0x18,0x18,0x18,   

188.0x18,0x18,0x18,0x7E,0x00,0x00,0x00,0x00};   

189.   

190./*2    */   

191.unsigned char code ch2[16]={   

192.0x00,0x00,0x7C,0xC6,0x06,0x0C,0x18,0x30,   

193.0x60,0xC0,0xC6,0xFE,0x00,0x00,0x00,0x00};   

194.   

195./*3    */   

196.unsigned char code ch3[16]={   

197.0x00,0x00,0x7C,0xC6,0x06,0x06,0x3C,0x06,   

198.0x06,0x06,0xC6,0x7C,0x00,0x00,0x00,0x00};   

199.   

200./*4    */   

201.unsigned char code ch4[16]={   

202.0x00,0x00,0x0C,0x1C,0x3C,0x6C,0xCC,0xFE,   

203.0x0C,0x0C,0x0C,0x1E,0x00,0x00,0x00,0x00};   

204.   

205./*5    */   

206.unsigned char code ch5[16]={   

207.0x00,0x00,0xFE,0xC0,0xC0,0xC0,0xFC,0x0E,   

208.0x06,0x06,0xC6,0x7C,0x00,0x00,0x00,0x00};   

209.   

210./*6    */   

211.unsigned char code ch6[16]={   

212.0x00,0x00,0x38,0x60,0xC0,0xC0,0xFC,0xC6,   

213.0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00};   

214.   

215./*7    */   

216.unsigned char code ch7[16]={   

217.0x00,0x00,0xFE,0xC6,0x06,0x06,0x0C,0x18,   

218.0x30,0x30,0x30,0x30,0x00,0x00,0x00,0x00};   

219.   

220./*8    */   

221.unsigned char code ch8[16]={   

222.0x00,0x00,0x7C,0xC6,0xC6,0xC6,0x7C,0xC6,   

223.0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00};   

224.   

225./*9    */   

226.unsigned char code ch9[16]={   

227.0x00,0x00,0x7C,0xC6,0xC6,0xC6,0x7E,0x06,   

228.0x06,0x06,0x0C,0x78,0x00,0x00,0x00,0x00   

229.};   

230.   

231.   

232.   

233.   

234.void gshowword(unsigned char y,unsigned char x,unsigned char *w_no) //图形方式下显示一个汉字字符(分为左右两半字模)   

235.{        //128*64dots,x--显示在第x(0~15)字符列!

,y--显示在第y(0~63)点阵!

行,w_no为tab代码      

236.         //调用示例:

gshowword(2,4,hao)  在第二行第四列显示"好" ----gshowword(点阵行,字符列,数组首地址)     

237.   unsigned int num;   

238.   unsigned char d1,d2,i=16;   

239.   num=y*16+x+0x800;                 //16--每行显示宽度为16个字符;0--图形显示区首地址为0800h   

240.     

241.      

242.      

243. for(i=16;i>0;i--)   

244.  {    d1=num/256;                       //得到显示屏上汉字显示的相对位置   

245.       d2=num%256;   

246.       write2byte(d2,d1,0x24);   

247.       write1byte(*w_no,0xc0);            //写汉字左代码   

248.       write1byte(*(w_no+16),0xc0);       //写汉字右代码   

249.       w_no++;   

250.       num+=0x10;                         //显示ram地址修正   

251.   

252.        }   

253.   

254.  }   

255.   

256.void gshowchar(unsigned char y,unsigned char x,unsigned char *w_no) //图形方式下显示一个字符(分为左右两半字模)   

257.{                    //128*64dots,x--显示在第x(0~15)字符列!

,y--显示在第y(0~63)点阵!

行,w_no为tab代码      

258.                     //调用示例:

gshowword(2,4,hao)  在第二点阵行第四字符列显示"好"      

259.   unsigned int num;   

260.   unsigned char d1,d2,i=16;   

261.   num=y*16+x+0x800;                 //16--每行显示宽度为16个字符;0--图形显示区首地址为0800h   

262.    

263.   for(i=16;i>0;i--)   

264.    {      

265.       d1=num/256;                       //得到显示屏上汉字显示的相对位置   

266.       d2=num%256;   

267.       write2byte(d2,d1,0x24);   

268.       write1byte(*w_no,0xc0);            //写汉字左代码   

269.  //     write1byte(*(w_no+16),0xc0);       //写汉字右代码   

270.       w_no++;   

271.       num+=0x10;                         //显示ram地址修正   

272.        }   

273.   

274.  }   

275.   

276.    

277.//////////////////////////////////////////////////////////////////////////////////////////////   

278.   

279.void disp5ch(unsigned char y,unsigned char x,unsigned long var)    

280.{           //带灭零处理及小数点的五位数显示子程序(可显示0.000~99.999),var指要显示的数据   

281.    uchar d4,d3,d2,d1,d0;   

282.    d4=var/10000;d3=(var%10000)/1000;d2=(var%1000)/100;d1=(var%1000)%100/

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 高中教育 > 高中教育

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2