Skip to content

Commit

Permalink
Use CTR0 for max fan
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Crawford <[email protected]>
  • Loading branch information
crawfxrd committed Aug 6, 2024
1 parent 84e2dbb commit 3efb0d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/board/system76/common/fan.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ static uint8_t fan_duty(const struct Fan *const fan, int16_t temp) {
} else if (temp < cur->temp) {
// If lower than first temp, return 0%
if (i == 0) {
return MIN_FAN_SPEED;
return 0;
} else {
const struct FanPoint *prev = &fan->points[i - 1];

Expand All @@ -146,7 +146,7 @@ static uint8_t fan_duty(const struct Fan *const fan, int16_t temp) {
}

// If no point is found, return 100%
return MAX_FAN_SPEED;
return CTR0;
}

static uint8_t fan_smooth(uint8_t last_duty, uint8_t duty) {
Expand Down Expand Up @@ -219,13 +219,13 @@ static uint8_t fan_get_duty(const struct Fan *const fan, int16_t temp) {
if (power_state == POWER_STATE_S0) {
duty = fan_duty(fan, temp);
if (fan_max) {
duty = PWM_DUTY(100);
duty = CTR0;
} else {
duty = fan_heatup(fan, duty);
duty = fan_cooldown(fan, duty);
}
} else {
duty = PWM_DUTY(0);
duty = 0;
}

return duty;
Expand Down
4 changes: 2 additions & 2 deletions src/board/system76/common/scratch.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ uint8_t __code __at(SCRATCH_OFFSET) scratch_rom[] = {
// Enter or exit scratch ROM
void scratch_trampoline(void) {
// Set fans to 100%
FAN1_PWM = 0xFF;
FAN1_PWM = CTR0;
#ifdef FAN2_PWM
FAN2_PWM = 0xFF;
FAN2_PWM = CTR0;
#endif

//TODO: Clear keyboard presses
Expand Down

0 comments on commit 3efb0d9

Please sign in to comment.