19 lines
405 B
C++
19 lines
405 B
C++
#include "sdcard.hpp"
|
|
#include <cstdio>
|
|
|
|
bool SDCardLogger::init() {
|
|
return (f_mount(&fs, "", 1) == FR_OK);
|
|
}
|
|
|
|
bool SDCardLogger::write(const std::string &line) {
|
|
if (f_open(&file, "co2_log.txt", FA_OPEN_APPEND | FA_WRITE) != FR_OK)
|
|
return false;
|
|
|
|
UINT bw;
|
|
f_write(&file, line.c_str(), line.size(), &bw);
|
|
f_write(&file, "\r\n", 2, &bw);
|
|
f_close(&file);
|
|
|
|
return true;
|
|
}
|