標(biāo)題: 求助單片機(jī)+LCD12864成年歷設(shè)置時(shí)出現(xiàn)問(wèn)題 [打印本頁(yè)]

作者: xxw369    時(shí)間: 2021-7-24 10:34
標(biāo)題: 求助單片機(jī)+LCD12864成年歷設(shè)置時(shí)出現(xiàn)問(wèn)題
void SetTime(uint8 count)
{
        int8 address,settime;
        int8 max,min;
        if(count < 7)
        {
                LcdDisplay12864(0,3,"設(shè)置");
        }
        if(count == 0)
        {
                address = 0x8d;max = 99;min = 0;
        }
        if(count == 1)
        {
                address = 0x89;max = 12;min = 1;
        }
        if(count == 2)
        {
                address = 0x87;max = 31;min = 0;
        }
        if(count == 3)
        {
                address = 0x85;max = 23;min = 0;
        }
        if(count == 4)
        {
                address = 0x83;max = 59;min = 0;
        }
        if(count == 5)
        {
                address = 0x81;max = 59;min = 0;
        }        
        if(count == 6)
        {
                address = 0x8b;max = 7;min = 0;
        }        
        
        settime = DS1302SingleRead(address);
        settime = (settime/16)*10 +settime%16;
        
        if(key2 == 0)
        {
                ConfigTimer0(10);
                if(key2 == 0)
                {
                        settime++;
                }
        }
        if(key3 == 0)
        {
                ConfigTimer0(10);
                if(key3 == 0)
                {
                        settime--;
                }
        }
        if(settime > max)
                settime = min;
        if(settime < min)
                settime = max;
        DS1302SingleWrite(7,0x00);
        settime = (settime/10)*16 + settime%10;
        DS1302SingleWrite(address - 1,settime);
        RefreshDate();
        RefreshTime();
}

void key(void)
{
        if(key1 == 0)
        {
                ConfigTimer0(10);
                if(key1 == 0 && w == 0)
                {
                        w = 1;
                        SetTime(setIndex);
                }
                if(key1 == 0 && w == 1)
                {
                        setIndex++;
                        if(setIndex == 7)
                        {
                                setIndex = 0;
                                LcdWriteCmd(0x0c);
                        }
                        SetTime(setIndex);                        
                }
                while(key1 == 0);
        }
        switch(setIndex)
        {
                case 0:LcdWriteCmd(0x0f);LcdWriteCmd(0x81);break;
                case 1:LcdWriteCmd(0x0f);LcdWriteCmd(0x83);break;
                case 2:LcdWriteCmd(0x0f);LcdWriteCmd(0x85);break;
                case 3:LcdWriteCmd(0x0f);LcdWriteCmd(0x90);break;
                case 4:LcdWriteCmd(0x0f);LcdWriteCmd(0x91);break;
                case 5:LcdWriteCmd(0x0f);LcdWriteCmd(0x93);break;
                case 6:LcdWriteCmd(0x0f);LcdWriteCmd(0x9a);break;
                //case 8:LcdWriteCmd(0x0f);LcdWriteCmd(0x92);break;
                //case 9:LcdWriteCmd(0x0f);LcdWriteCmd(0x9a);break;
                //case 10:LcdWriteCmd(0x0f);LcdWriteCmd(0x92);break;
                //case 11:LcdWriteCmd(0x0f);LcdWriteCmd(0x94);break;
                //case 12:LcdWriteCmd(0x0f);LcdWriteCmd(0x8b);break;
        }
        if(key4 == 0)
        {
                ConfigTimer0(10);
                if(key4 == 0 && w == 1)
                {
                        w = 0;
                        setIndex = 0;
                }
                while(key4 == 0);
        }
        if(key2 == 0)
        {
                ConfigTimer0(10);
                if(key2 == 0 && w == 1)
                {
                        SetTime(setIndex);
                }
                while(key2 == 0);
        }
        if(key3 == 0)
        {
                ConfigTimer0(10);
                if(key3 == 0 && w == 1)
                {
                        SetTime(setIndex);
                }
                while(key3 == 0);
        }
}
應(yīng)該是這段程序出現(xiàn)的問(wèn)題,但沒(méi)有找出來(lái)。麻煩高手給看看。謝謝。

時(shí)鐘.rar

80.92 KB, 下載次數(shù): 3


作者: yzwzfyz    時(shí)間: 2021-7-24 15:18
出的什么問(wèn)題呢?
作者: xxw369    時(shí)間: 2021-7-24 21:00
本帖最后由 xxw369 于 2021-7-24 21:19 編輯
yzwzfyz 發(fā)表于 2021-7-24 15:18
出的什么問(wèn)題呢?

調(diào)日期數(shù)字只能變兩下,而且光標(biāo)位置不對(duì)




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