+ rearranged files
+ improved ui log + added image browser - image loading fails at the moment - arrangement of ui in image browser not checked
This commit is contained in:
+13
-58
@@ -1,67 +1,28 @@
|
||||
#include "esp_check.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_lvgl_port.h"
|
||||
#include "lcd/lcd.h"
|
||||
#include "sd/sd.h"
|
||||
#include "lvgl.h"
|
||||
#include "lcd/lcd.h"
|
||||
#include "lcd/ui.h"
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
|
||||
static const char *TAG = "app";
|
||||
static lv_obj_t *log_textarea = NULL;
|
||||
|
||||
static void ui_log_append(const char *text)
|
||||
{
|
||||
if(log_textarea == NULL || text == NULL) return;
|
||||
|
||||
lvgl_port_lock(0);
|
||||
lv_textarea_add_text(log_textarea, text);
|
||||
lv_textarea_add_text(log_textarea, "\n");
|
||||
lv_textarea_set_cursor_pos(log_textarea, LV_TEXTAREA_CURSOR_LAST);
|
||||
lvgl_port_unlock();
|
||||
}
|
||||
|
||||
static void create_log_ui(void)
|
||||
{
|
||||
lv_obj_t *screen = lv_screen_active();
|
||||
lv_obj_set_style_bg_color(screen, lv_color_hex(0x101418), 0);
|
||||
|
||||
lv_obj_t *title = lv_label_create(screen);
|
||||
lv_label_set_text(title, "SD Image Viewer");
|
||||
lv_obj_set_style_text_color(title, lv_color_white(), 0);
|
||||
lv_obj_align(title, LV_ALIGN_TOP_MID, 0, 14);
|
||||
|
||||
log_textarea = lv_textarea_create(screen);
|
||||
lv_obj_set_size(log_textarea, lv_pct(92), lv_pct(84));
|
||||
lv_obj_align(log_textarea, LV_ALIGN_BOTTOM_MID, 0, -14);
|
||||
lv_textarea_set_one_line(log_textarea, false);
|
||||
lv_textarea_set_cursor_click_pos(log_textarea, false);
|
||||
lv_textarea_set_text(log_textarea, "");
|
||||
lv_obj_set_style_bg_color(log_textarea, lv_color_hex(0x182028), 0);
|
||||
lv_obj_set_style_text_color(log_textarea, lv_color_hex(0xdde7ef), 0);
|
||||
lv_obj_set_style_border_color(log_textarea, lv_color_hex(0x4b6478), 0);
|
||||
lv_obj_set_style_radius(log_textarea, 4, 0);
|
||||
lv_obj_set_style_pad_all(log_textarea, 12, 0);
|
||||
|
||||
lv_textarea_add_text(log_textarea, "Boot UI ready\n");
|
||||
lv_textarea_set_cursor_pos(log_textarea, LV_TEXTAREA_CURSOR_LAST);
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
void app_main(void){
|
||||
ESP_LOGI(TAG, "Start display application");
|
||||
ESP_ERROR_CHECK(lcd_init());
|
||||
|
||||
ESP_LOGI(TAG, "Creating log UI");
|
||||
lvgl_port_lock(0);
|
||||
create_log_ui();
|
||||
lvgl_port_unlock();
|
||||
|
||||
ESP_LOGI(TAG, "Initializing SD card");
|
||||
ui_log_append("Initializing SD card...");
|
||||
ui_log_append("\nInitializing SD card...");
|
||||
sd_init();
|
||||
print_sd_card_info();
|
||||
ui_log_append("SD initialization done");
|
||||
ESP_LOGI(TAG, "SD card initialization complete");
|
||||
|
||||
ui_log_append("\nListing files in root directory:");
|
||||
size_t file_count = sd_get_file_count();
|
||||
ESP_LOGI(TAG, "Found %d files in root directory", file_count);
|
||||
const char* filename = NULL;
|
||||
@@ -71,19 +32,13 @@ void app_main(void)
|
||||
char line[96];
|
||||
snprintf(line, sizeof(line), "Found file: %s", filename);
|
||||
ui_log_append(line);
|
||||
vTaskDelay(pdMS_TO_TICKS(1));
|
||||
}
|
||||
|
||||
/*
|
||||
FILE* file = sd_open_write("test.txt");
|
||||
if(file != NULL){
|
||||
fprintf(file, "Hello, SD card!\n");
|
||||
sd_close_file(file);
|
||||
ui_log_append("Wrote test.txt");
|
||||
} else {
|
||||
ui_log_append("Failed to open test.txt for writing");
|
||||
}
|
||||
*/
|
||||
ui_log_append("Done listing files in root directory");
|
||||
|
||||
sd_destroy();
|
||||
ui_log_append("SD card unmounted");
|
||||
ui_switch_view_to(UI_VIEW_IMAGE_BROWSER);
|
||||
|
||||
// sd_destroy();
|
||||
// ui_log_append("\nSD card unmounted");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user