Compare commits

...

5 Commits

Author SHA1 Message Date
terratec
75243a2cca
Merge 1820153c41bbd0cd6471f42e677b165f9e2080ef into 9d8198a4bb091b5404ab67c570a705cd319cfae6 2025-03-16 20:06:46 +00:00
skot
9d8198a4bb
Update readme.md with latest unlock settings 2025-03-16 13:13:18 -04:00
terratec
1820153c41 Move lv_display_trigger_activity into screen_show 2025-03-16 12:47:32 +01:00
terratec
e48e9e6bb6 Display timeout logic 2025-03-16 12:47:32 +01:00
terratec
427dda16d3 Add config for display timeout 2025-03-16 12:47:32 +01:00
11 changed files with 66 additions and 3 deletions

View File

@ -26,11 +26,17 @@
static const char * TAG = "display"; static const char * TAG = "display";
static esp_lcd_panel_handle_t panel_handle = NULL;
static bool display_state_on = false;
static lv_theme_t theme; static lv_theme_t theme;
static lv_style_t scr_style; static lv_style_t scr_style;
extern const lv_font_t lv_font_portfolio_6x8; extern const lv_font_t lv_font_portfolio_6x8;
esp_err_t display_on(void);
esp_err_t display_off(void);
static void theme_apply(lv_theme_t *theme, lv_obj_t *obj) { static void theme_apply(lv_theme_t *theme, lv_obj_t *obj) {
if (lv_obj_get_parent(obj) == NULL) { if (lv_obj_get_parent(obj) == NULL) {
lv_obj_add_style(obj, &scr_style, LV_PART_MAIN); lv_obj_add_style(obj, &scr_style, LV_PART_MAIN);
@ -61,7 +67,6 @@ esp_err_t display_init(void * pvParameters)
ESP_RETURN_ON_ERROR(esp_lcd_new_panel_io_i2c(i2c_master_bus_handle, &io_config, &io_handle), TAG, "Failed to initialise i2c panel bus"); ESP_RETURN_ON_ERROR(esp_lcd_new_panel_io_i2c(i2c_master_bus_handle, &io_config, &io_handle), TAG, "Failed to initialise i2c panel bus");
ESP_LOGI(TAG, "Install SSD1306 panel driver"); ESP_LOGI(TAG, "Install SSD1306 panel driver");
esp_lcd_panel_handle_t panel_handle = NULL;
esp_lcd_panel_dev_config_t panel_config = { esp_lcd_panel_dev_config_t panel_config = {
.bits_per_pixel = 1, .bits_per_pixel = 1,
.reset_gpio_num = -1, .reset_gpio_num = -1,
@ -123,7 +128,10 @@ esp_err_t display_init(void * pvParameters)
} }
// Only turn on the screen when it has been cleared // Only turn on the screen when it has been cleared
ESP_RETURN_ON_ERROR(esp_lcd_panel_disp_on_off(panel_handle, true), TAG, "Panel display on failed"); esp_err_t esp_err = display_on();
if (ESP_OK != esp_err) {
return esp_err;
}
GLOBAL_STATE->SYSTEM_MODULE.is_screen_active = true; GLOBAL_STATE->SYSTEM_MODULE.is_screen_active = true;
} else { } else {
@ -132,3 +140,22 @@ esp_err_t display_init(void * pvParameters)
return ESP_OK; return ESP_OK;
} }
esp_err_t display_on(void)
{
if (!display_state_on && (NULL != panel_handle)) {
ESP_RETURN_ON_ERROR(esp_lcd_panel_disp_on_off(panel_handle, true), TAG, "Panel display on failed");
display_state_on = true;
}
return ESP_OK;
}
esp_err_t display_off(void)
{
if (display_state_on && (NULL != panel_handle)) {
ESP_RETURN_ON_ERROR(esp_lcd_panel_disp_on_off(panel_handle, false), TAG, "Panel display off failed");
display_state_on = false;
}
return ESP_OK;
}

View File

@ -2,5 +2,7 @@
#define DISPLAY_H_ #define DISPLAY_H_
esp_err_t display_init(void * pvParameters); esp_err_t display_init(void * pvParameters);
esp_err_t display_on(void);
esp_err_t display_off(void);
#endif /* DISPLAY_H_ */ #endif /* DISPLAY_H_ */

View File

@ -49,6 +49,15 @@
</small> </small>
</div> </div>
<div class="field grid p-fluid">
<label htmlFor="displayTimeout" class="col-12 mb-2 md:col-2 md:mb-0">Display Timeout</label>
<div class="col-12 md:col-10">
<label>{{form.controls['displayTimeout'].value}} Minute(s)
<b *ngIf="form.controls['displayTimeout'].value == 0" style="color: #F2A900">Disabled</b></label>
<p-slider formControlName="displayTimeout" [min]="0" [max]="60"></p-slider>
</div>
</div>
<div class="col-12 md:col-4"> <div class="col-12 md:col-4">
<div class="field-checkbox"> <div class="field-checkbox">
<p-checkbox name="flipscreen" formControlName="flipscreen" inputId="flipscreen" <p-checkbox name="flipscreen" formControlName="flipscreen" inputId="flipscreen"

View File

@ -186,6 +186,7 @@ export class EditComponent implements OnInit, OnDestroy {
this.form = this.fb.group({ this.form = this.fb.group({
flipscreen: [info.flipscreen == 1], flipscreen: [info.flipscreen == 1],
invertscreen: [info.invertscreen == 1], invertscreen: [info.invertscreen == 1],
displayTimeout: [info.displayTimeout, [Validators.required]],
coreVoltage: [info.coreVoltage, [Validators.required]], coreVoltage: [info.coreVoltage, [Validators.required]],
frequency: [info.frequency, [Validators.required]], frequency: [info.frequency, [Validators.required]],
autofanspeed: [info.autofanspeed == 1, [Validators.required]], autofanspeed: [info.autofanspeed == 1, [Validators.required]],

View File

@ -57,6 +57,7 @@ export class SettingsComponent {
this.form = this.fb.group({ this.form = this.fb.group({
flipscreen: [info.flipscreen == 1], flipscreen: [info.flipscreen == 1],
invertscreen: [info.invertscreen == 1], invertscreen: [info.invertscreen == 1],
displayTimeout: [info.displayTimeout, [Validators.required]],
stratumURL: [info.stratumURL, [ stratumURL: [info.stratumURL, [
Validators.required, Validators.required,
Validators.pattern(/^(?!.*stratum\+tcp:\/\/).*$/), Validators.pattern(/^(?!.*stratum\+tcp:\/\/).*$/),

View File

@ -58,6 +58,7 @@ export class SystemService {
boardVersion: "204", boardVersion: "204",
flipscreen: 1, flipscreen: 1,
invertscreen: 0, invertscreen: 0,
displayTimeout: 0,
invertfanpolarity: 1, invertfanpolarity: 1,
autofanspeed: 1, autofanspeed: 1,
fanspeed: 100, fanspeed: 100,

View File

@ -9,6 +9,7 @@ export interface ISystemInfo {
flipscreen: number; flipscreen: number;
invertscreen: number; invertscreen: number;
displayTimeout: number;
power: number, power: number,
voltage: number, voltage: number,
current: number, current: number,

View File

@ -463,6 +463,9 @@ static esp_err_t PATCH_update_settings(httpd_req_t * req)
if ((item = cJSON_GetObjectItem(root, "invertscreen")) != NULL) { if ((item = cJSON_GetObjectItem(root, "invertscreen")) != NULL) {
nvs_config_set_u16(NVS_CONFIG_INVERT_SCREEN, item->valueint); nvs_config_set_u16(NVS_CONFIG_INVERT_SCREEN, item->valueint);
} }
if ((item = cJSON_GetObjectItem(root, "displayTimeout")) != NULL) {
nvs_config_set_u16(NVS_CONFIG_DISPLAY_TIMEOUT, item->valueint);
}
if ((item = cJSON_GetObjectItem(root, "invertfanpolarity")) != NULL) { if ((item = cJSON_GetObjectItem(root, "invertfanpolarity")) != NULL) {
nvs_config_set_u16(NVS_CONFIG_INVERT_FAN_POLARITY, item->valueint); nvs_config_set_u16(NVS_CONFIG_INVERT_FAN_POLARITY, item->valueint);
} }
@ -595,6 +598,7 @@ static esp_err_t GET_system_info(httpd_req_t * req)
cJSON_AddNumberToObject(root, "overheat_mode", nvs_config_get_u16(NVS_CONFIG_OVERHEAT_MODE, 0)); cJSON_AddNumberToObject(root, "overheat_mode", nvs_config_get_u16(NVS_CONFIG_OVERHEAT_MODE, 0));
cJSON_AddNumberToObject(root, "overclockEnabled", nvs_config_get_u16(NVS_CONFIG_OVERCLOCK_ENABLED, 0)); cJSON_AddNumberToObject(root, "overclockEnabled", nvs_config_get_u16(NVS_CONFIG_OVERCLOCK_ENABLED, 0));
cJSON_AddNumberToObject(root, "invertscreen", nvs_config_get_u16(NVS_CONFIG_INVERT_SCREEN, 0)); cJSON_AddNumberToObject(root, "invertscreen", nvs_config_get_u16(NVS_CONFIG_INVERT_SCREEN, 0));
cJSON_AddNumberToObject(root, "displayTimeout", nvs_config_get_u16(NVS_CONFIG_DISPLAY_TIMEOUT, 0));
cJSON_AddNumberToObject(root, "invertfanpolarity", nvs_config_get_u16(NVS_CONFIG_INVERT_FAN_POLARITY, 1)); cJSON_AddNumberToObject(root, "invertfanpolarity", nvs_config_get_u16(NVS_CONFIG_INVERT_FAN_POLARITY, 1));
cJSON_AddNumberToObject(root, "autofanspeed", nvs_config_get_u16(NVS_CONFIG_AUTO_FAN_SPEED, 1)); cJSON_AddNumberToObject(root, "autofanspeed", nvs_config_get_u16(NVS_CONFIG_AUTO_FAN_SPEED, 1));

View File

@ -23,6 +23,7 @@
#define NVS_CONFIG_BOARD_VERSION "boardversion" #define NVS_CONFIG_BOARD_VERSION "boardversion"
#define NVS_CONFIG_FLIP_SCREEN "flipscreen" #define NVS_CONFIG_FLIP_SCREEN "flipscreen"
#define NVS_CONFIG_INVERT_SCREEN "invertscreen" #define NVS_CONFIG_INVERT_SCREEN "invertscreen"
#define NVS_CONFIG_DISPLAY_TIMEOUT "displayTimeout"
#define NVS_CONFIG_INVERT_FAN_POLARITY "invertfanpol" #define NVS_CONFIG_INVERT_FAN_POLARITY "invertfanpol"
#define NVS_CONFIG_AUTO_FAN_SPEED "autofanspeed" #define NVS_CONFIG_AUTO_FAN_SPEED "autofanspeed"
#define NVS_CONFIG_FAN_SPEED "fanspeed" #define NVS_CONFIG_FAN_SPEED "fanspeed"

View File

@ -6,6 +6,8 @@
#include "esp_lvgl_port.h" #include "esp_lvgl_port.h"
#include "global_state.h" #include "global_state.h"
#include "screen.h" #include "screen.h"
#include "nvs_config.h"
#include "display.h"
// static const char * TAG = "screen"; // static const char * TAG = "screen";
@ -227,6 +229,10 @@ static lv_obj_t * create_scr_stats() {
static void screen_show(screen_t screen) static void screen_show(screen_t screen)
{ {
if (SCR_CAROUSEL_START > current_screen) {
lv_display_trigger_activity(NULL);
}
if (current_screen != screen) { if (current_screen != screen) {
lv_obj_t * scr = screens[screen]; lv_obj_t * scr = screens[screen];
@ -347,6 +353,7 @@ static void screen_update_cb(lv_timer_t * timer)
lv_label_set_text_fmt(difficulty_label, "Best: %s !!! BLOCK FOUND !!!", module->best_session_diff_string); lv_label_set_text_fmt(difficulty_label, "Best: %s !!! BLOCK FOUND !!!", module->best_session_diff_string);
screen_show(SCR_STATS); screen_show(SCR_STATS);
lv_display_trigger_activity(NULL);
} else { } else {
if (current_difficulty != module->best_session_nonce_diff) { if (current_difficulty != module->best_session_nonce_diff) {
lv_label_set_text_fmt(difficulty_label, "Best: %s/%s", module->best_session_diff_string, module->best_diff_string); lv_label_set_text_fmt(difficulty_label, "Best: %s/%s", module->best_session_diff_string, module->best_diff_string);
@ -362,6 +369,15 @@ static void screen_update_cb(lv_timer_t * timer)
current_difficulty = module->best_session_nonce_diff; current_difficulty = module->best_session_nonce_diff;
current_chip_temp = power_management->chip_temp_avg; current_chip_temp = power_management->chip_temp_avg;
const uint32_t display_inactive_time = lv_display_get_inactive_time(NULL);
const uint16_t display_timeout_config = nvs_config_get_u16(NVS_CONFIG_DISPLAY_TIMEOUT, 0) * 60 * 1000;
if ((0 != display_timeout_config) && (display_inactive_time > display_timeout_config)) {
display_off();
} else {
display_on();
}
if (CAROUSEL_DELAY_COUNT > current_screen_counter || found_block) { if (CAROUSEL_DELAY_COUNT > current_screen_counter || found_block) {
return; return;
} }

View File

@ -82,7 +82,7 @@ In the event that the admin web front end is inaccessible, for example because o
### Unlock Settings ### Unlock Settings
In order to unlock the Input fields for ASIC Mhz and ASIC Voltage you need to open up your Browser console (mostly done by pressing F12). If you submit the command `unlockSettings()` your input fields for ASIC Mhz and ASIC Voltage will be unlocked and you can place other values out of the predefined scope into them. In order to unlock the Input fields for ASIC Frequency and ASIC Core Voltage you need to append `?oc` to the end of the settings tab URL in your browser. Be aware that without additional cooling overclocking can overheat and/or damage your Bitaxe.
## Development ## Development