@@ -96,46 +96,46 @@ void POWER_MANAGEMENT_task(void * pvParameters)
9696 // goto looper; // This goto is problematic, consider refactoring if used
9797 // }
9898
99- //overheat mode if the voltage regulator or ASIC is too hot
100- if ((power_management -> vr_temp > TPS546_THROTTLE_TEMP || power_management -> chip_temp_avg > THROTTLE_TEMP ) && (power_management -> frequency_value > 50 || power_management -> voltage > 1000 )) {
101- ESP_LOGE (TAG , "OVERHEAT! VR: %fC ASIC %fC" , power_management -> vr_temp , power_management -> chip_temp_avg );
102- power_management -> fan_perc = 100 ;
103- Thermal_set_fan_percent (GLOBAL_STATE -> DEVICE_CONFIG , 1 );
104-
105- // Turn off core voltage
106- VCORE_set_voltage (0.0f , GLOBAL_STATE );
107-
108- nvs_config_set_u16 (NVS_CONFIG_ASIC_VOLTAGE , 1000 );
109- nvs_config_set_u16 (NVS_CONFIG_ASIC_FREQ , 50 );
110- nvs_config_set_u16 (NVS_CONFIG_FAN_SPEED , 100 );
111- nvs_config_set_u16 (NVS_CONFIG_AUTO_FAN_SPEED , 0 );
112- nvs_config_set_u16 (NVS_CONFIG_OVERHEAT_MODE , 1 );
113- exit (EXIT_FAILURE );
114- }
115- //enable the PID auto control for the FAN if set
116- if (nvs_config_get_u16 (NVS_CONFIG_AUTO_FAN_SPEED , 1 ) == 1 ) {
117- // Ignore invalid temperature readings (-1) during startup
118- if (power_management -> chip_temp_avg >= 0 ) {
119- pid_input = power_management -> chip_temp_avg ;
120- pid_compute (& pid );
121- power_management -> fan_perc = (uint16_t ) pid_output ;
122- Thermal_set_fan_percent (GLOBAL_STATE -> DEVICE_CONFIG , pid_output / 100.0 );
123- ESP_LOGI (TAG , "Temp: %.1f°C, SetPoint: %.1f°C, Output: %.1f%%" , pid_input , pid_setPoint , pid_output );
124- } else {
125- // Set fan to 70% in AP mode when temperature reading is invalid
126- if (GLOBAL_STATE -> SYSTEM_MODULE .ap_enabled ) {
127- ESP_LOGW (TAG , "AP mode with invalid temperature reading: %.1f°C - Setting fan to 70%%" , power_management -> chip_temp_avg );
128- power_management -> fan_perc = 70 ;
129- Thermal_set_fan_percent (GLOBAL_STATE -> DEVICE_CONFIG , 0.7 );
99+ //overheat mode if the voltage regulator or ASIC is too hot
100+ if ((power_management -> vr_temp > TPS546_THROTTLE_TEMP || power_management -> chip_temp_avg > THROTTLE_TEMP ) && (power_management -> frequency_value > 50 || power_management -> voltage > 1000 )) {
101+ ESP_LOGE (TAG , "OVERHEAT! VR: %fC ASIC %fC" , power_management -> vr_temp , power_management -> chip_temp_avg );
102+ power_management -> fan_perc = 100 ;
103+ Thermal_set_fan_percent (GLOBAL_STATE -> DEVICE_CONFIG , 1 );
104+
105+ // Turn off core voltage
106+ VCORE_set_voltage (0.0f , GLOBAL_STATE );
107+
108+ nvs_config_set_u16 (NVS_CONFIG_ASIC_VOLTAGE , 1000 );
109+ nvs_config_set_u16 (NVS_CONFIG_ASIC_FREQ , 50 );
110+ nvs_config_set_u16 (NVS_CONFIG_FAN_SPEED , 100 );
111+ nvs_config_set_u16 (NVS_CONFIG_AUTO_FAN_SPEED , 0 );
112+ nvs_config_set_u16 (NVS_CONFIG_OVERHEAT_MODE , 1 );
113+ exit (EXIT_FAILURE );
114+ }
115+ //enable the PID auto control for the FAN if set
116+ if (nvs_config_get_u16 (NVS_CONFIG_AUTO_FAN_SPEED , 1 ) == 1 ) {
117+ // Ignore invalid temperature readings (-1) during startup
118+ if (power_management -> chip_temp_avg >= 0 ) {
119+ pid_input = power_management -> chip_temp_avg ;
120+ pid_compute (& pid );
121+ power_management -> fan_perc = (uint16_t ) pid_output ;
122+ Thermal_set_fan_percent (GLOBAL_STATE -> DEVICE_CONFIG , pid_output / 100.0 );
123+ ESP_LOGI (TAG , "Temp: %.1f°C, SetPoint: %.1f°C, Output: %.1f%%" , pid_input , pid_setPoint , pid_output );
130124 } else {
131- ESP_LOGW (TAG , "Ignoring invalid temperature reading: %.1f°C" , power_management -> chip_temp_avg );
125+ // Set fan to 70% in AP mode when temperature reading is invalid
126+ if (GLOBAL_STATE -> SYSTEM_MODULE .ap_enabled ) {
127+ ESP_LOGW (TAG , "AP mode with invalid temperature reading: %.1f°C - Setting fan to 70%%" , power_management -> chip_temp_avg );
128+ power_management -> fan_perc = 70 ;
129+ Thermal_set_fan_percent (GLOBAL_STATE -> DEVICE_CONFIG , 0.7 );
130+ } else {
131+ ESP_LOGW (TAG , "Ignoring invalid temperature reading: %.1f°C" , power_management -> chip_temp_avg );
132+ }
132133 }
134+ } else {
135+ float fs = (float ) nvs_config_get_u16 (NVS_CONFIG_FAN_SPEED , 100 );
136+ power_management -> fan_perc = fs ;
137+ Thermal_set_fan_percent (GLOBAL_STATE -> DEVICE_CONFIG , (float ) fs / 100.0 );
133138 }
134- } else {
135- float fs = (float ) nvs_config_get_u16 (NVS_CONFIG_FAN_SPEED , 100 );
136- power_management -> fan_perc = fs ;
137- Thermal_set_fan_percent (GLOBAL_STATE -> DEVICE_CONFIG , (float ) fs / 100.0 );
138- }
139139
140140 // Read the state of plug sense pin
141141 // if (power_management->HAS_PLUG_SENSE) {
0 commit comments