예제 #1
0
static int8_t _mwii_read_sensors(fc_board_t self, struct fc_data *data){
	(void)(self); 
	data->flags = 0xffff; // all
	mpu6050_readRawAcc(&_brd.mpu, 
		&data->raw_acc.x, 
		&data->raw_acc.y, 
		&data->raw_acc.z); 
	mpu6050_readRawGyr(&_brd.mpu, 
		&data->raw_gyr.x, 
		&data->raw_gyr.y, 
		&data->raw_gyr.z
	); 
	mpu6050_convertAcc(&_brd.mpu, 
		data->raw_acc.x, 
		data->raw_acc.y, 
		data->raw_acc.z, 
		&data->acc_g.x, 
		&data->acc_g.y, 
		&data->acc_g.z
	); 
	mpu6050_convertAcc(&_brd.mpu, 
		data->raw_gyr.x, 
		data->raw_gyr.y, 
		data->raw_gyr.z, 
		&data->gyr_deg.x,
		&data->gyr_deg.y,
		&data->gyr_deg.z
	); 
	hmc5883l_readRawMag(&_brd.hmc, 
		&data->raw_mag.x, 
		&data->raw_mag.y, 
		&data->raw_mag.z
	); 
	hmc5883l_convertMag(&_brd.hmc, 
		data->raw_mag.x, 
		data->raw_mag.y, 
		data->raw_mag.z, 
		&data->mag.x, 
		&data->mag.y, 
		&data->mag.z
	); 
	
	int16_t sonar = hcsr04_read_distance_in_cm(&brd->hcsr); 
	data->atmospheric_altitude = bmp085_read_altitude(&brd->bmp); 
	data->sonar_altitude = (sonar > 0)?((float)sonar / 100.0):-1; 
	data->temperature = bmp085_read_temperature(&brd->bmp); 
	data->pressure = bmp085_read_pressure(&brd->bmp); 
	data->vbat = (adc0_read_cached(2) / 65535.0);
	return 0; 
}
예제 #2
0
//**********************
// READING SENSOR DATA
//**********************
/// reads last measured acceleration in G
void mwii_read_acceleration_g(float *ax, float *ay, float *az){
	int16_t x, y, z; 
	mpu6050_readRawAcc(&_brd.mpu, &x, &y, &z); 
	mpu6050_convertAcc(&_brd.mpu, x, y, z, ax, ay, az); 
}