armchair_fw/main/fan.hpp
jonny_l480 4731f9253e Cleanup: comments, structure, warnings
went trough all current files:
- remove old comments
- change structure / newlines

- main.cpp: outsource loglevel function
- http.cpp: FIX compiler warnings

	currentsensor.hpp
2023-08-22 11:16:37 +02:00

50 lines
1.1 KiB
C++

#pragma once
extern "C"
{
#include "driver/gpio.h"
}
#include "motorctl.hpp"
//--- fan_config_t ---
//struct with all config parameters for a fan
typedef struct fan_config_t {
gpio_num_t gpio_fan;
float dutyThreshold;
uint32_t minOnMs;
uint32_t minOffMs;
uint32_t turnOffDelayMs;
} fan_config;
//==================================
//====== controlledFan class =======
//==================================
class controlledFan {
public:
//--- constructor ---
controlledFan (fan_config_t config_f, controlledMotor* motor1_f, controlledMotor* motor2_f );
//--- functions ---
void handle(); //has to be run repeatedly in a slow loop
private:
//--- variables ---
bool fanRunning = false;
bool needsCooling = false;
uint32_t timestamp_needsCoolingSet;
uint32_t timestamp_lastThreshold = 0;
uint32_t timestamp_turnedOn = 0;
uint32_t timestamp_turnedOff = 0;
fan_config_t config;
controlledMotor * motor1;
controlledMotor * motor2;
motorCommand_t motor1Status;
motorCommand_t motor2Status;
};