LSM6DS3TR-C support (#3593)

* started work on pulling in the unphone library and dependencies, to do e.g. power switch management and etc.; currently failing at Adafruit_ImageReader

* now compiles with unphoneLibrary included

* successfully pulled in unphone library to manage power switch and init vibe motor and etc.
doesnt print to serial tho...

* simplified the build a bit; when doing meshtastic do not depend on the MCCI lora libs etc., then also no need to config them via build flags

* version that doesnt trigger brownout

* cleaned up initVariant a little

* note re. GPS

* back to mesh upstream version

* this time we're back to mesh upstream version

* getting LSM6DS3TRC driver installed

* shake to wake works, set threshold quite low may need increasing

* whats the crack with these end of file changes?

* paramatize the wake threshold

* try to get the PR to just include real changes

* got the right config item and also not giving compiler messages

* moved the lib_deps for the LSM6DS3TRC driver from our variant platformio.ini to the main one in root so all boards have it

* stuupid error #define-ing

---------

Co-authored-by: Hamish Cunningham <hamish@gate.ac.uk>
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
Gareth Coleman 2024-04-12 01:40:14 +01:00 committed by GitHub
parent 927d07e2c6
commit f4a2023dba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 24 additions and 4 deletions

View File

@ -132,3 +132,4 @@ lib_deps =
adafruit/Adafruit MPU6050@^2.2.4 adafruit/Adafruit MPU6050@^2.2.4
adafruit/Adafruit LIS3DH@^1.2.4 adafruit/Adafruit LIS3DH@^1.2.4
https://github.com/lewisxhe/SensorLib#27fd0f721e20cd09e1f81383f0ba58a54fe84a17 https://github.com/lewisxhe/SensorLib#27fd0f721e20cd09e1f81383f0ba58a54fe84a17
adafruit/Adafruit LSM6DS@^4.7.2

View File

@ -5,6 +5,7 @@
#include "power.h" #include "power.h"
#include <Adafruit_LIS3DH.h> #include <Adafruit_LIS3DH.h>
#include <Adafruit_LSM6DS3TRC.h>
#include <Adafruit_MPU6050.h> #include <Adafruit_MPU6050.h>
#include <Arduino.h> #include <Arduino.h>
#include <SensorBMA423.hpp> #include <SensorBMA423.hpp>
@ -108,6 +109,15 @@ class AccelerometerThread : public concurrency::OSThread
bmaSensor.enableTiltIRQ(); bmaSensor.enableTiltIRQ();
// It corresponds to isDoubleClick interrupt // It corresponds to isDoubleClick interrupt
bmaSensor.enableWakeupIRQ(); bmaSensor.enableWakeupIRQ();
} else if (acceleremoter_type == ScanI2C::DeviceType::LSM6DS3 && lsm.begin_I2C(accelerometer_found.address)) {
LOG_DEBUG("LSM6DS3 initializing\n");
// Default threshold of 2G, less sensitive options are 4, 8 or 16G
lsm.setAccelRange(LSM6DS_ACCEL_RANGE_2_G);
#ifndef LSM6DS3_WAKE_THRESH
#define LSM6DS3_WAKE_THRESH 20
#endif
lsm.enableWakeup(config.display.wake_on_tap_or_motion, 1, LSM6DS3_WAKE_THRESH);
// Duration is number of occurances needed to trigger, higher threshold is less sensitive
} }
} }
@ -133,6 +143,9 @@ class AccelerometerThread : public concurrency::OSThread
wakeScreen(); wakeScreen();
return 500; return 500;
} }
} else if (acceleremoter_type == ScanI2C::DeviceType::LSM6DS3 && lsm.shake()) {
wakeScreen();
return 500;
} }
return ACCELEROMETER_CHECK_INTERVAL_MS; return ACCELEROMETER_CHECK_INTERVAL_MS;
@ -156,6 +169,7 @@ class AccelerometerThread : public concurrency::OSThread
ScanI2C::DeviceType acceleremoter_type; ScanI2C::DeviceType acceleremoter_type;
Adafruit_MPU6050 mpu; Adafruit_MPU6050 mpu;
Adafruit_LIS3DH lis; Adafruit_LIS3DH lis;
Adafruit_LSM6DS3TRC lsm;
}; };
} // namespace concurrency } // namespace concurrency

View File

@ -128,6 +128,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MPU6050_ADDR 0x68 #define MPU6050_ADDR 0x68
#define LIS3DH_ADR 0x18 #define LIS3DH_ADR 0x18
#define BMA423_ADDR 0x19 #define BMA423_ADDR 0x19
#define LSM6DS3_ADDR 0x6A
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// LED // LED
@ -280,4 +281,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef MESHTASTIC_EXCLUDE_SCREEN #ifdef MESHTASTIC_EXCLUDE_SCREEN
#undef HAS_SCREEN #undef HAS_SCREEN
#define HAS_SCREEN 0 #define HAS_SCREEN 0
#endif #endif

View File

@ -36,8 +36,8 @@ ScanI2C::FoundDevice ScanI2C::firstKeyboard() const
ScanI2C::FoundDevice ScanI2C::firstAccelerometer() const ScanI2C::FoundDevice ScanI2C::firstAccelerometer() const
{ {
ScanI2C::DeviceType types[] = {MPU6050, LIS3DH, BMA423}; ScanI2C::DeviceType types[] = {MPU6050, LIS3DH, BMA423, LSM6DS3};
return firstOfOrNONE(3, types); return firstOfOrNONE(4, types);
} }
ScanI2C::FoundDevice ScanI2C::find(ScanI2C::DeviceType) const ScanI2C::FoundDevice ScanI2C::find(ScanI2C::DeviceType) const

View File

@ -39,6 +39,7 @@ class ScanI2C
LIS3DH, LIS3DH,
BMA423, BMA423,
BQ24295, BQ24295,
LSM6DS3,
#ifdef HAS_NCP5623 #ifdef HAS_NCP5623
NCP5623, NCP5623,
#endif #endif

View File

@ -310,6 +310,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port)
SCAN_SIMPLE_CASE(PMSA0031_ADDR, PMSA0031, "PMSA0031 air quality sensor found\n") SCAN_SIMPLE_CASE(PMSA0031_ADDR, PMSA0031, "PMSA0031 air quality sensor found\n")
SCAN_SIMPLE_CASE(MPU6050_ADDR, MPU6050, "MPU6050 accelerometer found\n"); SCAN_SIMPLE_CASE(MPU6050_ADDR, MPU6050, "MPU6050 accelerometer found\n");
SCAN_SIMPLE_CASE(BMA423_ADDR, BMA423, "BMA423 accelerometer found\n"); SCAN_SIMPLE_CASE(BMA423_ADDR, BMA423, "BMA423 accelerometer found\n");
SCAN_SIMPLE_CASE(LSM6DS3_ADDR, LSM6DS3, "LSM6DS3 accelerometer found\n");
default: default:
LOG_INFO("Device found at address 0x%x was not able to be enumerated\n", addr.address); LOG_INFO("Device found at address 0x%x was not able to be enumerated\n", addr.address);

View File

@ -53,6 +53,8 @@
#define I2C_SDA 3 // I2C pins for this board #define I2C_SDA 3 // I2C pins for this board
#define I2C_SCL 4 #define I2C_SCL 4
#define LSM6DS3_WAKE_THRESH 5 // higher values reduce the sensitivity of the wake threshold
// ratio of voltage divider = 3.20 (R1=100k, R2=220k) // ratio of voltage divider = 3.20 (R1=100k, R2=220k)
// #define ADC_MULTIPLIER 3.2 // #define ADC_MULTIPLIER 3.2