標(biāo)題: 求助,下邊程序只要添加dat_code[],數(shù)碼管就無法正常顯示 求解? [打印本頁]

作者: wucaimeng    時間: 2022-8-14 06:48
標(biāo)題: 求助,下邊程序只要添加dat_code[],數(shù)碼管就無法正常顯示 求解?
#include"public.h"
#include"smg.h"
#include"ds18b20.h"

void main()
{
        int temp_temperture=0;
        uchar temp_buff[6];
        uchar ds18b20_init(void);    //初始化 根據(jù)返回值判斷 DS18B20是否在線
        while(1)
        {
                 temp_temperture=125.23*100;
                if(temp_temperture<0)
                {
                        temp_buff[0]=0x40;
                }
                else temp_buff[0]=0x00;                                                 

                temp_buff[1]=dat_code[temp_temperture%10];                //個位
                temp_buff[2]=dat_code[temp_temperture%100/10];                //十位
                temp_buff[3]=dat_code[temp_temperture%1000/100];            //百位         加小數(shù)點(diǎn)
                temp_buff[4]=dat_code[temp_temperture%10000/1000];                //千位
                temp_buff[5]=dat_code[temp_temperture/10000];

                display(1,temp_buff[1]);
                display(2,temp_buff[2]);
                display(3,temp_buff[3]);
                display(4,temp_buff[4]);
                display(5,temp_buff[5]);
                display(6,temp_buff[0]);
        }
}






作者: xianfajushi    時間: 2022-8-14 10:44
盲人摸象還是管中窺豹?
作者: 飛云居士    時間: 2022-8-14 11:39
dat_code[temp_temperture%10]應(yīng)該是dat_code[temp_temperture]%10。下面同理
作者: angmall    時間: 2022-8-14 13:02
你有資料我們沒有,你有原理圖我們沒有,你有模塊化程序我們沒有。就你那兩句描述,怎么幫你

你這個程序不完整,沒法給你看是哪里出問題了!

作者: 名字不是重點(diǎn)    時間: 2022-8-14 17:09
第8行:
uchar ds18b20_init(void);    //初始化 根據(jù)返回值判斷 DS18B20是否在線
是什么鬼?

作者: 名字不是重點(diǎn)    時間: 2022-8-14 17:26
飛云居士 發(fā)表于 2022-8-14 11:39
dat_code[temp_temperture%10]應(yīng)該是dat_code[temp_temperture]%10。下面同理

你確定?
作者: Hephaestus    時間: 2022-8-14 19:59
飛云居士 發(fā)表于 2022-8-14 11:39
dat_code[temp_temperture%10]應(yīng)該是dat_code[temp_temperture]%10。下面同理

這一句顯然樓主是對的,你是錯的。
作者: lkc8210    時間: 2022-8-14 22:31
display函數(shù)是怎么寫的?
作者: 單片機(jī)學(xué)習(xí)習(xí)    時間: 2022-8-19 21:45
uchar ds18b20_init(void);   把括號里的void去掉就行了
作者: Hephaestus    時間: 2022-8-19 23:37
單片機(jī)學(xué)習(xí)習(xí) 發(fā)表于 2022-8-19 21:45
uchar ds18b20_init(void);   把括號里的void去掉就行了

你的回復(fù)毫無道理。
作者: robinsonlin    時間: 2022-8-20 12:58
temp_buff[4]=dat_code[temp_temperture%10000/1000];                //千位
temp_buff[5]=dat_code[temp_temperture/10000];


temp_buff[]  是 int 類型吧?  你把int類型來除以10000。  大概率是這里卡住了。 嘗試把 上面兩句注釋掉試試看看。
作者: xxxevery    時間: 2022-8-25 15:01
樓主只是說數(shù)碼管無法正常顯示,是顯示不出來嗎?還是顯示的和自己預(yù)想的不一樣,從給出的程序看,除
temp_temperture=125.23*100;這句有取值范圍的問題(temp_temperture是int值,而125.23是浮點(diǎn)數(shù),但這里編譯器可以隱式轉(zhuǎn)換過去),整個主程序應(yīng)該可以編譯過去,樓主要想搞清楚問題所在還是要把情況再說清楚些




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1