coda_adxl362.py 文件源码

python
阅读 39 收藏 0 点赞 0 评论 0

项目:pyCom 作者: dinosd 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号