Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added CS pin parameter to the constructor and changed the SD card flu…

…sh interval to 512 bytes since the buffer for the SD library is 512 bytes
  • Loading branch information...
commit 2f8f2fd66688745f3e1e2169e3cda39940a4936d 1 parent 53a20b0
@infomaniac50 authored
Showing with 14 additions and 15 deletions.
  1. +13 −15 Logger.cpp
  2. +1 −0  Logger.h
View
28 Logger.cpp
@@ -7,11 +7,9 @@
#include "Logger.h"
#include <LoggerSD.h>
-#define CS 4
-
-
-Logger::Logger(log_outputs output, data_formats format, boolean add_line_break)
+Logger::Logger(log_outputs output, data_formats format, boolean add_line_break, uint chip_select)
{
+ _chip_select = chip_select;
_output = output;
_format = format;
_add_line_break = add_line_break;
@@ -44,7 +42,7 @@ int Logger::initSD()
pinMode(10, OUTPUT);
#endif
- if (!SD.begin(CS)) {
+ if (!SD.begin(_chip_select)) {
return 1;
}
@@ -160,19 +158,19 @@ void Logger::logData(byte data)
checkAddLineBreak();
- if (_output == SERIAL_OUTPUT)
- {
- Serial.flush();
- }
-
- if (_output == SD_OUTPUT)
+ sync_counter++;
+ if (sync_counter >= 512)
{
- sync_counter++;
- if (sync_counter >= 2048)
+ if (_output == SD_OUTPUT)
{
- _file.flush();
- sync_counter = 0;
+ _file.flush();
}
+
+ if (_output == SERIAL_OUTPUT)
+ {
+ Serial.flush();
+ }
+ sync_counter = 0;
}
}
View
1  Logger.h
@@ -48,5 +48,6 @@ class Logger
log_outputs _output;
data_formats _format;
boolean _add_line_break;
+ uint _chip_select;
};
#endif
Please sign in to comment.
Something went wrong with that request. Please try again.