MMC56x3 offset+mG
This commit is contained in:
parent
65da56d15a
commit
92d36acb47
@ -68,3 +68,25 @@ esp_err_t MMC56x3_reset(){
|
||||
ESP_ERROR_CHECK(i2c_write_reg(IC0, &set, 1));
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t MMC56x3_get_bridge_offset(int32_t* x, int32_t* y, int32_t* z){
|
||||
MMC56x3_set();
|
||||
int32_t vbx, vby, vbz;
|
||||
MMC56x3_get_mag_field(&vbx, &vby, &vbz);
|
||||
*x=vbx;
|
||||
*y=vby;
|
||||
*z=vbz;
|
||||
MMC56x3_reset();
|
||||
MMC56x3_get_mag_field(&vbx, &vby, &vbz);
|
||||
*x=(*x+vbx)/2;
|
||||
*y=(*y+vby)/2;
|
||||
*z=(*z+vbz)/2;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t MMC56x3_to_mG(int32_t x, int32_t y, int32_t z, float* rx, float* ry, float* rz){
|
||||
*rx = x*0.0625;
|
||||
*ry = y*0.0625;
|
||||
*rz = z*0.0625;
|
||||
return ESP_OK;
|
||||
}
|
@ -8,3 +8,7 @@ esp_err_t MMC56x3_get_mag_field(int32_t* x, int32_t* y, int32_t* z);
|
||||
|
||||
esp_err_t MMC56x3_set();
|
||||
esp_err_t MMC56x3_reset();
|
||||
|
||||
esp_err_t MMC56x3_get_bridge_offset(int32_t* x, int32_t* y, int32_t* z);
|
||||
|
||||
esp_err_t MMC56x3_to_mG(int32_t x, int32_t y, int32_t z, float* rx, float* ry, float* rz);
|
@ -68,8 +68,12 @@ void app_main(void){
|
||||
MMC56x3_get_product_ID(&id);
|
||||
uint8_t temp;
|
||||
MMC56x3_get_temperature(&temp);
|
||||
int32_t offx, offy, offz;
|
||||
MMC56x3_get_bridge_offset(&offx, &offy, &offz);
|
||||
MMC56x3_set();
|
||||
ESP_LOGI("MAIN", "MMC5603 product id %d", id);
|
||||
ESP_LOGI("MAIN", "MMC measured temp is %d", temp);
|
||||
ESP_LOGI("MAIN", "MMC bridge offset; x %ld, y %ld, z %ld", offx, offy, offz);
|
||||
|
||||
init_scd4x();
|
||||
scd4x_power_down();
|
||||
@ -89,9 +93,12 @@ void app_main(void){
|
||||
}
|
||||
|
||||
while(1){
|
||||
/*int32_t x,y,z;
|
||||
int32_t x,y,z;
|
||||
MMC56x3_get_mag_field(&x, &y, &z);
|
||||
ESP_LOGI("MAIN", "BField x %ld, y %ld, z %ld", x, y, z);*/
|
||||
float bx, by, bz;
|
||||
MMC56x3_to_mG(x, y, z, &bx, &by, &bz);
|
||||
ESP_LOGI("MAIN", "BField x %ld, y %ld, z %ld", x, y, z);
|
||||
ESP_LOGI("MAIN", "BField x %f mG, y %f mG, z %f mG", bx, by, bz);
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user