self.wdt = WDT(30) #开启看门狗
# self.wdt_timer = osTimer()
# self.wdt_timer.start(5000, 1, self.wdt_timer_cb)
+ #马达
+ self.PIN_MOT=Pin(Pin.GPIO36, Pin.OUT, Pin.PULL_DISABLE, 0)
+ #蓝牙电源
+ self.PIN_BT_ON =Pin(Pin.GPIO31, Pin.OUT, Pin.PULL_DISABLE, 0)
count = 0
while True:
count += 1
self.pwk_key = ExtInt(ExtInt.GPIO41, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.pwk_extint_cb)
self.extint_AI = ExtInt(ExtInt.GPIO43,ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.keyAI_extint_cb)
#self.extint_AI = ExtInt(ExtInt.GPIO22,ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.keyAI_extint_cb)
- #蓝牙唤醒4G中断
- self.extint_wakeup_cta1 = ExtInt(ExtInt.GPIO22,ExtInt.IRQ_RISING, ExtInt.PULL_DISABLE, self.wakeup_extint_cb)
- #4G唤醒蓝牙中断
- self.PIN_wakeup_bt =Pin(Pin.GPIO21, Pin.OUT, Pin.PULL_DISABLE, 0)
- #蓝牙开电
- self.PIN_BT_ON =Pin(Pin.GPIO31, Pin.OUT, Pin.PULL_DISABLE, 0)
- utime.sleep_ms(200)
- self.PIN_BT_ON =Pin(Pin.GPIO31, Pin.OUT, Pin.PULL_DISABLE, 1)
- #马达
- self.PIN_MOT=Pin(Pin.GPIO36, Pin.OUT, Pin.PULL_DISABLE, 1)
- utime.sleep_ms(500)
- self.PIN_MOT=Pin(Pin.GPIO36, Pin.OUT, Pin.PULL_DISABLE, 0)
-
+ #蓝牙唤醒4G中断
+ self.extint_wakeup_cta1 = ExtInt(ExtInt.GPIO22,ExtInt.IRQ_RISING, ExtInt.PULL_DISABLE, self.wakeup_extint_cb)
+ #4G唤醒蓝牙中断
+ self.PIN_wakeup_bt =Pin(Pin.GPIO21, Pin.OUT, Pin.PULL_DISABLE, 0)
+
+ #马达
+ self.PIN_MOT.write(1)
+ utime.sleep_ms(200)
+ self.PIN_MOT.write(0)
+ self.PIN_BT_ON.write(1)
self.extint_wakeup_cta1_timer = osTimer()
self.extint_wakeup_cta1.enable()
self.extint_AI.enable()
self.PIN_wakeup_bt.write(1)
def wakeup_BT(self,event=None,msg=None):#4G唤醒蓝牙
-
- count = 150
+ print("wakeup_BT!!!!!!!!!!!!!!!")
+ print("wakeup_BT!!!!!!!!!!!!!!!")
+ count = 5
while(True):
count-=1
if count<=0:
return -1
- if self.extint_wakeup_cta1.read_level() == 1:
+ wakeup_cta1_io = self.extint_wakeup_cta1.read_level()
+ print("bt io状态:{}".format(wakeup_cta1_io))
+ if wakeup_cta1_io == 1:
self.PIN_wakeup_bt.write(1)
return 1
- utime.sleep_ms(2)
+ utime.sleep_ms(100)
if count%2 == 0:
self.PIN_wakeup_bt.write(0)
else:
def audio_cb(self,event):
if event == 0:
+ EventMesh.publish(constants.EVENT.SYSTEM_UP)#唤醒休眠
self.audio_play_state =1
#EventMesh.publish("set_audio_state", 1)
print('audio-play start.')
def kws_even(self,event = None,msg= None):
EventMesh.publish("publish_AI_btnInfo",{"func":self.kws_even_cb})
def kws_even_cb(self):
- if EventMesh.publish("get_sos_flag") == 1:
- return
print("kws_even_cb")
if EventMesh.publish("get_voice_record_flag") == 1:#停止静默录音
if EventMesh.publish("get_voice_record_mode") == 2:#语音留言不能被打断