示例#1
0
/**************************************************************************************************
 * @fn      HalKeyRead
 *
 * @brief   Read the current value of a key
 *
 * @param   None
 *
 * @return  keys - current keys status
 **************************************************************************************************/
uint8 HalKeyRead ( void )
{
  uint8 keys = 0;

#if defined (CC2540_MINIDK)|| (JANSION_KEY)
  if (!(HAL_KEY_SW_1_PORT & HAL_KEY_SW_1_BIT))    /* Key is active low */
  {
    keys |= HAL_KEY_SW_1;
  }
  if (!(HAL_KEY_SW_2_PORT & HAL_KEY_SW_2_BIT))    /* Key is active low */
  {
    keys |= HAL_KEY_SW_2;
  }
#else
#ifdef HAL_BOARD_CC2530EB_REV17
  if ( (HAL_KEY_SW_6_PORT & HAL_KEY_SW_6_BIT))    /* Key is active high */
#elif defined (HAL_BOARD_CC2530EB_REV13)
  if (!(HAL_KEY_SW_6_PORT & HAL_KEY_SW_6_BIT))    /* Key is active low */
#endif
  {
    keys |= HAL_KEY_SW_6;
  }

  if ((HAL_KEY_JOY_MOVE_PORT & HAL_KEY_JOY_MOVE_BIT))  /* Key is active low */
  {
    keys |= halGetJoyKeyInput();
  }
#endif
  return keys;
}
示例#2
0
/**************************************************************************************************
 * @fn      HalKeyPoll
 *
 * @brief   Called by hal_driver to poll the keys
 *
 * @param   None
 *
 * @return  None
 **************************************************************************************************/
void HalKeyPoll (void)
{
  uint8 keys = 0;
  uint8 notify = 0;
#if defined (CC2540_MINIDK)|| (JANSION_KEY)
  if (!(HAL_KEY_SW_1_PORT & HAL_KEY_SW_1_BIT))    /* Key is active low */
  {
    keys |= HAL_KEY_SW_1;
  }
  if (!(HAL_KEY_SW_2_PORT & HAL_KEY_SW_2_BIT))    /* Key is active low */
  {
    keys |= HAL_KEY_SW_2;
  }
#else
  if (!(HAL_KEY_SW_6_PORT & HAL_KEY_SW_6_BIT))    /* Key is active low */
  {
    keys |= HAL_KEY_SW_6;
  }

  if ((HAL_KEY_JOY_MOVE_PORT & HAL_KEY_JOY_MOVE_BIT))  /* Key is active HIGH */
  {
    keys = halGetJoyKeyInput();
  }
#endif

  /* If interrupts are not enabled, previous key status and current key status
   * are compared to find out if a key has changed status.
   */
  if (!Hal_KeyIntEnable)
  {
    if (keys == halKeySavedKeys)
    {
      /* Exit - since no keys have changed */
      return;
    }
    else
    {
      notify = 1;
    }
  }
  else
  {
    /* Key interrupt handled here */
    if (keys)
    {
      notify = 1;
    }
  }

  /* Store the current keys for comparation next time */
  halKeySavedKeys = keys;

  /* Invoke Callback if new keys were depressed */
  if (notify && (pHalKeyProcessFunction))
  {
    (pHalKeyProcessFunction) (keys, HAL_KEY_STATE_NORMAL);

  }
}
示例#3
0
文件: hal_key.c 项目: rmhulle/TG
/**************************************************************************************************
 * @fn      HalKeyRead
 *
 * @brief   Read the current value of a key
 *
 * @param   None
 *
 * @return  keys - current keys status
 **************************************************************************************************/
uint8 HalKeyRead ( void )
{
  uint8 keys = 0;

  if (HAL_PUSH_BUTTON1())
  {
    keys |= HAL_KEY_SW_6;
  }

  if ((HAL_KEY_JOY_MOVE_PORT & HAL_KEY_JOY_MOVE_BIT))  /* Key is active low */
  {
    keys |= halGetJoyKeyInput();
  }

  return keys;
}
示例#4
0
文件: hal_key.c 项目: rmhulle/TG
/**************************************************************************************************
 * @fn      HalKeyPoll
 *
 * @brief   Called by hal_driver to poll the keys
 *
 * @param   None
 *
 * @return  None
 **************************************************************************************************/
void HalKeyPoll (void)
{
  uint8 keys = 0;

  if ((HAL_KEY_JOY_MOVE_PORT & HAL_KEY_JOY_MOVE_BIT))  /* Key is active HIGH */
  {
    keys = halGetJoyKeyInput();
  }

  /* If interrupts are not enabled, previous key status and current key status
   * are compared to find out if a key has changed status.
   */
  if (!Hal_KeyIntEnable)
  {
    if (keys == halKeySavedKeys)
    {
      /* Exit - since no keys have changed */
      return;
    }
    /* Store the current keys for comparation next time */
    halKeySavedKeys = keys;
  }
  else
  {
  #if defined ( POWER_SAVING )
      osal_pwrmgr_device( PWRMGR_BATTERY );
  #endif  
  Pulses++;
  HalLcdWriteStringValue( (char*)titulo, Pulses, 10, 2 );
  }

  if (HAL_PUSH_BUTTON1())
  {
    keys |= HAL_KEY_SW_6;
  }

  /* Invoke Callback if new keys were depressed */
  if (keys && (pHalKeyProcessFunction))
  {
    (pHalKeyProcessFunction) (keys, HAL_KEY_STATE_NORMAL);
  }
}
/**************************************************************************************************
 * @fn      HalKeyPoll
 *
 * @brief   Called by hal_driver to poll the keys
 *
 * @param   None
 *
 * @return  None
 **************************************************************************************************/
