#pragma once

#include <Arduino.h>
#include <DebugLog.h>
#include "pins.h"

#include "driver/gpio.h"

enum State
{
    S_12P,
    S_12N_DELAY,
    S_12N,
    S_WAIT_10MS,
    S_34P,
    S_34N_DELAY,
    S_34N,
    S_WAIT_1MS,
    S_WAIT_10MS_END
};

struct timerStatus
{
    State state = State::S_12P;
    uint32_t state_time = 0;
    uint32_t clock_period_us;
    uint32_t pause_long_us;
    uint32_t pause_short_us;
    uint32_t coil_pulse_us;
    uint32_t spark_pulse_us;
    uint32_t spark_delay_us;
    bool soft_start = false;
    bool coil12p_high = false;
    bool coil34p_high = false;
    bool coil12n_high = false;
    bool coil34n_high = false;
    TaskHandle_t main_task;
};

void IRAM_ATTR onTimer(void *arg);
