Added Config for Tap/Acceleration Sensor
This commit is contained in:
parent
50586f2b50
commit
2070001f4c
41
main/i2c.c
41
main/i2c.c
@ -135,11 +135,34 @@ void read_sensor_task(void *params) {
|
||||
ret = bma4_read_accel_xyz(&sens_data, &bma456_struct);
|
||||
bma4_error_codes_print_result("bma4_read_accel_xyz", ret);
|
||||
|
||||
ESP_LOGI("ACC", "X: %d, Y: %d, Z: %d", sens_data.x, sens_data.y,
|
||||
sens_data.z);
|
||||
|
||||
if (interrupt_status) {
|
||||
ESP_LOGI("INTERRUPT", "Da war der Interrupt resetting");
|
||||
interrupt_status = 0;
|
||||
ret = bma456h_read_int_status(&int_status, &bma456_struct);
|
||||
bma4_error_codes_print_result("bma456w_step_counter_output status", ret);
|
||||
|
||||
int8_t rslt;
|
||||
struct bma456h_out_state tap_out = {0};
|
||||
|
||||
rslt = bma456h_output_state(&tap_out, &bma456_struct);
|
||||
|
||||
if (BMA4_OK == rslt) {
|
||||
/* Enters only if the obtained interrupt is single-tap */
|
||||
if (tap_out.single_tap) {
|
||||
ESP_LOGI("INTERRUPT", "Single Tap interrupt occurred\n");
|
||||
}
|
||||
/* Enters only if the obtained interrupt is double-tap */
|
||||
else if (tap_out.double_tap) {
|
||||
ESP_LOGI("INTERRUPT", "Double Tap interrupt occurred\n");
|
||||
}
|
||||
/* Enters only if the obtained interrupt is triple-tap */
|
||||
else if (tap_out.triple_tap) {
|
||||
ESP_LOGI("INTERRUPT", "Triple Tap interrupt occurred\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ESP_LOGI("i2c", "X:%d, Y%d, Z%d", sens_data.x, sens_data.y, sens_data.z);
|
||||
@ -187,12 +210,26 @@ void init_bma456() {
|
||||
ret = bma456h_write_config_file(&bma456_struct);
|
||||
bma4_error_codes_print_result("bma4_write_config_file", ret);
|
||||
|
||||
struct bma4_accel_config accel_config;
|
||||
bma4_get_accel_config(&accel_config, &bma456_struct);
|
||||
accel_config.range = BMA4_ACCEL_RANGE_2G;
|
||||
ret = bma4_set_accel_config(&accel_config, &bma456_struct);
|
||||
bma4_error_codes_print_result("bma4_set_accel_config status", ret);
|
||||
|
||||
/* Enable the accelerometer */
|
||||
ret = bma4_set_accel_enable(BMA4_ENABLE, &bma456_struct);
|
||||
bma4_error_codes_print_result("bma4_set_accel_enable status", ret);
|
||||
|
||||
ret = bma456h_feature_enable((BMA456H_DOUBLE_TAP_EN), BMA4_ENABLE,
|
||||
&bma456_struct);
|
||||
struct bma456h_multitap_settings tap_settings = {0};
|
||||
ret = bma456h_tap_get_parameter(&tap_settings, &bma456_struct);
|
||||
bma4_error_codes_print_result("bma456h_tap_get_parameter status", ret);
|
||||
tap_settings.tap_sens_thres = 0;
|
||||
ret = bma456h_tap_set_parameter(&tap_settings, &bma456_struct);
|
||||
bma4_error_codes_print_result("bma456h_tap_set_parameter status", ret);
|
||||
|
||||
ret = bma456h_feature_enable(
|
||||
(BMA456H_SINGLE_TAP_EN | BMA456H_DOUBLE_TAP_EN | BMA456H_TRIPLE_TAP_EN),
|
||||
BMA4_ENABLE, &bma456_struct);
|
||||
bma4_error_codes_print_result("bma456w_feature_enable status", ret);
|
||||
|
||||
/* Setting watermark level 1, the output step resolution is 20 steps.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user