打印

基于时间触发任务51单片机管理系统的电子钟

[复制链接]
2268|9
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
新好男孩|  楼主 | 2007-7-19 11:08 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
沙发
新好男孩|  楼主 | 2007-7-19 11:13 | 只看该作者

图和设置说明

使用特权

评论回复
板凳
ayb_ice| | 2007-7-19 15:26 | 只看该作者

这名字咋这么熟啊...

使用特权

评论回复
地板
新好男孩|  楼主 | 2007-7-19 15:43 | 只看该作者

不好意思,程序在数据转换的时候会产生一个BUG.

不好意思,程序在数据转换的时候会产生一个BUG.
此BUG我现已清除.但现在不公布,想考考大家!
:)

使用特权

评论回复
5
新好男孩|  楼主 | 2007-7-19 16:33 | 只看该作者

完整的设置说明!

完整的设置说明!
如果对这个系统有兴趣的朋友可按设置说明加上程序上没有写完的功能.
相关链接:https://bbs.21ic.com/upfiles/img/20077/2007719163145779.rar

使用特权

评论回复
6
新好男孩|  楼主 | 2007-7-20 10:00 | 只看该作者

第一次发一个完整的程序,给点意见吧!

第一次发一个完整的程序,给点意见吧!

使用特权

评论回复
7
新好男孩|  楼主 | 2007-7-20 10:41 | 只看该作者

全部代码在昨天完成,今天做了一些测试!

