new meter
This commit is contained in:
@@ -5,13 +5,75 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initializes the load balancer.
|
||||
*
|
||||
* This function configures the load balancer and its resources, including
|
||||
* any necessary persistence configurations, such as storage in NVS (Non-Volatile Storage).
|
||||
* This function prepares the system to perform load balancing efficiently.
|
||||
*/
|
||||
void loadbalancer_init(void);
|
||||
|
||||
/**
|
||||
* @brief Continuous task for the load balancer.
|
||||
*
|
||||
* This function executes the load balancing logic continuously, typically in a FreeRTOS task.
|
||||
* It performs balance calculations, checks the grid current and energy conditions, and adjusts
|
||||
* the outputs as necessary to ensure efficient energy consumption.
|
||||
*
|
||||
* @param param Input parameter, usually used to pass additional information or relevant context
|
||||
* for the task execution.
|
||||
*/
|
||||
void loadbalancer_task(void *param);
|
||||
|
||||
// Compatibility functions
|
||||
void setMaxGridCurrent(int max_grid_current);
|
||||
void setLiveGridCurrent(int live_grid_current);
|
||||
void setLiveVolt(int live_volt);
|
||||
/**
|
||||
* @brief Enables or disables the load balancing system.
|
||||
*
|
||||
* This function allows enabling or disabling the load balancing system. When enabled, the load
|
||||
* balancer starts managing the grid current based on the configured limits. If disabled, the system
|
||||
* operates without balancing.
|
||||
*
|
||||
* The configuration is persisted in NVS, ensuring that the choice is maintained across system restarts.
|
||||
*
|
||||
* @param value If true, enables load balancing. If false, disables it.
|
||||
*/
|
||||
void loadbalancer_set_enabled(bool value);
|
||||
|
||||
/**
|
||||
* @brief Checks if load balancing is enabled.
|
||||
*
|
||||
* This function returns the current status of the load balancing system.
|
||||
*
|
||||
* @return Returns true if load balancing is enabled, otherwise returns false.
|
||||
*/
|
||||
bool loadbalancer_is_enabled(void);
|
||||
|
||||
/**
|
||||
* @brief Sets the maximum grid current.
|
||||
*
|
||||
* This function configures the maximum grid current that can be supplied to the load balancing system.
|
||||
* The value set ensures that the system does not overload the electrical infrastructure and respects
|
||||
* the safety limits.
|
||||
*
|
||||
* @param max_grid_current The maximum allowed current (in amperes) for the load balancing system.
|
||||
* This value should be appropriate for the grid capacity and the installation.
|
||||
*/
|
||||
esp_err_t load_balancing_set_max_grid_current(uint8_t max_grid_current);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Gets the maximum grid current.
|
||||
*
|
||||
* This function retrieves the current maximum grid current limit.
|
||||
*
|
||||
* @return The maximum grid current (in amperes).
|
||||
*/
|
||||
uint8_t load_balancing_get_max_grid_current(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
24
components/loadbalancer/include/loadbalancer_events.h
Normal file
24
components/loadbalancer/include/loadbalancer_events.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include "esp_event.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "esp_timer.h"
|
||||
|
||||
ESP_EVENT_DECLARE_BASE(LOADBALANCER_EVENTS);
|
||||
|
||||
typedef enum {
|
||||
LOADBALANCER_EVENT_INIT,
|
||||
LOADBALANCER_EVENT_STATE_CHANGED,
|
||||
LOADBALANCER_EVENT_CHARGING_LIMIT_CHANGED
|
||||
} loadbalancer_event_id_t;
|
||||
|
||||
typedef struct {
|
||||
float limit;
|
||||
int64_t timestamp_us;
|
||||
} loadbalancer_charging_limit_event_t;
|
||||
|
||||
typedef struct {
|
||||
bool enabled;
|
||||
int64_t timestamp_us;
|
||||
} loadbalancer_state_event_t;
|
||||
|
||||
Reference in New Issue
Block a user