diff --git a/nyx/nyx_gui/frontend/gui.c b/nyx/nyx_gui/frontend/gui.c index a32498c..134a05c 100644 --- a/nyx/nyx_gui/frontend/gui.c +++ b/nyx/nyx_gui/frontend/gui.c @@ -782,13 +782,13 @@ static void _update_status_bar(void *params) max17050_get_property(MAX17050_VCELL, &batt_volt); max17050_get_property(MAX17050_Current, &batt_curr); + // Enable fan if more than 46 oC. u32 soc_temp_dec = (soc_temp >> 8); - // Enable fan if more than 44 oC. - if (soc_temp_dec > 50) - set_fan_duty(100); - else if (soc_temp_dec > 44) - set_fan_duty(53); - else + if (soc_temp_dec > 51) + set_fan_duty(102); + else if (soc_temp_dec > 46) + set_fan_duty(51); + else if (soc_temp_dec < 40) set_fan_duty(0); //! TODO: Parse time and use offset. diff --git a/nyx/nyx_gui/thermal/fan.c b/nyx/nyx_gui/thermal/fan.c index 0e3e6ff..f142638 100644 --- a/nyx/nyx_gui/thermal/fan.c +++ b/nyx/nyx_gui/thermal/fan.c @@ -23,14 +23,18 @@ #include "../soc/t210.h" #include "../utils/util.h" -bool fan_init = false; - void set_fan_duty(u32 duty) { + static bool fan_init = false; + static u16 curr_duty = -1; + + if (curr_duty == duty) + return; + if (!fan_init) { // Fan tachometer. - PINMUX_AUX(PINMUX_AUX_CAM1_PWDN) = PINMUX_PULL_UP | PINMUX_TRISTATE | PINMUX_INPUT_ENABLE | 1; + PINMUX_AUX(PINMUX_AUX_CAM1_PWDN) = PINMUX_TRISTATE | PINMUX_INPUT_ENABLE | PINMUX_PULL_UP | 1; gpio_config(GPIO_PORT_S, GPIO_PIN_7, GPIO_MODE_GPIO); gpio_output_enable(GPIO_PORT_S, GPIO_PIN_7, GPIO_OUTPUT_DISABLE); gpio_write(GPIO_PORT_S, GPIO_PIN_7, GPIO_LOW); @@ -52,7 +56,7 @@ void set_fan_duty(u32 duty) // If disabled send a 0 duty. if (inv_duty == 236) { - PWM(PWM_CONTROLLER_PWM_CSR_1) = PWM_CSR_EN | (1 << 24); + PWM(PWM_CONTROLLER_PWM_CSR_1) = PWM_CSR_EN | (1 << 24); // Bit 24 is absolute 0%. regulator_disable_5v(REGULATOR_5V_FAN); } else // Set PWM duty. @@ -61,6 +65,8 @@ void set_fan_duty(u32 duty) regulator_enable_5v(REGULATOR_5V_FAN); PWM(PWM_CONTROLLER_PWM_CSR_1) = PWM_CSR_EN | (inv_duty << 16); } + + curr_duty = duty; } void get_fan_speed(u32 *duty, u32 *rpm)