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

how to print

hi all,

Question: i want to print "BUTTON IS PRESSED" continuously when button is pressed and i want to print "BUTTON IS RELEASED" when button is released.

eg: if i pressed the button

"BUTTON IS PRESSED"

"BUTTON IS PRESSED" "BUTTON IS PRESSED" "BUTTON IS PRESSED" "BUTTON IS PRESSED" "BUTTON IS PRESSED"........

if i released the button "BUTTON IS RELEASED" please help with with the code.i am a begineer to nordic. please help me.

Thanks in advance

Parents
  • Hi Ranjith,

    I think you should edit bsp.c file.

    find this function and edit like this way. static void bsp_button_event_handler(uint8_t pin_no, uint8_t button_action)

    case APP_BUTTON_PUSH: printf("BUTTON IS PRESSED\r\n");

                event = m_events_list[button].push_event;
                if (m_events_list[button].long_push_event != BSP_EVENT_NOTHING)
                {
                    err_code = app_timer_start(m_button_timer_id,    BSP_MS_TO_TICK(BSP_LONG_PUSH_TIMEOUT_MS), (void*)&current_long_push_pin_no);
                    if (err_code == NRF_SUCCESS)
                    {
                        current_long_push_pin_no = pin_no;
                    }
                }
                release_event_at_push[button] = m_events_list[button].release_event;
                break;
            case APP_BUTTON_RELEASE:
    	printf("BUTTON IS RELEASE\r\n");
    
                (void)app_timer_stop(m_button_timer_id);
                if (release_event_at_push[button] == m_events_list[button].release_event)
                {
                    event = m_events_list[button].release_event;
                }
                break;
            case BSP_BUTTON_ACTION_LONG_PUSH:
    	printf("BUTTON IS PRESSED\r\n");
    
                event = m_events_list[button].long_push_event;
        }
    

    before use printf to print on terminal you have to initialize uart. find Bellow attached jpg file and show output.

    BUTTON.JPG

    Regards, Rajneesh

Reply
  • Hi Ranjith,

    I think you should edit bsp.c file.

    find this function and edit like this way. static void bsp_button_event_handler(uint8_t pin_no, uint8_t button_action)

    case APP_BUTTON_PUSH: printf("BUTTON IS PRESSED\r\n");

                event = m_events_list[button].push_event;
                if (m_events_list[button].long_push_event != BSP_EVENT_NOTHING)
                {
                    err_code = app_timer_start(m_button_timer_id,    BSP_MS_TO_TICK(BSP_LONG_PUSH_TIMEOUT_MS), (void*)&current_long_push_pin_no);
                    if (err_code == NRF_SUCCESS)
                    {
                        current_long_push_pin_no = pin_no;
                    }
                }
                release_event_at_push[button] = m_events_list[button].release_event;
                break;
            case APP_BUTTON_RELEASE:
    	printf("BUTTON IS RELEASE\r\n");
    
                (void)app_timer_stop(m_button_timer_id);
                if (release_event_at_push[button] == m_events_list[button].release_event)
                {
                    event = m_events_list[button].release_event;
                }
                break;
            case BSP_BUTTON_ACTION_LONG_PUSH:
    	printf("BUTTON IS PRESSED\r\n");
    
                event = m_events_list[button].long_push_event;
        }
    

    before use printf to print on terminal you have to initialize uart. find Bellow attached jpg file and show output.

    BUTTON.JPG

    Regards, Rajneesh

Children
No Data
Related