changes
This commit is contained in:
@@ -67,7 +67,7 @@ function FanStatusRestControllerForm(props: FanStatusRestControllerFormProps) {
|
||||
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:100']}
|
||||
errorMessages={['Low Temperature required', "Must be a number", "Must be 0 or higher", "Max value is 100"]}
|
||||
name="temperature_thres_low"
|
||||
label="Low Temperature Threshold"
|
||||
label="Low Temperature Threshold (fan start)"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.temperature_thres_low}
|
||||
@@ -79,7 +79,7 @@ function FanStatusRestControllerForm(props: FanStatusRestControllerFormProps) {
|
||||
validators={['required', 'isNumber', 'minNumber:30', 'maxNumber:200']}
|
||||
errorMessages={['High Temperature required', "Must be a number", "Must be 0 or higher", "Max value is 100"]}
|
||||
name="temperature_thres_high"
|
||||
label="High Temperature Threshold"
|
||||
label="High Temperature Threshold (fan max)"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.temperature_thres_high}
|
||||
@@ -90,21 +90,46 @@ function FanStatusRestControllerForm(props: FanStatusRestControllerFormProps) {
|
||||
|
||||
<TextValidator
|
||||
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:40']}
|
||||
errorMessages={['Fan GPIO pin is required', "Must be a number", "Must be 0 or higher", "Max value is 40"]}
|
||||
name="fan_gpio"
|
||||
label="Fan GPIO pin"
|
||||
errorMessages={['Fan PWM pin is required', "Must be a number", "Must be 0 or higher", "Max value is 40"]}
|
||||
name="fan_pwm_gpio"
|
||||
label="Fan PWM GPIO pin"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.fan_gpio}
|
||||
value={data.fan_pwm_gpio}
|
||||
type="number"
|
||||
onChange={handleValueChange('fan_gpio')}
|
||||
onChange={handleValueChange('fan_pwm_gpio')}
|
||||
margin="normal"
|
||||
/>
|
||||
<TextValidator
|
||||
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:1024']}
|
||||
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:40']}
|
||||
errorMessages={['Fan TACH pin is required', "Must be a number", "Must be 0 or higher", "Max value is 40"]}
|
||||
name="fan_tach_gpio"
|
||||
label="Fan TACH GPIO pin"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.fan_tach_gpio}
|
||||
type="number"
|
||||
onChange={handleValueChange('fan_tach_gpio')}
|
||||
margin="normal"
|
||||
/>
|
||||
<TextValidator
|
||||
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:40']}
|
||||
errorMessages={['Temp Sensor pin is required', "Must be a number", "Must be 0 or higher", "Max value is 40"]}
|
||||
name="oneWire_gpio"
|
||||
label="Sensor OneWire DS1820 gpio"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.oneWire_gpio}
|
||||
type="number"
|
||||
onChange={handleValueChange('oneWire_gpio')}
|
||||
margin="normal"
|
||||
/>
|
||||
|
||||
<TextValidator
|
||||
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:100000']}
|
||||
errorMessages={['Fan MAX is required', "Must be a number", "Must be 0 or higher", "Max value is 1024"]}
|
||||
name="fan_max_speed"
|
||||
label="Fan Max Speed"
|
||||
label="Fan Max RPM Speed"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={data.fan_max_speed}
|
||||
|
||||
@@ -13,6 +13,8 @@ export interface FanStatus {
|
||||
temperature_thres_low : number;
|
||||
temperature_thres_high : number;
|
||||
fan_status : boolean;
|
||||
fan_gpio : number;
|
||||
fan_pwm_gpio : number;
|
||||
fan_tach_gpio : number;
|
||||
fan_max_speed : number;
|
||||
oneWire_gpio : number;
|
||||
}
|
||||
@@ -4,16 +4,15 @@
|
||||
#include <FSPersistence.h>
|
||||
#include <HttpEndpoint.h>
|
||||
|
||||
#include <OneWire.h>
|
||||
#include <DallasTemperature.h>
|
||||
|
||||
#define FAN_PIN 13
|
||||
#define PRINT_DELAY 5000
|
||||
|
||||
|
||||
|
||||
#define DEFAULT_FAN_STATE false
|
||||
#define DEFAULT_FAN_PWM_GPIO 13
|
||||
#define DEFAULT_FAN_PWM_GPIO 12
|
||||
#define DEFAULT_FAN_TACH_GPIO 13
|
||||
#define DEFAULT_ONEWIRE_GPIO 16
|
||||
#define DEFAULT_ONEWIRE_GPIO 14
|
||||
#define DEFAULT_THRES_LOW 25
|
||||
#define DEFAULT_THRES_HIGH 70
|
||||
#define DEFAULT_FAN_MAX_SPEED 1021
|
||||
@@ -52,7 +51,6 @@ class FanSettings {
|
||||
root["oneWire_gpio"] = settings.OneWireGPIO;
|
||||
root["sensor_in_temp"] = settings.sensorInTemp;
|
||||
root["sensor_out_temp"] = settings.sensorOutTemp;
|
||||
|
||||
root["fan_status"] = settings.fanStatus;
|
||||
root["fan_pwm_gpio"] = settings.fanPwmGPIO;
|
||||
root["fan_tach_gpio"] = settings.fanTachGPIO;
|
||||
@@ -61,10 +59,12 @@ class FanSettings {
|
||||
root["temperature_thres_high"] = settings.thresHigh;
|
||||
// String s = (String)root["fan_status"] + "|" + (String)root["fan_gpio"] + "|" + (String)root["fan_max_speed"] + "|" + (String)root["temperature_thres_low"] + "|" + (String)root["temperature_thres_high"];
|
||||
String s = root["fan_status"]; Serial.println(" ** Fan read [fan_status : " + s + "]");
|
||||
String t = root["fan_gpio"]; Serial.println(" ** Fan read [fan_gpio : " + t + "]");
|
||||
String u = root["fan_max_speed"]; Serial.println(" ** Fan read [fan_max_speed : " + u + "]");
|
||||
String v = root["temperature_thres_low"]; Serial.println(" ** Fan read [temperature_thres_low : " + v + "]");
|
||||
String w = root["temperature_thres_high"]; Serial.println(" ** Fan read [temperature_thres_high : " + w + "]");
|
||||
String t = root["fan_pwm_gpio"]; Serial.println(" ** Fan read [fan_pwm_gpio : " + t + "]");
|
||||
String u = root["fan_tach_gpio"]; Serial.println(" ** Fan read [fan_tach_gpio : " + u + "]");
|
||||
String v = root["fan_max_speed"]; Serial.println(" ** Fan read [fan_max_speed : " + v + "]");
|
||||
String w = root["temperature_thres_low"]; Serial.println(" ** Fan read [temperature_thres_low : " + w + "]");
|
||||
String x = root["temperature_thres_high"]; Serial.println(" ** Fan read [temperature_thres_high : " + x + "]");
|
||||
String y = root["oneWire_gpio"]; Serial.println(" ** Fan read [oneWire_gpio : " + y + "]");
|
||||
}
|
||||
|
||||
static StateUpdateResult update(JsonObject& root, FanSettings& fanState) {
|
||||
@@ -74,7 +74,7 @@ class FanSettings {
|
||||
int newMaxSpeed = root["fan_max_speed"] | DEFAULT_FAN_MAX_SPEED;
|
||||
int newThresLow = root["temperature_thres_low"] | DEFAULT_THRES_LOW;
|
||||
int newThresHigh = root["temperature_thres_high"] | DEFAULT_THRES_HIGH;
|
||||
int newOneWireGPIO = root["sensor_onewire_gpio"] | DEFAULT_ONEWIRE_GPIO;
|
||||
int newOneWireGPIO = root["oneWire_gpio"] | DEFAULT_ONEWIRE_GPIO;
|
||||
Serial.println(" ** Fan update [status:" + (String)newFanState + "|gpio:" + (String)newFanPwmGPIO + "|mxspd:" + (String)newMaxSpeed + "|low:" + (String)newThresLow + "|high:" + (String)newThresHigh + "]");
|
||||
if ( fanState.fanStatus != newFanState
|
||||
|| fanState.fanPwmGPIO != newFanPwmGPIO
|
||||
@@ -125,9 +125,20 @@ class FanSettings {
|
||||
|
||||
class FanStateService : public StatefulService<FanSettings> {
|
||||
public:
|
||||
unsigned long lastpoll;
|
||||
float Tin;
|
||||
float Tout;
|
||||
OneWire oneWire1;
|
||||
DallasTemperature sensor_intake;
|
||||
unsigned int RPM;
|
||||
|
||||
|
||||
FanStateService(AsyncWebServer* server, FS* fs, SecurityManager* securityManager);
|
||||
void begin();
|
||||
void save();
|
||||
void compute();
|
||||
void SetLastPoll(unsigned long l);
|
||||
int getTachGPIO();
|
||||
|
||||
private:
|
||||
HttpEndpoint<FanSettings> _httpEndpoint;
|
||||
|
||||
Reference in New Issue
Block a user