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

[nrf_gpio/app_gpiote/nrf_drv_gpiote]

Hello Nordic,

I am following example code [--ble-app-lbs-master] for my application in (keil4.6/sdk8.0.0). Its already consisting (app_gpiote), but I want to add some code module which refer (nrf_drv_gpiote). Is it compulsory to use both files or only file can be used instead of two? How can I do so?

I tried to follow some previous posts but didn't get it well. Also, I am unable to see the icon for "run-time-environment" and "software-pack" icons (showing disabled) in Keil4.6.

Please suggest~

/Thanks n Regards

  • Hello @Stefan birnir Sverisson,

    Thanks for your well explanation. well,I understood so far, what you explain is:

    button_press: app_button_is_pushed();

    timer_starts: ?? (I did not find the timer in button_press function in --ble-app-lbs-example--)

    timer_timeout: pin_read();, app_button_event_handler();

    pressed/released: app_button_event handler();

    Sir, I checked it through debugging, handler is not properly called anywhere during the process. Please suggest me the code equation/function, it'd be little easy for me to follow the code.

    Should I need to add new timer to do so or its already there in the example code, as I didnt find the 'timer definition, when button_pushed. Also what is the need to use [#define APP_TIMER_MAX_TIMERS BSP_APP_TIMERS_NUMBER] ? Can I use simply [#define APP_TIMER_MAX_TIMERS 2].

    Please suggest.

    Thank you so much.

    /Regards

  • Hello @Stefan Birnir Sverisson Sir,

    Thanks for your reply~

    well,I found that in [--ble-app-lbs-master--] example, "button_is _pushed" is not called directly, when button is pushed, it directly called "Pushed button is detected". How about if I want to use the same button for different sequence, like "short press, long press, double press......etc. ? How can I implement this in same example [--ble-app-lbs-master--]?

    Please suggest.

    Thanks n Regards

  • Hi HSA

    When you press the button on the nRF51-DK board, the button_event_handler is called. In this handler, you call ble_lbs_on_button_change, which sends the "button pushed" message over BLE.

    In order to read a pin state periodically, create a periodic app_timer like in the example that I already linked to this thread. Start the app_timer in the button_event_handler. In the event handler for the app_timer, read the pin state and store it in an array or print it on UART.

    The button_event_handler is called both when a button is pressed and when a button is released. If you want to detect only a long button press for a button, you could set a long BUTTON_DETECTION_DELAY, which you set when you initialize the button library with call to buttons_init(). Then the button_event_handler will be called BUTTON_DETECTION_DELAY after the button is pushed. If the button is pushed for a shorter time, button_event_handler will not be called.

    You can implement all the functionality you want in the button_event_handler to detect long or short button press, double click, whatever you can think of. E.g. to detect a double click, set a short BUTTON_DETECTION_DELAY, then you can e.g. start an app_timer in the button_event_handler and if you receive a second push for the same button before the timer expires, it is a double click.

    When you get the first call to button_event_handler it is a short push. To detect a long push, start an app_timer in button_event_handler. When the app_timer expires and you still have not received a button released event, it is a long push.

  • @Stefan Birnir Sverrisson: Thank you so much sir for explaining the logic....

    I will try this and let you know the status.

    Thanks n Regards,

Related