Exemplo n.º 1
0
MagSample mag_sample_averaged(int samples) {
    int32_t field_accum[3] = { 0, 0, 0 };
    for (int s=0; s<samples; s++) {
        signal.wait();
        for (int i=0; i<3; i++)
            field_accum[i] += sample.field[i];
    }

    MagSample ret = sample;
    for (int i=0; i<3; i++)
        ret.field[i] = field_accum[i] / samples;
    return ret;
}
Exemplo n.º 2
0
MPUSample mpu_sample_averaged(int samples) {
    int32_t accel_accum[3] = { 0, 0, 0 };
    int32_t gyro_accum[3] = { 0, 0, 0 };
    for (int s=0; s<samples; s++) {
        signal.wait();
        for (int i=0; i<3; i++) {
            accel_accum[i] += sample.accel[i];
            gyro_accum[i] += sample.gyro[i];
        }
    }

    MPUSample ret = sample;
    for (int i=0; i<3; i++) {
        sample.accel[i] = accel_accum[i] / samples;
        sample.gyro[i] = gyro_accum[i] / samples;
    }
    return ret;
}
Exemplo n.º 3
0
MagSample mag_sample(bool block) {
    KernelCriticalSection crit;
    if (block)
        signal.wait();
    return sample;
}
Exemplo n.º 4
0
AltSample alt_sample(bool wait) {
    if (wait)
        signal.wait();
    return sample;
}