Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sdcard filesystem mount fails #3

Open
joekam54 opened this issue Apr 17, 2024 · 2 comments
Open

Sdcard filesystem mount fails #3

joekam54 opened this issue Apr 17, 2024 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@joekam54
Copy link

Hello!
First off all thank you for the great work you have done with this repo!

I have got an issue and ave no idea to overcome maybe you can help. My work is based on your WT32-sc-01 Plus code in combnation with lv_images, I would like to display images which are storred on the sdcard.
But It is not working because the file system mount fails.
your help is appreciated.

ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0xa (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x44c
load:0x403c9700,len:0xbe4
load:0x403cc700,len:0x2a38
entry 0x403c98d4
SD Card Type: SDHC
SD Card size: 7538
SD Card used bytes: 2
Listing directory: /
[ 955][E][vfs_api.cpp:24] open(): File system is not mounted

@SubCoderHUN
Copy link
Owner

SubCoderHUN commented Apr 17, 2024

Hello! 😄
Thank you for your feedback! 🙇

You need to format your SD card in FAT32.
Can you show me the code, where you try to read the image from the SD card?

Thanks!

@SubCoderHUN SubCoderHUN changed the title Sdcard filesystem mount ails Sdcard filesystem mount fails Apr 17, 2024
@joekam54
Copy link
Author

Hi thanks for your reply :-)
SD card is Fat32,
Im a step further already, the FS System is found and files too :-) but lv_images still is not able to load them.. so the original failure was my fault i joining lyimages with your code, so the isue is closed but if you have an idea what the problem now it would be great.

ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x9 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x44c
load:0x403c9700,len:0xbe4
load:0x403cc700,len:0x2a38
entry 0x403c98d4
SD Card Type: SDHC
SD Card size: 7538
SD Card used bytes: 2
Listing directory: /
DIR : System Volume Information
FILE: 5.jpg SIZE: 106618
FILE: 1.jpg SIZE: 19513
FILE: 2.jpg SIZE: 26107
FILE: 3.jpg SIZE: 22390
FILE: 4.jpg SIZE: 65133
FILE: test.txt SIZE: 1048576
FILE: foo.txt SIZE: 6
open : A:/1.jpg
File not find image...
File not find image...
File not find image...
File not find image...

thats the original part of lv_images from the board lilygo :https://github.com/Xinyuan-LilyGO/LilyGo-T-RGB/tree/main/examples/lv_images Arduino example
I used your setup for the board wt32-sc01 Plus since it was the best I could find to support the paralell display and went through implementing all dependencys ....
so this is my main.cpp now ;-) or lets say ours :-), Iam so far now and getting stopped with that issue

/////////////////////////////////////////////////////////////////
/*
Erase Flash: esptool.py --chip esp32-s3 erase_flash

°°°°°°°°°°°°°°°° Handcrafted and made with ❤ °°°°°°°°°°°°°°°°
*/
/////////////////////////////////////////////////////////////////

#include <Wire.h>
#define LGFX_USE_V1
#include <LovyanGFX.hpp>
#include <lvgl.h>
#include <ESP32Time.h>
#include <LV_Helper.h>
//#include "Audio.h"
//#include "ui.h"
//#include "Managers/TimeManager/time_manager.h"
#include "Managers/WiFiManager/wifi_manager.h"
//#include "Managers/EEPROMManager/eeprom_manager.h"
#include "Managers/SDManager/sd_manager.h"
//#include "Features/weather/weather.h"
//#include "Features/radio/radio.h"
#include "main.h"
#include <SD_MMC.h>
#include <FS.h>
#include "SD_MMC.h"
#include "SD.h"

#if !LV_USE_PNG || !LV_USE_BMP || !LV_USE_SJPG
#error "lvgl png , bmp , sjpg decoder library is not enable!"
#endif

const char *filename[] = {
"1.jpg", "6.jpg", "5.jpg",
"2.jpg", "3.jpg", "4.jpg",
};

////////////////////////////////////////////////////////////////////////////////////////////////////////
bool SDCARD_INSERTED = true; // Change this to false, if you are not using an SD card to save the logs!
////////////////////////////////////////////////////////////////////////////////////////////////////////

SimpleTimer Timer; // ~For weather update, 5 min
SimpleTimer WiFiTimer; // ~For WiFi management

static const int RXPin = 10, TXPin = 11, sclPin = 12, sdaPin = 13;
bool isSetupCompleted, runOnce, runWifiState, WriteLocToEEPROMOnce, doonce, setbrightness, setbrightnessbytime, setbrightness_s, setbrightnessbytime_s = false;
int screen_brightness = 255;
int fromroller, toroller = 0;
int forint = 0;
char location[15];

