1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/measure.h Mon Oct 14 13:02:19 2013 +0000
1.3 @@ -0,0 +1,108 @@
1.4 +/*
1.5 + * Ben NanoNote communication with the Pololu MinIMU-9 with the L3G4200D 3-axis
1.6 + * gyroscope and LSM303DLM accelerometer/magnetometer.
1.7 + *
1.8 + * http://www.pololu.com/catalog/product/1265
1.9 + *
1.10 + * Copyright (C) 2013 Paul Boddie
1.11 + *
1.12 + * This program is free software; you can redistribute it and/or modify
1.13 + * it under the terms of the GNU General Public License as published by
1.14 + * the Free Software Foundation; either version 2 of the License, or
1.15 + * (at your option) any later version.
1.16 + */
1.17 +
1.18 +#ifndef __MEASURE_H__
1.19 +#define __MEASURE_H__
1.20 +
1.21 +#include "geo.h"
1.22 +
1.23 +/* Function definitions. */
1.24 +
1.25 +void ui_calibrate(bool using_filter, int (*print)(const char *, ...), void (*flush)());
1.26 +void *get_measurements(void *arg);
1.27 +
1.28 +#ifdef __MEASURE_H_PRIVATE__
1.29 +
1.30 +/* The raw accelerometer value of 1g. */
1.31 +
1.32 +const double acceleration1g = 1000000.0 / IMU_UG_FACTOR;
1.33 +
1.34 +/* The device vectors defined in the chosen coordinate system, together with
1.35 + the corresponding initial view axes. */
1.36 +
1.37 +const vectorf devicex0 = {{0, 0, -1}}, viewz0 = {{0, 0, 1}},
1.38 + devicey0 = {{-1, 0, 0}}, viewx0 = {{1, 0, 0}},
1.39 + devicez0 = {{0, -1, 0}}, viewy0 = {{0, 1, 0}};
1.40 +
1.41 +/* Measurements. */
1.42 +
1.43 +vectorf accelerationB[IMU_ACCEL_BUFFER_SIZE],
1.44 + acceleration,
1.45 + acceleration0 = {{0, 0, 0}},
1.46 + rotation,
1.47 + rotation0 = {{0, 0, 0}},
1.48 + field,
1.49 + fieldmin = {{-327.0, -355.0, -338.0}},
1.50 + fieldmax = {{107.0, 150.0, 205.0}};
1.51 +
1.52 +/* Timekeeping. */
1.53 +
1.54 +struct timeval imu_updated, imu_magnet_updated;
1.55 +uint32_t imu_period = 0;
1.56 +
1.57 +/* Orientation. */
1.58 +
1.59 +vectorf devicex, devicey, devicez,
1.60 + viewx, viewy, viewz,
1.61 + accelerationD,
1.62 + accelerationR = {{0, 0, -1}},
1.63 + accelerationRD = {{0, 1, 0}},
1.64 + fieldD = {{0, 0, 0}},
1.65 + fieldD0 = {{0, 0, 0}},
1.66 + field0 = {{0, 0, 0}},
1.67 + fieldN = {{0, 0, 0}},
1.68 + fieldE = {{0, 0, 0}};
1.69 +double direction, elevation, tilt,
1.70 + elevationA = 0, tiltA = 0,
1.71 + directionF, elevationF,
1.72 + directionF0, elevationF0;
1.73 +
1.74 +/* Measurement thread. */
1.75 +
1.76 +pthread_t thread;
1.77 +pthread_mutex_t mutex;
1.78 +
1.79 +#else
1.80 +
1.81 +extern const double acceleration1g;
1.82 +extern vectorf devicex0, devicey0, devicez0,
1.83 + devicex, devicey, devicez,
1.84 + viewx0, viewy0, viewz0,
1.85 + viewx, viewy, viewz,
1.86 + accelerationB[IMU_ACCEL_BUFFER_SIZE],
1.87 + acceleration,
1.88 + acceleration0,
1.89 + accelerationD,
1.90 + accelerationR,
1.91 + accelerationRD,
1.92 + rotation,
1.93 + rotation0,
1.94 + field,
1.95 + fieldmin, fieldmax,
1.96 + fieldD, fieldD0, field0, fieldN, fieldE;
1.97 +extern struct timeval imu_updated;
1.98 +extern uint32_t imu_period;
1.99 +extern double direction, elevation, tilt,
1.100 + elevationA, tiltA,
1.101 + directionF, elevationF,
1.102 + directionF0, elevationF0;
1.103 +
1.104 +/* Measurement thread. */
1.105 +
1.106 +extern pthread_t thread;
1.107 +extern pthread_mutex_t mutex;
1.108 +
1.109 +#endif /* __MEASURE_H_PRIVATE__ */
1.110 +
1.111 +#endif /* __MEASURE_H__ */