Description
Hi, I’m trying to display a png to the screen by opening it from the file path “/mnt/flash/nexion.png”. However, every time I try to open this file up using the line img_set_src(img, “/mnt/flash/nexion.png”), I’m told that the file cannot be opened because it contains an unknown driver letter. The error is: lv_fs_open: Can’t open file ("/mnt/flash/nexion.png): unknown driver letter. I’m not sure why it is even using lv_fs_open to begin with. On this website: https://github.com/lvgl/lv_lib_png, it says that by deafult lodepng uses C file IO API (e.g. fopen) and images can be opened like this:
lv_img_set_src(img, “./lv_lib_png/png_decoder_test.png”). fopen works for me when using the call fopen("/mnt/flash/testfile.txt") so why would it not work when I’m setting the img_src in the same way?
What MCU/Processor/Board and compiler are you using?
Xilinx Zyng Development Board
What LVGL version are you using?
Version 8.1
What do you want to achieve?
I want to render a png to the screen without having to use the online decoder. I want to decode the png image to a C file and display it right away on the screen. I don’t mind doing so in a longer way - like using lodepng directly instead of using the lv_img_set_src function. However, I do not know what function to call to do so
What have you tried so far?
I have tried putting the png file in a folder on my windows C drive and using the absolute path in the call set_img_src(img, “C:/users/matth/…”). I had to register a driver to do so in main.c but had no luck with it and the documentation was not easy to follow. I added #define LV_USE_PNG 1 in lv_conf.h and lv_conf_internal.h. Then I added the snippet of code below to a testing page but it gives me the error of an unknown driver letter described above and an inability to properly open the file.
Code to reproduce
The code block(s) should be formatted like:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include "../lvgl/lvgl.h"
#include "controlTab.h"
#include "global.h"
#include "../lvgl/src/extra/libs/png/lv_png.h"
/* STATIC - PRIVATE VARIABLES */
static lv_obj_t * backButton;
static lv_obj_t * container;
static lv_obj_t * chart;
static lv_chart_series_t * ser;
static lv_chart_cursor_t * cursor;
/* FUNCTION DECLARATIONS */
static void BackButtonPressed(lv_event_t * event);
void TestingPageInit(void)
{
container = lv_obj_create(controlTab);
lv_obj_set_size(container, lv_obj_get_width(controlTab), lv_obj_get_height(controlTab)/2);
lv_obj_center(container);
lv_obj_t * label = lv_label_create(container);
backButton = lv_btn_create(controlTab);
lv_obj_align(backButton, LV_ALIGN_CENTER, -290, 110);
lv_obj_set_size(backButton, 120, 60);
lv_obj_t *label1 = lv_label_create(backButton);
lv_label_set_text(label1, LV_SYMBOL_BACKSPACE " BACK");
lv_obj_add_event_cb(backButton, BackButtonPressed, LV_EVENT_CLICKED, NULL);
lv_png_init();
//LV_IMG_DECLARE(png_decoder_test);
lv_obj_t * img = lv_img_create(lv_scr_act());
//lv_img_set_src(img, "./mnt/flash/nexion.png");
lv_img_set_src(img, "P:/users/matth/downloads/nexion.png");
}