self.KeyAI_status = 0
self.KeyAI_timer_count = 0
self.KeyAI_long_press = 0
+ self.KeySos_long_press = 0
self.KeyAI_press = 0
if self.is_wdt == 1:
self.wdt = WDT(30) #开启看门狗
except Exception as e:
usys.print_exception(e)
def pwk_key_timer_cb(self, *args, **kwargs):
+ if EventMesh.publish("get_play_new_voice_state") == 1:
+ EventMesh.publish("set_play_new_voice_state",0)
# EventMesh.publish("publish_AI_btnInfo",{"func":self.pwk_key_timer_cb_})
# def pwk_key_timer_cb_(self) :
try:
if self.KeyAI_status == 0:#按下
if self.KeyAI_press == 0 :
+ if EventMesh.publish("get_play_new_voice_state") == 1:
+ EventMesh.publish("set_play_new_voice_state",0)
EventMesh.publish(constants.EVENT.SYSTEM_UP)#唤醒休眠
self.extint_AI.disable()
self.KeyAI_press = 1
self.KeyAI_status = self.extint_AI.read_level()
self.KeyAI_timer_count +=1
if self.KeyAI_timer_count >= 10*1 : #长按1s
+
if self.KeyAI_long_press == 0:
self.KeyAI_long_press = 1
#EventMesh.publish("AI_key_long_press")
EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_key_long_press})
+ if self.KeyAI_timer_count >= 10*3 : #长按1s
+ print("long sos phone:{}".format(self.KeySOS_timer_flag))
+
+ if self.KeySOS_timer_flag == 1:
+ self.KeySOS_timer_flag=0
+ self.KeySos_long_press = 1
+ self.KeySOS_timer.stop()
+ get_sos_flag = EventMesh.publish("get_sos_flag")
+ if get_sos_flag == 0:
+ EventMesh.publish("set_sos_info_call")
+ pass
+
elif self.KeyAI_timer_count >= 10*8:#关机
if dev_type == 'jswm' or dev_type == 'jswm_BOX':
EventMesh.publish("audio_montage_play",["zhengzaiguanji.mp3"])
if dev_type == "7PIN_BK"or dev_type == "7PIN_BK_EU"or dev_type == "7PIN_BK_coze":
key_count = 3
if self.KeyAI_timer_count >= key_count: #防抖200ms
+ if self.KeyAI_long_press == 0:
+ if self.KeySOS_timer_flag == 0:
+ self.KeySOS_timer_flag = 1
+ self.KeySos_long_press = 0
+ self.KeySOS_timer.start(5000, 0, self.KeySos_timer_cb)
+ else:
+ self.KeySOS_timer_flag = 0
+ self.KeySos_long_press = 0
+ self.KeySOS_timer.stop()
+
#EventMesh.publish("AI_key_release")
EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_key_release})
self.extint_AI.enable()
self.KeyAI_timer.stop()
self.KeyAI_timer_count = 0
self.KeyAI_press = 0
+ self.KeyAI_long_press=0
except Exception as e:
usys.print_exception(e)
print("AI_key_press")
EventMesh.publish("AI_key_press")
def KeySos_timer_cb(self,*argc):
+ print("KeySos_timer_cb!!!!!!!!!!{} {}".format(self.KeySos_long_press,self.KeySOS_timer_flag))
+
+ if self.KeySos_long_press == 1 and self.KeySOS_timer_flag == 1:
+ self.KeySos_long_press=0
+ self.KeySOS_timer_flag=0
+ get_sos_flag = EventMesh.publish("get_sos_flag")
+ if get_sos_flag == 0:
+ EventMesh.publish("set_sos_info_call")
+ self.KeySos_long_press=0
+ self.KeySOS_timer_flag = 0
+ return
self.KeySOS_timer_flag = 0
if self.KeySOS_timer_count >= 3:
self.KeySOS_timer_count = 0
def AI_key_release(self):
print("AI_key_release")
- self.KeySOS_timer_count +=1
- print("self.KeySOS_timer_count:{} {}".format(self.KeySOS_timer_count,self.KeySOS_timer_flag))
- if self.KeySOS_timer_flag == 0:
- self.KeySOS_timer_flag = 1
- self.KeySOS_timer.start(5000, 0, self.KeySos_timer_cb)
+ # self.KeySOS_timer_count +=1
+ # print("self.KeySOS_timer_count:{} {}".format(self.KeySOS_timer_count,self.KeySOS_timer_flag))
+ # if self.KeySOS_timer_flag == 0:
+ # self.KeySOS_timer_flag = 1
+ # self.KeySOS_timer.start(5000, 0, self.KeySos_timer_cb)
EventMesh.publish("AI_key_release")
# EventMesh.publish("publish_AI_btnInfo",{"func":self.websocket_deconnect_VC})
# EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_VC_start})
except Exception as e:
- usys.print_exception(e)
+ usys.print_exception(e)
pass
def check_text_server(self,cmd):
return -1
self.alarm_array[i]["state"] = "0"
print("单次闹钟时间过了{}".format(self.alarm_array))
EventMesh.publish("set_storage_config",["alarm_list",self.alarm_array])
+ EventMesh.publish("GET_NEED_ALARM_REPORT_INFO")
continue
if (week_now in week_list) or all(c == '0' for c in loop) == 1:
if set_hour *60 + set_min == hour_now*60+ minute_now and self.alarm_min_repeat_tmp != minute_now:
ringUrl = alarm_TTS_str["ringUrl"]
print("{} {} {}".format(AringTimes,alarmMode,shakeType))
if alarmMode == "ring": #只响铃
- tts_audio = "chenggong.mp3"
- if AringTimes == 0:
- AringTimes = 1
- tts_str = [tts_audio] * AringTimes
- print(tts_str)
if ringUrl != None:
- pass
- # EventMesh.publish("play_new_voice",[ringUrl,1])
+ EventMesh.publish("play_new_voice",[ringUrl,1])
if ringUrl == None:
base_sentence = "{}".format(name)
if AringTimes == 0:
EventMesh.publish("play_tts",[final_sentence,1]) #播放tts闹钟文本内容
elif alarmMode == "both": #响铃加振动
- tts_audio = "chenggong.mp3"
- if AringTimes == 0:
- AringTimes = 1
- tts_str = [tts_audio] * AringTimes
if ringUrl != None:
- # EventMesh.publish("play_new_voice",[ringUrl,1])
+ EventMesh.publish("play_new_voice",[ringUrl,1])
pass
if shakeType == "short":
EventMesh.publish("set_motor_time",[1,1,5,8,4])#设置马达参数