|
我直接使用ble例程,但是发现它的按键没作用?是不是还要设置什么?
[url=]/**@brief[/url] Function for handling button events.
*
* @param[in] pin_no The pin number of the button pressed.
*/
static void button_event_handler(uint8_t pin_no, uint8_t button_action)
{
if (button_action == APP_BUTTON_PUSH)
{
switch (pin_no)
{
case LEFT_BUTTON_PIN_NO:
mouse_movement_send(-MOVEMENT_SPEED, 0);
break;
case RIGHT_BUTTON_PIN_NO:
mouse_movement_send(MOVEMENT_SPEED, 0);
break;
case UP_BUTTON_PIN_NO:
mouse_movement_send(0, -MOVEMENT_SPEED);
break;
case DOWN_BUTTON_PIN_NO:
mouse_movement_send(0, MOVEMENT_SPEED);
break;
default:
APP_ERROR_HANDLER(pin_no);
break;
}
}
}
[url=]/**@brief[/url] Function for initializing the button handler module.
*/
static void buttons_init(void)
{
static app_button_cfg_t buttons[] =
{
{LEFT_BUTTON_PIN_NO, false, BUTTON_PULL, button_event_handler},
{RIGHT_BUTTON_PIN_NO, false, BUTTON_PULL, button_event_handler}, // Note: This pin is also BONDMNGR_DELETE_BUTTON_PIN_NO
{UP_BUTTON_PIN_NO, false, BUTTON_PULL, button_event_handler},
{DOWN_BUTTON_PIN_NO, false, BUTTON_PULL, button_event_handler}
};
APP_BUTTON_INIT(buttons, sizeof(buttons) / sizeof(buttons[0]), BUTTON_DETECTION_DELAY, true);
}
?
|
|