diff --git a/.vscode/settings.json b/.vscode/settings.json index 270eaebd..314f86f1 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -16,12 +16,48 @@ "array": "c", "string": "c", "string_view": "c", - "*.tcc": "c" + "*.tcc": "c", + "esp_lvgl_port.h": "c", + "cstdint": "c", + "regex": "c", + "i2c_bitaxe.h": "c", + "i2c_master.h": "c", + "nvs_config.h": "c", + "display.h": "c", + "esp_lcd_panel_vendor.h": "c", + "esp_lcd_panel_st7789.h": "c", + "esp_lcd_panel_ssd1306.h": "c", + "esp_lcd_panel_io.h": "c", + "esp_lcd_panel_ops.h": "c", + "esp_lcd_io_i2c.h": "c", + "esp_lcd_types.h": "c", + "i2c.h": "c", + "cstdlib": "c", + "i2c_types.h": "c", + "esp_lcd_panel_dev.h": "c", + "bitset": "c", + "memory": "c", + "random": "c", + "future": "c", + "optional": "c", + "esp_lcd_panel_interface.h": "c", + "span": "c", + "oled.h": "c", + "charconv": "c", + "chrono": "c", + "format": "c", + "ratio": "c", + "system_error": "c", + "functional": "c", + "tuple": "c", + "type_traits": "c", + "utility": "c", + "compare": "c" }, "editor.formatOnSave": false, "cSpell.words": [ "ssid" ], - "idf.port": "/dev/cu.usbmodem1434301", + "idf.port": "/dev/ttyACM0", "C_Cpp.intelliSenseEngine": "Tag Parser" } diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 7d00f0be..d56d0ee2 100755 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -3,18 +3,19 @@ SRCS "adc.c" "DS4432U.c" "EMC2101.c" - "fonts.c" "i2c_bitaxe.c" "INA260.c" "led_controller.c" "main.c" "nvs_config.c" - "oled.c" + "display.c" "system.c" "TPS546.c" "vcore.c" "work_queue.c" "nvs_device.c" + "lv_font_portfolio-6x8.c" + "logo.c" "./http_server/http_server.c" "./self_test/self_test.c" "./tasks/stratum_task.c" diff --git a/main/display.c b/main/display.c new file mode 100644 index 00000000..1bb7427d --- /dev/null +++ b/main/display.c @@ -0,0 +1,157 @@ +#include +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "esp_timer.h" +#include "esp_lcd_panel_io.h" +#include "esp_lcd_panel_ops.h" +#include "esp_err.h" +#include "esp_log.h" +#include "esp_check.h" +#include "lvgl.h" +#include "esp_lvgl_port.h" +#include "nvs_config.h" +#include "i2c_bitaxe.h" +#include "driver/i2c_master.h" +#include "driver/i2c_types.h" +#include "esp_lcd_panel_ssd1306.h" + +#define SSD1306_I2C_ADDRESS 0x3C + +#define LCD_H_RES 128 +#define LCD_V_RES 32 +#define LCD_CMD_BITS 8 +#define LCD_PARAM_BITS 8 + +static bool is_display_active = false; + +static const char * TAG = "display"; + +static lv_style_t style; +extern const lv_font_t lv_font_portfolio_6x8; +extern const lv_img_dsc_t logo; + +esp_err_t display_init(void) +{ + uint8_t flip_screen = nvs_config_get_u16(NVS_CONFIG_FLIP_SCREEN, 1); + uint8_t invert_screen = nvs_config_get_u16(NVS_CONFIG_INVERT_SCREEN, 0); + + i2c_master_bus_handle_t i2c_master_bus_handle; + ESP_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, + .color_space = ESP_LCD_COLOR_SPACE_MONOCHROME, + }; + + esp_lcd_panel_ssd1306_config_t ssd1306_config = { + .height = LCD_V_RES, + }; + panel_config.vendor_config = &ssd1306_config; + + ESP_RETURN_ON_ERROR(esp_lcd_new_panel_ssd1306(io_handle, &panel_config, &panel_handle), TAG, "No display found"); + ESP_RETURN_ON_ERROR(esp_lcd_panel_reset(panel_handle), TAG, "Panel reset failed"); + ESP_RETURN_ON_ERROR(esp_lcd_panel_init(panel_handle), TAG, "Panel init failed"); + // ESP_RETURN_ON_ERROR(esp_lcd_panel_mirror(panel_handle, false, false), TAG, "Panel mirror failed"); + ESP_RETURN_ON_ERROR(esp_lcd_panel_invert_color(panel_handle, invert_screen), TAG, "Panel invert failed"); + + ESP_RETURN_ON_ERROR(esp_lcd_panel_disp_on_off(panel_handle, true), TAG, "Panel display on failed"); + + ESP_LOGI(TAG, "Initialize LVGL"); + const lvgl_port_cfg_t lvgl_cfg = ESP_LVGL_PORT_INIT_CONFIG(); + ESP_RETURN_ON_ERROR(lvgl_port_init(&lvgl_cfg), TAG, "LVGL init failed"); + + const lvgl_port_display_cfg_t disp_cfg = { + .io_handle = io_handle, + .panel_handle = panel_handle, + .buffer_size = LCD_H_RES * LCD_V_RES, + .double_buffer = true, + .hres = LCD_H_RES, + .vres = LCD_V_RES, + .monochrome = true, + .rotation = { + .swap_xy = false, + .mirror_x = !flip_screen, // The screen is not flipped, this is for backwards compatibility + .mirror_y = !flip_screen, + }, + }; + lvgl_port_add_disp(&disp_cfg); + + lv_style_init(&style); + lv_style_set_text_font(&style, &lv_font_portfolio_6x8); + + is_display_active = true; + + return ESP_OK; +} + +bool display_active(void) +{ + return is_display_active; +} + +void display_clear() +{ + if (lvgl_port_lock(0)) { + lv_obj_t *scr = lv_scr_act(); + lv_obj_clean(scr); + lvgl_port_unlock(); + } +} + +void display_show_status(const char *messages[], size_t message_count) +{ + if (lvgl_port_lock(0)) { + lv_obj_t *scr = lv_scr_act(); + lv_obj_clean(scr); + + lv_obj_t *container = lv_obj_create(scr); + lv_obj_set_size(container, LCD_H_RES, LCD_V_RES); + lv_obj_align(container, LV_ALIGN_CENTER, 0, 0); + + lv_obj_set_flex_flow(container, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(container, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START); + + for (int i = 0; i < message_count; i++) + { + lv_obj_t *label = lv_label_create(container); + lv_label_set_text(label, messages[i]); + lv_obj_add_style(label, &style, LV_PART_MAIN); + lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR); + lv_obj_set_width(label, LCD_H_RES); + } + + lvgl_port_unlock(); + } +} + +void display_show_logo() +{ + if (lvgl_port_lock(0)) { + lv_obj_t *scr = lv_scr_act(); + lv_obj_clean(scr); + + lv_obj_t *img = lv_img_create(scr); + + lv_img_set_src(img, &logo); + + lv_obj_align(img, LV_ALIGN_CENTER, 0, 0); + + lvgl_port_unlock(); + } +} diff --git a/main/display.h b/main/display.h new file mode 100644 index 00000000..f5e3d014 --- /dev/null +++ b/main/display.h @@ -0,0 +1,10 @@ +#ifndef DISPLAY_H_ +#define DISPLAY_H_ + +esp_err_t display_init(void); +bool display_active(void); +void display_clear(); +void display_show_status(const char *messages[], size_t message_count); +void display_show_logo(); + +#endif /* DISPLAY_H_ */ \ No newline at end of file diff --git a/main/fonts.c b/main/fonts.c deleted file mode 100644 index d16f26cc..00000000 --- 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 8ac051e1..4c9e922a 100644 --- a/main/global_state.h +++ b/main/global_state.h @@ -60,7 +60,6 @@ typedef struct uint64_t shares_accepted; uint64_t shares_rejected; int screen_page; - char oled_buf[20]; uint64_t best_nonce_diff; char best_diff_string[DIFF_STRING_SIZE]; uint64_t best_session_nonce_diff; diff --git a/main/i2c_bitaxe.c b/main/i2c_bitaxe.c index 494c48bf..6ed70f8e 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 67521bca..9d495c82 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 00000000..2606f646 --- /dev/null +++ b/main/idf_component.yml @@ -0,0 +1,10 @@ +## IDF Component Manager Manifest File +dependencies: + espressif/esp_lvgl_port: "=2.4.1" + ## LVGL 9 is blocked by https://github.com/espressif/esp-idf/issues/14784 + lvgl/lvgl: + version: "^8" + public: true + ## Required IDF version + idf: + version: ">=5.2.0" diff --git a/main/logo.c b/main/logo.c new file mode 100644 index 00000000..926f96fd --- /dev/null +++ b/main/logo.c @@ -0,0 +1,68 @@ +#ifdef __has_include + #if __has_include("lvgl.h") + #ifndef LV_LVGL_H_INCLUDE_SIMPLE + #define LV_LVGL_H_INCLUDE_SIMPLE + #endif + #endif +#endif + +#if defined(LV_LVGL_H_INCLUDE_SIMPLE) + #include "lvgl.h" +#else + #include "lvgl/lvgl.h" +#endif + + +#ifndef LV_ATTRIBUTE_MEM_ALIGN +#define LV_ATTRIBUTE_MEM_ALIGN +#endif + +#ifndef LV_ATTRIBUTE_IMG_LOGO +#define LV_ATTRIBUTE_IMG_LOGO +#endif + +const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_LOGO uint8_t logo_map[] = { + 0xff, 0xff, 0xff, 0xff, /*Color of index 0*/ + 0x00, 0x00, 0x00, 0xff, /*Color of index 1*/ + + 0b00000010, 0b00000000, 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, + 0b00000111, 0b00011100, 0b00000011, 0b10000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, + 0b00001111, 0b10111111, 0b10010111, 0b11000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, + 0b00011111, 0b11111111, 0b11100011, 0b10000000, 0b10000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, + 0b00100111, 0b11111111, 0b11000001, 0b00000001, 0b10000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, + 0b01000011, 0b11000111, 0b10000000, 0b00000011, 0b10000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, + 0b01000001, 0b11000011, 0b10000010, 0b00001111, 0b11100000, 0b01000000, 0b00010000, 0b00100000, 0b00000100, 0b00000000, + 0b10000001, 0b11000011, 0b10000111, 0b00011111, 0b11000000, 0b11111000, 0b00111000, 0b01110000, 0b00001111, 0b10001000, + 0b10000001, 0b11000011, 0b10001111, 0b11000111, 0b10000001, 0b11111111, 0b00111110, 0b01111100, 0b00011111, 0b11110000, + 0b10000001, 0b11000011, 0b10001111, 0b10000111, 0b10000011, 0b11111111, 0b01111100, 0b11111000, 0b01111111, 0b11100000, + 0b10000101, 0b11000011, 0b10000111, 0b10000111, 0b10001111, 0b00111110, 0b00111100, 0b01111000, 0b11110011, 0b11100000, + 0b01001001, 0b11001011, 0b10000111, 0b10000111, 0b10001111, 0b00011110, 0b00111100, 0b01111000, 0b11110001, 0b11110000, + 0b00110001, 0b11011111, 0b00100111, 0b10000111, 0b10000011, 0b00011110, 0b00111100, 0b01111000, 0b11110001, 0b11000000, + 0b00000001, 0b11011111, 0b11100111, 0b10000111, 0b10000001, 0b00011110, 0b00111100, 0b01111000, 0b11110001, 0b10000000, + 0b00000001, 0b11111111, 0b11000111, 0b10000111, 0b10000001, 0b10011110, 0b00111110, 0b01111000, 0b11110011, 0b00000000, + 0b00000001, 0b11000111, 0b10000111, 0b10000111, 0b10000000, 0b00011110, 0b00111111, 0b11100000, 0b11110110, 0b00000000, + 0b00000011, 0b11000011, 0b10001111, 0b11001111, 0b11000000, 0b01111111, 0b00111111, 0b11110101, 0b11111100, 0b00000000, + 0b00000001, 0b11000011, 0b10000111, 0b10000111, 0b10000000, 0b11011110, 0b01011111, 0b11111000, 0b11110000, 0b00000000, + 0b00000001, 0b11000011, 0b10000111, 0b10000111, 0b10000011, 0b10011110, 0b00001111, 0b11111000, 0b11110000, 0b00000000, + 0b00000001, 0b11000011, 0b10000111, 0b10000111, 0b10001111, 0b00011110, 0b00111100, 0b11111000, 0b11110000, 0b00010000, + 0b00000001, 0b11000011, 0b10000111, 0b10000111, 0b10001111, 0b00011110, 0b00111100, 0b01111000, 0b11110000, 0b00100000, + 0b00000001, 0b11000011, 0b10000111, 0b10000111, 0b10001111, 0b00011110, 0b00111100, 0b01111000, 0b11110000, 0b01100000, + 0b00001111, 0b11000011, 0b10000111, 0b10000111, 0b10001111, 0b00011110, 0b00111100, 0b01111000, 0b11110001, 0b11100000, + 0b00111111, 0b11000011, 0b11000111, 0b10000111, 0b10001111, 0b00011110, 0b00111100, 0b01111000, 0b11110001, 0b11100000, + 0b01111111, 0b11110011, 0b11000111, 0b10000111, 0b10001111, 0b11011110, 0b00111100, 0b01111000, 0b11111101, 0b11100000, + 0b11100111, 0b11111110, 0b00000111, 0b11100111, 0b11101111, 0b11111111, 0b00111110, 0b01111100, 0b11111111, 0b10000000, + 0b10000001, 0b11111100, 0b00000111, 0b11000111, 0b11001111, 0b11111110, 0b00111100, 0b01111000, 0b11111111, 0b00000000, + 0b10000000, 0b01111000, 0b00000011, 0b10000011, 0b10010011, 0b11101110, 0b00011000, 0b00110001, 0b00111110, 0b00000000, + 0b10000000, 0b00010000, 0b00000001, 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, + 0b01100000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, +}; + +const lv_img_dsc_t logo = { + .header.cf = LV_IMG_CF_INDEXED_1BIT, + .header.always_zero = 0, + .header.reserved = 0, + .header.w = 77, + .header.h = 30, + .data_size = 308, + .data = logo_map, +}; \ No newline at end of file diff --git a/main/lv_font_portfolio-6x8.c b/main/lv_font_portfolio-6x8.c new file mode 100644 index 00000000..0571835e --- /dev/null +++ b/main/lv_font_portfolio-6x8.c @@ -0,0 +1,505 @@ +/******************************************************************************* + * Size: 8 px + * Bpp: 1 + * Opts: --font oldschool_pc_font_pack_v2.2_linux/ttf - Mx (mixed outline+bitmap)/Mx437_Portfolio_6x8.ttf --bpp 1 --size 8 --format lvgl --range 0x20-0x7F -o portfolio_6x8 + ******************************************************************************/ + +#ifdef __has_include + #if __has_include("lvgl.h") + #ifndef LV_LVGL_H_INCLUDE_SIMPLE + #define LV_LVGL_H_INCLUDE_SIMPLE + #endif + #endif +#endif + +#ifdef LV_LVGL_H_INCLUDE_SIMPLE + #include "lvgl.h" +#else + #include "lvgl/lvgl.h" +#endif + +#ifndef PORTFOLIO_6X8 +#define PORTFOLIO_6X8 1 +#endif + +#if PORTFOLIO_6X8 + +/*----------------- + * BITMAPS + *----------------*/ + +/*Store the image of the glyphs*/ +static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = { + /* U+0020 " " */ + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + + /* U+0021 "!" */ + 0x20, 0x82, 0x8, 0x20, 0x2, 0x0, + + /* U+0022 "\"" */ + 0x51, 0x45, 0x0, 0x0, 0x0, 0x0, + + /* U+0023 "#" */ + 0x51, 0x4f, 0x94, 0xf9, 0x45, 0x0, + + /* U+0024 "$" */ + 0x21, 0xe8, 0x1c, 0xb, 0xc2, 0x0, + + /* U+0025 "%" */ + 0xc3, 0x21, 0x8, 0x42, 0x61, 0x80, + + /* U+0026 "&" */ + 0x62, 0x4a, 0x10, 0xaa, 0x46, 0x80, + + /* U+0027 "'" */ + 0x30, 0x42, 0x0, 0x0, 0x0, 0x0, + + /* U+0028 "(" */ + 0x10, 0x84, 0x10, 0x40, 0x81, 0x0, + + /* U+0029 ")" */ + 0x40, 0x81, 0x4, 0x10, 0x84, 0x0, + + /* U+002A "*" */ + 0x0, 0x8a, 0x9c, 0xa8, 0x80, 0x0, + + /* U+002B "+" */ + 0x0, 0x82, 0x3e, 0x20, 0x80, 0x0, + + /* U+002C "," */ + 0x0, 0x0, 0x0, 0x30, 0x42, 0x0, + + /* U+002D "-" */ + 0x0, 0x0, 0x3e, 0x0, 0x0, 0x0, + + /* U+002E "." */ + 0x0, 0x0, 0x0, 0x0, 0xc3, 0x0, + + /* U+002F "/" */ + 0x0, 0x21, 0x8, 0x42, 0x0, 0x0, + + /* U+0030 "0" */ + 0x72, 0x29, 0xaa, 0xca, 0x27, 0x0, + + /* U+0031 "1" */ + 0x21, 0x82, 0x8, 0x20, 0x87, 0x0, + + /* U+0032 "2" */ + 0x72, 0x20, 0x84, 0x21, 0xf, 0x80, + + /* U+0033 "3" */ + 0xf8, 0x42, 0x4, 0xa, 0x27, 0x0, + + /* U+0034 "4" */ + 0x10, 0xc5, 0x24, 0xf8, 0x41, 0x0, + + /* U+0035 "5" */ + 0xfa, 0xf, 0x2, 0xa, 0x27, 0x0, + + /* U+0036 "6" */ + 0x31, 0x8, 0x3c, 0x8a, 0x27, 0x0, + + /* U+0037 "7" */ + 0xf8, 0x21, 0x8, 0x20, 0x82, 0x0, + + /* U+0038 "8" */ + 0x72, 0x28, 0x9c, 0x8a, 0x27, 0x0, + + /* U+0039 "9" */ + 0x72, 0x28, 0x9e, 0x8, 0x46, 0x0, + + /* U+003A ":" */ + 0x0, 0xc3, 0x0, 0x30, 0xc0, 0x0, + + /* U+003B ";" */ + 0x0, 0xc3, 0x0, 0x30, 0x42, 0x0, + + /* U+003C "<" */ + 0x8, 0x42, 0x10, 0x20, 0x40, 0x80, + + /* U+003D "=" */ + 0x0, 0xf, 0x80, 0xf8, 0x0, 0x0, + + /* U+003E ">" */ + 0x81, 0x2, 0x4, 0x21, 0x8, 0x0, + + /* U+003F "?" */ + 0x72, 0x20, 0x84, 0x20, 0x2, 0x0, + + /* U+0040 "@" */ + 0x72, 0x29, 0xaa, 0x92, 0x7, 0x0, + + /* U+0041 "A" */ + 0x72, 0x28, 0xa2, 0xfa, 0x28, 0x80, + + /* U+0042 "B" */ + 0xf2, 0x28, 0xbc, 0x8a, 0x2f, 0x0, + + /* U+0043 "C" */ + 0x72, 0x28, 0x20, 0x82, 0x27, 0x0, + + /* U+0044 "D" */ + 0xe2, 0x48, 0xa2, 0x8a, 0x4e, 0x0, + + /* U+0045 "E" */ + 0xfa, 0x8, 0x3c, 0x82, 0xf, 0x80, + + /* U+0046 "F" */ + 0xfa, 0x8, 0x3c, 0x82, 0x8, 0x0, + + /* U+0047 "G" */ + 0x72, 0x28, 0x20, 0xba, 0x27, 0x80, + + /* U+0048 "H" */ + 0x8a, 0x28, 0xbe, 0x8a, 0x28, 0x80, + + /* U+0049 "I" */ + 0x70, 0x82, 0x8, 0x20, 0x87, 0x0, + + /* U+004A "J" */ + 0x38, 0x41, 0x4, 0x12, 0x46, 0x0, + + /* U+004B "K" */ + 0x8a, 0x4a, 0x30, 0xa2, 0x48, 0x80, + + /* U+004C "L" */ + 0x82, 0x8, 0x20, 0x82, 0xf, 0x80, + + /* U+004D "M" */ + 0x8b, 0x6a, 0xaa, 0x8a, 0x28, 0x80, + + /* U+004E "N" */ + 0x8a, 0x2c, 0xaa, 0x9a, 0x28, 0x80, + + /* U+004F "O" */ + 0x72, 0x28, 0xa2, 0x8a, 0x27, 0x0, + + /* U+0050 "P" */ + 0xf2, 0x28, 0xbc, 0x82, 0x8, 0x0, + + /* U+0051 "Q" */ + 0x72, 0x28, 0xa2, 0xaa, 0x46, 0x80, + + /* U+0052 "R" */ + 0xf2, 0x28, 0xbc, 0xa2, 0x48, 0x80, + + /* U+0053 "S" */ + 0x72, 0x28, 0x1c, 0xa, 0x27, 0x0, + + /* U+0054 "T" */ + 0xf8, 0x82, 0x8, 0x20, 0x82, 0x0, + + /* U+0055 "U" */ + 0x8a, 0x28, 0xa2, 0x8a, 0x27, 0x0, + + /* U+0056 "V" */ + 0x8a, 0x28, 0xa2, 0x89, 0x42, 0x0, + + /* U+0057 "W" */ + 0x8a, 0x28, 0xaa, 0xab, 0x68, 0x80, + + /* U+0058 "X" */ + 0x8a, 0x25, 0x8, 0x52, 0x28, 0x80, + + /* U+0059 "Y" */ + 0x8a, 0x28, 0x9c, 0x20, 0x82, 0x0, + + /* U+005A "Z" */ + 0xf8, 0x21, 0x8, 0x42, 0xf, 0x80, + + /* U+005B "[" */ + 0x71, 0x4, 0x10, 0x41, 0x7, 0x0, + + /* U+005C "\\" */ + 0x2, 0x4, 0x8, 0x10, 0x20, 0x0, + + /* U+005D "]" */ + 0x70, 0x41, 0x4, 0x10, 0x47, 0x0, + + /* U+005E "^" */ + 0x21, 0x48, 0x80, 0x0, 0x0, 0x0, + + /* U+005F "_" */ + 0x0, 0x0, 0x0, 0x0, 0x0, 0x3f, + + /* U+0060 "`" */ + 0x61, 0x2, 0x0, 0x0, 0x0, 0x0, + + /* U+0061 "a" */ + 0x0, 0x7, 0x2, 0x7a, 0x27, 0x80, + + /* U+0062 "b" */ + 0x82, 0xb, 0x32, 0x8a, 0x2f, 0x0, + + /* U+0063 "c" */ + 0x0, 0x7, 0x20, 0x82, 0x27, 0x0, + + /* U+0064 "d" */ + 0x8, 0x26, 0xa6, 0x8a, 0x27, 0x80, + + /* U+0065 "e" */ + 0x0, 0x7, 0x22, 0xfa, 0x7, 0x80, + + /* U+0066 "f" */ + 0x31, 0x24, 0x3c, 0x41, 0x4, 0x0, + + /* U+0067 "g" */ + 0x0, 0x7, 0xa2, 0x78, 0x27, 0x0, + + /* U+0068 "h" */ + 0x82, 0xb, 0x32, 0x8a, 0x28, 0x80, + + /* U+0069 "i" */ + 0x20, 0x6, 0x8, 0x20, 0x87, 0x0, + + /* U+006A "j" */ + 0x10, 0x3, 0x4, 0x12, 0x46, 0x0, + + /* U+006B "k" */ + 0x82, 0x8, 0xa4, 0xa3, 0x48, 0x80, + + /* U+006C "l" */ + 0x60, 0x82, 0x8, 0x20, 0x87, 0x0, + + /* U+006D "m" */ + 0x0, 0xd, 0x2a, 0xaa, 0x28, 0x80, + + /* U+006E "n" */ + 0x0, 0xb, 0x32, 0x8a, 0x28, 0x80, + + /* U+006F "o" */ + 0x0, 0x7, 0x22, 0x8a, 0x27, 0x0, + + /* U+0070 "p" */ + 0x0, 0xf, 0x22, 0xf2, 0x8, 0x0, + + /* U+0071 "q" */ + 0x0, 0x7, 0xa2, 0x78, 0x20, 0x80, + + /* U+0072 "r" */ + 0x0, 0xb, 0x32, 0x82, 0x8, 0x0, + + /* U+0073 "s" */ + 0x0, 0x7, 0xa0, 0x70, 0x2f, 0x0, + + /* U+0074 "t" */ + 0x41, 0xf, 0x10, 0x41, 0x23, 0x0, + + /* U+0075 "u" */ + 0x0, 0x8, 0xa2, 0x8a, 0x66, 0x80, + + /* U+0076 "v" */ + 0x0, 0x8, 0xa2, 0x89, 0x42, 0x0, + + /* U+0077 "w" */ + 0x0, 0x8, 0xa2, 0xaa, 0xa5, 0x0, + + /* U+0078 "x" */ + 0x0, 0x8, 0x94, 0x21, 0x48, 0x80, + + /* U+0079 "y" */ + 0x0, 0x8, 0xa2, 0x78, 0x2f, 0x0, + + /* U+007A "z" */ + 0x0, 0xf, 0x84, 0x21, 0xf, 0x80, + + /* U+007B "{" */ + 0x18, 0x82, 0x18, 0x20, 0x81, 0x80, + + /* U+007C "|" */ + 0x20, 0x82, 0x0, 0x20, 0x82, 0x0, + + /* U+007D "}" */ + 0xc0, 0x82, 0xc, 0x20, 0x8c, 0x0, + + /* U+007E "~" */ + 0x6a, 0xc0, 0x0, 0x0, 0x0, 0x0, + + /* U+007F "" */ + 0x0, 0x2, 0x14, 0x8b, 0xe0, 0x0 +}; + + +/*--------------------- + * GLYPH DESCRIPTION + *--------------------*/ + +static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = { + {.bitmap_index = 0, .adv_w = 0, .box_w = 0, .box_h = 0, .ofs_x = 0, .ofs_y = 0} /* id = 0 reserved */, + {.bitmap_index = 0, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 6, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 12, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 18, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 24, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 30, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 36, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 42, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 48, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 54, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 60, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 66, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 72, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 78, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 84, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 90, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 96, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 102, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 108, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 114, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 120, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 126, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 132, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 138, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 144, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 150, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 156, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 162, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 168, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 174, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 180, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 186, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 192, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 198, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 204, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 210, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 216, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 222, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 228, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 234, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 240, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 246, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 252, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 258, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 264, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 270, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 276, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 282, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 288, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 294, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 300, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 306, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 312, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 318, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 324, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 330, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 336, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 342, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 348, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 354, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 360, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 366, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 372, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 378, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 384, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 390, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 396, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 402, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 408, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 414, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 420, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 426, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 432, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 438, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 444, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 450, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 456, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 462, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 468, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 474, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 480, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 486, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 492, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 498, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 504, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 510, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 516, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 522, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 528, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 534, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 540, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 546, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 552, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 558, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 564, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 570, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = -1} +}; + +/*--------------------- + * CHARACTER MAPPING + *--------------------*/ + + + +/*Collect the unicode lists and glyph_id offsets*/ +static const lv_font_fmt_txt_cmap_t cmaps[] = +{ + { + .range_start = 32, .range_length = 96, .glyph_id_start = 1, + .unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY + } +}; + + + +/*-------------------- + * ALL CUSTOM DATA + *--------------------*/ + +#if LVGL_VERSION_MAJOR == 8 +/*Store all the custom data of the font*/ +static lv_font_fmt_txt_glyph_cache_t cache; +#endif + +#if LVGL_VERSION_MAJOR >= 8 +static const lv_font_fmt_txt_dsc_t font_dsc = { +#else +static lv_font_fmt_txt_dsc_t font_dsc = { +#endif + .glyph_bitmap = glyph_bitmap, + .glyph_dsc = glyph_dsc, + .cmaps = cmaps, + .kern_dsc = NULL, + .kern_scale = 0, + .cmap_num = 1, + .bpp = 1, + .kern_classes = 0, + .bitmap_format = 0, +#if LVGL_VERSION_MAJOR == 8 + .cache = &cache +#endif +}; + + + +/*----------------- + * PUBLIC FONT + *----------------*/ + +/*Initialize a public general font descriptor*/ +#if LVGL_VERSION_MAJOR >= 8 +const lv_font_t lv_font_portfolio_6x8 = { +#else +lv_font_t lv_font_portfolio_6x8 = { +#endif + .get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt, /*Function pointer to get glyph's data*/ + .get_glyph_bitmap = lv_font_get_bitmap_fmt_txt, /*Function pointer to get glyph's bitmap*/ + .line_height = 8, /*The maximum line height required by the font*/ + .base_line = 1, /*Baseline measured from the bottom of the line*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 + .underline_position = 0, + .underline_thickness = 1, +#endif + .dsc = &font_dsc, /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ +#if LV_VERSION_CHECK(8, 2, 0) || LVGL_VERSION_MAJOR >= 9 + .fallback = NULL, +#endif + .user_data = NULL, +}; + + + +#endif /*#if PORTFOLIO_6X8*/ + diff --git a/main/oled.c b/main/oled.c deleted file mode 100644 index 801abda9..00000000 --- a/main/oled.c +++ /dev/null @@ -1,313 +0,0 @@ -// OLED SSD1306 using the I2C interface -// Written by Larry Bank (bitbank@pobox.com) -// Project started 1/15/2017 -// -// The I2C writes (through a file handle) can be single or multiple bytes. -// The write mode stays in effect throughout each call to write() -// To write commands to the OLED controller, start a byte sequence with 0x00, -// to write data, start a byte sequence with 0x40, -// The OLED controller is set to "page mode". This divides the display -// into 8 128x8 "pages" or strips. Each data write advances the output -// automatically to the next address. The bytes are arranged such that the LSB -// is the topmost pixel and the MSB is the bottom. -// The font data comes from another source and must be rotated 90 degrees -// (at init time) to match the orientation of the bits on the display memory. -// A copy of the display memory is maintained by this code so that single pixel -// writes can occur without having to read from the display controller. - -#include -#include -#include -#include "esp_err.h" -#include "esp_log.h" - -#include "nvs_config.h" -#include "i2c_bitaxe.h" -#include "oled.h" - -#define OLED_I2C_ADDR 0x3C - -extern unsigned char ucSmallFont[]; -static int iScreenOffset; // current write offset of screen data -static unsigned char ucScreen[1024]; // local copy of the image buffer -static int oled_type, oled_flip; - -static void write_command(unsigned char); -static esp_err_t write(uint8_t *, uint8_t); - -static bool oled_active; - -static i2c_master_dev_handle_t ssd1306_dev_handle; - -// Initialialize the OLED Screen -esp_err_t OLED_init(void) -{ - - //init the I2C device - if (i2c_bitaxe_add_device(OLED_I2C_ADDR, &ssd1306_dev_handle) != ESP_OK) { - return ESP_FAIL; - } - - uint8_t oled32_initbuf[] = {0x00, - 0xae, // cmd: display off - 0xd5, // cmd: set display clock - 0x80, - 0xa8, // cmd: set multiplex ratio - 0x1f, // HEIGHT - 1 -> 31 - 0xd3, // cmd: set display offset - 0x00, - 0x40, // cmd: Set Display Start Line - 0x8d, - 0x14, // cmd: Set Higher Column Start Address for Page Addressing Mode - 0xa1, - 0xc8, // cmd: Set COM Output Scan Direction C0/C8 - 0xda, // cmd: Set COM Pins Hardware Configuration - 0x02, // - 0x81, // cmd: Set Contrast control - 0x7f, - 0xd9, // cmd: Set Pre-Charge Period - 0xf1, - 0xdb, // comd: Vcom regulator output - 0x40, - 0xa4, // cmd: display on ram contents - 0xa6, // cmd: set normal - 0xaf}; // cmd: display on - uint8_t uc[4]; - - uint8_t bFlip = nvs_config_get_u16(NVS_CONFIG_FLIP_SCREEN, 1); - uint8_t bInvert = nvs_config_get_u16(NVS_CONFIG_INVERT_SCREEN, 0); - oled_active = false; - - // //enable the module - // GPIO_write(Board_OLED_DISP_ENABLE, 0); - // DELAY_MS(50); - // GPIO_write(Board_OLED_DISP_ENABLE, 1); - // DELAY_MS(50); - - oled_type = OLED_128x32; - oled_flip = bFlip; - - // /* Call driver init functions */ - // I2C_init(); - - // /* Create I2C for usage */ - // I2C_Params_init(&oled_i2cParams); - // oled_i2cParams.bitRate = I2C_100kHz; - // oled_i2c = I2C_open(Board_I2C_SSD1306, &oled_i2cParams); - - // if (oled_i2c == NULL) { - // return false; - // } - oled_active = true; - - write(oled32_initbuf, sizeof(oled32_initbuf)); - - if (bInvert) { - uc[0] = 0; // command - uc[1] = 0xa7; // invert command - write(uc, 2); - } - - if (bFlip) { // rotate display 180 - uc[0] = 0; // command - uc[1] = 0xa0; - write(uc, 2); - uc[1] = 0xc0; - write(uc, 2); - } - return true; -} - -// Sends a command to turn off the OLED display -// Closes the I2C file handle -void OLED_shutdown() -{ - - write_command(0xaE); // turn off OLED - // I2C_close(oled_i2c); - // GPIO_write(Board_OLED_DISP_ENABLE, 0); //turn off power - oled_active = false; -} - -// Send a single byte command to the OLED controller -static void write_command(uint8_t c) -{ - uint8_t buf[2]; - - buf[0] = 0x00; // command introducer - buf[1] = c; - write(buf, 2); -} - -static void oledWriteCommand2(uint8_t c, uint8_t d) -{ - uint8_t buf[3]; - - buf[0] = 0x00; - buf[1] = c; - buf[2] = d; - write(buf, 3); -} - -bool OLED_setContrast(uint8_t ucContrast) -{ - - oledWriteCommand2(0x81, ucContrast); - return true; -} - -// Send commands to position the "cursor" to the given -// row and column -static void oledSetPosition(int x, int y) -{ - iScreenOffset = (y * 128) + x; - if (oled_type == OLED_64x32) // visible display starts at column 32, row 4 - { - x += 32; // display is centered in VRAM, so this is always true - if (oled_flip == 0) // non-flipped display starts from line 4 - y += 4; - } else if (oled_type == OLED_132x64) // SH1106 has 128 pixels centered in 132 - { - x += 2; - } - - write_command(0xb0 | y); // go to page Y - write_command(0x00 | (x & 0x0f)); // lower col addr - write_command(0x10 | ((x >> 4) & 0x0f));// upper col addr -} - -// Write a block of pixel data to the OLED -// Length can be anything from 1 to 1024 (whole display) -static void oledWriteDataBlock(const uint8_t * ucBuf, int iLen) -{ - uint8_t ucTemp[129]; - - ucTemp[0] = 0x40; // data command - memcpy(&ucTemp[1], ucBuf, iLen); - write(ucTemp, iLen + 1); - // Keep a copy in local buffer - memcpy(&ucScreen[iScreenOffset], ucBuf, iLen); - iScreenOffset += iLen; -} - -// Set (or clear) an individual pixel -// The local copy of the frame buffer is used to avoid -// reading data from the display controller -int OLED_setPixel(int x, int y, uint8_t ucColor) -{ - int i; - uint8_t uc, ucOld; - - // if (oled_i2c == NULL) - // return -1; - - i = ((y >> 3) * 128) + x; - if (i < 0 || i > 1023) // off the screen - return -1; - uc = ucOld = ucScreen[i]; - uc &= ~(0x1 << (y & 7)); - if (ucColor) { - uc |= (0x1 << (y & 7)); - } - if (uc != ucOld) // pixel changed - { - oledSetPosition(x, y >> 3); - oledWriteDataBlock(&uc, 1); - } - return 0; -} - -// Write a bitmap to the screen -// The X position is in character widths (8 or 16) -// The Y position is in memory pages (8 lines each) -// Bitmap should be aligned vertical, 1 bit per pixel -// Width and Height must be per 8 pixels -// Conversion tool: https://javl.github.io/image2cpp/ -int OLED_showBitmap(int x, int y, const uint8_t *bitmap, int width, int height) -{ - for (int row = 0; row < (height >> 3); row++) { - oledSetPosition(x, y + row); - oledWriteDataBlock(&bitmap[row * width], width); - } - - return 0; -} - -// -// Draw a string of small (8x8), large (16x24), or very small (6x8) characters -// At the given col+row -// The X position is in character widths (8 or 16) -// The Y position is in memory pages (8 lines each) -// -int OLED_writeString(int x, int y, const char * szMsg) -{ - int i, iLen; - uint8_t * s; - - // if (oled_i2c == NULL) return -1; // not initialized - - iLen = strlen(szMsg); - - oledSetPosition(x * 6, y); - if (iLen + x > 21) - iLen = 21 - x; - if (iLen < 0) - return -1; - for (i = 0; i < iLen; i++) { - s = &ucSmallFont[(unsigned char) szMsg[i] * 6]; - oledWriteDataBlock(s, 6); - } - - return 0; -} - -// Fill the frame buffer with a byte pattern -// e.g. all off (0x00) or all on (0xff) -int OLED_fill(uint8_t ucData) -{ - int y; - uint8_t temp[128]; - int iLines, iCols; - - // if (oled_i2c == NULL) return -1; // not initialized - - iLines = (oled_type == OLED_128x32 || oled_type == OLED_64x32) ? 4 : 8; - iCols = (oled_type == OLED_64x32) ? 4 : 8; - - memset(temp, ucData, 128); - for (y = 0; y < iLines; y++) { - oledSetPosition(0, y); // set to (0,Y) - oledWriteDataBlock(temp, iCols * 16); // fill with data byte - } // for y - return 0; -} - -int OLED_clearLine(uint8_t line) -{ - uint8_t temp[128]; - - // if (oled_i2c == NULL) return -1; // not initialized - if (line > 4) - return -1; // line number too big - - memset(temp, 0, 128); - oledSetPosition(0, line); // set to (0,Y) - oledWriteDataBlock(temp, 128); // fill with data byte - - return 0; -} - -bool OLED_status(void) -{ - return oled_active; -} - -/** - * @brief Write a byte to a I2C register - */ -static esp_err_t write(uint8_t * data, uint8_t len) -{ - //return i2c_master_write_to_device(I2C_MASTER_NUM, 0x3C, data, len, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); - - return i2c_bitaxe_register_write_bytes(ssd1306_dev_handle, data, len); -} diff --git a/main/oled.h b/main/oled.h deleted file mode 100644 index ba3d82c2..00000000 --- a/main/oled.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef OLED96_H -#define OLED96_H -// -// OLED96 -// Library for accessing the 0.96" SSD1306 128x64 OLED display -// Written by Larry Bank (bitbank@pobox.com) -// Copyright (c) 2017 BitBank Software, Inc. -// Project started 1/15/2017 -// -// OLED type for init function -enum -{ - OLED_128x32 = 1, - OLED_128x64, - OLED_132x64, - OLED_64x32 -}; - -typedef enum -{ - FONT_NORMAL = 0, // 8x8 - FONT_BIG, // 16x24 - FONT_SMALL // 6x8 -} FONTSIZE; - -// Initialize the OLED96 library for a specific I2C address -// Optionally enable inverted or flipped mode -// returns 0 for success, 1 for failure -// -esp_err_t OLED_init(void); - -// Turns off the display and closes the I2C handle -void OLED_shutdown(void); - -// Fills the display with the byte pattern -int OLED_fill(uint8_t ucPattern); - -// Write a text string to the display at x (column 0-127) and y (row 0-7) -// bLarge = 0 - 8x8 font, bLarge = 1 - 16x24 font -int OLED_writeString(int x, int y, const char *szText); - -// Sets a pixel to On (1) or Off (0) -// Coordinate system is pixels, not text rows (0-127, 0-63) -int OLED_setPixel(int x, int y, uint8_t ucPixel); -int OLED_showBitmap(int x, int y, const uint8_t *bitmap, int width, int height); - -// Sets the contrast (brightness) level of the display -// Valid values are 0-255 where 0=off and 255=max brightness -bool OLED_setContrast(uint8_t ucContrast); -int OLED_clearLine(uint8_t); -bool OLED_status(void); - -#endif // OLED96_H diff --git a/main/self_test/self_test.c b/main/self_test/self_test.c index 89fcc9d5..305da31b 100644 --- a/main/self_test/self_test.c +++ b/main/self_test/self_test.c @@ -7,7 +7,7 @@ #include "global_state.h" #include "nvs_config.h" #include "nvs_flash.h" -#include "oled.h" +#include "display.h" #include "vcore.h" #include "utils.h" #include "string.h" @@ -19,6 +19,7 @@ #define POWER_CONSUMPTION_MARGIN 3 //+/- watts static const char * TAG = "self_test"; +const char *messages[] = {"", "", "", ""}; bool should_test(GlobalState * GLOBAL_STATE) { bool is_max = GLOBAL_STATE->asic_model == ASIC_BM1397; @@ -31,17 +32,14 @@ bool should_test(GlobalState * GLOBAL_STATE) { } static void display_msg(char * msg, GlobalState * GLOBAL_STATE) { - SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; - switch (GLOBAL_STATE->device_model) { case DEVICE_MAX: case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - if (OLED_status()) { - memset(module->oled_buf, 0, 20); - snprintf(module->oled_buf, 20, msg); - OLED_writeString(0, 2, module->oled_buf); + if (display_active()) { + messages[2] = msg; + display_show_status(messages, 4); } break; default: @@ -49,17 +47,15 @@ static void display_msg(char * msg, GlobalState * GLOBAL_STATE) { } static void display_end_screen(GlobalState * GLOBAL_STATE) { - switch (GLOBAL_STATE->device_model) { case DEVICE_MAX: case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - if (OLED_status()) { - OLED_clearLine(2); - OLED_writeString(0, 2, "TESTS PASS!"); - OLED_clearLine(3); - OLED_writeString(0, 3, " PRESS RESET"); + if (display_active()) { + messages[2] = "TESTS PASS!"; + messages[3] = " PRESS RESET"; + display_show_status(messages, 4); } break; default: @@ -130,13 +126,12 @@ void self_test(void * pvParameters) case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - if (!OLED_init()) { + if (!display_init()) { ESP_LOGE(TAG, "OLED init failed!"); } else { ESP_LOGI(TAG, "OLED init success!"); - // clear the oled screen - OLED_fill(0); - OLED_writeString(0, 0, "BITAXE SELF TESTING"); + messages[0] = "BITAXE SELF TESTING"; + display_show_status(messages, 4); } break; default: @@ -350,10 +345,10 @@ void self_test(void * pvParameters) case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - if (OLED_status()) { - OLED_clearLine(3); - OLED_writeString(0, 3, " PRESS RESET"); - } + if (display_active()) { + messages[3] = " PRESS RESET"; + display_show_status(messages, 4); + } break; default: } @@ -363,9 +358,10 @@ void self_test(void * pvParameters) case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - if (OLED_status()) { - OLED_clearLine(3); - } + if (display_active()) { + messages[3] = ""; + display_show_status(messages, 4); + } break; default: } diff --git a/main/system.c b/main/system.c index 2fc7fb9f..edfb8b45 100644 --- a/main/system.c +++ b/main/system.c @@ -26,7 +26,7 @@ #include "connect.h" #include "led_controller.h" #include "nvs_config.h" -#include "oled.h" +#include "display.h" #include "vcore.h" @@ -41,8 +41,6 @@ QueueHandle_t user_input_queue; //local function prototypes static esp_err_t ensure_overheat_mode_config(); static void _show_overheat_screen(GlobalState * GLOBAL_STATE); -static void _clear_display(GlobalState * GLOBAL_STATE); -static void _init_connection(GlobalState * GLOBAL_STATE); static void _update_connection(GlobalState * GLOBAL_STATE); static void _update_screen_one(GlobalState * GLOBAL_STATE); static void _update_screen_two(GlobalState * GLOBAL_STATE); @@ -141,12 +139,11 @@ void SYSTEM_init_peripherals(GlobalState * GLOBAL_STATE) { case DEVICE_SUPRA: case DEVICE_GAMMA: // oled - if (!OLED_init()) { - ESP_LOGI(TAG, "OLED init failed!"); + if (display_init() != ESP_OK) { + ESP_LOGW(TAG, "OLED init failed!"); } else { ESP_LOGI(TAG, "OLED init success!"); - // clear the oled screen - OLED_fill(0); + display_clear(); } break; default: @@ -155,46 +152,8 @@ void SYSTEM_init_peripherals(GlobalState * GLOBAL_STATE) { netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF"); user_input_queue = xQueueCreate(10, sizeof(char[10])); // Create a queue to handle user input events - - _clear_display(GLOBAL_STATE); - _init_connection(GLOBAL_STATE); } -static const uint8_t bitaxe_splash[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x10, 0x18, 0x3c, - 0x7e, 0xfc, 0xf8, 0xf0, 0x38, 0x3c, 0x3c, 0x7c, 0xf8, 0xf8, 0xf8, 0x30, 0x10, 0x08, 0x00, 0x08, - 0x9c, 0x3e, 0x1c, 0x08, 0x00, 0x00, 0x80, 0x80, 0xc0, 0xe0, 0xf0, 0x80, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x10, 0x20, 0x20, 0x10, 0x08, - 0x00, 0xff, 0xff, 0xff, 0x80, 0xe0, 0xf0, 0xe0, 0xff, 0xff, 0xdf, 0xc0, 0x60, 0x00, 0x06, 0xff, - 0xff, 0xff, 0xfe, 0x02, 0x00, 0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x18, 0x18, - 0x3c, 0xfe, 0x87, 0x07, 0x0f, 0xff, 0xff, 0xfe, 0xfe, 0x06, 0x00, 0x04, 0xff, 0xff, 0xff, 0xfe, - 0x82, 0x00, 0x04, 0xff, 0xff, 0xff, 0xfe, 0x02, 0x00, 0x00, 0xf8, 0xfc, 0xfc, 0xfe, 0x07, 0x07, - 0x8f, 0xff, 0x7f, 0x3e, 0x1e, 0x12, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, - 0x82, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x02, 0xff, - 0xff, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02, 0xff, 0xff, 0xff, 0xff, 0x02, 0x00, 0x00, 0xf0, 0xf0, - 0xf8, 0xf8, 0x0c, 0x06, 0x02, 0xff, 0xff, 0xff, 0xff, 0x02, 0x00, 0x04, 0xf3, 0xf7, 0xff, 0xff, - 0x0f, 0x0f, 0x1f, 0xff, 0xff, 0xfe, 0xfc, 0x02, 0x00, 0x02, 0xff, 0xff, 0xff, 0xff, 0x02, 0x03, - 0x01, 0x80, 0x80, 0xc0, 0xe0, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x46, 0x47, 0x03, 0x03, 0x07, - 0x07, 0x0f, 0x0f, 0x1f, 0x1e, 0x3e, 0x1c, 0x0c, 0x07, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x0f, - 0x1f, 0x3f, 0x1f, 0x0c, 0x04, 0x00, 0x00, 0x0f, 0x1f, 0x3f, 0x1f, 0x0c, 0x04, 0x10, 0x0f, 0x0f, - 0x1f, 0x1f, 0x1e, 0x1e, 0x1c, 0x0f, 0x1f, 0x1f, 0x1f, 0x04, 0x00, 0x00, 0x0f, 0x1f, 0x1f, 0x0f, - 0x04, 0x00, 0x00, 0x0f, 0x1f, 0x1f, 0x0f, 0x04, 0x00, 0x10, 0x0f, 0x0f, 0x1f, 0x1f, 0x1e, 0x1e, - 0x1c, 0x0f, 0x07, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - void SYSTEM_task(void * pvParameters) { GlobalState * GLOBAL_STATE = (GlobalState *) pvParameters; @@ -216,9 +175,11 @@ void SYSTEM_task(void * pvParameters) vTaskDelay(1000 / portTICK_PERIOD_MS); } - OLED_showBitmap(0, 0, bitaxe_splash, 128, 32); - vTaskDelay(5000 / portTICK_PERIOD_MS); - + if (display_active()) { + display_show_logo(); + vTaskDelay(5000 / portTICK_PERIOD_MS); + } + int current_screen = 0; TickType_t last_update_time = xTaskGetTickCount(); @@ -232,7 +193,6 @@ void SYSTEM_task(void * pvParameters) } // Update the current screen - _clear_display(GLOBAL_STATE); module->screen_page = current_screen; switch (current_screen) { @@ -268,8 +228,6 @@ void SYSTEM_task(void * pvParameters) } last_update_time = xTaskGetTickCount(); - - } } @@ -371,7 +329,6 @@ void SYSTEM_notify_found_nonce(GlobalState * GLOBAL_STATE, double found_diff, ui /// static void _show_overheat_screen(GlobalState * GLOBAL_STATE) { - SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; esp_netif_ip_info_t ip_info; switch (GLOBAL_STATE->device_model) { @@ -379,20 +336,16 @@ static void _show_overheat_screen(GlobalState * GLOBAL_STATE) case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - if (OLED_status()) { - OLED_clearLine(0); - OLED_writeString(0, 0, "DEVICE OVERHEAT!"); - OLED_clearLine(1); - OLED_writeString(0, 1, "See AxeOS settings"); - OLED_clearLine(2); - OLED_clearLine(3); + if (display_active()) { esp_netif_get_ip_info(netif, &ip_info); char ip_address_str[IP4ADDR_STRLEN_MAX]; esp_ip4addr_ntoa(&ip_info.ip, ip_address_str, IP4ADDR_STRLEN_MAX); - - memset(module->oled_buf, 0, 20); - snprintf(module->oled_buf, 20, "IP: %s", ip_address_str); - OLED_writeString(0, 3, module->oled_buf); + display_show_status((const char *[]){ + "DEVICE OVERHEAT!", + "See AxeOS settings", + "IP:", + ip_address_str + }, 4); } break; default: @@ -401,40 +354,6 @@ static void _show_overheat_screen(GlobalState * GLOBAL_STATE) } static void _update_screen_one(GlobalState * GLOBAL_STATE) -{ - SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; - PowerManagementModule * power_management = &GLOBAL_STATE->POWER_MANAGEMENT_MODULE; - switch (GLOBAL_STATE->device_model) { - case DEVICE_MAX: - case DEVICE_ULTRA: - case DEVICE_SUPRA: - case DEVICE_GAMMA: - if (OLED_status()) { - float efficiency = GLOBAL_STATE->POWER_MANAGEMENT_MODULE.power / (module->current_hashrate / 1000.0); - - memset(module->oled_buf, 0, 20); - snprintf(module->oled_buf, 20, "Gh/s: %.2f", module->current_hashrate); - OLED_writeString(0, 0, module->oled_buf); - - memset(module->oled_buf, 0, 20); - snprintf(module->oled_buf, 20, "J/Th: %.2f", efficiency); - OLED_writeString(0, 1, module->oled_buf); - - memset(module->oled_buf, 0, 20); - snprintf(module->oled_buf, 20, module->FOUND_BLOCK ? "!!! BLOCK FOUND !!!" : "Best: %s", module->best_diff_string); - OLED_writeString(0, 2, module->oled_buf); - - memset(module->oled_buf, 0, 20); - snprintf(module->oled_buf, 20, "Temp: %.1f C", power_management->chip_temp_avg); - OLED_writeString(0, 3, module->oled_buf); - } - break; - default: - break; - } -} - -static void _update_screen_two(GlobalState * GLOBAL_STATE) { SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; esp_netif_ip_info_t ip_info; @@ -444,34 +363,16 @@ static void _update_screen_two(GlobalState * GLOBAL_STATE) case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - if (OLED_status()) { - // Pool URL - OLED_writeString(0, 0, "Mining URL:"); - memset(module->oled_buf, 0, 20); - if (module->is_using_fallback) { - snprintf(module->oled_buf, 20, "%.19s", module->fallback_pool_url); - } else { - snprintf(module->oled_buf, 20, "%.19s", module->pool_url); - } - OLED_writeString(0, 1, module->oled_buf); - // // Second line of pool URL - // memset(module->oled_buf, 0, 20); - // if (module->is_using_fallback) { - // snprintf(module->oled_buf, 20, "%.19s", module->fallback_pool_url + 13); - // } else { - // snprintf(module->oled_buf, 20, "%.19s", module->pool_url + 13); - // } - // OLED_writeString(0, 1, module->oled_buf); - - // IP Address - OLED_writeString(0, 2, "Bitaxe IP:"); + if (display_active()) { esp_netif_get_ip_info(netif, &ip_info); char ip_address_str[IP4ADDR_STRLEN_MAX]; esp_ip4addr_ntoa(&ip_info.ip, ip_address_str, IP4ADDR_STRLEN_MAX); - - memset(module->oled_buf, 0, 20); - snprintf(module->oled_buf, 20, "%s", ip_address_str); - OLED_writeString(0, 3, module->oled_buf); + display_show_status((const char *[]){ + "Mining URL:", + module->is_using_fallback ? module->fallback_pool_url : module->pool_url, + "Bitaxe IP:", + ip_address_str + }, 4); } break; default: @@ -479,38 +380,39 @@ static void _update_screen_two(GlobalState * GLOBAL_STATE) } } -static void _clear_display(GlobalState * GLOBAL_STATE) +static void _update_screen_two(GlobalState * GLOBAL_STATE) { + SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; + PowerManagementModule * power_management = &GLOBAL_STATE->POWER_MANAGEMENT_MODULE; switch (GLOBAL_STATE->device_model) { case DEVICE_MAX: case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - OLED_clearLine(0); - OLED_clearLine(1); - OLED_clearLine(2); - OLED_clearLine(3); - break; - default: - } -} + if (display_active()) { + char label_hashrate[20]; + snprintf(label_hashrate, 20, "Gh/s: %.2f", module->current_hashrate); -static void _init_connection(GlobalState * GLOBAL_STATE) -{ - SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE; + char label_efficiency[20]; + float efficiency = GLOBAL_STATE->POWER_MANAGEMENT_MODULE.power / (module->current_hashrate / 1000.0); + snprintf(label_efficiency, 20, "J/Th: %.2f", efficiency); - switch (GLOBAL_STATE->device_model) { - case DEVICE_MAX: - case DEVICE_ULTRA: - case DEVICE_SUPRA: - case DEVICE_GAMMA: - if (OLED_status()) { - memset(module->oled_buf, 0, 20); - snprintf(module->oled_buf, 20, "Connecting to SSID:"); - OLED_writeString(0, 0, module->oled_buf); + char label_best[20]; + snprintf(label_best, 27, "Best: %s/%s", module->best_session_diff_string, module->best_diff_string); + + char label_temp_avg[20]; + snprintf(label_temp_avg, 20, "Temp: %.1f C", power_management->chip_temp_avg); + + display_show_status((const char *[]){ + label_hashrate, + label_efficiency, + module->FOUND_BLOCK ? "!!! BLOCK FOUND !!!" : label_best, + label_temp_avg + }, 4); } break; default: + break; } } @@ -523,21 +425,17 @@ static void _update_connection(GlobalState * GLOBAL_STATE) case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - if (OLED_status()) { - OLED_clearLine(2); - strncpy(module->oled_buf, module->ssid, sizeof(module->oled_buf)); - module->oled_buf[sizeof(module->oled_buf) - 1] = 0; - OLED_writeString(0, 1, module->oled_buf); - - memset(module->oled_buf, 0, 20); - snprintf(module->oled_buf, 20, "Configuration SSID:"); - OLED_writeString(0, 2, module->oled_buf); + if (display_active()) { char ap_ssid[13]; generate_ssid(ap_ssid); - memset(module->oled_buf, 0, 20); - snprintf(module->oled_buf, 20, ap_ssid); - OLED_writeString(0, 3, module->oled_buf); + + display_show_status((const char *[]){ + "Connecting to SSID:", + module->ssid, + "Configuration SSID:", + ap_ssid + }, 4); } break; default: @@ -552,15 +450,14 @@ static void show_ap_information(const char * error, GlobalState * GLOBAL_STATE) case DEVICE_ULTRA: case DEVICE_SUPRA: case DEVICE_GAMMA: - if (OLED_status()) { - _clear_display(GLOBAL_STATE); - if (error != NULL) { - OLED_writeString(0, 0, error); - } - OLED_writeString(0, 1, "Configuration SSID:"); + if (display_active()) { char ap_ssid[13]; generate_ssid(ap_ssid); - OLED_writeString(0, 2, ap_ssid); + + display_show_status((const char *[]){ + "Configuration SSID:", + ap_ssid + }, 2); } break; default: diff --git a/readme.md b/readme.md index aac5113f..f628af5e 100755 --- a/readme.md +++ b/readme.md @@ -65,3 +65,7 @@ Some API examples in curl: ## Administration The firmware hosts a small web server on port 80 for administrative purposes. Once the Bitaxe device is connected to the local network, the admin web front end may be accessed via a web browser connected to the same network at `http://`, replacing `IP` with the LAN IP address of the Bitaxe device, or `http://bitaxe`, provided your network supports mDNS configuration. + +## Attributions + +The display font is Portfolio 6x8 from https://int10h.org/oldschool-pc-fonts/ by VileR. \ No newline at end of file diff --git a/sdkconfig.defaults b/sdkconfig.defaults index 63d09ca1..3a05b981 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -10,3 +10,7 @@ CONFIG_SPIFFS_OBJ_NAME_LEN=64 CONFIG_HTTPD_MAX_URI_LEN=2048 CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y CONFIG_ESP_WIFI_11KV_SUPPORT=y +CONFIG_LV_USE_THEME_DEFAULT=n +CONFIG_LV_USE_THEME_BASIC=n +CONFIG_LV_USE_SNAPSHOT=n +CONFIG_LV_BUILD_EXAMPLES=n