}
-int imu_log(void)
+
+int imu_log(uint8_t to_stdout)
{
char buf[128];
int16_t len;
imu.gx, imu.gy, imu.gz,
imu.ax, imu.ay, imu.az,
imu.mx, imu.my, imu.mz);
- if (sd_log_write(buf, len) != len) {
- printf_P(PSTR("error writing to file\n"));
- return -1;
+ if (!to_stdout && sd_log_enabled()) {
+ if (sd_log_write(buf, len) != len) {
+ printf_P(PSTR("error writing to file\n"));
+ return -1;
+ }
+ }
+ else if (to_stdout) {
+ printf_P(PSTR("%s"), buf);
}
return 0;