?? show_temperature.c
字號:
#include "msp430x14x.h"
#include "DS18B20.h"
#include "Cry12864.h"
#include "stdio.h"
typedef unsigned char uchar;
typedef unsigned int uint;
const uchar hang4[] = {"室溫:"};
static uchar dN[10];
uchar temper[]={"℃"};
void show_T(uint temp);
/*******************************************
函數名稱:Show_Temperature
功 能:將從DS18B20讀取的11bit溫度數
在12864上顯示
參 數:temper--11bit溫度數據
返回值 :無
********************************************/
void Show_Temperature(void)
{
Disp_HZ(0x99,hang4,3);
show_T(Do1Convert());
Disp_HZ(0x9e,temper,1);
}
/*******************************************
函數名稱:show_T
功 能:將從DS18B20讀取的11bit溫度數據轉換
成12864示的溫度數字
參 數:temp--11bit溫度數據
返回值 :無
********************************************/
void show_T(uint temp)
{
int i;
float ftemp;
ftemp = temp* 0.0625;
sprintf(dN,"%f",ftemp);//把溫度值寫入數組內存
Write_Cmd(0x9c);
for(i=0;i<4;i++)
Write_Data(dN[i]); //寫入溫度
}
/*******************************************
函數名稱:Disp_Numb
功 能:將從DS18B20讀取的11bit溫度數據轉換
成12864示的溫度數字
參 數:temper--11bit溫度數據
返回值 :無
********************************************
void Disp_Numb(uint temper)
uchar i;
for(i = 0;i < 6;i++) dN[i] = 0; //初始化顯示變量
//數值轉換
if(temper & BIT0)
{
dN[0] = 5;
dN[1] = 2;
dN[2] = 6;
}
if(temper&BIT1)
{
dN[1] += 5;
dN[2] += 2;
dN[3] += 1;
}
if(temper & BIT2)
{
dN[2] += 5;
dN[3] += 2;
if(dN[2] >= 10)
{
dN[2] -= 10;
dN[3] += 1;
}
}
if(temper&BIT3)
{
dN[3] += 5;
}
if(temper & BIT4)
{
dN[4] += 1;
}
if(temper & BIT5)
{
dN[4] += 2;
}
if(temper & BIT6)
{
dN[4] += 4;
}
if(temper & BIT7)
{
dN[4] += 8;
if(dN[4] >= 10)
{
dN[4] -= 10;
dN[5] += 1;
}
}
if(temper & BIT8)
{
dN[4] += 6;
dN[5] += 1;
if(dN[4] >= 10)
{
dN[4] -= 10;
dN[5] += 1;
}
}
if(temper & BIT9)
{
dN[4] += 2;
dN[5] += 3;
if(dN[4] >= 10)
{
dN[4] -= 10;
dN[5] += 1;
}
}
if(temper & BITA)
{
dN[4] += 4;
dN[5] += 6;
if(dN[4] >= 10)
{
dN[4] -= 10;
dN[5] += 1;
}
if(dN[5] >= 10)
{
dN[5] -= 10;
}
}
dN[5] =dN[5]+0x30;
dN[4] =dN[4]+0x30;
dN[3] =dN[3]+0x30;
dN[2] =dN[2]+0x30;
dN[1] =dN[1]+0x30;
dN[0] =dN[0]+0x30;
}*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -