Files
Smart-flower-system/main/auto_ctrl_thresholds.h
Wang Beihong fcc2d0825d first commit
2026-03-14 14:19:32 +08:00

34 lines
954 B
C

#pragma once
#include "esp_err.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
float pump_on_soil_below_pct;
float pump_off_soil_above_pct;
float light_on_lux_below;
float light_off_lux_above;
} auto_ctrl_thresholds_t;
// Initializes default thresholds once at boot.
void auto_ctrl_thresholds_init_defaults(void);
// Thread-safe snapshot read, intended for control loop usage.
void auto_ctrl_thresholds_get(auto_ctrl_thresholds_t *out);
// Thread-safe full update with range/order validation.
esp_err_t auto_ctrl_thresholds_set(const auto_ctrl_thresholds_t *cfg);
// Convenience API for MQTT callback usage.
esp_err_t auto_ctrl_thresholds_set_values(float pump_on_soil_below_pct,
float pump_off_soil_above_pct,
float light_on_lux_below,
float light_off_lux_above);
#ifdef __cplusplus
}
#endif