SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
bhi260ap_klio_self_learning.ino File Reference

@license MIT License More...

#include <Wire.h>
#include <SPI.h>
#include <Arduino.h>
#include <ImuDrv.hpp>
#include <BoschFirmware.h>
Include dependency graph for bhi260ap_klio_self_learning.ino:

Go to the source code of this file.

Macros

#define USE_I2C_INTERFACE
 
#define BHI260_SDA   2
 
#define BHI260_SCL   3
 
#define BHI260_IRQ   8
 
#define BHI260_RST   -1
 
#define BOSCH_BHI260_KLIO
 
#define USING_SENSOR_IRQ_METHOD
 

Functions

void dataReadyISR ()
 
void progress_callback (uint32_t total, uint32_t transferred, void *user_data)
 
void recognition_event_callback (uint8_t pattern_id, float count, void *user_data)
 Callback function for handling KLIO sensor recognition events.
 
void learning_event_callback (SensorBHI260AP_Klio::LearningChangeReason reason, uint32_t progress, int learn_index, void *user_data)
 Callback function for KLIO sensor learning events.
 
void setup ()
 
void loop ()
 

Variables

SensorBHI260AP bhy
 
SensorBHI260AP_Klio klio (bhy)
 
bool force_update_flash_firmware = true
 
volatile bool isInterruptTriggered = false
 

Detailed Description

@license MIT License

Copyright (c) 2025 lewis he

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Author
Lewis He (lewis.nosp@m.he@o.nosp@m.utloo.nosp@m.k.co.nosp@m.m)
Date
2025-02-02
Note
Changed from Boschsensortec API https://github.com/boschsensortec/BHY2_SensorAPI

Definition in file bhi260ap_klio_self_learning.ino.

Macro Definition Documentation

◆ BHI260_IRQ

#define BHI260_IRQ   8

Definition at line 78 of file bhi260ap_klio_self_learning.ino.

◆ BHI260_RST

#define BHI260_RST   -1

Definition at line 83 of file bhi260ap_klio_self_learning.ino.

◆ BHI260_SCL

#define BHI260_SCL   3

Definition at line 73 of file bhi260ap_klio_self_learning.ino.

◆ BHI260_SDA

#define BHI260_SDA   2

Definition at line 69 of file bhi260ap_klio_self_learning.ino.

◆ BOSCH_BHI260_KLIO

#define BOSCH_BHI260_KLIO

Definition at line 90 of file bhi260ap_klio_self_learning.ino.

◆ USE_I2C_INTERFACE

#define USE_I2C_INTERFACE

Definition at line 40 of file bhi260ap_klio_self_learning.ino.

◆ USING_SENSOR_IRQ_METHOD

#define USING_SENSOR_IRQ_METHOD

Definition at line 104 of file bhi260ap_klio_self_learning.ino.

Function Documentation

◆ dataReadyISR()

void dataReadyISR ( )

Definition at line 110 of file bhi260ap_klio_self_learning.ino.

References isInterruptTriggered.

Referenced by setup().

◆ learning_event_callback()

void learning_event_callback ( SensorBHI260AP_Klio::LearningChangeReason  reason,
uint32_t  progress,
int  learn_index,
void *  user_data 
)

Callback function for KLIO sensor learning events.

This function is invoked whenever there is a change in the learning process of the KLIO sensor. It handles different learning - related events, logs information about the learning progress, and takes actions based on the learning results.

Parameters
reasonThe reason for the learning change. It is an enumeration value from the SensorBHI260AP_Klio::LearningChangeReason type, indicating why the learning state has changed.
progressThe current progress of the learning process, represented as an unsigned 32 - bit integer. This value typically ranges from 0 to 100, indicating the percentage of the learning completion.
learn_indexThe index of the learned pattern. If the learning is invalid, it will be set to SensorBHI260AP_Klio::INVALID_LEARNING_INDEX. Otherwise, it represents the index of the successfully learned pattern.
user_dataA pointer to user - defined data. It can be used to pass additional context information from the calling code to this callback function. In this implementation, it may not be used actively.

Definition at line 169 of file bhi260ap_klio_self_learning.ino.

References SensorBHI260AP_Klio::errorToString(), SensorBHI260AP_Klio::getLearnPattern(), i, SensorBHI260AP_Klio::INVALID_LEARNING_INDEX, klio, SensorBHI260AP_Klio::recognition(), and SensorBHI260AP_Klio::writePattern().

Referenced by setup().

◆ loop()

void loop ( )

Definition at line 359 of file bhi260ap_klio_self_learning.ino.

References bhy, and isInterruptTriggered.

◆ progress_callback()

void progress_callback ( uint32_t  total,
uint32_t  transferred,
void *  user_data 
)

Definition at line 117 of file bhi260ap_klio_self_learning.ino.

◆ recognition_event_callback()

void recognition_event_callback ( uint8_t  pattern_id,
float  count,
void *  user_data 
)

Callback function for handling KLIO sensor recognition events.

This function is invoked when the KLIO sensor successfully recognizes a specific pattern. Its main purpose is to print information about the recognized pattern, including the pattern ID and the recognition count, to the serial monitor. This allows developers to monitor the recognition process effectively.

Parameters
pattern_idThe unique identifier of the recognized pattern. Each predefined or learned pattern in the system has a distinct ID, and this parameter indicates which specific pattern has been recognized.
countA floating-point value representing the recognition count. This could be the number of times the pattern has been recognized, a confidence level associated with the recognition, or some other metric depending on the implementation of the recognition algorithm.
user_dataA pointer to user-defined data. It can be used to pass additional context or information from the calling code to this callback function. In this implementation, it is not used, but it is included to maintain compatibility with the callback function signature.

Definition at line 144 of file bhi260ap_klio_self_learning.ino.

Referenced by setup().

◆ setup()

Variable Documentation

◆ bhy

Definition at line 86 of file bhi260ap_klio_self_learning.ino.

Referenced by loop(), and setup().

◆ force_update_flash_firmware

bool force_update_flash_firmware = true

Definition at line 101 of file bhi260ap_klio_self_learning.ino.

Referenced by setup().

◆ isInterruptTriggered

volatile bool isInterruptTriggered = false

Definition at line 108 of file bhi260ap_klio_self_learning.ino.

Referenced by dataReadyISR(), and loop().

◆ klio

Referenced by learning_event_callback(), and setup().