new release
This commit is contained in:
@@ -2,17 +2,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "scheduler_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
void scheduler_init(void);
|
||||
void scheduler_set_config(const sched_config_t *cfg);
|
||||
sched_config_t scheduler_get_config(void);
|
||||
bool scheduler_is_allowed_now(void);
|
||||
void scheduler_init(void);
|
||||
void scheduler_set_config(const sched_config_t *cfg);
|
||||
sched_config_t scheduler_get_config(void);
|
||||
|
||||
bool scheduler_is_allowed_now(void);
|
||||
uint16_t scheduler_get_current_limit_now_a(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,17 +1,19 @@
|
||||
// scheduler_events.h
|
||||
// components/scheduler/include/scheduler_events.h
|
||||
#pragma once
|
||||
#include "esp_event.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
ESP_EVENT_DECLARE_BASE(SCHED_EVENTS);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SCHED_EVENT_INIT = 0, // envia estado inicial
|
||||
SCHED_EVENT_WINDOW_CHANGED, // allowed_now mudou
|
||||
SCHED_EVENT_INIT = 0,
|
||||
SCHED_EVENT_WINDOW_CHANGED,
|
||||
} sched_event_id_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bool allowed_now;
|
||||
} sched_event_state_t;
|
||||
uint16_t current_limit_a; // 0 se fora de janela / sem override
|
||||
} sched_event_state_t;
|
||||
@@ -4,28 +4,37 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
SCHED_MODE_DISABLED = 0, // não faz gating
|
||||
SCHED_MODE_SIMPLE, // por ex: janela diária única
|
||||
SCHED_MODE_WEEKLY // por ex: janelas por dia da semana
|
||||
} sched_mode_t;
|
||||
typedef enum
|
||||
{
|
||||
SCHED_MODE_DISABLED = 0,
|
||||
SCHED_MODE_DAILY_MULTI = 1,
|
||||
} sched_mode_t;
|
||||
|
||||
typedef struct {
|
||||
bool enabled; // gating ativo?
|
||||
sched_mode_t mode;
|
||||
#define SCHED_MAX_WINDOWS 4
|
||||
|
||||
// exemplo bem simples: uma janela diária [start_min..end_min[
|
||||
// minutos desde meia-noite, 0..1439
|
||||
uint16_t start_min;
|
||||
uint16_t end_min;
|
||||
} sched_config_t;
|
||||
typedef struct
|
||||
{
|
||||
uint16_t start_min; // 0..1440 (aceita 1440 = 24:00)
|
||||
uint16_t end_min; // 0..1440
|
||||
uint16_t current_a; // 6..80
|
||||
} sched_window_t;
|
||||
|
||||
const char *sched_mode_to_str(sched_mode_t mode);
|
||||
bool sched_mode_from_str(const char *s, sched_mode_t *out);
|
||||
typedef struct
|
||||
{
|
||||
bool enabled;
|
||||
sched_mode_t mode;
|
||||
|
||||
uint8_t window_count;
|
||||
sched_window_t windows[SCHED_MAX_WINDOWS];
|
||||
} sched_config_t;
|
||||
|
||||
const char *sched_mode_to_str(sched_mode_t mode);
|
||||
bool sched_mode_from_str(const char *s, sched_mode_t *out);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
Reference in New Issue
Block a user