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

Regarding timer

Hello 

I am developing a firmware for nrf52832 using buttons like if I continuosly press my button for 6 seconds it will go to active mode from sleep mode and have been using app_timer example  for second generation is there any alternate way to genrate a time count for 6 seconds accuracy does not matter.

Thanks and regards

Manikandan v

Parents
  • Hi Manikandan ,

    There are other alternatives than using the app_timer, typically using an RTC directly or using a TIMER (though with a high current consumption as a result). The app_timer is probably the best to use for this though. Why do you want an alternative?

    Einar

  • I want to make this code as minimal as possible 

    Thanks and regards 

    manikandan v

    void process_button(uint32_t button_name, uint32_t action){
    
    //    sd_nvic_SystemReset();
    #if NRF52832 == 1
        if(button_name == SW1 && coaster_config_data.snooze_enabled){
            if(sleep_mode){
                app_timer_stop(long_press_timer);
                ret_code_t err = app_timer_start(long_press_timer, SIX_SECONDS, (void *)WAKE_UP);
                APP_ERROR_CHECK(err);
            }
            else{
                snooze_present_mems();
                five_min_counter = coaster_config_data.snoozer_timer_interval / 5;
                turn_off_buzzer = true;
                app_timer_stop(snooze_timer);
                app_timer_start(snooze_timer, APP_TIMER_TICKS(5*60*1000), NULL);
            }
        }
        else if(button_name == SW2){
            printf("SW2\n");
            if(!timer_started && !sleep_mode){
                timer_started = true;
                ret_code_t err = app_timer_start(long_press_timer, SIX_SECONDS, (void *)LONG_PRESS);
                APP_ERROR_CHECK(err);
            }
            ++count_for_long_press;
        }

  • I see. If you want to keep the total amount of code as low as possible, then doing things as low-level as possible will achieve that. That is typically not a requirement, though. A more common approach is where you want to keep your application code as simple and minimal, and achieve that by using higher level libraries that provide functionality you need. That is what you get by using the app_timer library, as I see you do here.

Reply
  • I see. If you want to keep the total amount of code as low as possible, then doing things as low-level as possible will achieve that. That is typically not a requirement, though. A more common approach is where you want to keep your application code as simple and minimal, and achieve that by using higher level libraries that provide functionality you need. That is what you get by using the app_timer library, as I see you do here.

Children
No Data
Related