#include "U8glib.h"
#include "SdFat.h"
#define SPI_SPEED SD_SCK_MHZ(4)
#define CS_PIN 10
SdFat sd;
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0 | U8G_I2C_OPT_NO_ACK | U8G_I2C_OPT_FAST); // Fast I2C / TWI
int progress = 0;
void setup() {
Serial.begin(115200);
if (!sd.begin(CS_PIN, SPI_SPEED)) {
if (sd.card()->errorCode()) {
Serial.println("SD initialization failed.");
} else if (sd.vol()->fatType() == 0) {
Serial.println("Can't find a valid FAT16/FAT32 partition.");
} else {
Serial.println("Can't determine error type");
}
return;
}
Serial.println("Files on card:");
Serial.println(" Size Name");
sd.ls(LS_R | LS_SIZE);
u8g.setFont(u8g_font_tpssb);
u8g.setColorIndex(1);
}
void loop() {
u8g.firstPage();
do {
u8g.drawStr(40, 50, "Loading");
u8g.drawFrame(0, 10, 128, 20);
u8g.drawBox(10, 15, progress, 10);
} while ( u8g.nextPage() );
if (progress < 108) {
progress++;
} else {
u8g.firstPage();
}
}