Sync fan changes to darp5/galp3-c

This commit is contained in:
Jeremy Soller
2020-04-08 12:15:55 -06:00
parent 747dc84b5b
commit 65ba339fb5
2 changed files with 22 additions and 10 deletions

View File

@ -8,11 +8,14 @@
#include <ec/pwm.h> #include <ec/pwm.h>
// Fan speed is the lowest requested over HEATUP seconds // Fan speed is the lowest requested over HEATUP seconds
#define HEATUP 5 #define HEATUP 10
// Fan speed is the highest HEATUP speed over COOLDOWN seconds // Fan speed is the highest HEATUP speed over COOLDOWN seconds
#define COOLDOWN 10 #define COOLDOWN 10
// Interpolate duty cycle
#define INTERPOLATE 0
// Tjunction = 100C for i7-8565U (and probably the same for all WHL-U) // Tjunction = 100C for i7-8565U (and probably the same for all WHL-U)
#define T_JUNCTION 100 #define T_JUNCTION 100
@ -33,10 +36,9 @@ struct FanPoint {
// Fan curve with temperature in degrees C, duty cycle in percent // Fan curve with temperature in degrees C, duty cycle in percent
struct FanPoint __code FAN_POINTS[] = { struct FanPoint __code FAN_POINTS[] = {
FAN_POINT(65, 40), FAN_POINT(65, 40),
FAN_POINT(70, 45), FAN_POINT(70, 55),
FAN_POINT(75, 55), FAN_POINT(75, 75),
FAN_POINT(80, 75), FAN_POINT(80, 100)
FAN_POINT(84, 100)
}; };
// Get duty cycle based on temperature, adapted from // Get duty cycle based on temperature, adapted from
@ -55,6 +57,7 @@ uint8_t fan_duty(int16_t temp) {
} else { } else {
const struct FanPoint * prev = &FAN_POINTS[i - 1]; const struct FanPoint * prev = &FAN_POINTS[i - 1];
#if INTERPOLATE
// If in between current temp and previous temp, interpolate // If in between current temp and previous temp, interpolate
if (temp > prev->temp) { if (temp > prev->temp) {
int16_t dtemp = (cur->temp - prev->temp); int16_t dtemp = (cur->temp - prev->temp);
@ -64,6 +67,9 @@ uint8_t fan_duty(int16_t temp) {
((temp - prev->temp) * dduty) / dtemp ((temp - prev->temp) * dduty) / dtemp
); );
} }
#else // INTERPOLATE
return prev->duty;
#endif // INTERPOLATE
} }
} }
} }

View File

@ -8,11 +8,14 @@
#include <ec/pwm.h> #include <ec/pwm.h>
// Fan speed is the lowest requested over HEATUP seconds // Fan speed is the lowest requested over HEATUP seconds
#define HEATUP 5 #define HEATUP 10
// Fan speed is the highest HEATUP speed over COOLDOWN seconds // Fan speed is the highest HEATUP speed over COOLDOWN seconds
#define COOLDOWN 10 #define COOLDOWN 10
// Interpolate duty cycle
#define INTERPOLATE 0
// Tjunction = 100C for i7-8565U (and probably the same for all WHL-U) // Tjunction = 100C for i7-8565U (and probably the same for all WHL-U)
#define T_JUNCTION 100 #define T_JUNCTION 100
@ -33,10 +36,9 @@ struct FanPoint {
// Fan curve with temperature in degrees C, duty cycle in percent // Fan curve with temperature in degrees C, duty cycle in percent
struct FanPoint __code FAN_POINTS[] = { struct FanPoint __code FAN_POINTS[] = {
FAN_POINT(65, 40), FAN_POINT(65, 40),
FAN_POINT(70, 45), FAN_POINT(70, 55),
FAN_POINT(75, 55), FAN_POINT(75, 75),
FAN_POINT(80, 75), FAN_POINT(80, 100)
FAN_POINT(84, 100)
}; };
// Get duty cycle based on temperature, adapted from // Get duty cycle based on temperature, adapted from
@ -55,6 +57,7 @@ uint8_t fan_duty(int16_t temp) {
} else { } else {
const struct FanPoint * prev = &FAN_POINTS[i - 1]; const struct FanPoint * prev = &FAN_POINTS[i - 1];
#if INTERPOLATE
// If in between current temp and previous temp, interpolate // If in between current temp and previous temp, interpolate
if (temp > prev->temp) { if (temp > prev->temp) {
int16_t dtemp = (cur->temp - prev->temp); int16_t dtemp = (cur->temp - prev->temp);
@ -64,6 +67,9 @@ uint8_t fan_duty(int16_t temp) {
((temp - prev->temp) * dduty) / dtemp ((temp - prev->temp) * dduty) / dtemp
); );
} }
#else // INTERPOLATE
return prev->duty;
#endif // INTERPOLATE
} }
} }
} }