From 47e8042a574e9f53eb10c96a187d056a77f07d76 Mon Sep 17 00:00:00 2001 From: Anson Biggs Date: Sat, 13 Nov 2021 11:25:44 -0700 Subject: [PATCH] cleaned write2csv --- include/LoadCells.h | 1 + include/teensy.h | 13 +++++++------ src/main.cpp | 3 +-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/LoadCells.h b/include/LoadCells.h index 2b89a93..a47bee6 100644 --- a/include/LoadCells.h +++ b/include/LoadCells.h @@ -1,5 +1,6 @@ #include +#pragma once struct LoadCells { HX711 lc0; diff --git a/include/teensy.h b/include/teensy.h index b04d15c..856dc21 100644 --- a/include/teensy.h +++ b/include/teensy.h @@ -1,3 +1,4 @@ +#include "LoadCells.h" #include "Vehicle.h" #include #include @@ -65,7 +66,7 @@ void initFile() { // File Header dataFile.println( "t,x,y,z,vx,vy,vz,ax,ay,az,yaw,pitch,roll,yawdot,pitchdot,rolldot," - "Servo1,Servo2,thrustFiring,thrust,simResponse,l0,l1,l2,l3"); + "Servo1,Servo2,thrustFiring,thrust,simResponse,lc0,lc1,lc2,lc3"); } void thrustInfo(Vehicle &State) { @@ -112,7 +113,7 @@ void processTVC(Vehicle &State, LoadCells &loadCells) { State.momentZ = 0.0; } -void write2CSV(Vehicle &State, double a, double b, double c, double d) { +void write2CSV(Vehicle &State, LoadCells &loadCells) { dataFile.print(String(State.time, 5)); dataFile.print(","); @@ -164,13 +165,13 @@ void write2CSV(Vehicle &State, double a, double b, double c, double d) { dataFile.print(String(State.stepDuration, 5)); dataFile.print(","); - dataFile.print(String(a, 5)); + dataFile.print(String(loadCells.lc0Val, 5)); dataFile.print(","); - dataFile.print(String(b, 5)); + dataFile.print(String(loadCells.lc1Val, 5)); dataFile.print(","); - dataFile.print(String(c, 5)); + dataFile.print(String(loadCells.lc2Val, 5)); dataFile.print(","); - dataFile.print(String(d, 5)); + dataFile.print(String(loadCells.lc3Val, 5)); dataFile.print("\n"); } diff --git a/src/main.cpp b/src/main.cpp index 5e9abd7..d4828fe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -121,8 +121,7 @@ void loop() { processTVC(State, loadCells); State.stepDuration = micros() - last; - write2CSV(State, loadCells.lc0Val, loadCells.lc1Val, loadCells.lc2Val, - loadCells.lc3Val); + write2CSV(State, loadCells); // Set "prev" values for next timestep PrevState = State;