More reduction (#5256)

* Now with even fewer ings

* Ye

* Mo

* QMA6100PSensor
This commit is contained in:
Ben Meadors
2024-11-04 19:15:59 -06:00
committed by GitHub
parent 7ba6d97e99
commit f769c50fa5
83 changed files with 362 additions and 364 deletions

View File

@@ -65,14 +65,14 @@ class AccelerometerThread : public concurrency::OSThread
return;
if (device.address.port == ScanI2C::I2CPort::NO_I2C || device.address.address == 0 || device.type == ScanI2C::NONE) {
LOG_DEBUG("AccelerometerThread disabling due to no sensors found");
LOG_DEBUG("AccelerometerThread Disable due to no sensors found");
disable();
return;
}
#ifndef RAK_4631
if (!config.display.wake_on_tap_or_motion && !config.device.double_tap_as_button_press) {
LOG_DEBUG("AccelerometerThread disabling due to no interested configurations");
LOG_DEBUG("AccelerometerThread Disable due to no interested configurations");
disable();
return;
}

View File

@@ -41,10 +41,10 @@ bool BMA423Sensor::init()
// It corresponds to isDoubleClick interrupt
sensor.enableWakeupIRQ();
LOG_DEBUG("BMA423Sensor::init ok");
LOG_DEBUG("BMA423 init ok");
return true;
}
LOG_DEBUG("BMA423Sensor::init failed");
LOG_DEBUG("BMA423 init failed");
return false;
}

View File

@@ -16,10 +16,10 @@ bool BMX160Sensor::init()
if (sensor.begin()) {
// set output data rate
sensor.ODR_Config(BMX160_ACCEL_ODR_100HZ, BMX160_GYRO_ODR_100HZ);
LOG_DEBUG("BMX160Sensor::init ok");
LOG_DEBUG("BMX160 init ok");
return true;
}
LOG_DEBUG("BMX160Sensor::init failed");
LOG_DEBUG("BMX160 init failed");
return false;
}

View File

@@ -44,14 +44,14 @@ int32_t ICM20948Sensor::runOnce()
// Wake on motion using polling - this is not as efficient as using hardware interrupt pin (see above)
auto status = sensor->setBank(0);
if (sensor->status != ICM_20948_Stat_Ok) {
LOG_DEBUG("ICM20948Sensor::isWakeOnMotion failed to set bank - %s", sensor->statusString());
LOG_DEBUG("ICM20948 isWakeOnMotion failed to set bank - %s", sensor->statusString());
return MOTION_SENSOR_CHECK_INTERVAL_MS;
}
ICM_20948_INT_STATUS_t int_stat;
status = sensor->read(AGB0_REG_INT_STATUS, (uint8_t *)&int_stat, sizeof(ICM_20948_INT_STATUS_t));
if (status != ICM_20948_Stat_Ok) {
LOG_DEBUG("ICM20948Sensor::isWakeOnMotion failed to read interrupts - %s", sensor->statusString());
LOG_DEBUG("ICM20948 isWakeOnMotion failed to read interrupts - %s", sensor->statusString());
return MOTION_SENSOR_CHECK_INTERVAL_MS;
}
@@ -99,25 +99,25 @@ bool ICM20948Singleton::init(ScanI2C::FoundDevice device)
ICM_20948_Status_e status = begin(Wire, device.address.address == ICM20948_ADDR ? 1 : 0);
#endif
if (status != ICM_20948_Stat_Ok) {
LOG_DEBUG("ICM20948Sensor::init begin - %s", statusString());
LOG_DEBUG("ICM20948 init begin - %s", statusString());
return false;
}
// SW reset to make sure the device starts in a known state
if (swReset() != ICM_20948_Stat_Ok) {
LOG_DEBUG("ICM20948Sensor::init reset - %s", statusString());
LOG_DEBUG("ICM20948 init reset - %s", statusString());
return false;
}
delay(200);
// Now wake the sensor up
if (sleep(false) != ICM_20948_Stat_Ok) {
LOG_DEBUG("ICM20948Sensor::init wake - %s", statusString());
LOG_DEBUG("ICM20948 init wake - %s", statusString());
return false;
}
if (lowPower(false) != ICM_20948_Stat_Ok) {
LOG_DEBUG("ICM20948Sensor::init high power - %s", statusString());
LOG_DEBUG("ICM20948 init high power - %s", statusString());
return false;
}
@@ -125,19 +125,19 @@ bool ICM20948Singleton::init(ScanI2C::FoundDevice device)
// Active low
cfgIntActiveLow(true);
LOG_DEBUG("ICM20948Sensor::init set cfgIntActiveLow - %s", statusString());
LOG_DEBUG("ICM20948 init set cfgIntActiveLow - %s", statusString());
// Push-pull
cfgIntOpenDrain(false);
LOG_DEBUG("ICM20948Sensor::init set cfgIntOpenDrain - %s", statusString());
LOG_DEBUG("ICM20948 init set cfgIntOpenDrain - %s", statusString());
// If enabled, *ANY* read will clear the INT_STATUS register.
cfgIntAnyReadToClear(true);
LOG_DEBUG("ICM20948Sensor::init set cfgIntAnyReadToClear - %s", statusString());
LOG_DEBUG("ICM20948 init set cfgIntAnyReadToClear - %s", statusString());
// Latch the interrupt until cleared
cfgIntLatch(true);
LOG_DEBUG("ICM20948Sensor::init set cfgIntLatch - %s", statusString());
LOG_DEBUG("ICM20948 init set cfgIntLatch - %s", statusString());
// Set up an interrupt pin with an internal pullup for active low
pinMode(ICM_20948_INT_PIN, INPUT_PULLUP);
@@ -168,13 +168,13 @@ bool ICM20948Singleton::setWakeOnMotion()
// Enable WoM Logic mode 1 = Compare the current sample with the previous sample
status = WOMLogic(true, 1);
LOG_DEBUG("ICM20948Sensor::init set WOMLogic - %s", statusString());
LOG_DEBUG("ICM20948 init set WOMLogic - %s", statusString());
if (status != ICM_20948_Stat_Ok)
return false;
// Enable interrupts on WakeOnMotion
status = intEnableWOM(true);
LOG_DEBUG("ICM20948Sensor::init set intEnableWOM - %s", statusString());
LOG_DEBUG("ICM20948 init set intEnableWOM - %s", statusString());
return status == ICM_20948_Stat_Ok;
// Clear any current interrupts

