本文整理汇总了C++中SdFile::flush方法的典型用法代码示例。如果您正苦于以下问题:C++ SdFile::flush方法的具体用法?C++ SdFile::flush怎么用?C++ SdFile::flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SdFile
的用法示例。
在下文中一共展示了SdFile::flush方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sync
void sync(boolean force) {
// TODO: Test if file is open first?
//don't sync too often - requires 2048 bytes of I/O to SD card
if (!force && (millis() - syncTime) < SYNC_INTERVAL) {
return;
}
syncTime = millis();
#ifdef SDCARD
file.flush();
#endif
}
示例2: open
bool open(char* fileName) {
// Create LDxxxx.CSV for the lowest value of x.
#ifdef SDCARD
uint16_t i = 0;
do {
fileName[2] = (i/1000) % 10 + '0';
fileName[3] = (i/100) % 10 + '0';
fileName[4] = (i/10) % 10 + '0';
fileName[5] = i % 10 + '0';
i++;
}
while(sd.exists(fileName));
if(!file.open(fileName, O_CREAT | O_WRITE | O_EXCL)) {
// error_P("file open");
return false;
}
file.clearWriteError();
// write data header
file.print("time (s)");
#endif
Serial.print("v");
Serial.println(FIRMWARE_VERSION);
Serial.print("File: ");
Serial.println(fileName);
// write data header
Serial.print("time (s)");
/* We are no longer using the junction temperature in our data output.
// write data header
file.print("time (s), ambient");
Serial.print("time (s), ambient");
switch(temperatureUnit) {
case TEMPERATURE_UNITS_C:
file.print(" (C)");
Serial.print(" (C)");
break;
case TEMPERATURE_UNITS_F:
file.print(" (F)");
Serial.print(" (F)");
break;
case TEMPERATURE_UNITS_K:
file.print(" (K)");
Serial.print(" (K)");
break;
}*/
for (uint8_t i = 0; i < SENSOR_COUNT; i++) {
#ifdef SDCARD
file.print(", temp_");
file.print(i, DEC);
#endif
Serial.print(", temp_");
Serial.print(i, DEC);
switch(temperatureUnit) {
case TEMPERATURE_UNITS_C:
#ifdef SDCARD
file.print(" (C)");
#endif
Serial.print(" (C)");
break;
case TEMPERATURE_UNITS_F:
#ifdef SDCARD
file.print(" (F)");
#endif
Serial.print(" (F)");
break;
case TEMPERATURE_UNITS_K:
#ifdef SDCARD
file.print(" (K)");
#endif
Serial.print(" (K)");
break;
}
}
#ifdef SDCARD
file.println();
file.flush();
#endif
Serial.println();
#ifdef SDCARD
return (file.getWriteError() == false);
#else
return true;
#endif
}