Skip to content

Commit

Permalink
overheat mode init
Browse files Browse the repository at this point in the history
  • Loading branch information
WantClue committed Aug 1, 2024
1 parent 04c8b80 commit 95fb477
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 3 deletions.
3 changes: 2 additions & 1 deletion config.cvs.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ flipscreen,data,u16,1
invertfanpol,data,u16,1
autofanspeed,data,u16,1
fanspeed,data,u16,100
selftest,data,u16,1
selftest,data,u16,1
overheat,data,u16,0
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@
</div>
</div>

<div class="col-12 md:col-4">
<div class="field-checkbox">
<p-checkbox name="overheat" formControlName="overheat" inputId="overheat"
[binary]="true"></p-checkbox>
<label for="diagnostics">Disable Overheat Mode. Make sure to reset Frequency and Voltage</label>
</div>
</div>

<div *ngIf="form.controls['autofanspeed'].value != true">
<div class="col-12" *ngIf="form.controls['autofanspeed'].value != true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export class EditComponent implements OnInit {
autofanspeed: [info.autofanspeed == 1, [Validators.required]],
invertfanpolarity: [info.invertfanpolarity == 1, [Validators.required]],
fanspeed: [info.fanspeed, [Validators.required]],
overheat: [info.overheat]
});

this.form.controls['autofanspeed'].valueChanges.pipe(
Expand Down
3 changes: 2 additions & 1 deletion main/http_server/axe-os/src/app/services/system.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ export class SystemService {
fanrpm: 0,

boardtemp1: 30,
boardtemp2: 40
boardtemp2: 40,
overheat: 0
}
).pipe(delay(1000));
}
Expand Down
3 changes: 2 additions & 1 deletion main/http_server/axe-os/src/models/ISystemInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ export interface ISystemInfo {
coreVoltageActual: number,

boardtemp1?: number,
boardtemp2?: number
boardtemp2?: number,
overheat: number
}
4 changes: 4 additions & 0 deletions main/http_server/http_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,9 @@ static esp_err_t PATCH_update_settings(httpd_req_t * req)
if ((item = cJSON_GetObjectItem(root, "flipscreen")) != NULL) {
nvs_config_set_u16(NVS_CONFIG_FLIP_SCREEN, item->valueint);
}
if ((item = cJSON_GetObjectItem(root, "overheat")) == 1) {
nvs_config_set_u16(NVS_CONFIG_OVERHEAT_MODE, item->0);
}
if ((item = cJSON_GetObjectItem(root, "invertscreen")) != NULL) {
nvs_config_set_u16(NVS_CONFIG_INVERT_SCREEN, item->valueint);
}
Expand Down Expand Up @@ -412,6 +415,7 @@ static esp_err_t GET_system_info(httpd_req_t * req)
cJSON_AddStringToObject(root, "runningPartition", esp_ota_get_running_partition()->label);

cJSON_AddNumberToObject(root, "flipscreen", nvs_config_get_u16(NVS_CONFIG_FLIP_SCREEN, 1));
cJSON_AddNumberToObject(root, "overheat", nvs_config_get_u16(NVS_CONFIG_OVERHEAT_MODE,0));
cJSON_AddNumberToObject(root, "invertscreen", nvs_config_get_u16(NVS_CONFIG_INVERT_SCREEN, 0));

cJSON_AddNumberToObject(root, "invertfanpolarity", nvs_config_get_u16(NVS_CONFIG_INVERT_FAN_POLARITY, 1));
Expand Down
1 change: 1 addition & 0 deletions main/nvs_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#define NVS_CONFIG_FAN_SPEED "fanspeed"
#define NVS_CONFIG_BEST_DIFF "bestdiff"
#define NVS_CONFIG_SELF_TEST "selftest"
#define NVS_CONFIG_OVERHEAT_MODE "overheat_mode"

#define NVS_CONFIG_SWARM "swarmconfig"

Expand Down
31 changes: 31 additions & 0 deletions main/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,28 @@ static void _init_system(GlobalState * GLOBAL_STATE)
netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
}

static void _show_overheat_screen(GlobalState * GLOBAL_STATE)
{
switch (GLOBAL_STATE->device_model) {
case DEVICE_MAX:
case DEVICE_ULTRA:
case DEVICE_SUPRA:
if (OLED_status()) {
OLED_clearLine(0);
OLED_clearLine(1);
OLED_clearLine(2);
OLED_clearLine(3);
OLED_writeString(0, 0, "DEVICE OVERHEATED");
OLED_writeString(0, 1, "Please check");
OLED_writeString(0, 2, "webUI for more");
OLED_writeString(0, 3, "information");
}
break;
default:
break;
}
}

static void _update_hashrate(GlobalState * GLOBAL_STATE)
{
SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE;
Expand Down Expand Up @@ -485,6 +507,15 @@ void SYSTEM_task(void * pvParameters)
}

while (1) {
// Check for overheat mode
uint16_t overheat_mode = nvs_config_get_u16(NVS_CONFIG_OVERHEAT_MODE, 0);

if (overheat_mode == 1) {
_show_overheat_screen(GLOBAL_STATE);
vTaskDelay(5000 / portTICK_PERIOD_MS); // Update every 5 seconds
continue; // Skip the normal screen cycle
}

// Automatically cycle through screens
for (int screen = 0; screen < 3; screen++) {
_clear_display(GLOBAL_STATE);
Expand Down
1 change: 1 addition & 0 deletions main/tasks/power_management_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ void POWER_MANAGEMENT_task(void * pvParameters)
nvs_config_set_u16(NVS_CONFIG_ASIC_FREQ, 50);
nvs_config_set_u16(NVS_CONFIG_FAN_SPEED, 100);
nvs_config_set_u16(NVS_CONFIG_AUTO_FAN_SPEED, 0);
nvs_config_set_u16(NVS_CONFIG_OVERHEAT_MODE, 1);
exit(EXIT_FAILURE);
}

Expand Down

0 comments on commit 95fb477

Please sign in to comment.