Rohan - COG4050 and ADXL355 Tilt sensing
Dependents: COG4050_adxl355_tilt COG4050_adxl355_tilt COG4050_adxl355_tilt_4050
Fork of ADXL355 by
Diff: ADXL355.cpp
- Revision:
- 1:e80c97768af4
- Parent:
- 0:1b8d65be0eef
--- a/ADXL355.cpp Wed Aug 15 11:51:45 2018 +0000 +++ b/ADXL355.cpp Tue Aug 21 13:25:06 2018 +0000 @@ -237,9 +237,11 @@ // Otherwise perform the 2's complement math on the value return float((~(data - 0x01)) & 0xfffff) * -1; } -ADXL355::ADXL355_calibdata_t ADXL355::convert_2p(float angle[11][2], float meas[11][2]){ +ADXL355::ADXL355_calibdata_t ADXL355::convert_2p(float angle[11][2], float meas[11][2]) +{ ADXL355_calibdata_t res; - for(int i=0; i<3; i++){ + for(int i=0; i<3; i++) + { res.S[i][i]= (angle[i][1]-angle[i][0])/(meas[i][1]-meas[i][0]); res.B[i][0]= (angle[i][0]*meas[i][1]-angle[i][1]*meas[i][0])/(meas[i][1]-meas[i][0]); }