36#ifdef ARDUINO_ARCH_ESP32
80#define USING_DATA_HELPER
82#ifdef USING_DATA_HELPER
83SensorOrientation orientation1(bhy1);
84SensorOrientation orientation2(bhy2);
88#define BOSCH_APP30_SHUTTLE_BHI260_FW
118bool isInterruptTriggered1 =
false;
119bool isInterruptTriggered2 =
false;
123 isInterruptTriggered1 =
true;
128 isInterruptTriggered2 =
true;
136 sprintf( report,
"\r\n ________________ " \
143 "\r\n |________________| \r\n" );
147 sprintf( report,
"\r\n ________________ " \
154 "\r\n |________________| \r\n" );
157 sprintf( report,
"\r\n ________________ " \
164 "\r\n |________________| \r\n" );
167 sprintf( report,
"\r\n ________________ " \
174 "\r\n |________________| \r\n" );
177 sprintf( report,
"None of the 3D orientation axes is set in BHI260 - accelerometer.\r\n" );
181 Serial.println(direction);
182 Serial.println(report);
185#ifndef USING_DATA_HELPER
186void orientation_process_callback(uint8_t sensor_id,
const uint8_t *data_ptr, uint32_t len, uint64_t *
timestamp,
void *user_data)
188 uint8_t direction = *data_ptr;
190 Serial.println((
const char *)user_data);
199 float progress = (float)transferred / total * 100;
200 Serial.print(
"Upload progress: ");
201 Serial.print(progress);
207 TwoWire &wire,
void(*interrupts)(),
217 Serial.println(
"Initializing Sensors...");
232 sensor.setBootFromFlash(bosch_firmware_type);
237 if (!
sensor.
begin(wire, BHI260AP_SLAVE_ADDRESS_L, sda, scl)) {
238 Serial.print(
"Failed to initialize sensor - error code:");
239 Serial.println(
sensor.getError());
245 Serial.println(
"Initializing the sensor successfully!");
251 ArduinoStreamPrinter printer(Serial);
252 info.printInfo(printer);
254 info.printInfo([](
const char *format, ...) ->
int {
256 va_start(args, format);
257 int result = vprintf(format, args);
264 float sample_rate = 1;
265 uint32_t report_latency_ms = 0;
267#ifdef USING_DATA_HELPER
268 orientation.enable(sample_rate, report_latency_ms);
271 sensor.configure(BoschSensorID::DEVICE_ORIENTATION, sample_rate, report_latency_ms);
273 sensor.onResultEvent(BoschSensorID::DEVICE_ORIENTATION, orientation_process_callback, user_data);
276 pinMode(irq, INPUT_PULLUP);
278 attachInterrupt(irq, interrupts, RISING);
283 Serial.begin(115200);
285 const char *sensor1_user_data =
"Sensor1";
286 const char *sensor2_user_data =
"Sensor2";
288 initSensor(bhy1, BHI260_RST1, BHI260_SDA1, BHI260_SCL1, BHI260_IRQ1, Wire, dataReady1_ISR, (
void *)sensor1_user_data
293 initSensor(bhy2, BHI260_RST2, BHI260_SDA2, BHI260_SCL2, BHI260_IRQ2, Wire1, dataReady2_ISR, (
void *)sensor2_user_data
299 Serial.println(
"All sensor init done!");
306 if (isInterruptTriggered1) {
307 isInterruptTriggered1 =
false;
308 Serial.println(
"isInterruptTriggered1:");
312 if (isInterruptTriggered2) {
313 isInterruptTriggered2 =
false;
314 Serial.println(
"isInterruptTriggered2:");
318#ifdef USING_DATA_HELPER
319 if (orientation1.hasUpdated()) {
323 if (orientation2.hasUpdated()) {
335 Serial.begin(115200);
340 Serial.println(
"The example only support your esp32 platform"); delay(1000);
#define USING_DATA_HELPER
void progress_callback(uint32_t total, uint32_t transferred, void *user_data)
bool force_update_flash_firmware
SensorOrientation orientation(bhy)
void print_orientation(uint8_t direction)
bool begin(CommInterface interface, SensorCommCustom::CustomCallback callback, SensorCommCustomHal::CustomHalCallback hal_callback, uint8_t addr=0)
Initialize the sensor using custom callback interface.
SensorInfo getSensorInfo() const
Get sensor information.