class LGFX : public lgfx::LGFX_Device
{
lgfx::Panel_ST7796 _panel_instance;
lgfx::Bus_Parallel8 _bus_instance;
lgfx::Light_PWM _light_instance;
lgfx::Touch_FT5x06 _touch_instance;

public:
LGFX(void)
{
{
auto cfg = _bus_instance.config();
cfg.freq_write = 40000000;
cfg.pin_wr = 47;
cfg.pin_rd = -1;
cfg.pin_rs = 0;
cfg.pin_d0 = 9;
cfg.pin_d1 = 46;
cfg.pin_d2 = 3;
cfg.pin_d3 = 8;
cfg.pin_d4 = 18;
cfg.pin_d5 = 17;
cfg.pin_d6 = 16;
cfg.pin_d7 = 15;
_bus_instance.config(cfg);
_panel_instance.setBus(&_bus_instance);
}

{
  auto cfg = _panel_instance.config();
  cfg.pin_cs = -1;
  cfg.pin_rst = 4;
  cfg.pin_busy = -1;
  cfg.memory_width = 320;
  cfg.memory_height = 480;
  cfg.panel_width = 320;
  cfg.panel_height = 480;
  cfg.offset_x = 0;
  cfg.offset_y = 0;
  cfg.offset_rotation = 0;
  cfg.dummy_read_pixel = 8;
  cfg.dummy_read_bits = 1;
  cfg.readable = true;
  cfg.invert = true;
  cfg.rgb_order = false;
  cfg.dlen_16bit = false;
  cfg.bus_shared = true;

  _panel_instance.config(cfg);
}

{
  auto cfg = _light_instance.config();
  cfg.pin_bl = 45;
  cfg.invert = false;
  cfg.freq = 44100;
  cfg.pwm_channel = 7;

  _light_instance.config(cfg);
  _panel_instance.setLight(&_light_instance);
}

{
  auto cfg = _touch_instance.config();
  cfg.i2c_port = 1;
  cfg.i2c_addr = 0x38;
  cfg.pin_sda = 6;
  cfg.pin_scl = 5;
  cfg.freq = 400000;
  cfg.x_min = 0;
  cfg.x_max = 320;
  cfg.y_min = 0;
  cfg.y_max = 480;

  _touch_instance.config(cfg);
  _panel_instance.setTouch(&_touch_instance);
}

setPanel(&_panel_instance);

}
};
static LGFX tft;

/Change to your screen resolution/
static const uint32_t screenWidth = 480;
static const uint32_t screenHeight = 320;
static lv_disp_draw_buf_t draw_buf;
static lv_color_t buf[screenWidth * 100];

/* Display flushing */
void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
{
uint32_t w = (area->x2 - area->x1 + 1);
uint32_t h = (area->y2 - area->y1 + 1);

tft.startWrite();
tft.setAddrWindow(area->x1, area->y1, w, h);
tft.writePixels((lgfx::rgb565_t *)&color_p->full, w * h);
tft.endWrite();

lv_disp_flush_ready(disp);
}

/Read the touchpad/
void my_touchpad_read(lv_indev_drv_t *indev_driver, lv_indev_data_t *data)
{

uint16_t x, y;
if (tft.getTouch(&x, &y))
{
data->state = LV_INDEV_STATE_PR;
data->point.x = x;
data->point.y = y;
}
else
{
data->state = LV_INDEV_STATE_REL;
}
}
void listDir(fs::FS &fs, const char *dirname, uint8_t levels)
{
Serial.printf("Listing directory: %s\n", dirname);

File root = fs.open(dirname);
if (!root) {
    Serial.println("Failed to open directory");
    return;
}
if (!root.isDirectory()) {
    Serial.println("Not a directory");
    return;
}

File file = root.openNextFile();
while (file) {
    if (file.isDirectory()) {
        Serial.print("  DIR : ");
        Serial.println(file.name());
        if (levels) {
            listDir(fs, file.path(), levels - 1);
        }
    } else {
        Serial.print("  FILE: ");
        Serial.print(file.name());
        Serial.print("  SIZE: ");
        Serial.println(file.size());
    }
    file = root.openNextFile();
}

}

void initDisplay()
{
tft.begin();
tft.setRotation(1);
tft.setBrightness(screen_brightness);
tft.fillScreen(TFT_BLACK);
tft.setBrightness(255);
}
void setup()
{
Serial.begin(115200);
initDisplay();
SDSetup(); // Setup SD card
lv_init();
lv_disp_draw_buf_init(&draw_buf, buf, NULL, screenWidth * 100);

/Initialize the display/
static lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv);
/Change the following line to your display resolution/
disp_drv.hor_res = screenWidth;
disp_drv.ver_res = screenHeight;
disp_drv.flush_cb = my_disp_flush;
disp_drv.draw_buf = &draw_buf;
lv_disp_drv_register(&disp_drv);

// Call lvgl initialization
beginLvglHelper();
auto fs = SD_FS(SD);
listDir(fs, "/", 0);

lv_obj_t *img =  lv_img_create(lv_scr_act());
lv_obj_center(img);

lv_timer_create([](lv_timer_t *t) {
    static int i = 0;
    auto fs = SD_FS(SD);

    if (!fs.exists(String("/") + filename[i])) {
        Serial.println("File not find image..."); return ;
    }

    // String path = LV_FS_POSIX_LETTER + String(":/image_") + filename[i];
    String path = lvgl_helper_get_fs_filename(String("/") + filename[i]);

    Serial.print("open : ");
    Serial.println(path);

    lv_img_set_src((lv_obj_t *)t->user_data, path.c_str());
    i++;
    i %= sizeof(filename) / sizeof(filename[0]);
}, 5000, img);

}
void loop()
{
lv_timer_handler();
delay(2);
}

@SubCoderHUN SubCoderHUN added the help wanted Extra attention is needed label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants