add some interrupt support & clang format
This commit is contained in:
parent
d689757b04
commit
ba2c197f67
3 changed files with 31 additions and 2 deletions
|
|
@ -10,6 +10,13 @@ git:
|
|||
env:
|
||||
global:
|
||||
- PRETTYNAME="Adafruit MSA301 Arduino Library"
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- llvm-toolchain-trusty-5.0
|
||||
- key_url: 'http://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
packages:
|
||||
- clang-format-5.0
|
||||
|
||||
before_install:
|
||||
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh)
|
||||
|
|
@ -19,6 +26,7 @@ install:
|
|||
- arduino --install-library "Adafruit Unified Sensor"
|
||||
|
||||
script:
|
||||
- ./run-clang-format.py -r .
|
||||
- build_main_platforms
|
||||
|
||||
# Generate and deploy documentation
|
||||
|
|
|
|||
|
|
@ -281,9 +281,9 @@ uint8_t Adafruit_MSA301::getClick(void) {
|
|||
return ClickStatus.read();
|
||||
}
|
||||
|
||||
void Adafruit_MSA301::enableInterrupts(bool orient, bool singletap, bool doubletap,
|
||||
void Adafruit_MSA301::enableInterrupts(bool singletap, bool doubletap,
|
||||
bool activeX, bool activeY, bool activeZ,
|
||||
bool newData, bool freefall) {
|
||||
bool newData, bool freefall, bool orient) {
|
||||
Adafruit_BusIO_Register IntSet0 =
|
||||
Adafruit_BusIO_Register(i2c_dev, MSA301_REG_INTSET0, 1);
|
||||
Adafruit_BusIO_Register IntSet1 =
|
||||
|
|
@ -302,6 +302,23 @@ void Adafruit_MSA301::enableInterrupts(bool orient, bool singletap, bool doublet
|
|||
IntSet1.write(irqs);
|
||||
}
|
||||
|
||||
void Adafruit_MSA301::mapInterruptPin(bool singletap, bool doubletap, bool activity,
|
||||
bool newData, bool freefall, bool orient) {
|
||||
Adafruit_BusIO_Register IntMap0 =
|
||||
Adafruit_BusIO_Register(i2c_dev, MSA301_REG_INTMAP0, 1);
|
||||
Adafruit_BusIO_Register IntMap1 =
|
||||
Adafruit_BusIO_Register(i2c_dev, MSA301_REG_INTMAP1, 1);
|
||||
uint8_t irqs = 0;
|
||||
irqs |= orient << 6;
|
||||
irqs |= singletap << 5;
|
||||
irqs |= doubletap << 4;
|
||||
irqs |= activity << 2;
|
||||
irqs |= freefall << 0;
|
||||
IntMap0.write(irqs);
|
||||
irqs = newData << 0;
|
||||
IntMap1.write(irqs);
|
||||
}
|
||||
|
||||
uint8_t Adafruit_MSA301::getMotionInterruptStatus(void) {
|
||||
Adafruit_BusIO_Register IntStatus =
|
||||
Adafruit_BusIO_Register(i2c_dev, MSA301_REG_MOTIONINT, 1);
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ I2C ADDRESS/BITS
|
|||
#define MSA301_REG_POWERMODE 0x11
|
||||
#define MSA301_REG_INTSET0 0x16
|
||||
#define MSA301_REG_INTSET1 0x17
|
||||
#define MSA301_REG_INTMAP0 0x19
|
||||
#define MSA301_REG_INTMAP1 0x1A
|
||||
#define MSA301_REG_TAPDUR 0x2A
|
||||
#define MSA301_REG_TAPTH 0x2B
|
||||
|
||||
|
|
@ -147,6 +149,8 @@ class Adafruit_MSA301 : public Adafruit_Sensor {
|
|||
void enableInterrupts(bool singletap=false, bool doubletap=false,
|
||||
bool activeX=false, bool activeY=false, bool activeZ=false,
|
||||
bool newData=false, bool freefall=false, bool orient=false);
|
||||
void mapInterruptPin(bool singletap=false, bool doubletap=false, bool activity=false,
|
||||
bool newData=false, bool freefall=false, bool orient=false);
|
||||
|
||||
uint8_t getClick(void);
|
||||
uint8_t getMotionInterruptStatus(void) ;
|
||||
|
|
|
|||
Loading…
Reference in a new issue