39#if !defined(USE_I2C_INTERFACE) && !defined(USE_SPI_INTERFACE)
40#define USE_I2C_INTERFACE
41#warning "No interface type is selected, use I2C interface"
44#if defined(USE_SPI_INTERFACE)
94#define USING_DATA_HELPER
96#ifdef USING_DATA_HELPER
102#define BOSCH_APP30_SHUTTLE_BHI260_AUX_BMM150FW
132#define USING_SENSOR_IRQ_METHOD
135#ifdef USING_SENSOR_IRQ_METHOD
144#ifndef USING_DATA_HELPER
147 struct bhy2_data_quaternion data;
151 bhy2_parse_quaternion(data_ptr, &data);
153 BoschSensorUtils::time_to_s_ns(_timestamp, &s, &ns, &tns);
154 Serial.print(
"SID:"); Serial.print(sensor_id);
155 Serial.print(
" T:"); Serial.print(s);
156 Serial.print(
"."); Serial.print(ns);
157 Serial.print(
" x:"); Serial.print(data.x / 16384.0f);
158 Serial.print(
" y:"); Serial.print(data.y / 16384.0f);
159 Serial.print(
" x:"); Serial.print(data.z / 16384.0f);
160 Serial.print(
" w:"); Serial.print(data.w / 16384.0f);
161 Serial.print(
" acc:"); Serial.println(((data.accuracy * 180.0f) / 16384.0f) / 3.141592653589793f);
168 float progress = (float)transferred / total * 100;
169 Serial.print(
"Upload progress: ");
170 Serial.print(progress);
176 Serial.begin(115200);
182 Serial.println(
"Initializing Sensors...");
199#ifdef USE_I2C_INTERFACE
204 Serial.print(
"Failed to initialize sensor - error code:");
205 Serial.println(
bhy.getError());
212#ifdef USE_SPI_INTERFACE
215 Serial.print(
"Failed to initialize sensor - error code:");
216 Serial.println(
bhy.getError());
223 Serial.println(
"Initializing the sensor successfully!");
226 BoschSensorInfo info =
bhy.getSensorInfo();
229 ArduinoStreamPrinter printer(Serial);
230 info.printInfo(printer);
232 info.printInfo([](
const char *format, ...) ->
int {
234 va_start(args, format);
235 int result = vprintf(format, args);
241 float sample_rate = 100.0;
242 uint32_t report_latency_ms = 0;
249#ifdef USING_DATA_HELPER
250 quaternion.enable(sample_rate, report_latency_ms);
252 bhy.configure(BoschSensorID::ROTATION_VECTOR, sample_rate, report_latency_ms);
257#ifdef USING_SENSOR_IRQ_METHOD
272#ifdef USING_SENSOR_IRQ_METHOD
282#ifdef USING_SENSOR_IRQ_METHOD
286#ifdef USING_DATA_HELPER
291#ifdef PLATFORM_HAS_PRINTF
292 Serial.printf(
"[T: %" PRIu32
".%09" PRIu32
"] QX:%+7.2f QY:%+7.2f QZ:%+7.2f QW:%+7.2f\n",
295 Serial.print(
"[T: ");
302 Serial.print(
" QY:");
304 Serial.print(
" QZ:");
306 Serial.print(
" QW:");
volatile bool isInterruptTriggered
void progress_callback(uint32_t total, uint32_t transferred, void *user_data)
bool force_update_flash_firmware
SensorQuaternion quaternion(bhy)
void parse_quaternion(uint8_t sensor_id, const uint8_t *data_ptr, uint32_t len, uint64_t *timestamp, void *user_data)
void setBootFromFlash(bool boot_from_flash)
setBootFromFlash