按键弹起、按下的事件

Return

return表示从被调函数返回到主调函数继续执行,返回时可 附带一个返回值,返回值可以是一个常量,变量,或是表达式。

 

//按键按下事件

void keyPress(void)

{

         //低电平标示按键按下

         if(KEY1== 0)

         {

                   //按键去抖

                   delay_ms(10);

                   if(KEY1== 0)

                   {

                            //如果原来按键松开,则执行按键按下操作

                            if(1== focusFarButtonValue)

                            {

                                     //按键按下

                                     focusFarButtonValue= 0;

                                    

                                     //如果KEY4按下时,不执行聚焦操作了

                                     if(1== KEY4_press_flag)

                                     {

                                                 //如果按下KEY4,又按下其他按键,模拟按键松开,也不再执行KEY4松开的其他操作了

                                                        KEY4_Event_exec_flag= 2;

                                                        return;

                                     }

                                    

                                     //执行按键按下操作,聚焦远

                                     SetCameraValue(9,4,1);

                                              

                            }

                                    

                   }

         }

 

         //低电平标示按键按下

         if(KEY2== 0)

         {

                   //按键去抖

                   delay_ms(10);

                   if(KEY2== 0)

                   {

                            //如果原来按键松开,则执行按键按下操作

                            if(1== focusNearButtonValue)

                            {

                                     //按键按下

                                     focusNearButtonValue= 0;

                                    

                                     //如果KEY4按下时,不执行聚焦操作了

                                     if(1== KEY4_press_flag)

                                     {

                                                 //如果按下KEY4,又按下其他按键,模拟按键松开,也不再执行KEY4松开的其他操作了

                                                        KEY4_Event_exec_flag= 2;

                                                        return;

                                     }

                                    

                                     //执行按键按下操作,聚焦近

                                     SetCameraValue(9,4,0);

                            }

                   }

         }

}

 

//按键松开事件

void keyRelease(void)

{

         //高电平标示按键松开

         if(KEY1== 1)

         {

                   //按键去抖

                   delay_ms(10);

                   if(KEY1== 1)

                   {

                            //如果原来按键按下,则执行按键松开操作

                            if(0== focusFarButtonValue)

                            {

                                     //按键松开

                                     focusFarButtonValue= 1;

                                     //执行按键松开操作,聚焦停止

                                     sendBPcmd2(4);//调焦停止

                            }

                   }

         }

 

         //高电平标示按键松开

         if(KEY2== 1)

         {

                   //按键去抖

                   delay_ms(10);

                   if(KEY1== 1)

                   {

                            //如果原来按键按下,则执行按键松开操作

                            if(0== focusNearButtonValue)

                            {

                                     //按键松开

                                     focusNearButtonValue= 1;

                                     //执行按键松开操作,聚焦停止

                                     sendBPcmd2(4);//调焦停止

                            }

                   }

         }

}

你可能感兴趣的:(ARM学习)