View File

@@ -11,10 +11,10 @@ bool LIS3DHSensor::init()
sensor.setRange(LIS3DH_RANGE_2_G);
// Adjust threshold, higher numbers are less sensitive
sensor.setClick(config.device.double_tap_as_button_press ? 2 : 1, MOTION_SENSOR_CHECK_INTERVAL_MS);
LOG_DEBUG("LIS3DHSensor::init ok");
LOG_DEBUG("LIS3DH init ok");
return true;
}
LOG_DEBUG("LIS3DHSensor::init failed");
LOG_DEBUG("LIS3DH init failed");
return false;
}

View File

@@ -15,10 +15,10 @@ bool LSM6DS3Sensor::init()
// Duration is number of occurrences needed to trigger, higher threshold is less sensitive
sensor.enableWakeup(config.display.wake_on_tap_or_motion, 1, LSM6DS3_WAKE_THRESH);
LOG_DEBUG("LSM6DS3Sensor::init ok");
LOG_DEBUG("LSM6DS3 init ok");
return true;
}
LOG_DEBUG("LSM6DS3Sensor::init failed");
LOG_DEBUG("LSM6DS3 init failed");
return false;
}

View File

@@ -13,10 +13,10 @@ bool MPU6050Sensor::init()
sensor.setMotionDetectionDuration(20);
sensor.setInterruptPinLatch(true); // Keep it latched. Will turn off when reinitialized.
sensor.setInterruptPinPolarity(true);
LOG_DEBUG("MPU6050Sensor::init ok");
LOG_DEBUG("MPU6050 init ok");
return true;
}
LOG_DEBUG("MPU6050Sensor::init failed");
LOG_DEBUG("MPU6050 init failed");
return false;
}

View File

