Files

69 lines
1.1 KiB
Markdown
Raw Permalink Normal View History

2019-02-27 14:11:30 +08:00
# TF card
2019-02-27 11:57:45 +08:00
## begin()
2019-02-27 14:11:30 +08:00
**説明:**
2019-02-27 11:57:45 +08:00
2019-02-27 14:11:30 +08:00
TFカード機能が使用可能になります。
2019-02-27 11:57:45 +08:00
2019-02-27 14:11:30 +08:00
**構文:**
2019-02-27 11:57:45 +08:00
2019-03-01 18:57:09 +08:00
<mark>boolean begin(uint8_t cspin);</mark>
2019-02-27 14:11:30 +08:00
| 引数 | 説明 | 型 |
| --- | --- | -- |
| cspin | chip select line (defaults SS line of SPI bus) | uint8_t |
**使用例:**
2019-02-27 11:57:45 +08:00
```arduino
#include <M5Stack.h>
2019-02-27 14:11:30 +08:00
void setup() {
SD.begin();
}
2019-02-27 11:57:45 +08:00
```
## open()
2019-02-27 14:11:30 +08:00
**説明:**
2019-02-27 11:57:45 +08:00
2019-02-27 14:11:30 +08:00
ファイルを開きます。
2019-02-27 11:57:45 +08:00
2019-02-27 14:11:30 +08:00
**構文:**
2019-02-27 11:57:45 +08:00
2019-03-01 18:57:09 +08:00
<mark>File open(const char *filename, uint8_t mode = FILE_READ);</mark>
2019-02-27 14:11:30 +08:00
| 引数 | 説明 | 型 |
| --- | --- | -- |
| filepath | path to file | const char * |
| mode | read / write / rw (optional) | uint8_t |
**使用例:**
2019-02-27 11:57:45 +08:00
```arduino
/*
2019-02-27 14:11:30 +08:00
M5にTFカードのhello.txtの中身を表示する。
2019-02-27 11:57:45 +08:00
*/
#include <M5Stack.h>
2019-02-27 14:11:30 +08:00
void setup() {
M5.begin();
if (!SD.begin()) {
M5.Lcd.println("Card failed, or not present");
while (1);
}
Serial.println("TF card initialized.");
File f = SD.open("/hello.txt", FILE_READ);
if (f) {
M5.Lcd.print(f.read());
f.close();
} else {
M5.Lcd.println("open error hello.txt");
}
2019-02-27 11:57:45 +08:00
}
2019-02-27 14:11:30 +08:00
void loop() {
2019-02-27 11:57:45 +08:00
}
```