#ifndef DRIVER_H
#define DRIVER_H
#include <main.h>
#include <stdio.h>
#include <Inf_4G.h>
extern uint8_t device_status[13];
extern uint32_t pump_flow;
extern uint32_t flow_to_upload;

extern uint8_t new_flow_data;
// 控制变量
static uint32_t total_pump_time = 0; // 水泵总运行时间（以秒为单位）
static uint32_t pump_start_time = 0;  // 水泵启动时间
static uint32_t last_dredge_time = 0; // 上次排泥时间

typedef struct {
    uint8_t pump_fault;     // 水泵故障标志 0:正常 1:故障
    uint8_t fan1_fault;     // 风机1故障标志
    uint8_t fan2_fault;     // 风机2故障标志
} Device_Fault_t;

extern  Device_Fault_t device_fault;

void LED1_Control(uint8_t state);
void Control_WaterPump(uint8_t state);
void Control_Fan1(uint8_t state);
void Control_Fan2(uint8_t state);
void Ozone_Control(uint8_t state);
void Control_Heater(uint8_t state);
void Control_Plate1(uint8_t state);
void Control_Plate2(uint8_t state);
void Control_Phosphorus(uint8_t state);
void Control_All_Devices(uint8_t state);
uint8_t Read_FloatBall(void);
uint8_t Read_LED1_Status(void);
uint8_t Read_WaterPump_Status(void);
uint8_t Read_Fan1_Status(void);
uint8_t Read_Fan2_Status(void);
uint8_t Ozone_GetState(void);
void Update_All_Status(void);
uint8_t Read_MainPower(void);

//void Check_Flow(void);
void Check_Fan1_Fault(void);
void Check_Fan2_Fault(void);

void Control_Dredge(uint8_t state);

void Control_All_Devices(uint8_t cmd);
#endif