void HalKeyPoll (void)
{
  uint8 keys = 0;

  if ((HAL_KEY_JOY_MOVE_PORT & HAL_KEY_JOY_MOVE_BIT))  /* Key is active HIGH */
  {
    keys = halGetJoyKeyInput();
  }

  /* If interrupts are not enabled, previous key status and current key status
   * are compared to find out if a key has changed status.
   */
  if (!Hal_KeyIntEnable)
  {
    if (keys == halKeySavedKeys)
    {
      /* Exit - since no keys have changed */
      return;
    }
    /* Store the current keys for comparation next time */
    halKeySavedKeys = keys;
  }
  else
  {
    /* Key interrupt handled here */
  }

  if (HAL_PUSH_BUTTON1())
  {
    keys |= HAL_KEY_SW_6;
  }

  /* Invoke Callback if new keys were depressed */
  if (keys && (pHalKeyProcessFunction))
  {
    (pHalKeyProcessFunction) (keys, HAL_KEY_STATE_NORMAL);
  }
}
示例#6
0
/**************************************************************************************************
 * @fn      HalKeyPoll
 *
 * @brief   Called by hal_driver to poll the keys
 *
 * @param   None
 *
 * @return  None
 **************************************************************************************************/
void HalKeyPoll (void)
{
  uint8 keys = 0,sendkeys=0;
  uint8 notify = 0;
#if defined (CC2540_MINIDK)
  if (!(HAL_KEY_SW_1_PORT & HAL_KEY_SW_1_BIT))    /* Key is active low */
  {
    keys |= HAL_KEY_SW_1;
  }
  if (!(HAL_KEY_SW_2_PORT & HAL_KEY_SW_2_BIT))    /* Key is active low */
  {
    keys |= HAL_KEY_SW_2;
  }
#else
  if (!(HAL_KEY_SW_6_PORT & HAL_KEY_SW_6_BIT))    /* Key is active low */
  {
    keys |= HAL_KEY_SW_6;
  }

  if ((HAL_KEY_JOY_MOVE_PORT & HAL_KEY_JOY_MOVE_BIT))  /* Key is active HIGH */
  {
    keys = halGetJoyKeyInput();
  }
#endif

  /* If interrupts are not enabled, previous key status and current key status
   * are compared to find out if a key has changed status.
   */
 if (!Hal_KeyIntEnable)
    {
      if (keys == halKeySavedKeys)                                                //Èç¹ûÖжϹرգ¨ÂÖѯÖУ©£¬²¢ÇÒ°´¼üÊDZ£³Ö°´ÏµÄ
        {
          
          keypresslasttime++;
//          //ÒòΪpollingÿ100msÖ´ÐÐÒ»´Î£¬ËùÒÔµ±keypresslasttime=20ʱ£¬·¢³ö³¤°´µÄÏûÏ¢£¬
//          if(keypresslasttime==20)                                                  //Èç¹û´ïµ½2000ms
//            {
//              sendkeys = keys | HAL_KEY_LONG;                                          //¼ÓÉϳ¤°´±êÖ¾
//             (pHalKeyProcessFunction) ( sendkeys, HAL_KEY_STATE_NORMAL);              //·¢ËÍ°´¼üÏûÏ¢
//            // keypresslasttime=1;
//             
//            }
//          else                                                                      //Èç¹ûû´ïµ½2000ms£¬ÔòÖ±½Ó·µ»Ø
//            {
            /* Exit - since no keys have changed */
              return;
//            }
        }
      else 
        {
          //µ±°´¼üµ¯Æðʱ£¬¿´Ò»Ï°´ÏµÄʱ¼ä¶à³¤£¬ÒòΪpollingµÄʱ¼äÊÇ100ms£¬ËùÒÔµ±keypresslasttime<5ʱ£¬·¢³ö¶Ì°´µÄÏûÏ¢£¬
          if(keypresslasttime <5&&keypresslasttime!=1)
            {
                //keys;
               sendkeys = halKeySavedKeys| HAL_KEY_SHORT;
              (pHalKeyProcessFunction) ( sendkeys, HAL_KEY_STATE_NORMAL);
               keys=0;
               keypresslasttime=1;
            }
           else if(keypresslasttime >15)
            {
                
               sendkeys = halKeySavedKeys| HAL_KEY_LONG;
              (pHalKeyProcessFunction) ( sendkeys, HAL_KEY_STATE_NORMAL);
               keys=0;
               keypresslasttime=1;
            }
          notify = 1;
         
        }
    }
 else                                                                            
    {
      /* Key interrupt handled here */
      //Èç¹ûÊÇ°´¼üÖնˣ¬Ôò¿ªÊ¼¼Æʱ
      keypresslasttime = 1;
      if (keys)
        {
          notify = 1;
        }
 
    }
  
       /* Store the current keys for comparation next time */
    halKeySavedKeys = keys;

    /* Invoke Callback if new keys were depressed */
    if (notify && (pHalKeyProcessFunction))
      {

            (pHalKeyProcessFunction) (keys, HAL_KEY_STATE_NORMAL);
      }
 
 

}