This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

what can I do ,if I want to send left or right button data with ble_hids_inp_rep_send()

I what to send button data , how to construct button data array : uint8_t buffer[INPUT_REP_BUTTONS_LEN]; in function ble_hids_inp_rep_send() ?

In SDK mouse demo I can see that, if I want to send mouse move data I can do like this :

    APP_ERROR_CHECK_BOOL(INPUT_REP_MOVEMENT_LEN == 3);
    
    x_delta = MIN(x_delta, 0x0fff);
    y_delta = MIN(y_delta, 0x0fff);

    buffer[0] = x_delta & 0x00ff;
    buffer[1] = ((y_delta & 0x000f) << 4) | ((x_delta & 0x0f00) >> 8);
    buffer[2] = (y_delta & 0x0ff0) >> 4;
    
    err_code = ble_hids_inp_rep_send(&m_hids,
                                     INPUT_REP_MOVEMENT_INDEX, 
                                     INPUT_REP_MOVEMENT_LEN, 
                                     buffer);

but I don't know why buffer[] construct like this and how can I construct it in button data array.

Parents
  • when I initialize button

    static void buttons_init(void) { static app_button_cfg_t buttons[] = { {LEFT_BUTTON_PIN_NO, false, NRF_GPIO_PIN_NOPULL, button_event_handler}, {RIGHT_BUTTON_PIN_NO, false, NRF_GPIO_PIN_NOPULL, button_event_handler}, // Note: This pin is also BONDMNGR_DELETE_BUTTON_PIN_NO {UP_BUTTON_PIN_NO, false, NRF_GPIO_PIN_NOPULL, button_event_handler}, {DOWN_BUTTON_PIN_NO, false, NRF_GPIO_PIN_NOPULL, button_event_handler} };

    APP_BUTTON_INIT(buttons, sizeof(buttons) / sizeof(buttons[0]), BUTTON_DETECTION_DELAY, true);
    

    }

    I can send data when button is pressed,but how can I send button release event when button is release?

    One click event is constructed of a press and a release event.

Reply
  • when I initialize button

    static void buttons_init(void) { static app_button_cfg_t buttons[] = { {LEFT_BUTTON_PIN_NO, false, NRF_GPIO_PIN_NOPULL, button_event_handler}, {RIGHT_BUTTON_PIN_NO, false, NRF_GPIO_PIN_NOPULL, button_event_handler}, // Note: This pin is also BONDMNGR_DELETE_BUTTON_PIN_NO {UP_BUTTON_PIN_NO, false, NRF_GPIO_PIN_NOPULL, button_event_handler}, {DOWN_BUTTON_PIN_NO, false, NRF_GPIO_PIN_NOPULL, button_event_handler} };

    APP_BUTTON_INIT(buttons, sizeof(buttons) / sizeof(buttons[0]), BUTTON_DETECTION_DELAY, true);
    

    }

    I can send data when button is pressed,but how can I send button release event when button is release?

    One click event is constructed of a press and a release event.

Children
No Data
Related