53#if !defined(USE_I2C_INTERFACE) && !defined(USE_SPI_INTERFACE)
54#define USE_I2C_INTERFACE
57#if defined(USE_SPI_INTERFACE)
83#ifdef ARDUINO_T_BEAM_S3_SUPREME
84#include <XPowersAXP2101.tpp>
87static void serialPrintFmt(
const char *fmt, ...)
92 vsnprintf(
buf,
sizeof(
buf), fmt, args);
99#if defined(ARDUINO_T_BEAM_S3_SUPREME)
100 XPowersAXP2101 power;
101 power.begin(Wire1, AXP2101_SLAVE_ADDRESS, 42, 41);
102 power.disableALDO1();
103 power.disableALDO2();
105 power.setALDO1Voltage(3300);
107 power.setALDO2Voltage(3300);
126 Serial.println(
"[EVENT] Any motion detected!");
131 Serial.
begin(115200);
135 Serial.println(
"QMI8658 Any-Motion Example");
137#ifdef USE_I2C_INTERFACE
139 Serial.println(
"Failed to initialize QMI8658!");
140 while (1) delay(1000);
144#ifdef USE_SPI_INTERFACE
146 Serial.println(
"Failed to initialize QMI8658!");
147 while (1) delay(1000);
163 serialPrintFmt(
"Any-Motion config=%s enable=%s\n", cfg ?
"OK" :
"FAIL", en ?
"OK" :
"FAIL");
164 Serial.println(
"Move sensor to trigger Any-Motion.");
166 int irq = digitalPinToInterrupt(
IMU_IRQ);
168 attachInterrupt(irq, +[]() {
171 serialPrintFmt(
"IRQ attached on pin %d (CHANGE trigger)\n",
IMU_IRQ);
173 serialPrintFmt(
"IRQ pin %d has no interrupt mapping, polling only\n",
IMU_IRQ);
183 bool doUpdate =
false;
189 uint32_t now = millis();
bool begin(CommInterface interface, SensorCommCustom::CustomCallback callback, SensorCommCustomHal::CustomHalCallback hal_callback, uint8_t addr=0)
Initialize the sensor using custom callback interface.
QMI8658 IMU sensor driver class.
bool enableAccel() override
Enable the accelerometer.
bool enableMotionDetect(IntPin pin=IntPin::PIN1)
Enable motion detection on specified pin.
@ ANY_MOTION
Any motion detection.
void setAnyMotionCallback(MotionCallback callback)
Set callback for any-motion event.
bool configAccel(AccelFullScaleRange range, float data_rate_hz, LpfMode lpf=LpfMode::MODE_0)
Configure the accelerometer with specified parameters.
uint16_t update()
Update sensor status and process events.
void setPins(int pin)
Set interrupt pin.
bool configMotionDetect(MotionType type, float threshold_x, float threshold_y, float threshold_z, uint8_t duration)
Configure motion detection parameters.
constexpr float kAccelOdrHz
volatile bool isInterruptTriggered
constexpr uint8_t kAnyWindow
constexpr float kAnyThresholdMg
constexpr uint32_t kPollIntervalMs