mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-15 17:55:09 +00:00

* First addition of __has_include for sensor support * Add __has_include blocks for sensors * Put BMP and BME back in the right sensors * Make TelemetrySensor::setup() a pure virtual finction * Split environmental_base to environmental_extra, to compile the working sensor libs for Native * Remove hard-coded checks for ARCH_PORTDUINO * Un-clobber bmx160 * Move BusIO to environmental_extra due to Armv7 compile error * Move to forked BusIO for the moment * Enable HAS_SENSOR for Portduino * Move back to Adafruit BusIO after patch
38 lines
1.1 KiB
C++
Executable File
38 lines
1.1 KiB
C++
Executable File
#include "LIS3DHSensor.h"
|
|
#include "NodeDB.h"
|
|
|
|
#if !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_I2C && __has_include(<Adafruit_LIS3DH.h>)
|
|
|
|
LIS3DHSensor::LIS3DHSensor(ScanI2C::FoundDevice foundDevice) : MotionSensor::MotionSensor(foundDevice) {}
|
|
|
|
bool LIS3DHSensor::init()
|
|
{
|
|
if (sensor.begin(deviceAddress())) {
|
|
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("LIS3DH init ok");
|
|
return true;
|
|
}
|
|
LOG_DEBUG("LIS3DH init failed");
|
|
return false;
|
|
}
|
|
|
|
int32_t LIS3DHSensor::runOnce()
|
|
{
|
|
if (sensor.getClick() > 0) {
|
|
uint8_t click = sensor.getClick();
|
|
if (!config.device.double_tap_as_button_press && config.display.wake_on_tap_or_motion) {
|
|
wakeScreen();
|
|
}
|
|
|
|
if (config.device.double_tap_as_button_press && (click & 0x20)) {
|
|
buttonPress();
|
|
return 500;
|
|
}
|
|
}
|
|
return MOTION_SENSOR_CHECK_INTERVAL_MS;
|
|
}
|
|
|
|
#endif
|