Переглянути джерело

Add startMicros to LowLatencyLogger

main
Bill Greiman 8 роки тому
джерело
коміт
36d5c97e24
3 змінених файлів з 26 додано та 18 видалено
  1. +13
    -9
      LowLatencyLoggerADXL345/LowLatencyLoggerADXL345.ino
  2. +0
    -0
      LowLatencyLoggerADXL345/readme.txt
  3. +13
    -9
      SdFat/examples/LowLatencyLogger/LowLatencyLogger.ino

+ 13
- 9
LowLatencyLoggerADXL345/LowLatencyLoggerADXL345.ino Переглянути файл

@@ -17,12 +17,15 @@
#include "SdFat.h"
#include "FreeStack.h"
//------------------------------------------------------------------------------
// User data functions. Modify these functions for your data items.
#include "UserDataType.h" // Edit this include file to change data_t.

// Set useSharedSpi true for use of an SPI sensor.
const bool useSharedSpi = true;

// File start time in micros.
uint32_t startMicros;
//------------------------------------------------------------------------------
// User data functions. Modify these functions for your data items.
#include "UserDataType.h" // Edit this include file to change data_t.

const uint8_t ADXL345_CS = 9;

const uint8_t POWER_CTL = 0x2D; //Power Control Register
@@ -67,7 +70,7 @@ void acquireData(data_t* data) {

// Print a data record.
void printData(Print* pr, data_t* data) {
pr->print(data->time);
pr->print(data->time - startMicros);
for (int i = 0; i < ACCEL_DIM; i++) {
pr->write(',');
pr->print(data->accel[i]);
@@ -417,6 +420,7 @@ void logData() {
// Wait for Serial Idle.
Serial.flush();
delay(10);
bool closeFile = false;
uint32_t bn = 0;
uint32_t t0 = millis();
uint32_t t1 = t0;
@@ -426,11 +430,11 @@ void logData() {
uint32_t maxDelta = 0;
uint32_t minDelta = 99999;
uint32_t maxLatency = 0;
// Start at a multiple of interval.
uint32_t logTime = micros()/LOG_INTERVAL_USEC + 1;
logTime *= LOG_INTERVAL_USEC;
bool closeFile = false;
uint32_t logTime = micros();
// Set time for first record of file.
startMicros = logTime + LOG_INTERVAL_USEC;
while (1) {
// Time for next data record.
logTime += LOG_INTERVAL_USEC;

LowLatencyLoggerADXL345/readme.txt.txt → LowLatencyLoggerADXL345/readme.txt Переглянути файл


+ 13
- 9
SdFat/examples/LowLatencyLogger/LowLatencyLogger.ino Переглянути файл

@@ -17,12 +17,15 @@
#include "SdFat.h"
#include "FreeStack.h"
//------------------------------------------------------------------------------
// User data functions. Modify these functions for your data items.
#include "UserDataType.h" // Edit this include file to change data_t.

// Set useSharedSpi true for use of an SPI sensor.
const bool useSharedSpi = false;

// File start time in micros.
uint32_t startMicros;
//------------------------------------------------------------------------------
// User data functions. Modify these functions for your data items.
#include "UserDataType.h" // Edit this include file to change data_t.

// Acquire a data record.
void acquireData(data_t* data) {
data->time = micros();
@@ -33,7 +36,7 @@ void acquireData(data_t* data) {

// Print a data record.
void printData(Print* pr, data_t* data) {
pr->print(data->time);
pr->print(data->time - startMicros);
for (int i = 0; i < ADC_DIM; i++) {
pr->write(',');
pr->print(data->adc[i]);
@@ -388,6 +391,7 @@ void logData() {
// Wait for Serial Idle.
Serial.flush();
delay(10);
bool closeFile = false;
uint32_t bn = 0;
uint32_t t0 = millis();
uint32_t t1 = t0;
@@ -397,11 +401,11 @@ void logData() {
uint32_t maxDelta = 0;
uint32_t minDelta = 99999;
uint32_t maxLatency = 0;
// Start at a multiple of interval.
uint32_t logTime = micros()/LOG_INTERVAL_USEC + 1;
logTime *= LOG_INTERVAL_USEC;
bool closeFile = false;
uint32_t logTime = micros();
// Set time for first record of file.
startMicros = logTime + LOG_INTERVAL_USEC;
while (1) {
// Time for next data record.
logTime += LOG_INTERVAL_USEC;

Завантаження…
Відмінити
Зберегти