全部代码在昨天完成,今天做了一些测试!还没有发现问题.
现把更新的按键处理代码贴出来.
该代码已实现时间设置,8个闹铃的设置以及还可以删除8个闹铃.
/*---------------------------------------------------------*-
 * 函数名称: KeyProcess()
 * 参    数: 
 * 返    回:
 * 函数功能: 键值处理
 * 
 * 说     明: 
 *
 * 当前版本: V1.0                * 取代版本:
 * 作     者: wsl             * 修     改:  
 * 版本信息: 2006-12-16         * 修改信息:  
-*---------------------------------------------------------*/
void KeyProcess(void)
{
    // 若无按键请求则返回
    if ( Flag_keyprocess )        
    {    
        Flag_keyprocess = 0;    // 清按键有效标志
        // 是引导键
        switch ( keybuffer[1] )    
        {
            case 0:
            // 是功能键
                switch ( keybuffer[0] )    
                {
                    case K_Up:    
                    switch (g_SET)
                    {
                        case 0: CloseBuzzer();    break;
                        case 1:    
                            g_subset++;
                            if (g_subset > 9)    {g_subset = 0;}
                            Main_MENU_interface(g_subset);
                        break;
                        /***************/
                        case 2:
                        case 3:
                            *(pF+Led_i) = *(pF+Led_i)+1;    /*指针指向的变量加1*/
                            if (Led_i == 0)        {    if (*(pF+Led_i) > 2)    {*(pF+Led_i) = 0;}    }
                            else if(Led_i == 2)    {    if (*(pF+Led_i) > 5)    {*(pF+Led_i) = 0;}    }
                            else    {    if (*(pF+Led_i) > 9)    {*(pF+Led_i) = 0;}    }

                            if (*pF == 2) {if (*(pF+1) > 3) {*(pF+1) = 0;}}
                        break;
                        /*******************/

                        default:    break;
                    }
                    break;

                    case K_LoopRight:    
                        switch (g_SET)
                        {
                            case 0: CloseBuzzer();    break;
                            case 2:
                            case 3: 
                                Led_i++;
                                Flag &= 0x0f;
                                if (Led_i>3)    {Led_i = 0;}
                                SETBIT(Flag, Led_i+4);        
                            break;

                            case 4:
                                RingCnt++;
                                if (RingCnt>8-1) {RingCnt = 0;}    /*C语言变量从0开始计数,而闹铃点只有8个*/
                                DATA_Amend_BCD(Ring[RingCnt].hour, Ring[RingCnt].min, Led_i);
                                /*在这里只准点闪烁*/
                                RTC_interface();
                                /*如果RingIDRegister某位为1,说明该点闹铃声已设置*/
                                if (GETBIT(BackupRingID, RingCnt))
                                {    /*点亮最后一位的小数点表示该点闹铃声已设置*/
                                    Dlink4 = 1;
                                }
                                else
                                {
                                    Dlink4 = 0;
                                }
                            break;

                            default:    break;
                        }
                    
                    break;
                    case K_Enter:    
                        switch (g_SET)
                        {
                            case 0: CloseBuzzer();    break;
                            case 1:
                            switch (g_subset)
                            {    /*进入时钟设置板面*/ 
                                case 0: 
                                /*进入系统设置板面*/
                                Led_i = 0;
                                DATA_Amend_BD(now.hour, now.min, Led_i);
                                pF = &dispbuf[0];        /*指向显示缓冲区首地址*/
                                g_SET = 2;
                                break;
                                /*进入闹铃设置板面*/
                                case 1: 
                                /*进入闹铃系统设置板面*/
                                Led_i = 0;
                                RingCnt = 0;
                                DATA_Amend_BCD(Ring[RingCnt].hour, Ring[RingCnt].min, Led_i);
                                /*如果RingIDRegister某位为1,说明该点闹铃声已设置*/
                                if (GETBIT(BackupRingID, RingCnt))
                                   {    /*点亮最后一位的小数点表示该点闹铃声已设置*/
                                    Dlink4 = 1;
                                }
                                else
                                {
                                    Dlink4 = 0;
                                }
                                
                                pF = &dispbuf[0];        /*指向显示缓冲区首地址*/
                                g_SET = 3;
                                break;
                                
                                /*进入闹钟删除设置*/
                                case 2:
                                RingCnt = 0;
                                DATA_Amend_BCD(Ring[RingCnt].hour, Ring[RingCnt].min, Led_i);
                                /*在这里只准点闪烁*/
                                RTC_interface();
                                /*如果RingIDRegister某位为1,说明该点闹铃声已设置*/
                                if (GETBIT(BackupRingID, RingCnt))
                                   {    /*点亮最后一位的小数点表示该点闹铃声已设置*/
                                    Dlink4 = 1;
                                }
                                else
                                {
                                    Dlink4 = 0;
                                }
                                g_SET =4;

                                break;

                                default:    break;
                            }
                            break;
                            /***************************/
                            case 2:    /*保存时间修改设置*/
                                now.sec = 0x00;    
                                now.min = dispbuf[2]*10 + dispbuf[3];
                                now.hour = dispbuf[0]*10 + dispbuf[1];
                                g_UpdataFlagEn = 1;    /*数码显示缓冲区更新*/
                                g_SET = 0;    /*清设置标志*/
                                g_subset = 0;
                                RTC_interface();
                            break;
                            /*********************************/
                            case 3:    /*读闹铃*/
                            RingCnt++;
                            if (RingCnt>8-1) {RingCnt = 0;}    /*C语言变量从0开始计数,而闹铃点只有8个*/
                            Led_i = 0;    /*数码管闪烁从时的首位开始*/
                            DATA_Amend_BCD(Ring[RingCnt].hour, Ring[RingCnt].min, Led_i);
                            /*如果RingIDRegister某位为1,说明该点闹铃声已设置*/
                            if (GETBIT(BackupRingID, RingCnt))
                            {    /*点亮最后一位的小数点表示该点闹铃声已设置*/
                                Dlink4 = 1;
                            }
                            else
                            {
                                Dlink4 = 0;
                            }
                            pF = &dispbuf[0];        /*指向显示缓冲区首地址*/
                            break;
                            /*********************************/

                            /*删除闹钟*/
                            case 4:
                                if ( !GETBIT(BackupRingID, RingCnt) )
                                {    /*该闹铃未被设定*/

                                }
                                else
                                {    /*删除闹铃*/
                                    RingStop(RingCnt);
                                    RESETBIT(BackupRingID ,RingCnt);
                                    Dlink4 = 0;
                                }

                            break;

                            default:    break;
                        }                    
                        break;
                    default:    break;
                }
                break;
                
            case K_Shift:    

                if ( keybuffer[0] == K_Up )
                {
                    /*退出设置板面且不保存已修改的数据*/
                    RTC_interface();
                    g_UpdataFlagEn = 1;    /*数码显示缓冲区更新*/
                    g_SET = 0;    /*清设置标志*/
                    g_subset = 0;
                }
                // 是复合键
                if (keybuffer[0] == K_Enter)
                {
                    switch (g_SET)
                    {
                        case 0:
                            g_SET = 1;    /*置位设置标志*/
                            g_UpdataFlagEn = 0;    /*数码显示缓冲区不更新*/
                            g_subset = 0;
                            /*进入系统设置板面*/
                            Main_MENU_interface(g_subset);
                        break;
                        case 3:
                            /*保存闹铃修改设置*/
                            dispbuf[0] = (dispbuf[0]<<4) + dispbuf[1];
                            dispbuf[2] = (dispbuf[2]<<4) + dispbuf[3];
                            SetRing(dispbuf[0] , dispbuf[2], RingCnt);
                            dispbuf[0] = dispbuf[0]>>4;
                            dispbuf[2] = dispbuf[2]>>4;
                            g_UpdataFlagEn = 1;    /*数码显示缓冲区更新*/
                              g_SET = 0;    /*清设置标志*/
                            g_subset = 0;
                            RTC_interface();

                        break;
                        default : break;
                    }

                }
                break;
            
            default:    break;
        
        }

    }
     // 置位按键任务完成标志
    Flag_keydone = 1;            
}
/*****************************************************************************************************************/

使用特权

评论回复
8
新好男孩|  楼主 | 2007-7-28 13:50 | 只看该作者

mycakeyc@sina.com

发电子邮件吧,这几天比较忙,很少在台位上,都上工作台.工作台上没有电脑.
mycakeyc@sina.com

使用特权

评论回复
9
ETUAL| | 2007-7-28 23:13 | 只看该作者

好的,学习一下~~

谢谢代码了,学习一下~~

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

25

主题

136

帖子

0

粉丝