56#if !defined(USE_I2C_INTERFACE) && !defined(USE_SPI_INTERFACE)
57#define USE_I2C_INTERFACE
60#if defined(USE_SPI_INTERFACE)
94#ifdef ARDUINO_T_BEAM_S3_SUPREME
95#include <XPowersAXP2101.tpp>
98static void serialPrintFmt(
const char *fmt, ...)
103 vsnprintf(
buf,
sizeof(
buf), fmt, args);
110#if defined(ARDUINO_T_BEAM_S3_SUPREME)
111 XPowersAXP2101 power;
112 power.begin(Wire1, AXP2101_SLAVE_ADDRESS, 42, 41);
113 power.disableALDO1();
114 power.disableALDO2();
116 power.setALDO1Voltage(3300);
118 power.setALDO2Voltage(3300);
138 Serial.print(
"["); Serial.print(millis() / 1000);
139 Serial.println(
"][WOM] Wake-on-motion detected!");
152 serialPrintFmt(
"[WOM CFG] thr=%u odr=%.1f pinDefault=%u blank=0x%02X range=%s -> %s\n",
165 Serial.println(
"\nWoM debug commands:");
166 Serial.println(
" t+ / t- : threshold +/- 10");
167 Serial.println(
" b+ / b- : blanking +/- 1");
168 Serial.println(
" p0 / p1 : default pin level 0/1");
169 Serial.println(
" o3/o11/o21/o128 : ODR 3/11/21/128Hz");
170 Serial.println(
" r2/r4/r8/r16 : accel range 2/4/8/16G");
171 Serial.println(
" s : show/apply current config");
172 Serial.println(
" h : show this help");
177 if (!Serial.available()) {
181 String
cmd = Serial.readStringUntil(
'\n');
183 if (
cmd.length() == 0) {
187 bool changed =
false;
192 }
else if (
cmd ==
"t-") {
195 }
else if (
cmd ==
"b+") {
198 }
else if (
cmd ==
"b-") {
201 }
else if (
cmd ==
"p0") {
204 }
else if (
cmd ==
"p1") {
207 }
else if (
cmd ==
"o3") {
210 }
else if (
cmd ==
"o11") {
213 }
else if (
cmd ==
"o21") {
216 }
else if (
cmd ==
"o128") {
219 }
else if (
cmd ==
"r2") {
222 }
else if (
cmd ==
"r4") {
225 }
else if (
cmd ==
"r8") {
228 }
else if (
cmd ==
"r16") {
231 }
else if (
cmd ==
"s") {
233 }
else if (
cmd ==
"h") {
236 Serial.println(
"Unknown command, input 'h' for help.");
246 Serial.begin(115200);
251 Serial.println(
"QMI8658 Wake-on-Motion Example");
253#ifdef USE_I2C_INTERFACE
255 Serial.println(
"Failed to initialize QMI8658!");
262#ifdef USE_SPI_INTERFACE
265 Serial.println(
"Failed to initialize QMI8658!");
276 Serial.println(
"\n=== Advanced Usage ===");
277 Serial.println(
"Custom: threshold=150, ODR=11Hz, PIN2, pinDefault=1, blanking=0x20, range=8G");
280 Serial.println(
"\nWake-on-motion configured. Move the sensor to trigger!");
283 int irq = digitalPinToInterrupt(
IMU_IRQ);
285 attachInterrupt(irq, +[]() {
288 serialPrintFmt(
"IRQ attached on pin %d (CHANGE trigger)\n",
IMU_IRQ);
290 serialPrintFmt(
"IRQ pin %d has no interrupt mapping, polling only\n",
IMU_IRQ);
298 bool doUpdate =
false;
304 uint32_t now = millis();
AccelFullScaleRange
Enumeration of accelerometer full-scale range settings.
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.
uint16_t update()
Update sensor status and process events.
void setPins(int pin)
Set interrupt pin.
bool configWakeOnMotionAdvanced(uint8_t threshold, float odr_hz, IntPin pin, uint8_t default_pin_value, uint8_t blanking_time, AccelFullScaleRange acc_range)
Configure wake-on-motion (WoM) with full vendor parameters.
void setWakeOnMotionCallback(MotionCallback callback)
Set callback for wake-on-motion event.
volatile bool isInterruptTriggered
SensorQMI8658::IntPin womIntPin
AccelFullScaleRange womRange
constexpr uint32_t kPollIntervalMs
uint8_t womDefaultPinValue