@@ -10,8 +10,8 @@ MotionSensor::MotionSensor(ScanI2C::FoundDevice foundDevice)
device.address.address = foundDevice.address.address;
device.address.port = foundDevice.address.port;
device.type = foundDevice.type;
LOG_DEBUG("MotionSensor::MotionSensor port: %s address: 0x%x type: %d",
devicePort() == ScanI2C::I2CPort::WIRE1 ? "Wire1" : "Wire", (uint8_t)deviceAddress(), deviceType());
LOG_DEBUG("Motion MotionSensor port: %s address: 0x%x type: %d", devicePort() == ScanI2C::I2CPort::WIRE1 ? "Wire1" : "Wire",
(uint8_t)deviceAddress(), deviceType());
}
ScanI2C::DeviceType MotionSensor::deviceType()
@@ -57,14 +57,14 @@ void MotionSensor::drawFrameCalibration(OLEDDisplay *display, OLEDDisplayUiState
void MotionSensor::wakeScreen()
{
if (powerFSM.getState() == &stateDARK) {
LOG_DEBUG("MotionSensor::wakeScreen detected");
LOG_DEBUG("Motion wakeScreen detected");
powerFSM.trigger(EVENT_INPUT);
}
}
void MotionSensor::buttonPress()
{
LOG_DEBUG("MotionSensor::buttonPress detected");
LOG_DEBUG("Motion buttonPress detected");
powerFSM.trigger(EVENT_PRESS);
}

View File

@@ -44,7 +44,7 @@ int32_t QMA6100PSensor::runOnce()
uint8_t tempVal;
if (!sensor->readRegisterRegion(SFE_QMA6100P_INT_ST0, &tempVal, 1)) {
LOG_DEBUG("QMA6100PSensor::isWakeOnMotion failed to read interrupts");
LOG_DEBUG("QMA6100PS isWakeOnMotion failed to read interrupts");
return MOTION_SENSOR_CHECK_INTERVAL_MS;
}
@@ -88,55 +88,55 @@ bool QMA6100PSingleton::init(ScanI2C::FoundDevice device)
bool status = begin(device.address.address, &Wire);
#endif
if (status != true) {
LOG_WARN("QMA6100PSensor::init begin failed\n");
LOG_WARN("QMA6100P init begin failed\n");
return false;
}
delay(20);
// SW reset to make sure the device starts in a known state
if (softwareReset() != true) {
LOG_WARN("QMA6100PSensor::init reset failed\n");
LOG_WARN("QMA6100P init reset failed\n");
return false;
}
delay(20);
// Set range
if (!setRange(QMA_6100P_MPU_ACCEL_SCALE)) {
LOG_WARN("QMA6100PSensor::init range failed");
LOG_WARN("QMA6100P init range failed");
return false;
}
// set active mode
if (!enableAccel()) {
LOG_WARN("ERROR :QMA6100PSensor::active mode set failed");
LOG_WARN("ERROR QMA6100P active mode set failed");
}
// set calibrateoffsets
if (!calibrateOffsets()) {
LOG_WARN("ERROR :QMA6100PSensor:: calibration failed");
LOG_WARN("ERROR QMA6100P calibration failed");
}
#ifdef QMA_6100P_INT_PIN
// Active low & Open Drain
uint8_t tempVal;
if (!readRegisterRegion(SFE_QMA6100P_INTPINT_CONF, &tempVal, 1)) {
LOG_WARN("QMA6100PSensor::init failed to read interrupt pin config");
LOG_WARN("QMA6100P init failed to read interrupt pin config");
return false;
}
tempVal |= 0b00000010; // Active low & Open Drain
if (!writeRegisterByte(SFE_QMA6100P_INTPINT_CONF, tempVal)) {
LOG_WARN("QMA6100PSensor::init failed to write interrupt pin config");
LOG_WARN("QMA6100P init failed to write interrupt pin config");
return false;
}
// Latch until cleared, all reads clear the latch
if (!readRegisterRegion(SFE_QMA6100P_INT_CFG, &tempVal, 1)) {
LOG_WARN("QMA6100PSensor::init failed to read interrupt config");
LOG_WARN("QMA6100P init failed to read interrupt config");
return false;
}
tempVal |= 0b10000001; // Latch until cleared, INT_RD_CLR1
if (!writeRegisterByte(SFE_QMA6100P_INT_CFG, tempVal)) {
LOG_WARN("QMA6100PSensor::init failed to write interrupt config");
LOG_WARN("QMA6100P init failed to write interrupt config");
return false;
}
// Set up an interrupt pin with an internal pullup for active low
@@ -153,7 +153,7 @@ bool QMA6100PSingleton::setWakeOnMotion()
{
// Enable 'Any Motion' interrupt
if (!writeRegisterByte(SFE_QMA6100P_INT_EN2, 0b00000111)) {
LOG_WARN("QMA6100PSingleton::setWakeOnMotion failed to write interrupt enable");
LOG_WARN("QMA6100P :setWakeOnMotion failed to write interrupt enable");
return false;
}
@@ -161,7 +161,7 @@ bool QMA6100PSingleton::setWakeOnMotion()
uint8_t tempVal;
if (!readRegisterRegion(SFE_QMA6100P_INT_MAP1, &tempVal, 1)) {
LOG_WARN("QMA6100PSingleton::setWakeOnMotion failed to read interrupt map");
LOG_WARN("QMA6100P setWakeOnMotion failed to read interrupt map");
return false;
}
@@ -171,7 +171,7 @@ bool QMA6100PSingleton::setWakeOnMotion()
tempVal = int_map1.all;
if (!writeRegisterByte(SFE_QMA6100P_INT_MAP1, tempVal)) {
LOG_WARN("QMA6100PSingleton::setWakeOnMotion failed to write interrupt map");
LOG_WARN("QMA6100P setWakeOnMotion failed to write interrupt map");
return false;
}

View File

@@ -17,10 +17,10 @@ bool STK8XXXSensor::init()
attachInterrupt(
digitalPinToInterrupt(STK8XXX_INT), [] { STK_IRQ = true; }, RISING);
LOG_DEBUG("STK8XXXSensor::init ok");
LOG_DEBUG("STK8XXX init ok");
return true;
}
LOG_DEBUG("STK8XXXSensor::init failed");
LOG_DEBUG("STK8XXX init failed");
return false;
}