Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Inkplate.h" // Include Inkplate library
- Inkplate display(INKPLATE_3BIT); // Create an Inkplate object in 3-bit mode
- // No need to declare SdFile or SdFat objects separately; we'll use the one provided by Inkplate
- // SdFile file; // Not needed in this context
- void setup()
- {
- display.begin(); // Initialize Inkplate library
- display.clearDisplay(); // Clear display buffer
- display.setTextColor(BLACK); // Set text color to black
- display.setTextSize(3); // Set font size to 3
- // Initialize the SD card
- if (!display.sdCardInit()) {
- display.println("SD Card initialization failed!");
- display.display();
- return;
- }
- display.println("SD Card OK! Reading folder...");
- display.display();
- // Example variables (replace these with your actual variables)
- const char* nr = "123"; // Replace with: const char* nr = docP["nr"];
- const char* v = "voice1"; // Replace with: const char* v = voice["voice"];
- // Construct the path using the variables
- char path[256];
- snprintf(path, sizeof(path), "/%s/%s", nr, v);
- // Check if the directory exists
- if (sd.exists(path)) {
- display.println("Directory exists.");
- display.display();
- } else {
- display.println("Directory does not exist.");
- display.display();
- // Attempt to create the directory (including parent directories)
- if (sd.mkdir(path, true)) {
- display.println("Directories created successfully.");
- display.display();
- } else {
- display.println("Failed to create directories.");
- display.display();
- }
- }
- // Turn off the SD card to save power (optional)
- display.sdCardSleep();
- }
- void loop()
- {
- // Nothing to do here
- }
Advertisement
Add Comment
Please, Sign In to add comment