Skip to content
Snippets Groups Projects
Commit 822184d2 authored by Leo's avatar Leo :shark:
Browse files

SD Card

parent 24e59a00
No related branches found
No related tags found
No related merge requests found
......@@ -18,3 +18,4 @@ framework = arduino
lib_deps =
arpruss/USBComposite for STM32F1@^0.99
olikraus/U8g2@^2.28.8
arduino-libraries/SD@^1.2.4
#include <Arduino.h>
#include <USBComposite.h>
#include <U8g2lib.h>
#include <USBComposite.h>
#include <SD.h>
#include <SPI.h>
File root;
File myFile;
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
......@@ -9,34 +15,52 @@
#include <Wire.h>
#endif
U8G2_SSD1306_128X64_NONAME_F_HW_I2C oled(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
USBMultiSerial<1> VirtSerial;
U8G2_SSD1306_128X64_NONAME_F_HW_I2C oled(U8G2_R0, /* reset=*/U8X8_PIN_NONE);
USBSerial VirtSerial;
void setup(void) {
VirtSerial.begin();
VirtSerial.ports[0].println("Moin");
// VirtSerial.begin(9600);
// while (!USBComposite);
oled.begin();
oled.setFont(u8g2_font_bubble_tr);
oled.firstPage();
do {
oled.setCursor(0, 25);
oled.print("Crypt");
oled.setCursor(30, 55);
oled.print("Stick");
} while (oled.nextPage());
delay(3000);
oled.setFont(u8g2_font_7x14_mf);
oled.clear();
if (!SD.begin(PA4)) {
oled.firstPage();
do {
oled.setCursor(0, 25);
oled.print("SD card init failed");
} while (oled.nextPage());
while (1)
;
}
do {
oled.setCursor(0, 25);
oled.print("SD card init done");
} while (oled.nextPage());
oled.begin();
oled.setFont(u8g2_font_bubble_tr);
oled.firstPage();
do {
oled.setCursor(0, 25);
oled.print("Crypt");
oled.setCursor(30, 55);
oled.print("Stick");
} while ( oled.nextPage() );
delay(1000);
}
root = SD.open("/");
myFile = SD.open("test.txt", FILE_READ);
void loop(void) {
if (myFile) {
while (myFile.available()) {
VirtSerial.print((char)myFile.read());
}
} else {
VirtSerial.println("error opening test.txt");
}
}
void loop(void) {}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment