New controller will be run with single controller at first... get single board version from V2.0 and create new folder (two boards version is kept) -> copied firmware from e6e586e5855d81ee726bb9a0fbe8ab12def5eeef
50 lines
1.1 KiB
C++
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;
|
|
};
|