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/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/CMakeLists.txt b/main/CMakeLists.txt index 7d00f0be0..e4e4d90b4 100755 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -3,25 +3,27 @@ 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" + "screen.c" + "input.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" "./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 @@ -51,6 +53,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/display.c b/main/display.c new file mode 100644 index 000000000..54428517d --- /dev/null +++ b/main/display.c @@ -0,0 +1,133 @@ +#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 "esp_check.h" +#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" +#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 const char * TAG = "display"; + +static lv_theme_t theme; +static lv_style_t scr_style; + +extern const lv_font_t lv_font_portfolio_6x8; + +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 * 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); + + i2c_master_bus_handle_t 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; + 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_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; + esp_lcd_panel_dev_config_t panel_config = { + .bits_per_pixel = 1, + .reset_gpio_num = -1, + }; + + esp_lcd_panel_ssd1306_config_t ssd1306_config = { + .height = LCD_V_RES, + }; + panel_config.vendor_config = &ssd1306_config; + + 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_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(); + 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, + .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, + .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, + } + }; + + 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(); + } + + 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/display.h b/main/display.h new file mode 100644 index 000000000..9cdc5e97d --- /dev/null +++ b/main/display.h @@ -0,0 +1,6 @@ +#ifndef DISPLAY_H_ +#define DISPLAY_H_ + +esp_err_t display_init(void * pvParameters); + +#endif /* DISPLAY_H_ */ 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..682e0c327 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; @@ -69,6 +68,8 @@ 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; uint16_t pool_port; @@ -76,8 +77,17 @@ typedef struct bool is_using_fallback; uint16_t overheat_mode; uint32_t lastClockSync; + bool is_screen_active; } SystemModule; +typedef struct +{ + bool active; + char *message; + bool result; + bool finished; +} SelfTestModule; + typedef struct { DeviceModel device_model; @@ -98,6 +108,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/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..816a2e2f1 --- /dev/null +++ b/main/idf_component.yml @@ -0,0 +1,7 @@ +## IDF Component Manager Manifest File +dependencies: + 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..bcbb912be --- /dev/null +++ b/main/input.c @@ -0,0 +1,80 @@ +#include "esp_log.h" +#include "esp_err.h" +#include "esp_check.h" +#include "lvgl.h" +#include "esp_lvgl_port.h" +#include "driver/gpio.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 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) +{ + 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_event_cb(lv_event_t *e) +{ + ESP_LOGI(TAG, "Short button click detected"); + button_short_clicked_fn(); +} + +static void button_long_pressed_event_cb(lv_event_t *e) +{ + ESP_LOGI(TAG, "Long button press detected"); + button_long_pressed_fn(); +} + +esp_err_t input_init(void (*button_short_clicked_cb)(void), void (*button_long_pressed_cb)(void)) +{ + ESP_LOGI(TAG, "Install button driver"); + + // 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"); + + 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_KEYPAD); + 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); + 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 new file mode 100644 index 000000000..6dc95acde --- /dev/null +++ b/main/input.h @@ -0,0 +1,6 @@ +#ifndef INPUT_H_ +#define INPUT_H_ + +esp_err_t input_init(void (*button_short_clicked_cb)(void), void (*button_long_pressed_cb)(void)); + +#endif /* INPUT_H_ */ diff --git a/main/logo.c b/main/logo.c new file mode 100644 index 000000000..6ce55f2eb --- /dev/null +++ b/main/logo.c @@ -0,0 +1,64 @@ +#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_IMAGE_LOGO +#define LV_ATTRIBUTE_IMAGE_LOGO +#endif + +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_image_dsc_t logo = { + .header.cf = LV_COLOR_FORMAT_RGB565, + .header.magic = LV_IMAGE_HEADER_MAGIC, + .header.w = 77, + .header.h = 30, + .data_size = 2310 * 2, + .data = logo_map, +}; diff --git a/main/lv_conf.h b/main/lv_conf.h new file mode 100644 index 000000000..979297a85 --- /dev/null +++ b/main/lv_conf.h @@ -0,0 +1,63 @@ +#ifndef LV_CONF_H +#define LV_CONF_H + +#define LV_COLOR_DEPTH 1 + +#define LV_USE_OS LV_OS_FREERTOS + +#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_COMPLEX 0 + +#define LV_USE_FLOAT 1 + +#define LV_FONT_MONTSERRAT_14 0 + +#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 + +#define LV_USE_THEME_DEFAULT 0 +#define LV_USE_THEME_SIMPLE 0 +#define LV_USE_THEME_MONO 0 + +#define LV_BUILD_EXAMPLES 0 + +#endif /* LV_CONF_H */ 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/main.c b/main/main.c index dbc467bf9..ab790c191 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" @@ -60,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); @@ -75,11 +74,12 @@ 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); 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/oled.c b/main/oled.c deleted file mode 100644 index 41277ff31..000000000 --- a/main/oled.c +++ /dev/null @@ -1,315 +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 "esp_check.h" - -#include "nvs_config.h" -#include "i2c_bitaxe.h" -#include "oled.h" - -#define OLED_I2C_ADDR 0x3C - -static const char * TAG = "oled"; - -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 - ESP_RETURN_ON_ERROR(i2c_bitaxe_add_device(OLED_I2C_ADDR, &ssd1306_dev_handle), TAG, "Failed to add display i2c device"); - - 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 ESP_OK; -} - -// 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/screen.c b/main/screen.c new file mode 100644 index 000000000..9c550a2fc --- /dev/null +++ b/main/screen.c @@ -0,0 +1,338 @@ +#include "esp_log.h" +#include "esp_err.h" +#include "esp_check.h" +#include "lvgl.h" +#include "esp_lvgl_port.h" +#include "global_state.h" +#include "screen.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 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_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; +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 +#define CAROUSEL_DELAY_COUNT 10000 / SCREEN_UPDATE_MS + +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_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; +} + +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_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, module->ip_addr_str); + + return scr; +} + +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); + 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, "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); + + 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_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); + + 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_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, module->ip_addr_str); + + return scr; +} + +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); + 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) +{ + if (GLOBAL_STATE->SELF_TEST_MODULE.active) { + + screen_show(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; + } + + if (GLOBAL_STATE->ASIC_functions.init_fn == NULL) { + screen_show(SCR_INVALID_ASIC); + 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; + } + + 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; + } + + // 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); + } + + if (current_power != power_management->power || current_hashrate != module->current_hashrate) { + 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 (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) { + 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 || found_block) { + 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); + } +} + +esp_err_t screen_start(void * pvParameters) +{ + GLOBAL_STATE = (GlobalState *) pvParameters; + + if (GLOBAL_STATE->SYSTEM_MODULE.is_screen_active) { + SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; + + 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(); + screens[SCR_URLS] = create_scr_urls(module); + screens[SCR_STATS] = create_scr_stats(); + + lv_timer_create(screen_update_cb, SCREEN_UPDATE_MS, NULL); + } + + return ESP_OK; +} diff --git a/main/screen.h b/main/screen.h new file mode 100644 index 000000000..e134f3f02 --- /dev/null +++ b/main/screen.h @@ -0,0 +1,22 @@ +#ifndef SCREEN_H_ +#define SCREEN_H_ + +typedef enum { + SCR_SELF_TEST, + SCR_OVERHEAT, + SCR_INVALID_ASIC, + 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); + +#endif /* SCREEN_H_ */ diff --git a/main/self_test/self_test.c b/main/self_test/self_test.c index a3a80b7ea..89bab7455 100644 --- a/main/self_test/self_test.c +++ b/main/self_test/self_test.c @@ -15,23 +15,16 @@ #include "global_state.h" #include "nvs_config.h" #include "nvs_flash.h" -#include "oled.h" +#include "display.h" +#include "screen.h" +#include "input.h" #include "vcore.h" #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 @@ -52,18 +45,10 @@ // #define HASHRATE_TARGET_ULTRA 1000 //GH/s // #define HASHRATE_TARGET_MAX 2000 //GH/s - static const char * TAG = "self_test"; -// 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; @@ -75,22 +60,15 @@ bool should_test(GlobalState * GLOBAL_STATE) { return false; } -static void display_msg(char * msg, GlobalState * GLOBAL_STATE) { - SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; +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(); +} - 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, 1, module->oled_buf); - } - break; - default: - } +static void display_msg(char * msg, GlobalState * GLOBAL_STATE) +{ + GLOBAL_STATE->SELF_TEST_MODULE.message = msg; } static esp_err_t test_fan_sense(GlobalState * GLOBAL_STATE) @@ -159,12 +137,16 @@ esp_err_t test_display(GlobalState * GLOBAL_STATE) { case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - ESP_RETURN_ON_ERROR(OLED_init(), TAG, "OLED init failed!"); + if (display_init(GLOBAL_STATE) != ESP_OK) { + display_msg("DISPLAY:FAIL", GLOBAL_STATE); + return ESP_FAIL; + } - ESP_LOGI(TAG, "OLED init success!"); - // clear the oled screen - OLED_fill(0); - OLED_writeString(0, 0, "BITAXE SELF TESTING"); + if (GLOBAL_STATE->SYSTEM_MODULE.is_screen_active) { + ESP_LOGI(TAG, "DISPLAY init success!"); + } else { + ESP_LOGW(TAG, "DISPLAY not found!"); + } break; default: @@ -173,6 +155,47 @@ esp_err_t test_display(GlobalState * GLOBAL_STATE) { return ESP_OK; } +esp_err_t test_input(GlobalState * GLOBAL_STATE) { + // Input testing + switch (GLOBAL_STATE->device_model) { + case DEVICE_MAX: + case DEVICE_ULTRA: + case DEVICE_SUPRA: + case DEVICE_GAMMA: + if (input_init(NULL, reset_self_test) != ESP_OK) { + display_msg("INPUT:FAIL", GLOBAL_STATE); + return ESP_FAIL; + } + + ESP_LOGI(TAG, "INPUT init success!"); + break; + default: + } + + 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: + } + + return ESP_OK; +} + esp_err_t init_voltage_regulator(GlobalState * GLOBAL_STATE) { ESP_RETURN_ON_ERROR(VCORE_init(GLOBAL_STATE), TAG, "VCORE init failed!"); @@ -263,8 +286,6 @@ esp_err_t test_init_peripherals(GlobalState * GLOBAL_STATE) { return ESP_OK; } - - /** * @brief Perform a self-test of the system. * @@ -279,17 +300,26 @@ 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) { ESP_LOGE(TAG, "Display test failed!"); tests_done(GLOBAL_STATE, TESTS_FAILED); } - + + //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!"); @@ -332,7 +362,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; } @@ -467,15 +496,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 { @@ -487,81 +512,12 @@ static void tests_done(GlobalState * GLOBAL_STATE, bool test_result) { case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - if (OLED_status()) { - OLED_clearLine(2); - if (test_result == TESTS_PASSED) { - OLED_writeString(0, 2, "TESTS PASS!"); - } else { - OLED_writeString(0, 2, "TESTS FAIL!"); - } - OLED_clearLine(3); - OLED_writeString(0, 3, "LONG PRESS BOOT"); - } + 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); -} - -// 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"); + vTaskDelay(portMAX_DELAY); } diff --git a/main/system.c b/main/system.c index b26b638df..f80a38572 100644 --- a/main/system.c +++ b/main/system.c @@ -26,27 +26,19 @@ #include "connect.h" #include "led_controller.h" #include "nvs_config.h" -#include "oled.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 _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); -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); @@ -95,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); @@ -122,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; @@ -138,156 +128,31 @@ 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 (!OLED_init()) { - ESP_LOGI(TAG, "OLED init failed!"); + // display + 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!"); - // clear the oled screen - OLED_fill(0); } 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 - - _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; - 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(screen_next, toggle_wifi_softap) != 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"); } - - OLED_showBitmap(0, 0, bitaxe_splash, 128, 32); - 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 - _clear_display(GLOBAL_STATE); - 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) @@ -296,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; @@ -369,208 +235,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) -{ - 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 (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); - 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); - } - break; - default: - break; - } -} - -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; - - switch (GLOBAL_STATE->device_model) { - case DEVICE_MAX: - 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:"); - 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); - } - break; - default: - break; - } -} - -static void _clear_display(GlobalState * GLOBAL_STATE) -{ - 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: - } -} - -static void _init_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 (OLED_status()) { - memset(module->oled_buf, 0, 20); - snprintf(module->oled_buf, 20, "Connecting to SSID:"); - OLED_writeString(0, 0, module->oled_buf); - } - break; - default: - } -} - -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 (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); - - 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); - } - 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 (OLED_status()) { - _clear_display(GLOBAL_STATE); - if (error != NULL) { - OLED_writeString(0, 0, error); - } - OLED_writeString(0, 1, "Configuration SSID:"); - char ap_ssid[13]; - generate_ssid(ap_ssid); - OLED_writeString(0, 2, ap_ssid); - } - 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 5ff8f79ff..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; @@ -293,6 +295,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 diff --git a/readme.md b/readme.md index 02641fd5f..b117f7cdd 100755 --- a/readme.md +++ b/readme.md @@ -69,3 +69,7 @@ The firmware hosts a small web server on port 80 for administrative purposes. On ### Recovery In the event that the admin web front end is inaccessible, for example because of an unsuccessful firmware update (`www.bin`), a recovery page can be accessed at `http:///recovery`. + +## Attributions + +The display font is Portfolio 6x8 from https://int10h.org/oldschool-pc-fonts/ by VileR. diff --git a/sdkconfig.defaults b/sdkconfig.defaults index 63d09ca1c..40a1fa009 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -10,3 +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_CONF_SKIP=n