def __init__(self, csPIN, ISRPin, ActivityThreshold=70, ActivityTime=5, InactivityThreshold=1000, InactivityTime=5):
self.steps = 0
ADXL362.__init__(self, csPIN)
self.isrpin = Pin(ISRPin, mode=Pin.IN)
self.isrpin.callback(trigger=Pin.IRQ_RISING, handler=self._isr_handler)
self.setupDCActivityInterrupt(ActivityThreshold, ActivityTime)
self.setupDCInactivityInterrupt(InactivityThreshold, InactivityTime)
#ACTIVITY/INACTIVITY CONTROL REGISTER
self.SPIwriteOneRegister(0x27, 0B111111) #B111111 Link/Loop:11 (Loop Mode), Inactive Ref Mode:1,Inactive Enable (under threshold):1,Active Ref Mode:1, Active Enable (over threshold):1
#MAP INTERRUPT 1 REGISTER.
self.SPIwriteOneRegister(0x2A,0B10010000) #B00010000 0=HIGH on ISR,AWAKE:0,INACT:0,ACT:1,FIFO_OVERRUN:0,FIFO_WATERMARK:0,FIFO_READY:0,DATA_READY:0
#POWER CONTROL REGISTER
self.SPIwriteOneRegister(0x2D, 0B1110) #B1011 Wake-up:1,Autosleep:0,measure:11=Reserved (Maybe works better)
self.beginMeasure()
time.sleep_ms(100)
评论列表
文章目录