From 7535042f9a0a109a19ea759d640fb7eac3689dc5 Mon Sep 17 00:00:00 2001 From: feeling Date: Tue, 2 Feb 2021 09:21:44 +0100 Subject: [PATCH] changes --- interface/src/project/FanCtlSettings.tsx | 43 +++++++++++++++++++----- interface/src/project/types.ts | 4 ++- src/FanStateService.h | 35 ++++++++++++------- 3 files changed, 60 insertions(+), 22 deletions(-) diff --git a/interface/src/project/FanCtlSettings.tsx b/interface/src/project/FanCtlSettings.tsx index abd9b89..9597aaf 100644 --- a/interface/src/project/FanCtlSettings.tsx +++ b/interface/src/project/FanCtlSettings.tsx @@ -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) { + + + #include +#include +#include -#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 @@ -51,8 +50,7 @@ class FanSettings { static void read(FanSettings& settings, JsonObject& root) { root["oneWire_gpio"] = settings.OneWireGPIO; root["sensor_in_temp"] = settings.sensorInTemp; - root["sensor_out_temp"] = settings.sensorOutTemp; - + 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 { 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 _httpEndpoint;