标题: 求助单片机+LCD12864成年历设置时出现问题 [打印本页]

作者: xxw369    时间: 2021-7-24 10:34
标题: 求助单片机+LCD12864成年历设置时出现问题
void SetTime(uint8 count)
{
        int8 address,settime;
        int8 max,min;
        if(count < 7)
        {
                LcdDisplay12864(0,3,"设置");
        }
        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);
        }
}
应该是这段程序出现的问题,但没有找出来。麻烦高手给看看。谢谢。

时钟.rar

80.92 KB, 下载次数: 3


作者: yzwzfyz    时间: 2021-7-24 15:18
出的什么问题呢?
作者: xxw369    时间: 2021-7-24 21:00
本帖最后由 xxw369 于 2021-7-24 21:19 编辑
yzwzfyz 发表于 2021-7-24 15:18
出的什么问题呢?

调日期数字只能变两下,而且光标位置不对




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1