From 148f4542e9121812121fee96d0173ce1ffeb5ee9 Mon Sep 17 00:00:00 2001 From: mutatrum Date: Fri, 25 Oct 2024 22:31:39 +0200 Subject: [PATCH 01/23] Implement LVGL 8.4 Fixes #299 --- .vscode/settings.json | 40 ++- main/CMakeLists.txt | 5 +- main/display.c | 157 +++++++++++ main/display.h | 10 + main/fonts.c | 50 ---- main/global_state.h | 1 - main/i2c_bitaxe.c | 9 +- main/i2c_bitaxe.h | 5 +- main/idf_component.yml | 10 + main/logo.c | 68 +++++ main/lv_font_portfolio-6x8.c | 505 +++++++++++++++++++++++++++++++++++ main/oled.c | 313 ---------------------- main/oled.h | 53 ---- main/self_test/self_test.c | 44 ++- main/system.c | 217 ++++----------- sdkconfig.defaults | 22 +- 16 files changed, 890 insertions(+), 619 deletions(-) create mode 100644 main/display.c create mode 100644 main/display.h delete mode 100644 main/fonts.c create mode 100644 main/idf_component.yml create mode 100644 main/logo.c create mode 100644 main/lv_font_portfolio-6x8.c delete mode 100644 main/oled.c delete mode 100644 main/oled.h diff --git a/.vscode/settings.json b/.vscode/settings.json index 270eaebd9..314f86f11 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -16,12 +16,48 @@ "array": "c", "string": "c", "string_view": "c", - "*.tcc": "c" + "*.tcc": "c", + "esp_lvgl_port.h": "c", + "cstdint": "c", + "regex": "c", + "i2c_bitaxe.h": "c", + "i2c_master.h": "c", + "nvs_config.h": "c", + "display.h": "c", + "esp_lcd_panel_vendor.h": "c", + "esp_lcd_panel_st7789.h": "c", + "esp_lcd_panel_ssd1306.h": "c", + "esp_lcd_panel_io.h": "c", + "esp_lcd_panel_ops.h": "c", + "esp_lcd_io_i2c.h": "c", + "esp_lcd_types.h": "c", + "i2c.h": "c", + "cstdlib": "c", + "i2c_types.h": "c", + "esp_lcd_panel_dev.h": "c", + "bitset": "c", + "memory": "c", + "random": "c", + "future": "c", + "optional": "c", + "esp_lcd_panel_interface.h": "c", + "span": "c", + "oled.h": "c", + "charconv": "c", + "chrono": "c", + "format": "c", + "ratio": "c", + "system_error": "c", + "functional": "c", + "tuple": "c", + "type_traits": "c", + "utility": "c", + "compare": "c" }, "editor.formatOnSave": false, "cSpell.words": [ "ssid" ], - "idf.port": "/dev/cu.usbmodem1434301", + "idf.port": "/dev/ttyACM0", "C_Cpp.intelliSenseEngine": "Tag Parser" } diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 7d00f0be0..d56d0ee27 100755 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -3,18 +3,19 @@ SRCS "adc.c" "DS4432U.c" "EMC2101.c" - "fonts.c" "i2c_bitaxe.c" "INA260.c" "led_controller.c" "main.c" "nvs_config.c" - "oled.c" + "display.c" "system.c" "TPS546.c" "vcore.c" "work_queue.c" "nvs_device.c" + "lv_font_portfolio-6x8.c" + "logo.c" "./http_server/http_server.c" "./self_test/self_test.c" "./tasks/stratum_task.c" diff --git a/main/display.c b/main/display.c new file mode 100644 index 000000000..f9adf3eec --- /dev/null +++ b/main/display.c @@ -0,0 +1,157 @@ +#include +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "esp_timer.h" +#include "esp_lcd_panel_io.h" +#include "esp_lcd_panel_ops.h" +#include "esp_err.h" +#include "esp_log.h" +#include "lvgl.h" +#include "esp_lvgl_port.h" +#include "nvs_config.h" +#include "i2c_bitaxe.h" +#include "driver/i2c_master.h" +#include "driver/i2c_types.h" +#include "esp_lcd_panel_ssd1306.h" + +#define SSD1306_I2C_ADDRESS 0x3C + +#define LCD_H_RES 128 +#define LCD_V_RES 32 +#define LCD_CMD_BITS 8 +#define LCD_PARAM_BITS 8 + +static bool is_display_active = false; + +static const char * TAG = "display"; + +static lv_style_t style; +extern const lv_font_t lv_font_portfolio_6x8; +extern const lv_img_dsc_t logo; + +esp_err_t display_init(void) +{ + uint8_t flip_screen = nvs_config_get_u16(NVS_CONFIG_FLIP_SCREEN, 1); + uint8_t invert_screen = nvs_config_get_u16(NVS_CONFIG_INVERT_SCREEN, 0); + + i2c_master_bus_handle_t i2c_master_bus_handle; + ESP_ERROR_CHECK(i2c_bitaxe_get_master_bus_handle(&i2c_master_bus_handle)); + + ESP_LOGI(TAG, "Install panel IO"); + esp_lcd_panel_io_handle_t io_handle = NULL; + esp_lcd_panel_io_i2c_config_t io_config = { + .scl_speed_hz = I2C_BUS_SPEED_HZ, + .dev_addr = SSD1306_I2C_ADDRESS, + .control_phase_bytes = 1, + .lcd_cmd_bits = LCD_CMD_BITS, + .lcd_param_bits = LCD_PARAM_BITS, + .dc_bit_offset = 6 + }; + + ESP_ERROR_CHECK(esp_lcd_new_panel_io_i2c(i2c_master_bus_handle, &io_config, &io_handle)); + + ESP_LOGI(TAG, "Install SSD1306 panel driver"); + esp_lcd_panel_handle_t panel_handle = NULL; + esp_lcd_panel_dev_config_t panel_config = { + .bits_per_pixel = 1, + .reset_gpio_num = -1, + .color_space = ESP_LCD_COLOR_SPACE_MONOCHROME, + }; + + esp_lcd_panel_ssd1306_config_t ssd1306_config = { + .height = LCD_V_RES, + }; + panel_config.vendor_config = &ssd1306_config; + + ESP_ERROR_CHECK(esp_lcd_new_panel_ssd1306(io_handle, &panel_config, &panel_handle)); + + ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle)); + ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle)); + // ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, false, false)); + ESP_ERROR_CHECK(esp_lcd_panel_invert_color(panel_handle, invert_screen)); + + ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel_handle, true)); + + ESP_LOGI(TAG, "Initialize LVGL"); + const lvgl_port_cfg_t lvgl_cfg = ESP_LVGL_PORT_INIT_CONFIG(); + lvgl_port_init(&lvgl_cfg); + + const lvgl_port_display_cfg_t disp_cfg = { + .io_handle = io_handle, + .panel_handle = panel_handle, + .buffer_size = LCD_H_RES * LCD_V_RES, + .double_buffer = true, + .hres = LCD_H_RES, + .vres = LCD_V_RES, + .monochrome = true, + .rotation = { + .swap_xy = false, + .mirror_x = !flip_screen, // The screen is not flipped, this is for backwards compatibility + .mirror_y = !flip_screen, + }, + }; + lvgl_port_add_disp(&disp_cfg); + + lv_style_init(&style); + lv_style_set_text_font(&style, &lv_font_portfolio_6x8); + + is_display_active = true; + + return ESP_OK; +} + +bool display_active(void) +{ + return is_display_active; +} + +void display_clear() +{ + if (lvgl_port_lock(0)) { + lv_obj_t *scr = lv_scr_act(); + lv_obj_clean(scr); + lvgl_port_unlock(); + } +} + +void display_show_status(const char *messages[], size_t message_count) +{ + if (lvgl_port_lock(0)) { + lv_obj_t *scr = lv_scr_act(); + lv_obj_clean(scr); + + lv_obj_t *container = lv_obj_create(scr); + lv_obj_set_size(container, LCD_H_RES, LCD_V_RES); + lv_obj_align(container, LV_ALIGN_CENTER, 0, 0); + + lv_obj_set_flex_flow(container, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(container, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START); + + for (int i = 0; i < message_count; i++) + { + lv_obj_t *label = lv_label_create(container); + lv_label_set_text(label, messages[i]); + lv_obj_add_style(label, &style, LV_PART_MAIN); + lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR); + lv_obj_set_width(label, LCD_H_RES); + } + + lvgl_port_unlock(); + } +} + +void display_show_logo() +{ + if (lvgl_port_lock(0)) { + lv_obj_t *scr = lv_scr_act(); + lv_obj_clean(scr); + + lv_obj_t *img = lv_img_create(scr); + + lv_img_set_src(img, &logo); + + lv_obj_align(img, LV_ALIGN_CENTER, 0, 0); + + lvgl_port_unlock(); + } +} diff --git a/main/display.h b/main/display.h new file mode 100644 index 000000000..f5e3d0140 --- /dev/null +++ b/main/display.h @@ -0,0 +1,10 @@ +#ifndef DISPLAY_H_ +#define DISPLAY_H_ + +esp_err_t display_init(void); +bool display_active(void); +void display_clear(); +void display_show_status(const char *messages[], size_t message_count); +void display_show_logo(); + +#endif /* DISPLAY_H_ */ \ No newline at end of file diff --git a/main/fonts.c b/main/fonts.c deleted file mode 100644 index d16f26cc6..000000000 --- a/main/fonts.c +++ /dev/null @@ -1,50 +0,0 @@ - -// 5x7 font (in 6x8 cell) -unsigned char ucSmallFont[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x45, 0x51, 0x45, 0x3e, 0x00, 0x3e, 0x6b, 0x6f, - 0x6b, 0x3e, 0x00, 0x1c, 0x3e, 0x7c, 0x3e, 0x1c, 0x00, 0x18, 0x3c, 0x7e, 0x3c, 0x18, 0x00, 0x30, - 0x36, 0x7f, 0x36, 0x30, 0x00, 0x18, 0x5c, 0x7e, 0x5c, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0xff, 0xe7, 0xe7, 0xff, 0xff, 0x00, 0x3c, 0x24, 0x24, 0x3c, 0x00, 0x00, 0xc3, 0xdb, 0xdb, - 0xc3, 0xff, 0x00, 0x30, 0x48, 0x4a, 0x36, 0x0e, 0x00, 0x06, 0x29, 0x79, 0x29, 0x06, 0x00, 0x60, - 0x70, 0x3f, 0x02, 0x04, 0x00, 0x60, 0x7e, 0x0a, 0x35, 0x3f, 0x00, 0x2a, 0x1c, 0x36, 0x1c, 0x2a, - 0x00, 0x00, 0x7f, 0x3e, 0x1c, 0x08, 0x00, 0x08, 0x1c, 0x3e, 0x7f, 0x00, 0x00, 0x14, 0x36, 0x7f, - 0x36, 0x14, 0x00, 0x00, 0x5f, 0x00, 0x5f, 0x00, 0x00, 0x06, 0x09, 0x7f, 0x01, 0x7f, 0x00, 0x22, - 0x4d, 0x55, 0x59, 0x22, 0x00, 0x60, 0x60, 0x60, 0x60, 0x00, 0x00, 0x14, 0xb6, 0xff, 0xb6, 0x14, - 0x00, 0x04, 0x06, 0x7f, 0x06, 0x04, 0x00, 0x10, 0x30, 0x7f, 0x30, 0x10, 0x00, 0x08, 0x08, 0x3e, - 0x1c, 0x08, 0x00, 0x08, 0x1c, 0x3e, 0x08, 0x08, 0x00, 0x78, 0x40, 0x40, 0x40, 0x40, 0x00, 0x08, - 0x3e, 0x08, 0x3e, 0x08, 0x00, 0x30, 0x3c, 0x3f, 0x3c, 0x30, 0x00, 0x03, 0x0f, 0x3f, 0x0f, 0x03, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x5f, 0x06, 0x00, 0x00, 0x07, 0x03, 0x00, - 0x07, 0x03, 0x00, 0x24, 0x7e, 0x24, 0x7e, 0x24, 0x00, 0x24, 0x2b, 0x6a, 0x12, 0x00, 0x00, 0x63, - 0x13, 0x08, 0x64, 0x63, 0x00, 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, 0x00, 0x07, 0x03, 0x00, 0x00, - 0x00, 0x00, 0x3e, 0x41, 0x00, 0x00, 0x00, 0x00, 0x41, 0x3e, 0x00, 0x00, 0x00, 0x08, 0x3e, 0x1c, - 0x3e, 0x08, 0x00, 0x08, 0x08, 0x3e, 0x08, 0x08, 0x00, 0x00, 0xe0, 0x60, 0x00, 0x00, 0x00, 0x08, - 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, - 0x00, 0x3e, 0x51, 0x49, 0x45, 0x3e, 0x00, 0x00, 0x42, 0x7f, 0x40, 0x00, 0x00, 0x62, 0x51, 0x49, - 0x49, 0x46, 0x00, 0x22, 0x49, 0x49, 0x49, 0x36, 0x00, 0x18, 0x14, 0x12, 0x7f, 0x10, 0x00, 0x2f, - 0x49, 0x49, 0x49, 0x31, 0x00, 0x3c, 0x4a, 0x49, 0x49, 0x30, 0x00, 0x01, 0x71, 0x09, 0x05, 0x03, - 0x00, 0x36, 0x49, 0x49, 0x49, 0x36, 0x00, 0x06, 0x49, 0x49, 0x29, 0x1e, 0x00, 0x00, 0x6c, 0x6c, - 0x00, 0x00, 0x00, 0x00, 0xec, 0x6c, 0x00, 0x00, 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, 0x00, 0x24, - 0x24, 0x24, 0x24, 0x24, 0x00, 0x00, 0x41, 0x22, 0x14, 0x08, 0x00, 0x02, 0x01, 0x59, 0x09, 0x06, - 0x00, 0x3e, 0x41, 0x5d, 0x55, 0x1e, 0x00, 0x7e, 0x11, 0x11, 0x11, 0x7e, 0x00, 0x7f, 0x49, 0x49, - 0x49, 0x36, 0x00, 0x3e, 0x41, 0x41, 0x41, 0x22, 0x00, 0x7f, 0x41, 0x41, 0x41, 0x3e, 0x00, 0x7f, - 0x49, 0x49, 0x49, 0x41, 0x00, 0x7f, 0x09, 0x09, 0x09, 0x01, 0x00, 0x3e, 0x41, 0x49, 0x49, 0x7a, - 0x00, 0x7f, 0x08, 0x08, 0x08, 0x7f, 0x00, 0x00, 0x41, 0x7f, 0x41, 0x00, 0x00, 0x30, 0x40, 0x40, - 0x40, 0x3f, 0x00, 0x7f, 0x08, 0x14, 0x22, 0x41, 0x00, 0x7f, 0x40, 0x40, 0x40, 0x40, 0x00, 0x7f, - 0x02, 0x04, 0x02, 0x7f, 0x00, 0x7f, 0x02, 0x04, 0x08, 0x7f, 0x00, 0x3e, 0x41, 0x41, 0x41, 0x3e, - 0x00, 0x7f, 0x09, 0x09, 0x09, 0x06, 0x00, 0x3e, 0x41, 0x51, 0x21, 0x5e, 0x00, 0x7f, 0x09, 0x09, - 0x19, 0x66, 0x00, 0x26, 0x49, 0x49, 0x49, 0x32, 0x00, 0x01, 0x01, 0x7f, 0x01, 0x01, 0x00, 0x3f, - 0x40, 0x40, 0x40, 0x3f, 0x00, 0x1f, 0x20, 0x40, 0x20, 0x1f, 0x00, 0x3f, 0x40, 0x3c, 0x40, 0x3f, - 0x00, 0x63, 0x14, 0x08, 0x14, 0x63, 0x00, 0x07, 0x08, 0x70, 0x08, 0x07, 0x00, 0x71, 0x49, 0x45, - 0x43, 0x00, 0x00, 0x00, 0x7f, 0x41, 0x41, 0x00, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, - 0x41, 0x41, 0x7f, 0x00, 0x00, 0x04, 0x02, 0x01, 0x02, 0x04, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x00, 0x00, 0x03, 0x07, 0x00, 0x00, 0x00, 0x20, 0x54, 0x54, 0x54, 0x78, 0x00, 0x7f, 0x44, 0x44, - 0x44, 0x38, 0x00, 0x38, 0x44, 0x44, 0x44, 0x28, 0x00, 0x38, 0x44, 0x44, 0x44, 0x7f, 0x00, 0x38, - 0x54, 0x54, 0x54, 0x08, 0x00, 0x08, 0x7e, 0x09, 0x09, 0x00, 0x00, 0x18, 0xa4, 0xa4, 0xa4, 0x7c, - 0x00, 0x7f, 0x04, 0x04, 0x78, 0x00, 0x00, 0x00, 0x00, 0x7d, 0x40, 0x00, 0x00, 0x40, 0x80, 0x84, - 0x7d, 0x00, 0x00, 0x7f, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x40, 0x00, 0x00, 0x7c, - 0x04, 0x18, 0x04, 0x78, 0x00, 0x7c, 0x04, 0x04, 0x78, 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, - 0x00, 0xfc, 0x44, 0x44, 0x44, 0x38, 0x00, 0x38, 0x44, 0x44, 0x44, 0xfc, 0x00, 0x44, 0x78, 0x44, - 0x04, 0x08, 0x00, 0x08, 0x54, 0x54, 0x54, 0x20, 0x00, 0x04, 0x3e, 0x44, 0x24, 0x00, 0x00, 0x3c, - 0x40, 0x20, 0x7c, 0x00, 0x00, 0x1c, 0x20, 0x40, 0x20, 0x1c, 0x00, 0x3c, 0x60, 0x30, 0x60, 0x3c, - 0x00, 0x6c, 0x10, 0x10, 0x6c, 0x00, 0x00, 0x9c, 0xa0, 0x60, 0x3c, 0x00, 0x00, 0x64, 0x54, 0x54, - 0x4c, 0x00, 0x00, 0x08, 0x3e, 0x41, 0x41, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x00, - 0x41, 0x41, 0x3e, 0x08, 0x00, 0x02, 0x01, 0x02, 0x01, 0x00, 0x00, 0x3c, 0x26, 0x23, 0x26, 0x3c}; diff --git a/main/global_state.h b/main/global_state.h index 8ac051e15..4c9e922a6 100644 --- a/main/global_state.h +++ b/main/global_state.h @@ -60,7 +60,6 @@ typedef struct uint64_t shares_accepted; uint64_t shares_rejected; int screen_page; - char oled_buf[20]; uint64_t best_nonce_diff; char best_diff_string[DIFF_STRING_SIZE]; uint64_t best_session_nonce_diff; diff --git a/main/i2c_bitaxe.c b/main/i2c_bitaxe.c index 494c48bf4..6ed70f8ea 100644 --- a/main/i2c_bitaxe.c +++ b/main/i2c_bitaxe.c @@ -4,7 +4,6 @@ #define I2C_MASTER_SCL_IO 48 /*!< GPIO number used for I2C master clock */ #define I2C_MASTER_SDA_IO 47 /*!< GPIO number used for I2C master data */ -#define I2C_MASTER_FREQ_HZ 100000 /*!< I2C master clock frequency */ #define I2C_MASTER_NUM 0 /*!< I2C master i2c port number, the number of i2c peripheral interfaces available will depend on the chip */ #define I2C_MASTER_TIMEOUT_MS 1000 @@ -41,12 +40,18 @@ esp_err_t i2c_bitaxe_add_device(uint8_t device_address, i2c_master_dev_handle_t i2c_device_config_t dev_cfg = { .dev_addr_length = I2C_ADDR_BIT_LEN_7, .device_address = device_address, - .scl_speed_hz = I2C_MASTER_FREQ_HZ, + .scl_speed_hz = I2C_BUS_SPEED_HZ, }; return i2c_master_bus_add_device(i2c_bus_handle, &dev_cfg, dev_handle); } +esp_err_t i2c_bitaxe_get_master_bus_handle(i2c_master_bus_handle_t * dev_handle) +{ + *dev_handle = i2c_bus_handle; + return ESP_OK; +} + /** * @brief Read a sequence of I2C bytes * @param dev_handle The I2C device handle diff --git a/main/i2c_bitaxe.h b/main/i2c_bitaxe.h index 67521bca6..9d495c82c 100644 --- a/main/i2c_bitaxe.h +++ b/main/i2c_bitaxe.h @@ -2,11 +2,12 @@ #define I2C_MASTER_H_ #include "driver/i2c_master.h" -//#include "driver/i2c.h" + +#define I2C_BUS_SPEED_HZ 100000 /*!< I2C master clock frequency */ esp_err_t i2c_bitaxe_init(void); esp_err_t i2c_bitaxe_add_device(uint8_t device_address, i2c_master_dev_handle_t * dev_handle); - +esp_err_t i2c_bitaxe_get_master_bus_handle(i2c_master_bus_handle_t * dev_handle); esp_err_t i2c_bitaxe_register_read(i2c_master_dev_handle_t dev_handle, uint8_t reg_addr, uint8_t * read_buf, size_t len); esp_err_t i2c_bitaxe_register_write_byte(i2c_master_dev_handle_t dev_handle, uint8_t reg_addr, uint8_t data); diff --git a/main/idf_component.yml b/main/idf_component.yml new file mode 100644 index 000000000..2606f646a --- /dev/null +++ b/main/idf_component.yml @@ -0,0 +1,10 @@ +## IDF Component Manager Manifest File +dependencies: + espressif/esp_lvgl_port: "=2.4.1" + ## LVGL 9 is blocked by https://github.com/espressif/esp-idf/issues/14784 + lvgl/lvgl: + version: "^8" + public: true + ## Required IDF version + idf: + version: ">=5.2.0" diff --git a/main/logo.c b/main/logo.c new file mode 100644 index 000000000..926f96fde --- /dev/null +++ b/main/logo.c @@ -0,0 +1,68 @@ +#ifdef __has_include + #if __has_include("lvgl.h") + #ifndef LV_LVGL_H_INCLUDE_SIMPLE + #define LV_LVGL_H_INCLUDE_SIMPLE + #endif + #endif +#endif + +#if defined(LV_LVGL_H_INCLUDE_SIMPLE) + #include "lvgl.h" +#else + #include "lvgl/lvgl.h" +#endif + + +#ifndef LV_ATTRIBUTE_MEM_ALIGN +#define LV_ATTRIBUTE_MEM_ALIGN +#endif + +#ifndef LV_ATTRIBUTE_IMG_LOGO +#define LV_ATTRIBUTE_IMG_LOGO +#endif + +const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_LOGO uint8_t logo_map[] = { + 0xff, 0xff, 0xff, 0xff, /*Color of index 0*/ + 0x00, 0x00, 0x00, 0xff, /*Color of index 1*/ + + 0b00000010, 0b00000000, 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, + 0b00000111, 0b00011100, 0b00000011, 0b10000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, + 0b00001111, 0b10111111, 0b10010111, 0b11000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, + 0b00011111, 0b11111111, 0b11100011, 0b10000000, 0b10000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, + 0b00100111, 0b11111111, 0b11000001, 0b00000001, 0b10000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, + 0b01000011, 0b11000111, 0b10000000, 0b00000011, 0b10000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, + 0b01000001, 0b11000011, 0b10000010, 0b00001111, 0b11100000, 0b01000000, 0b00010000, 0b00100000, 0b00000100, 0b00000000, + 0b10000001, 0b11000011, 0b10000111, 0b00011111, 0b11000000, 0b11111000, 0b00111000, 0b01110000, 0b00001111, 0b10001000, + 0b10000001, 0b11000011, 0b10001111, 0b11000111, 0b10000001, 0b11111111, 0b00111110, 0b01111100, 0b00011111, 0b11110000, + 0b10000001, 0b11000011, 0b10001111, 0b10000111, 0b10000011, 0b11111111, 0b01111100, 0b11111000, 0b01111111, 0b11100000, + 0b10000101, 0b11000011, 0b10000111, 0b10000111, 0b10001111, 0b00111110, 0b00111100, 0b01111000, 0b11110011, 0b11100000, + 0b01001001, 0b11001011, 0b10000111, 0b10000111, 0b10001111, 0b00011110, 0b00111100, 0b01111000, 0b11110001, 0b11110000, + 0b00110001, 0b11011111, 0b00100111, 0b10000111, 0b10000011, 0b00011110, 0b00111100, 0b01111000, 0b11110001, 0b11000000, + 0b00000001, 0b11011111, 0b11100111, 0b10000111, 0b10000001, 0b00011110, 0b00111100, 0b01111000, 0b11110001, 0b10000000, + 0b00000001, 0b11111111, 0b11000111, 0b10000111, 0b10000001, 0b10011110, 0b00111110, 0b01111000, 0b11110011, 0b00000000, + 0b00000001, 0b11000111, 0b10000111, 0b10000111, 0b10000000, 0b00011110, 0b00111111, 0b11100000, 0b11110110, 0b00000000, + 0b00000011, 0b11000011, 0b10001111, 0b11001111, 0b11000000, 0b01111111, 0b00111111, 0b11110101, 0b11111100, 0b00000000, + 0b00000001, 0b11000011, 0b10000111, 0b10000111, 0b10000000, 0b11011110, 0b01011111, 0b11111000, 0b11110000, 0b00000000, + 0b00000001, 0b11000011, 0b10000111, 0b10000111, 0b10000011, 0b10011110, 0b00001111, 0b11111000, 0b11110000, 0b00000000, + 0b00000001, 0b11000011, 0b10000111, 0b10000111, 0b10001111, 0b00011110, 0b00111100, 0b11111000, 0b11110000, 0b00010000, + 0b00000001, 0b11000011, 0b10000111, 0b10000111, 0b10001111, 0b00011110, 0b00111100, 0b01111000, 0b11110000, 0b00100000, + 0b00000001, 0b11000011, 0b10000111, 0b10000111, 0b10001111, 0b00011110, 0b00111100, 0b01111000, 0b11110000, 0b01100000, + 0b00001111, 0b11000011, 0b10000111, 0b10000111, 0b10001111, 0b00011110, 0b00111100, 0b01111000, 0b11110001, 0b11100000, + 0b00111111, 0b11000011, 0b11000111, 0b10000111, 0b10001111, 0b00011110, 0b00111100, 0b01111000, 0b11110001, 0b11100000, + 0b01111111, 0b11110011, 0b11000111, 0b10000111, 0b10001111, 0b11011110, 0b00111100, 0b01111000, 0b11111101, 0b11100000, + 0b11100111, 0b11111110, 0b00000111, 0b11100111, 0b11101111, 0b11111111, 0b00111110, 0b01111100, 0b11111111, 0b10000000, + 0b10000001, 0b11111100, 0b00000111, 0b11000111, 0b11001111, 0b11111110, 0b00111100, 0b01111000, 0b11111111, 0b00000000, + 0b10000000, 0b01111000, 0b00000011, 0b10000011, 0b10010011, 0b11101110, 0b00011000, 0b00110001, 0b00111110, 0b00000000, + 0b10000000, 0b00010000, 0b00000001, 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, + 0b01100000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, +}; + +const lv_img_dsc_t logo = { + .header.cf = LV_IMG_CF_INDEXED_1BIT, + .header.always_zero = 0, + .header.reserved = 0, + .header.w = 77, + .header.h = 30, + .data_size = 308, + .data = logo_map, +}; \ No newline at end of file diff --git a/main/lv_font_portfolio-6x8.c b/main/lv_font_portfolio-6x8.c new file mode 100644 index 000000000..0571835ea --- /dev/null +++ b/main/lv_font_portfolio-6x8.c @@ -0,0 +1,505 @@ +/******************************************************************************* + * Size: 8 px + * Bpp: 1 + * Opts: --font oldschool_pc_font_pack_v2.2_linux/ttf - Mx (mixed outline+bitmap)/Mx437_Portfolio_6x8.ttf --bpp 1 --size 8 --format lvgl --range 0x20-0x7F -o portfolio_6x8 + ******************************************************************************/ + +#ifdef __has_include + #if __has_include("lvgl.h") + #ifndef LV_LVGL_H_INCLUDE_SIMPLE + #define LV_LVGL_H_INCLUDE_SIMPLE + #endif + #endif +#endif + +#ifdef LV_LVGL_H_INCLUDE_SIMPLE + #include "lvgl.h" +#else + #include "lvgl/lvgl.h" +#endif + +#ifndef PORTFOLIO_6X8 +#define PORTFOLIO_6X8 1 +#endif + +#if PORTFOLIO_6X8 + +/*----------------- + * BITMAPS + *----------------*/ + +/*Store the image of the glyphs*/ +static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = { + /* U+0020 " " */ + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + + /* U+0021 "!" */ + 0x20, 0x82, 0x8, 0x20, 0x2, 0x0, + + /* U+0022 "\"" */ + 0x51, 0x45, 0x0, 0x0, 0x0, 0x0, + + /* U+0023 "#" */ + 0x51, 0x4f, 0x94, 0xf9, 0x45, 0x0, + + /* U+0024 "$" */ + 0x21, 0xe8, 0x1c, 0xb, 0xc2, 0x0, + + /* U+0025 "%" */ + 0xc3, 0x21, 0x8, 0x42, 0x61, 0x80, + + /* U+0026 "&" */ + 0x62, 0x4a, 0x10, 0xaa, 0x46, 0x80, + + /* U+0027 "'" */ + 0x30, 0x42, 0x0, 0x0, 0x0, 0x0, + + /* U+0028 "(" */ + 0x10, 0x84, 0x10, 0x40, 0x81, 0x0, + + /* U+0029 ")" */ + 0x40, 0x81, 0x4, 0x10, 0x84, 0x0, + + /* U+002A "*" */ + 0x0, 0x8a, 0x9c, 0xa8, 0x80, 0x0, + + /* U+002B "+" */ + 0x0, 0x82, 0x3e, 0x20, 0x80, 0x0, + + /* U+002C "," */ + 0x0, 0x0, 0x0, 0x30, 0x42, 0x0, + + /* U+002D "-" */ + 0x0, 0x0, 0x3e, 0x0, 0x0, 0x0, + + /* U+002E "." */ + 0x0, 0x0, 0x0, 0x0, 0xc3, 0x0, + + /* U+002F "/" */ + 0x0, 0x21, 0x8, 0x42, 0x0, 0x0, + + /* U+0030 "0" */ + 0x72, 0x29, 0xaa, 0xca, 0x27, 0x0, + + /* U+0031 "1" */ + 0x21, 0x82, 0x8, 0x20, 0x87, 0x0, + + /* U+0032 "2" */ + 0x72, 0x20, 0x84, 0x21, 0xf, 0x80, + + /* U+0033 "3" */ + 0xf8, 0x42, 0x4, 0xa, 0x27, 0x0, + + /* U+0034 "4" */ + 0x10, 0xc5, 0x24, 0xf8, 0x41, 0x0, + + /* U+0035 "5" */ + 0xfa, 0xf, 0x2, 0xa, 0x27, 0x0, + + /* U+0036 "6" */ + 0x31, 0x8, 0x3c, 0x8a, 0x27, 0x0, + + /* U+0037 "7" */ + 0xf8, 0x21, 0x8, 0x20, 0x82, 0x0, + + /* U+0038 "8" */ + 0x72, 0x28, 0x9c, 0x8a, 0x27, 0x0, + + /* U+0039 "9" */ + 0x72, 0x28, 0x9e, 0x8, 0x46, 0x0, + + /* U+003A ":" */ + 0x0, 0xc3, 0x0, 0x30, 0xc0, 0x0, + + /* U+003B ";" */ + 0x0, 0xc3, 0x0, 0x30, 0x42, 0x0, + + /* U+003C "<" */ + 0x8, 0x42, 0x10, 0x20, 0x40, 0x80, + + /* U+003D "=" */ + 0x0, 0xf, 0x80, 0xf8, 0x0, 0x0, + + /* U+003E ">" */ + 0x81, 0x2, 0x4, 0x21, 0x8, 0x0, + + /* U+003F "?" */ + 0x72, 0x20, 0x84, 0x20, 0x2, 0x0, + + /* U+0040 "@" */ + 0x72, 0x29, 0xaa, 0x92, 0x7, 0x0, + + /* U+0041 "A" */ + 0x72, 0x28, 0xa2, 0xfa, 0x28, 0x80, + + /* U+0042 "B" */ + 0xf2, 0x28, 0xbc, 0x8a, 0x2f, 0x0, + + /* U+0043 "C" */ + 0x72, 0x28, 0x20, 0x82, 0x27, 0x0, + + /* U+0044 "D" */ + 0xe2, 0x48, 0xa2, 0x8a, 0x4e, 0x0, + + /* U+0045 "E" */ + 0xfa, 0x8, 0x3c, 0x82, 0xf, 0x80, + + /* U+0046 "F" */ + 0xfa, 0x8, 0x3c, 0x82, 0x8, 0x0, + + /* U+0047 "G" */ + 0x72, 0x28, 0x20, 0xba, 0x27, 0x80, + + /* U+0048 "H" */ + 0x8a, 0x28, 0xbe, 0x8a, 0x28, 0x80, + + /* U+0049 "I" */ + 0x70, 0x82, 0x8, 0x20, 0x87, 0x0, + + /* U+004A "J" */ + 0x38, 0x41, 0x4, 0x12, 0x46, 0x0, + + /* U+004B "K" */ + 0x8a, 0x4a, 0x30, 0xa2, 0x48, 0x80, + + /* U+004C "L" */ + 0x82, 0x8, 0x20, 0x82, 0xf, 0x80, + + /* U+004D "M" */ + 0x8b, 0x6a, 0xaa, 0x8a, 0x28, 0x80, + + /* U+004E "N" */ + 0x8a, 0x2c, 0xaa, 0x9a, 0x28, 0x80, + + /* U+004F "O" */ + 0x72, 0x28, 0xa2, 0x8a, 0x27, 0x0, + + /* U+0050 "P" */ + 0xf2, 0x28, 0xbc, 0x82, 0x8, 0x0, + + /* U+0051 "Q" */ + 0x72, 0x28, 0xa2, 0xaa, 0x46, 0x80, + + /* U+0052 "R" */ + 0xf2, 0x28, 0xbc, 0xa2, 0x48, 0x80, + + /* U+0053 "S" */ + 0x72, 0x28, 0x1c, 0xa, 0x27, 0x0, + + /* U+0054 "T" */ + 0xf8, 0x82, 0x8, 0x20, 0x82, 0x0, + + /* U+0055 "U" */ + 0x8a, 0x28, 0xa2, 0x8a, 0x27, 0x0, + + /* U+0056 "V" */ + 0x8a, 0x28, 0xa2, 0x89, 0x42, 0x0, + + /* U+0057 "W" */ + 0x8a, 0x28, 0xaa, 0xab, 0x68, 0x80, + + /* U+0058 "X" */ + 0x8a, 0x25, 0x8, 0x52, 0x28, 0x80, + + /* U+0059 "Y" */ + 0x8a, 0x28, 0x9c, 0x20, 0x82, 0x0, + + /* U+005A "Z" */ + 0xf8, 0x21, 0x8, 0x42, 0xf, 0x80, + + /* U+005B "[" */ + 0x71, 0x4, 0x10, 0x41, 0x7, 0x0, + + /* U+005C "\\" */ + 0x2, 0x4, 0x8, 0x10, 0x20, 0x0, + + /* U+005D "]" */ + 0x70, 0x41, 0x4, 0x10, 0x47, 0x0, + + /* U+005E "^" */ + 0x21, 0x48, 0x80, 0x0, 0x0, 0x0, + + /* U+005F "_" */ + 0x0, 0x0, 0x0, 0x0, 0x0, 0x3f, + + /* U+0060 "`" */ + 0x61, 0x2, 0x0, 0x0, 0x0, 0x0, + + /* U+0061 "a" */ + 0x0, 0x7, 0x2, 0x7a, 0x27, 0x80, + + /* U+0062 "b" */ + 0x82, 0xb, 0x32, 0x8a, 0x2f, 0x0, + + /* U+0063 "c" */ + 0x0, 0x7, 0x20, 0x82, 0x27, 0x0, + + /* U+0064 "d" */ + 0x8, 0x26, 0xa6, 0x8a, 0x27, 0x80, + + /* U+0065 "e" */ + 0x0, 0x7, 0x22, 0xfa, 0x7, 0x80, + + /* U+0066 "f" */ + 0x31, 0x24, 0x3c, 0x41, 0x4, 0x0, + + /* U+0067 "g" */ + 0x0, 0x7, 0xa2, 0x78, 0x27, 0x0, + + /* U+0068 "h" */ + 0x82, 0xb, 0x32, 0x8a, 0x28, 0x80, + + /* U+0069 "i" */ + 0x20, 0x6, 0x8, 0x20, 0x87, 0x0, + + /* U+006A "j" */ + 0x10, 0x3, 0x4, 0x12, 0x46, 0x0, + + /* U+006B "k" */ + 0x82, 0x8, 0xa4, 0xa3, 0x48, 0x80, + + /* U+006C "l" */ + 0x60, 0x82, 0x8, 0x20, 0x87, 0x0, + + /* U+006D "m" */ + 0x0, 0xd, 0x2a, 0xaa, 0x28, 0x80, + + /* U+006E "n" */ + 0x0, 0xb, 0x32, 0x8a, 0x28, 0x80, + + /* U+006F "o" */ + 0x0, 0x7, 0x22, 0x8a, 0x27, 0x0, + + /* U+0070 "p" */ + 0x0, 0xf, 0x22, 0xf2, 0x8, 0x0, + + /* U+0071 "q" */ + 0x0, 0x7, 0xa2, 0x78, 0x20, 0x80, + + /* U+0072 "r" */ + 0x0, 0xb, 0x32, 0x82, 0x8, 0x0, + + /* U+0073 "s" */ + 0x0, 0x7, 0xa0, 0x70, 0x2f, 0x0, + + /* U+0074 "t" */ + 0x41, 0xf, 0x10, 0x41, 0x23, 0x0, + + /* U+0075 "u" */ + 0x0, 0x8, 0xa2, 0x8a, 0x66, 0x80, + + /* U+0076 "v" */ + 0x0, 0x8, 0xa2, 0x89, 0x42, 0x0, + + /* U+0077 "w" */ + 0x0, 0x8, 0xa2, 0xaa, 0xa5, 0x0, + + /* U+0078 "x" */ + 0x0, 0x8, 0x94, 0x21, 0x48, 0x80, + + /* U+0079 "y" */ + 0x0, 0x8, 0xa2, 0x78, 0x2f, 0x0, + + /* U+007A "z" */ + 0x0, 0xf, 0x84, 0x21, 0xf, 0x80, + + /* U+007B "{" */ + 0x18, 0x82, 0x18, 0x20, 0x81, 0x80, + + /* U+007C "|" */ + 0x20, 0x82, 0x0, 0x20, 0x82, 0x0, + + /* U+007D "}" */ + 0xc0, 0x82, 0xc, 0x20, 0x8c, 0x0, + + /* U+007E "~" */ + 0x6a, 0xc0, 0x0, 0x0, 0x0, 0x0, + + /* U+007F "" */ + 0x0, 0x2, 0x14, 0x8b, 0xe0, 0x0 +}; + + +/*--------------------- + * GLYPH DESCRIPTION + *--------------------*/ + +static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = { + {.bitmap_index = 0, .adv_w = 0, .box_w = 0, .box_h = 0, .ofs_x = 0, .ofs_y = 0} /* id = 0 reserved */, + {.bitmap_index = 0, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 6, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 12, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 18, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 24, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 30, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 36, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 42, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 48, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 54, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 60, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 66, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 72, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 78, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 84, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 90, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 96, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 102, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 108, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 114, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 120, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 126, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 132, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 138, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 144, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 150, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 156, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 162, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 168, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 174, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 180, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 186, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 192, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 198, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 204, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 210, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 216, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 222, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 228, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 234, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 240, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 246, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 252, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 258, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 264, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 270, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 276, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 282, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 288, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 294, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 300, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 306, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 312, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 318, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 324, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 330, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 336, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 342, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 348, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 354, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 360, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 366, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 372, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 378, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 384, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 390, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 396, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 402, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 408, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 414, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 420, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 426, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 432, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 438, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 444, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 450, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 456, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 462, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 468, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 474, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 480, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 486, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 492, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 498, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 504, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 510, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 516, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 522, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 528, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 534, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 540, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 546, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 552, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 558, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 564, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 570, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1} +}; + +/*--------------------- + * CHARACTER MAPPING + *--------------------*/ + + + +/*Collect the unicode lists and glyph_id offsets*/ +static const lv_font_fmt_txt_cmap_t cmaps[] = +{ + { + .range_start = 32, .range_length = 96, .glyph_id_start = 1, + .unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY + } +}; + + + +/*-------------------- + * ALL CUSTOM DATA + *--------------------*/ + +#if LVGL_VERSION_MAJOR == 8 +/*Store all the custom data of the font*/ +static lv_font_fmt_txt_glyph_cache_t cache; +#endif + +#if LVGL_VERSION_MAJOR >= 8 +static const lv_font_fmt_txt_dsc_t font_dsc = { +#else +static lv_font_fmt_txt_dsc_t font_dsc = { +#endif + .glyph_bitmap = glyph_bitmap, + .glyph_dsc = glyph_dsc, + .cmaps = cmaps, + .kern_dsc = NULL, + .kern_scale = 0, + .cmap_num = 1, + .bpp = 1, + .kern_classes = 0, + .bitmap_format = 0, +#if LVGL_VERSION_MAJOR == 8 + .cache = &cache +#endif +}; + + + +/*----------------- + * PUBLIC FONT + *----------------*/ + +/*Initialize a public general font descriptor*/ +#if LVGL_VERSION_MAJOR >= 8 +const lv_font_t lv_font_portfolio_6x8 = { +#else +lv_font_t lv_font_portfolio_6x8 = { +#endif + .get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt, /*Function pointer to get glyph's data*/ + .get_glyph_bitmap = lv_font_get_bitmap_fmt_txt, /*Function pointer to get glyph's bitmap*/ + .line_height = 8, /*The maximum line height required by the font*/ + .base_line = 1, /*Baseline measured from the bottom of the line*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 + .underline_position = 0, + .underline_thickness = 1, +#endif + .dsc = &font_dsc, /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ +#if LV_VERSION_CHECK(8, 2, 0) || LVGL_VERSION_MAJOR >= 9 + .fallback = NULL, +#endif + .user_data = NULL, +}; + + + +#endif /*#if PORTFOLIO_6X8*/ + diff --git a/main/oled.c b/main/oled.c deleted file mode 100644 index 801abda9f..000000000 --- a/main/oled.c +++ /dev/null @@ -1,313 +0,0 @@ -// OLED SSD1306 using the I2C interface -// Written by Larry Bank (bitbank@pobox.com) -// Project started 1/15/2017 -// -// The I2C writes (through a file handle) can be single or multiple bytes. -// The write mode stays in effect throughout each call to write() -// To write commands to the OLED controller, start a byte sequence with 0x00, -// to write data, start a byte sequence with 0x40, -// The OLED controller is set to "page mode". This divides the display -// into 8 128x8 "pages" or strips. Each data write advances the output -// automatically to the next address. The bytes are arranged such that the LSB -// is the topmost pixel and the MSB is the bottom. -// The font data comes from another source and must be rotated 90 degrees -// (at init time) to match the orientation of the bits on the display memory. -// A copy of the display memory is maintained by this code so that single pixel -// writes can occur without having to read from the display controller. - -#include -#include -#include -#include "esp_err.h" -#include "esp_log.h" - -#include "nvs_config.h" -#include "i2c_bitaxe.h" -#include "oled.h" - -#define OLED_I2C_ADDR 0x3C - -extern unsigned char ucSmallFont[]; -static int iScreenOffset; // current write offset of screen data -static unsigned char ucScreen[1024]; // local copy of the image buffer -static int oled_type, oled_flip; - -static void write_command(unsigned char); -static esp_err_t write(uint8_t *, uint8_t); - -static bool oled_active; - -static i2c_master_dev_handle_t ssd1306_dev_handle; - -// Initialialize the OLED Screen -esp_err_t OLED_init(void) -{ - - //init the I2C device - if (i2c_bitaxe_add_device(OLED_I2C_ADDR, &ssd1306_dev_handle) != ESP_OK) { - return ESP_FAIL; - } - - uint8_t oled32_initbuf[] = {0x00, - 0xae, // cmd: display off - 0xd5, // cmd: set display clock - 0x80, - 0xa8, // cmd: set multiplex ratio - 0x1f, // HEIGHT - 1 -> 31 - 0xd3, // cmd: set display offset - 0x00, - 0x40, // cmd: Set Display Start Line - 0x8d, - 0x14, // cmd: Set Higher Column Start Address for Page Addressing Mode - 0xa1, - 0xc8, // cmd: Set COM Output Scan Direction C0/C8 - 0xda, // cmd: Set COM Pins Hardware Configuration - 0x02, // - 0x81, // cmd: Set Contrast control - 0x7f, - 0xd9, // cmd: Set Pre-Charge Period - 0xf1, - 0xdb, // comd: Vcom regulator output - 0x40, - 0xa4, // cmd: display on ram contents - 0xa6, // cmd: set normal - 0xaf}; // cmd: display on - uint8_t uc[4]; - - uint8_t bFlip = nvs_config_get_u16(NVS_CONFIG_FLIP_SCREEN, 1); - uint8_t bInvert = nvs_config_get_u16(NVS_CONFIG_INVERT_SCREEN, 0); - oled_active = false; - - // //enable the module - // GPIO_write(Board_OLED_DISP_ENABLE, 0); - // DELAY_MS(50); - // GPIO_write(Board_OLED_DISP_ENABLE, 1); - // DELAY_MS(50); - - oled_type = OLED_128x32; - oled_flip = bFlip; - - // /* Call driver init functions */ - // I2C_init(); - - // /* Create I2C for usage */ - // I2C_Params_init(&oled_i2cParams); - // oled_i2cParams.bitRate = I2C_100kHz; - // oled_i2c = I2C_open(Board_I2C_SSD1306, &oled_i2cParams); - - // if (oled_i2c == NULL) { - // return false; - // } - oled_active = true; - - write(oled32_initbuf, sizeof(oled32_initbuf)); - - if (bInvert) { - uc[0] = 0; // command - uc[1] = 0xa7; // invert command - write(uc, 2); - } - - if (bFlip) { // rotate display 180 - uc[0] = 0; // command - uc[1] = 0xa0; - write(uc, 2); - uc[1] = 0xc0; - write(uc, 2); - } - return true; -} - -// Sends a command to turn off the OLED display -// Closes the I2C file handle -void OLED_shutdown() -{ - - write_command(0xaE); // turn off OLED - // I2C_close(oled_i2c); - // GPIO_write(Board_OLED_DISP_ENABLE, 0); //turn off power - oled_active = false; -} - -// Send a single byte command to the OLED controller -static void write_command(uint8_t c) -{ - uint8_t buf[2]; - - buf[0] = 0x00; // command introducer - buf[1] = c; - write(buf, 2); -} - -static void oledWriteCommand2(uint8_t c, uint8_t d) -{ - uint8_t buf[3]; - - buf[0] = 0x00; - buf[1] = c; - buf[2] = d; - write(buf, 3); -} - -bool OLED_setContrast(uint8_t ucContrast) -{ - - oledWriteCommand2(0x81, ucContrast); - return true; -} - -// Send commands to position the "cursor" to the given -// row and column -static void oledSetPosition(int x, int y) -{ - iScreenOffset = (y * 128) + x; - if (oled_type == OLED_64x32) // visible display starts at column 32, row 4 - { - x += 32; // display is centered in VRAM, so this is always true - if (oled_flip == 0) // non-flipped display starts from line 4 - y += 4; - } else if (oled_type == OLED_132x64) // SH1106 has 128 pixels centered in 132 - { - x += 2; - } - - write_command(0xb0 | y); // go to page Y - write_command(0x00 | (x & 0x0f)); // lower col addr - write_command(0x10 | ((x >> 4) & 0x0f));// upper col addr -} - -// Write a block of pixel data to the OLED -// Length can be anything from 1 to 1024 (whole display) -static void oledWriteDataBlock(const uint8_t * ucBuf, int iLen) -{ - uint8_t ucTemp[129]; - - ucTemp[0] = 0x40; // data command - memcpy(&ucTemp[1], ucBuf, iLen); - write(ucTemp, iLen + 1); - // Keep a copy in local buffer - memcpy(&ucScreen[iScreenOffset], ucBuf, iLen); - iScreenOffset += iLen; -} - -// Set (or clear) an individual pixel -// The local copy of the frame buffer is used to avoid -// reading data from the display controller -int OLED_setPixel(int x, int y, uint8_t ucColor) -{ - int i; - uint8_t uc, ucOld; - - // if (oled_i2c == NULL) - // return -1; - - i = ((y >> 3) * 128) + x; - if (i < 0 || i > 1023) // off the screen - return -1; - uc = ucOld = ucScreen[i]; - uc &= ~(0x1 << (y & 7)); - if (ucColor) { - uc |= (0x1 << (y & 7)); - } - if (uc != ucOld) // pixel changed - { - oledSetPosition(x, y >> 3); - oledWriteDataBlock(&uc, 1); - } - return 0; -} - -// Write a bitmap to the screen -// The X position is in character widths (8 or 16) -// The Y position is in memory pages (8 lines each) -// Bitmap should be aligned vertical, 1 bit per pixel -// Width and Height must be per 8 pixels -// Conversion tool: https://javl.github.io/image2cpp/ -int OLED_showBitmap(int x, int y, const uint8_t *bitmap, int width, int height) -{ - for (int row = 0; row < (height >> 3); row++) { - oledSetPosition(x, y + row); - oledWriteDataBlock(&bitmap[row * width], width); - } - - return 0; -} - -// -// Draw a string of small (8x8), large (16x24), or very small (6x8) characters -// At the given col+row -// The X position is in character widths (8 or 16) -// The Y position is in memory pages (8 lines each) -// -int OLED_writeString(int x, int y, const char * szMsg) -{ - int i, iLen; - uint8_t * s; - - // if (oled_i2c == NULL) return -1; // not initialized - - iLen = strlen(szMsg); - - oledSetPosition(x * 6, y); - if (iLen + x > 21) - iLen = 21 - x; - if (iLen < 0) - return -1; - for (i = 0; i < iLen; i++) { - s = &ucSmallFont[(unsigned char) szMsg[i] * 6]; - oledWriteDataBlock(s, 6); - } - - return 0; -} - -// Fill the frame buffer with a byte pattern -// e.g. all off (0x00) or all on (0xff) -int OLED_fill(uint8_t ucData) -{ - int y; - uint8_t temp[128]; - int iLines, iCols; - - // if (oled_i2c == NULL) return -1; // not initialized - - iLines = (oled_type == OLED_128x32 || oled_type == OLED_64x32) ? 4 : 8; - iCols = (oled_type == OLED_64x32) ? 4 : 8; - - memset(temp, ucData, 128); - for (y = 0; y < iLines; y++) { - oledSetPosition(0, y); // set to (0,Y) - oledWriteDataBlock(temp, iCols * 16); // fill with data byte - } // for y - return 0; -} - -int OLED_clearLine(uint8_t line) -{ - uint8_t temp[128]; - - // if (oled_i2c == NULL) return -1; // not initialized - if (line > 4) - return -1; // line number too big - - memset(temp, 0, 128); - oledSetPosition(0, line); // set to (0,Y) - oledWriteDataBlock(temp, 128); // fill with data byte - - return 0; -} - -bool OLED_status(void) -{ - return oled_active; -} - -/** - * @brief Write a byte to a I2C register - */ -static esp_err_t write(uint8_t * data, uint8_t len) -{ - //return i2c_master_write_to_device(I2C_MASTER_NUM, 0x3C, data, len, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); - - return i2c_bitaxe_register_write_bytes(ssd1306_dev_handle, data, len); -} diff --git a/main/oled.h b/main/oled.h deleted file mode 100644 index ba3d82c24..000000000 --- a/main/oled.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef OLED96_H -#define OLED96_H -// -// OLED96 -// Library for accessing the 0.96" SSD1306 128x64 OLED display -// Written by Larry Bank (bitbank@pobox.com) -// Copyright (c) 2017 BitBank Software, Inc. -// Project started 1/15/2017 -// -// OLED type for init function -enum -{ - OLED_128x32 = 1, - OLED_128x64, - OLED_132x64, - OLED_64x32 -}; - -typedef enum -{ - FONT_NORMAL = 0, // 8x8 - FONT_BIG, // 16x24 - FONT_SMALL // 6x8 -} FONTSIZE; - -// Initialize the OLED96 library for a specific I2C address -// Optionally enable inverted or flipped mode -// returns 0 for success, 1 for failure -// -esp_err_t OLED_init(void); - -// Turns off the display and closes the I2C handle -void OLED_shutdown(void); - -// Fills the display with the byte pattern -int OLED_fill(uint8_t ucPattern); - -// Write a text string to the display at x (column 0-127) and y (row 0-7) -// bLarge = 0 - 8x8 font, bLarge = 1 - 16x24 font -int OLED_writeString(int x, int y, const char *szText); - -// Sets a pixel to On (1) or Off (0) -// Coordinate system is pixels, not text rows (0-127, 0-63) -int OLED_setPixel(int x, int y, uint8_t ucPixel); -int OLED_showBitmap(int x, int y, const uint8_t *bitmap, int width, int height); - -// Sets the contrast (brightness) level of the display -// Valid values are 0-255 where 0=off and 255=max brightness -bool OLED_setContrast(uint8_t ucContrast); -int OLED_clearLine(uint8_t); -bool OLED_status(void); - -#endif // OLED96_H diff --git a/main/self_test/self_test.c b/main/self_test/self_test.c index 9eb92de3a..a3130cb52 100644 --- a/main/self_test/self_test.c +++ b/main/self_test/self_test.c @@ -7,7 +7,7 @@ #include "global_state.h" #include "nvs_config.h" #include "nvs_flash.h" -#include "oled.h" +#include "display.h" #include "vcore.h" #include "utils.h" #include "string.h" @@ -20,6 +20,7 @@ #define POWER_CONSUMPTION_MARGIN 3 //+/- watts static const char * TAG = "self_test"; +const char *messages[] = {"", "", "", ""}; bool should_test(GlobalState * GLOBAL_STATE) { bool is_max = GLOBAL_STATE->asic_model == ASIC_BM1397; @@ -32,17 +33,14 @@ bool should_test(GlobalState * GLOBAL_STATE) { } static void display_msg(char * msg, GlobalState * GLOBAL_STATE) { - SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; - switch (GLOBAL_STATE->device_model) { case DEVICE_MAX: case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - if (OLED_status()) { - memset(module->oled_buf, 0, 20); - snprintf(module->oled_buf, 20, msg); - OLED_writeString(0, 2, module->oled_buf); + if (display_active()) { + messages[2] = msg; + display_show_status(messages, 4); } break; default: @@ -50,17 +48,15 @@ static void display_msg(char * msg, GlobalState * GLOBAL_STATE) { } static void display_end_screen(GlobalState * GLOBAL_STATE) { - switch (GLOBAL_STATE->device_model) { case DEVICE_MAX: case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - if (OLED_status()) { - OLED_clearLine(2); - OLED_writeString(0, 2, "TESTS PASS!"); - OLED_clearLine(3); - OLED_writeString(0, 3, " PRESS RESET"); + if (display_active()) { + messages[2] = "TESTS PASS!"; + messages[3] = " PRESS RESET"; + display_show_status(messages, 4); } break; default: @@ -131,13 +127,12 @@ void self_test(void * pvParameters) case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - if (!OLED_init()) { + if (!display_init()) { ESP_LOGE(TAG, "OLED init failed!"); } else { ESP_LOGI(TAG, "OLED init success!"); - // clear the oled screen - OLED_fill(0); - OLED_writeString(0, 0, "BITAXE SELF TESTING"); + messages[0] = "BITAXE SELF TESTING"; + display_show_status(messages, 4); } break; default: @@ -387,10 +382,10 @@ void self_test(void * pvParameters) case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - if (OLED_status()) { - OLED_clearLine(3); - OLED_writeString(0, 3, " PRESS RESET"); - } + if (display_active()) { + messages[3] = " PRESS RESET"; + display_show_status(messages, 4); + } break; default: } @@ -400,9 +395,10 @@ void self_test(void * pvParameters) case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - if (OLED_status()) { - OLED_clearLine(3); - } + if (display_active()) { + messages[3] = ""; + display_show_status(messages, 4); + } break; default: } diff --git a/main/system.c b/main/system.c index b26b638df..2e28eeeca 100644 --- a/main/system.c +++ b/main/system.c @@ -26,7 +26,7 @@ #include "connect.h" #include "led_controller.h" #include "nvs_config.h" -#include "oled.h" +#include "display.h" #include "vcore.h" @@ -41,8 +41,6 @@ QueueHandle_t user_input_queue; //local function prototypes static esp_err_t ensure_overheat_mode_config(); static void _show_overheat_screen(GlobalState * GLOBAL_STATE); -static void _clear_display(GlobalState * GLOBAL_STATE); -static void _init_connection(GlobalState * GLOBAL_STATE); static void _update_connection(GlobalState * GLOBAL_STATE); static void _update_screen_one(GlobalState * GLOBAL_STATE); static void _update_screen_two(GlobalState * GLOBAL_STATE); @@ -145,12 +143,11 @@ void SYSTEM_init_peripherals(GlobalState * GLOBAL_STATE) { case DEVICE_SUPRA: case DEVICE_GAMMA: // oled - if (!OLED_init()) { - ESP_LOGI(TAG, "OLED init failed!"); + if (display_init() != ESP_OK) { + ESP_LOGW(TAG, "OLED init failed!"); } else { ESP_LOGI(TAG, "OLED init success!"); - // clear the oled screen - OLED_fill(0); + display_clear(); } break; default: @@ -159,46 +156,8 @@ void SYSTEM_init_peripherals(GlobalState * GLOBAL_STATE) { netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF"); user_input_queue = xQueueCreate(10, sizeof(char[10])); // Create a queue to handle user input events - - _clear_display(GLOBAL_STATE); - _init_connection(GLOBAL_STATE); } -static const uint8_t bitaxe_splash[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x10, 0x18, 0x3c, - 0x7e, 0xfc, 0xf8, 0xf0, 0x38, 0x3c, 0x3c, 0x7c, 0xf8, 0xf8, 0xf8, 0x30, 0x10, 0x08, 0x00, 0x08, - 0x9c, 0x3e, 0x1c, 0x08, 0x00, 0x00, 0x80, 0x80, 0xc0, 0xe0, 0xf0, 0x80, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x10, 0x20, 0x20, 0x10, 0x08, - 0x00, 0xff, 0xff, 0xff, 0x80, 0xe0, 0xf0, 0xe0, 0xff, 0xff, 0xdf, 0xc0, 0x60, 0x00, 0x06, 0xff, - 0xff, 0xff, 0xfe, 0x02, 0x00, 0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x18, 0x18, - 0x3c, 0xfe, 0x87, 0x07, 0x0f, 0xff, 0xff, 0xfe, 0xfe, 0x06, 0x00, 0x04, 0xff, 0xff, 0xff, 0xfe, - 0x82, 0x00, 0x04, 0xff, 0xff, 0xff, 0xfe, 0x02, 0x00, 0x00, 0xf8, 0xfc, 0xfc, 0xfe, 0x07, 0x07, - 0x8f, 0xff, 0x7f, 0x3e, 0x1e, 0x12, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, - 0x82, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x02, 0xff, - 0xff, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02, 0xff, 0xff, 0xff, 0xff, 0x02, 0x00, 0x00, 0xf0, 0xf0, - 0xf8, 0xf8, 0x0c, 0x06, 0x02, 0xff, 0xff, 0xff, 0xff, 0x02, 0x00, 0x04, 0xf3, 0xf7, 0xff, 0xff, - 0x0f, 0x0f, 0x1f, 0xff, 0xff, 0xfe, 0xfc, 0x02, 0x00, 0x02, 0xff, 0xff, 0xff, 0xff, 0x02, 0x03, - 0x01, 0x80, 0x80, 0xc0, 0xe0, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x46, 0x47, 0x03, 0x03, 0x07, - 0x07, 0x0f, 0x0f, 0x1f, 0x1e, 0x3e, 0x1c, 0x0c, 0x07, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x0f, - 0x1f, 0x3f, 0x1f, 0x0c, 0x04, 0x00, 0x00, 0x0f, 0x1f, 0x3f, 0x1f, 0x0c, 0x04, 0x10, 0x0f, 0x0f, - 0x1f, 0x1f, 0x1e, 0x1e, 0x1c, 0x0f, 0x1f, 0x1f, 0x1f, 0x04, 0x00, 0x00, 0x0f, 0x1f, 0x1f, 0x0f, - 0x04, 0x00, 0x00, 0x0f, 0x1f, 0x1f, 0x0f, 0x04, 0x00, 0x10, 0x0f, 0x0f, 0x1f, 0x1f, 0x1e, 0x1e, - 0x1c, 0x0f, 0x07, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - void SYSTEM_task(void * pvParameters) { GlobalState * GLOBAL_STATE = (GlobalState *) pvParameters; @@ -220,9 +179,9 @@ void SYSTEM_task(void * pvParameters) vTaskDelay(1000 / portTICK_PERIOD_MS); } - OLED_showBitmap(0, 0, bitaxe_splash, 128, 32); + display_show_logo(); vTaskDelay(5000 / portTICK_PERIOD_MS); - + int current_screen = 0; TickType_t last_update_time = xTaskGetTickCount(); @@ -236,7 +195,6 @@ void SYSTEM_task(void * pvParameters) } // Update the current screen - _clear_display(GLOBAL_STATE); module->screen_page = current_screen; switch (current_screen) { @@ -272,8 +230,6 @@ void SYSTEM_task(void * pvParameters) } last_update_time = xTaskGetTickCount(); - - } } @@ -375,7 +331,6 @@ void SYSTEM_notify_found_nonce(GlobalState * GLOBAL_STATE, double found_diff, ui /// static void _show_overheat_screen(GlobalState * GLOBAL_STATE) { - SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; esp_netif_ip_info_t ip_info; switch (GLOBAL_STATE->device_model) { @@ -383,20 +338,16 @@ static void _show_overheat_screen(GlobalState * GLOBAL_STATE) case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - if (OLED_status()) { - OLED_clearLine(0); - OLED_writeString(0, 0, "DEVICE OVERHEAT!"); - OLED_clearLine(1); - OLED_writeString(0, 1, "See AxeOS settings"); - OLED_clearLine(2); - OLED_clearLine(3); + if (display_active()) { esp_netif_get_ip_info(netif, &ip_info); char ip_address_str[IP4ADDR_STRLEN_MAX]; esp_ip4addr_ntoa(&ip_info.ip, ip_address_str, IP4ADDR_STRLEN_MAX); - - memset(module->oled_buf, 0, 20); - snprintf(module->oled_buf, 20, "IP: %s", ip_address_str); - OLED_writeString(0, 3, module->oled_buf); + display_show_status((const char *[]){ + "DEVICE OVERHEAT!", + "See AxeOS settings", + "IP:", + ip_address_str + }, 4); } break; default: @@ -405,40 +356,6 @@ static void _show_overheat_screen(GlobalState * GLOBAL_STATE) } static void _update_screen_one(GlobalState * GLOBAL_STATE) -{ - SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; - PowerManagementModule * power_management = &GLOBAL_STATE->POWER_MANAGEMENT_MODULE; - switch (GLOBAL_STATE->device_model) { - case DEVICE_MAX: - case DEVICE_ULTRA: - case DEVICE_SUPRA: - case DEVICE_GAMMA: - if (OLED_status()) { - float efficiency = GLOBAL_STATE->POWER_MANAGEMENT_MODULE.power / (module->current_hashrate / 1000.0); - - memset(module->oled_buf, 0, 20); - snprintf(module->oled_buf, 20, "Gh/s: %.2f", module->current_hashrate); - OLED_writeString(0, 0, module->oled_buf); - - memset(module->oled_buf, 0, 20); - snprintf(module->oled_buf, 20, "J/Th: %.2f", efficiency); - OLED_writeString(0, 1, module->oled_buf); - - memset(module->oled_buf, 0, 20); - snprintf(module->oled_buf, 20, module->FOUND_BLOCK ? "!!! BLOCK FOUND !!!" : "Best: %s", module->best_diff_string); - OLED_writeString(0, 2, module->oled_buf); - - memset(module->oled_buf, 0, 20); - snprintf(module->oled_buf, 20, "Temp: %.1f C", power_management->chip_temp_avg); - OLED_writeString(0, 3, module->oled_buf); - } - break; - default: - break; - } -} - -static void _update_screen_two(GlobalState * GLOBAL_STATE) { SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; esp_netif_ip_info_t ip_info; @@ -448,34 +365,16 @@ static void _update_screen_two(GlobalState * GLOBAL_STATE) case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - if (OLED_status()) { - // Pool URL - OLED_writeString(0, 0, "Mining URL:"); - memset(module->oled_buf, 0, 20); - if (module->is_using_fallback) { - snprintf(module->oled_buf, 20, "%.19s", module->fallback_pool_url); - } else { - snprintf(module->oled_buf, 20, "%.19s", module->pool_url); - } - OLED_writeString(0, 1, module->oled_buf); - // // Second line of pool URL - // memset(module->oled_buf, 0, 20); - // if (module->is_using_fallback) { - // snprintf(module->oled_buf, 20, "%.19s", module->fallback_pool_url + 13); - // } else { - // snprintf(module->oled_buf, 20, "%.19s", module->pool_url + 13); - // } - // OLED_writeString(0, 1, module->oled_buf); - - // IP Address - OLED_writeString(0, 2, "Bitaxe IP:"); + if (display_active()) { esp_netif_get_ip_info(netif, &ip_info); char ip_address_str[IP4ADDR_STRLEN_MAX]; esp_ip4addr_ntoa(&ip_info.ip, ip_address_str, IP4ADDR_STRLEN_MAX); - - memset(module->oled_buf, 0, 20); - snprintf(module->oled_buf, 20, "%s", ip_address_str); - OLED_writeString(0, 3, module->oled_buf); + display_show_status((const char *[]){ + "Mining URL:", + module->is_using_fallback ? module->fallback_pool_url : module->pool_url, + "Bitaxe IP:", + ip_address_str + }, 4); } break; default: @@ -483,38 +382,39 @@ static void _update_screen_two(GlobalState * GLOBAL_STATE) } } -static void _clear_display(GlobalState * GLOBAL_STATE) +static void _update_screen_two(GlobalState * GLOBAL_STATE) { + SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; + PowerManagementModule * power_management = &GLOBAL_STATE->POWER_MANAGEMENT_MODULE; switch (GLOBAL_STATE->device_model) { case DEVICE_MAX: case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - OLED_clearLine(0); - OLED_clearLine(1); - OLED_clearLine(2); - OLED_clearLine(3); - break; - default: - } -} + if (display_active()) { + char label_hashrate[20]; + snprintf(label_hashrate, 20, "Gh/s: %.2f", module->current_hashrate); -static void _init_connection(GlobalState * GLOBAL_STATE) -{ - SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; + char label_efficiency[20]; + float efficiency = GLOBAL_STATE->POWER_MANAGEMENT_MODULE.power / (module->current_hashrate / 1000.0); + snprintf(label_efficiency, 20, "J/Th: %.2f", efficiency); - switch (GLOBAL_STATE->device_model) { - case DEVICE_MAX: - case DEVICE_ULTRA: - case DEVICE_SUPRA: - case DEVICE_GAMMA: - if (OLED_status()) { - memset(module->oled_buf, 0, 20); - snprintf(module->oled_buf, 20, "Connecting to SSID:"); - OLED_writeString(0, 0, module->oled_buf); + char label_best[20]; + snprintf(label_best, 27, "Best: %s/%s", module->best_session_diff_string, module->best_diff_string); + + char label_temp_avg[20]; + snprintf(label_temp_avg, 20, "Temp: %.1f C", power_management->chip_temp_avg); + + display_show_status((const char *[]){ + label_hashrate, + label_efficiency, + module->FOUND_BLOCK ? "!!! BLOCK FOUND !!!" : label_best, + label_temp_avg + }, 4); } break; default: + break; } } @@ -527,21 +427,17 @@ static void _update_connection(GlobalState * GLOBAL_STATE) case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - if (OLED_status()) { - OLED_clearLine(2); - strncpy(module->oled_buf, module->ssid, sizeof(module->oled_buf)); - module->oled_buf[sizeof(module->oled_buf) - 1] = 0; - OLED_writeString(0, 1, module->oled_buf); - - memset(module->oled_buf, 0, 20); - snprintf(module->oled_buf, 20, "Configuration SSID:"); - OLED_writeString(0, 2, module->oled_buf); + if (display_active()) { char ap_ssid[13]; generate_ssid(ap_ssid); - memset(module->oled_buf, 0, 20); - snprintf(module->oled_buf, 20, ap_ssid); - OLED_writeString(0, 3, module->oled_buf); + + display_show_status((const char *[]){ + "Connecting to SSID:", + module->ssid, + "Configuration SSID:", + ap_ssid + }, 4); } break; default: @@ -556,15 +452,14 @@ static void show_ap_information(const char * error, GlobalState * GLOBAL_STATE) case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - if (OLED_status()) { - _clear_display(GLOBAL_STATE); - if (error != NULL) { - OLED_writeString(0, 0, error); - } - OLED_writeString(0, 1, "Configuration SSID:"); + if (display_active()) { char ap_ssid[13]; generate_ssid(ap_ssid); - OLED_writeString(0, 2, ap_ssid); + + display_show_status((const char *[]){ + "Configuration SSID:", + ap_ssid + }, 2); } break; default: diff --git a/sdkconfig.defaults b/sdkconfig.defaults index 63d09ca1c..97b1ea187 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -1,12 +1,16 @@ -CONFIG_PARTITION_TABLE_CUSTOM=y -CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" -CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" -CONFIG_PARTITION_TABLE_OFFSET=0x8000 -CONFIG_PARTITION_TABLE_MD5=y +# This file was generated using idf.py save-defconfig. It can be edited manually. +# Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration +# +CONFIG_IDF_TARGET="esp32s3" CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y -CONFIG_ESPTOOLPY_FLASHSIZE="16MB" +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_COMPILER_ORPHAN_SECTIONS_WARNING=y +CONFIG_HTTPD_MAX_URI_LEN=2048 CONFIG_HTTPD_WS_SUPPORT=y +CONFIG_SPIRAM=y +CONFIG_SPIRAM_MODE_OCT=y CONFIG_SPIFFS_OBJ_NAME_LEN=64 -CONFIG_HTTPD_MAX_URI_LEN=2048 -CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y -CONFIG_ESP_WIFI_11KV_SUPPORT=y +CONFIG_LV_USE_THEME_DEFAULT=n +CONFIG_LV_USE_THEME_BASIC=n +CONFIG_LV_USE_SNAPSHOT=n +CONFIG_LV_BUILD_EXAMPLES=n From 7fd5be9538513ffc2ab5fc5d972e287978933b95 Mon Sep 17 00:00:00 2001 From: mutatrum Date: Sun, 10 Nov 2024 10:47:21 +0100 Subject: [PATCH 02/23] Add font attribution --- readme.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/readme.md b/readme.md index aac5113fb..f628af5e0 100755 --- a/readme.md +++ b/readme.md @@ -65,3 +65,7 @@ Some API examples in curl: ## Administration The firmware hosts a small web server on port 80 for administrative purposes. Once the Bitaxe device is connected to the local network, the admin web front end may be accessed via a web browser connected to the same network at `http://`, replacing `IP` with the LAN IP address of the Bitaxe device, or `http://bitaxe`, provided your network supports mDNS configuration. + +## Attributions + +The display font is Portfolio 6x8 from https://int10h.org/oldschool-pc-fonts/ by VileR. \ No newline at end of file From 6cadf46d8ed7ab3480bb88db72f2c3d2bcb2d1ce Mon Sep 17 00:00:00 2001 From: mutatrum Date: Sun, 10 Nov 2024 14:02:08 +0100 Subject: [PATCH 03/23] Add missing values in sdkconfig.defaults --- sdkconfig.defaults | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdkconfig.defaults b/sdkconfig.defaults index 97b1ea187..f1f41f132 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -9,6 +9,8 @@ CONFIG_HTTPD_MAX_URI_LEN=2048 CONFIG_HTTPD_WS_SUPPORT=y CONFIG_SPIRAM=y CONFIG_SPIRAM_MODE_OCT=y +CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y +CONFIG_ESP_WIFI_11KV_SUPPORT=y CONFIG_SPIFFS_OBJ_NAME_LEN=64 CONFIG_LV_USE_THEME_DEFAULT=n CONFIG_LV_USE_THEME_BASIC=n From 7b5bda260336ffbb8ca830ed16aa9a92b15f9e8b Mon Sep 17 00:00:00 2001 From: mutatrum Date: Sun, 10 Nov 2024 15:26:34 +0100 Subject: [PATCH 04/23] Fix crash when screen is not present --- main/display.c | 20 ++++++++++---------- main/system.c | 6 ++++-- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/main/display.c b/main/display.c index f9adf3eec..1bb7427d9 100644 --- a/main/display.c +++ b/main/display.c @@ -6,6 +6,7 @@ #include "esp_lcd_panel_ops.h" #include "esp_err.h" #include "esp_log.h" +#include "esp_check.h" #include "lvgl.h" #include "esp_lvgl_port.h" #include "nvs_config.h" @@ -35,7 +36,7 @@ esp_err_t display_init(void) uint8_t invert_screen = nvs_config_get_u16(NVS_CONFIG_INVERT_SCREEN, 0); i2c_master_bus_handle_t i2c_master_bus_handle; - ESP_ERROR_CHECK(i2c_bitaxe_get_master_bus_handle(&i2c_master_bus_handle)); + ESP_RETURN_ON_ERROR(i2c_bitaxe_get_master_bus_handle(&i2c_master_bus_handle), TAG, "Failed to get i2c master bus handle"); ESP_LOGI(TAG, "Install panel IO"); esp_lcd_panel_io_handle_t io_handle = NULL; @@ -48,7 +49,7 @@ esp_err_t display_init(void) .dc_bit_offset = 6 }; - ESP_ERROR_CHECK(esp_lcd_new_panel_io_i2c(i2c_master_bus_handle, &io_config, &io_handle)); + 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_lcd_panel_handle_t panel_handle = NULL; @@ -63,18 +64,17 @@ esp_err_t display_init(void) }; panel_config.vendor_config = &ssd1306_config; - ESP_ERROR_CHECK(esp_lcd_new_panel_ssd1306(io_handle, &panel_config, &panel_handle)); - - ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle)); - ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle)); - // ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, false, false)); - ESP_ERROR_CHECK(esp_lcd_panel_invert_color(panel_handle, invert_screen)); + ESP_RETURN_ON_ERROR(esp_lcd_new_panel_ssd1306(io_handle, &panel_config, &panel_handle), TAG, "No display found"); + ESP_RETURN_ON_ERROR(esp_lcd_panel_reset(panel_handle), TAG, "Panel reset failed"); + ESP_RETURN_ON_ERROR(esp_lcd_panel_init(panel_handle), TAG, "Panel init failed"); + // ESP_RETURN_ON_ERROR(esp_lcd_panel_mirror(panel_handle, false, false), TAG, "Panel mirror failed"); + ESP_RETURN_ON_ERROR(esp_lcd_panel_invert_color(panel_handle, invert_screen), TAG, "Panel invert failed"); - ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel_handle, true)); + ESP_RETURN_ON_ERROR(esp_lcd_panel_disp_on_off(panel_handle, true), TAG, "Panel display on failed"); ESP_LOGI(TAG, "Initialize LVGL"); const lvgl_port_cfg_t lvgl_cfg = ESP_LVGL_PORT_INIT_CONFIG(); - lvgl_port_init(&lvgl_cfg); + ESP_RETURN_ON_ERROR(lvgl_port_init(&lvgl_cfg), TAG, "LVGL init failed"); const lvgl_port_display_cfg_t disp_cfg = { .io_handle = io_handle, diff --git a/main/system.c b/main/system.c index 2e28eeeca..a8cb063ea 100644 --- a/main/system.c +++ b/main/system.c @@ -179,8 +179,10 @@ void SYSTEM_task(void * pvParameters) vTaskDelay(1000 / portTICK_PERIOD_MS); } - display_show_logo(); - vTaskDelay(5000 / portTICK_PERIOD_MS); + if (display_active()) { + display_show_logo(); + vTaskDelay(5000 / portTICK_PERIOD_MS); + } int current_screen = 0; TickType_t last_update_time = xTaskGetTickCount(); From f3e6dd7356b36056e22501d30f8c659120d4f97e Mon Sep 17 00:00:00 2001 From: mutatrum Date: Sun, 10 Nov 2024 17:50:16 +0100 Subject: [PATCH 05/23] Revert SPIRAM enable --- sdkconfig.defaults | 2 -- 1 file changed, 2 deletions(-) diff --git a/sdkconfig.defaults b/sdkconfig.defaults index f1f41f132..78aa65acb 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -7,8 +7,6 @@ CONFIG_PARTITION_TABLE_CUSTOM=y CONFIG_COMPILER_ORPHAN_SECTIONS_WARNING=y CONFIG_HTTPD_MAX_URI_LEN=2048 CONFIG_HTTPD_WS_SUPPORT=y -CONFIG_SPIRAM=y -CONFIG_SPIRAM_MODE_OCT=y CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y CONFIG_ESP_WIFI_11KV_SUPPORT=y CONFIG_SPIFFS_OBJ_NAME_LEN=64 From c3956489772c399f3dde3247ce59f0f951ef4f33 Mon Sep 17 00:00:00 2001 From: mutatrum Date: Mon, 11 Nov 2024 09:15:25 +0100 Subject: [PATCH 06/23] Revert use of idf.py save-defconfig --- sdkconfig.defaults | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sdkconfig.defaults b/sdkconfig.defaults index 78aa65acb..3a05b9811 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -1,15 +1,15 @@ -# This file was generated using idf.py save-defconfig. It can be edited manually. -# Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Minimal Configuration -# -CONFIG_IDF_TARGET="esp32s3" -CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y CONFIG_PARTITION_TABLE_CUSTOM=y -CONFIG_COMPILER_ORPHAN_SECTIONS_WARNING=y -CONFIG_HTTPD_MAX_URI_LEN=2048 +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" +CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" +CONFIG_PARTITION_TABLE_OFFSET=0x8000 +CONFIG_PARTITION_TABLE_MD5=y +CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y +CONFIG_ESPTOOLPY_FLASHSIZE="16MB" CONFIG_HTTPD_WS_SUPPORT=y -CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y -CONFIG_ESP_WIFI_11KV_SUPPORT=y CONFIG_SPIFFS_OBJ_NAME_LEN=64 +CONFIG_HTTPD_MAX_URI_LEN=2048 +CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y +CONFIG_ESP_WIFI_11KV_SUPPORT=y CONFIG_LV_USE_THEME_DEFAULT=n CONFIG_LV_USE_THEME_BASIC=n CONFIG_LV_USE_SNAPSHOT=n From 6d29557ff66ee4b16b92b36d0bfb1191dec4428a Mon Sep 17 00:00:00 2001 From: mutatrum Date: Mon, 18 Nov 2024 14:01:03 +0100 Subject: [PATCH 07/23] Use custom lv_conf.h --- main/CMakeLists.txt | 3 + main/lv_conf.h | 783 ++++++++++++++++++++++++++++++++++++++++++++ sdkconfig.defaults | 5 +- 3 files changed, 787 insertions(+), 4 deletions(-) create mode 100644 main/lv_conf.h diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index d56d0ee27..629c74449 100755 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -52,6 +52,9 @@ PRIV_REQUIRES "esp_driver_i2c" ) +idf_build_set_property(COMPILE_OPTIONS "-DLV_CONF_INCLUDE_SIMPLE=1" APPEND) +idf_build_set_property(COMPILE_OPTIONS "-DLV_CONF_PATH= ${CMAKE_SOURCE_DIR}/main/lv_conf.h" APPEND) + set(WEB_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/http_server/axe-os") if("$ENV{GITHUB_ACTIONS}" STREQUAL "true") diff --git a/main/lv_conf.h b/main/lv_conf.h new file mode 100644 index 000000000..0d49a2f46 --- /dev/null +++ b/main/lv_conf.h @@ -0,0 +1,783 @@ +/** + * @file lv_conf.h + * Configuration file for v8.4.0 + */ + +/* + * Copy this file as `lv_conf.h` + * 1. simply next to the `lvgl` folder + * 2. or any other places and + * - define `LV_CONF_INCLUDE_SIMPLE` + * - add the path as include path + */ + +/* clang-format off */ +#if 1 /*Set it to "1" to enable content*/ + +#ifndef LV_CONF_H +#define LV_CONF_H + +#include + +/*==================== + COLOR SETTINGS + *====================*/ + +/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/ +#define LV_COLOR_DEPTH 16 + +/*Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface (e.g. SPI)*/ +#define LV_COLOR_16_SWAP 0 + +/*Enable features to draw on transparent background. + *It's required if opa, and transform_* style properties are used. + *Can be also used if the UI is above another layer, e.g. an OSD menu or video player.*/ +#define LV_COLOR_SCREEN_TRANSP 0 + +/* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently. + * 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */ +#define LV_COLOR_MIX_ROUND_OFS 0 + +/*Images pixels with this color will not be drawn if they are chroma keyed)*/ +#define LV_COLOR_CHROMA_KEY lv_color_hex(0x00ff00) /*pure green*/ + +/*========================= + MEMORY SETTINGS + *=========================*/ + +/*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/ +#define LV_MEM_CUSTOM 0 +#if LV_MEM_CUSTOM == 0 + /*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/ + #define LV_MEM_SIZE (48U * 1024U) /*[bytes]*/ + + /*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/ + #define LV_MEM_ADR 0 /*0: unused*/ + /*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/ + #if LV_MEM_ADR == 0 + #undef LV_MEM_POOL_INCLUDE + #undef LV_MEM_POOL_ALLOC + #endif + +#else /*LV_MEM_CUSTOM*/ + #define LV_MEM_CUSTOM_INCLUDE /*Header for the dynamic memory function*/ + #define LV_MEM_CUSTOM_ALLOC malloc + #define LV_MEM_CUSTOM_FREE free + #define LV_MEM_CUSTOM_REALLOC realloc +#endif /*LV_MEM_CUSTOM*/ + +/*Number of the intermediate memory buffer used during rendering and other internal processing mechanisms. + *You will see an error log message if there wasn't enough buffers. */ +#define LV_MEM_BUF_MAX_NUM 16 + +/*Use the standard `memcpy` and `memset` instead of LVGL's own functions. (Might or might not be faster).*/ +#define LV_MEMCPY_MEMSET_STD 0 + +/*==================== + HAL SETTINGS + *====================*/ + +/*Default display refresh period. LVG will redraw changed areas with this period time*/ +#define LV_DISP_DEF_REFR_PERIOD 30 /*[ms]*/ + +/*Input device read period in milliseconds*/ +#define LV_INDEV_DEF_READ_PERIOD 30 /*[ms]*/ + +/*Use a custom tick source that tells the elapsed time in milliseconds. + *It removes the need to manually update the tick with `lv_tick_inc()`)*/ +#define LV_TICK_CUSTOM 0 +#if LV_TICK_CUSTOM + #define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/ + #define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/ + /*If using lvgl as ESP32 component*/ + // #define LV_TICK_CUSTOM_INCLUDE "esp_timer.h" + // #define LV_TICK_CUSTOM_SYS_TIME_EXPR ((esp_timer_get_time() / 1000LL)) +#endif /*LV_TICK_CUSTOM*/ + +/*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings. + *(Not so important, you can adjust it to modify default sizes and spaces)*/ +#define LV_DPI_DEF 130 /*[px/inch]*/ + +/*======================= + * FEATURE CONFIGURATION + *=======================*/ + +/*------------- + * Drawing + *-----------*/ + +/*Enable complex draw engine. + *Required to draw shadow, gradient, rounded corners, circles, arc, skew lines, image transformations or any masks*/ +#define LV_DRAW_COMPLEX 0 +#if LV_DRAW_COMPLEX != 0 + + /*Allow buffering some shadow calculation. + *LV_SHADOW_CACHE_SIZE is the max. shadow size to buffer, where shadow size is `shadow_width + radius` + *Caching has LV_SHADOW_CACHE_SIZE^2 RAM cost*/ + #define LV_SHADOW_CACHE_SIZE 0 + + /* Set number of maximally cached circle data. + * The circumference of 1/4 circle are saved for anti-aliasing + * radius * 4 bytes are used per circle (the most often used radiuses are saved) + * 0: to disable caching */ + #define LV_CIRCLE_CACHE_SIZE 4 +#endif /*LV_DRAW_COMPLEX*/ + +/** + * "Simple layers" are used when a widget has `style_opa < 255` to buffer the widget into a layer + * and blend it as an image with the given opacity. + * Note that `bg_opa`, `text_opa` etc don't require buffering into layer) + * The widget can be buffered in smaller chunks to avoid using large buffers. + * + * - LV_LAYER_SIMPLE_BUF_SIZE: [bytes] the optimal target buffer size. LVGL will try to allocate it + * - LV_LAYER_SIMPLE_FALLBACK_BUF_SIZE: [bytes] used if `LV_LAYER_SIMPLE_BUF_SIZE` couldn't be allocated. + * + * Both buffer sizes are in bytes. + * "Transformed layers" (where transform_angle/zoom properties are used) use larger buffers + * and can't be drawn in chunks. So these settings affects only widgets with opacity. + */ +#define LV_LAYER_SIMPLE_BUF_SIZE (24 * 1024) +#define LV_LAYER_SIMPLE_FALLBACK_BUF_SIZE (3 * 1024) + +/*Default image cache size. Image caching keeps the images opened. + *If only the built-in image formats are used there is no real advantage of caching. (I.e. if no new image decoder is added) + *With complex image decoders (e.g. PNG or JPG) caching can save the continuous open/decode of images. + *However the opened images might consume additional RAM. + *0: to disable caching*/ +#define LV_IMG_CACHE_DEF_SIZE 0 + +/*Number of stops allowed per gradient. Increase this to allow more stops. + *This adds (sizeof(lv_color_t) + 1) bytes per additional stop*/ +#define LV_GRADIENT_MAX_STOPS 2 + +/*Default gradient buffer size. + *When LVGL calculates the gradient "maps" it can save them into a cache to avoid calculating them again. + *LV_GRAD_CACHE_DEF_SIZE sets the size of this cache in bytes. + *If the cache is too small the map will be allocated only while it's required for the drawing. + *0 mean no caching.*/ +#define LV_GRAD_CACHE_DEF_SIZE 0 + +/*Allow dithering the gradients (to achieve visual smooth color gradients on limited color depth display) + *LV_DITHER_GRADIENT implies allocating one or two more lines of the object's rendering surface + *The increase in memory consumption is (32 bits * object width) plus 24 bits * object width if using error diffusion */ +#define LV_DITHER_GRADIENT 0 +#if LV_DITHER_GRADIENT + /*Add support for error diffusion dithering. + *Error diffusion dithering gets a much better visual result, but implies more CPU consumption and memory when drawing. + *The increase in memory consumption is (24 bits * object's width)*/ + #define LV_DITHER_ERROR_DIFFUSION 0 +#endif + +/*Maximum buffer size to allocate for rotation. + *Only used if software rotation is enabled in the display driver.*/ +#define LV_DISP_ROT_MAX_BUF (10*1024) + +/*------------- + * GPU + *-----------*/ + +/*Use Arm's 2D acceleration library Arm-2D */ +#define LV_USE_GPU_ARM2D 0 + +/*Use STM32's DMA2D (aka Chrom Art) GPU*/ +#define LV_USE_GPU_STM32_DMA2D 0 +#if LV_USE_GPU_STM32_DMA2D + /*Must be defined to include path of CMSIS header of target processor + e.g. "stm32f7xx.h" or "stm32f4xx.h"*/ + #define LV_GPU_DMA2D_CMSIS_INCLUDE +#endif + +/*Enable RA6M3 G2D GPU*/ +#define LV_USE_GPU_RA6M3_G2D 0 +#if LV_USE_GPU_RA6M3_G2D + /*include path of target processor + e.g. "hal_data.h"*/ + #define LV_GPU_RA6M3_G2D_INCLUDE "hal_data.h" +#endif + +/*Use SWM341's DMA2D GPU*/ +#define LV_USE_GPU_SWM341_DMA2D 0 +#if LV_USE_GPU_SWM341_DMA2D + #define LV_GPU_SWM341_DMA2D_INCLUDE "SWM341.h" +#endif + +/*Use NXP's PXP GPU iMX RTxxx platforms*/ +#define LV_USE_GPU_NXP_PXP 0 +#if LV_USE_GPU_NXP_PXP + /*1: Add default bare metal and FreeRTOS interrupt handling routines for PXP (lv_gpu_nxp_pxp_osa.c) + * and call lv_gpu_nxp_pxp_init() automatically during lv_init(). Note that symbol SDK_OS_FREE_RTOS + * has to be defined in order to use FreeRTOS OSA, otherwise bare-metal implementation is selected. + *0: lv_gpu_nxp_pxp_init() has to be called manually before lv_init() + */ + #define LV_USE_GPU_NXP_PXP_AUTO_INIT 0 +#endif + +/*Use NXP's VG-Lite GPU iMX RTxxx platforms*/ +#define LV_USE_GPU_NXP_VG_LITE 0 + +/*Use SDL renderer API*/ +#define LV_USE_GPU_SDL 0 +#if LV_USE_GPU_SDL + #define LV_GPU_SDL_INCLUDE_PATH + /*Texture cache size, 8MB by default*/ + #define LV_GPU_SDL_LRU_SIZE (1024 * 1024 * 8) + /*Custom blend mode for mask drawing, disable if you need to link with older SDL2 lib*/ + #define LV_GPU_SDL_CUSTOM_BLEND_MODE (SDL_VERSION_ATLEAST(2, 0, 6)) +#endif + +/*------------- + * Logging + *-----------*/ + +/*Enable the log module*/ +#define LV_USE_LOG 0 +#if LV_USE_LOG + + /*How important log should be added: + *LV_LOG_LEVEL_TRACE A lot of logs to give detailed information + *LV_LOG_LEVEL_INFO Log important events + *LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem + *LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail + *LV_LOG_LEVEL_USER Only logs added by the user + *LV_LOG_LEVEL_NONE Do not log anything*/ + #define LV_LOG_LEVEL LV_LOG_LEVEL_WARN + + /*1: Print the log with 'printf'; + *0: User need to register a callback with `lv_log_register_print_cb()`*/ + #define LV_LOG_PRINTF 0 + + /*Enable/disable LV_LOG_TRACE in modules that produces a huge number of logs*/ + #define LV_LOG_TRACE_MEM 1 + #define LV_LOG_TRACE_TIMER 1 + #define LV_LOG_TRACE_INDEV 1 + #define LV_LOG_TRACE_DISP_REFR 1 + #define LV_LOG_TRACE_EVENT 1 + #define LV_LOG_TRACE_OBJ_CREATE 1 + #define LV_LOG_TRACE_LAYOUT 1 + #define LV_LOG_TRACE_ANIM 1 + +#endif /*LV_USE_LOG*/ + +/*------------- + * Asserts + *-----------*/ + +/*Enable asserts if an operation is failed or an invalid data is found. + *If LV_USE_LOG is enabled an error message will be printed on failure*/ +#define LV_USE_ASSERT_NULL 1 /*Check if the parameter is NULL. (Very fast, recommended)*/ +#define LV_USE_ASSERT_MALLOC 1 /*Checks is the memory is successfully allocated or no. (Very fast, recommended)*/ +#define LV_USE_ASSERT_STYLE 0 /*Check if the styles are properly initialized. (Very fast, recommended)*/ +#define LV_USE_ASSERT_MEM_INTEGRITY 0 /*Check the integrity of `lv_mem` after critical operations. (Slow)*/ +#define LV_USE_ASSERT_OBJ 0 /*Check the object's type and existence (e.g. not deleted). (Slow)*/ + +/*Add a custom handler when assert happens e.g. to restart the MCU*/ +#define LV_ASSERT_HANDLER_INCLUDE +#define LV_ASSERT_HANDLER while(1); /*Halt by default*/ + +/*------------- + * Others + *-----------*/ + +/*1: Show CPU usage and FPS count*/ +#define LV_USE_PERF_MONITOR 0 +#if LV_USE_PERF_MONITOR + #define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT +#endif + +/*1: Show the used memory and the memory fragmentation + * Requires LV_MEM_CUSTOM = 0*/ +#define LV_USE_MEM_MONITOR 0 +#if LV_USE_MEM_MONITOR + #define LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_LEFT +#endif + +/*1: Draw random colored rectangles over the redrawn areas*/ +#define LV_USE_REFR_DEBUG 0 + +/*Change the built in (v)snprintf functions*/ +#define LV_SPRINTF_CUSTOM 0 +#if LV_SPRINTF_CUSTOM + #define LV_SPRINTF_INCLUDE + #define lv_snprintf snprintf + #define lv_vsnprintf vsnprintf +#else /*LV_SPRINTF_CUSTOM*/ + #define LV_SPRINTF_USE_FLOAT 0 +#endif /*LV_SPRINTF_CUSTOM*/ + +#define LV_USE_USER_DATA 1 + +/*Garbage Collector settings + *Used if lvgl is bound to higher level language and the memory is managed by that language*/ +#define LV_ENABLE_GC 0 +#if LV_ENABLE_GC != 0 + #define LV_GC_INCLUDE "gc.h" /*Include Garbage Collector related things*/ +#endif /*LV_ENABLE_GC*/ + +/*===================== + * COMPILER SETTINGS + *====================*/ + +/*For big endian systems set to 1*/ +#define LV_BIG_ENDIAN_SYSTEM 0 + +/*Define a custom attribute to `lv_tick_inc` function*/ +#define LV_ATTRIBUTE_TICK_INC + +/*Define a custom attribute to `lv_timer_handler` function*/ +#define LV_ATTRIBUTE_TIMER_HANDLER + +/*Define a custom attribute to `lv_disp_flush_ready` function*/ +#define LV_ATTRIBUTE_FLUSH_READY + +/*Required alignment size for buffers*/ +#define LV_ATTRIBUTE_MEM_ALIGN_SIZE 1 + +/*Will be added where memories needs to be aligned (with -Os data might not be aligned to boundary by default). + * E.g. __attribute__((aligned(4)))*/ +#define LV_ATTRIBUTE_MEM_ALIGN + +/*Attribute to mark large constant arrays for example font's bitmaps*/ +#define LV_ATTRIBUTE_LARGE_CONST + +/*Compiler prefix for a big array declaration in RAM*/ +#define LV_ATTRIBUTE_LARGE_RAM_ARRAY + +/*Place performance critical functions into a faster memory (e.g RAM)*/ +#define LV_ATTRIBUTE_FAST_MEM + +/*Prefix variables that are used in GPU accelerated operations, often these need to be placed in RAM sections that are DMA accessible*/ +#define LV_ATTRIBUTE_DMA + +/*Export integer constant to binding. This macro is used with constants in the form of LV_ that + *should also appear on LVGL binding API such as Micropython.*/ +#define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning /*The default value just prevents GCC warning*/ + +/*Extend the default -32k..32k coordinate range to -4M..4M by using int32_t for coordinates instead of int16_t*/ +#define LV_USE_LARGE_COORD 0 + +/*================== + * FONT USAGE + *===================*/ + +/*Montserrat fonts with ASCII range and some symbols using bpp = 4 + *https://fonts.google.com/specimen/Montserrat*/ +#define LV_FONT_MONTSERRAT_8 0 +#define LV_FONT_MONTSERRAT_10 0 +#define LV_FONT_MONTSERRAT_12 0 +#define LV_FONT_MONTSERRAT_14 0 +#define LV_FONT_MONTSERRAT_16 0 +#define LV_FONT_MONTSERRAT_18 0 +#define LV_FONT_MONTSERRAT_20 0 +#define LV_FONT_MONTSERRAT_22 0 +#define LV_FONT_MONTSERRAT_24 0 +#define LV_FONT_MONTSERRAT_26 0 +#define LV_FONT_MONTSERRAT_28 0 +#define LV_FONT_MONTSERRAT_30 0 +#define LV_FONT_MONTSERRAT_32 0 +#define LV_FONT_MONTSERRAT_34 0 +#define LV_FONT_MONTSERRAT_36 0 +#define LV_FONT_MONTSERRAT_38 0 +#define LV_FONT_MONTSERRAT_40 0 +#define LV_FONT_MONTSERRAT_42 0 +#define LV_FONT_MONTSERRAT_44 0 +#define LV_FONT_MONTSERRAT_46 0 +#define LV_FONT_MONTSERRAT_48 0 + +/*Demonstrate special features*/ +#define LV_FONT_MONTSERRAT_12_SUBPX 0 +#define LV_FONT_MONTSERRAT_28_COMPRESSED 0 /*bpp = 3*/ +#define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 0 /*Hebrew, Arabic, Persian letters and all their forms*/ +#define LV_FONT_SIMSUN_16_CJK 0 /*1000 most common CJK radicals*/ + +/*Pixel perfect monospace fonts*/ +#define LV_FONT_UNSCII_8 0 +#define LV_FONT_UNSCII_16 0 + +/*Optionally declare custom fonts here. + *You can use these fonts as default font too and they will be available globally. + *E.g. #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) LV_FONT_DECLARE(my_font_2)*/ +#define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(lv_font_portfolio_6x8) + +/*Always set a default font*/ +#define LV_FONT_DEFAULT &lv_font_portfolio_6x8 + +/*Enable handling large font and/or fonts with a lot of characters. + *The limit depends on the font size, font face and bpp. + *Compiler error will be triggered if a font needs it.*/ +#define LV_FONT_FMT_TXT_LARGE 0 + +/*Enables/disables support for compressed fonts.*/ +#define LV_USE_FONT_COMPRESSED 0 + +/*Enable subpixel rendering*/ +#define LV_USE_FONT_SUBPX 0 +#if LV_USE_FONT_SUBPX + /*Set the pixel order of the display. Physical order of RGB channels. Doesn't matter with "normal" fonts.*/ + #define LV_FONT_SUBPX_BGR 0 /*0: RGB; 1:BGR order*/ +#endif + +/*Enable drawing placeholders when glyph dsc is not found*/ +#define LV_USE_FONT_PLACEHOLDER 0 + +/*================= + * TEXT SETTINGS + *=================*/ + +/** + * Select a character encoding for strings. + * Your IDE or editor should have the same character encoding + * - LV_TXT_ENC_UTF8 + * - LV_TXT_ENC_ASCII + */ +#define LV_TXT_ENC LV_TXT_ENC_UTF8 + +/*Can break (wrap) texts on these chars*/ +#define LV_TXT_BREAK_CHARS " ,.;:-_" + +/*If a word is at least this long, will break wherever "prettiest" + *To disable, set to a value <= 0*/ +#define LV_TXT_LINE_BREAK_LONG_LEN 0 + +/*Minimum number of characters in a long word to put on a line before a break. + *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ +#define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3 + +/*Minimum number of characters in a long word to put on a line after a break. + *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ +#define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3 + +/*The control character to use for signalling text recoloring.*/ +#define LV_TXT_COLOR_CMD "#" + +/*Support bidirectional texts. Allows mixing Left-to-Right and Right-to-Left texts. + *The direction will be processed according to the Unicode Bidirectional Algorithm: + *https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ +#define LV_USE_BIDI 0 +#if LV_USE_BIDI + /*Set the default direction. Supported values: + *`LV_BASE_DIR_LTR` Left-to-Right + *`LV_BASE_DIR_RTL` Right-to-Left + *`LV_BASE_DIR_AUTO` detect texts base direction*/ + #define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO +#endif + +/*Enable Arabic/Persian processing + *In these languages characters should be replaced with an other form based on their position in the text*/ +#define LV_USE_ARABIC_PERSIAN_CHARS 0 + +/*================== + * WIDGET USAGE + *================*/ + +/*Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.html*/ + +#define LV_USE_ARC 0 + +#define LV_USE_BAR 0 + +#define LV_USE_BTN 0 + +#define LV_USE_BTNMATRIX 0 + +#define LV_USE_CANVAS 0 + +#define LV_USE_CHECKBOX 0 + +#define LV_USE_DROPDOWN 0 /*Requires: lv_label*/ + +#define LV_USE_IMG 1 /*Requires: lv_label*/ + +#define LV_USE_LABEL 1 +#if LV_USE_LABEL + #define LV_LABEL_TEXT_SELECTION 0 /*Enable selecting text of the label*/ + #define LV_LABEL_LONG_TXT_HINT 0 /*Store some extra info in labels to speed up drawing of very long texts*/ +#endif + +#define LV_USE_LINE 0 + +#define LV_USE_ROLLER 0 /*Requires: lv_label*/ +#if LV_USE_ROLLER + #define LV_ROLLER_INF_PAGES 7 /*Number of extra "pages" when the roller is infinite*/ +#endif + +#define LV_USE_SLIDER 0 /*Requires: lv_bar*/ + +#define LV_USE_SWITCH 0 + +#define LV_USE_TEXTAREA 0 /*Requires: lv_label*/ +#if LV_USE_TEXTAREA != 0 + #define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/ +#endif + +#define LV_USE_TABLE 0 + +/*================== + * EXTRA COMPONENTS + *==================*/ + +/*----------- + * Widgets + *----------*/ +#define LV_USE_ANIMIMG 0 + +#define LV_USE_CALENDAR 0 +#if LV_USE_CALENDAR + #define LV_CALENDAR_WEEK_STARTS_MONDAY 0 + #if LV_CALENDAR_WEEK_STARTS_MONDAY + #define LV_CALENDAR_DEFAULT_DAY_NAMES {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"} + #else + #define LV_CALENDAR_DEFAULT_DAY_NAMES {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"} + #endif + + #define LV_CALENDAR_DEFAULT_MONTH_NAMES {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"} + #define LV_USE_CALENDAR_HEADER_ARROW 1 + #define LV_USE_CALENDAR_HEADER_DROPDOWN 1 +#endif /*LV_USE_CALENDAR*/ + +#define LV_USE_CHART 0 + +#define LV_USE_COLORWHEEL 0 + +#define LV_USE_IMGBTN 0 + +#define LV_USE_KEYBOARD 0 + +#define LV_USE_LED 0 + +#define LV_USE_LIST 0 + +#define LV_USE_MENU 0 + +#define LV_USE_METER 0 + +#define LV_USE_MSGBOX 0 + +#define LV_USE_SPAN 0 +#if LV_USE_SPAN + /*A line text can contain maximum num of span descriptor */ + #define LV_SPAN_SNIPPET_STACK_SIZE 64 +#endif + +#define LV_USE_SPINBOX 0 + +#define LV_USE_SPINNER 0 + +#define LV_USE_TABVIEW 0 + +#define LV_USE_TILEVIEW 0 + +#define LV_USE_WIN 0 + +/*----------- + * Themes + *----------*/ + +/*A simple, impressive and very complete theme*/ +#define LV_USE_THEME_DEFAULT 0 +#if LV_USE_THEME_DEFAULT + + /*0: Light mode; 1: Dark mode*/ + #define LV_THEME_DEFAULT_DARK 0 + + /*1: Enable grow on press*/ + #define LV_THEME_DEFAULT_GROW 1 + + /*Default transition time in [ms]*/ + #define LV_THEME_DEFAULT_TRANSITION_TIME 80 +#endif /*LV_USE_THEME_DEFAULT*/ + +/*A very simple theme that is a good starting point for a custom theme*/ +#define LV_USE_THEME_BASIC 0 + +/*A theme designed for monochrome displays*/ +#define LV_USE_THEME_MONO 0 + +/*----------- + * Layouts + *----------*/ + +/*A layout similar to Flexbox in CSS.*/ +#define LV_USE_FLEX 1 + +/*A layout similar to Grid in CSS.*/ +#define LV_USE_GRID 1 + +/*--------------------- + * 3rd party libraries + *--------------------*/ + +/*File system interfaces for common APIs */ + +/*API for fopen, fread, etc*/ +#define LV_USE_FS_STDIO 0 +#if LV_USE_FS_STDIO + #define LV_FS_STDIO_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ + #define LV_FS_STDIO_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/ + #define LV_FS_STDIO_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ +#endif + +/*API for open, read, etc*/ +#define LV_USE_FS_POSIX 0 +#if LV_USE_FS_POSIX + #define LV_FS_POSIX_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ + #define LV_FS_POSIX_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/ + #define LV_FS_POSIX_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ +#endif + +/*API for CreateFile, ReadFile, etc*/ +#define LV_USE_FS_WIN32 0 +#if LV_USE_FS_WIN32 + #define LV_FS_WIN32_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ + #define LV_FS_WIN32_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/ + #define LV_FS_WIN32_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ +#endif + +/*API for FATFS (needs to be added separately). Uses f_open, f_read, etc*/ +#define LV_USE_FS_FATFS 0 +#if LV_USE_FS_FATFS + #define LV_FS_FATFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ + #define LV_FS_FATFS_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ +#endif + +/*API for LittleFS (library needs to be added separately). Uses lfs_file_open, lfs_file_read, etc*/ +#define LV_USE_FS_LITTLEFS 0 +#if LV_USE_FS_LITTLEFS + #define LV_FS_LITTLEFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ + #define LV_FS_LITTLEFS_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ +#endif + +/*PNG decoder library*/ +#define LV_USE_PNG 0 + +/*BMP decoder library*/ +#define LV_USE_BMP 0 + +/* JPG + split JPG decoder library. + * Split JPG is a custom format optimized for embedded systems. */ +#define LV_USE_SJPG 0 + +/*GIF decoder library*/ +#define LV_USE_GIF 0 + +/*QR code library*/ +#define LV_USE_QRCODE 0 + +/*FreeType library*/ +#define LV_USE_FREETYPE 0 +#if LV_USE_FREETYPE + /*Memory used by FreeType to cache characters [bytes] (-1: no caching)*/ + #define LV_FREETYPE_CACHE_SIZE (16 * 1024) + #if LV_FREETYPE_CACHE_SIZE >= 0 + /* 1: bitmap cache use the sbit cache, 0:bitmap cache use the image cache. */ + /* sbit cache:it is much more memory efficient for small bitmaps(font size < 256) */ + /* if font size >= 256, must be configured as image cache */ + #define LV_FREETYPE_SBIT_CACHE 0 + /* Maximum number of opened FT_Face/FT_Size objects managed by this cache instance. */ + /* (0:use system defaults) */ + #define LV_FREETYPE_CACHE_FT_FACES 0 + #define LV_FREETYPE_CACHE_FT_SIZES 0 + #endif +#endif + +/*Tiny TTF library*/ +#define LV_USE_TINY_TTF 0 +#if LV_USE_TINY_TTF + /*Load TTF data from files*/ + #define LV_TINY_TTF_FILE_SUPPORT 0 +#endif + +/*Rlottie library*/ +#define LV_USE_RLOTTIE 0 + +/*FFmpeg library for image decoding and playing videos + *Supports all major image formats so do not enable other image decoder with it*/ +#define LV_USE_FFMPEG 0 +#if LV_USE_FFMPEG + /*Dump input information to stderr*/ + #define LV_FFMPEG_DUMP_FORMAT 0 +#endif + +/*----------- + * Others + *----------*/ + +/*1: Enable API to take snapshot for object*/ + +/*1: Enable Monkey test*/ +#define LV_USE_MONKEY 0 + +/*1: Enable grid navigation*/ +#define LV_USE_GRIDNAV 0 + +/*1: Enable lv_obj fragment*/ +#define LV_USE_FRAGMENT 0 + +/*1: Support using images as font in label or span widgets */ +#define LV_USE_IMGFONT 0 + +/*1: Enable a published subscriber based messaging system */ +#define LV_USE_MSG 0 + +/*1: Enable Pinyin input method*/ +/*Requires: lv_keyboard*/ +#define LV_USE_IME_PINYIN 0 +#if LV_USE_IME_PINYIN + /*1: Use default thesaurus*/ + /*If you do not use the default thesaurus, be sure to use `lv_ime_pinyin` after setting the thesauruss*/ + #define LV_IME_PINYIN_USE_DEFAULT_DICT 1 + /*Set the maximum number of candidate panels that can be displayed*/ + /*This needs to be adjusted according to the size of the screen*/ + #define LV_IME_PINYIN_CAND_TEXT_NUM 6 + + /*Use 9 key input(k9)*/ + #define LV_IME_PINYIN_USE_K9_MODE 1 + #if LV_IME_PINYIN_USE_K9_MODE == 1 + #define LV_IME_PINYIN_K9_CAND_TEXT_NUM 3 + #endif // LV_IME_PINYIN_USE_K9_MODE +#endif + +/*================== +* EXAMPLES +*==================*/ + +/*Enable the examples to be built with the library*/ +#define LV_BUILD_EXAMPLES 0 + +/*=================== + * DEMO USAGE + ====================*/ + +/*Show some widget. It might be required to increase `LV_MEM_SIZE` */ +#define LV_USE_DEMO_WIDGETS 0 +#if LV_USE_DEMO_WIDGETS +#define LV_DEMO_WIDGETS_SLIDESHOW 0 +#endif + +/*Demonstrate the usage of encoder and keyboard*/ +#define LV_USE_DEMO_KEYPAD_AND_ENCODER 0 + +/*Benchmark your system*/ +#define LV_USE_DEMO_BENCHMARK 0 +#if LV_USE_DEMO_BENCHMARK +/*Use RGB565A8 images with 16 bit color depth instead of ARGB8565*/ +#define LV_DEMO_BENCHMARK_RGB565A8 0 +#endif + +/*Stress test for LVGL*/ +#define LV_USE_DEMO_STRESS 0 + +/*Music player demo*/ +#define LV_USE_DEMO_MUSIC 0 +#if LV_USE_DEMO_MUSIC + #define LV_DEMO_MUSIC_SQUARE 0 + #define LV_DEMO_MUSIC_LANDSCAPE 0 + #define LV_DEMO_MUSIC_ROUND 0 + #define LV_DEMO_MUSIC_LARGE 0 + #define LV_DEMO_MUSIC_AUTO_PLAY 0 +#endif + +/*--END OF LV_CONF_H--*/ + +#endif /*LV_CONF_H*/ + +#endif /*End of "Content enable"*/ diff --git a/sdkconfig.defaults b/sdkconfig.defaults index 3a05b9811..40a1fa009 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -10,7 +10,4 @@ CONFIG_SPIFFS_OBJ_NAME_LEN=64 CONFIG_HTTPD_MAX_URI_LEN=2048 CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y CONFIG_ESP_WIFI_11KV_SUPPORT=y -CONFIG_LV_USE_THEME_DEFAULT=n -CONFIG_LV_USE_THEME_BASIC=n -CONFIG_LV_USE_SNAPSHOT=n -CONFIG_LV_BUILD_EXAMPLES=n +CONFIG_LV_CONF_SKIP=n From 5adbe526a6f6493368bfdcfb3763acb57d961f0b Mon Sep 17 00:00:00 2001 From: mutatrum Date: Fri, 22 Nov 2024 17:22:38 +0100 Subject: [PATCH 08/23] Port to LVGL 9 with esp_lvgl_port patch version --- main/display.c | 14 +- main/idf_component.yml | 7 +- main/logo.c | 78 ++-- main/lv_conf.h | 948 ++++++++++++++++++++++++++++------------- 4 files changed, 700 insertions(+), 347 deletions(-) diff --git a/main/display.c b/main/display.c index 1bb7427d9..93638d1e8 100644 --- a/main/display.c +++ b/main/display.c @@ -56,7 +56,6 @@ esp_err_t display_init(void) esp_lcd_panel_dev_config_t panel_config = { .bits_per_pixel = 1, .reset_gpio_num = -1, - .color_space = ESP_LCD_COLOR_SPACE_MONOCHROME, }; esp_lcd_panel_ssd1306_config_t ssd1306_config = { @@ -84,16 +83,28 @@ esp_err_t display_init(void) .hres = LCD_H_RES, .vres = LCD_V_RES, .monochrome = true, + .color_format = LV_COLOR_FORMAT_RGB565, .rotation = { .swap_xy = false, .mirror_x = !flip_screen, // The screen is not flipped, this is for backwards compatibility .mirror_y = !flip_screen, }, + .flags = { + .swap_bytes = false, + .sw_rotate = false, + } }; lvgl_port_add_disp(&disp_cfg); lv_style_init(&style); lv_style_set_text_font(&style, &lv_font_portfolio_6x8); + lv_style_set_bg_opa(&style, LV_OPA_COVER); + + if (lvgl_port_lock(0)) { + lv_obj_t *scr = lv_scr_act(); + lv_obj_add_style(scr, &style, LV_PART_MAIN); + lvgl_port_unlock(); + } is_display_active = true; @@ -131,7 +142,6 @@ void display_show_status(const char *messages[], size_t message_count) { lv_obj_t *label = lv_label_create(container); lv_label_set_text(label, messages[i]); - lv_obj_add_style(label, &style, LV_PART_MAIN); lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR); lv_obj_set_width(label, LCD_H_RES); } diff --git a/main/idf_component.yml b/main/idf_component.yml index 2606f646a..69aeccc53 100644 --- a/main/idf_component.yml +++ b/main/idf_component.yml @@ -1,9 +1,12 @@ ## IDF Component Manager Manifest File dependencies: - espressif/esp_lvgl_port: "=2.4.1" + espressif/esp_lvgl_port: + git: https://github.com/espressif/esp-bsp.git + path: components/esp_lvgl_port + version: fix/lvgl_port_monochromatic_v9 ## LVGL 9 is blocked by https://github.com/espressif/esp-idf/issues/14784 lvgl/lvgl: - version: "^8" + version: "^9" public: true ## Required IDF version idf: diff --git a/main/logo.c b/main/logo.c index 926f96fde..d66b633b6 100644 --- a/main/logo.c +++ b/main/logo.c @@ -17,52 +17,48 @@ #define LV_ATTRIBUTE_MEM_ALIGN #endif -#ifndef LV_ATTRIBUTE_IMG_LOGO -#define LV_ATTRIBUTE_IMG_LOGO +#ifndef LV_ATTRIBUTE_IMAGE_LOGO +#define LV_ATTRIBUTE_IMAGE_LOGO #endif -const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_LOGO uint8_t logo_map[] = { - 0xff, 0xff, 0xff, 0xff, /*Color of index 0*/ - 0x00, 0x00, 0x00, 0xff, /*Color of index 1*/ - - 0b00000010, 0b00000000, 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, - 0b00000111, 0b00011100, 0b00000011, 0b10000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, - 0b00001111, 0b10111111, 0b10010111, 0b11000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, - 0b00011111, 0b11111111, 0b11100011, 0b10000000, 0b10000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, - 0b00100111, 0b11111111, 0b11000001, 0b00000001, 0b10000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, - 0b01000011, 0b11000111, 0b10000000, 0b00000011, 0b10000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, - 0b01000001, 0b11000011, 0b10000010, 0b00001111, 0b11100000, 0b01000000, 0b00010000, 0b00100000, 0b00000100, 0b00000000, - 0b10000001, 0b11000011, 0b10000111, 0b00011111, 0b11000000, 0b11111000, 0b00111000, 0b01110000, 0b00001111, 0b10001000, - 0b10000001, 0b11000011, 0b10001111, 0b11000111, 0b10000001, 0b11111111, 0b00111110, 0b01111100, 0b00011111, 0b11110000, - 0b10000001, 0b11000011, 0b10001111, 0b10000111, 0b10000011, 0b11111111, 0b01111100, 0b11111000, 0b01111111, 0b11100000, - 0b10000101, 0b11000011, 0b10000111, 0b10000111, 0b10001111, 0b00111110, 0b00111100, 0b01111000, 0b11110011, 0b11100000, - 0b01001001, 0b11001011, 0b10000111, 0b10000111, 0b10001111, 0b00011110, 0b00111100, 0b01111000, 0b11110001, 0b11110000, - 0b00110001, 0b11011111, 0b00100111, 0b10000111, 0b10000011, 0b00011110, 0b00111100, 0b01111000, 0b11110001, 0b11000000, - 0b00000001, 0b11011111, 0b11100111, 0b10000111, 0b10000001, 0b00011110, 0b00111100, 0b01111000, 0b11110001, 0b10000000, - 0b00000001, 0b11111111, 0b11000111, 0b10000111, 0b10000001, 0b10011110, 0b00111110, 0b01111000, 0b11110011, 0b00000000, - 0b00000001, 0b11000111, 0b10000111, 0b10000111, 0b10000000, 0b00011110, 0b00111111, 0b11100000, 0b11110110, 0b00000000, - 0b00000011, 0b11000011, 0b10001111, 0b11001111, 0b11000000, 0b01111111, 0b00111111, 0b11110101, 0b11111100, 0b00000000, - 0b00000001, 0b11000011, 0b10000111, 0b10000111, 0b10000000, 0b11011110, 0b01011111, 0b11111000, 0b11110000, 0b00000000, - 0b00000001, 0b11000011, 0b10000111, 0b10000111, 0b10000011, 0b10011110, 0b00001111, 0b11111000, 0b11110000, 0b00000000, - 0b00000001, 0b11000011, 0b10000111, 0b10000111, 0b10001111, 0b00011110, 0b00111100, 0b11111000, 0b11110000, 0b00010000, - 0b00000001, 0b11000011, 0b10000111, 0b10000111, 0b10001111, 0b00011110, 0b00111100, 0b01111000, 0b11110000, 0b00100000, - 0b00000001, 0b11000011, 0b10000111, 0b10000111, 0b10001111, 0b00011110, 0b00111100, 0b01111000, 0b11110000, 0b01100000, - 0b00001111, 0b11000011, 0b10000111, 0b10000111, 0b10001111, 0b00011110, 0b00111100, 0b01111000, 0b11110001, 0b11100000, - 0b00111111, 0b11000011, 0b11000111, 0b10000111, 0b10001111, 0b00011110, 0b00111100, 0b01111000, 0b11110001, 0b11100000, - 0b01111111, 0b11110011, 0b11000111, 0b10000111, 0b10001111, 0b11011110, 0b00111100, 0b01111000, 0b11111101, 0b11100000, - 0b11100111, 0b11111110, 0b00000111, 0b11100111, 0b11101111, 0b11111111, 0b00111110, 0b01111100, 0b11111111, 0b10000000, - 0b10000001, 0b11111100, 0b00000111, 0b11000111, 0b11001111, 0b11111110, 0b00111100, 0b01111000, 0b11111111, 0b00000000, - 0b10000000, 0b01111000, 0b00000011, 0b10000011, 0b10010011, 0b11101110, 0b00011000, 0b00110001, 0b00111110, 0b00000000, - 0b10000000, 0b00010000, 0b00000001, 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, - 0b01100000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, +const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMAGE_LOGO uint8_t logo_map[] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, }; -const lv_img_dsc_t logo = { - .header.cf = LV_IMG_CF_INDEXED_1BIT, - .header.always_zero = 0, - .header.reserved = 0, +const lv_image_dsc_t logo = { + .header.cf = LV_COLOR_FORMAT_RGB565, + .header.magic = LV_IMAGE_HEADER_MAGIC, .header.w = 77, .header.h = 30, - .data_size = 308, + .data_size = 2310 * 2, .data = logo_map, }; \ No newline at end of file diff --git a/main/lv_conf.h b/main/lv_conf.h index 0d49a2f46..d725a4ed3 100644 --- a/main/lv_conf.h +++ b/main/lv_conf.h @@ -1,6 +1,6 @@ /** * @file lv_conf.h - * Configuration file for v8.4.0 + * Configuration file for v9.2.2 */ /* @@ -17,39 +17,46 @@ #ifndef LV_CONF_H #define LV_CONF_H -#include +/*If you need to include anything here, do it inside the `__ASSEMBLY__` guard */ +#if 0 && defined(__ASSEMBLY__) +#include "my_include.h" +#endif /*==================== COLOR SETTINGS *====================*/ -/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/ -#define LV_COLOR_DEPTH 16 - -/*Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface (e.g. SPI)*/ -#define LV_COLOR_16_SWAP 0 +/*Color depth: 1 (I1), 8 (L8), 16 (RGB565), 24 (RGB888), 32 (XRGB8888)*/ +#define LV_COLOR_DEPTH 1 -/*Enable features to draw on transparent background. - *It's required if opa, and transform_* style properties are used. - *Can be also used if the UI is above another layer, e.g. an OSD menu or video player.*/ -#define LV_COLOR_SCREEN_TRANSP 0 +/*========================= + STDLIB WRAPPER SETTINGS + *=========================*/ -/* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently. - * 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */ -#define LV_COLOR_MIX_ROUND_OFS 0 +/* Possible values + * - LV_STDLIB_BUILTIN: LVGL's built in implementation + * - LV_STDLIB_CLIB: Standard C functions, like malloc, strlen, etc + * - LV_STDLIB_MICROPYTHON: MicroPython implementation + * - LV_STDLIB_RTTHREAD: RT-Thread implementation + * - LV_STDLIB_CUSTOM: Implement the functions externally + */ +#define LV_USE_STDLIB_MALLOC LV_STDLIB_BUILTIN +#define LV_USE_STDLIB_STRING LV_STDLIB_BUILTIN +#define LV_USE_STDLIB_SPRINTF LV_STDLIB_BUILTIN -/*Images pixels with this color will not be drawn if they are chroma keyed)*/ -#define LV_COLOR_CHROMA_KEY lv_color_hex(0x00ff00) /*pure green*/ +#define LV_STDINT_INCLUDE +#define LV_STDDEF_INCLUDE +#define LV_STDBOOL_INCLUDE +#define LV_INTTYPES_INCLUDE +#define LV_LIMITS_INCLUDE +#define LV_STDARG_INCLUDE -/*========================= - MEMORY SETTINGS - *=========================*/ +#if LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN + /*Size of the memory available for `lv_malloc()` in bytes (>= 2kB)*/ + #define LV_MEM_SIZE (64 * 1024U) /*[bytes]*/ -/*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/ -#define LV_MEM_CUSTOM 0 -#if LV_MEM_CUSTOM == 0 - /*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/ - #define LV_MEM_SIZE (48U * 1024U) /*[bytes]*/ + /*Size of the memory expand for `lv_malloc()` in bytes*/ + #define LV_MEM_POOL_EXPAND_SIZE 0 /*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/ #define LV_MEM_ADR 0 /*0: unused*/ @@ -58,173 +65,211 @@ #undef LV_MEM_POOL_INCLUDE #undef LV_MEM_POOL_ALLOC #endif - -#else /*LV_MEM_CUSTOM*/ - #define LV_MEM_CUSTOM_INCLUDE /*Header for the dynamic memory function*/ - #define LV_MEM_CUSTOM_ALLOC malloc - #define LV_MEM_CUSTOM_FREE free - #define LV_MEM_CUSTOM_REALLOC realloc -#endif /*LV_MEM_CUSTOM*/ - -/*Number of the intermediate memory buffer used during rendering and other internal processing mechanisms. - *You will see an error log message if there wasn't enough buffers. */ -#define LV_MEM_BUF_MAX_NUM 16 - -/*Use the standard `memcpy` and `memset` instead of LVGL's own functions. (Might or might not be faster).*/ -#define LV_MEMCPY_MEMSET_STD 0 +#endif /*LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN*/ /*==================== HAL SETTINGS *====================*/ -/*Default display refresh period. LVG will redraw changed areas with this period time*/ -#define LV_DISP_DEF_REFR_PERIOD 30 /*[ms]*/ - -/*Input device read period in milliseconds*/ -#define LV_INDEV_DEF_READ_PERIOD 30 /*[ms]*/ - -/*Use a custom tick source that tells the elapsed time in milliseconds. - *It removes the need to manually update the tick with `lv_tick_inc()`)*/ -#define LV_TICK_CUSTOM 0 -#if LV_TICK_CUSTOM - #define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/ - #define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/ - /*If using lvgl as ESP32 component*/ - // #define LV_TICK_CUSTOM_INCLUDE "esp_timer.h" - // #define LV_TICK_CUSTOM_SYS_TIME_EXPR ((esp_timer_get_time() / 1000LL)) -#endif /*LV_TICK_CUSTOM*/ +/*Default display refresh, input device read and animation step period.*/ +#define LV_DEF_REFR_PERIOD 33 /*[ms]*/ /*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings. *(Not so important, you can adjust it to modify default sizes and spaces)*/ #define LV_DPI_DEF 130 /*[px/inch]*/ -/*======================= - * FEATURE CONFIGURATION - *=======================*/ +/*================= + * OPERATING SYSTEM + *=================*/ +/*Select an operating system to use. Possible options: + * - LV_OS_NONE + * - LV_OS_PTHREAD + * - LV_OS_FREERTOS + * - LV_OS_CMSIS_RTOS2 + * - LV_OS_RTTHREAD + * - LV_OS_WINDOWS + * - LV_OS_MQX + * - LV_OS_CUSTOM */ +#define LV_USE_OS LV_OS_FREERTOS + +#if LV_USE_OS == LV_OS_CUSTOM + #define LV_OS_CUSTOM_INCLUDE +#endif +#if LV_USE_OS == LV_OS_FREERTOS + /* + * Unblocking an RTOS task with a direct notification is 45% faster and uses less RAM + * than unblocking a task using an intermediary object such as a binary semaphore. + * RTOS task notifications can only be used when there is only one task that can be the recipient of the event. + */ + #define LV_USE_FREERTOS_TASK_NOTIFY 1 +#endif -/*------------- - * Drawing - *-----------*/ +/*======================== + * RENDERING CONFIGURATION + *========================*/ -/*Enable complex draw engine. - *Required to draw shadow, gradient, rounded corners, circles, arc, skew lines, image transformations or any masks*/ -#define LV_DRAW_COMPLEX 0 -#if LV_DRAW_COMPLEX != 0 +/*Align the stride of all layers and images to this bytes*/ +#define LV_DRAW_BUF_STRIDE_ALIGN 1 - /*Allow buffering some shadow calculation. - *LV_SHADOW_CACHE_SIZE is the max. shadow size to buffer, where shadow size is `shadow_width + radius` - *Caching has LV_SHADOW_CACHE_SIZE^2 RAM cost*/ - #define LV_SHADOW_CACHE_SIZE 0 +/*Align the start address of draw_buf addresses to this bytes*/ +#define LV_DRAW_BUF_ALIGN 4 - /* Set number of maximally cached circle data. - * The circumference of 1/4 circle are saved for anti-aliasing - * radius * 4 bytes are used per circle (the most often used radiuses are saved) - * 0: to disable caching */ - #define LV_CIRCLE_CACHE_SIZE 4 -#endif /*LV_DRAW_COMPLEX*/ +/*Using matrix for transformations. + *Requirements: + `LV_USE_MATRIX = 1`. + The rendering engine needs to support 3x3 matrix transformations.*/ +#define LV_DRAW_TRANSFORM_USE_MATRIX 0 -/** - * "Simple layers" are used when a widget has `style_opa < 255` to buffer the widget into a layer - * and blend it as an image with the given opacity. - * Note that `bg_opa`, `text_opa` etc don't require buffering into layer) - * The widget can be buffered in smaller chunks to avoid using large buffers. - * - * - LV_LAYER_SIMPLE_BUF_SIZE: [bytes] the optimal target buffer size. LVGL will try to allocate it - * - LV_LAYER_SIMPLE_FALLBACK_BUF_SIZE: [bytes] used if `LV_LAYER_SIMPLE_BUF_SIZE` couldn't be allocated. - * - * Both buffer sizes are in bytes. - * "Transformed layers" (where transform_angle/zoom properties are used) use larger buffers - * and can't be drawn in chunks. So these settings affects only widgets with opacity. - */ -#define LV_LAYER_SIMPLE_BUF_SIZE (24 * 1024) -#define LV_LAYER_SIMPLE_FALLBACK_BUF_SIZE (3 * 1024) +/* If a widget has `style_opa < 255` (not `bg_opa`, `text_opa` etc) or not NORMAL blend mode + * it is buffered into a "simple" layer before rendering. The widget can be buffered in smaller chunks. + * "Transformed layers" (if `transform_angle/zoom` are set) use larger buffers + * and can't be drawn in chunks. */ -/*Default image cache size. Image caching keeps the images opened. - *If only the built-in image formats are used there is no real advantage of caching. (I.e. if no new image decoder is added) - *With complex image decoders (e.g. PNG or JPG) caching can save the continuous open/decode of images. - *However the opened images might consume additional RAM. - *0: to disable caching*/ -#define LV_IMG_CACHE_DEF_SIZE 0 +/*The target buffer size for simple layer chunks.*/ +#define LV_DRAW_LAYER_SIMPLE_BUF_SIZE (24 * 1024) /*[bytes]*/ -/*Number of stops allowed per gradient. Increase this to allow more stops. - *This adds (sizeof(lv_color_t) + 1) bytes per additional stop*/ -#define LV_GRADIENT_MAX_STOPS 2 - -/*Default gradient buffer size. - *When LVGL calculates the gradient "maps" it can save them into a cache to avoid calculating them again. - *LV_GRAD_CACHE_DEF_SIZE sets the size of this cache in bytes. - *If the cache is too small the map will be allocated only while it's required for the drawing. - *0 mean no caching.*/ -#define LV_GRAD_CACHE_DEF_SIZE 0 - -/*Allow dithering the gradients (to achieve visual smooth color gradients on limited color depth display) - *LV_DITHER_GRADIENT implies allocating one or two more lines of the object's rendering surface - *The increase in memory consumption is (32 bits * object width) plus 24 bits * object width if using error diffusion */ -#define LV_DITHER_GRADIENT 0 -#if LV_DITHER_GRADIENT - /*Add support for error diffusion dithering. - *Error diffusion dithering gets a much better visual result, but implies more CPU consumption and memory when drawing. - *The increase in memory consumption is (24 bits * object's width)*/ - #define LV_DITHER_ERROR_DIFFUSION 0 -#endif - -/*Maximum buffer size to allocate for rotation. - *Only used if software rotation is enabled in the display driver.*/ -#define LV_DISP_ROT_MAX_BUF (10*1024) +/* The stack size of the drawing thread. + * NOTE: If FreeType or ThorVG is enabled, it is recommended to set it to 32KB or more. + */ +#define LV_DRAW_THREAD_STACK_SIZE (8 * 1024) /*[bytes]*/ + +#define LV_USE_DRAW_SW 1 +#if LV_USE_DRAW_SW == 1 + + /* + * Selectively disable color format support in order to reduce code size. + * NOTE: some features use certain color formats internally, e.g. + * - gradients use RGB888 + * - bitmaps with transparency may use ARGB8888 + */ + + #define LV_DRAW_SW_SUPPORT_RGB565 1 + #define LV_DRAW_SW_SUPPORT_RGB565A8 0 + #define LV_DRAW_SW_SUPPORT_RGB888 0 + #define LV_DRAW_SW_SUPPORT_XRGB8888 0 + #define LV_DRAW_SW_SUPPORT_ARGB8888 0 + #define LV_DRAW_SW_SUPPORT_L8 0 + #define LV_DRAW_SW_SUPPORT_AL88 0 + #define LV_DRAW_SW_SUPPORT_A8 0 + #define LV_DRAW_SW_SUPPORT_I1 1 + + /* Set the number of draw unit. + * > 1 requires an operating system enabled in `LV_USE_OS` + * > 1 means multiple threads will render the screen in parallel */ + #define LV_DRAW_SW_DRAW_UNIT_CNT 1 + + /* Use Arm-2D to accelerate the sw render */ + #define LV_USE_DRAW_ARM2D_SYNC 0 + + /* Enable native helium assembly to be compiled */ + #define LV_USE_NATIVE_HELIUM_ASM 0 + + /* 0: use a simple renderer capable of drawing only simple rectangles with gradient, images, texts, and straight lines only + * 1: use a complex renderer capable of drawing rounded corners, shadow, skew lines, and arcs too */ + #define LV_DRAW_SW_COMPLEX 0 + + #if LV_DRAW_SW_COMPLEX == 1 + /*Allow buffering some shadow calculation. + *LV_DRAW_SW_SHADOW_CACHE_SIZE is the max. shadow size to buffer, where shadow size is `shadow_width + radius` + *Caching has LV_DRAW_SW_SHADOW_CACHE_SIZE^2 RAM cost*/ + #define LV_DRAW_SW_SHADOW_CACHE_SIZE 0 + + /* Set number of maximally cached circle data. + * The circumference of 1/4 circle are saved for anti-aliasing + * radius * 4 bytes are used per circle (the most often used radiuses are saved) + * 0: to disable caching */ + #define LV_DRAW_SW_CIRCLE_CACHE_SIZE 4 + #endif -/*------------- - * GPU - *-----------*/ + #define LV_USE_DRAW_SW_ASM LV_DRAW_SW_ASM_NONE -/*Use Arm's 2D acceleration library Arm-2D */ -#define LV_USE_GPU_ARM2D 0 + #if LV_USE_DRAW_SW_ASM == LV_DRAW_SW_ASM_CUSTOM + #define LV_DRAW_SW_ASM_CUSTOM_INCLUDE "" + #endif -/*Use STM32's DMA2D (aka Chrom Art) GPU*/ -#define LV_USE_GPU_STM32_DMA2D 0 -#if LV_USE_GPU_STM32_DMA2D - /*Must be defined to include path of CMSIS header of target processor - e.g. "stm32f7xx.h" or "stm32f4xx.h"*/ - #define LV_GPU_DMA2D_CMSIS_INCLUDE + /* Enable drawing complex gradients in software: linear at an angle, radial or conical */ + #define LV_USE_DRAW_SW_COMPLEX_GRADIENTS 0 #endif -/*Enable RA6M3 G2D GPU*/ -#define LV_USE_GPU_RA6M3_G2D 0 -#if LV_USE_GPU_RA6M3_G2D - /*include path of target processor - e.g. "hal_data.h"*/ - #define LV_GPU_RA6M3_G2D_INCLUDE "hal_data.h" -#endif +/* Use NXP's VG-Lite GPU on iMX RTxxx platforms. */ +#define LV_USE_DRAW_VGLITE 0 + +#if LV_USE_DRAW_VGLITE + /* Enable blit quality degradation workaround recommended for screen's dimension > 352 pixels. */ + #define LV_USE_VGLITE_BLIT_SPLIT 0 + + #if LV_USE_OS + /* Use additional draw thread for VG-Lite processing.*/ + #define LV_USE_VGLITE_DRAW_THREAD 1 -/*Use SWM341's DMA2D GPU*/ -#define LV_USE_GPU_SWM341_DMA2D 0 -#if LV_USE_GPU_SWM341_DMA2D - #define LV_GPU_SWM341_DMA2D_INCLUDE "SWM341.h" + #if LV_USE_VGLITE_DRAW_THREAD + /* Enable VGLite draw async. Queue multiple tasks and flash them once to the GPU. */ + #define LV_USE_VGLITE_DRAW_ASYNC 1 + #endif + #endif + + /* Enable VGLite asserts. */ + #define LV_USE_VGLITE_ASSERT 0 #endif -/*Use NXP's PXP GPU iMX RTxxx platforms*/ -#define LV_USE_GPU_NXP_PXP 0 -#if LV_USE_GPU_NXP_PXP - /*1: Add default bare metal and FreeRTOS interrupt handling routines for PXP (lv_gpu_nxp_pxp_osa.c) - * and call lv_gpu_nxp_pxp_init() automatically during lv_init(). Note that symbol SDK_OS_FREE_RTOS - * has to be defined in order to use FreeRTOS OSA, otherwise bare-metal implementation is selected. - *0: lv_gpu_nxp_pxp_init() has to be called manually before lv_init() - */ - #define LV_USE_GPU_NXP_PXP_AUTO_INIT 0 +/* Use NXP's PXP on iMX RTxxx platforms. */ +#define LV_USE_PXP 0 + +#if LV_USE_PXP + /* Use PXP for drawing.*/ + #define LV_USE_DRAW_PXP 1 + + /* Use PXP to rotate display.*/ + #define LV_USE_ROTATE_PXP 0 + + #if LV_USE_DRAW_PXP && LV_USE_OS + /* Use additional draw thread for PXP processing.*/ + #define LV_USE_PXP_DRAW_THREAD 1 + #endif + + /* Enable PXP asserts. */ + #define LV_USE_PXP_ASSERT 0 #endif -/*Use NXP's VG-Lite GPU iMX RTxxx platforms*/ -#define LV_USE_GPU_NXP_VG_LITE 0 +/* Use Renesas Dave2D on RA platforms. */ +#define LV_USE_DRAW_DAVE2D 0 + +/* Draw using cached SDL textures*/ +#define LV_USE_DRAW_SDL 0 + +/* Use VG-Lite GPU. */ +#define LV_USE_DRAW_VG_LITE 0 + +#if LV_USE_DRAW_VG_LITE + /* Enable VG-Lite custom external 'gpu_init()' function */ + #define LV_VG_LITE_USE_GPU_INIT 0 + + /* Enable VG-Lite assert. */ + #define LV_VG_LITE_USE_ASSERT 0 + + /* VG-Lite flush commit trigger threshold. GPU will try to batch these many draw tasks. */ + #define LV_VG_LITE_FLUSH_MAX_COUNT 8 + + /* Enable border to simulate shadow + * NOTE: which usually improves performance, + * but does not guarantee the same rendering quality as the software. */ + #define LV_VG_LITE_USE_BOX_SHADOW 0 + + /* VG-Lite gradient maximum cache number. + * NOTE: The memory usage of a single gradient image is 4K bytes. + */ + #define LV_VG_LITE_GRAD_CACHE_CNT 32 + + /* VG-Lite stroke maximum cache number. + */ + #define LV_VG_LITE_STROKE_CACHE_CNT 32 -/*Use SDL renderer API*/ -#define LV_USE_GPU_SDL 0 -#if LV_USE_GPU_SDL - #define LV_GPU_SDL_INCLUDE_PATH - /*Texture cache size, 8MB by default*/ - #define LV_GPU_SDL_LRU_SIZE (1024 * 1024 * 8) - /*Custom blend mode for mask drawing, disable if you need to link with older SDL2 lib*/ - #define LV_GPU_SDL_CUSTOM_BLEND_MODE (SDL_VERSION_ATLEAST(2, 0, 6)) #endif +/*======================= + * FEATURE CONFIGURATION + *=======================*/ + /*------------- * Logging *-----------*/ @@ -246,6 +291,20 @@ *0: User need to register a callback with `lv_log_register_print_cb()`*/ #define LV_LOG_PRINTF 0 + /*Set callback to print the logs. + *E.g `my_print`. The prototype should be `void my_print(lv_log_level_t level, const char * buf)` + *Can be overwritten by `lv_log_register_print_cb`*/ + //#define LV_LOG_PRINT_CB + + /*1: Enable print timestamp; + *0: Disable print timestamp*/ + #define LV_LOG_USE_TIMESTAMP 1 + + /*1: Print file and line number of the log; + *0: Do not print file and line number of the log*/ + #define LV_LOG_USE_FILE_LINE 1 + + /*Enable/disable LV_LOG_TRACE in modules that produces a huge number of logs*/ #define LV_LOG_TRACE_MEM 1 #define LV_LOG_TRACE_TIMER 1 @@ -255,6 +314,7 @@ #define LV_LOG_TRACE_OBJ_CREATE 1 #define LV_LOG_TRACE_LAYOUT 1 #define LV_LOG_TRACE_ANIM 1 + #define LV_LOG_TRACE_CACHE 1 #endif /*LV_USE_LOG*/ @@ -274,44 +334,97 @@ #define LV_ASSERT_HANDLER_INCLUDE #define LV_ASSERT_HANDLER while(1); /*Halt by default*/ +/*------------- + * Debug + *-----------*/ + +/*1: Draw random colored rectangles over the redrawn areas*/ +#define LV_USE_REFR_DEBUG 0 + +/*1: Draw a red overlay for ARGB layers and a green overlay for RGB layers*/ +#define LV_USE_LAYER_DEBUG 0 + +/*1: Draw overlays with different colors for each draw_unit's tasks. + *Also add the index number of the draw unit on white background. + *For layers add the index number of the draw unit on black background.*/ +#define LV_USE_PARALLEL_DRAW_DEBUG 0 + /*------------- * Others *-----------*/ -/*1: Show CPU usage and FPS count*/ -#define LV_USE_PERF_MONITOR 0 -#if LV_USE_PERF_MONITOR - #define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT +#define LV_ENABLE_GLOBAL_CUSTOM 0 +#if LV_ENABLE_GLOBAL_CUSTOM + /*Header to include for the custom 'lv_global' function"*/ + #define LV_GLOBAL_CUSTOM_INCLUDE #endif -/*1: Show the used memory and the memory fragmentation - * Requires LV_MEM_CUSTOM = 0*/ -#define LV_USE_MEM_MONITOR 0 -#if LV_USE_MEM_MONITOR - #define LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_LEFT -#endif +/*Default cache size in bytes. + *Used by image decoders such as `lv_lodepng` to keep the decoded image in the memory. + *If size is not set to 0, the decoder will fail to decode when the cache is full. + *If size is 0, the cache function is not enabled and the decoded mem will be released immediately after use.*/ +#define LV_CACHE_DEF_SIZE 0 -/*1: Draw random colored rectangles over the redrawn areas*/ -#define LV_USE_REFR_DEBUG 0 +/*Default number of image header cache entries. The cache is used to store the headers of images + *The main logic is like `LV_CACHE_DEF_SIZE` but for image headers.*/ +#define LV_IMAGE_HEADER_CACHE_DEF_CNT 0 + +/*Number of stops allowed per gradient. Increase this to allow more stops. + *This adds (sizeof(lv_color_t) + 1) bytes per additional stop*/ +#define LV_GRADIENT_MAX_STOPS 2 + +/* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently. + * 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */ +#define LV_COLOR_MIX_ROUND_OFS 0 + +/* Add 2 x 32 bit variables to each lv_obj_t to speed up getting style properties */ +#define LV_OBJ_STYLE_CACHE 0 + +/* Add `id` field to `lv_obj_t` */ +#define LV_USE_OBJ_ID 0 + +/* Automatically assign an ID when obj is created */ +#define LV_OBJ_ID_AUTO_ASSIGN LV_USE_OBJ_ID -/*Change the built in (v)snprintf functions*/ -#define LV_SPRINTF_CUSTOM 0 -#if LV_SPRINTF_CUSTOM - #define LV_SPRINTF_INCLUDE - #define lv_snprintf snprintf - #define lv_vsnprintf vsnprintf -#else /*LV_SPRINTF_CUSTOM*/ - #define LV_SPRINTF_USE_FLOAT 0 -#endif /*LV_SPRINTF_CUSTOM*/ - -#define LV_USE_USER_DATA 1 - -/*Garbage Collector settings - *Used if lvgl is bound to higher level language and the memory is managed by that language*/ -#define LV_ENABLE_GC 0 -#if LV_ENABLE_GC != 0 - #define LV_GC_INCLUDE "gc.h" /*Include Garbage Collector related things*/ -#endif /*LV_ENABLE_GC*/ +/*Use the builtin obj ID handler functions: +* - lv_obj_assign_id: Called when a widget is created. Use a separate counter for each widget class as an ID. +* - lv_obj_id_compare: Compare the ID to decide if it matches with a requested value. +* - lv_obj_stringify_id: Return e.g. "button3" +* - lv_obj_free_id: Does nothing, as there is no memory allocation for the ID. +* When disabled these functions needs to be implemented by the user.*/ +#define LV_USE_OBJ_ID_BUILTIN 1 + +/*Use obj property set/get API*/ +#define LV_USE_OBJ_PROPERTY 0 + +/*Enable property name support*/ +#define LV_USE_OBJ_PROPERTY_NAME 1 + +/* VG-Lite Simulator */ +/*Requires: LV_USE_THORVG_INTERNAL or LV_USE_THORVG_EXTERNAL */ +#define LV_USE_VG_LITE_THORVG 0 + +#if LV_USE_VG_LITE_THORVG + + /*Enable LVGL's blend mode support*/ + #define LV_VG_LITE_THORVG_LVGL_BLEND_SUPPORT 0 + + /*Enable YUV color format support*/ + #define LV_VG_LITE_THORVG_YUV_SUPPORT 0 + + /*Enable Linear gradient extension support*/ + #define LV_VG_LITE_THORVG_LINEAR_GRADIENT_EXT_SUPPORT 0 + + /*Enable 16 pixels alignment*/ + #define LV_VG_LITE_THORVG_16PIXELS_ALIGN 1 + + /*Buffer address alignment*/ + #define LV_VG_LITE_THORVG_BUF_ADDR_ALIGN 64 + + /*Enable multi-thread render*/ + #define LV_VG_LITE_THORVG_THREAD_RENDER 0 + +#endif /*===================== * COMPILER SETTINGS @@ -326,7 +439,7 @@ /*Define a custom attribute to `lv_timer_handler` function*/ #define LV_ATTRIBUTE_TIMER_HANDLER -/*Define a custom attribute to `lv_disp_flush_ready` function*/ +/*Define a custom attribute to `lv_display_flush_ready` function*/ #define LV_ATTRIBUTE_FLUSH_READY /*Required alignment size for buffers*/ @@ -345,15 +458,22 @@ /*Place performance critical functions into a faster memory (e.g RAM)*/ #define LV_ATTRIBUTE_FAST_MEM -/*Prefix variables that are used in GPU accelerated operations, often these need to be placed in RAM sections that are DMA accessible*/ -#define LV_ATTRIBUTE_DMA - /*Export integer constant to binding. This macro is used with constants in the form of LV_ that - *should also appear on LVGL binding API such as Micropython.*/ + *should also appear on LVGL binding API such as MicroPython.*/ #define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning /*The default value just prevents GCC warning*/ -/*Extend the default -32k..32k coordinate range to -4M..4M by using int32_t for coordinates instead of int16_t*/ -#define LV_USE_LARGE_COORD 0 +/*Prefix all global extern data with this*/ +#define LV_ATTRIBUTE_EXTERN_DATA + +/* Use `float` as `lv_value_precise_t` */ +#define LV_USE_FLOAT 0 + +/*Enable matrix support + *Requires `LV_USE_FLOAT = 1`*/ +#define LV_USE_MATRIX 0 + +/*Include `lvgl_private.h` in `lvgl.h` to access internal data and functions by default*/ +#define LV_USE_PRIVATE_API 0 /*================== * FONT USAGE @@ -384,9 +504,9 @@ #define LV_FONT_MONTSERRAT_48 0 /*Demonstrate special features*/ -#define LV_FONT_MONTSERRAT_12_SUBPX 0 #define LV_FONT_MONTSERRAT_28_COMPRESSED 0 /*bpp = 3*/ #define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 0 /*Hebrew, Arabic, Persian letters and all their forms*/ +#define LV_FONT_SIMSUN_14_CJK 0 /*1000 most common CJK radicals*/ #define LV_FONT_SIMSUN_16_CJK 0 /*1000 most common CJK radicals*/ /*Pixel perfect monospace fonts*/ @@ -409,13 +529,6 @@ /*Enables/disables support for compressed fonts.*/ #define LV_USE_FONT_COMPRESSED 0 -/*Enable subpixel rendering*/ -#define LV_USE_FONT_SUBPX 0 -#if LV_USE_FONT_SUBPX - /*Set the pixel order of the display. Physical order of RGB channels. Doesn't matter with "normal" fonts.*/ - #define LV_FONT_SUBPX_BGR 0 /*0: RGB; 1:BGR order*/ -#endif - /*Enable drawing placeholders when glyph dsc is not found*/ #define LV_USE_FONT_PLACEHOLDER 0 @@ -432,7 +545,7 @@ #define LV_TXT_ENC LV_TXT_ENC_UTF8 /*Can break (wrap) texts on these chars*/ -#define LV_TXT_BREAK_CHARS " ,.;:-_" +#define LV_TXT_BREAK_CHARS " ,.;:-_)]}" /*If a word is at least this long, will break wherever "prettiest" *To disable, set to a value <= 0*/ @@ -446,9 +559,6 @@ *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ #define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3 -/*The control character to use for signalling text recoloring.*/ -#define LV_TXT_COLOR_CMD "#" - /*Support bidirectional texts. Allows mixing Left-to-Right and Right-to-Left texts. *The direction will be processed according to the Unicode Bidirectional Algorithm: *https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ @@ -462,63 +572,26 @@ #endif /*Enable Arabic/Persian processing - *In these languages characters should be replaced with an other form based on their position in the text*/ + *In these languages characters should be replaced with another form based on their position in the text*/ #define LV_USE_ARABIC_PERSIAN_CHARS 0 /*================== - * WIDGET USAGE + * WIDGETS *================*/ /*Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.html*/ -#define LV_USE_ARC 0 - -#define LV_USE_BAR 0 - -#define LV_USE_BTN 0 - -#define LV_USE_BTNMATRIX 0 - -#define LV_USE_CANVAS 0 - -#define LV_USE_CHECKBOX 0 - -#define LV_USE_DROPDOWN 0 /*Requires: lv_label*/ - -#define LV_USE_IMG 1 /*Requires: lv_label*/ +#define LV_WIDGETS_HAS_DEFAULT_VALUE 0 -#define LV_USE_LABEL 1 -#if LV_USE_LABEL - #define LV_LABEL_TEXT_SELECTION 0 /*Enable selecting text of the label*/ - #define LV_LABEL_LONG_TXT_HINT 0 /*Store some extra info in labels to speed up drawing of very long texts*/ -#endif - -#define LV_USE_LINE 0 - -#define LV_USE_ROLLER 0 /*Requires: lv_label*/ -#if LV_USE_ROLLER - #define LV_ROLLER_INF_PAGES 7 /*Number of extra "pages" when the roller is infinite*/ -#endif - -#define LV_USE_SLIDER 0 /*Requires: lv_bar*/ - -#define LV_USE_SWITCH 0 +#define LV_USE_ANIMIMG 0 -#define LV_USE_TEXTAREA 0 /*Requires: lv_label*/ -#if LV_USE_TEXTAREA != 0 - #define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/ -#endif +#define LV_USE_ARC 0 -#define LV_USE_TABLE 0 +#define LV_USE_BAR 0 -/*================== - * EXTRA COMPONENTS - *==================*/ +#define LV_USE_BUTTON 0 -/*----------- - * Widgets - *----------*/ -#define LV_USE_ANIMIMG 0 +#define LV_USE_BUTTONMATRIX 0 #define LV_USE_CALENDAR 0 #if LV_USE_CALENDAR @@ -532,26 +605,48 @@ #define LV_CALENDAR_DEFAULT_MONTH_NAMES {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"} #define LV_USE_CALENDAR_HEADER_ARROW 1 #define LV_USE_CALENDAR_HEADER_DROPDOWN 1 + #define LV_USE_CALENDAR_CHINESE 0 #endif /*LV_USE_CALENDAR*/ +#define LV_USE_CANVAS 0 + #define LV_USE_CHART 0 -#define LV_USE_COLORWHEEL 0 +#define LV_USE_CHECKBOX 0 + +#define LV_USE_DROPDOWN 0 /*Requires: lv_label*/ + +#define LV_USE_IMAGE 1 /*Requires: lv_label*/ -#define LV_USE_IMGBTN 0 +#define LV_USE_IMAGEBUTTON 0 #define LV_USE_KEYBOARD 0 +#define LV_USE_LABEL 1 +#if LV_USE_LABEL + #define LV_LABEL_TEXT_SELECTION 1 /*Enable selecting text of the label*/ + #define LV_LABEL_LONG_TXT_HINT 1 /*Store some extra info in labels to speed up drawing of very long texts*/ + #define LV_LABEL_WAIT_CHAR_COUNT 3 /*The count of wait chart*/ +#endif + #define LV_USE_LED 0 +#define LV_USE_LINE 0 + #define LV_USE_LIST 0 -#define LV_USE_MENU 0 +#define LV_USE_LOTTIE 0 /*Requires: lv_canvas, thorvg */ -#define LV_USE_METER 0 +#define LV_USE_MENU 0 #define LV_USE_MSGBOX 0 +#define LV_USE_ROLLER 0 /*Requires: lv_label*/ + +#define LV_USE_SCALE 0 + +#define LV_USE_SLIDER 0 /*Requires: lv_bar*/ + #define LV_USE_SPAN 0 #if LV_USE_SPAN /*A line text can contain maximum num of span descriptor */ @@ -562,15 +657,24 @@ #define LV_USE_SPINNER 0 +#define LV_USE_SWITCH 0 + +#define LV_USE_TEXTAREA 0 /*Requires: lv_label*/ +#if LV_USE_TEXTAREA != 0 + #define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/ +#endif + +#define LV_USE_TABLE 0 + #define LV_USE_TABVIEW 0 #define LV_USE_TILEVIEW 0 #define LV_USE_WIN 0 -/*----------- - * Themes - *----------*/ +/*================== + * THEMES + *==================*/ /*A simple, impressive and very complete theme*/ #define LV_USE_THEME_DEFAULT 0 @@ -587,14 +691,14 @@ #endif /*LV_USE_THEME_DEFAULT*/ /*A very simple theme that is a good starting point for a custom theme*/ -#define LV_USE_THEME_BASIC 0 +#define LV_USE_THEME_SIMPLE 0 /*A theme designed for monochrome displays*/ #define LV_USE_THEME_MONO 0 -/*----------- - * Layouts - *----------*/ +/*================== + * LAYOUTS + *==================*/ /*A layout similar to Flexbox in CSS.*/ #define LV_USE_FLEX 1 @@ -602,12 +706,15 @@ /*A layout similar to Grid in CSS.*/ #define LV_USE_GRID 1 -/*--------------------- - * 3rd party libraries - *--------------------*/ +/*==================== + * 3RD PARTS LIBRARIES + *====================*/ /*File system interfaces for common APIs */ +/*Setting a default driver letter allows skipping the driver prefix in filepaths*/ +#define LV_FS_DEFAULT_DRIVE_LETTER '\0' + /*API for fopen, fread, etc*/ #define LV_USE_FS_STDIO 0 #if LV_USE_FS_STDIO @@ -639,56 +746,105 @@ #define LV_FS_FATFS_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ #endif -/*API for LittleFS (library needs to be added separately). Uses lfs_file_open, lfs_file_read, etc*/ +/*API for memory-mapped file access. */ +#define LV_USE_FS_MEMFS 0 +#if LV_USE_FS_MEMFS + #define LV_FS_MEMFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ +#endif + +/*API for LittleFs. */ #define LV_USE_FS_LITTLEFS 0 #if LV_USE_FS_LITTLEFS #define LV_FS_LITTLEFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ - #define LV_FS_LITTLEFS_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ #endif -/*PNG decoder library*/ -#define LV_USE_PNG 0 +/*API for Arduino LittleFs. */ +#define LV_USE_FS_ARDUINO_ESP_LITTLEFS 0 +#if LV_USE_FS_ARDUINO_ESP_LITTLEFS + #define LV_FS_ARDUINO_ESP_LITTLEFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ +#endif + +/*API for Arduino Sd. */ +#define LV_USE_FS_ARDUINO_SD 0 +#if LV_USE_FS_ARDUINO_SD + #define LV_FS_ARDUINO_SD_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ +#endif + +/*LODEPNG decoder library*/ +#define LV_USE_LODEPNG 0 + +/*PNG decoder(libpng) library*/ +#define LV_USE_LIBPNG 0 /*BMP decoder library*/ #define LV_USE_BMP 0 /* JPG + split JPG decoder library. * Split JPG is a custom format optimized for embedded systems. */ -#define LV_USE_SJPG 0 +#define LV_USE_TJPGD 0 + +/* libjpeg-turbo decoder library. + * Supports complete JPEG specifications and high-performance JPEG decoding. */ +#define LV_USE_LIBJPEG_TURBO 0 /*GIF decoder library*/ #define LV_USE_GIF 0 +#if LV_USE_GIF + /*GIF decoder accelerate*/ + #define LV_GIF_CACHE_DECODE_DATA 0 +#endif + + +/*Decode bin images to RAM*/ +#define LV_BIN_DECODER_RAM_LOAD 0 + +/*RLE decompress library*/ +#define LV_USE_RLE 0 /*QR code library*/ #define LV_USE_QRCODE 0 +/*Barcode code library*/ +#define LV_USE_BARCODE 0 + /*FreeType library*/ #define LV_USE_FREETYPE 0 #if LV_USE_FREETYPE - /*Memory used by FreeType to cache characters [bytes] (-1: no caching)*/ - #define LV_FREETYPE_CACHE_SIZE (16 * 1024) - #if LV_FREETYPE_CACHE_SIZE >= 0 - /* 1: bitmap cache use the sbit cache, 0:bitmap cache use the image cache. */ - /* sbit cache:it is much more memory efficient for small bitmaps(font size < 256) */ - /* if font size >= 256, must be configured as image cache */ - #define LV_FREETYPE_SBIT_CACHE 0 - /* Maximum number of opened FT_Face/FT_Size objects managed by this cache instance. */ - /* (0:use system defaults) */ - #define LV_FREETYPE_CACHE_FT_FACES 0 - #define LV_FREETYPE_CACHE_FT_SIZES 0 - #endif + /*Let FreeType to use LVGL memory and file porting*/ + #define LV_FREETYPE_USE_LVGL_PORT 0 + + /*Cache count of the glyphs in FreeType. It means the number of glyphs that can be cached. + *The higher the value, the more memory will be used.*/ + #define LV_FREETYPE_CACHE_FT_GLYPH_CNT 256 #endif -/*Tiny TTF library*/ +/* Built-in TTF decoder */ #define LV_USE_TINY_TTF 0 #if LV_USE_TINY_TTF - /*Load TTF data from files*/ + /* Enable loading TTF data from files */ #define LV_TINY_TTF_FILE_SUPPORT 0 + #define LV_TINY_TTF_CACHE_GLYPH_CNT 256 #endif /*Rlottie library*/ #define LV_USE_RLOTTIE 0 +/*Enable Vector Graphic APIs + *Requires `LV_USE_MATRIX = 1`*/ +#define LV_USE_VECTOR_GRAPHIC 0 + +/* Enable ThorVG (vector graphics library) from the src/libs folder */ +#define LV_USE_THORVG_INTERNAL 0 + +/* Enable ThorVG by assuming that its installed and linked to the project */ +#define LV_USE_THORVG_EXTERNAL 0 + +/*Use lvgl built-in LZ4 lib*/ +#define LV_USE_LZ4_INTERNAL 0 + +/*Use external LZ4 library*/ +#define LV_USE_LZ4_EXTERNAL 0 + /*FFmpeg library for image decoding and playing videos *Supports all major image formats so do not enable other image decoder with it*/ #define LV_USE_FFMPEG 0 @@ -697,11 +853,64 @@ #define LV_FFMPEG_DUMP_FORMAT 0 #endif -/*----------- - * Others - *----------*/ +/*================== + * OTHERS + *==================*/ /*1: Enable API to take snapshot for object*/ +#define LV_USE_SNAPSHOT 0 + +/*1: Enable system monitor component*/ +#define LV_USE_SYSMON 0 +#if LV_USE_SYSMON + /*Get the idle percentage. E.g. uint32_t my_get_idle(void);*/ + #define LV_SYSMON_GET_IDLE lv_timer_get_idle + + /*1: Show CPU usage and FPS count + * Requires `LV_USE_SYSMON = 1`*/ + #define LV_USE_PERF_MONITOR 0 + #if LV_USE_PERF_MONITOR + #define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT + + /*0: Displays performance data on the screen, 1: Prints performance data using log.*/ + #define LV_USE_PERF_MONITOR_LOG_MODE 0 + #endif + + /*1: Show the used memory and the memory fragmentation + * Requires `LV_USE_STDLIB_MALLOC = LV_STDLIB_BUILTIN` + * Requires `LV_USE_SYSMON = 1`*/ + #define LV_USE_MEM_MONITOR 0 + #if LV_USE_MEM_MONITOR + #define LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_LEFT + #endif + +#endif /*LV_USE_SYSMON*/ + +/*1: Enable the runtime performance profiler*/ +#define LV_USE_PROFILER 0 +#if LV_USE_PROFILER + /*1: Enable the built-in profiler*/ + #define LV_USE_PROFILER_BUILTIN 1 + #if LV_USE_PROFILER_BUILTIN + /*Default profiler trace buffer size*/ + #define LV_PROFILER_BUILTIN_BUF_SIZE (16 * 1024) /*[bytes]*/ + #endif + + /*Header to include for the profiler*/ + #define LV_PROFILER_INCLUDE "lvgl/src/misc/lv_profiler_builtin.h" + + /*Profiler start point function*/ + #define LV_PROFILER_BEGIN LV_PROFILER_BUILTIN_BEGIN + + /*Profiler end point function*/ + #define LV_PROFILER_END LV_PROFILER_BUILTIN_END + + /*Profiler start point function with custom tag*/ + #define LV_PROFILER_BEGIN_TAG LV_PROFILER_BUILTIN_BEGIN_TAG + + /*Profiler end point function with custom tag*/ + #define LV_PROFILER_END_TAG LV_PROFILER_BUILTIN_END_TAG +#endif /*1: Enable Monkey test*/ #define LV_USE_MONKEY 0 @@ -715,15 +924,15 @@ /*1: Support using images as font in label or span widgets */ #define LV_USE_IMGFONT 0 -/*1: Enable a published subscriber based messaging system */ -#define LV_USE_MSG 0 +/*1: Enable an observer pattern implementation*/ +#define LV_USE_OBSERVER 1 /*1: Enable Pinyin input method*/ /*Requires: lv_keyboard*/ #define LV_USE_IME_PINYIN 0 #if LV_USE_IME_PINYIN /*1: Use default thesaurus*/ - /*If you do not use the default thesaurus, be sure to use `lv_ime_pinyin` after setting the thesauruss*/ + /*If you do not use the default thesaurus, be sure to use `lv_ime_pinyin` after setting the thesaurus*/ #define LV_IME_PINYIN_USE_DEFAULT_DICT 1 /*Set the maximum number of candidate panels that can be displayed*/ /*This needs to be adjusted according to the size of the screen*/ @@ -733,7 +942,131 @@ #define LV_IME_PINYIN_USE_K9_MODE 1 #if LV_IME_PINYIN_USE_K9_MODE == 1 #define LV_IME_PINYIN_K9_CAND_TEXT_NUM 3 - #endif // LV_IME_PINYIN_USE_K9_MODE + #endif /*LV_IME_PINYIN_USE_K9_MODE*/ +#endif + +/*1: Enable file explorer*/ +/*Requires: lv_table*/ +#define LV_USE_FILE_EXPLORER 0 +#if LV_USE_FILE_EXPLORER + /*Maximum length of path*/ + #define LV_FILE_EXPLORER_PATH_MAX_LEN (128) + /*Quick access bar, 1:use, 0:not use*/ + /*Requires: lv_list*/ + #define LV_FILE_EXPLORER_QUICK_ACCESS 1 +#endif + +/*================== + * DEVICES + *==================*/ + +/*Use SDL to open window on PC and handle mouse and keyboard*/ +#define LV_USE_SDL 0 +#if LV_USE_SDL + #define LV_SDL_INCLUDE_PATH + #define LV_SDL_RENDER_MODE LV_DISPLAY_RENDER_MODE_DIRECT /*LV_DISPLAY_RENDER_MODE_DIRECT is recommended for best performance*/ + #define LV_SDL_BUF_COUNT 1 /*1 or 2*/ + #define LV_SDL_ACCELERATED 1 /*1: Use hardware acceleration*/ + #define LV_SDL_FULLSCREEN 0 /*1: Make the window full screen by default*/ + #define LV_SDL_DIRECT_EXIT 1 /*1: Exit the application when all SDL windows are closed*/ + #define LV_SDL_MOUSEWHEEL_MODE LV_SDL_MOUSEWHEEL_MODE_ENCODER /*LV_SDL_MOUSEWHEEL_MODE_ENCODER/CROWN*/ +#endif + +/*Use X11 to open window on Linux desktop and handle mouse and keyboard*/ +#define LV_USE_X11 0 +#if LV_USE_X11 + #define LV_X11_DIRECT_EXIT 1 /*Exit the application when all X11 windows have been closed*/ + #define LV_X11_DOUBLE_BUFFER 1 /*Use double buffers for rendering*/ + /*select only 1 of the following render modes (LV_X11_RENDER_MODE_PARTIAL preferred!)*/ + #define LV_X11_RENDER_MODE_PARTIAL 1 /*Partial render mode (preferred)*/ + #define LV_X11_RENDER_MODE_DIRECT 0 /*direct render mode*/ + #define LV_X11_RENDER_MODE_FULL 0 /*Full render mode*/ +#endif + +/*Use Wayland to open a window and handle input on Linux or BSD desktops */ +#define LV_USE_WAYLAND 0 +#if LV_USE_WAYLAND + #define LV_WAYLAND_WINDOW_DECORATIONS 0 /*Draw client side window decorations only necessary on Mutter/GNOME*/ + #define LV_WAYLAND_WL_SHELL 0 /*Use the legacy wl_shell protocol instead of the default XDG shell*/ +#endif + +/*Driver for /dev/fb*/ +#define LV_USE_LINUX_FBDEV 0 +#if LV_USE_LINUX_FBDEV + #define LV_LINUX_FBDEV_BSD 0 + #define LV_LINUX_FBDEV_RENDER_MODE LV_DISPLAY_RENDER_MODE_PARTIAL + #define LV_LINUX_FBDEV_BUFFER_COUNT 0 + #define LV_LINUX_FBDEV_BUFFER_SIZE 60 +#endif + +/*Use Nuttx to open window and handle touchscreen*/ +#define LV_USE_NUTTX 0 + +#if LV_USE_NUTTX + #define LV_USE_NUTTX_LIBUV 0 + + /*Use Nuttx custom init API to open window and handle touchscreen*/ + #define LV_USE_NUTTX_CUSTOM_INIT 0 + + /*Driver for /dev/lcd*/ + #define LV_USE_NUTTX_LCD 0 + #if LV_USE_NUTTX_LCD + #define LV_NUTTX_LCD_BUFFER_COUNT 0 + #define LV_NUTTX_LCD_BUFFER_SIZE 60 + #endif + + /*Driver for /dev/input*/ + #define LV_USE_NUTTX_TOUCHSCREEN 0 + +#endif + +/*Driver for /dev/dri/card*/ +#define LV_USE_LINUX_DRM 0 + +/*Interface for TFT_eSPI*/ +#define LV_USE_TFT_ESPI 0 + +/*Driver for evdev input devices*/ +#define LV_USE_EVDEV 0 + +/*Driver for libinput input devices*/ +#define LV_USE_LIBINPUT 0 + +#if LV_USE_LIBINPUT + #define LV_LIBINPUT_BSD 0 + + /*Full keyboard support*/ + #define LV_LIBINPUT_XKB 0 + #if LV_LIBINPUT_XKB + /*"setxkbmap -query" can help find the right values for your keyboard*/ + #define LV_LIBINPUT_XKB_KEY_MAP { .rules = NULL, .model = "pc101", .layout = "us", .variant = NULL, .options = NULL } + #endif +#endif + +/*Drivers for LCD devices connected via SPI/parallel port*/ +#define LV_USE_ST7735 0 +#define LV_USE_ST7789 0 +#define LV_USE_ST7796 0 +#define LV_USE_ILI9341 0 + +#define LV_USE_GENERIC_MIPI (LV_USE_ST7735 | LV_USE_ST7789 | LV_USE_ST7796 | LV_USE_ILI9341) + +/*Driver for Renesas GLCD*/ +#define LV_USE_RENESAS_GLCDC 0 + +/* LVGL Windows backend */ +#define LV_USE_WINDOWS 0 + +/* Use OpenGL to open window on PC and handle mouse and keyboard */ +#define LV_USE_OPENGLES 0 +#if LV_USE_OPENGLES + #define LV_USE_OPENGLES_DEBUG 1 /* Enable or disable debug for opengles */ +#endif + +/* QNX Screen display and input drivers */ +#define LV_USE_QNX 0 +#if LV_USE_QNX + #define LV_QNX_BUF_COUNT 1 /*1 or 2*/ #endif /*================== @@ -749,19 +1082,15 @@ /*Show some widget. It might be required to increase `LV_MEM_SIZE` */ #define LV_USE_DEMO_WIDGETS 0 -#if LV_USE_DEMO_WIDGETS -#define LV_DEMO_WIDGETS_SLIDESHOW 0 -#endif /*Demonstrate the usage of encoder and keyboard*/ #define LV_USE_DEMO_KEYPAD_AND_ENCODER 0 /*Benchmark your system*/ #define LV_USE_DEMO_BENCHMARK 0 -#if LV_USE_DEMO_BENCHMARK -/*Use RGB565A8 images with 16 bit color depth instead of ARGB8565*/ -#define LV_DEMO_BENCHMARK_RGB565A8 0 -#endif + +/*Render test for each primitives. Requires at least 480x272 display*/ +#define LV_USE_DEMO_RENDER 0 /*Stress test for LVGL*/ #define LV_USE_DEMO_STRESS 0 @@ -776,6 +1105,21 @@ #define LV_DEMO_MUSIC_AUTO_PLAY 0 #endif +/*Flex layout demo*/ +#define LV_USE_DEMO_FLEX_LAYOUT 0 + +/*Smart-phone like multi-language demo*/ +#define LV_USE_DEMO_MULTILANG 0 + +/*Widget transformation demo*/ +#define LV_USE_DEMO_TRANSFORM 0 + +/*Demonstrate scroll settings*/ +#define LV_USE_DEMO_SCROLL 0 + +/*Vector graphic demo*/ +#define LV_USE_DEMO_VECTOR_GRAPHIC 0 + /*--END OF LV_CONF_H--*/ #endif /*LV_CONF_H*/ From 6397fa48ec0896daf1759df6e24efc7021a8e46a Mon Sep 17 00:00:00 2001 From: mutatrum Date: Sat, 30 Nov 2024 14:22:01 +0100 Subject: [PATCH 09/23] LVGL all the things! * Button input handle by LVGL * All screen related code into screen.c * Screen class handles boot, config, logo and carousel * Scrolling long lines * Add live updating stats * Add screen transition animations --- main/CMakeLists.txt | 3 +- main/display.c | 80 ++------ main/display.h | 3 - main/global_state.h | 9 + main/idf_component.yml | 10 +- main/input.c | 68 +++++++ main/input.h | 6 + main/lv_conf.h | 2 +- main/main.c | 6 +- main/screen.c | 305 +++++++++++++++++++++++++++++ main/screen.h | 22 +++ main/self_test/self_test.c | 5 + main/system.c | 248 +---------------------- main/system.h | 4 - main/tasks/power_management_task.c | 9 + main/tasks/user_input_task.c | 48 ----- main/tasks/user_input_task.h | 6 - 17 files changed, 458 insertions(+), 376 deletions(-) create mode 100644 main/input.c create mode 100644 main/input.h create mode 100644 main/screen.c create mode 100644 main/screen.h delete mode 100644 main/tasks/user_input_task.c delete mode 100644 main/tasks/user_input_task.h diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 629c74449..e4e4d90b4 100755 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -9,6 +9,8 @@ SRCS "main.c" "nvs_config.c" "display.c" + "screen.c" + "input.c" "system.c" "TPS546.c" "vcore.c" @@ -22,7 +24,6 @@ SRCS "./tasks/create_jobs_task.c" "./tasks/asic_task.c" "./tasks/asic_result_task.c" - "./tasks/user_input_task.c" "./tasks/power_management_task.c" INCLUDE_DIRS diff --git a/main/display.c b/main/display.c index 93638d1e8..05ddae1da 100644 --- a/main/display.c +++ b/main/display.c @@ -8,6 +8,7 @@ #include "esp_log.h" #include "esp_check.h" #include "lvgl.h" +#include "lvgl__lvgl/src/themes/lv_theme_private.h" #include "esp_lvgl_port.h" #include "nvs_config.h" #include "i2c_bitaxe.h" @@ -26,9 +27,16 @@ static bool is_display_active = false; static const char * TAG = "display"; -static lv_style_t style; +static lv_theme_t theme; +static lv_style_t scr_style; + extern const lv_font_t lv_font_portfolio_6x8; -extern const lv_img_dsc_t logo; + +static void theme_apply(lv_theme_t *theme, lv_obj_t *obj) { + if (lv_obj_get_parent(obj) == NULL) { + lv_obj_add_style(obj, &scr_style, LV_PART_MAIN); + } +} esp_err_t display_init(void) { @@ -69,8 +77,6 @@ esp_err_t display_init(void) // ESP_RETURN_ON_ERROR(esp_lcd_panel_mirror(panel_handle, false, false), TAG, "Panel mirror failed"); ESP_RETURN_ON_ERROR(esp_lcd_panel_invert_color(panel_handle, invert_screen), TAG, "Panel invert failed"); - ESP_RETURN_ON_ERROR(esp_lcd_panel_disp_on_off(panel_handle, true), TAG, "Panel display on failed"); - ESP_LOGI(TAG, "Initialize LVGL"); const lvgl_port_cfg_t lvgl_cfg = ESP_LVGL_PORT_INIT_CONFIG(); ESP_RETURN_ON_ERROR(lvgl_port_init(&lvgl_cfg), TAG, "LVGL init failed"); @@ -94,18 +100,22 @@ esp_err_t display_init(void) .sw_rotate = false, } }; - lvgl_port_add_disp(&disp_cfg); - lv_style_init(&style); - lv_style_set_text_font(&style, &lv_font_portfolio_6x8); - lv_style_set_bg_opa(&style, LV_OPA_COVER); + lv_style_init(&scr_style); + lv_style_set_text_font(&scr_style, &lv_font_portfolio_6x8); + lv_style_set_bg_opa(&scr_style, LV_OPA_COVER); + + lv_theme_set_apply_cb(&theme, theme_apply); + lv_disp_t * disp = lvgl_port_add_disp(&disp_cfg); if (lvgl_port_lock(0)) { - lv_obj_t *scr = lv_scr_act(); - lv_obj_add_style(scr, &style, LV_PART_MAIN); + lv_display_set_theme(disp, &theme); lvgl_port_unlock(); } + // 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"); + is_display_active = true; return ESP_OK; @@ -115,53 +125,3 @@ bool display_active(void) { return is_display_active; } - -void display_clear() -{ - if (lvgl_port_lock(0)) { - lv_obj_t *scr = lv_scr_act(); - lv_obj_clean(scr); - lvgl_port_unlock(); - } -} - -void display_show_status(const char *messages[], size_t message_count) -{ - if (lvgl_port_lock(0)) { - lv_obj_t *scr = lv_scr_act(); - lv_obj_clean(scr); - - lv_obj_t *container = lv_obj_create(scr); - lv_obj_set_size(container, LCD_H_RES, LCD_V_RES); - lv_obj_align(container, LV_ALIGN_CENTER, 0, 0); - - lv_obj_set_flex_flow(container, LV_FLEX_FLOW_COLUMN); - lv_obj_set_flex_align(container, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START); - - for (int i = 0; i < message_count; i++) - { - lv_obj_t *label = lv_label_create(container); - lv_label_set_text(label, messages[i]); - lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR); - lv_obj_set_width(label, LCD_H_RES); - } - - lvgl_port_unlock(); - } -} - -void display_show_logo() -{ - if (lvgl_port_lock(0)) { - lv_obj_t *scr = lv_scr_act(); - lv_obj_clean(scr); - - lv_obj_t *img = lv_img_create(scr); - - lv_img_set_src(img, &logo); - - lv_obj_align(img, LV_ALIGN_CENTER, 0, 0); - - lvgl_port_unlock(); - } -} diff --git a/main/display.h b/main/display.h index f5e3d0140..035168ff1 100644 --- a/main/display.h +++ b/main/display.h @@ -3,8 +3,5 @@ esp_err_t display_init(void); bool display_active(void); -void display_clear(); -void display_show_status(const char *messages[], size_t message_count); -void display_show_logo(); #endif /* DISPLAY_H_ */ \ No newline at end of file diff --git a/main/global_state.h b/main/global_state.h index 4c9e922a6..a154074e9 100644 --- a/main/global_state.h +++ b/main/global_state.h @@ -68,6 +68,7 @@ typedef struct bool startup_done; char ssid[32]; char wifi_status[20]; + char ap_ssid[32]; char * pool_url; char * fallback_pool_url; uint16_t pool_port; @@ -77,6 +78,13 @@ typedef struct uint32_t lastClockSync; } SystemModule; +typedef struct +{ + bool running; + char *message; + bool result; +} SelfTestModule; + typedef struct { DeviceModel device_model; @@ -97,6 +105,7 @@ typedef struct SystemModule SYSTEM_MODULE; AsicTaskModule ASIC_TASK_MODULE; PowerManagementModule POWER_MANAGEMENT_MODULE; + SelfTestModule SELF_TEST_MODULE; char * extranonce_str; int extranonce_2_len; diff --git a/main/idf_component.yml b/main/idf_component.yml index 69aeccc53..816a2e2f1 100644 --- a/main/idf_component.yml +++ b/main/idf_component.yml @@ -1,13 +1,7 @@ ## IDF Component Manager Manifest File dependencies: - espressif/esp_lvgl_port: - git: https://github.com/espressif/esp-bsp.git - path: components/esp_lvgl_port - version: fix/lvgl_port_monochromatic_v9 - ## LVGL 9 is blocked by https://github.com/espressif/esp-idf/issues/14784 - lvgl/lvgl: - version: "^9" - public: true + lvgl/lvgl: "^9" + espressif/esp_lvgl_port: "^2.4.3" ## Required IDF version idf: version: ">=5.2.0" diff --git a/main/input.c b/main/input.c new file mode 100644 index 000000000..3c3d8b04b --- /dev/null +++ b/main/input.c @@ -0,0 +1,68 @@ +#include "esp_log.h" +#include "esp_err.h" +#include "esp_check.h" +#include "lvgl.h" +#include "esp_lvgl_port.h" +#include "driver/gpio.h" +#include "screen.h" +#include "connect.h" + +#define BUTTON_BOOT_GPIO GPIO_NUM_0 +#define ESP_INTR_FLAG_DEFAULT 0 +#define LONG_PRESS_DURATION_MS 2000 + +static const char * TAG = "input"; + +static lv_indev_state_t button_state = LV_INDEV_STATE_RELEASED; +static lv_point_t points[] = { {0, 0} }; // must be static + +static void button_read(lv_indev_t *indev, lv_indev_data_t *data) +{ + data->key = LV_KEY_ENTER; + data->state = button_state; +} + +static void IRAM_ATTR button_isr_handler(void *arg) +{ + bool pressed = gpio_get_level(BUTTON_BOOT_GPIO) == 0; // LOW when pressed + button_state = pressed ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED; +} + +static void button_short_clicked(lv_event_t *e) +{ + ESP_LOGI(TAG, "Short button press detected, switching to next screen"); + screen_next(); +} + +static void button_long_pressed(lv_event_t *e) +{ + ESP_LOGI(TAG, "Long button press detected, toggling WiFi SoftAP"); + toggle_wifi_softap(); +} + +esp_err_t input_init(void) +{ + // Button handling + gpio_config_t io_conf = { + .pin_bit_mask = (1ULL << BUTTON_BOOT_GPIO), + .mode = GPIO_MODE_INPUT, + .pull_up_en = GPIO_PULLUP_ENABLE, + .intr_type = GPIO_INTR_ANYEDGE + }; + gpio_config(&io_conf); + + // Install ISR service and hook the interrupt handler + ESP_RETURN_ON_ERROR(gpio_install_isr_service(ESP_INTR_FLAG_DEFAULT), TAG, "Error installing ISR service"); + ESP_RETURN_ON_ERROR(gpio_isr_handler_add(BUTTON_BOOT_GPIO, button_isr_handler, NULL), TAG, "Error adding ISR handler"); + + // Create input device + lv_indev_t * indev = lv_indev_create(); + lv_indev_set_type(indev, LV_INDEV_TYPE_BUTTON); + lv_indev_set_long_press_time(indev, LONG_PRESS_DURATION_MS); + lv_indev_set_read_cb(indev, button_read); + lv_indev_set_button_points(indev, points); + lv_indev_add_event_cb(indev, button_short_clicked, LV_EVENT_SHORT_CLICKED, NULL); + lv_indev_add_event_cb(indev, button_long_pressed, LV_EVENT_LONG_PRESSED, NULL); + + return ESP_OK; +} diff --git a/main/input.h b/main/input.h new file mode 100644 index 000000000..cdc382b2b --- /dev/null +++ b/main/input.h @@ -0,0 +1,6 @@ +#ifndef INPUT_H_ +#define INPUT_H_ + +esp_err_t input_init(void); + +#endif /* INPUT_H_ */ \ No newline at end of file diff --git a/main/lv_conf.h b/main/lv_conf.h index d725a4ed3..9410c9d13 100644 --- a/main/lv_conf.h +++ b/main/lv_conf.h @@ -466,7 +466,7 @@ #define LV_ATTRIBUTE_EXTERN_DATA /* Use `float` as `lv_value_precise_t` */ -#define LV_USE_FLOAT 0 +#define LV_USE_FLOAT 1 /*Enable matrix support *Requires `LV_USE_FLOAT = 1`*/ diff --git a/main/main.c b/main/main.c index dbc467bf9..30f7905e6 100644 --- a/main/main.c +++ b/main/main.c @@ -15,7 +15,6 @@ #include "nvs_config.h" #include "serial.h" #include "stratum_task.h" -#include "user_input_task.h" #include "i2c_bitaxe.h" #include "adc.h" #include "nvs_device.h" @@ -77,9 +76,10 @@ void app_main(void) // init and connect to wifi wifi_init(wifi_ssid, wifi_pass, hostname); + generate_ssid(GLOBAL_STATE.SYSTEM_MODULE.ap_ssid); + SYSTEM_init_peripherals(&GLOBAL_STATE); - xTaskCreate(SYSTEM_task, "SYSTEM_task", 4096, (void *) &GLOBAL_STATE, 3, NULL); xTaskCreate(POWER_MANAGEMENT_task, "power mangement", 8192, (void *) &GLOBAL_STATE, 10, NULL); //start the API for AxeOS @@ -116,8 +116,6 @@ void app_main(void) GLOBAL_STATE.SYSTEM_MODULE.startup_done = true; GLOBAL_STATE.new_stratum_version_rolling_msg = false; - xTaskCreate(USER_INPUT_task, "user input", 8192, (void *) &GLOBAL_STATE, 5, NULL); - if (GLOBAL_STATE.ASIC_functions.init_fn != NULL) { wifi_softap_off(); diff --git a/main/screen.c b/main/screen.c new file mode 100644 index 000000000..6cfe6a964 --- /dev/null +++ b/main/screen.c @@ -0,0 +1,305 @@ +#include "esp_log.h" +#include "esp_err.h" +#include "esp_check.h" +#include "esp_event.h" +#include "esp_netif.h" +#include "lvgl.h" +#include "esp_lvgl_port.h" +#include "global_state.h" +#include "display.h" +#include "screen.h" +#include "lwip/lwip_napt.h" + +static const char * TAG = "screen"; + +extern const lv_img_dsc_t logo; + +static lv_obj_t * screens[MAX_SCREENS]; + +static screen_t current_screen = -1; +static TickType_t current_screen_counter; + +static GlobalState * GLOBAL_STATE; + +static char ip_address_str[IP4ADDR_STRLEN_MAX]; + +static lv_obj_t *hashrate_label; +static lv_obj_t *efficiency_label; +static lv_obj_t *difficulty_label; +static lv_obj_t *chip_temp_label; + +static lv_obj_t *self_test_labels[2]; + +static double current_hashrate; +static float current_power; +static uint64_t current_difficulty; +static float curreny_chip_temp; + +#define SCREEN_UPDATE_MS 500 +#define LOGO_DELAY_COUNT 5000/SCREEN_UPDATE_MS +#define CAROUSEL_DELAY_COUNT 10000 / SCREEN_UPDATE_MS + +static lv_obj_t * create_scr_self_test(SystemModule * module) { + lv_obj_t * scr = lv_obj_create(NULL); + + lv_obj_set_flex_flow(scr, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(scr, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START); + lv_obj_t *label1 = lv_label_create(scr); + lv_label_set_text(label1, "BITAXE SELF TEST"); + self_test_labels[0] = lv_label_create(scr); + self_test_labels[1] = lv_label_create(scr); + + return scr; +} + +static lv_obj_t * create_scr_overheat(SystemModule * module) { + lv_obj_t * scr = lv_obj_create(NULL); + + lv_obj_set_flex_flow(scr, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(scr, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START); + lv_obj_t *label1 = lv_label_create(scr); + lv_label_set_text(label1, "DEVICE OVERHEAT!"); + lv_obj_t *label2 = lv_label_create(scr); + lv_label_set_text(label2, "Power, frequency and fan configurations have been reset. Go to AxeOS to reconfigure device."); + lv_label_set_long_mode(label2, LV_LABEL_LONG_SCROLL_CIRCULAR); + lv_obj_t *label3 = lv_label_create(scr); + lv_label_set_text(label3, "Device IP:"); + lv_obj_t *label4 = lv_label_create(scr); + lv_label_set_text_static(label4, ip_address_str); + + return scr; +} + +static lv_obj_t * create_scr_configure(SystemModule * module) { + lv_obj_t * scr = lv_obj_create(NULL); + + lv_obj_set_flex_flow(scr, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(scr, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START); + lv_obj_t *label1 = lv_label_create(scr); + lv_label_set_text(label1, "Welcome to your new BitAxe! Connect to the configuration Wifi and connect the BitAxe to your network."); + lv_label_set_long_mode(label1, LV_LABEL_LONG_SCROLL_CIRCULAR); + lv_obj_t *label2 = lv_label_create(scr); + lv_label_set_text(label2, "Configuration SSID:"); + lv_obj_t *label3 = lv_label_create(scr); + lv_label_set_text(label3, module->ap_ssid); + + return scr; +} + +static lv_obj_t * create_scr_connection(SystemModule * module) { + lv_obj_t * scr = lv_obj_create(NULL); + + lv_obj_set_flex_flow(scr, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(scr, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START); + lv_obj_t *label1 = lv_label_create(scr); + lv_label_set_text(label1, "Connecting to SSID:"); + lv_obj_t *label2 = lv_label_create(scr); + lv_label_set_text(label2, module->ssid); + lv_obj_t *label3 = lv_label_create(scr); + lv_label_set_text(label3, "Configuration SSID:"); + lv_obj_t *label4 = lv_label_create(scr); + lv_label_set_text(label4, module->ap_ssid); + + return scr; +} + +static lv_obj_t * create_scr_logo() { + lv_obj_t * scr = lv_obj_create(NULL); + + lv_obj_t *img = lv_img_create(scr); + lv_img_set_src(img, &logo); + lv_obj_align(img, LV_ALIGN_CENTER, 0, 0); + + return scr; +} + +static lv_obj_t * create_scr_urls(SystemModule * module) { + lv_obj_t * scr = lv_obj_create(NULL); + + lv_obj_set_flex_flow(scr, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(scr, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START); + lv_obj_t *label1 = lv_label_create(scr); + lv_label_set_text(label1, "Mining URL:"); + lv_obj_t *label2 = lv_label_create(scr); + lv_label_set_text(label2, module->is_using_fallback ? module->fallback_pool_url : module->pool_url); + lv_obj_t *label3 = lv_label_create(scr); + lv_label_set_text(label3, "Bitaxe IP:"); + lv_obj_t *label4 = lv_label_create(scr); + lv_label_set_text_static(label4, ip_address_str); + + return scr; +} + +static lv_obj_t * create_scr_stats(SystemModule * module, PowerManagementModule * power_management) { + lv_obj_t * scr = lv_obj_create(NULL); + + lv_obj_set_flex_flow(scr, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(scr, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START); + + hashrate_label = lv_label_create(scr); + lv_label_set_text(hashrate_label, "Gh/s: n/a"); + efficiency_label = lv_label_create(scr); + lv_label_set_text(efficiency_label, "J/Th: n/a"); + difficulty_label = lv_label_create(scr); + lv_label_set_text(difficulty_label, "Best: n/a"); + chip_temp_label = lv_label_create(scr); + lv_label_set_text(chip_temp_label, "Temp: n/a"); + + return scr; +} + +static void screen_show(screen_t screen) +{ + if (current_screen != screen) { + lv_obj_t * scr = screens[screen]; + + if (scr && lvgl_port_lock(0)) { + lv_screen_load_anim(scr, LV_SCR_LOAD_ANIM_MOVE_LEFT, LV_DEF_REFR_PERIOD * 128 / 8, 0, false); + lvgl_port_unlock(); + } + + current_screen = screen; + current_screen_counter = 0; + } +} + +static void screen_update_cb(lv_timer_t * timer) +{ + SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; + PowerManagementModule * power_management = &GLOBAL_STATE->POWER_MANAGEMENT_MODULE; + + if (module->overheat_mode == 1) { + screen_show(SCR_OVERHEAT); + return; + } + + if (GLOBAL_STATE->SELF_TEST_MODULE.running) { + screen_show(SCR_SELF_TEST); + return; + } + + if (current_screen == SCR_SELF_TEST) { + + return; + } + + if (GLOBAL_STATE->ASIC_functions.init_fn == NULL) { + // Invalid model + // TODO Not sure what should be done here? + return; + } + + if (module->ssid[0] == '\0') { + screen_show(SCR_CONFIGURE); + return; + } + + if (!module->startup_done) { + screen_show(SCR_CONNECTION); + return; + } + + current_screen_counter++; + + // Logo + + if (current_screen < SCR_LOGO) { + screen_show(SCR_LOGO); + return; + } + + if (current_screen == SCR_LOGO) { + if (LOGO_DELAY_COUNT > current_screen_counter) { + return; + } + screen_show(SCR_CAROUSEL_START); + return; + } + + if (module->FOUND_BLOCK) { + // TODO make special screen for this + } + + // Carousel + + if (current_hashrate != module->current_hashrate) { + lv_label_set_text_fmt(hashrate_label, "Gh/s: %.2f", module->current_hashrate); + } + + if (current_power != power_management->power || current_hashrate != module->current_hashrate) { + lv_label_set_text_fmt(efficiency_label, "J/Th: %.2f", power_management->power / (module->current_hashrate / 1000.0)); + } + + 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); + } + + if (curreny_chip_temp != power_management->chip_temp_avg) { + lv_label_set_text_fmt(chip_temp_label, "Temp: %.1f C", power_management->chip_temp_avg); + } + + current_hashrate = module->current_hashrate; + current_power = power_management->power; + current_difficulty = module->best_session_nonce_diff; + curreny_chip_temp = power_management->chip_temp_avg; + + if (CAROUSEL_DELAY_COUNT > current_screen_counter) { + return; + } + + screen_next(); +} + +void screen_next() +{ + if (current_screen >= SCR_CAROUSEL_START) { + screen_show(current_screen == SCR_CAROUSEL_END ? SCR_CAROUSEL_START : current_screen + 1); + } +} + +static void ip_event_handler(void * arg, esp_event_base_t event_base, int32_t event_id, void * event_data) +{ + if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) { + ip_event_got_ip_t * event = (ip_event_got_ip_t *) event_data; + esp_ip4addr_ntoa(&event->ip_info.ip, ip_address_str, IP4ADDR_STRLEN_MAX); + } +} + +esp_err_t screen_start(void * pvParameters) +{ + GLOBAL_STATE = (GlobalState *) pvParameters; + + if (display_active()) { + SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; + PowerManagementModule * power_management = &GLOBAL_STATE->POWER_MANAGEMENT_MODULE; + + screens[SCR_SELF_TEST] = create_scr_self_test(module); + screens[SCR_OVERHEAT] = create_scr_overheat(module); + screens[SCR_CONFIGURE] = create_scr_configure(module); + screens[SCR_CONNECTION] = create_scr_connection(module); + screens[SCR_LOGO] = create_scr_logo(); + screens[SCR_URLS] = create_scr_urls(module); + screens[SCR_STATS] = create_scr_stats(module, power_management); + + lv_timer_create(screen_update_cb, SCREEN_UPDATE_MS, NULL); + + esp_event_handler_instance_t instance_got_ip; + ESP_RETURN_ON_ERROR(esp_event_handler_instance_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &ip_event_handler, NULL, &instance_got_ip), TAG, "Error registering IP event handler"); + } + + return ESP_OK; +} + +// TODO: Transition code until self test code is revamped +void display_show_status(const char *messages[], size_t message_count) +{ + if (lvgl_port_lock(0)) { + + screen_show(SCR_SELF_TEST); + // messages[0] is ignored, it's already on the screen + lv_label_set_text(self_test_labels[0], messages[1]); + lv_label_set_text(self_test_labels[1], messages[2]); + lvgl_port_unlock(); + } +} + diff --git a/main/screen.h b/main/screen.h new file mode 100644 index 000000000..55214df84 --- /dev/null +++ b/main/screen.h @@ -0,0 +1,22 @@ +#ifndef SCREEN_H_ +#define SCREEN_H_ + +typedef enum { + SCR_SELF_TEST, + SCR_OVERHEAT, + SCR_CONFIGURE, + SCR_CONNECTION, + SCR_LOGO, + SCR_URLS, + SCR_STATS, + MAX_SCREENS, +} screen_t; + +#define SCR_CAROUSEL_START SCR_URLS +#define SCR_CAROUSEL_END SCR_STATS + +esp_err_t screen_start(void * pvParameters); +void screen_next(void); +void display_show_status(const char *messages[], size_t message_count); + +#endif /* SCREEN_H_ */ \ No newline at end of file diff --git a/main/self_test/self_test.c b/main/self_test/self_test.c index a3130cb52..526b2c4fc 100644 --- a/main/self_test/self_test.c +++ b/main/self_test/self_test.c @@ -8,6 +8,7 @@ #include "nvs_config.h" #include "nvs_flash.h" #include "display.h" +#include "input.h" #include "vcore.h" #include "utils.h" #include "string.h" @@ -138,6 +139,10 @@ void self_test(void * pvParameters) default: } + if (input_init() != ESP_OK) { + ESP_LOGW(TAG, "Input init failed!"); + } + GLOBAL_STATE->ASIC_TASK_MODULE.active_jobs = malloc(sizeof(bm_job *) * 128); GLOBAL_STATE->valid_jobs = malloc(sizeof(uint8_t) * 128); diff --git a/main/system.c b/main/system.c index a8cb063ea..3b5c6f4c5 100644 --- a/main/system.c +++ b/main/system.c @@ -27,24 +27,18 @@ #include "led_controller.h" #include "nvs_config.h" #include "display.h" +#include "input.h" +#include "screen.h" #include "vcore.h" - static const char * TAG = "SystemModule"; static void _suffix_string(uint64_t, char *, size_t, int); static esp_netif_t * netif; -QueueHandle_t user_input_queue; - //local function prototypes static esp_err_t ensure_overheat_mode_config(); -static void _show_overheat_screen(GlobalState * GLOBAL_STATE); -static void _update_connection(GlobalState * GLOBAL_STATE); -static void _update_screen_one(GlobalState * GLOBAL_STATE); -static void _update_screen_two(GlobalState * GLOBAL_STATE); -static void show_ap_information(const char * error, GlobalState * GLOBAL_STATE); static void _check_for_best_diff(GlobalState * GLOBAL_STATE, double diff, uint8_t job_id); static void _suffix_string(uint64_t val, char * buf, size_t bufsiz, int sigdigits); @@ -93,7 +87,6 @@ void SYSTEM_init_system(GlobalState * GLOBAL_STATE) memset(module->wifi_status, 0, 20); } - void SYSTEM_init_peripherals(GlobalState * GLOBAL_STATE) { // Initialize the core voltage regulator VCORE_init(GLOBAL_STATE); @@ -120,7 +113,6 @@ void SYSTEM_init_peripherals(GlobalState * GLOBAL_STATE) { case DEVICE_ULTRA: case DEVICE_SUPRA: if (GLOBAL_STATE->board_version < 402) { - // Initialize the LED controller INA260_init(); } break; @@ -147,105 +139,20 @@ void SYSTEM_init_peripherals(GlobalState * GLOBAL_STATE) { ESP_LOGW(TAG, "OLED init failed!"); } else { ESP_LOGI(TAG, "OLED init success!"); - display_clear(); } break; default: } - netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF"); - - user_input_queue = xQueueCreate(10, sizeof(char[10])); // Create a queue to handle user input events -} - -void SYSTEM_task(void * pvParameters) -{ - GlobalState * GLOBAL_STATE = (GlobalState *) pvParameters; - SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; - - //_init_system(GLOBAL_STATE); - - char input_event[10]; - ESP_LOGI(TAG, "SYSTEM_task started"); - - while (GLOBAL_STATE->ASIC_functions.init_fn == NULL) { - show_ap_information("ASIC MODEL INVALID", GLOBAL_STATE); - vTaskDelay(5000 / portTICK_PERIOD_MS); + if (input_init() != ESP_OK) { + ESP_LOGW(TAG, "Input init failed!"); } - // show the connection screen - while (!module->startup_done) { - _update_connection(GLOBAL_STATE); - vTaskDelay(1000 / portTICK_PERIOD_MS); + if (screen_start(GLOBAL_STATE) != ESP_OK) { + ESP_LOGW(TAG, "Screen init failed"); } - - if (display_active()) { - display_show_logo(); - vTaskDelay(5000 / portTICK_PERIOD_MS); - } - - int current_screen = 0; - TickType_t last_update_time = xTaskGetTickCount(); - - while (1) { - // Check for overheat mode - if (module->overheat_mode == 1) { - _show_overheat_screen(GLOBAL_STATE); - vTaskDelay(5000 / portTICK_PERIOD_MS); // Update every 5 seconds - SYSTEM_update_overheat_mode(GLOBAL_STATE); // Check for changes - continue; // Skip the normal screen cycle - } - - // Update the current screen - module->screen_page = current_screen; - - switch (current_screen) { - case 0: - _update_screen_one(GLOBAL_STATE); - break; - case 1: - _update_screen_two(GLOBAL_STATE); - break; - } - - // Wait for user input or timeout - bool input_received = false; - TickType_t current_time = xTaskGetTickCount(); - TickType_t wait_time = pdMS_TO_TICKS(10000) - (current_time - last_update_time); - - if (wait_time > 0) { - if (xQueueReceive(user_input_queue, &input_event, wait_time) == pdTRUE) { - input_received = true; - if (strcmp(input_event, "SHORT") == 0) { - ESP_LOGI(TAG, "Short button press detected, switching to next screen"); - current_screen = (current_screen + 1) % 2; - } else if (strcmp(input_event, "LONG") == 0) { - ESP_LOGI(TAG, "Long button press detected, toggling WiFi SoftAP"); - toggle_wifi_softap(); - } - } - } - - // If no input received and 10 seconds have passed, switch to the next screen - if (!input_received && (xTaskGetTickCount() - last_update_time) >= pdMS_TO_TICKS(10000)) { - current_screen = (current_screen + 1) % 2; - } - - last_update_time = xTaskGetTickCount(); - } -} - - -void SYSTEM_update_overheat_mode(GlobalState * GLOBAL_STATE) -{ - SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; - uint16_t new_overheat_mode = nvs_config_get_u16(NVS_CONFIG_OVERHEAT_MODE, 0); - - if (new_overheat_mode != module->overheat_mode) { - module->overheat_mode = new_overheat_mode; - ESP_LOGI(TAG, "Overheat mode updated to: %d", module->overheat_mode); - } + netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF"); } void SYSTEM_notify_accepted_share(GlobalState * GLOBAL_STATE) @@ -327,147 +234,6 @@ void SYSTEM_notify_found_nonce(GlobalState * GLOBAL_STATE, double found_diff, ui _check_for_best_diff(GLOBAL_STATE, found_diff, job_id); } - -/// -/// LOCAL FUNCTIONS -/// -static void _show_overheat_screen(GlobalState * GLOBAL_STATE) -{ - esp_netif_ip_info_t ip_info; - - switch (GLOBAL_STATE->device_model) { - case DEVICE_MAX: - case DEVICE_ULTRA: - case DEVICE_SUPRA: - case DEVICE_GAMMA: - if (display_active()) { - esp_netif_get_ip_info(netif, &ip_info); - char ip_address_str[IP4ADDR_STRLEN_MAX]; - esp_ip4addr_ntoa(&ip_info.ip, ip_address_str, IP4ADDR_STRLEN_MAX); - display_show_status((const char *[]){ - "DEVICE OVERHEAT!", - "See AxeOS settings", - "IP:", - ip_address_str - }, 4); - } - break; - default: - break; - } -} - -static void _update_screen_one(GlobalState * GLOBAL_STATE) -{ - SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; - esp_netif_ip_info_t ip_info; - - switch (GLOBAL_STATE->device_model) { - case DEVICE_MAX: - case DEVICE_ULTRA: - case DEVICE_SUPRA: - case DEVICE_GAMMA: - if (display_active()) { - esp_netif_get_ip_info(netif, &ip_info); - char ip_address_str[IP4ADDR_STRLEN_MAX]; - esp_ip4addr_ntoa(&ip_info.ip, ip_address_str, IP4ADDR_STRLEN_MAX); - display_show_status((const char *[]){ - "Mining URL:", - module->is_using_fallback ? module->fallback_pool_url : module->pool_url, - "Bitaxe IP:", - ip_address_str - }, 4); - } - break; - default: - break; - } -} - -static void _update_screen_two(GlobalState * GLOBAL_STATE) -{ - SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; - PowerManagementModule * power_management = &GLOBAL_STATE->POWER_MANAGEMENT_MODULE; - switch (GLOBAL_STATE->device_model) { - case DEVICE_MAX: - case DEVICE_ULTRA: - case DEVICE_SUPRA: - case DEVICE_GAMMA: - if (display_active()) { - char label_hashrate[20]; - snprintf(label_hashrate, 20, "Gh/s: %.2f", module->current_hashrate); - - char label_efficiency[20]; - float efficiency = GLOBAL_STATE->POWER_MANAGEMENT_MODULE.power / (module->current_hashrate / 1000.0); - snprintf(label_efficiency, 20, "J/Th: %.2f", efficiency); - - char label_best[20]; - snprintf(label_best, 27, "Best: %s/%s", module->best_session_diff_string, module->best_diff_string); - - char label_temp_avg[20]; - snprintf(label_temp_avg, 20, "Temp: %.1f C", power_management->chip_temp_avg); - - display_show_status((const char *[]){ - label_hashrate, - label_efficiency, - module->FOUND_BLOCK ? "!!! BLOCK FOUND !!!" : label_best, - label_temp_avg - }, 4); - } - break; - default: - break; - } -} - -static void _update_connection(GlobalState * GLOBAL_STATE) -{ - SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; - - switch (GLOBAL_STATE->device_model) { - case DEVICE_MAX: - case DEVICE_ULTRA: - case DEVICE_SUPRA: - case DEVICE_GAMMA: - if (display_active()) { - - char ap_ssid[13]; - generate_ssid(ap_ssid); - - display_show_status((const char *[]){ - "Connecting to SSID:", - module->ssid, - "Configuration SSID:", - ap_ssid - }, 4); - } - break; - default: - } -} - - -static void show_ap_information(const char * error, GlobalState * GLOBAL_STATE) -{ - switch (GLOBAL_STATE->device_model) { - case DEVICE_MAX: - case DEVICE_ULTRA: - case DEVICE_SUPRA: - case DEVICE_GAMMA: - if (display_active()) { - char ap_ssid[13]; - generate_ssid(ap_ssid); - - display_show_status((const char *[]){ - "Configuration SSID:", - ap_ssid - }, 2); - } - break; - default: - } -} - static double _calculate_network_difficulty(uint32_t nBits) { uint32_t mantissa = nBits & 0x007fffff; // Extract the mantissa from nBits diff --git a/main/system.h b/main/system.h index 46a25400a..4fae05cc0 100644 --- a/main/system.h +++ b/main/system.h @@ -5,7 +5,6 @@ void SYSTEM_init_system(GlobalState * GLOBAL_STATE); void SYSTEM_init_peripherals(GlobalState * GLOBAL_STATE); -void SYSTEM_task(void * parameters); void SYSTEM_notify_accepted_share(GlobalState * GLOBAL_STATE); void SYSTEM_notify_rejected_share(GlobalState * GLOBAL_STATE); @@ -13,7 +12,4 @@ void SYSTEM_notify_found_nonce(GlobalState * GLOBAL_STATE, double found_diff, ui void SYSTEM_notify_mining_started(GlobalState * GLOBAL_STATE); void SYSTEM_notify_new_ntime(GlobalState * GLOBAL_STATE, uint32_t ntime); -void SYSTEM_update_overheat_mode(GlobalState * GLOBAL_STATE); - - #endif /* SYSTEM_H_ */ diff --git a/main/tasks/power_management_task.c b/main/tasks/power_management_task.c index c7eb7b995..af370547f 100644 --- a/main/tasks/power_management_task.c +++ b/main/tasks/power_management_task.c @@ -292,6 +292,15 @@ void POWER_MANAGEMENT_task(void * pvParameters) last_asic_frequency = asic_frequency; } + // Check for changing of overheat mode + SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; + uint16_t new_overheat_mode = nvs_config_get_u16(NVS_CONFIG_OVERHEAT_MODE, 0); + + if (new_overheat_mode != module->overheat_mode) { + module->overheat_mode = new_overheat_mode; + ESP_LOGI(TAG, "Overheat mode updated to: %d", module->overheat_mode); + } + vTaskDelay(POLL_RATE / portTICK_PERIOD_MS); } } diff --git a/main/tasks/user_input_task.c b/main/tasks/user_input_task.c deleted file mode 100644 index 6ff5174de..000000000 --- a/main/tasks/user_input_task.c +++ /dev/null @@ -1,48 +0,0 @@ -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "freertos/queue.h" -#include "esp_timer.h" // Include esp_timer for esp_timer_get_time -#include "driver/gpio.h" -#include "esp_log.h" -#include "connect.h" - -#define BUTTON_BOOT GPIO_NUM_0 -#define SHORT_PRESS_DURATION_MS 100 // Define what constitutes a short press -#define LONG_PRESS_DURATION_MS 2000 // Define what constitutes a long press - -static const char *TAG = "user_input"; -static bool button_being_pressed = false; -static int64_t button_press_time = 0; - -extern QueueHandle_t user_input_queue; // Declare the queue as external - -void USER_INPUT_task(void *pvParameters) -{ - gpio_set_direction(BUTTON_BOOT, GPIO_MODE_INPUT); - - while (1) - { - if (gpio_get_level(BUTTON_BOOT) == 0 && button_being_pressed == false) - { // If button is pressed - button_being_pressed = true; - button_press_time = esp_timer_get_time(); - } - else if (gpio_get_level(BUTTON_BOOT) == 1 && button_being_pressed == true) - { - int64_t press_duration = esp_timer_get_time() - button_press_time; - button_being_pressed = false; - if (press_duration > LONG_PRESS_DURATION_MS * 1000) - { - ESP_LOGI(TAG, "LONG PRESS DETECTED"); - xQueueSend(user_input_queue, (void *)"LONG", (TickType_t)0); - } - else if (press_duration > SHORT_PRESS_DURATION_MS * 1000) - { - ESP_LOGI(TAG, "SHORT PRESS DETECTED"); - xQueueSend(user_input_queue, (void *)"SHORT", (TickType_t)0); - } - } - - vTaskDelay(30 / portTICK_PERIOD_MS); // Add delay so that current task does not starve idle task and trigger watchdog timer - } -} \ No newline at end of file diff --git a/main/tasks/user_input_task.h b/main/tasks/user_input_task.h deleted file mode 100644 index b3691b854..000000000 --- a/main/tasks/user_input_task.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef USER_INPUT_TASK_H_ -#define USER_INPUT_TASK_H_ - -void USER_INPUT_task(void *pvParameters); - -#endif \ No newline at end of file From 03610bb7c6197dbe6c86eb0ccf2124ca308357da Mon Sep 17 00:00:00 2001 From: mutatrum Date: Sat, 30 Nov 2024 14:36:48 +0100 Subject: [PATCH 10/23] Bump esp_lvgl_port to 2.4.3 --- main/idf_component.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/main/idf_component.yml b/main/idf_component.yml index 69aeccc53..816a2e2f1 100644 --- a/main/idf_component.yml +++ b/main/idf_component.yml @@ -1,13 +1,7 @@ ## IDF Component Manager Manifest File dependencies: - espressif/esp_lvgl_port: - git: https://github.com/espressif/esp-bsp.git - path: components/esp_lvgl_port - version: fix/lvgl_port_monochromatic_v9 - ## LVGL 9 is blocked by https://github.com/espressif/esp-idf/issues/14784 - lvgl/lvgl: - version: "^9" - public: true + lvgl/lvgl: "^9" + espressif/esp_lvgl_port: "^2.4.3" ## Required IDF version idf: version: ">=5.2.0" From 06d048c4032d5f1d310feb1d7b24b974ed4e8552 Mon Sep 17 00:00:00 2001 From: mutatrum Date: Sat, 30 Nov 2024 14:51:26 +0100 Subject: [PATCH 11/23] Fix missing include --- main/self_test/self_test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/main/self_test/self_test.c b/main/self_test/self_test.c index 526b2c4fc..8813e621d 100644 --- a/main/self_test/self_test.c +++ b/main/self_test/self_test.c @@ -8,6 +8,7 @@ #include "nvs_config.h" #include "nvs_flash.h" #include "display.h" +#include "screen.h" #include "input.h" #include "vcore.h" #include "utils.h" From 6238a3b175a06e748c7dc4ac7c2eb82282c7e20b Mon Sep 17 00:00:00 2001 From: mutatrum Date: Sun, 1 Dec 2024 13:25:32 +0100 Subject: [PATCH 12/23] Adapt self_test to lvgl code Other changes: * self test results, is_screen_active and ip_addr_str in GLOBAL_STATE * Fix long label scrolling * Add callback for long press function --- components/connect/connect.c | 11 +- components/connect/include/connect.h | 2 +- main/display.c | 14 +-- main/display.h | 3 +- main/global_state.h | 5 +- main/input.c | 20 ++-- main/input.h | 2 +- main/main.c | 4 +- main/screen.c | 119 +++++++++--------- main/screen.h | 1 - main/self_test/self_test.c | 173 ++++++++------------------- main/system.c | 10 +- 12 files changed, 154 insertions(+), 210 deletions(-) diff --git a/components/connect/connect.c b/components/connect/connect.c index 36be658ad..79808011a 100644 --- a/components/connect/connect.c +++ b/components/connect/connect.c @@ -53,6 +53,8 @@ static const char * TAG = "wifi_station"; static int s_retry_num = 0; +static char * _ip_addr_str; + static void event_handler(void * arg, esp_event_base_t event_base, int32_t event_id, void * event_data) { if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) { @@ -75,8 +77,11 @@ static void event_handler(void * arg, esp_event_base_t event_base, int32_t event MINER_set_wifi_status(WIFI_RETRYING, s_retry_num); } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) { + ip_event_got_ip_t * event = (ip_event_got_ip_t *) event_data; - ESP_LOGI(TAG, "Bitaxe ip:" IPSTR, IP2STR(&event->ip_info.ip)); + snprintf(_ip_addr_str, IP4ADDR_STRLEN_MAX, IPSTR, IP2STR(&event->ip_info.ip)); + + ESP_LOGI(TAG, "Bitaxe ip: %s", _ip_addr_str); s_retry_num = 0; xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT); MINER_set_wifi_status(WIFI_CONNECTED, 0); @@ -194,8 +199,10 @@ esp_netif_t * wifi_init_sta(const char * wifi_ssid, const char * wifi_pass) return esp_netif_sta; } -void wifi_init(const char * wifi_ssid, const char * wifi_pass, const char * hostname) +void wifi_init(const char * wifi_ssid, const char * wifi_pass, const char * hostname, char * ip_addr_str) { + _ip_addr_str = ip_addr_str; + s_wifi_event_group = xEventGroupCreate(); ESP_ERROR_CHECK(esp_netif_init()); diff --git a/components/connect/include/connect.h b/components/connect/include/connect.h index bd0b97564..f23bc923e 100644 --- a/components/connect/include/connect.h +++ b/components/connect/include/connect.h @@ -32,6 +32,6 @@ typedef enum void toggle_wifi_softap(void); void wifi_softap_on(void); void wifi_softap_off(void); -void wifi_init(const char * wifi_ssid, const char * wifi_pass, const char * hostname); +void wifi_init(const char * wifi_ssid, const char * wifi_pass, const char * hostname, char * ip_addr_str); EventBits_t wifi_connect(void); void generate_ssid(char * ssid); diff --git a/main/display.c b/main/display.c index 05ddae1da..6fabd774e 100644 --- a/main/display.c +++ b/main/display.c @@ -10,6 +10,7 @@ #include "lvgl.h" #include "lvgl__lvgl/src/themes/lv_theme_private.h" #include "esp_lvgl_port.h" +#include "global_state.h" #include "nvs_config.h" #include "i2c_bitaxe.h" #include "driver/i2c_master.h" @@ -23,8 +24,6 @@ #define LCD_CMD_BITS 8 #define LCD_PARAM_BITS 8 -static bool is_display_active = false; - static const char * TAG = "display"; static lv_theme_t theme; @@ -38,8 +37,10 @@ static void theme_apply(lv_theme_t *theme, lv_obj_t *obj) { } } -esp_err_t display_init(void) +esp_err_t display_init(void * pvParameters) { + GlobalState * GLOBAL_STATE = (GlobalState *) pvParameters; + uint8_t flip_screen = nvs_config_get_u16(NVS_CONFIG_FLIP_SCREEN, 1); uint8_t invert_screen = nvs_config_get_u16(NVS_CONFIG_INVERT_SCREEN, 0); @@ -116,12 +117,7 @@ esp_err_t display_init(void) // 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"); - is_display_active = true; + GLOBAL_STATE->SYSTEM_MODULE.is_screen_active = true; return ESP_OK; } - -bool display_active(void) -{ - return is_display_active; -} diff --git a/main/display.h b/main/display.h index 035168ff1..456466195 100644 --- a/main/display.h +++ b/main/display.h @@ -1,7 +1,6 @@ #ifndef DISPLAY_H_ #define DISPLAY_H_ -esp_err_t display_init(void); -bool display_active(void); +esp_err_t display_init(void * pvParameters); #endif /* DISPLAY_H_ */ \ No newline at end of file diff --git a/main/global_state.h b/main/global_state.h index a154074e9..682e0c327 100644 --- a/main/global_state.h +++ b/main/global_state.h @@ -68,6 +68,7 @@ typedef struct bool startup_done; char ssid[32]; char wifi_status[20]; + char ip_addr_str[16]; // IP4ADDR_STRLEN_MAX char ap_ssid[32]; char * pool_url; char * fallback_pool_url; @@ -76,13 +77,15 @@ typedef struct bool is_using_fallback; uint16_t overheat_mode; uint32_t lastClockSync; + bool is_screen_active; } SystemModule; typedef struct { - bool running; + bool active; char *message; bool result; + bool finished; } SelfTestModule; typedef struct diff --git a/main/input.c b/main/input.c index 3c3d8b04b..74b43afbd 100644 --- a/main/input.c +++ b/main/input.c @@ -16,6 +16,8 @@ static const char * TAG = "input"; static lv_indev_state_t button_state = LV_INDEV_STATE_RELEASED; static lv_point_t points[] = { {0, 0} }; // must be static +static void (*button_long_pressed)(void) = NULL; + static void button_read(lv_indev_t *indev, lv_indev_data_t *data) { data->key = LV_KEY_ENTER; @@ -28,20 +30,24 @@ static void IRAM_ATTR button_isr_handler(void *arg) button_state = pressed ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED; } -static void button_short_clicked(lv_event_t *e) +static void button_short_clicked_event_cb(lv_event_t *e) { ESP_LOGI(TAG, "Short button press detected, switching to next screen"); screen_next(); } -static void button_long_pressed(lv_event_t *e) +static void button_long_pressed_event_cb(lv_event_t *e) { - ESP_LOGI(TAG, "Long button press detected, toggling WiFi SoftAP"); - toggle_wifi_softap(); + if (button_long_pressed != NULL) { + ESP_LOGI(TAG, "Long button press detected"); + button_long_pressed(); + } } -esp_err_t input_init(void) +esp_err_t input_init(void (*button_long_pressed_cb)(void)) { + button_long_pressed = button_long_pressed_cb; + // Button handling gpio_config_t io_conf = { .pin_bit_mask = (1ULL << BUTTON_BOOT_GPIO), @@ -61,8 +67,8 @@ esp_err_t input_init(void) lv_indev_set_long_press_time(indev, LONG_PRESS_DURATION_MS); lv_indev_set_read_cb(indev, button_read); lv_indev_set_button_points(indev, points); - lv_indev_add_event_cb(indev, button_short_clicked, LV_EVENT_SHORT_CLICKED, NULL); - lv_indev_add_event_cb(indev, button_long_pressed, LV_EVENT_LONG_PRESSED, NULL); + lv_indev_add_event_cb(indev, button_short_clicked_event_cb, LV_EVENT_SHORT_CLICKED, NULL); + lv_indev_add_event_cb(indev, button_long_pressed_event_cb, LV_EVENT_LONG_PRESSED, NULL); return ESP_OK; } diff --git a/main/input.h b/main/input.h index cdc382b2b..afbd69592 100644 --- a/main/input.h +++ b/main/input.h @@ -1,6 +1,6 @@ #ifndef INPUT_H_ #define INPUT_H_ -esp_err_t input_init(void); +esp_err_t input_init(void (*button_long_pressed_cb)(void)); #endif /* INPUT_H_ */ \ No newline at end of file diff --git a/main/main.c b/main/main.c index 30f7905e6..ab790c191 100644 --- a/main/main.c +++ b/main/main.c @@ -59,7 +59,7 @@ void app_main(void) //should we run the self test? if (should_test(&GLOBAL_STATE)) { self_test((void *) &GLOBAL_STATE); - vTaskDelay(60 * 60 * 1000 / portTICK_PERIOD_MS); + return; } SYSTEM_init_system(&GLOBAL_STATE); @@ -74,7 +74,7 @@ void app_main(void) GLOBAL_STATE.SYSTEM_MODULE.ssid[sizeof(GLOBAL_STATE.SYSTEM_MODULE.ssid)-1] = 0; // init and connect to wifi - wifi_init(wifi_ssid, wifi_pass, hostname); + wifi_init(wifi_ssid, wifi_pass, hostname, GLOBAL_STATE.SYSTEM_MODULE.ip_addr_str); generate_ssid(GLOBAL_STATE.SYSTEM_MODULE.ap_ssid); diff --git a/main/screen.c b/main/screen.c index 6cfe6a964..839b2cafe 100644 --- a/main/screen.c +++ b/main/screen.c @@ -1,16 +1,12 @@ #include "esp_log.h" #include "esp_err.h" #include "esp_check.h" -#include "esp_event.h" -#include "esp_netif.h" #include "lvgl.h" #include "esp_lvgl_port.h" #include "global_state.h" -#include "display.h" #include "screen.h" -#include "lwip/lwip_napt.h" -static const char * TAG = "screen"; +// static const char * TAG = "screen"; extern const lv_img_dsc_t logo; @@ -21,14 +17,14 @@ static TickType_t current_screen_counter; static GlobalState * GLOBAL_STATE; -static char ip_address_str[IP4ADDR_STRLEN_MAX]; - static lv_obj_t *hashrate_label; static lv_obj_t *efficiency_label; static lv_obj_t *difficulty_label; static lv_obj_t *chip_temp_label; -static lv_obj_t *self_test_labels[2]; +static lv_obj_t *self_test_message_label; +static lv_obj_t *self_test_result_label; +static lv_obj_t *self_test_finished_label; static double current_hashrate; static float current_power; @@ -36,18 +32,27 @@ static uint64_t current_difficulty; static float curreny_chip_temp; #define SCREEN_UPDATE_MS 500 -#define LOGO_DELAY_COUNT 5000/SCREEN_UPDATE_MS +#define LOGO_DELAY_COUNT 5000 / SCREEN_UPDATE_MS #define CAROUSEL_DELAY_COUNT 10000 / SCREEN_UPDATE_MS -static lv_obj_t * create_scr_self_test(SystemModule * module) { +static lv_obj_t * create_scr_self_test() { lv_obj_t * scr = lv_obj_create(NULL); lv_obj_set_flex_flow(scr, LV_FLEX_FLOW_COLUMN); lv_obj_set_flex_align(scr, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START); + lv_obj_t *label1 = lv_label_create(scr); lv_label_set_text(label1, "BITAXE SELF TEST"); - self_test_labels[0] = lv_label_create(scr); - self_test_labels[1] = lv_label_create(scr); + + self_test_message_label = lv_label_create(scr); + + self_test_result_label = lv_label_create(scr); + + self_test_finished_label = lv_label_create(scr); + lv_obj_set_width(self_test_finished_label, LV_HOR_RES); + lv_obj_add_flag(self_test_finished_label, LV_OBJ_FLAG_HIDDEN); + lv_label_set_long_mode(self_test_finished_label, LV_LABEL_LONG_SCROLL_CIRCULAR); + lv_label_set_text(self_test_finished_label, "Self test finished. Press BOOT button for 2 seconds to reset self test status and reboot the device."); return scr; } @@ -57,15 +62,20 @@ static lv_obj_t * create_scr_overheat(SystemModule * module) { lv_obj_set_flex_flow(scr, LV_FLEX_FLOW_COLUMN); lv_obj_set_flex_align(scr, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START); + lv_obj_t *label1 = lv_label_create(scr); lv_label_set_text(label1, "DEVICE OVERHEAT!"); + lv_obj_t *label2 = lv_label_create(scr); - lv_label_set_text(label2, "Power, frequency and fan configurations have been reset. Go to AxeOS to reconfigure device."); + lv_obj_set_width(label2, LV_HOR_RES); lv_label_set_long_mode(label2, LV_LABEL_LONG_SCROLL_CIRCULAR); + lv_label_set_text(label2, "Power, frequency and fan configurations have been reset. Go to AxeOS to reconfigure device."); + lv_obj_t *label3 = lv_label_create(scr); lv_label_set_text(label3, "Device IP:"); + lv_obj_t *label4 = lv_label_create(scr); - lv_label_set_text_static(label4, ip_address_str); + lv_label_set_text_static(label4, module->ip_addr_str); return scr; } @@ -75,11 +85,15 @@ static lv_obj_t * create_scr_configure(SystemModule * module) { lv_obj_set_flex_flow(scr, LV_FLEX_FLOW_COLUMN); lv_obj_set_flex_align(scr, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START); + lv_obj_t *label1 = lv_label_create(scr); - lv_label_set_text(label1, "Welcome to your new BitAxe! Connect to the configuration Wifi and connect the BitAxe to your network."); + lv_obj_set_width(label1, LV_HOR_RES); lv_label_set_long_mode(label1, LV_LABEL_LONG_SCROLL_CIRCULAR); + lv_label_set_text(label1, "Welcome to your new BitAxe! Connect to the configuration Wifi and connect the BitAxe to your network."); + lv_obj_t *label2 = lv_label_create(scr); lv_label_set_text(label2, "Configuration SSID:"); + lv_obj_t *label3 = lv_label_create(scr); lv_label_set_text(label3, module->ap_ssid); @@ -118,19 +132,25 @@ static lv_obj_t * create_scr_urls(SystemModule * module) { lv_obj_set_flex_flow(scr, LV_FLEX_FLOW_COLUMN); lv_obj_set_flex_align(scr, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START); + lv_obj_t *label1 = lv_label_create(scr); lv_label_set_text(label1, "Mining URL:"); + lv_obj_t *label2 = lv_label_create(scr); + lv_obj_set_width(label2, LV_HOR_RES); + lv_label_set_long_mode(label2, LV_LABEL_LONG_SCROLL_CIRCULAR); lv_label_set_text(label2, module->is_using_fallback ? module->fallback_pool_url : module->pool_url); + lv_obj_t *label3 = lv_label_create(scr); lv_label_set_text(label3, "Bitaxe IP:"); + lv_obj_t *label4 = lv_label_create(scr); - lv_label_set_text_static(label4, ip_address_str); + lv_label_set_text_static(label4, module->ip_addr_str); return scr; } -static lv_obj_t * create_scr_stats(SystemModule * module, PowerManagementModule * power_management) { +static lv_obj_t * create_scr_stats() { lv_obj_t * scr = lv_obj_create(NULL); lv_obj_set_flex_flow(scr, LV_FLEX_FLOW_COLUMN); @@ -138,10 +158,13 @@ static lv_obj_t * create_scr_stats(SystemModule * module, PowerManagementModule hashrate_label = lv_label_create(scr); lv_label_set_text(hashrate_label, "Gh/s: n/a"); + efficiency_label = lv_label_create(scr); lv_label_set_text(efficiency_label, "J/Th: n/a"); + difficulty_label = lv_label_create(scr); lv_label_set_text(difficulty_label, "Best: n/a"); + chip_temp_label = lv_label_create(scr); lv_label_set_text(chip_temp_label, "Temp: n/a"); @@ -165,20 +188,19 @@ static void screen_show(screen_t screen) static void screen_update_cb(lv_timer_t * timer) { - SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; - PowerManagementModule * power_management = &GLOBAL_STATE->POWER_MANAGEMENT_MODULE; + if (GLOBAL_STATE->SELF_TEST_MODULE.active) { - if (module->overheat_mode == 1) { - screen_show(SCR_OVERHEAT); - return; - } - - if (GLOBAL_STATE->SELF_TEST_MODULE.running) { screen_show(SCR_SELF_TEST); - return; - } - if (current_screen == SCR_SELF_TEST) { + SelfTestModule * self_test = &GLOBAL_STATE->SELF_TEST_MODULE; + + lv_label_set_text(self_test_message_label, self_test->message); + + if (self_test->finished) { + lv_label_set_text(self_test_result_label, self_test->result ? "TESTS PASS!" : "TESTS FAIL!"); + + lv_obj_remove_flag(self_test_finished_label, LV_OBJ_FLAG_HIDDEN); + } return; } @@ -189,6 +211,14 @@ static void screen_update_cb(lv_timer_t * timer) return; } + SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; + + if (module->overheat_mode == 1) { + screen_show(SCR_OVERHEAT); + + return; + } + if (module->ssid[0] == '\0') { screen_show(SCR_CONFIGURE); return; @@ -222,6 +252,8 @@ static void screen_update_cb(lv_timer_t * timer) // Carousel + PowerManagementModule * power_management = &GLOBAL_STATE->POWER_MANAGEMENT_MODULE; + if (current_hashrate != module->current_hashrate) { lv_label_set_text_fmt(hashrate_label, "Gh/s: %.2f", module->current_hashrate); } @@ -257,49 +289,24 @@ void screen_next() } } -static void ip_event_handler(void * arg, esp_event_base_t event_base, int32_t event_id, void * event_data) -{ - if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) { - ip_event_got_ip_t * event = (ip_event_got_ip_t *) event_data; - esp_ip4addr_ntoa(&event->ip_info.ip, ip_address_str, IP4ADDR_STRLEN_MAX); - } -} - esp_err_t screen_start(void * pvParameters) { GLOBAL_STATE = (GlobalState *) pvParameters; - if (display_active()) { + if (GLOBAL_STATE->SYSTEM_MODULE.is_screen_active) { SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; - PowerManagementModule * power_management = &GLOBAL_STATE->POWER_MANAGEMENT_MODULE; - screens[SCR_SELF_TEST] = create_scr_self_test(module); + screens[SCR_SELF_TEST] = create_scr_self_test(); screens[SCR_OVERHEAT] = create_scr_overheat(module); screens[SCR_CONFIGURE] = create_scr_configure(module); screens[SCR_CONNECTION] = create_scr_connection(module); screens[SCR_LOGO] = create_scr_logo(); screens[SCR_URLS] = create_scr_urls(module); - screens[SCR_STATS] = create_scr_stats(module, power_management); + screens[SCR_STATS] = create_scr_stats(); lv_timer_create(screen_update_cb, SCREEN_UPDATE_MS, NULL); - - esp_event_handler_instance_t instance_got_ip; - ESP_RETURN_ON_ERROR(esp_event_handler_instance_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &ip_event_handler, NULL, &instance_got_ip), TAG, "Error registering IP event handler"); } return ESP_OK; } -// TODO: Transition code until self test code is revamped -void display_show_status(const char *messages[], size_t message_count) -{ - if (lvgl_port_lock(0)) { - - screen_show(SCR_SELF_TEST); - // messages[0] is ignored, it's already on the screen - lv_label_set_text(self_test_labels[0], messages[1]); - lv_label_set_text(self_test_labels[1], messages[2]); - lvgl_port_unlock(); - } -} - diff --git a/main/screen.h b/main/screen.h index 55214df84..1d585d267 100644 --- a/main/screen.h +++ b/main/screen.h @@ -17,6 +17,5 @@ typedef enum { esp_err_t screen_start(void * pvParameters); void screen_next(void); -void display_show_status(const char *messages[], size_t message_count); #endif /* SCREEN_H_ */ \ No newline at end of file diff --git a/main/self_test/self_test.c b/main/self_test/self_test.c index 816e1189d..52a676c5d 100644 --- a/main/self_test/self_test.c +++ b/main/self_test/self_test.c @@ -22,18 +22,9 @@ #include "utils.h" #include "TPS546.h" - -#define BUTTON_BOOT GPIO_NUM_0 -#define LONG_PRESS_DURATION_MS 2000 // Define what constitutes a long press -#define ESP_INTR_FLAG_DEFAULT 0 //wtf is this for esp-idf? - #define TESTS_FAILED 0 #define TESTS_PASSED 1 -// Define event bits -#define EVENT_SHORT_PRESS 1 -#define EVENT_LONG_PRESS 2 - /////Test Constants///// //Test Fan Speed #define FAN_SPEED_TARGET_MIN 1000 //RPM @@ -54,19 +45,10 @@ // #define HASHRATE_TARGET_ULTRA 1000 //GH/s // #define HASHRATE_TARGET_MAX 2000 //GH/s - static const char * TAG = "self_test"; -const char *messages[] = {"", "", "", ""}; - -// Create an event group -EventGroupHandle_t xTestsEventGroup; -TimerHandle_t xButtonTimer; -bool button_pressed = false; //local function prototypes static void tests_done(GlobalState * GLOBAL_STATE, bool test_result); -static void configure_button_boot_interrupt(void); -void vButtonTimerCallback(TimerHandle_t xTimer); bool should_test(GlobalState * GLOBAL_STATE) { bool is_max = GLOBAL_STATE->asic_model == ASIC_BM1397; @@ -78,20 +60,15 @@ bool should_test(GlobalState * GLOBAL_STATE) { return false; } +static void reset_self_test() { + ESP_LOGI(TAG, "Long press detected, resetting self test flag and rebooting..."); + nvs_config_set_u16(NVS_CONFIG_SELF_TEST, 0); + esp_restart(); +} + static void display_msg(char * msg, GlobalState * GLOBAL_STATE) { - switch (GLOBAL_STATE->device_model) { - case DEVICE_MAX: - case DEVICE_ULTRA: - case DEVICE_SUPRA: - case DEVICE_GAMMA: - if (display_active()) { - messages[1] = msg; - display_show_status(messages, 4); - } - break; - default: - } + GLOBAL_STATE->SELF_TEST_MODULE.message = msg; } static esp_err_t test_fan_sense(GlobalState * GLOBAL_STATE) @@ -160,19 +137,19 @@ esp_err_t test_display(GlobalState * GLOBAL_STATE) { case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - ESP_RETURN_ON_ERROR(display_init(), TAG, "DISPLAY init failed!"); + if (display_init(GLOBAL_STATE) != ESP_OK) { + display_msg("DISPLAY:FAIL", GLOBAL_STATE); + return ESP_FAIL; + } ESP_LOGI(TAG, "DISPLAY init success!"); - - messages[0] = "BITAXE SELF TESTING"; - display_show_status(messages, 4); - break; default: } return ESP_OK; } + esp_err_t test_input(GlobalState * GLOBAL_STATE) { // Input testing switch (GLOBAL_STATE->device_model) { @@ -180,13 +157,33 @@ esp_err_t test_input(GlobalState * GLOBAL_STATE) { case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - ESP_RETURN_ON_ERROR(input_init(), TAG, "INPUT init failed!"); + if (input_init(reset_self_test) != ESP_OK) { + display_msg("INPUT:FAIL", GLOBAL_STATE); + return ESP_FAIL; + } ESP_LOGI(TAG, "INPUT init success!"); + break; + default: + } - messages[0] = "BITAXE SELF TESTING"; - display_show_status(messages, 4); + return ESP_OK; +} +esp_err_t test_screen(GlobalState * GLOBAL_STATE) { + // Screen testing + switch (GLOBAL_STATE->device_model) { + case DEVICE_MAX: + case DEVICE_ULTRA: + case DEVICE_SUPRA: + case DEVICE_GAMMA: + if (screen_start(GLOBAL_STATE) != ESP_OK) { + display_msg("SCREEN:FAIL", GLOBAL_STATE); + return ESP_FAIL; + } + + ESP_LOGI(TAG, "SCREEN start success!"); + break; default: } @@ -284,8 +281,6 @@ esp_err_t test_init_peripherals(GlobalState * GLOBAL_STATE) { return ESP_OK; } - - /** * @brief Perform a self-test of the system. * @@ -300,10 +295,7 @@ void self_test(void * pvParameters) ESP_LOGI(TAG, "Running Self Tests"); - //create the button timer for long press detection - xButtonTimer = xTimerCreate("ButtonTimer", pdMS_TO_TICKS(LONG_PRESS_DURATION_MS), pdFALSE, (void*)0, vButtonTimerCallback); - - configure_button_boot_interrupt(); + GLOBAL_STATE->SELF_TEST_MODULE.active = true; //Run display tests if (test_display(GLOBAL_STATE) != ESP_OK) { @@ -311,12 +303,18 @@ void self_test(void * pvParameters) tests_done(GLOBAL_STATE, TESTS_FAILED); } - //Run display tests + //Run input tests if (test_input(GLOBAL_STATE) != ESP_OK) { ESP_LOGE(TAG, "Input test failed!"); tests_done(GLOBAL_STATE, TESTS_FAILED); } + //Run screen tests + if (test_screen(GLOBAL_STATE) != ESP_OK) { + ESP_LOGE(TAG, "Screen test failed!"); + tests_done(GLOBAL_STATE, TESTS_FAILED); + } + //Init peripherals EMC2101 and INA260 (if present) if (test_init_peripherals(GLOBAL_STATE) != ESP_OK) { ESP_LOGE(TAG, "Peripherals init failed!"); @@ -359,7 +357,6 @@ void self_test(void * pvParameters) GLOBAL_STATE->valid_jobs = malloc(sizeof(uint8_t) * 128); for (int i = 0; i < 128; i++) { - GLOBAL_STATE->ASIC_TASK_MODULE.active_jobs[i] = NULL; GLOBAL_STATE->valid_jobs[i] = 0; } @@ -494,15 +491,11 @@ void self_test(void * pvParameters) tests_done(GLOBAL_STATE, TESTS_PASSED); ESP_LOGI(TAG, "Self Tests Passed!!!"); - return; - + return; } -static void tests_done(GlobalState * GLOBAL_STATE, bool test_result) { - - // Create event group for the System task - xTestsEventGroup = xEventGroupCreate(); - +static void tests_done(GlobalState * GLOBAL_STATE, bool test_result) +{ if (test_result == TESTS_PASSED) { ESP_LOGI(TAG, "SELF TESTS PASS -- Press RESET to continue"); } else { @@ -514,80 +507,12 @@ static void tests_done(GlobalState * GLOBAL_STATE, bool test_result) { case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - if (display_active()) { - if (test_result == TESTS_PASSED) { - messages[2] = "TESTS PASS!"; - } else { - messages[2] = "TESTS FAIL!"; - } - messages[3] = "LONG PRESS BOOT"; - display_show_status(messages, 4); - } + GLOBAL_STATE->SELF_TEST_MODULE.result = test_result; + GLOBAL_STATE->SELF_TEST_MODULE.finished = true; break; default: } //wait here for a long press to reboot - while (1) { - - EventBits_t uxBits = xEventGroupWaitBits( - xTestsEventGroup, - EVENT_LONG_PRESS, - pdTRUE, // Clear bits on exit - pdFALSE, // Wait for any bit - portMAX_DELAY //wait forever - ); - - if (uxBits & EVENT_LONG_PRESS) { - ESP_LOGI(TAG, "Long press detected, rebooting"); - nvs_config_set_u16(NVS_CONFIG_SELF_TEST, 0); - esp_restart(); - } - - } -} - -void vButtonTimerCallback(TimerHandle_t xTimer) { - // Timer callback, set the long press event bit - xEventGroupSetBits(xTestsEventGroup, EVENT_LONG_PRESS); + vTaskDelay(portMAX_DELAY); } - -// Interrupt handler for BUTTON_BOOT -void IRAM_ATTR button_boot_isr_handler(void* arg) { - if (gpio_get_level(BUTTON_BOOT) == 0) { - // Button pressed, start the timer - if (!button_pressed) { - button_pressed = true; - xTimerStartFromISR(xButtonTimer, NULL); - } - } else { - // Button released, stop the timer and check the duration - if (button_pressed) { - button_pressed = false; - if (xTimerIsTimerActive(xButtonTimer)) { - xTimerStopFromISR(xButtonTimer, NULL); - //xEventGroupSetBitsFromISR(xTestsEventGroup, EVENT_SHORT_PRESS, NULL); //we don't care about a short press - } - } - } -} - -static void configure_button_boot_interrupt(void) { - // Configure the GPIO pin as input - gpio_config_t io_conf = { - .intr_type = GPIO_INTR_ANYEDGE, // Interrupt on both edges - .mode = GPIO_MODE_INPUT, // Set as input mode - .pin_bit_mask = (1ULL << BUTTON_BOOT), // Bit mask of the pin to configure - .pull_down_en = GPIO_PULLDOWN_DISABLE, // Disable pull-down mode - .pull_up_en = GPIO_PULLUP_ENABLE, // Enable pull-up mode - }; - gpio_config(&io_conf); - - // Install the ISR service - gpio_install_isr_service(ESP_INTR_FLAG_DEFAULT); - - // Attach the interrupt handler - gpio_isr_handler_add(BUTTON_BOOT, button_boot_isr_handler, NULL); - - ESP_LOGI(TAG, "BUTTON_BOOT interrupt configured"); -} \ No newline at end of file diff --git a/main/system.c b/main/system.c index 3b5c6f4c5..d5d1254a9 100644 --- a/main/system.c +++ b/main/system.c @@ -128,23 +128,25 @@ void SYSTEM_init_peripherals(GlobalState * GLOBAL_STATE) { ESP_LOGE(TAG, "Failed to ensure overheat_mode config"); } - //Init the OLED + //Init the DISPLAY switch (GLOBAL_STATE->device_model) { case DEVICE_MAX: case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - // oled - if (display_init() != ESP_OK) { + // display + if (display_init(GLOBAL_STATE) != ESP_OK) { ESP_LOGW(TAG, "OLED init failed!"); } else { ESP_LOGI(TAG, "OLED init success!"); + + GLOBAL_STATE->SYSTEM_MODULE.is_screen_active = true; } break; default: } - if (input_init() != ESP_OK) { + if (input_init(toggle_wifi_softap) != ESP_OK) { ESP_LOGW(TAG, "Input init failed!"); } From c0263dee6e2eb7b507078585cb09ccfeb74de378 Mon Sep 17 00:00:00 2001 From: mutatrum Date: Mon, 2 Dec 2024 09:33:12 +0100 Subject: [PATCH 13/23] Remove camelcase from Bitaxe --- main/screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/screen.c b/main/screen.c index 839b2cafe..08f634285 100644 --- a/main/screen.c +++ b/main/screen.c @@ -89,7 +89,7 @@ static lv_obj_t * create_scr_configure(SystemModule * module) { lv_obj_t *label1 = lv_label_create(scr); lv_obj_set_width(label1, LV_HOR_RES); lv_label_set_long_mode(label1, LV_LABEL_LONG_SCROLL_CIRCULAR); - lv_label_set_text(label1, "Welcome to your new BitAxe! Connect to the configuration Wifi and connect the BitAxe to your network."); + lv_label_set_text(label1, "Welcome to your new Bitaxe! Connect to the configuration Wifi and connect the Bitaxe to your network."); lv_obj_t *label2 = lv_label_create(scr); lv_label_set_text(label2, "Configuration SSID:"); From 183789f74fb1a97906b3e1d5352d9c1d68b8b5c9 Mon Sep 17 00:00:00 2001 From: mutatrum Date: Mon, 2 Dec 2024 10:49:59 +0100 Subject: [PATCH 14/23] Fix crash when display is not present --- main/display.c | 32 +++++++++++++++++++----------- main/input.c | 11 +++++++--- main/self_test/self_test.c | 7 ++++++- main/system.c | 5 ++--- main/tasks/power_management_task.c | 2 ++ 5 files changed, 38 insertions(+), 19 deletions(-) diff --git a/main/display.c b/main/display.c index 6fabd774e..0d0b0fc3a 100644 --- a/main/display.c +++ b/main/display.c @@ -74,9 +74,13 @@ esp_err_t display_init(void * pvParameters) ESP_RETURN_ON_ERROR(esp_lcd_new_panel_ssd1306(io_handle, &panel_config, &panel_handle), TAG, "No display found"); ESP_RETURN_ON_ERROR(esp_lcd_panel_reset(panel_handle), TAG, "Panel reset failed"); - ESP_RETURN_ON_ERROR(esp_lcd_panel_init(panel_handle), TAG, "Panel init failed"); - // ESP_RETURN_ON_ERROR(esp_lcd_panel_mirror(panel_handle, false, false), TAG, "Panel mirror failed"); - ESP_RETURN_ON_ERROR(esp_lcd_panel_invert_color(panel_handle, invert_screen), TAG, "Panel invert failed"); + esp_err_t esp_lcd_panel_init_err = esp_lcd_panel_init(panel_handle); + if (esp_lcd_panel_init_err != ESP_OK) { + ESP_LOGE(TAG, "Panel init failed, no display connected?"); + } else { + ESP_RETURN_ON_ERROR(esp_lcd_panel_invert_color(panel_handle, invert_screen), TAG, "Panel invert failed"); + // ESP_RETURN_ON_ERROR(esp_lcd_panel_mirror(panel_handle, false, false), TAG, "Panel mirror failed"); + } ESP_LOGI(TAG, "Initialize LVGL"); const lvgl_port_cfg_t lvgl_cfg = ESP_LVGL_PORT_INIT_CONFIG(); @@ -102,22 +106,26 @@ esp_err_t display_init(void * pvParameters) } }; - lv_style_init(&scr_style); - lv_style_set_text_font(&scr_style, &lv_font_portfolio_6x8); - lv_style_set_bg_opa(&scr_style, LV_OPA_COVER); - - lv_theme_set_apply_cb(&theme, theme_apply); - lv_disp_t * disp = lvgl_port_add_disp(&disp_cfg); if (lvgl_port_lock(0)) { lv_display_set_theme(disp, &theme); lvgl_port_unlock(); } - // 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"); + lv_style_init(&scr_style); + lv_style_set_text_font(&scr_style, &lv_font_portfolio_6x8); + lv_style_set_bg_opa(&scr_style, LV_OPA_COVER); - GLOBAL_STATE->SYSTEM_MODULE.is_screen_active = true; + lv_theme_set_apply_cb(&theme, theme_apply); + + if (esp_lcd_panel_init_err == ESP_OK) { + // 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"); + + GLOBAL_STATE->SYSTEM_MODULE.is_screen_active = true; + } else { + ESP_LOGW(TAG, "No display found."); + } return ESP_OK; } diff --git a/main/input.c b/main/input.c index 74b43afbd..8c7d36d6c 100644 --- a/main/input.c +++ b/main/input.c @@ -14,7 +14,6 @@ static const char * TAG = "input"; static lv_indev_state_t button_state = LV_INDEV_STATE_RELEASED; -static lv_point_t points[] = { {0, 0} }; // must be static static void (*button_long_pressed)(void) = NULL; @@ -46,6 +45,8 @@ static void button_long_pressed_event_cb(lv_event_t *e) esp_err_t input_init(void (*button_long_pressed_cb)(void)) { + ESP_LOGI(TAG, "Install button driver"); + button_long_pressed = button_long_pressed_cb; // Button handling @@ -61,12 +62,16 @@ esp_err_t input_init(void (*button_long_pressed_cb)(void)) ESP_RETURN_ON_ERROR(gpio_install_isr_service(ESP_INTR_FLAG_DEFAULT), TAG, "Error installing ISR service"); ESP_RETURN_ON_ERROR(gpio_isr_handler_add(BUTTON_BOOT_GPIO, button_isr_handler, NULL), TAG, "Error adding ISR handler"); + lv_group_t * group = lv_group_create(); + lv_group_set_default(group); + lv_group_add_obj(group, lv_obj_create(NULL)); // dummy screen for event handling, in case no display is attached + // Create input device lv_indev_t * indev = lv_indev_create(); - lv_indev_set_type(indev, LV_INDEV_TYPE_BUTTON); + lv_indev_set_type(indev, LV_INDEV_TYPE_KEYPAD); lv_indev_set_long_press_time(indev, LONG_PRESS_DURATION_MS); lv_indev_set_read_cb(indev, button_read); - lv_indev_set_button_points(indev, points); + lv_indev_set_group(indev, group); lv_indev_add_event_cb(indev, button_short_clicked_event_cb, LV_EVENT_SHORT_CLICKED, NULL); lv_indev_add_event_cb(indev, button_long_pressed_event_cb, LV_EVENT_LONG_PRESSED, NULL); diff --git a/main/self_test/self_test.c b/main/self_test/self_test.c index 52a676c5d..8edb3bf39 100644 --- a/main/self_test/self_test.c +++ b/main/self_test/self_test.c @@ -142,7 +142,12 @@ esp_err_t test_display(GlobalState * GLOBAL_STATE) { return ESP_FAIL; } - ESP_LOGI(TAG, "DISPLAY init success!"); + if (GLOBAL_STATE->SYSTEM_MODULE.is_screen_active) { + ESP_LOGI(TAG, "DISPLAY init success!"); + } else { + ESP_LOGW(TAG, "DISPLAY not found!"); + } + break; default: } diff --git a/main/system.c b/main/system.c index d5d1254a9..baf7faa0b 100644 --- a/main/system.c +++ b/main/system.c @@ -135,12 +135,10 @@ void SYSTEM_init_peripherals(GlobalState * GLOBAL_STATE) { case DEVICE_SUPRA: case DEVICE_GAMMA: // display - if (display_init(GLOBAL_STATE) != ESP_OK) { + if (display_init(GLOBAL_STATE) != ESP_OK || !GLOBAL_STATE->SYSTEM_MODULE.is_screen_active) { ESP_LOGW(TAG, "OLED init failed!"); } else { ESP_LOGI(TAG, "OLED init success!"); - - GLOBAL_STATE->SYSTEM_MODULE.is_screen_active = true; } break; default: @@ -163,6 +161,7 @@ void SYSTEM_notify_accepted_share(GlobalState * GLOBAL_STATE) module->shares_accepted++; } + void SYSTEM_notify_rejected_share(GlobalState * GLOBAL_STATE) { SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; diff --git a/main/tasks/power_management_task.c b/main/tasks/power_management_task.c index 77eed13a9..7ac987469 100644 --- a/main/tasks/power_management_task.c +++ b/main/tasks/power_management_task.c @@ -74,6 +74,8 @@ static double automatic_fan_speed(float chip_temp, GlobalState * GLOBAL_STATE) void POWER_MANAGEMENT_task(void * pvParameters) { + ESP_LOGI(TAG, "Starting"); + GlobalState * GLOBAL_STATE = (GlobalState *) pvParameters; PowerManagementModule * power_management = &GLOBAL_STATE->POWER_MANAGEMENT_MODULE; From 03e08e49e5a2279e7e37b56323411344efd8261e Mon Sep 17 00:00:00 2001 From: mutatrum Date: Mon, 2 Dec 2024 11:00:46 +0100 Subject: [PATCH 15/23] Make a minimal lv_conf.h --- main/lv_conf.h | 1156 ++---------------------------------------------- 1 file changed, 46 insertions(+), 1110 deletions(-) diff --git a/main/lv_conf.h b/main/lv_conf.h index 9410c9d13..979297a85 100644 --- a/main/lv_conf.h +++ b/main/lv_conf.h @@ -1,1127 +1,63 @@ -/** - * @file lv_conf.h - * Configuration file for v9.2.2 - */ - -/* - * Copy this file as `lv_conf.h` - * 1. simply next to the `lvgl` folder - * 2. or any other places and - * - define `LV_CONF_INCLUDE_SIMPLE` - * - add the path as include path - */ - -/* clang-format off */ -#if 1 /*Set it to "1" to enable content*/ - #ifndef LV_CONF_H #define LV_CONF_H -/*If you need to include anything here, do it inside the `__ASSEMBLY__` guard */ -#if 0 && defined(__ASSEMBLY__) -#include "my_include.h" -#endif - -/*==================== - COLOR SETTINGS - *====================*/ - -/*Color depth: 1 (I1), 8 (L8), 16 (RGB565), 24 (RGB888), 32 (XRGB8888)*/ #define LV_COLOR_DEPTH 1 -/*========================= - STDLIB WRAPPER SETTINGS - *=========================*/ - -/* Possible values - * - LV_STDLIB_BUILTIN: LVGL's built in implementation - * - LV_STDLIB_CLIB: Standard C functions, like malloc, strlen, etc - * - LV_STDLIB_MICROPYTHON: MicroPython implementation - * - LV_STDLIB_RTTHREAD: RT-Thread implementation - * - LV_STDLIB_CUSTOM: Implement the functions externally - */ -#define LV_USE_STDLIB_MALLOC LV_STDLIB_BUILTIN -#define LV_USE_STDLIB_STRING LV_STDLIB_BUILTIN -#define LV_USE_STDLIB_SPRINTF LV_STDLIB_BUILTIN - -#define LV_STDINT_INCLUDE -#define LV_STDDEF_INCLUDE -#define LV_STDBOOL_INCLUDE -#define LV_INTTYPES_INCLUDE -#define LV_LIMITS_INCLUDE -#define LV_STDARG_INCLUDE - -#if LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN - /*Size of the memory available for `lv_malloc()` in bytes (>= 2kB)*/ - #define LV_MEM_SIZE (64 * 1024U) /*[bytes]*/ - - /*Size of the memory expand for `lv_malloc()` in bytes*/ - #define LV_MEM_POOL_EXPAND_SIZE 0 - - /*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/ - #define LV_MEM_ADR 0 /*0: unused*/ - /*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/ - #if LV_MEM_ADR == 0 - #undef LV_MEM_POOL_INCLUDE - #undef LV_MEM_POOL_ALLOC - #endif -#endif /*LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN*/ - -/*==================== - HAL SETTINGS - *====================*/ - -/*Default display refresh, input device read and animation step period.*/ -#define LV_DEF_REFR_PERIOD 33 /*[ms]*/ - -/*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings. - *(Not so important, you can adjust it to modify default sizes and spaces)*/ -#define LV_DPI_DEF 130 /*[px/inch]*/ - -/*================= - * OPERATING SYSTEM - *=================*/ -/*Select an operating system to use. Possible options: - * - LV_OS_NONE - * - LV_OS_PTHREAD - * - LV_OS_FREERTOS - * - LV_OS_CMSIS_RTOS2 - * - LV_OS_RTTHREAD - * - LV_OS_WINDOWS - * - LV_OS_MQX - * - LV_OS_CUSTOM */ -#define LV_USE_OS LV_OS_FREERTOS - -#if LV_USE_OS == LV_OS_CUSTOM - #define LV_OS_CUSTOM_INCLUDE -#endif -#if LV_USE_OS == LV_OS_FREERTOS - /* - * Unblocking an RTOS task with a direct notification is 45% faster and uses less RAM - * than unblocking a task using an intermediary object such as a binary semaphore. - * RTOS task notifications can only be used when there is only one task that can be the recipient of the event. - */ - #define LV_USE_FREERTOS_TASK_NOTIFY 1 -#endif - -/*======================== - * RENDERING CONFIGURATION - *========================*/ - -/*Align the stride of all layers and images to this bytes*/ -#define LV_DRAW_BUF_STRIDE_ALIGN 1 - -/*Align the start address of draw_buf addresses to this bytes*/ -#define LV_DRAW_BUF_ALIGN 4 - -/*Using matrix for transformations. - *Requirements: - `LV_USE_MATRIX = 1`. - The rendering engine needs to support 3x3 matrix transformations.*/ -#define LV_DRAW_TRANSFORM_USE_MATRIX 0 - -/* If a widget has `style_opa < 255` (not `bg_opa`, `text_opa` etc) or not NORMAL blend mode - * it is buffered into a "simple" layer before rendering. The widget can be buffered in smaller chunks. - * "Transformed layers" (if `transform_angle/zoom` are set) use larger buffers - * and can't be drawn in chunks. */ - -/*The target buffer size for simple layer chunks.*/ -#define LV_DRAW_LAYER_SIMPLE_BUF_SIZE (24 * 1024) /*[bytes]*/ - -/* The stack size of the drawing thread. - * NOTE: If FreeType or ThorVG is enabled, it is recommended to set it to 32KB or more. - */ -#define LV_DRAW_THREAD_STACK_SIZE (8 * 1024) /*[bytes]*/ - -#define LV_USE_DRAW_SW 1 -#if LV_USE_DRAW_SW == 1 - - /* - * Selectively disable color format support in order to reduce code size. - * NOTE: some features use certain color formats internally, e.g. - * - gradients use RGB888 - * - bitmaps with transparency may use ARGB8888 - */ - - #define LV_DRAW_SW_SUPPORT_RGB565 1 - #define LV_DRAW_SW_SUPPORT_RGB565A8 0 - #define LV_DRAW_SW_SUPPORT_RGB888 0 - #define LV_DRAW_SW_SUPPORT_XRGB8888 0 - #define LV_DRAW_SW_SUPPORT_ARGB8888 0 - #define LV_DRAW_SW_SUPPORT_L8 0 - #define LV_DRAW_SW_SUPPORT_AL88 0 - #define LV_DRAW_SW_SUPPORT_A8 0 - #define LV_DRAW_SW_SUPPORT_I1 1 - - /* Set the number of draw unit. - * > 1 requires an operating system enabled in `LV_USE_OS` - * > 1 means multiple threads will render the screen in parallel */ - #define LV_DRAW_SW_DRAW_UNIT_CNT 1 - - /* Use Arm-2D to accelerate the sw render */ - #define LV_USE_DRAW_ARM2D_SYNC 0 - - /* Enable native helium assembly to be compiled */ - #define LV_USE_NATIVE_HELIUM_ASM 0 - - /* 0: use a simple renderer capable of drawing only simple rectangles with gradient, images, texts, and straight lines only - * 1: use a complex renderer capable of drawing rounded corners, shadow, skew lines, and arcs too */ - #define LV_DRAW_SW_COMPLEX 0 - - #if LV_DRAW_SW_COMPLEX == 1 - /*Allow buffering some shadow calculation. - *LV_DRAW_SW_SHADOW_CACHE_SIZE is the max. shadow size to buffer, where shadow size is `shadow_width + radius` - *Caching has LV_DRAW_SW_SHADOW_CACHE_SIZE^2 RAM cost*/ - #define LV_DRAW_SW_SHADOW_CACHE_SIZE 0 - - /* Set number of maximally cached circle data. - * The circumference of 1/4 circle are saved for anti-aliasing - * radius * 4 bytes are used per circle (the most often used radiuses are saved) - * 0: to disable caching */ - #define LV_DRAW_SW_CIRCLE_CACHE_SIZE 4 - #endif - - #define LV_USE_DRAW_SW_ASM LV_DRAW_SW_ASM_NONE - - #if LV_USE_DRAW_SW_ASM == LV_DRAW_SW_ASM_CUSTOM - #define LV_DRAW_SW_ASM_CUSTOM_INCLUDE "" - #endif - - /* Enable drawing complex gradients in software: linear at an angle, radial or conical */ - #define LV_USE_DRAW_SW_COMPLEX_GRADIENTS 0 -#endif - -/* Use NXP's VG-Lite GPU on iMX RTxxx platforms. */ -#define LV_USE_DRAW_VGLITE 0 - -#if LV_USE_DRAW_VGLITE - /* Enable blit quality degradation workaround recommended for screen's dimension > 352 pixels. */ - #define LV_USE_VGLITE_BLIT_SPLIT 0 - - #if LV_USE_OS - /* Use additional draw thread for VG-Lite processing.*/ - #define LV_USE_VGLITE_DRAW_THREAD 1 - - #if LV_USE_VGLITE_DRAW_THREAD - /* Enable VGLite draw async. Queue multiple tasks and flash them once to the GPU. */ - #define LV_USE_VGLITE_DRAW_ASYNC 1 - #endif - #endif - - /* Enable VGLite asserts. */ - #define LV_USE_VGLITE_ASSERT 0 -#endif - -/* Use NXP's PXP on iMX RTxxx platforms. */ -#define LV_USE_PXP 0 - -#if LV_USE_PXP - /* Use PXP for drawing.*/ - #define LV_USE_DRAW_PXP 1 - - /* Use PXP to rotate display.*/ - #define LV_USE_ROTATE_PXP 0 - - #if LV_USE_DRAW_PXP && LV_USE_OS - /* Use additional draw thread for PXP processing.*/ - #define LV_USE_PXP_DRAW_THREAD 1 - #endif - - /* Enable PXP asserts. */ - #define LV_USE_PXP_ASSERT 0 -#endif - -/* Use Renesas Dave2D on RA platforms. */ -#define LV_USE_DRAW_DAVE2D 0 - -/* Draw using cached SDL textures*/ -#define LV_USE_DRAW_SDL 0 - -/* Use VG-Lite GPU. */ -#define LV_USE_DRAW_VG_LITE 0 - -#if LV_USE_DRAW_VG_LITE - /* Enable VG-Lite custom external 'gpu_init()' function */ - #define LV_VG_LITE_USE_GPU_INIT 0 - - /* Enable VG-Lite assert. */ - #define LV_VG_LITE_USE_ASSERT 0 - - /* VG-Lite flush commit trigger threshold. GPU will try to batch these many draw tasks. */ - #define LV_VG_LITE_FLUSH_MAX_COUNT 8 - - /* Enable border to simulate shadow - * NOTE: which usually improves performance, - * but does not guarantee the same rendering quality as the software. */ - #define LV_VG_LITE_USE_BOX_SHADOW 0 - - /* VG-Lite gradient maximum cache number. - * NOTE: The memory usage of a single gradient image is 4K bytes. - */ - #define LV_VG_LITE_GRAD_CACHE_CNT 32 - - /* VG-Lite stroke maximum cache number. - */ - #define LV_VG_LITE_STROKE_CACHE_CNT 32 - -#endif - -/*======================= - * FEATURE CONFIGURATION - *=======================*/ - -/*------------- - * Logging - *-----------*/ - -/*Enable the log module*/ -#define LV_USE_LOG 0 -#if LV_USE_LOG - - /*How important log should be added: - *LV_LOG_LEVEL_TRACE A lot of logs to give detailed information - *LV_LOG_LEVEL_INFO Log important events - *LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem - *LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail - *LV_LOG_LEVEL_USER Only logs added by the user - *LV_LOG_LEVEL_NONE Do not log anything*/ - #define LV_LOG_LEVEL LV_LOG_LEVEL_WARN - - /*1: Print the log with 'printf'; - *0: User need to register a callback with `lv_log_register_print_cb()`*/ - #define LV_LOG_PRINTF 0 - - /*Set callback to print the logs. - *E.g `my_print`. The prototype should be `void my_print(lv_log_level_t level, const char * buf)` - *Can be overwritten by `lv_log_register_print_cb`*/ - //#define LV_LOG_PRINT_CB - - /*1: Enable print timestamp; - *0: Disable print timestamp*/ - #define LV_LOG_USE_TIMESTAMP 1 - - /*1: Print file and line number of the log; - *0: Do not print file and line number of the log*/ - #define LV_LOG_USE_FILE_LINE 1 - - - /*Enable/disable LV_LOG_TRACE in modules that produces a huge number of logs*/ - #define LV_LOG_TRACE_MEM 1 - #define LV_LOG_TRACE_TIMER 1 - #define LV_LOG_TRACE_INDEV 1 - #define LV_LOG_TRACE_DISP_REFR 1 - #define LV_LOG_TRACE_EVENT 1 - #define LV_LOG_TRACE_OBJ_CREATE 1 - #define LV_LOG_TRACE_LAYOUT 1 - #define LV_LOG_TRACE_ANIM 1 - #define LV_LOG_TRACE_CACHE 1 +#define LV_USE_OS LV_OS_FREERTOS -#endif /*LV_USE_LOG*/ +#define LV_DRAW_SW_SUPPORT_RGB565A8 0 +#define LV_DRAW_SW_SUPPORT_RGB888 0 +#define LV_DRAW_SW_SUPPORT_XRGB8888 0 +#define LV_DRAW_SW_SUPPORT_ARGB8888 0 +#define LV_DRAW_SW_SUPPORT_L8 0 +#define LV_DRAW_SW_SUPPORT_AL88 0 +#define LV_DRAW_SW_SUPPORT_A8 0 -/*------------- - * Asserts - *-----------*/ +#define LV_DRAW_SW_COMPLEX 0 -/*Enable asserts if an operation is failed or an invalid data is found. - *If LV_USE_LOG is enabled an error message will be printed on failure*/ -#define LV_USE_ASSERT_NULL 1 /*Check if the parameter is NULL. (Very fast, recommended)*/ -#define LV_USE_ASSERT_MALLOC 1 /*Checks is the memory is successfully allocated or no. (Very fast, recommended)*/ -#define LV_USE_ASSERT_STYLE 0 /*Check if the styles are properly initialized. (Very fast, recommended)*/ -#define LV_USE_ASSERT_MEM_INTEGRITY 0 /*Check the integrity of `lv_mem` after critical operations. (Slow)*/ -#define LV_USE_ASSERT_OBJ 0 /*Check the object's type and existence (e.g. not deleted). (Slow)*/ +#define LV_USE_FLOAT 1 -/*Add a custom handler when assert happens e.g. to restart the MCU*/ -#define LV_ASSERT_HANDLER_INCLUDE -#define LV_ASSERT_HANDLER while(1); /*Halt by default*/ - -/*------------- - * Debug - *-----------*/ - -/*1: Draw random colored rectangles over the redrawn areas*/ -#define LV_USE_REFR_DEBUG 0 - -/*1: Draw a red overlay for ARGB layers and a green overlay for RGB layers*/ -#define LV_USE_LAYER_DEBUG 0 - -/*1: Draw overlays with different colors for each draw_unit's tasks. - *Also add the index number of the draw unit on white background. - *For layers add the index number of the draw unit on black background.*/ -#define LV_USE_PARALLEL_DRAW_DEBUG 0 - -/*------------- - * Others - *-----------*/ - -#define LV_ENABLE_GLOBAL_CUSTOM 0 -#if LV_ENABLE_GLOBAL_CUSTOM - /*Header to include for the custom 'lv_global' function"*/ - #define LV_GLOBAL_CUSTOM_INCLUDE -#endif - -/*Default cache size in bytes. - *Used by image decoders such as `lv_lodepng` to keep the decoded image in the memory. - *If size is not set to 0, the decoder will fail to decode when the cache is full. - *If size is 0, the cache function is not enabled and the decoded mem will be released immediately after use.*/ -#define LV_CACHE_DEF_SIZE 0 - -/*Default number of image header cache entries. The cache is used to store the headers of images - *The main logic is like `LV_CACHE_DEF_SIZE` but for image headers.*/ -#define LV_IMAGE_HEADER_CACHE_DEF_CNT 0 - -/*Number of stops allowed per gradient. Increase this to allow more stops. - *This adds (sizeof(lv_color_t) + 1) bytes per additional stop*/ -#define LV_GRADIENT_MAX_STOPS 2 - -/* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently. - * 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */ -#define LV_COLOR_MIX_ROUND_OFS 0 - -/* Add 2 x 32 bit variables to each lv_obj_t to speed up getting style properties */ -#define LV_OBJ_STYLE_CACHE 0 - -/* Add `id` field to `lv_obj_t` */ -#define LV_USE_OBJ_ID 0 - -/* Automatically assign an ID when obj is created */ -#define LV_OBJ_ID_AUTO_ASSIGN LV_USE_OBJ_ID - -/*Use the builtin obj ID handler functions: -* - lv_obj_assign_id: Called when a widget is created. Use a separate counter for each widget class as an ID. -* - lv_obj_id_compare: Compare the ID to decide if it matches with a requested value. -* - lv_obj_stringify_id: Return e.g. "button3" -* - lv_obj_free_id: Does nothing, as there is no memory allocation for the ID. -* When disabled these functions needs to be implemented by the user.*/ -#define LV_USE_OBJ_ID_BUILTIN 1 - -/*Use obj property set/get API*/ -#define LV_USE_OBJ_PROPERTY 0 - -/*Enable property name support*/ -#define LV_USE_OBJ_PROPERTY_NAME 1 - -/* VG-Lite Simulator */ -/*Requires: LV_USE_THORVG_INTERNAL or LV_USE_THORVG_EXTERNAL */ -#define LV_USE_VG_LITE_THORVG 0 - -#if LV_USE_VG_LITE_THORVG - - /*Enable LVGL's blend mode support*/ - #define LV_VG_LITE_THORVG_LVGL_BLEND_SUPPORT 0 - - /*Enable YUV color format support*/ - #define LV_VG_LITE_THORVG_YUV_SUPPORT 0 - - /*Enable Linear gradient extension support*/ - #define LV_VG_LITE_THORVG_LINEAR_GRADIENT_EXT_SUPPORT 0 - - /*Enable 16 pixels alignment*/ - #define LV_VG_LITE_THORVG_16PIXELS_ALIGN 1 - - /*Buffer address alignment*/ - #define LV_VG_LITE_THORVG_BUF_ADDR_ALIGN 64 - - /*Enable multi-thread render*/ - #define LV_VG_LITE_THORVG_THREAD_RENDER 0 - -#endif - -/*===================== - * COMPILER SETTINGS - *====================*/ - -/*For big endian systems set to 1*/ -#define LV_BIG_ENDIAN_SYSTEM 0 - -/*Define a custom attribute to `lv_tick_inc` function*/ -#define LV_ATTRIBUTE_TICK_INC - -/*Define a custom attribute to `lv_timer_handler` function*/ -#define LV_ATTRIBUTE_TIMER_HANDLER - -/*Define a custom attribute to `lv_display_flush_ready` function*/ -#define LV_ATTRIBUTE_FLUSH_READY - -/*Required alignment size for buffers*/ -#define LV_ATTRIBUTE_MEM_ALIGN_SIZE 1 - -/*Will be added where memories needs to be aligned (with -Os data might not be aligned to boundary by default). - * E.g. __attribute__((aligned(4)))*/ -#define LV_ATTRIBUTE_MEM_ALIGN - -/*Attribute to mark large constant arrays for example font's bitmaps*/ -#define LV_ATTRIBUTE_LARGE_CONST - -/*Compiler prefix for a big array declaration in RAM*/ -#define LV_ATTRIBUTE_LARGE_RAM_ARRAY - -/*Place performance critical functions into a faster memory (e.g RAM)*/ -#define LV_ATTRIBUTE_FAST_MEM - -/*Export integer constant to binding. This macro is used with constants in the form of LV_ that - *should also appear on LVGL binding API such as MicroPython.*/ -#define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning /*The default value just prevents GCC warning*/ - -/*Prefix all global extern data with this*/ -#define LV_ATTRIBUTE_EXTERN_DATA - -/* Use `float` as `lv_value_precise_t` */ -#define LV_USE_FLOAT 1 - -/*Enable matrix support - *Requires `LV_USE_FLOAT = 1`*/ -#define LV_USE_MATRIX 0 - -/*Include `lvgl_private.h` in `lvgl.h` to access internal data and functions by default*/ -#define LV_USE_PRIVATE_API 0 - -/*================== - * FONT USAGE - *===================*/ - -/*Montserrat fonts with ASCII range and some symbols using bpp = 4 - *https://fonts.google.com/specimen/Montserrat*/ -#define LV_FONT_MONTSERRAT_8 0 -#define LV_FONT_MONTSERRAT_10 0 -#define LV_FONT_MONTSERRAT_12 0 #define LV_FONT_MONTSERRAT_14 0 -#define LV_FONT_MONTSERRAT_16 0 -#define LV_FONT_MONTSERRAT_18 0 -#define LV_FONT_MONTSERRAT_20 0 -#define LV_FONT_MONTSERRAT_22 0 -#define LV_FONT_MONTSERRAT_24 0 -#define LV_FONT_MONTSERRAT_26 0 -#define LV_FONT_MONTSERRAT_28 0 -#define LV_FONT_MONTSERRAT_30 0 -#define LV_FONT_MONTSERRAT_32 0 -#define LV_FONT_MONTSERRAT_34 0 -#define LV_FONT_MONTSERRAT_36 0 -#define LV_FONT_MONTSERRAT_38 0 -#define LV_FONT_MONTSERRAT_40 0 -#define LV_FONT_MONTSERRAT_42 0 -#define LV_FONT_MONTSERRAT_44 0 -#define LV_FONT_MONTSERRAT_46 0 -#define LV_FONT_MONTSERRAT_48 0 - -/*Demonstrate special features*/ -#define LV_FONT_MONTSERRAT_28_COMPRESSED 0 /*bpp = 3*/ -#define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 0 /*Hebrew, Arabic, Persian letters and all their forms*/ -#define LV_FONT_SIMSUN_14_CJK 0 /*1000 most common CJK radicals*/ -#define LV_FONT_SIMSUN_16_CJK 0 /*1000 most common CJK radicals*/ - -/*Pixel perfect monospace fonts*/ -#define LV_FONT_UNSCII_8 0 -#define LV_FONT_UNSCII_16 0 -/*Optionally declare custom fonts here. - *You can use these fonts as default font too and they will be available globally. - *E.g. #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) LV_FONT_DECLARE(my_font_2)*/ #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(lv_font_portfolio_6x8) +#define LV_FONT_DEFAULT &lv_font_portfolio_6x8 + +#define LV_WIDGETS_HAS_DEFAULT_VALUE 0 + +#define LV_USE_ANIMIMG 0 +#define LV_USE_ARC 0 +#define LV_USE_BAR 0 +#define LV_USE_BUTTON 0 +#define LV_USE_BUTTONMATRIX 0 +#define LV_USE_CALENDAR 0 +#define LV_USE_CANVAS 0 +#define LV_USE_CHART 0 +#define LV_USE_CHECKBOX 0 +#define LV_USE_DROPDOWN 0 +#define LV_USE_IMAGEBUTTON 0 +#define LV_USE_KEYBOARD 0 +#define LV_USE_LED 0 +#define LV_USE_LINE 0 +#define LV_USE_LIST 0 +#define LV_USE_MENU 0 +#define LV_USE_MSGBOX 0 +#define LV_USE_ROLLER 0 +#define LV_USE_SCALE 0 +#define LV_USE_SLIDER 0 +#define LV_USE_SPAN 0 +#define LV_USE_SPINBOX 0 +#define LV_USE_SPINNER 0 +#define LV_USE_SWITCH 0 +#define LV_USE_TEXTAREA 0 +#define LV_USE_TABLE 0 +#define LV_USE_TABVIEW 0 +#define LV_USE_TILEVIEW 0 +#define LV_USE_WIN 0 -/*Always set a default font*/ -#define LV_FONT_DEFAULT &lv_font_portfolio_6x8 - -/*Enable handling large font and/or fonts with a lot of characters. - *The limit depends on the font size, font face and bpp. - *Compiler error will be triggered if a font needs it.*/ -#define LV_FONT_FMT_TXT_LARGE 0 - -/*Enables/disables support for compressed fonts.*/ -#define LV_USE_FONT_COMPRESSED 0 - -/*Enable drawing placeholders when glyph dsc is not found*/ -#define LV_USE_FONT_PLACEHOLDER 0 - -/*================= - * TEXT SETTINGS - *=================*/ - -/** - * Select a character encoding for strings. - * Your IDE or editor should have the same character encoding - * - LV_TXT_ENC_UTF8 - * - LV_TXT_ENC_ASCII - */ -#define LV_TXT_ENC LV_TXT_ENC_UTF8 - -/*Can break (wrap) texts on these chars*/ -#define LV_TXT_BREAK_CHARS " ,.;:-_)]}" - -/*If a word is at least this long, will break wherever "prettiest" - *To disable, set to a value <= 0*/ -#define LV_TXT_LINE_BREAK_LONG_LEN 0 - -/*Minimum number of characters in a long word to put on a line before a break. - *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ -#define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3 - -/*Minimum number of characters in a long word to put on a line after a break. - *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ -#define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3 - -/*Support bidirectional texts. Allows mixing Left-to-Right and Right-to-Left texts. - *The direction will be processed according to the Unicode Bidirectional Algorithm: - *https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ -#define LV_USE_BIDI 0 -#if LV_USE_BIDI - /*Set the default direction. Supported values: - *`LV_BASE_DIR_LTR` Left-to-Right - *`LV_BASE_DIR_RTL` Right-to-Left - *`LV_BASE_DIR_AUTO` detect texts base direction*/ - #define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO -#endif - -/*Enable Arabic/Persian processing - *In these languages characters should be replaced with another form based on their position in the text*/ -#define LV_USE_ARABIC_PERSIAN_CHARS 0 - -/*================== - * WIDGETS - *================*/ - -/*Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.html*/ - -#define LV_WIDGETS_HAS_DEFAULT_VALUE 0 - -#define LV_USE_ANIMIMG 0 - -#define LV_USE_ARC 0 - -#define LV_USE_BAR 0 - -#define LV_USE_BUTTON 0 - -#define LV_USE_BUTTONMATRIX 0 - -#define LV_USE_CALENDAR 0 -#if LV_USE_CALENDAR - #define LV_CALENDAR_WEEK_STARTS_MONDAY 0 - #if LV_CALENDAR_WEEK_STARTS_MONDAY - #define LV_CALENDAR_DEFAULT_DAY_NAMES {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"} - #else - #define LV_CALENDAR_DEFAULT_DAY_NAMES {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"} - #endif - - #define LV_CALENDAR_DEFAULT_MONTH_NAMES {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"} - #define LV_USE_CALENDAR_HEADER_ARROW 1 - #define LV_USE_CALENDAR_HEADER_DROPDOWN 1 - #define LV_USE_CALENDAR_CHINESE 0 -#endif /*LV_USE_CALENDAR*/ - -#define LV_USE_CANVAS 0 - -#define LV_USE_CHART 0 - -#define LV_USE_CHECKBOX 0 - -#define LV_USE_DROPDOWN 0 /*Requires: lv_label*/ - -#define LV_USE_IMAGE 1 /*Requires: lv_label*/ - -#define LV_USE_IMAGEBUTTON 0 - -#define LV_USE_KEYBOARD 0 - -#define LV_USE_LABEL 1 -#if LV_USE_LABEL - #define LV_LABEL_TEXT_SELECTION 1 /*Enable selecting text of the label*/ - #define LV_LABEL_LONG_TXT_HINT 1 /*Store some extra info in labels to speed up drawing of very long texts*/ - #define LV_LABEL_WAIT_CHAR_COUNT 3 /*The count of wait chart*/ -#endif - -#define LV_USE_LED 0 - -#define LV_USE_LINE 0 - -#define LV_USE_LIST 0 - -#define LV_USE_LOTTIE 0 /*Requires: lv_canvas, thorvg */ - -#define LV_USE_MENU 0 - -#define LV_USE_MSGBOX 0 - -#define LV_USE_ROLLER 0 /*Requires: lv_label*/ - -#define LV_USE_SCALE 0 - -#define LV_USE_SLIDER 0 /*Requires: lv_bar*/ - -#define LV_USE_SPAN 0 -#if LV_USE_SPAN - /*A line text can contain maximum num of span descriptor */ - #define LV_SPAN_SNIPPET_STACK_SIZE 64 -#endif - -#define LV_USE_SPINBOX 0 - -#define LV_USE_SPINNER 0 - -#define LV_USE_SWITCH 0 - -#define LV_USE_TEXTAREA 0 /*Requires: lv_label*/ -#if LV_USE_TEXTAREA != 0 - #define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/ -#endif - -#define LV_USE_TABLE 0 - -#define LV_USE_TABVIEW 0 - -#define LV_USE_TILEVIEW 0 - -#define LV_USE_WIN 0 - -/*================== - * THEMES - *==================*/ - -/*A simple, impressive and very complete theme*/ #define LV_USE_THEME_DEFAULT 0 -#if LV_USE_THEME_DEFAULT - - /*0: Light mode; 1: Dark mode*/ - #define LV_THEME_DEFAULT_DARK 0 - - /*1: Enable grow on press*/ - #define LV_THEME_DEFAULT_GROW 1 - - /*Default transition time in [ms]*/ - #define LV_THEME_DEFAULT_TRANSITION_TIME 80 -#endif /*LV_USE_THEME_DEFAULT*/ - -/*A very simple theme that is a good starting point for a custom theme*/ -#define LV_USE_THEME_SIMPLE 0 - -/*A theme designed for monochrome displays*/ -#define LV_USE_THEME_MONO 0 - -/*================== - * LAYOUTS - *==================*/ - -/*A layout similar to Flexbox in CSS.*/ -#define LV_USE_FLEX 1 - -/*A layout similar to Grid in CSS.*/ -#define LV_USE_GRID 1 - -/*==================== - * 3RD PARTS LIBRARIES - *====================*/ - -/*File system interfaces for common APIs */ - -/*Setting a default driver letter allows skipping the driver prefix in filepaths*/ -#define LV_FS_DEFAULT_DRIVE_LETTER '\0' - -/*API for fopen, fread, etc*/ -#define LV_USE_FS_STDIO 0 -#if LV_USE_FS_STDIO - #define LV_FS_STDIO_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ - #define LV_FS_STDIO_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/ - #define LV_FS_STDIO_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ -#endif - -/*API for open, read, etc*/ -#define LV_USE_FS_POSIX 0 -#if LV_USE_FS_POSIX - #define LV_FS_POSIX_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ - #define LV_FS_POSIX_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/ - #define LV_FS_POSIX_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ -#endif - -/*API for CreateFile, ReadFile, etc*/ -#define LV_USE_FS_WIN32 0 -#if LV_USE_FS_WIN32 - #define LV_FS_WIN32_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ - #define LV_FS_WIN32_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/ - #define LV_FS_WIN32_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ -#endif - -/*API for FATFS (needs to be added separately). Uses f_open, f_read, etc*/ -#define LV_USE_FS_FATFS 0 -#if LV_USE_FS_FATFS - #define LV_FS_FATFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ - #define LV_FS_FATFS_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ -#endif - -/*API for memory-mapped file access. */ -#define LV_USE_FS_MEMFS 0 -#if LV_USE_FS_MEMFS - #define LV_FS_MEMFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ -#endif - -/*API for LittleFs. */ -#define LV_USE_FS_LITTLEFS 0 -#if LV_USE_FS_LITTLEFS - #define LV_FS_LITTLEFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ -#endif - -/*API for Arduino LittleFs. */ -#define LV_USE_FS_ARDUINO_ESP_LITTLEFS 0 -#if LV_USE_FS_ARDUINO_ESP_LITTLEFS - #define LV_FS_ARDUINO_ESP_LITTLEFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ -#endif - -/*API for Arduino Sd. */ -#define LV_USE_FS_ARDUINO_SD 0 -#if LV_USE_FS_ARDUINO_SD - #define LV_FS_ARDUINO_SD_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ -#endif - -/*LODEPNG decoder library*/ -#define LV_USE_LODEPNG 0 - -/*PNG decoder(libpng) library*/ -#define LV_USE_LIBPNG 0 - -/*BMP decoder library*/ -#define LV_USE_BMP 0 - -/* JPG + split JPG decoder library. - * Split JPG is a custom format optimized for embedded systems. */ -#define LV_USE_TJPGD 0 - -/* libjpeg-turbo decoder library. - * Supports complete JPEG specifications and high-performance JPEG decoding. */ -#define LV_USE_LIBJPEG_TURBO 0 - -/*GIF decoder library*/ -#define LV_USE_GIF 0 -#if LV_USE_GIF - /*GIF decoder accelerate*/ - #define LV_GIF_CACHE_DECODE_DATA 0 -#endif - - -/*Decode bin images to RAM*/ -#define LV_BIN_DECODER_RAM_LOAD 0 - -/*RLE decompress library*/ -#define LV_USE_RLE 0 - -/*QR code library*/ -#define LV_USE_QRCODE 0 - -/*Barcode code library*/ -#define LV_USE_BARCODE 0 - -/*FreeType library*/ -#define LV_USE_FREETYPE 0 -#if LV_USE_FREETYPE - /*Let FreeType to use LVGL memory and file porting*/ - #define LV_FREETYPE_USE_LVGL_PORT 0 - - /*Cache count of the glyphs in FreeType. It means the number of glyphs that can be cached. - *The higher the value, the more memory will be used.*/ - #define LV_FREETYPE_CACHE_FT_GLYPH_CNT 256 -#endif - -/* Built-in TTF decoder */ -#define LV_USE_TINY_TTF 0 -#if LV_USE_TINY_TTF - /* Enable loading TTF data from files */ - #define LV_TINY_TTF_FILE_SUPPORT 0 - #define LV_TINY_TTF_CACHE_GLYPH_CNT 256 -#endif - -/*Rlottie library*/ -#define LV_USE_RLOTTIE 0 - -/*Enable Vector Graphic APIs - *Requires `LV_USE_MATRIX = 1`*/ -#define LV_USE_VECTOR_GRAPHIC 0 +#define LV_USE_THEME_SIMPLE 0 +#define LV_USE_THEME_MONO 0 -/* Enable ThorVG (vector graphics library) from the src/libs folder */ -#define LV_USE_THORVG_INTERNAL 0 - -/* Enable ThorVG by assuming that its installed and linked to the project */ -#define LV_USE_THORVG_EXTERNAL 0 - -/*Use lvgl built-in LZ4 lib*/ -#define LV_USE_LZ4_INTERNAL 0 - -/*Use external LZ4 library*/ -#define LV_USE_LZ4_EXTERNAL 0 - -/*FFmpeg library for image decoding and playing videos - *Supports all major image formats so do not enable other image decoder with it*/ -#define LV_USE_FFMPEG 0 -#if LV_USE_FFMPEG - /*Dump input information to stderr*/ - #define LV_FFMPEG_DUMP_FORMAT 0 -#endif - -/*================== - * OTHERS - *==================*/ - -/*1: Enable API to take snapshot for object*/ -#define LV_USE_SNAPSHOT 0 - -/*1: Enable system monitor component*/ -#define LV_USE_SYSMON 0 -#if LV_USE_SYSMON - /*Get the idle percentage. E.g. uint32_t my_get_idle(void);*/ - #define LV_SYSMON_GET_IDLE lv_timer_get_idle - - /*1: Show CPU usage and FPS count - * Requires `LV_USE_SYSMON = 1`*/ - #define LV_USE_PERF_MONITOR 0 - #if LV_USE_PERF_MONITOR - #define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT - - /*0: Displays performance data on the screen, 1: Prints performance data using log.*/ - #define LV_USE_PERF_MONITOR_LOG_MODE 0 - #endif - - /*1: Show the used memory and the memory fragmentation - * Requires `LV_USE_STDLIB_MALLOC = LV_STDLIB_BUILTIN` - * Requires `LV_USE_SYSMON = 1`*/ - #define LV_USE_MEM_MONITOR 0 - #if LV_USE_MEM_MONITOR - #define LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_LEFT - #endif - -#endif /*LV_USE_SYSMON*/ - -/*1: Enable the runtime performance profiler*/ -#define LV_USE_PROFILER 0 -#if LV_USE_PROFILER - /*1: Enable the built-in profiler*/ - #define LV_USE_PROFILER_BUILTIN 1 - #if LV_USE_PROFILER_BUILTIN - /*Default profiler trace buffer size*/ - #define LV_PROFILER_BUILTIN_BUF_SIZE (16 * 1024) /*[bytes]*/ - #endif - - /*Header to include for the profiler*/ - #define LV_PROFILER_INCLUDE "lvgl/src/misc/lv_profiler_builtin.h" - - /*Profiler start point function*/ - #define LV_PROFILER_BEGIN LV_PROFILER_BUILTIN_BEGIN - - /*Profiler end point function*/ - #define LV_PROFILER_END LV_PROFILER_BUILTIN_END - - /*Profiler start point function with custom tag*/ - #define LV_PROFILER_BEGIN_TAG LV_PROFILER_BUILTIN_BEGIN_TAG - - /*Profiler end point function with custom tag*/ - #define LV_PROFILER_END_TAG LV_PROFILER_BUILTIN_END_TAG -#endif - -/*1: Enable Monkey test*/ -#define LV_USE_MONKEY 0 - -/*1: Enable grid navigation*/ -#define LV_USE_GRIDNAV 0 - -/*1: Enable lv_obj fragment*/ -#define LV_USE_FRAGMENT 0 - -/*1: Support using images as font in label or span widgets */ -#define LV_USE_IMGFONT 0 - -/*1: Enable an observer pattern implementation*/ -#define LV_USE_OBSERVER 1 - -/*1: Enable Pinyin input method*/ -/*Requires: lv_keyboard*/ -#define LV_USE_IME_PINYIN 0 -#if LV_USE_IME_PINYIN - /*1: Use default thesaurus*/ - /*If you do not use the default thesaurus, be sure to use `lv_ime_pinyin` after setting the thesaurus*/ - #define LV_IME_PINYIN_USE_DEFAULT_DICT 1 - /*Set the maximum number of candidate panels that can be displayed*/ - /*This needs to be adjusted according to the size of the screen*/ - #define LV_IME_PINYIN_CAND_TEXT_NUM 6 - - /*Use 9 key input(k9)*/ - #define LV_IME_PINYIN_USE_K9_MODE 1 - #if LV_IME_PINYIN_USE_K9_MODE == 1 - #define LV_IME_PINYIN_K9_CAND_TEXT_NUM 3 - #endif /*LV_IME_PINYIN_USE_K9_MODE*/ -#endif - -/*1: Enable file explorer*/ -/*Requires: lv_table*/ -#define LV_USE_FILE_EXPLORER 0 -#if LV_USE_FILE_EXPLORER - /*Maximum length of path*/ - #define LV_FILE_EXPLORER_PATH_MAX_LEN (128) - /*Quick access bar, 1:use, 0:not use*/ - /*Requires: lv_list*/ - #define LV_FILE_EXPLORER_QUICK_ACCESS 1 -#endif - -/*================== - * DEVICES - *==================*/ - -/*Use SDL to open window on PC and handle mouse and keyboard*/ -#define LV_USE_SDL 0 -#if LV_USE_SDL - #define LV_SDL_INCLUDE_PATH - #define LV_SDL_RENDER_MODE LV_DISPLAY_RENDER_MODE_DIRECT /*LV_DISPLAY_RENDER_MODE_DIRECT is recommended for best performance*/ - #define LV_SDL_BUF_COUNT 1 /*1 or 2*/ - #define LV_SDL_ACCELERATED 1 /*1: Use hardware acceleration*/ - #define LV_SDL_FULLSCREEN 0 /*1: Make the window full screen by default*/ - #define LV_SDL_DIRECT_EXIT 1 /*1: Exit the application when all SDL windows are closed*/ - #define LV_SDL_MOUSEWHEEL_MODE LV_SDL_MOUSEWHEEL_MODE_ENCODER /*LV_SDL_MOUSEWHEEL_MODE_ENCODER/CROWN*/ -#endif - -/*Use X11 to open window on Linux desktop and handle mouse and keyboard*/ -#define LV_USE_X11 0 -#if LV_USE_X11 - #define LV_X11_DIRECT_EXIT 1 /*Exit the application when all X11 windows have been closed*/ - #define LV_X11_DOUBLE_BUFFER 1 /*Use double buffers for rendering*/ - /*select only 1 of the following render modes (LV_X11_RENDER_MODE_PARTIAL preferred!)*/ - #define LV_X11_RENDER_MODE_PARTIAL 1 /*Partial render mode (preferred)*/ - #define LV_X11_RENDER_MODE_DIRECT 0 /*direct render mode*/ - #define LV_X11_RENDER_MODE_FULL 0 /*Full render mode*/ -#endif - -/*Use Wayland to open a window and handle input on Linux or BSD desktops */ -#define LV_USE_WAYLAND 0 -#if LV_USE_WAYLAND - #define LV_WAYLAND_WINDOW_DECORATIONS 0 /*Draw client side window decorations only necessary on Mutter/GNOME*/ - #define LV_WAYLAND_WL_SHELL 0 /*Use the legacy wl_shell protocol instead of the default XDG shell*/ -#endif - -/*Driver for /dev/fb*/ -#define LV_USE_LINUX_FBDEV 0 -#if LV_USE_LINUX_FBDEV - #define LV_LINUX_FBDEV_BSD 0 - #define LV_LINUX_FBDEV_RENDER_MODE LV_DISPLAY_RENDER_MODE_PARTIAL - #define LV_LINUX_FBDEV_BUFFER_COUNT 0 - #define LV_LINUX_FBDEV_BUFFER_SIZE 60 -#endif - -/*Use Nuttx to open window and handle touchscreen*/ -#define LV_USE_NUTTX 0 - -#if LV_USE_NUTTX - #define LV_USE_NUTTX_LIBUV 0 - - /*Use Nuttx custom init API to open window and handle touchscreen*/ - #define LV_USE_NUTTX_CUSTOM_INIT 0 - - /*Driver for /dev/lcd*/ - #define LV_USE_NUTTX_LCD 0 - #if LV_USE_NUTTX_LCD - #define LV_NUTTX_LCD_BUFFER_COUNT 0 - #define LV_NUTTX_LCD_BUFFER_SIZE 60 - #endif - - /*Driver for /dev/input*/ - #define LV_USE_NUTTX_TOUCHSCREEN 0 - -#endif - -/*Driver for /dev/dri/card*/ -#define LV_USE_LINUX_DRM 0 - -/*Interface for TFT_eSPI*/ -#define LV_USE_TFT_ESPI 0 - -/*Driver for evdev input devices*/ -#define LV_USE_EVDEV 0 - -/*Driver for libinput input devices*/ -#define LV_USE_LIBINPUT 0 - -#if LV_USE_LIBINPUT - #define LV_LIBINPUT_BSD 0 - - /*Full keyboard support*/ - #define LV_LIBINPUT_XKB 0 - #if LV_LIBINPUT_XKB - /*"setxkbmap -query" can help find the right values for your keyboard*/ - #define LV_LIBINPUT_XKB_KEY_MAP { .rules = NULL, .model = "pc101", .layout = "us", .variant = NULL, .options = NULL } - #endif -#endif - -/*Drivers for LCD devices connected via SPI/parallel port*/ -#define LV_USE_ST7735 0 -#define LV_USE_ST7789 0 -#define LV_USE_ST7796 0 -#define LV_USE_ILI9341 0 - -#define LV_USE_GENERIC_MIPI (LV_USE_ST7735 | LV_USE_ST7789 | LV_USE_ST7796 | LV_USE_ILI9341) - -/*Driver for Renesas GLCD*/ -#define LV_USE_RENESAS_GLCDC 0 - -/* LVGL Windows backend */ -#define LV_USE_WINDOWS 0 - -/* Use OpenGL to open window on PC and handle mouse and keyboard */ -#define LV_USE_OPENGLES 0 -#if LV_USE_OPENGLES - #define LV_USE_OPENGLES_DEBUG 1 /* Enable or disable debug for opengles */ -#endif - -/* QNX Screen display and input drivers */ -#define LV_USE_QNX 0 -#if LV_USE_QNX - #define LV_QNX_BUF_COUNT 1 /*1 or 2*/ -#endif - -/*================== -* EXAMPLES -*==================*/ - -/*Enable the examples to be built with the library*/ #define LV_BUILD_EXAMPLES 0 -/*=================== - * DEMO USAGE - ====================*/ - -/*Show some widget. It might be required to increase `LV_MEM_SIZE` */ -#define LV_USE_DEMO_WIDGETS 0 - -/*Demonstrate the usage of encoder and keyboard*/ -#define LV_USE_DEMO_KEYPAD_AND_ENCODER 0 - -/*Benchmark your system*/ -#define LV_USE_DEMO_BENCHMARK 0 - -/*Render test for each primitives. Requires at least 480x272 display*/ -#define LV_USE_DEMO_RENDER 0 - -/*Stress test for LVGL*/ -#define LV_USE_DEMO_STRESS 0 - -/*Music player demo*/ -#define LV_USE_DEMO_MUSIC 0 -#if LV_USE_DEMO_MUSIC - #define LV_DEMO_MUSIC_SQUARE 0 - #define LV_DEMO_MUSIC_LANDSCAPE 0 - #define LV_DEMO_MUSIC_ROUND 0 - #define LV_DEMO_MUSIC_LARGE 0 - #define LV_DEMO_MUSIC_AUTO_PLAY 0 -#endif - -/*Flex layout demo*/ -#define LV_USE_DEMO_FLEX_LAYOUT 0 - -/*Smart-phone like multi-language demo*/ -#define LV_USE_DEMO_MULTILANG 0 - -/*Widget transformation demo*/ -#define LV_USE_DEMO_TRANSFORM 0 - -/*Demonstrate scroll settings*/ -#define LV_USE_DEMO_SCROLL 0 - -/*Vector graphic demo*/ -#define LV_USE_DEMO_VECTOR_GRAPHIC 0 - -/*--END OF LV_CONF_H--*/ - -#endif /*LV_CONF_H*/ - -#endif /*End of "Content enable"*/ +#endif /* LV_CONF_H */ From ff1a4bebec3fca89d5fd5822fdffb0c174554fb1 Mon Sep 17 00:00:00 2001 From: mutatrum Date: Mon, 2 Dec 2024 11:09:15 +0100 Subject: [PATCH 16/23] Add callback to button short click --- main/input.c | 29 +++++++++++++++-------------- main/input.h | 2 +- main/self_test/self_test.c | 2 +- main/system.c | 2 +- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/main/input.c b/main/input.c index 8c7d36d6c..bcbb912be 100644 --- a/main/input.c +++ b/main/input.c @@ -4,8 +4,6 @@ #include "lvgl.h" #include "esp_lvgl_port.h" #include "driver/gpio.h" -#include "screen.h" -#include "connect.h" #define BUTTON_BOOT_GPIO GPIO_NUM_0 #define ESP_INTR_FLAG_DEFAULT 0 @@ -15,7 +13,8 @@ static const char * TAG = "input"; static lv_indev_state_t button_state = LV_INDEV_STATE_RELEASED; -static void (*button_long_pressed)(void) = NULL; +static void (*button_short_clicked_fn)(void) = NULL; +static void (*button_long_pressed_fn)(void) = NULL; static void button_read(lv_indev_t *indev, lv_indev_data_t *data) { @@ -31,24 +30,20 @@ static void IRAM_ATTR button_isr_handler(void *arg) static void button_short_clicked_event_cb(lv_event_t *e) { - ESP_LOGI(TAG, "Short button press detected, switching to next screen"); - screen_next(); + ESP_LOGI(TAG, "Short button click detected"); + button_short_clicked_fn(); } static void button_long_pressed_event_cb(lv_event_t *e) { - if (button_long_pressed != NULL) { - ESP_LOGI(TAG, "Long button press detected"); - button_long_pressed(); - } + ESP_LOGI(TAG, "Long button press detected"); + button_long_pressed_fn(); } -esp_err_t input_init(void (*button_long_pressed_cb)(void)) +esp_err_t input_init(void (*button_short_clicked_cb)(void), void (*button_long_pressed_cb)(void)) { ESP_LOGI(TAG, "Install button driver"); - button_long_pressed = button_long_pressed_cb; - // Button handling gpio_config_t io_conf = { .pin_bit_mask = (1ULL << BUTTON_BOOT_GPIO), @@ -72,8 +67,14 @@ esp_err_t input_init(void (*button_long_pressed_cb)(void)) lv_indev_set_long_press_time(indev, LONG_PRESS_DURATION_MS); lv_indev_set_read_cb(indev, button_read); lv_indev_set_group(indev, group); - lv_indev_add_event_cb(indev, button_short_clicked_event_cb, LV_EVENT_SHORT_CLICKED, NULL); - lv_indev_add_event_cb(indev, button_long_pressed_event_cb, LV_EVENT_LONG_PRESSED, NULL); + if (button_short_clicked_cb != NULL) { + button_short_clicked_fn = button_short_clicked_cb; + lv_indev_add_event_cb(indev, button_short_clicked_event_cb, LV_EVENT_SHORT_CLICKED, NULL); + } + if (button_long_pressed_cb != NULL) { + button_long_pressed_fn = button_long_pressed_cb; + lv_indev_add_event_cb(indev, button_long_pressed_event_cb, LV_EVENT_LONG_PRESSED, NULL); + } return ESP_OK; } diff --git a/main/input.h b/main/input.h index afbd69592..d4384ed1a 100644 --- a/main/input.h +++ b/main/input.h @@ -1,6 +1,6 @@ #ifndef INPUT_H_ #define INPUT_H_ -esp_err_t input_init(void (*button_long_pressed_cb)(void)); +esp_err_t input_init(void (*button_short_clicked_cb)(void), void (*button_long_pressed_cb)(void)); #endif /* INPUT_H_ */ \ No newline at end of file diff --git a/main/self_test/self_test.c b/main/self_test/self_test.c index 8edb3bf39..89bab7455 100644 --- a/main/self_test/self_test.c +++ b/main/self_test/self_test.c @@ -162,7 +162,7 @@ esp_err_t test_input(GlobalState * GLOBAL_STATE) { case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - if (input_init(reset_self_test) != ESP_OK) { + if (input_init(NULL, reset_self_test) != ESP_OK) { display_msg("INPUT:FAIL", GLOBAL_STATE); return ESP_FAIL; } diff --git a/main/system.c b/main/system.c index baf7faa0b..f80a38572 100644 --- a/main/system.c +++ b/main/system.c @@ -144,7 +144,7 @@ void SYSTEM_init_peripherals(GlobalState * GLOBAL_STATE) { default: } - if (input_init(toggle_wifi_softap) != ESP_OK) { + if (input_init(screen_next, toggle_wifi_softap) != ESP_OK) { ESP_LOGW(TAG, "Input init failed!"); } From 7768004b680fa9939387f9c2c096ff1194b51602 Mon Sep 17 00:00:00 2001 From: mutatrum Date: Mon, 2 Dec 2024 11:28:36 +0100 Subject: [PATCH 17/23] Don't divide by zero on boot --- main/screen.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main/screen.c b/main/screen.c index 08f634285..5567586e0 100644 --- a/main/screen.c +++ b/main/screen.c @@ -259,7 +259,10 @@ static void screen_update_cb(lv_timer_t * timer) } if (current_power != power_management->power || current_hashrate != module->current_hashrate) { - lv_label_set_text_fmt(efficiency_label, "J/Th: %.2f", power_management->power / (module->current_hashrate / 1000.0)); + if (power_management->power > 0 && module->current_hashrate > 0) { + float efficiency = power_management->power / (module->current_hashrate / 1000.0); + lv_label_set_text_fmt(efficiency_label, "J/Th: %.2f", efficiency); + } } if (current_difficulty != module->best_session_nonce_diff) { From cef9b3fb945a3994522c0708eb700b4aff53ce3a Mon Sep 17 00:00:00 2001 From: mutatrum Date: Mon, 2 Dec 2024 11:48:21 +0100 Subject: [PATCH 18/23] Add found block to stats screen --- main/screen.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/main/screen.c b/main/screen.c index 5567586e0..75e1b438a 100644 --- a/main/screen.c +++ b/main/screen.c @@ -30,6 +30,7 @@ static double current_hashrate; static float current_power; static uint64_t current_difficulty; static float curreny_chip_temp; +static bool found_block; #define SCREEN_UPDATE_MS 500 #define LOGO_DELAY_COUNT 5000 / SCREEN_UPDATE_MS @@ -246,10 +247,6 @@ static void screen_update_cb(lv_timer_t * timer) return; } - if (module->FOUND_BLOCK) { - // TODO make special screen for this - } - // Carousel PowerManagementModule * power_management = &GLOBAL_STATE->POWER_MANAGEMENT_MODULE; @@ -265,8 +262,18 @@ static void screen_update_cb(lv_timer_t * timer) } } - 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); + if (module->FOUND_BLOCK && !found_block) { + found_block = true; + + lv_obj_set_width(difficulty_label, LV_HOR_RES); + lv_label_set_long_mode(difficulty_label, LV_LABEL_LONG_SCROLL_CIRCULAR); + lv_label_set_text_fmt(difficulty_label, "Best: %s !!! BLOCK FOUND !!!", module->best_session_diff_string); + + screen_show(SCR_STATS); + } else { + 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); + } } if (curreny_chip_temp != power_management->chip_temp_avg) { @@ -278,7 +285,7 @@ static void screen_update_cb(lv_timer_t * timer) current_difficulty = module->best_session_nonce_diff; curreny_chip_temp = power_management->chip_temp_avg; - if (CAROUSEL_DELAY_COUNT > current_screen_counter) { + if (CAROUSEL_DELAY_COUNT > current_screen_counter || found_block) { return; } From 78ec3c8202631b44d18a527b1e99497d18303b04 Mon Sep 17 00:00:00 2001 From: mutatrum Date: Mon, 2 Dec 2024 11:51:38 +0100 Subject: [PATCH 19/23] Whitespace --- main/display.h | 2 +- main/input.h | 2 +- main/logo.c | 2 +- main/screen.c | 1 - main/screen.h | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/main/display.h b/main/display.h index 456466195..9cdc5e97d 100644 --- a/main/display.h +++ b/main/display.h @@ -3,4 +3,4 @@ esp_err_t display_init(void * pvParameters); -#endif /* DISPLAY_H_ */ \ No newline at end of file +#endif /* DISPLAY_H_ */ diff --git a/main/input.h b/main/input.h index d4384ed1a..6dc95acde 100644 --- a/main/input.h +++ b/main/input.h @@ -3,4 +3,4 @@ esp_err_t input_init(void (*button_short_clicked_cb)(void), void (*button_long_pressed_cb)(void)); -#endif /* INPUT_H_ */ \ No newline at end of file +#endif /* INPUT_H_ */ diff --git a/main/logo.c b/main/logo.c index d66b633b6..6ce55f2eb 100644 --- a/main/logo.c +++ b/main/logo.c @@ -61,4 +61,4 @@ const lv_image_dsc_t logo = { .header.h = 30, .data_size = 2310 * 2, .data = logo_map, -}; \ No newline at end of file +}; diff --git a/main/screen.c b/main/screen.c index 75e1b438a..bb8a0c98f 100644 --- a/main/screen.c +++ b/main/screen.c @@ -319,4 +319,3 @@ esp_err_t screen_start(void * pvParameters) return ESP_OK; } - diff --git a/main/screen.h b/main/screen.h index 1d585d267..ef509120d 100644 --- a/main/screen.h +++ b/main/screen.h @@ -18,4 +18,4 @@ typedef enum { esp_err_t screen_start(void * pvParameters); void screen_next(void); -#endif /* SCREEN_H_ */ \ No newline at end of file +#endif /* SCREEN_H_ */ From 9ddfd96ea94c395463bff6768589161575c0f311 Mon Sep 17 00:00:00 2001 From: mutatrum Date: Mon, 2 Dec 2024 12:13:47 +0100 Subject: [PATCH 20/23] Fix screen noise on boot --- main/display.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/main/display.c b/main/display.c index 0d0b0fc3a..54428517d 100644 --- a/main/display.c +++ b/main/display.c @@ -83,6 +83,7 @@ esp_err_t display_init(void * pvParameters) } ESP_LOGI(TAG, "Initialize LVGL"); + const lvgl_port_cfg_t lvgl_cfg = ESP_LVGL_PORT_INIT_CONFIG(); ESP_RETURN_ON_ERROR(lvgl_port_init(&lvgl_cfg), TAG, "LVGL init failed"); @@ -107,17 +108,18 @@ esp_err_t display_init(void * pvParameters) }; lv_disp_t * disp = lvgl_port_add_disp(&disp_cfg); + if (lvgl_port_lock(0)) { + lv_style_init(&scr_style); + lv_style_set_text_font(&scr_style, &lv_font_portfolio_6x8); + lv_style_set_bg_opa(&scr_style, LV_OPA_COVER); + + lv_theme_set_apply_cb(&theme, theme_apply); + lv_display_set_theme(disp, &theme); lvgl_port_unlock(); } - lv_style_init(&scr_style); - lv_style_set_text_font(&scr_style, &lv_font_portfolio_6x8); - lv_style_set_bg_opa(&scr_style, LV_OPA_COVER); - - lv_theme_set_apply_cb(&theme, theme_apply); - if (esp_lcd_panel_init_err == ESP_OK) { // 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"); From f350993518972c4a866972918108108f5f94cfee Mon Sep 17 00:00:00 2001 From: mutatrum Date: Mon, 2 Dec 2024 14:06:17 +0100 Subject: [PATCH 21/23] Add screen for invalid ASIC --- main/screen.c | 23 ++++++++++++++++++++--- main/screen.h | 1 + 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/main/screen.c b/main/screen.c index bb8a0c98f..19e5a22fe 100644 --- a/main/screen.c +++ b/main/screen.c @@ -81,6 +81,24 @@ static lv_obj_t * create_scr_overheat(SystemModule * module) { return scr; } +static lv_obj_t * create_scr_invalid_asic() { + lv_obj_t * scr = lv_obj_create(NULL); + + lv_obj_set_flex_flow(scr, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(scr, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START); + + lv_obj_t *label1 = lv_label_create(scr); + lv_label_set_text(hashrate_label, "ASIC MODEL INVALID"); + + lv_obj_t *label2 = lv_label_create(scr); + lv_label_set_text(label2, "Configuration SSID:"); + + lv_obj_t *label3 = lv_label_create(scr); + lv_label_set_text(label3, module->ap_ssid); + + return scr; +} + static lv_obj_t * create_scr_configure(SystemModule * module) { lv_obj_t * scr = lv_obj_create(NULL); @@ -207,8 +225,7 @@ static void screen_update_cb(lv_timer_t * timer) } if (GLOBAL_STATE->ASIC_functions.init_fn == NULL) { - // Invalid model - // TODO Not sure what should be done here? + screen_show(SCR_INVALID_ASIC); return; } @@ -216,7 +233,6 @@ static void screen_update_cb(lv_timer_t * timer) if (module->overheat_mode == 1) { screen_show(SCR_OVERHEAT); - return; } @@ -308,6 +324,7 @@ esp_err_t screen_start(void * pvParameters) screens[SCR_SELF_TEST] = create_scr_self_test(); screens[SCR_OVERHEAT] = create_scr_overheat(module); + screens[SCR_INVALID_ASIC] = create_scr_invalid_asic(module); screens[SCR_CONFIGURE] = create_scr_configure(module); screens[SCR_CONNECTION] = create_scr_connection(module); screens[SCR_LOGO] = create_scr_logo(); diff --git a/main/screen.h b/main/screen.h index ef509120d..e134f3f02 100644 --- a/main/screen.h +++ b/main/screen.h @@ -4,6 +4,7 @@ typedef enum { SCR_SELF_TEST, SCR_OVERHEAT, + SCR_INVALID_ASIC, SCR_CONFIGURE, SCR_CONNECTION, SCR_LOGO, From b1244e28a965a8f996947e150746bbe3e898804b Mon Sep 17 00:00:00 2001 From: mutatrum Date: Mon, 2 Dec 2024 14:09:32 +0100 Subject: [PATCH 22/23] Fix label reference --- main/screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/screen.c b/main/screen.c index 19e5a22fe..3edc6fd29 100644 --- a/main/screen.c +++ b/main/screen.c @@ -88,7 +88,7 @@ static lv_obj_t * create_scr_invalid_asic() { lv_obj_set_flex_align(scr, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START); lv_obj_t *label1 = lv_label_create(scr); - lv_label_set_text(hashrate_label, "ASIC MODEL INVALID"); + lv_label_set_text(label1, "ASIC MODEL INVALID"); lv_obj_t *label2 = lv_label_create(scr); lv_label_set_text(label2, "Configuration SSID:"); From d8f26ce5019e316f6c987bf907c729f7739905f6 Mon Sep 17 00:00:00 2001 From: mutatrum Date: Mon, 2 Dec 2024 14:22:42 +0100 Subject: [PATCH 23/23] Fix missing reference --- main/screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/screen.c b/main/screen.c index 3edc6fd29..9c550a2fc 100644 --- a/main/screen.c +++ b/main/screen.c @@ -81,7 +81,7 @@ static lv_obj_t * create_scr_overheat(SystemModule * module) { return scr; } -static lv_obj_t * create_scr_invalid_asic() { +static lv_obj_t * create_scr_invalid_asic(SystemModule * module) { lv_obj_t * scr = lv_obj_create(NULL); lv_obj_set_flex_flow(scr, LV_FLEX_FLOW_COLUMN);