Start stop button ?

Dear Members,

How can I make a start/stop button with 1 button ?

Here's my handler :

void bsp_event_handler(bsp_event_t event)
{
    switch (event)
    {
        case BSP_EVENT_SLEEP:
            nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_SYSOFF);
            break;
				
				 case BSP_EVENT_KEY_0:
					 NRF_LOG_INFO("BSP_EVENT_KEY 0 PUSH ON\n");
            if (actual_state != BSP_INDICATE_FIRST)
                actual_state--;
						    //NRF_LOG_INFO("BSP_EVENT_KEY 0 PUSH ON\n"); //2Mar22 Rixtronix LAB
            else
                actual_state = BSP_INDICATE_LAST;
						    NRF_LOG_INFO("BSP_EVENT_KEY 0 PUSH OFF\n"); //2Mar22 Rixtronix LAB
            break;
            ............

Any clues ?

Kind regards,

Rixtronix LAB

  • Hello Rixtronix.

    RixtronixLAB said:

    I got "error code 7"

    what does it mean ?

    Please make sure to have DEBUG defined in your preprocessor defines, like shown in the included image:

    This will make your logger output detailed debug information whenever a non-NRF_SUCCESS error code is passed to an APP_ERROR_CHECK.
    You may then check the returned error code against the functions API reference, to see why it would return this error and how you can resolve it.

    RixtronixLAB said:
    don't have to use bsp_btn_ant_init, I took it from ANT example ?

    The ant and ble options loads the usual button support package configuration for those cases.
    For instance, in our BLE examples we always use the same button layout and functionality - i.e erase bonds on a long press wakeup, or advertising indication by blinking of LED 1, etc.
    If you do not wish for any of this functionality to be already implemented you may instead not use the ant or ble bsp options. You should then go into the ant or ble bsp init functions to see how they initialize the bsp module, so that you may do it in a similar way for your own bsp usage.

    Best regards,
    Karl

Related