-
-
Save lovyan03/7a5a9b66130e81e1cb84776b5346e0fe to your computer and use it in GitHub Desktop.
LovyanGFX + ESP-IDFでSDカードをマウントしてdrawJpgFileを使うサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// long filename を扱う場合は menuconfig で Component config -> FAT Filesystem support -> Long filename support を有効にすること | |
#include <esp_vfs_fat.h> | |
#define LGFX_AUTODETECT | |
#include <LovyanGFX.hpp> | |
LGFX lcd; | |
void setup(void) | |
{ | |
lcd.init(); | |
sdspi_device_config_t device_config = SDSPI_DEVICE_CONFIG_DEFAULT(); | |
device_config.host_id = VSPI_HOST; | |
device_config.gpio_cs = (gpio_num_t)4; // SDカードのCSピンの番号を指定 | |
sdmmc_host_t host = SDSPI_HOST_DEFAULT(); | |
host.slot = device_config.host_id; | |
esp_vfs_fat_mount_config_t mount_config = { | |
.format_if_mount_failed = false, | |
.max_files = 5, | |
.allocation_unit_size = 16 * 1024 | |
}; | |
sdmmc_card_t* card; | |
esp_err_t res = esp_vfs_fat_sdspi_mount("/sdcard", &host, &device_config, &mount_config, &card); | |
lcd.drawJpgFile("/sdcard/m5stack.jpg", 0, 0); | |
} | |
void loop(void) | |
{ | |
taskYIELD(); | |
} | |
#if !defined ( ARDUINO ) | |
extern "C" { | |
void loopTask(void*) | |
{ | |
setup(); | |
for (;;) { | |
loop(); | |
} | |
vTaskDelete(NULL); | |
} | |
void app_main() | |
{ | |
xTaskCreatePinnedToCore(loopTask, "loopTask", 8192, NULL, 1, NULL, 1); | |
} | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment