#include <Wire.h>
#include "SdFat.h"
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define SPI_SPEED SD_SCK_MHZ(4)
#define CS_PIN 4
SdFat sd;
Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void bootscreen(int,int);
const int button1 = 3,
button2 = 5,
button3 = 6;
class modes{
private:
float grades[21];
void webAssign (int pause){
}
public:
};
void setup() {
// put your setup code here, to run once:
if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
while (true);
}
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);
bootscreen(50,6);
Serial.begin(9600);
pinMode(button1, INPUT);
pinMode(button2, INPUT);
pinMode(button3, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int button1State = digitalRead(button1);
int button2State = digitalRead(button2);
int button3State = digitalRead(button3);
Serial.print("Button 1: ");
Serial.print(button1State);
Serial.print(" ");
Serial.print("Button 2: ");
Serial.print(button2State);
Serial.print(" ");
Serial.print("Button 3: ");
Serial.print(button3State);
Serial.println(" ");
}
void bootscreen(int x, int size){
delay(2000); // wait for initializing
oled.clearDisplay(); // clear display
oled.setTextSize(3); // text size
oled.setTextColor(WHITE); // text color
oled.setCursor(0, 10); // position to display
oled.println("Hello,");
oled.println("Booting"); // text to display
oled.display(); // show on OLED
delay(1000);
oled.clearDisplay();
oled.setTextSize(5);
for(int i = 0; i < 5; i++){
oled.setCursor(0, 0);
for(int i = 0; i < 4; i++){
oled.print(".");
oled.display();
delay(x);
}
delay(10);
oled.clearDisplay();
}
}