From 95fb4775ef99c40538e28ce72f64ddce137e49bd Mon Sep 17 00:00:00 2001 From: WantClue Date: Thu, 1 Aug 2024 22:58:19 +0200 Subject: [PATCH 1/4] overheat mode init --- config.cvs.example | 3 +- .../app/components/edit/edit.component.html | 7 +++++ .../src/app/components/edit/edit.component.ts | 1 + .../axe-os/src/app/services/system.service.ts | 3 +- .../axe-os/src/models/ISystemInfo.ts | 3 +- main/http_server/http_server.c | 4 +++ main/nvs_config.h | 1 + main/system.c | 31 +++++++++++++++++++ main/tasks/power_management_task.c | 1 + 9 files changed, 51 insertions(+), 3 deletions(-) diff --git a/config.cvs.example b/config.cvs.example index 6afb47148..7315b50b4 100644 --- a/config.cvs.example +++ b/config.cvs.example @@ -16,4 +16,5 @@ flipscreen,data,u16,1 invertfanpol,data,u16,1 autofanspeed,data,u16,1 fanspeed,data,u16,100 -selftest,data,u16,1 \ No newline at end of file +selftest,data,u16,1 +overheat,data,u16,0 \ No newline at end of file diff --git a/main/http_server/axe-os/src/app/components/edit/edit.component.html b/main/http_server/axe-os/src/app/components/edit/edit.component.html index 5af1eab3f..6a0e328e6 100644 --- a/main/http_server/axe-os/src/app/components/edit/edit.component.html +++ b/main/http_server/axe-os/src/app/components/edit/edit.component.html @@ -147,6 +147,13 @@ +
+
+ + +
+
diff --git a/main/http_server/axe-os/src/app/components/edit/edit.component.ts b/main/http_server/axe-os/src/app/components/edit/edit.component.ts index 54aa8bab8..9c26b1b85 100644 --- a/main/http_server/axe-os/src/app/components/edit/edit.component.ts +++ b/main/http_server/axe-os/src/app/components/edit/edit.component.ts @@ -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( diff --git a/main/http_server/axe-os/src/app/services/system.service.ts b/main/http_server/axe-os/src/app/services/system.service.ts index 2267b7f27..aa8a11d63 100644 --- a/main/http_server/axe-os/src/app/services/system.service.ts +++ b/main/http_server/axe-os/src/app/services/system.service.ts @@ -56,7 +56,8 @@ export class SystemService { fanrpm: 0, boardtemp1: 30, - boardtemp2: 40 + boardtemp2: 40, + overheat: 0 } ).pipe(delay(1000)); } diff --git a/main/http_server/axe-os/src/models/ISystemInfo.ts b/main/http_server/axe-os/src/models/ISystemInfo.ts index a93895079..9647045d6 100644 --- a/main/http_server/axe-os/src/models/ISystemInfo.ts +++ b/main/http_server/axe-os/src/models/ISystemInfo.ts @@ -36,5 +36,6 @@ export interface ISystemInfo { coreVoltageActual: number, boardtemp1?: number, - boardtemp2?: number + boardtemp2?: number, + overheat: number } diff --git a/main/http_server/http_server.c b/main/http_server/http_server.c index d1a594709..faf277128 100644 --- a/main/http_server/http_server.c +++ b/main/http_server/http_server.c @@ -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); } @@ -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)); diff --git a/main/nvs_config.h b/main/nvs_config.h index 84dd4fe2a..c5f318d52 100644 --- a/main/nvs_config.h +++ b/main/nvs_config.h @@ -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" diff --git a/main/system.c b/main/system.c index 960d42c93..f19ffa487 100644 --- a/main/system.c +++ b/main/system.c @@ -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; @@ -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); diff --git a/main/tasks/power_management_task.c b/main/tasks/power_management_task.c index 4f1c54b69..03968db4d 100644 --- a/main/tasks/power_management_task.c +++ b/main/tasks/power_management_task.c @@ -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); } From 93916fd80d638cfa50646a0157a0f381afeb018e Mon Sep 17 00:00:00 2001 From: WantClue Date: Thu, 1 Aug 2024 23:13:59 +0200 Subject: [PATCH 2/4] update set setting --- main/http_server/http_server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/http_server/http_server.c b/main/http_server/http_server.c index faf277128..0c00da684 100644 --- a/main/http_server/http_server.c +++ b/main/http_server/http_server.c @@ -296,8 +296,8 @@ 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, "overheat")) != NULL) { + nvs_config_set_u16(NVS_CONFIG_OVERHEAT_MODE, 0); } if ((item = cJSON_GetObjectItem(root, "invertscreen")) != NULL) { nvs_config_set_u16(NVS_CONFIG_INVERT_SCREEN, item->valueint); From 4f394c4708a96a833a3e5eca99ebb2dcb49b0935 Mon Sep 17 00:00:00 2001 From: WantClue Date: Sat, 3 Aug 2024 13:01:35 +0200 Subject: [PATCH 3/4] adding disable button if overheat mode is false --- .../axe-os/src/app/components/edit/edit.component.html | 2 +- .../axe-os/src/app/components/edit/edit.component.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/main/http_server/axe-os/src/app/components/edit/edit.component.html b/main/http_server/axe-os/src/app/components/edit/edit.component.html index 6a0e328e6..593d720fb 100644 --- a/main/http_server/axe-os/src/app/components/edit/edit.component.html +++ b/main/http_server/axe-os/src/app/components/edit/edit.component.html @@ -147,7 +147,7 @@
-
+
diff --git a/main/http_server/axe-os/src/app/components/edit/edit.component.ts b/main/http_server/axe-os/src/app/components/edit/edit.component.ts index 9c26b1b85..4a24d471d 100644 --- a/main/http_server/axe-os/src/app/components/edit/edit.component.ts +++ b/main/http_server/axe-os/src/app/components/edit/edit.component.ts @@ -137,7 +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] + overheat: [info.overheat, [Validators.required]] }); this.form.controls['autofanspeed'].valueChanges.pipe( @@ -175,6 +175,8 @@ export class EditComponent implements OnInit { delete form.stratumPassword; } + form.overheat = form.overheat ? 1 : 0; + this.systemService.updateSystem(this.uri, form) .pipe(this.loadingService.lockUIUntilComplete()) .subscribe({ From c8f0fb11760ffea8bfa7357b24fdd09a845267ee Mon Sep 17 00:00:00 2001 From: WantClue Date: Sat, 3 Aug 2024 14:01:19 +0200 Subject: [PATCH 4/4] typo --- .../axe-os/src/app/components/edit/edit.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/http_server/axe-os/src/app/components/edit/edit.component.html b/main/http_server/axe-os/src/app/components/edit/edit.component.html index 593d720fb..07facc967 100644 --- a/main/http_server/axe-os/src/app/components/edit/edit.component.html +++ b/main/http_server/axe-os/src/app/components/edit/edit.component.html @@ -151,7 +151,7 @@
- +