ben-pololu-imu

Annotated measure.h

1:e037b6ad9b71
2013-10-14 Paul Boddie Added some documentation.
paul@0 1
/*
paul@0 2
 * Ben NanoNote communication with the Pololu MinIMU-9 with the L3G4200D 3-axis
paul@0 3
 * gyroscope and LSM303DLM accelerometer/magnetometer.
paul@0 4
 *
paul@0 5
 * http://www.pololu.com/catalog/product/1265
paul@0 6
 *
paul@0 7
 * Copyright (C) 2013 Paul Boddie
paul@0 8
 *
paul@0 9
 * This program is free software; you can redistribute it and/or modify
paul@0 10
 * it under the terms of the GNU General Public License as published by
paul@0 11
 * the Free Software Foundation; either version 2 of the License, or
paul@0 12
 * (at your option) any later version.
paul@0 13
 */
paul@0 14
paul@0 15
#ifndef __MEASURE_H__
paul@0 16
#define __MEASURE_H__
paul@0 17
paul@0 18
#include "geo.h"
paul@0 19
paul@0 20
/* Function definitions. */
paul@0 21
paul@0 22
void ui_calibrate(bool using_filter, int (*print)(const char *, ...), void (*flush)());
paul@0 23
void *get_measurements(void *arg);
paul@0 24
paul@0 25
#ifdef __MEASURE_H_PRIVATE__
paul@0 26
paul@0 27
/* The raw accelerometer value of 1g. */
paul@0 28
paul@0 29
const double acceleration1g = 1000000.0 / IMU_UG_FACTOR;
paul@0 30
paul@0 31
/* The device vectors defined in the chosen coordinate system, together with
paul@0 32
   the corresponding initial view axes. */
paul@0 33
paul@0 34
const vectorf devicex0 = {{0, 0, -1}}, viewz0 = {{0, 0, 1}},
paul@0 35
              devicey0 = {{-1, 0, 0}}, viewx0 = {{1, 0, 0}},
paul@0 36
              devicez0 = {{0, -1, 0}}, viewy0 = {{0, 1, 0}};
paul@0 37
paul@0 38
/* Measurements. */
paul@0 39
paul@0 40
vectorf accelerationB[IMU_ACCEL_BUFFER_SIZE],
paul@0 41
        acceleration,
paul@0 42
        acceleration0 = {{0, 0, 0}},
paul@0 43
        rotation,
paul@0 44
        rotation0 = {{0, 0, 0}},
paul@0 45
        field,
paul@0 46
        fieldmin = {{-327.0, -355.0, -338.0}},
paul@0 47
        fieldmax = {{107.0, 150.0, 205.0}};
paul@0 48
paul@0 49
/* Timekeeping. */
paul@0 50
paul@0 51
struct timeval imu_updated, imu_magnet_updated;
paul@0 52
uint32_t imu_period = 0;
paul@0 53
paul@0 54
/* Orientation. */
paul@0 55
paul@0 56
vectorf devicex, devicey, devicez,
paul@0 57
        viewx, viewy, viewz,
paul@0 58
        accelerationD,
paul@0 59
        accelerationR = {{0, 0, -1}},
paul@0 60
        accelerationRD = {{0, 1, 0}},
paul@0 61
        fieldD = {{0, 0, 0}},
paul@0 62
        fieldD0 = {{0, 0, 0}},
paul@0 63
        field0 = {{0, 0, 0}},
paul@0 64
        fieldN = {{0, 0, 0}},
paul@0 65
        fieldE = {{0, 0, 0}};
paul@0 66
double direction, elevation, tilt,
paul@0 67
       elevationA = 0, tiltA = 0,
paul@0 68
       directionF, elevationF,
paul@0 69
       directionF0, elevationF0;
paul@0 70
paul@0 71
/* Measurement thread. */
paul@0 72
paul@0 73
pthread_t thread;
paul@0 74
pthread_mutex_t mutex;
paul@0 75
paul@0 76
#else
paul@0 77
paul@0 78
extern const double acceleration1g;
paul@0 79
extern vectorf devicex0, devicey0, devicez0,
paul@0 80
               devicex, devicey, devicez,
paul@0 81
               viewx0, viewy0, viewz0,
paul@0 82
               viewx, viewy, viewz,
paul@0 83
               accelerationB[IMU_ACCEL_BUFFER_SIZE],
paul@0 84
               acceleration,
paul@0 85
               acceleration0,
paul@0 86
               accelerationD,
paul@0 87
               accelerationR,
paul@0 88
               accelerationRD,
paul@0 89
               rotation,
paul@0 90
               rotation0,
paul@0 91
               field,
paul@0 92
               fieldmin, fieldmax,
paul@0 93
               fieldD, fieldD0, field0, fieldN, fieldE;
paul@0 94
extern struct timeval imu_updated;
paul@0 95
extern uint32_t imu_period;
paul@0 96
extern double direction, elevation, tilt,
paul@0 97
              elevationA, tiltA,
paul@0 98
              directionF, elevationF,
paul@0 99
              directionF0, elevationF0;
paul@0 100
paul@0 101
/* Measurement thread. */
paul@0 102
paul@0 103
extern pthread_t thread;
paul@0 104
extern pthread_mutex_t mutex;
paul@0 105
paul@0 106
#endif /* __MEASURE_H_PRIVATE__ */
paul@0 107
paul@0 108
#endif /* __MEASURE_H__ */