/* timer_idx - the timer number to initialize auto_reload - should the timer auto reload on alarm? timer_interval_sec - the interval of alarm to set  */
static void example_tg0_timer_init(int timer_idx, bool auto_reload, double timer_interval_sec)
/* timer_idx - the timer number to initialize auto_reload - should the timer auto reload on alarm? timer_interval_sec - the interval of alarm to set  */
static void example_tg0_timer_init(int timer_idx, bool auto_reload, double timer_interval_sec)
{
    timer_config_t config;
    config.divider = TIMER_DIVIDER;
    config.counter_dir = TIMER_COUNT_UP;
    config.counter_en = TIMER_PAUSE;
    config.alarm_en = TIMER_ALARM_EN;
    config.intr_type = TIMER_INTR_LEVEL;
    config.auto_reload = auto_reload;
    timer_init(TIMER_GROUP_0, timer_idx, &config);
    timer_set_counter_value(TIMER_GROUP_0, timer_idx, 0x00000000ULL);
    timer_set_alarm_value(TIMER_GROUP_0, timer_idx, timer_interval_sec * TIMER_SCALE);
    timer_enable_intr(TIMER_GROUP_0, timer_idx);
    timer_isr_register(TIMER_GROUP_0, timer_idx, timer_group0_isr, 
        (void *) timer_idx, ESP_INTR_FLAG_IRAM, NULL);
    timer_start(TIMER_GROUP_0, timer_idx);
}