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

fix sd mmc free space display #21869

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ ftp start stop ftp server: 0 = OFF, 1 = SDC, 2 = FlashFile
#define UFS_TFAT 2
#define UFS_TLFS 3

#define UFS_SDC 0
#define UFS_SDMMC 1

/*
// In tasmota.ino
#ifdef ESP8266
Expand Down Expand Up @@ -97,6 +100,8 @@ uint8_t ufs_dir;
// 0 = None, 1 = SD, 2 = ffat, 3 = littlefs
uint8_t ufs_type;
uint8_t ffs_type;
// sd type 0 = SD spi interface, 1 = MMC interface
uint8_t sd_type;

struct {
char run_file[48];
Expand Down Expand Up @@ -206,6 +211,7 @@ void UfsCheckSDCardInit(void) {
#endif // ESP32

ufs_type = UFS_TSDC;
sd_type = UFS_SDC;
dfsp = ufsp;
if (ffsp) {ufs_dir = 1;}
// make sd card the global filesystem
Expand Down Expand Up @@ -239,6 +245,7 @@ void UfsCheckSDCardInit(void) {
ufsp = &SD_MMC;

ufs_type = UFS_TSDC;
sd_type = UFS_SDMMC;
dfsp = ufsp;
if (ffsp) {ufs_dir = 1;}
// make sd card the global filesystem
Expand Down Expand Up @@ -274,11 +281,29 @@ uint32_t UfsInfo(uint32_t sel, uint32_t type) {
}
#endif // ESP8266
#ifdef ESP32
#ifdef SOC_SDMMC_HOST_SUPPORTED
if (sd_type == UFS_SDC) {
if (sel == 0) {
result = SD.totalBytes();
} else {
result = (SD.totalBytes() - SD.usedBytes());
}
} else if (sd_type == UFS_SDMMC) {
if (sel == 0) {
result = SD_MMC.totalBytes();
} else {
result = (SD_MMC.totalBytes() - SD_MMC.usedBytes());
}
} else {
result = 0;
}
#else
if (sel == 0) {
result = SD.totalBytes();
} else {
result = (SD.totalBytes() - SD.usedBytes());
}
#endif // SOC_SDMMC_HOST_SUPPORTED
#endif // ESP32
#endif // USE_SDCARD
break;
Expand Down