32 lines
889 B
C
32 lines
889 B
C
#ifndef EVSE_SESSION_H
|
|
#define EVSE_SESSION_H
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include "freertos/FreeRTOS.h"
|
|
|
|
/**
|
|
* @brief Charging session statistics
|
|
*/
|
|
typedef struct {
|
|
TickType_t start_tick; ///< tick when session began (debug/trace)
|
|
uint32_t duration_s; ///< total duration in seconds (tempo real)
|
|
uint32_t energy_wh; ///< total energy consumed in Wh (tempo real)
|
|
uint32_t avg_power_w; ///< average power in W
|
|
bool is_current; ///< true if session still in progress
|
|
} evse_session_t;
|
|
|
|
void evse_session_init(void);
|
|
void evse_session_start(void);
|
|
void evse_session_end(void);
|
|
|
|
/**
|
|
* @brief Periodic tick: called (e.g., each 1s) to accumulate energy from instant power.
|
|
* Implementação usa esp_timer (não assume 1s exato).
|
|
*/
|
|
void evse_session_tick(void);
|
|
|
|
bool evse_session_get(evse_session_t *out);
|
|
|
|
#endif // EVSE_SESSION_H
|