您当前的位置:五五电子网电子知识单片机-工控设备PIC单片机用PIC16F877的c语言写的一个时闹钟程序(转贴) 正文
用PIC16F877的c语言写的一个时闹钟程序(转贴)

用PIC16F877的c语言写的一个时闹钟程序(转贴)

点击数:7643 次   录入时间:03-04 11:39:06   整理:http://www.55dianzi.com   PIC单片机
    }
    else if(adjust_item == 5)
    {
        if (((CurrentDate.monthh == 3) & (KeyNew <2)) | ((CurrentDate.monthh != 3) & (KeyNew >=0) & (KeyNew <=9)))
        {
            CurrentDate.monthl = KeyNew;
            lcd_write_data(CurrentDate.monthl + '0');
            //lcd_write_inst(time_start_addr + 6);
            adjust_item ++;
            lcd_write_inst(time_start_addr + 8);
        }
        else if (KeyNew == key_left)
        {
            adjust_item --;
            lcd_write_inst(time_start_addr + 5);
        }
        else if (KeyNew == key_right)
        {
            adjust_item ++;
            lcd_write_inst(time_start_addr + 8);
        }
    }
    else if(adjust_item == 6)
    {
        if (((CurrentDate.dayl>1) & ((KeyNew == 1) | (KeyNew == 2))) | ((CurrentDate.dayl == 0) & (KeyNew >0) & (KeyNew<4))
            | ((CurrentDate.dayl == 1) & (KeyNew <4)))
        {
            CurrentDate.dayh = KeyNew;
            lcd_write_data(CurrentDate.dayh + '0');
            //lcd_write_inst(time_start_addr + 8);
            adjust_item ++;
        }
        else if (KeyNew == key_left)
        {
            adjust_item --;
            lcd_write_inst(time_start_addr + 6);
        }
        else if (KeyNew == key_right)
        {
            adjust_item ++;
            lcd_write_inst(time_start_addr + 9);
        }
    }
    else if(adjust_item == 7)
    {
        if (((CurrentDate.dayh == 3) & (KeyNew <2)) | ((CurrentDate.dayh != 3) & (KeyNew >=0) & (KeyNew <=9)))
        {
            CurrentDate.dayl = KeyNew;
            lcd_write_data(CurrentDate.dayl + '0');
            //lcd_write_inst(time_start_addr + 9);
            adjust_item ++;
            lcd_write_inst(time_start_addr + 0);
        }
        else if (KeyNew == key_left)
        {
            adjust_item --;
            lcd_write_inst(time_start_addr + 8);
        }
        else if (KeyNew == key_right)
        {
            adjust_item = 0;
            lcd_write_inst(time_start_addr + 0);
        }
    }
}

//    -------------------------------------------------------
void set_time(void)
{
    if (adjust_item == 0)    //    set hourh
    {
        if (((CurrentTime.hourl <4) & (KeyNew < 3)) | ((CurrentTime.hourl >3) & (KeyNew <2)))
        {
            CurrentTime.hourh = KeyNew;
            lcd_write_data(CurrentTime.hourh + '0');    //    refresh hourh
            //lcd_write_inst(0x10);    //    move cursor back
            adjust_item ++;
        }
        else if(KeyNew == key_left)
        {
            adjust_item = 5;
            lcd_write_inst(time_secondl_addr);
        }
        else if(KeyNew == key_right)
        {
            adjust_item ++;
            lcd_write_inst(time_hourl_addr);
        }
    }
    else if (adjust_item == 1) //    set hourl
    {
        if (((CurrentTime.hourh == 2) & (KeyNew < 4)) | ((CurrentTime.hourh < 2) & (KeyNew <=9)))
        {
            CurrentTime.hourl = KeyNew;
            lcd_write_data(CurrentTime.hourl + '0');    //    refresh hourl
            //lcd_write_inst(0x10);    //    move cursor back
            adjust_item ++;
            lcd_write_inst(time_minuteh_addr);
        }
        else if(KeyNew == key_left)
        {
            adjust_item --;
            lcd_write_inst(time_hourh_addr);
        }
        else if(KeyNew == key_right)
        {
            adjust_item ++;
            lcd_write_inst(time_minuteh_addr);
        }
    }
    else if (adjust_item == 2)    //    set minuteh
    {
        if (KeyNew <6)
        {
            CurrentTime.minuteh = KeyNew;
            lcd_write_data(CurrentTime.minuteh + '0');
            //lcd_write_inst(0x10);    //    move cursor back
            adjust_item ++;
        }

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]  下一页


本文关键字:程序  C语言  PIC单片机单片机-工控设备 - PIC单片机