--- /dev/null
+@echo off
+
+md images
+del images /q
+..\..\Helios_SDK\tools\ASR_1606\win32\mklfs.exe -c ext -b 4096 -r 4096 -p 4096 -s 1363148 -i .\images\ext_fs.bin
+if errorlevel 1 (
+ echo "ext_fs.binÉú³Éʧ°Ü !!!!!!!!!!!!!!! "
+ goto exit
+)
+if errorlevel 0 (
+ echo "ext_fs.binÉú³É³É¹¦ !!!!!!!!!!!!!!! "
+)
+
+..\..\Helios_SDK\tools\ASR_1606\win32\mklfs.exe -c usr -b 4096 -r 4096 -p 4096 -s 491520 -i .\images\customer_fs.bin
+if errorlevel 1 (
+ echo "customer_fs.binÉú³Éʧ°Ü Çë¼ì²éusrĿ¼ÊÇ·ñ´óÓÚ316K!!!!!!!!!!!!!!!"
+ goto exit
+)
+if errorlevel 0 (
+ echo "customer_fs.binÉú³É³É¹¦ !!!!!!!!!!!!!!! "
+)
+
+copy font\ext_font.bin images\ext_font.bin
+
+..\..\Helios_SDK\tools\common\win32\7z\7z a sdk\system\platform\ASR_1606\boards\EG810MCN_GA_VOLTE\images\firmware_base_release_pack.zip .\images\
+if errorlevel 0 (
+ echo imagesѹËõ³É¹¦!!!!!!!!!!!!!!
+)
+if errorlevel 1 (
+ echo imagesѹËõʧ°Ü!!!!!!!!!!!!!!!!!!
+ goto exit
+)
+xcopy sdk\ ..\..\Helios_SDK\ /e/h/y
+cd ..\..\Helios_SDK
+helios make services/microPython @EG810MCN_GA_VOLTE EG810MCN_GA_VOLTE
+cd ..
+:exit
\ No newline at end of file
--- /dev/null
+import _thread
+import usys
+
+import versions
+
+MODEL = "K5_" #项目型号
+
+
+version = "{}{}".format(MODEL,versions.Version)
+builTime = "{}".format(versions.Build_Time)
+
+class EventStore(object):
+ def __init__(self):
+ self.map = dict()
+ self.log = None
+ self.__filters = []
+
+ def add_filter(self, flt):
+ self.__filters.append(flt)
+
+ def append(self, event, cb):
+ self.map[event] = cb
+
+ def fire_async(self, event, msg,thread_size):
+ if event in self.map:
+ #print("fire_async:thread_size:{}".format(thread_size))
+ if thread_size != None:
+ _thread.stack_size(thread_size)
+ #print("fire_async:thread_size:{}".format(thread_size))
+ _thread.start_new_thread(self.map[event], (event, msg))
+ if thread_size != None:
+ _thread.stack_size(8*1024)
+ if self.log:
+ self.log.info("ASYNC executed (event) -> {} (params) -> {} (result) -> {}".format(event, msg, None))
+
+ def fire_sync(self, event, msg):
+ res = None
+ try:
+ if event in self.map:
+ res = self.map[event](event, msg)
+ except Exception as e:
+ usys.print_exception(e)
+ if self.log:
+ self.log.info("ERROR executed (event) -> {} (params) -> {} (result) -> {}".format(event, msg, res))
+ if event not in self.__filters:
+ if self.log:
+ self.log.info("SYNC executed (event) -> {} (params) -> {} (result) -> {}".format(event, msg, res))
+ return res
+
+
+event_store = EventStore()
+
+
+def subscribe(event, cb):
+ """
+ subscribe event and cb
+ """
+ return event_store.append(event, cb)
+
+
+def publish(event, msg=None):
+ """
+ publish event and msg
+ """
+ return publish_sync(event, msg)
+
+
+def publish_async(event, msg=None,thread_size = None):
+ """
+ 异步发送
+ """
+ return event_store.fire_async(event, msg,thread_size)
+
+
+def publish_sync(event, msg=None):
+ """
+ 同步发送
+ """
+ return event_store.fire_sync(event, msg)
+
+
+def set_log(log_adapter):
+ event_store.log = log_adapter
+
+
+def add_filter(flt):
+ event_store.add_filter(flt)
+
+
+def callback_wrapper(callback):#按键回调
+ def wrapped_callback(*args, **kwargs):
+ try:
+ return callback(*args, **kwargs)
+ except Exception as e:
+ # 在这里处理异常,例如打印错误信息,保存到日志文件,等等。
+ print('Exception in callback:', e)
+ # 如果需要,你可以在这里重新抛出异常
+ # raise
+ return wrapped_callback
+
+import utime
+import uos
+debug_Log = 1
+def debug_log(*data):
+ if debug_Log != 0 :
+ print(data)
+Txt_Log = 0
+def txt_log(data):
+ if Txt_Log != 0 :
+ print(data)
+ try:
+ check_file = ql_fs.path_exists("usr/log.txt")
+
+ if check_file == True:
+ f_stat = uos.stat("usr/log.txt")
+ if f_stat[6] > 50*1024:
+ uos.remove("usr/log.txt")
+ except Exception as e:
+ usys.print_exception(e)
+ with open("/usr/log.txt","a",encoding="utf-8") as fd:
+ d_time = utime.localtime()
+ data_tmp = "%02d-%02d %02d:%02d:%02d :"%(d_time[1],d_time[2],d_time[3],d_time[4],d_time[5])
+ fd.write(data_tmp+data+"\n")
+
--- /dev/null
+# Copyright (c) Quectel Wireless Solution, Co., Ltd.All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#env
+TOP := ../../..
+ROOT := $(TOP)/../..
+
+KCONFIG_CONFIG_DIR := ../../../../..
+include $(KCONFIG_CONFIG_DIR)/config/$(KCONFIG_CONFIG)
+
+ifeq ("$(origin V)", "command line")
+BUILD_VERBOSE=$(V)
+endif
+ifndef BUILD_VERBOSE
+BUILD_VERBOSE = 0
+endif
+# ifeq ($(BUILD_VERBOSE),0)
+# Q = @
+# else
+# Q =
+# endif
+
+BUILD ?= build
+FROZEN_MPY_DIR ?= .
+
+RM = rm
+ECHO = echo
+CP = cp
+MKDIR = mkdir
+SED = sed
+CAT = cat
+TOUCH = touch
+
+MAKE_MANIFEST = $(PYTHON) $(TOP)/tools/makemanifest.py
+MAKE_FROZEN = $(PYTHON) $(TOP)/tools/make-frozen.py
+#because E-safeNet, mpy-cross could not read the py file, rename as notepad++
+ifeq ($(strip $(HOST)),linux)
+MPY_CROSS = $(TOP)/ports/quectel/tools/mpy-cross
+else
+MPY_CROSS = $(TOP)/ports/quectel/tools/notepad++.exe
+endif
+MPY_TOOL = $(PYTHON) $(TOP)/tools/mpy-tool.py
+
+QSTR_DEFS = source/qstrdefsport.h
+#py
+PY_SRC ?= $(TOP)/py
+HEADER_BUILD = $(TOP)/genhdr
+PY_QSTR_DEFS = $(PY_SRC)/qstrdefs.h
+ifneq ($(QSTR_AUTOGEN_DISABLE),1)
+QSTR_DEFS_COLLECTED = $(HEADER_BUILD)/qstrdefs.collected.h
+endif
+QSTR_GLOBAL_DEPENDENCIES += $(PY_SRC)/mpconfig.h source/mpconfigport.h
+CSUPEROPT = -O3
+ifeq ($(strip $(PLAT)),ECR6600)
+MPY_CROSS_FLAGS += -march=xtensa
+else
+MPY_CROSS_FLAGS += -march=armv7m
+endif
+# Enable building 32-bit code on 64-bit host.
+ifeq ($(MICROPY_FORCE_32BIT),1)
+CC += -m32
+CXX += -m32
+LD += -m32
+endif
+
+# External modules written in C.
+ifneq ($(USER_C_MODULES),)
+# pre-define USERMOD variables as expanded so that variables are immediate
+# expanded as they're added to them
+SRC_USERMOD :=
+C_FLAGS_USERMOD :=
+LD_FLAGS_USERMOD :=
+$(foreach module, $(wildcard $(USER_C_MODULES)/*/micropython.mk), \
+ $(eval USERMOD_DIR = $(patsubst %/,%,$(dir $(module))))\
+ $(info Including User C Module from $(USERMOD_DIR))\
+ $(eval include $(module))\
+)
+
+SRC_MOD += $(patsubst $(USER_C_MODULES)/%.c,%.c,$(SRC_USERMOD))
+C_FLAGS_MOD += $(C_FLAGS_USERMOD)
+LD_FLAGS_MOD += $(LD_FLAGS_USERMOD)
+endif
+
+# py object files
+PY_CORE_O_BASENAME = $(addprefix py/,\
+ mpstate.o \
+ nlr.o \
+ nlrx86.o \
+ nlrx64.o \
+ nlrthumb.o \
+ nlrpowerpc.o \
+ nlrxtensa.o \
+ nlrsetjmp.o \
+ malloc.o \
+ gc.o \
+ pystack.o \
+ qstr.o \
+ vstr.o \
+ mpprint.o \
+ unicode.o \
+ mpz.o \
+ reader.o \
+ lexer.o \
+ parse.o \
+ scope.o \
+ compile.o \
+ emitcommon.o \
+ emitbc.o \
+ asmbase.o \
+ asmx64.o \
+ emitnx64.o \
+ asmx86.o \
+ emitnx86.o \
+ asmthumb.o \
+ emitnthumb.o \
+ emitinlinethumb.o \
+ asmarm.o \
+ emitnarm.o \
+ asmxtensa.o \
+ emitnxtensa.o \
+ emitinlinextensa.o \
+ emitnxtensawin.o \
+ formatfloat.o \
+ parsenumbase.o \
+ parsenum.o \
+ emitglue.o \
+ persistentcode.o \
+ runtime.o \
+ runtime_utils.o \
+ scheduler.o \
+ nativeglue.o \
+ pairheap.o \
+ ringbuf.o \
+ stackctrl.o \
+ argcheck.o \
+ warning.o \
+ profile.o \
+ map.o \
+ obj.o \
+ objarray.o \
+ objattrtuple.o \
+ objbool.o \
+ objboundmeth.o \
+ objcell.o \
+ objclosure.o \
+ objcomplex.o \
+ objdeque.o \
+ objdict.o \
+ objenumerate.o \
+ objexcept.o \
+ objfilter.o \
+ objfloat.o \
+ objfun.o \
+ objgenerator.o \
+ objgetitemiter.o \
+ objint.o \
+ objint_longlong.o \
+ objint_mpz.o \
+ objlist.o \
+ objmap.o \
+ objmodule.o \
+ objobject.o \
+ objpolyiter.o \
+ objproperty.o \
+ objnone.o \
+ objnamedtuple.o \
+ objrange.o \
+ objreversed.o \
+ objset.o \
+ objsingleton.o \
+ objslice.o \
+ objstr.o \
+ objstrunicode.o \
+ objstringio.o \
+ objtuple.o \
+ objtype.o \
+ objzip.o \
+ opmethods.o \
+ sequence.o \
+ stream.o \
+ binary.o \
+ builtinimport.o \
+ builtinevex.o \
+ builtinhelp.o \
+ modarray.o \
+ modbuiltins.o \
+ modcollections.o \
+ modgc.o \
+ modio.o \
+ modmath.o \
+ modcmath.o \
+ modmicropython.o \
+ modstruct.o \
+ modsys.o \
+ moduerrno.o \
+ modthread.o \
+ vm.o \
+ bc.o \
+ showbc.o \
+ repl.o \
+ smallint.o \
+ frozenmod.o \
+ )
+
+PY_EXTMOD_O_BASENAME = \
+ extmod/moductypes.o \
+ extmod/modujson.o \
+ extmod/modure.o \
+ extmod/moduzlib.o \
+ extmod/moduheapq.o \
+ extmod/modutimeq.o \
+ extmod/modubinascii.o \
+ extmod/virtpin.o \
+ extmod/machine_mem.o \
+ extmod/machine_pinbase.o \
+ extmod/machine_signal.o \
+ extmod/machine_pulse.o \
+ extmod/machine_i2c.o \
+ extmod/machine_spi.o \
+ extmod/modbluetooth.o \
+ extmod/modurandom.o \
+ extmod/moduselect.o \
+ extmod/moduasyncio.o \
+ extmod/moduwebsocket.o \
+ extmod/modwebrepl.o \
+ extmod/modframebuf.o \
+ extmod/vfs.o \
+ extmod/vfs_blockdev.o \
+ extmod/vfs_reader.o \
+ extmod/vfs_posix.o \
+ extmod/vfs_posix_file.o \
+ extmod/vfs_fat.o \
+ extmod/vfs_fat_file.o \
+ extmod/vfs_lfs.o \
+ extmod/utime_mphal.o \
+ extmod/uos_dupterm.o \
+ extmod/modussl_mbedtls.o \
+ extmod/moduhashlib.o \
+ extmod/moducryptolib.o \
+ lib/embed/abort_.o \
+ lib/utils/printf.o \
+ lib/utils/sys_stdio_mphal.o
+
+ifeq ($(strip $(PLAT)),Qualcomm)
+PY_EXTMOD_O_BASENAME += \
+ extmod/vfs_efs.o \
+ extmod/vfs_efs_file.o
+endif
+
+ifeq ($(strip $(PLAT)), $(filter $(PLAT),Unisoc Unisoc_8910_R05))
+PY_EXTMOD_O_BASENAME += \
+ extmod/vfs_temp.o \
+ extmod/vfs_temp_file.o
+endif
+
+# Sources that may contain qstrings
+SRC_QSTR_IGNORE = py/nlr%
+SRC_QSTR += $(SRC_MOD) $(filter-out $(SRC_QSTR_IGNORE),$(PY_CORE_O_BASENAME:.o=.c)) $(PY_EXTMOD_O_BASENAME:.o=.c)
+SRC_QSTR += \
+ source/modalipay.c \
+ source/audio_audio.c \
+ source/audio_queue.c \
+ source/audio_record.c \
+ source/audio_tts.c \
+ source/audiocodec_rt5616.c \
+ source/callbackdeal.c \
+ source/camera_capture.c \
+ source/camera_preview.c \
+ source/camera_scandecode.c \
+ source/devreport.c \
+ source/machine_extint.c \
+ source/machine_hw_spi.c \
+ source/machine_iic.c \
+ source/machine_iic_simulation.c \
+ source/machine_keypad.c \
+ source/machine_lcd.c \
+ source/machine_nandflash.c \
+ source/machine_pin.c \
+ source/machine_rtc.c \
+ source/machine_timer.c \
+ source/machine_uart.c \
+ source/machine_wdt.c \
+ source/misc_adc.c \
+ source/misc_power.c \
+ source/misc_powerkey.c \
+ source/misc_pwm.c \
+ source/misc_temperature.c \
+ source/misc_usb.c \
+ source/misc_usbnet.c \
+ source/modatcmd.c \
+ source/modaudio.c \
+ source/modaudiocodec.c \
+ source/modble.c \
+ source/modbt.c \
+ source/modcamera.c \
+ source/modcelllocator.c \
+ source/modcelllocator_qpy.c \
+ source/locator.c \
+ source/modcsd.c \
+ source/moddatacall.c \
+ source/moddev.c \
+ source/modethernet.c \
+ source/modethernet_dm9051.c \
+ source/modethernet_w5500.c \
+ source/modethernet_ch395.c \
+ source/modexample.c \
+ source/modfota.c \
+ source/modgnss.c \
+ source/modlpm.c \
+ source/modlvgl.c \
+ source/modlwm2m.c \
+ source/modmachine.c \
+ source/modmisc.c \
+ source/modnb.c \
+ source/modnet.c \
+ source/modostimer.c \
+ source/modpoc.c \
+ source/modqrcode.c \
+ source/modrtmp.c \
+ source/modsecuredata.c \
+ source/modsensor.c \
+ source/modsha1.c \
+ source/modsim.c \
+ source/modslipif.c \
+ source/modsms.c \
+ source/modsocket.c \
+ source/modtp.c \
+ source/moduos.c \
+ source/modutils.c \
+ source/modutime.c \
+ source/modvoicecall.c \
+ source/modwifilocator.c \
+ source/modwifiscan.c \
+ source/nb_aep.c \
+ source/nb_oc.c \
+ source/nb_onenet.c \
+ source/quecpython.c \
+ source/sensor_sn95500.c \
+ source/sensor_icckey.c \
+ source/sensor_gnss.c \
+ source/tp_gt9xx.c \
+ source/tp_xpt2046.c \
+ source/tp_cst816.c \
+ source/modGsensor.c \
+ source/modGsensor_SC7A20.c \
+ source/modHsensor.c \
+ source/modHsensor_GH3018.c \
+ source/modVideoCall.c \
+ source/modVideoCall_juphoon.c \
+ source/modHsensor_HX3918.c \
+ source/modgpio_encoder.c \
+ source/modrsa.c \
+ source/utils_crc32.c \
+ source/http_parser.c \
+ source/modwebserver.c \
+ source/modethernet_yt8512h.c \
+ source/sim_esim.c \
+ source/modG711.c \
+ source/modG729.c \
+ source/modcan_mcp2515.c \
+ source/modextuart_wk2114.c \
+ source/modextgpio_aw9523.c \
+ source/machine_key.c \
+ source/lpm_wakeup.c \
+ source/sensor_handmic_key.c \
+ source/modnetwork.c \
+ source/modwlan_ASR5803.c \
+ source/machine_soft_spi.c \
+ source/code128_p.c \
+ source/modwlan.c\
+ source/modwlan.c \
+ source/modmask.c \
+ source/modVad.c \
+ source/machine_one_wire.c
+
+
+ifeq ($(strip $(PLAT)),RDA)
+SRC_QSTR += $(ROOT)/components/quecsdk/cloud/python/modquecIot-BC25old.c
+else
+SRC_QSTR += $(ROOT)/components/quecsdk/cloud/python/modquecIot.c
+endif
+
+ifeq ($(CONFIG_USQLITE), y)
+SRC_QSTR += lib/usqlite/usqlite_connection.c \
+ lib/usqlite/usqlite_cursor.c \
+ lib/usqlite/usqlite_row.c \
+ lib/usqlite/usqlite_file.c \
+ lib/usqlite/usqlite_mem.c \
+ lib/usqlite/usqlite_vfs.c \
+ lib/usqlite/usqlite_utils.c \
+ lib/usqlite/usqlite.c \
+ lib/usqlite/usqlite_module.c
+
+INC += -Ilib/usqlite
+endif
+
+$(BUILD)/%.pp: %.c
+ @$(ECHO) "PreProcess $<"
+ $(Q)$(CPP) $(C_FLAGS) -Wp,-C,-dD,-dI -o $@ $<
+
+# Anything that depends on FORCE will be considered out-of-date
+FORCE:
+.PHONY: FORCE
+
+$(HEADER_BUILD):
+ $(MKDIR) -p $@
+
+#$(HEADER_BUILD)/mpversion.h: FORCE | $(HEADER_BUILD)
+# $(Q)$(PYTHON) $(PY_SRC)/makeversionhdr.py $@
+# mpconfigport.mk is optional, but changes to it may drastically change
+# overall config, so they need to be caught
+MPCONFIGPORT_MK = $(wildcard mpconfigport.mk)
+
+# qstr data
+# Adding an order only dependency on $(HEADER_BUILD) causes $(HEADER_BUILD) to get
+# created before we run the script to generate the .h
+# Note: we need to protect the qstr names from the preprocessor, so we wrap
+# the lines in "" and then unwrap after the preprocessor is finished.
+# See more information about this process in docs/develop/qstr.rst.
+$(HEADER_BUILD)/qstrdefs.generated.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(QSTR_DEFS_COLLECTED) $(PY_SRC)/makeqstrdata.py source/mpconfigport.h $(MPCONFIGPORT_MK) $(PY_SRC)/mpconfig.h | $(HEADER_BUILD)
+ @$(ECHO) "GEN $@"
+ $(Q)$(CAT) $(PY_QSTR_DEFS) $(QSTR_DEFS) $(QSTR_DEFS_COLLECTED) | $(SED) 's/^Q(.*)/"&"/' | $(CPP) $(C_FLAGS) - | $(SED) 's/^\"\(Q(.*)\)\"/\1/' > $(HEADER_BUILD)/qstrdefs.preprocessed.h
+ $(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/qstrdefs.preprocessed.h > $@
+
+# Compressed error strings.
+$(HEADER_BUILD)/compressed.split: $(HEADER_BUILD)/qstr.i.last
+ @$(ECHO) "GEN $@"
+ $(Q)$(PYTHON) $(PY_SRC)/makeqstrdefs.py split compress $< $(HEADER_BUILD)/compress _
+ $(Q)$(TOUCH) $@
+
+$(HEADER_BUILD)/compressed.collected: $(HEADER_BUILD)/compressed.split
+ @$(ECHO) "GEN $@"
+ $(Q)$(PYTHON) $(PY_SRC)/makeqstrdefs.py $(CAT) compress _ $(HEADER_BUILD)/compress $@
+
+$(HEADER_BUILD)/compressed.data.h: $(HEADER_BUILD)/compressed.collected
+ @$(ECHO) "GEN $@"
+ $(Q)$(PYTHON) $(PY_SRC)/makecompresseddata.py $< > $@
+
+# build a list of registered modules for py/objmodule.c.
+$(HEADER_BUILD)/moduledefs.h: $(SRC_QSTR) $(QSTR_GLOBAL_DEPENDENCIES) | $(HEADER_BUILD)
+ @$(ECHO) "GEN $@"
+ $(Q)$(PYTHON) $(PY_SRC)/makemoduledefs.py --vpath="., $(TOP), $(USER_C_MODULES)" $(SRC_QSTR) > $@
+
+SRC_QSTR += $(HEADER_BUILD)/moduledefs.h
+
+INC += -I$(ROOT)/system/platform/$(strip $(PLAT))/boards/$(strip $(BOARD))/config
+INC += -I$(ROOT)/system/platform/$(strip $(PLAT))/include
+
+ifeq ($(strip $(PLAT)),Qualcomm)
+INC += -I$(COMPILER_PATH)/armv7m-none-eabi/libc/include
+INC += -I$(ROOT)/system/platform/$(strip $(PLAT))/boards/$(strip $(BOARD))/include/azure_api
+INC += -I$(ROOT)/system/platform/$(strip $(PLAT))/boards/$(strip $(BOARD))/include/azure_api/c-utility
+INC += -I$(ROOT)/system/platform/$(strip $(PLAT))/boards/$(strip $(BOARD))/include/azure_api/c-utility/inc
+INC += -I$(ROOT)/system/platform/$(strip $(PLAT))/boards/$(strip $(BOARD))/include/azure_api/c-utility/inc/azure_c_shared_utility
+INC += -I$(ROOT)/system/platform/$(strip $(PLAT))/boards/$(strip $(BOARD))/include/azure_api/c-utility/pal
+INC += -I$(ROOT)/system/platform/$(strip $(PLAT))/boards/$(strip $(BOARD))/include/azure_api/c-utility/pal/generic
+INC += -I$(ROOT)/system/platform/$(strip $(PLAT))/boards/$(strip $(BOARD))/include/azure_api/iothub_client
+INC += -I$(ROOT)/system/platform/$(strip $(PLAT))/boards/$(strip $(BOARD))/include/azure_api/iothub_client/inc
+INC += -I$(ROOT)/system/platform/$(strip $(PLAT))/boards/$(strip $(BOARD))/include/azure_api/iothub_client/inc/internal
+INC += -I$(ROOT)/system/platform/$(strip $(PLAT))/boards/$(strip $(BOARD))/include/azure_api/serializer
+INC += -I$(ROOT)/system/platform/$(strip $(PLAT))/boards/$(strip $(BOARD))/include/azure_api/serializer/inc
+INC += -I$(ROOT)/system/platform/$(strip $(PLAT))/boards/$(strip $(BOARD))/include/azure_api/umqtt
+INC += -I$(ROOT)/system/platform/$(strip $(PLAT))/boards/$(strip $(BOARD))/include/azure_api/umqtt/inc
+INC += -I$(ROOT)/system/platform/$(strip $(PLAT))/boards/$(strip $(BOARD))/include/azure_api/umqtt/inc/azure_umqtt_c
+INC += -I$(ROOT)/system/platform/$(strip $(PLAT))/boards/$(strip $(BOARD))/include/qapi
+INC += -I$(ROOT)/system/platform/$(strip $(PLAT))/boards/$(strip $(BOARD))/include/threadx_api
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/include
+INC += -I$(ROOT)/system/at
+INC += -I$(ROOT)/system/esim
+endif
+
+INC += -I.
+INC += -I$(HEADER_BUILD)
+INC += -I$(TOP)
+INC += -I$(TOP)/py
+INC += -I$(TOP)/extmod
+INC += -I$(TOP)/lib/utils
+INC += -I$(TOP)/lib/mp-readline
+INC += -I$(TOP)/lib/littlefs
+INC += -I$(TOP)/lib/netutils
+INC += -I$(TOP)/lib/timeutils
+INC += -I$(TOP)/ports/quectel/core
+INC += -I$(TOP)/ports/quectel/core/source
+INC += -I$(TOP)/ports/quectel/core/py
+INC += -I$(ROOT)/peripheral
+INC += -I$(ROOT)/system/include
+INC += -I$(ROOT)/system/platform/$(strip $(PLAT))/include
+INC += -I$(ROOT)/system/platform/$(strip $(PLAT))/boards/$(strip $(BOARD))/include
+INC += -I$(ROOT)/system/debug
+INC += -I$(ROOT)/system/dev
+INC += -I$(ROOT)/system/fs
+INC += -I$(ROOT)/system/hal
+INC += -I$(ROOT)/system/gnss
+INC += -I$(ROOT)/system/network
+INC += -I$(ROOT)/system/at
+INC += -I$(ROOT)/system/aliiot
+
+ifeq ($(strip $(PLAT)),ASR_1803s)
+INC += -I$(ROOT)/system/csd
+INC += -I$(ROOT)/system/esim
+endif
+ifeq ($(strip $(PLAT)),ASR_1606)
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/include
+endif
+
+ifeq ($(strip $(PLAT)),Unisoc)
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/include
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/lwip
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/lwip/apps
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/lwip/priv
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/lwip/prot
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/netif
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/posix
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/posix/arpa
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/posix/net
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/posix/netinet
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/posix/sys
+INC += -I$(ROOT)/system/at
+endif
+
+ifeq ($(strip $(PLAT)),Unisoc_8910_R05)
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/include
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/lwip
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/lwip/apps
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/lwip/priv
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/lwip/prot
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/netif
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/netif/ppp
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/netif/ppp/polarssl
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/compat/posix
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/compat/posix/arpa
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/compat/posix/net
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/compat/posix/netinet
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/compat/posix/sys
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/compat/stdc
+endif
+
+ifeq ($(strip $(PLAT)),EIGEN)
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/include
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/include/lwip
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/include/lwip/apps
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/include/lwip/priv
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/include/lwip/prot
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/include/arch
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/include/netif
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/include/posix
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/include/posix/sys
+endif
+
+ifeq ($(strip $(PLAT)),Unisoc_8850)
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/include
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/lwip
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/lwip/apps
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/lwip/priv
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/lwip/prot
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/netif
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/netif/ppp
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/netif/ppp/polarssl
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/compat/posix
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/compat/posix/arpa
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/compat/posix/net
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/compat/posix/netinet
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/compat/posix/sys
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/compat/stdc
+endif
+
+ifeq ($(strip $(PLAT)),RDA)
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/include
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/include/arch
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/lwip
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/lwip/apps
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/lwip/priv
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/lwip/prot
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/netif
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/posix
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/posix/arpa
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/posix/net
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/posix/netinet
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/src/include/posix/sys
+endif
+
+ifeq ($(strip $(PLAT)), $(filter $(PLAT),ASR ASR_1803s))
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/include
+INC += -I$(ROOT)/system/at
+endif
+
+ifeq ($(strip $(PLAT)),ECR6600)
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))
+INC += -I$(ROOT)/system/lwip/$(strip $(PLAT))/include
+endif
+
+ifeq (y, $(CONFIG_MBEDTLS))
+INC += -I$(ROOT)/system/mbedtls
+INC += -I$(ROOT)/system/mbedtls/include
+INC += -I$(ROOT)/system/mbedtls/include/mbedtls
+INC += -I$(ROOT)/system/mbedtls/library
+INC += -I$(ROOT)/system/mbedtls/port/helios/inc
+endif
+INC += -I$(ROOT)/system/network
+INC += -I$(ROOT)/system/os
+INC += -I$(ROOT)/system/startup
+INC += -I$(ROOT)/system/fota
+INC += -I$(ROOT)/system/bt
+INC += -I$(ROOT)/system/at
+ifeq (y, $(CONFIG_LVGL))
+INC += -I$(TOP)/lib/lvgl
+INC += -I$(TOP)/lib/lvgl/src
+INC += -I$(TOP)/lib/lvgl/src/core
+INC += -I$(TOP)/lib/lvgl/src/draw
+INC += -I$(TOP)/lib/lvgl/src/extra
+INC += -I$(TOP)/lib/lvgl/src/font
+INC += -I$(TOP)/lib/lvgl/src/gpu
+INC += -I$(TOP)/lib/lvgl/src/hal
+INC += -I$(TOP)/lib/lvgl/src/misc
+INC += -I$(TOP)/lib/lvgl/src/widgts
+endif
+INC += -I$(ROOT)/driver
+INC += -I$(ROOT)/driver/lcd
+ifeq (y, $(CONFIG_QRCODE))
+INC += -I$(ROOT)/components/qrcode
+endif
+ifeq (y, $(CONFIG_QUECTHING))
+INC += -I$(ROOT)/components/quecsdk/cloud
+INC += -I$(ROOT)/components/quecsdk/driverLayer
+INC += -I$(ROOT)/components/quecsdk/thirdLib/mqtt
+INC += -I$(ROOT)/components/quecsdk/thirdLib/cJSON
+INC += -I$(ROOT)/components/quecsdk/kernel
+endif
+ifeq ($(CONFIG_SPINAND), y)
+INC += -I$(ROOT)/components/fs/include
+INC += -I$(ROOT)/components/fs/yaffs/src/direct
+INC += -I$(ROOT)/components/fs/yaffs/src/port
+INC += -I$(ROOT)/components/fs/yaffs/src
+INC += -I$(ROOT)/components/fs/yaffs
+endif
+ifeq ($(CONFIG_RTMP), y)
+INC += -I$(ROOT)/components/rtmpdump/librtmp/inc
+INC += -I$(ROOT)/components/rtmpdump/libz/inc
+endif
+INC += -I$(ROOT)/utilities
+ifeq ($(CONFIG_JPEG), y)
+INC += -I$(ROOT)/components/jpeg/jpeg-9c
+INC += -I$(ROOT)/components/jpeg
+endif
+ifeq ($(CONFIG_HX3918), y)
+INC += -I$(ROOT)/components/HX3918
+endif
+ifeq ($(CONFIG_GH301x), y)
+INC += -I$(ROOT)/components/GH301x
+endif
+ifeq ($(CONFIG_SC7A20), y)
+INC += -I$(ROOT)/components/SC7A20
+endif
+ifeq ($(CONFIG_juphoon), y)
+INC += -I$(ROOT)/components/juphoon
+endif
+ifeq ($(CONFIG_POC_BND), y)
+INC += -I$(ROOT)/components/poc
+INC += -I$(ROOT)/components/poc/bnd/inc
+endif
+ifeq ($(CONFIG_POC_BND_XIN), y)
+INC += -I$(ROOT)/components/poc
+INC += -I$(ROOT)/components/poc/bnd_xin/inc
+endif
+ifeq ($(CONFIG_POC_SL), y)
+INC += -I$(ROOT)/components/poc
+INC += -I$(ROOT)/components/poc/sl/inc
+endif
+ifeq ($(CONFIG_POC_QS), y)
+INC += -I$(ROOT)/components/poc
+INC += -I$(ROOT)/components/poc/qs/inc
+endif
+#Stephen.Gao add 2022/11/23
+ifeq ($(CONFIG_POC_ZZD), y)
+INC += -I$(ROOT)/components/poc
+INC += -I$(ROOT)/components/poc/zzd/inc
+endif
+#Stephen.Gao add 2023/01/06
+ifeq ($(CONFIG_POC_YDWL), y)
+INC += -I$(ROOT)/components/poc
+INC += -I$(ROOT)/components/poc/ydwl/inc
+endif
+
+ifeq ($(CONFIG_POC_SLPOC), y)
+INC += -I$(ROOT)/components/poc -I$(ROOT)/components/poc/slpoc/src
+INC += -I$(ROOT)/components/poc/slpoc/inc
+SRC_QSTR += $(ROOT)/components/poc/slpoc/src/modpoc_slpoc.c
+endif
+
+ifeq ($(CONFIG_POC_RDA_BND), y)
+INC += -I$(ROOT)/components/poc -I$(ROOT)/components/poc/rda_bnd/src
+INC += -I$(ROOT)/components/poc/rda_bnd/inc
+SRC_QSTR += $(ROOT)/components/poc/rda_bnd/src/modpocrda.c
+endif
+
+
+ifeq (y,$(CONFIG_DECODE_ZBAR))
+INC += -I$(ROOT)/components/decode/ZBar/zbar
+INC += -I$(ROOT)/components/decode/ZBar/include
+INC += -I$(ROOT)/components/decode/ZBar/zbar/decoder
+INC += -I$(ROOT)/components/decode/ZBar/zbar/qrcode
+endif
+ifeq (y,$(CONFIG_DECODE_QUECTEL))
+INC += -I$(ROOT)/components/decode/quectel/inc
+endif
+
+ifeq (y,$(CONFIG_DECODE_QINGYA))
+ifneq ($(strip $(PLAT)),ASR)
+ifneq ($(strip $(PLAT)),ASR_1606)
+INC += -I$(ROOT)/components/decode/qingya
+endif
+endif
+endif
+
+ifeq ($(CONFIG_SPI_SDCARD), y)
+INC += -I$(ROOT)/components/fs/fatfs/include
+endif
+
+ifeq ($(CONFIG_AUDIO_G711_COMPRESS), y)
+INC += -I$(ROOT)/components/audio/G711
+endif
+ifeq ($(strip $(PLAT)),EIGEN)
+INC += -I$(ROOT)/components/audio
+endif
+
+ifeq ($(CONFIG_GMSSL), y)
+INC += -I$(ROOT)/components/GMSSL/include
+INC += -I$(ROOT)/components/GMSSL/include/gmssl
+endif
+
+ifeq ($(CONFIG_AUDIO_G729_COMPRESS), y)
+INC += -I$(ROOT)/components/audio/G729
+INC += -I$(ROOT)/components/audio/G729/src
+INC += -I$(ROOT)/components/audio/G729/include
+endif
+
+# compiler settings
+CWARN = -Wall -Werror
+CWARN += -Wpointer-arith -Wuninitialized
+C_FLAGS = $(INC) $(CWARN) -std=gnu99 $(C_FLAGS_MOD) $(COPT) $(C_FLAGS_EXTRA)
+C_FLAGS += -fdata-sections -ffunction-sections -fno-asynchronous-unwind-tables --include=../../../../../../config/autoconf.h
+
+LD_FLAGS_ARCH = -Wl,-Map=$@.map,--cref -Wl,--gc-sections
+LD_FLAGS = $(LD_FLAGS_MOD) $(LD_FLAGS_ARCH) -lm $(LD_FLAGS_EXTRA)
+
+D_FLAGS += $(foreach dflag, $(DFLAGS), -D$(dflag))
+D_FLAGS += -DMP_CONFIGFILE="\"ports/quectel/core/source/mpconfigport.h\"" \
+ -DMICROPY_MPTHREADPORT_H="\"ports/quectel/core/source/mpthreadport.h\"" \
+ -DMICROPY_MPHALPORT_H="\"ports/quectel/core/source/mphalport.h\""
+
+vpath %.S . $(TOP) $(USER_C_MODULES)
+$(BUILD)/%.o: %.S
+ @$(ECHO) "CC $<"
+ $(Q)$(CC) $(C_FLAGS) $(D_FLAGS) -c -o $@ $<
+
+vpath %.s . $(TOP) $(USER_C_MODULES)
+$(BUILD)/%.o: %.s
+ @$(ECHO) "AS $<"
+ $(Q)$(AS) -o $@ $<
+QSTR_GEN_EXTRA_C_FLAGS += -DNO_QSTR
+vpath %.c . $(TOP) $(USER_C_MODULES)
+$(BUILD)/%.pp: %.c
+ @$(ECHO) "PreProcess $<"
+ $(Q)$(CPP) $(C_FLAGS) $(D_FLAGS) -Wp,-C,-dD,-dI -o $@ $<
+
+#$(OBJ): | $(HEADER_BUILD)/qstrdefs.generated.h $(HEADER_BUILD)/mpversion.h
+
+
+$(HEADER_BUILD)/qstr.i.last: $(SRC_QSTR) $(QSTR_GLOBAL_DEPENDENCIES) | $(QSTR_GLOBAL_REQUIREMENTS)
+ @$(ECHO) "GEN $@"
+ @rm -f $@ $@.dep
+ @for src in $(if $(filter $?,$(QSTR_GLOBAL_DEPENDENCIES)),$^,$(if $?,$?,$^)); \
+ do \
+ echo $$src >> $@.dep; \
+ done
+ @while read -r src; \
+ do \
+ echo processing on $$src ...; \
+ $(CPP) $(QSTR_GEN_EXTRA_C_FLAGS) $(C_FLAGS) $(D_FLAGS) $$src >> $@; \
+ done < $@.dep
+
+$(HEADER_BUILD)/qstr.split: $(HEADER_BUILD)/qstr.i.last
+ @$(ECHO) "GEN $@"
+ $(Q)$(PYTHON) $(PY_SRC)/makeqstrdefs.py split qstr $(HEADER_BUILD)/qstr.i.last $(HEADER_BUILD)/qstr $(QSTR_DEFS_COLLECTED)
+ $(Q)$(TOUCH) $@
+
+$(QSTR_DEFS_COLLECTED): $(HEADER_BUILD)/qstr.split
+ @$(ECHO) "GEN $@"
+ $(Q)$(PYTHON) $(PY_SRC)/makeqstrdefs.py cat qstr $(HEADER_BUILD)/qstr.i.last $(HEADER_BUILD)/qstr $(QSTR_DEFS_COLLECTED)
+
+
+$(BUILD)/%.mpy: $(FROZEN_MPY_DIR)/%.py
+ @$(ECHO) "MPY $<"
+ $(Q)$(MKDIR) -p $(dir $@)
+ $(Q)$(MPY_CROSS) -o $@ -s $(<:$(FROZEN_MPY_DIR)/%=%) $(MPY_CROSS_FLAGS) $<
+
+ifeq ($(strip $(PLAT)),RDA)
+frozen_mpy_list = $(BUILD)/_boot_RDA.mpy \
+ $(BUILD)/system.mpy \
+ $(BUILD)/dataCall.mpy \
+ $(BUILD)/umqtt.mpy \
+ $(BUILD)/sys_bus.mpy \
+ $(BUILD)/queue.mpy \
+ $(BUILD)/log.mpy \
+ $(BUILD)/request.mpy \
+ $(BUILD)/ql_fs.mpy \
+ $(BUILD)/app_fota_mount.mpy \
+ $(BUILD)/app_fota_download.mpy \
+ $(BUILD)/checksum.mpy \
+ $(BUILD)/file_crc32.mpy \
+ $(BUILD)/app_fota_updater.mpy \
+ $(BUILD)/app_fota.mpy \
+ $(BUILD)/backup_restore.mpy \
+ $(BUILD)/event_message.mpy \
+ $(BUILD)/ntptime.mpy \
+ $(BUILD)/checkNet.mpy \
+ $(BUILD)/uping.mpy \
+ $(BUILD)/ymodem.mpy \
+
+ifeq ($(strip $(BOARD)),$(filter $(strip $(BOARD)),BC25B8PA_LBS))
+ frozen_mpy_list += $(BUILD)/cellLocator.mpy
+endif
+
+else ifeq ($(strip $(PLAT)),ASR_1803s)
+frozen_mpy_list = $(BUILD)/_boot.mpy \
+ $(BUILD)/system.mpy \
+ $(BUILD)/checkNet.mpy \
+ $(BUILD)/ntptime.mpy \
+ $(BUILD)/dataCall.mpy \
+ $(BUILD)/log.mpy \
+ $(BUILD)/request.mpy \
+ $(BUILD)/umqtt.mpy \
+ $(BUILD)/ql_fs.mpy \
+ $(BUILD)/app_fota_mount.mpy \
+ $(BUILD)/app_fota_download.mpy \
+ $(BUILD)/checksum.mpy \
+ $(BUILD)/file_crc32.mpy \
+ $(BUILD)/app_fota_updater.mpy \
+ $(BUILD)/app_fota.mpy \
+ $(BUILD)/backup_restore.mpy \
+ $(BUILD)/queue.mpy \
+ $(BUILD)/sys_bus.mpy \
+ $(BUILD)/event_message.mpy \
+ $(BUILD)/bak_util.mpy \
+ $(BUILD)/cellLocator.mpy \
+ $(BUILD)/ftplib.mpy \
+ $(BUILD)/ftplibtls.mpy \
+ $(BUILD)/uwebsocket.mpy \
+ $(BUILD)/uping.mpy \
+ $(BUILD)/ymodem.mpy \
+
+else ifeq ($(strip $(PLAT)),Qualcomm)
+frozen_mpy_list = $(BUILD)/_boot_Qualcomm.mpy \
+ $(BUILD)/system.mpy \
+ $(BUILD)/checkNet.mpy \
+ $(BUILD)/ntptime.mpy \
+ $(BUILD)/dataCall.mpy \
+ $(BUILD)/umqtt.mpy \
+ $(BUILD)/log.mpy \
+ $(BUILD)/request.mpy \
+ $(BUILD)/ql_fs.mpy \
+ $(BUILD)/app_fota_download.mpy \
+ $(BUILD)/checksum.mpy \
+ $(BUILD)/file_crc32.mpy \
+ $(BUILD)/app_fota_mount.mpy \
+ $(BUILD)/app_fota_updater.mpy \
+ $(BUILD)/app_fota.mpy \
+ $(BUILD)/backup_restore.mpy \
+ $(BUILD)/queue.mpy \
+ $(BUILD)/sys_bus.mpy \
+ $(BUILD)/event_message.mpy \
+ $(BUILD)/bak_util.mpy \
+ $(BUILD)/uwebsocket.mpy \
+ $(BUILD)/uping.mpy \
+ $(BUILD)/ymodem.mpy \
+
+else ifeq ($(strip $(PLAT)),ASR_1606)
+ifeq ($(strip $(BOARD)),$(filter $(strip $(BOARD)),EC600MCN_CC EC800MCN_CC EC600MCN_CC_EXT EC600MCN_LF_SLPOC))
+frozen_mpy_list = $(BUILD)/_boot.mpy \
+ $(BUILD)/system.mpy \
+ $(BUILD)/dataCall.mpy \
+ $(BUILD)/umqtt.mpy \
+ $(BUILD)/queue.mpy \
+ $(BUILD)/log.mpy \
+ $(BUILD)/request.mpy \
+ $(BUILD)/ql_fs.mpy \
+ $(BUILD)/app_fota_mount.mpy \
+ $(BUILD)/app_fota_download.mpy \
+ $(BUILD)/checksum.mpy \
+ $(BUILD)/file_crc32.mpy \
+ $(BUILD)/app_fota_updater.mpy \
+ $(BUILD)/app_fota.mpy \
+ $(BUILD)/backup_restore.mpy \
+ $(BUILD)/ntptime.mpy \
+ $(BUILD)/checkNet.mpy \
+ $(BUILD)/ymodem.mpy
+
+else ifeq ($(strip $(BOARD)),$(filter $(strip $(BOARD)),EC600MCN_CC_EXT_TTS))
+frozen_mpy_list = $(BUILD)/_boot.mpy \
+ $(BUILD)/dataCall.mpy \
+ $(BUILD)/file_crc32.mpy \
+ $(BUILD)/ntptime.mpy \
+ $(BUILD)/ymodem.mpy
+else
+frozen_mpy_list = $(BUILD)/_boot.mpy \
+ $(BUILD)/umqtt.mpy \
+ $(BUILD)/ntptime.mpy \
+ $(BUILD)/request.mpy \
+ $(BUILD)/log.mpy \
+ $(BUILD)/aLiYun.mpy \
+ $(BUILD)/hmac.mpy \
+ $(BUILD)/hashlib.mpy \
+ $(BUILD)/base64.mpy \
+ $(BUILD)/TenCentYun.mpy \
+ $(BUILD)/file_sha256.mpy \
+ $(BUILD)/checksum.mpy \
+ $(BUILD)/checkNet.mpy \
+ $(BUILD)/dataCall.mpy \
+ $(BUILD)/ql_fs.mpy \
+ $(BUILD)/app_fota_mount.mpy \
+ $(BUILD)/app_fota_download.mpy\
+ $(BUILD)/app_fota_updater.mpy \
+ $(BUILD)/app_fota.mpy \
+ $(BUILD)/backup_restore.mpy \
+ $(BUILD)/file_crc32.mpy \
+ $(BUILD)/system.mpy \
+ $(BUILD)/gnss.mpy \
+ $(BUILD)/unzip.mpy \
+ $(BUILD)/queue.mpy \
+ $(BUILD)/sys_bus.mpy \
+ $(BUILD)/event_message.mpy \
+ $(BUILD)/hls.mpy \
+ $(BUILD)/wifilocator.mpy \
+ $(BUILD)/cellLocator.mpy \
+ $(BUILD)/bak_util.mpy \
+ $(BUILD)/uwebsocket.mpy \
+ $(BUILD)/uping.mpy \
+ $(BUILD)/ymodem.mpy \
+ $(BUILD)/alarm.mpy \
+ $(BUILD)/code.mpy \
+ $(BUILD)/common.mpy \
+ $(BUILD)/constants.mpy \
+ $(BUILD)/EventMesh.mpy \
+ $(BUILD)/lcd.mpy \
+ $(BUILD)/mgr.mpy \
+ $(BUILD)/protocol.mpy \
+ $(BUILD)/ui.mpy \
+ $(BUILD)/ui_main_menu.mpy \
+ $(BUILD)/ui_WatchFaceScreen.mpy \
+ $(BUILD)/ui_health.mpy \
+ $(BUILD)/main_init.mpy \
+ $(BUILD)/versions.mpy \
+ $(BUILD)/motor.mpy \
+ $(BUILD)/ai_VC.mpy \
+
+endif
+
+else ifeq ($(strip $(PLAT)),Unisoc_8850)
+ifeq ($(strip $(BOARD)),$(filter $(strip $(BOARD)),EC600GCN_LD EC600GCN_LD_YM EC800GCN_LD EC800GCN_LD_HRXM))
+frozen_mpy_list = $(BUILD)/_boot.mpy \
+ $(BUILD)/umqtt.mpy \
+ $(BUILD)/ntptime.mpy \
+ $(BUILD)/request.mpy \
+ $(BUILD)/log.mpy \
+ $(BUILD)/checksum.mpy \
+ $(BUILD)/checkNet.mpy \
+ $(BUILD)/dataCall.mpy \
+ $(BUILD)/ql_fs.mpy \
+ $(BUILD)/app_fota_mount.mpy \
+ $(BUILD)/app_fota_download.mpy\
+ $(BUILD)/app_fota_updater.mpy \
+ $(BUILD)/app_fota.mpy \
+ $(BUILD)/backup_restore.mpy \
+ $(BUILD)/file_crc32.mpy \
+ $(BUILD)/system.mpy \
+ $(BUILD)/queue.mpy \
+ $(BUILD)/sys_bus.mpy \
+ $(BUILD)/event_message.mpy \
+ $(BUILD)/bak_util.mpy \
+ $(BUILD)/ymodem.mpy \
+
+else
+frozen_mpy_list = $(BUILD)/_boot.mpy \
+ $(BUILD)/umqtt.mpy \
+ $(BUILD)/ntptime.mpy \
+ $(BUILD)/request.mpy \
+ $(BUILD)/log.mpy \
+ $(BUILD)/aLiYun.mpy \
+ $(BUILD)/hmac.mpy \
+ $(BUILD)/hashlib.mpy \
+ $(BUILD)/base64.mpy \
+ $(BUILD)/TenCentYun.mpy \
+ $(BUILD)/file_sha256.mpy \
+ $(BUILD)/checksum.mpy \
+ $(BUILD)/checkNet.mpy \
+ $(BUILD)/dataCall.mpy \
+ $(BUILD)/ql_fs.mpy \
+ $(BUILD)/app_fota_mount.mpy \
+ $(BUILD)/app_fota_download.mpy\
+ $(BUILD)/app_fota_updater.mpy \
+ $(BUILD)/app_fota.mpy \
+ $(BUILD)/backup_restore.mpy \
+ $(BUILD)/file_crc32.mpy \
+ $(BUILD)/system.mpy \
+ $(BUILD)/gnss.mpy \
+ $(BUILD)/unzip.mpy \
+ $(BUILD)/queue.mpy \
+ $(BUILD)/sys_bus.mpy \
+ $(BUILD)/event_message.mpy \
+ $(BUILD)/hls.mpy \
+ $(BUILD)/wifilocator.mpy \
+ $(BUILD)/bak_util.mpy \
+ $(BUILD)/ftplib.mpy \
+ $(BUILD)/ftplibtls.mpy \
+ $(BUILD)/uwebsocket.mpy \
+ $(BUILD)/uping.mpy \
+ $(BUILD)/ymodem.mpy \
+
+endif
+
+else ifeq ($(strip $(PLAT)),EIGEN)
+ifeq ($(strip $(BOARD)),$(filter $(strip $(BOARD)),EC800ECN_LC_WDF))
+frozen_mpy_list = $(BUILD)/_boot_WDF.mpy \
+ $(BUILD)/umqtt.mpy \
+ $(BUILD)/dataCall.mpy \
+ $(BUILD)/log.mpy \
+ $(BUILD)/request.mpy \
+ $(BUILD)/aLiYun.mpy \
+ $(BUILD)/hmac.mpy \
+ $(BUILD)/hashlib.mpy \
+ $(BUILD)/ntptime.mpy \
+ $(BUILD)/checksum.mpy \
+ $(BUILD)/checkNet.mpy \
+ $(BUILD)/ql_fs.mpy \
+ $(BUILD)/app_fota_mount.mpy \
+ $(BUILD)/app_fota_download.mpy\
+ $(BUILD)/app_fota_updater.mpy \
+ $(BUILD)/app_fota.mpy \
+ $(BUILD)/backup_restore.mpy \
+ $(BUILD)/file_crc32.mpy \
+ $(BUILD)/system.mpy \
+ $(BUILD)/queue.mpy \
+ $(BUILD)/sys_bus.mpy \
+ $(BUILD)/event_message.mpy \
+ $(BUILD)/bak_util.mpy \
+ $(BUILD)/ftplib.mpy \
+ $(BUILD)/ftplibtls.mpy \
+ $(BUILD)/ymodem.mpy \
+
+else
+frozen_mpy_list = $(BUILD)/_boot.mpy \
+ $(BUILD)/umqtt.mpy \
+ $(BUILD)/dataCall.mpy \
+ $(BUILD)/log.mpy \
+ $(BUILD)/request.mpy \
+ $(BUILD)/aLiYun.mpy \
+ $(BUILD)/hmac.mpy \
+ $(BUILD)/hashlib.mpy \
+ $(BUILD)/ntptime.mpy \
+ $(BUILD)/checksum.mpy \
+ $(BUILD)/checkNet.mpy \
+ $(BUILD)/ql_fs.mpy \
+ $(BUILD)/app_fota_mount.mpy \
+ $(BUILD)/app_fota_download.mpy\
+ $(BUILD)/app_fota_updater.mpy \
+ $(BUILD)/app_fota.mpy \
+ $(BUILD)/backup_restore.mpy \
+ $(BUILD)/file_crc32.mpy \
+ $(BUILD)/system.mpy \
+ $(BUILD)/queue.mpy \
+ $(BUILD)/sys_bus.mpy \
+ $(BUILD)/event_message.mpy \
+ $(BUILD)/bak_util.mpy \
+ $(BUILD)/ftplib.mpy \
+ $(BUILD)/ftplibtls.mpy \
+ $(BUILD)/cellLocator.mpy \
+ $(BUILD)/ymodem.mpy \
+
+endif
+
+else ifeq ($(strip $(PLAT)),ECR6600)
+frozen_mpy_list = $(BUILD)/_boot_WIFI.mpy \
+ $(BUILD)/umqtt.mpy \
+ $(BUILD)/request.mpy \
+ $(BUILD)/ql_fs.mpy \
+ $(BUILD)/queue.mpy \
+ $(BUILD)/sys_bus.mpy \
+
+else
+ifeq ($(strip $(BOARD)),$(filter $(strip $(BOARD)),EC600UEU_AB_POC))
+frozen_mpy_list = $(BUILD)/_boot.mpy \
+ $(BUILD)/ntptime.mpy \
+ $(BUILD)/log.mpy \
+ $(BUILD)/file_sha256.mpy \
+ $(BUILD)/checksum.mpy \
+ $(BUILD)/checkNet.mpy \
+ $(BUILD)/dataCall.mpy \
+ $(BUILD)/ql_fs.mpy \
+ $(BUILD)/app_fota_mount.mpy \
+ $(BUILD)/app_fota_download.mpy\
+ $(BUILD)/app_fota_updater.mpy \
+ $(BUILD)/app_fota.mpy \
+ $(BUILD)/backup_restore.mpy \
+ $(BUILD)/file_crc32.mpy \
+ $(BUILD)/system.mpy \
+ $(BUILD)/queue.mpy \
+ $(BUILD)/bak_util.mpy \
+ $(BUILD)/ymodem.mpy
+else
+frozen_mpy_list = $(BUILD)/_boot.mpy \
+ $(BUILD)/umqtt.mpy \
+ $(BUILD)/ntptime.mpy \
+ $(BUILD)/request.mpy \
+ $(BUILD)/log.mpy \
+ $(BUILD)/aLiYun.mpy \
+ $(BUILD)/hmac.mpy \
+ $(BUILD)/hashlib.mpy \
+ $(BUILD)/base64.mpy \
+ $(BUILD)/TenCentYun.mpy \
+ $(BUILD)/file_sha256.mpy \
+ $(BUILD)/checksum.mpy \
+ $(BUILD)/checkNet.mpy \
+ $(BUILD)/dataCall.mpy \
+ $(BUILD)/ql_fs.mpy \
+ $(BUILD)/app_fota_mount.mpy \
+ $(BUILD)/app_fota_download.mpy\
+ $(BUILD)/app_fota_updater.mpy \
+ $(BUILD)/app_fota.mpy \
+ $(BUILD)/backup_restore.mpy \
+ $(BUILD)/file_crc32.mpy \
+ $(BUILD)/system.mpy \
+ $(BUILD)/gnss.mpy \
+ $(BUILD)/unzip.mpy \
+ $(BUILD)/queue.mpy \
+ $(BUILD)/sys_bus.mpy \
+ $(BUILD)/event_message.mpy \
+ $(BUILD)/hls.mpy \
+ $(BUILD)/wifilocator.mpy \
+ $(BUILD)/bak_util.mpy \
+ $(BUILD)/ftplib.mpy \
+ $(BUILD)/ftplibtls.mpy \
+ $(BUILD)/uwebsocket.mpy \
+ $(BUILD)/uping.mpy \
+ $(BUILD)/ymodem.mpy
+endif
+endif
+
+$(BUILD)/_frozen_mpy.c: $(frozen_mpy_list) $(HEADER_BUILD)/qstrdefs.generated.h
+ @$(ECHO) "MISC freezing bytecode"
+ $(Q)$(MPY_TOOL) -f -q $(HEADER_BUILD)/qstrdefs.preprocessed.h $(frozen_mpy_list) > $@
+
+$(BUILD):
+ $(Q)echo creating directory: $@
+ -$(Q)$(MKDIR) $@
+
+all:$(BUILD) $(HEADER_BUILD)/qstrdefs.generated.h $(HEADER_BUILD)/moduledefs.h $(HEADER_BUILD)/compressed.data.h $(BUILD)/_frozen_mpy.c
+
+clean:
+ @echo ----- cleaning microPython private target
+ @rm -rf $(HEADER_BUILD)
+ @rm -rf $(BUILD)
+ @echo ----- done.
--- /dev/null
+import utime
+import audio
+from machine import Pin
+import osTimer
+import _thread
+from queue import Queue
+#import usr.uwebsocket as uwebsocket
+import uwebsocket
+import usys
+import EventMesh
+import constants
+import ujson
+import lvgl as lv
+import urandom
+import uhashlib
+import ubinascii
+import gc
+import uos
+from ui import style_font_youyuan_20,style_screen,Screen,style_img
+LCD_SIZE_H = 320
+LCD_SIZE_W = 240
+style_font_youyuan_ai_20 = lv.style_t()
+style_font_youyuan_ai_20.init()
+style_font_youyuan_ai_20.set_text_color(lv.color_make(253, 82, 19))
+style_font_youyuan_ai_20.set_text_font_v2("font_28.bin",28,0)
+#length长度内,返回string句号或逗号的分割字符串
+def split_string(string,start,end):
+ count = string.find('\n',start,end)
+ if count != -1:
+ return string[:count+1]
+ count = string.find(',',start,end)
+ if count != -1:
+ return string[:count+1]
+ count = string.find('.',start,end)
+ if count != -1:
+ return string[:count+1]
+ count = string.find('!',start,end)
+ if count != -1:
+ return string[:count+1]
+ count = string.find('?',start,end)
+ if count != -1:
+ return string[:count+1]
+
+
+ count = string.find(',',start,end)
+ if count != -1:
+ return string[:count+len(',')]
+ count = string.find('。',start,end)
+ if count != -1:
+ return string[:count+len('。')]
+ count = string.find('、',start,end)
+ if count != -1:
+ return string[:count+len('、')]
+
+ count = string.find('!',start,end)
+ if count != -1:
+ return string[:count+len('!')]
+ count = string.find('?',start,end)
+ if count != -1:
+ return string[:count+len('?')]
+ return ''
+def sub_utf8_String(string,length):
+ if length >= len(string):
+ return string
+ i = 0
+ p = 0
+ while True:
+ ch = ord(string[i])
+ #1111110x
+ if ch >= 252:
+ p = p + 6
+ #111110xx
+ elif ch >= 248:
+ p = p + 5
+ #11110xxx
+ elif ch >= 240:
+ p = p + 4
+ #1110xxxx
+ elif ch >= 224:
+ p = p + 3
+ #110xxxxx
+ elif ch >= 192:
+ p = p + 2
+ else:
+ p = p + 1
+ if p >= length:
+ break
+ else:
+ i = p
+
+ return string[0:i]
+
+style_AI_btn = lv.style_t()
+style_AI_btn.init()
+style_AI_btn.set_bg_color(lv.color_make(0x1E, 0x26, 0xff))
+style_AI_btn.set_border_width(0)
+style_AI_btn.set_shadow_opa(0)
+
+style_common_bg_rect_btn_pressed = lv.style_t()
+style_common_bg_rect_btn_pressed.init()
+style_common_bg_rect_btn_pressed.set_bg_color(lv.color_make(0x1E, 0x26, 0xff))
+style_common_bg_rect_btn_pressed.set_bg_opa(100)
+style_common_bg_rect_btn_pressed.set_border_width(0)
+style_common_bg_rect_btn_pressed.set_shadow_opa(0)
+
+style_font_20_ai_white = lv.style_t()
+style_font_20_ai_white.init()
+style_font_20_ai_white.set_radius(0)
+style_font_20_ai_white.set_bg_color(lv.color_make(0xff, 0xff, 0xff))
+#style_font_20_ai_white.set_bg_grad_color(lv.color_make(0x21,0x95,0xf6))
+style_font_20_ai_white.set_bg_grad_dir(lv.GRAD_DIR.NONE)
+style_font_20_ai_white.set_bg_opa(255)
+style_font_20_ai_white.set_text_color(lv.color_make(0x00, 0x00, 0x00))
+# style_font_20_ai_white.set_text_font_v2("font_28.bin",28,0)
+style_font_20_ai_white.set_text_font_v2("font_28.bin",28,0)
+
+style_font_20_ai_green = lv.style_t()
+style_font_20_ai_green.init()
+style_font_20_ai_green.set_radius(5)
+style_font_20_ai_green.set_bg_color(lv.color_make(0x00, 0xff, 0x2a))
+#style_font_20_ai_green.set_bg_grad_color(lv.color_make(0x21,0x95,0xf6))
+style_font_20_ai_green.set_bg_grad_dir(lv.GRAD_DIR.NONE)
+style_font_20_ai_green.set_bg_opa(255)
+style_font_20_ai_green.set_text_color(lv.color_make(0xff, 0xff, 0xff))
+# style_font_20_ai_green.set_text_font_v2("font_28.bin",28,0)
+style_font_20_ai_green.set_text_font_v2("font_28.bin",28,0)
+
+AI_screen = lv.obj()
+print("AI_screen")
+AI_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+AI_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+AI_talk_end_screen = lv.obj(AI_screen)
+AI_talk_end_screen.set_pos(0, 0)
+AI_talk_end_screen.set_size(LCD_SIZE_W,LCD_SIZE_H)
+print("AI_talk_end_screen")
+AI_talk_end_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+AI_talk_end_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+AI_talk_end_screen.add_flag(lv.obj.FLAG.HIDDEN) #
+
+AI_screen_list_screen_title = lv.obj(AI_talk_end_screen)
+AI_screen_list_screen_title.set_pos(0, 0)
+AI_screen_list_screen_title.set_size(LCD_SIZE_W,60)
+AI_screen_list_screen_title.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+AI_screen_list_screen_title.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+# al_success_title1 = lv.label(AI_screen_list_screen_title)
+# al_success_title1.set_pos(0, 5)
+# al_success_title1.set_size(LCD_SIZE_W, 25)
+# al_success_title1.set_text("AI智能助手")
+# al_success_title1.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+# al_success_title1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+# AI_press_btn = lv.btn(AI_talk_end_screen)
+# AI_press_btn.set_pos(10, (LCD_SIZE_H-60)+4)
+# AI_press_btn.set_size(LCD_SIZE_W-20, 56)
+# AI_press_btn.add_style(style_AI_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+# AI_press_btn.add_style(style_common_bg_rect_btn_pressed, lv.PART.MAIN | lv.STATE.PRESSED)
+# AI_press_btn.set_style_radius(30,0)
+
+AI_talk_end_bt_screen = lv.obj(AI_talk_end_screen)
+AI_talk_end_bt_screen.set_pos(0, LCD_SIZE_H-60)
+AI_talk_end_bt_screen.set_size(LCD_SIZE_W,60)
+print("AI_talk_end_bt_screen")
+AI_talk_end_bt_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+AI_talk_end_bt_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+al_talk_end_screen_icon1 = lv.img(AI_talk_end_bt_screen)
+al_talk_end_screen_icon1.set_size(26,26)
+al_talk_end_screen_icon1.set_pos(10,5)
+al_talk_end_screen_icon1.add_flag(lv.obj.FLAG.CLICKABLE)
+al_talk_end_screen_icon1.set_src("U:/static/AI/ai_result_can_start.png")
+al_talk_end_screen_icon1.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+al_talk_end_screen_cancel_bt = lv.label(AI_talk_end_bt_screen)
+al_talk_end_screen_cancel_bt.set_text(" ")
+al_talk_end_screen_cancel_bt.set_size(44, 60)
+al_talk_end_screen_cancel_bt.set_pos(0,0)
+al_talk_end_screen_cancel_bt.add_flag(lv.obj.FLAG.CLICKABLE)
+
+al_talk_end_screen_icon2 = lv.label(AI_talk_end_bt_screen)
+al_talk_end_screen_icon2.set_pos(int(44),int(5))
+al_talk_end_screen_icon2.set_size(200,60)
+al_talk_end_screen_icon2.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+al_talk_end_screen_icon2.set_text("继续对话")
+al_talk_end_screen_icon2.set_long_mode(lv.label.LONG.WRAP)
+al_talk_end_screen_icon2.add_flag(lv.obj.FLAG.CLICKABLE)
+# create style style_screen_label_1_main_main_default
+al_talk_screen_icon_main_main_default = lv.style_t()
+al_talk_screen_icon_main_main_default.init()
+al_talk_screen_icon_main_main_default.set_radius(30)
+al_talk_screen_icon_main_main_default.set_bg_color(lv.color_make(0x19,0x19,0x19))
+al_talk_screen_icon_main_main_default.set_bg_grad_color(lv.color_make(0x19,0x19,0x19))
+al_talk_screen_icon_main_main_default.set_bg_grad_dir(lv.GRAD_DIR.NONE)
+al_talk_screen_icon_main_main_default.set_bg_opa(255)
+al_talk_screen_icon_main_main_default.set_text_color(lv.color_make(0xff,0xff,0xff))
+al_talk_screen_icon_main_main_default.set_text_font_v2("font_28.bin",28,0)
+al_talk_screen_icon_main_main_default.set_text_letter_space(2)
+al_talk_screen_icon_main_main_default.set_text_line_space(0)
+al_talk_screen_icon_main_main_default.set_text_align(lv.TEXT_ALIGN.CENTER)
+al_talk_screen_icon_main_main_default.set_pad_left(0)
+al_talk_screen_icon_main_main_default.set_pad_right(0)
+al_talk_screen_icon_main_main_default.set_pad_top(3)
+al_talk_screen_icon_main_main_default.set_pad_bottom(0)
+
+# add style for screen_label_1
+al_talk_end_screen_icon2.add_style(al_talk_screen_icon_main_main_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+style_green_screen = lv.style_t()
+style_green_screen.init()
+style_green_screen.set_radius(5)
+style_green_screen.set_bg_color(lv.color_make(79,195,76))
+style_green_screen.set_bg_opa(255)
+style_green_screen.set_border_width(0)
+style_green_screen.set_pad_left(0)
+style_green_screen.set_pad_right(0)
+style_green_screen.set_pad_top(0)
+style_green_screen.set_pad_bottom(0)
+
+style_font_28_green_bg_gray = lv.style_t()
+style_font_28_green_bg_gray.init()
+style_font_28_green_bg_gray.set_text_color(lv.color_make(255, 255, 255)) #字体文本颜色
+style_font_28_green_bg_gray.set_text_font_v2("font_28.bin",28,0)
+style_gray_screen = lv.style_t()
+style_gray_screen.init()
+style_gray_screen.set_radius(5)
+style_gray_screen.set_bg_color(lv.color_make(66,66,66)) #灰色背景
+style_gray_screen.set_bg_opa(255)
+style_gray_screen.set_border_width(0)
+style_gray_screen.set_pad_left(0)
+style_gray_screen.set_pad_right(0)
+style_gray_screen.set_pad_top(0)
+style_gray_screen.set_pad_bottom(0)
+
+#灰色背景黑色字
+style_font_28_black_bg_gray = lv.style_t()
+style_font_28_black_bg_gray.init()
+style_font_28_black_bg_gray.set_text_color(lv.color_make(153, 153, 153)) #字体文本颜色
+style_font_28_black_bg_gray.set_text_font_v2("font_28.bin",28,0)
+
+style_wechat_r_btn = lv.style_t()
+style_wechat_r_btn.init()
+style_wechat_r_btn.set_radius(5)
+style_wechat_r_btn.set_bg_opa(255)
+style_wechat_r_btn.set_border_width(0)
+style_wechat_r_btn.set_pad_left(0)
+style_wechat_r_btn.set_pad_right(0)
+style_wechat_r_btn.set_pad_top(0)
+style_wechat_r_btn.set_pad_bottom(0)
+style_wechat_r_btn.set_bg_color(lv.color_make(66,66,66))
+style_wechat_r_btn.set_border_width(0)
+style_wechat_r_btn.set_shadow_opa(0)
+#列表obj
+style_wechat_s_btn = lv.style_t()
+style_wechat_s_btn.init()
+style_wechat_s_btn.set_radius(5)
+style_wechat_s_btn.set_bg_opa(255)
+style_wechat_s_btn.set_border_width(0)
+style_wechat_s_btn.set_pad_left(0)
+style_wechat_s_btn.set_pad_right(0)
+style_wechat_s_btn.set_pad_top(0)
+style_wechat_s_btn.set_pad_bottom(0)
+style_wechat_s_btn.set_bg_color(lv.color_make(79,195,76))
+style_wechat_s_btn.set_shadow_opa(0)
+
+AI_end_screen_list_screen = lv.obj(AI_talk_end_screen)
+AI_end_screen_list_screen.set_pos(5, 0)
+AI_end_screen_list_screen.set_size(LCD_SIZE_W-10,LCD_SIZE_H-60)
+AI_end_screen_list_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+AI_end_screen_list_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+AI_end_screen_list_screen.set_flex_flow(lv.FLEX_FLOW.COLUMN)#自动排成一列对齐
+
+AI_end_screen_list_detail_screen = lv.obj(AI_end_screen_list_screen)
+AI_end_screen_list_detail_screen.set_pos(0, 5)
+AI_end_screen_list_detail_screen.set_size(LCD_SIZE_W-10,lv.SIZE.CONTENT)
+AI_end_screen_list_detail_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+#ASR结果1
+AI_end_screen_list_detail_screen1 = lv.obj(AI_end_screen_list_detail_screen)
+AI_end_screen_list_detail_screen1.set_pos(20,10)
+AI_end_screen_list_detail_screen1.set_size(LCD_SIZE_W-50,lv.SIZE.CONTENT)
+AI_end_screen_list_detail_screen1.add_style(style_wechat_s_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+AI_listen_text = lv.label(AI_end_screen_list_detail_screen1)
+AI_listen_text.set_pos(5, 5)
+AI_listen_text.set_size(120, lv.SIZE.CONTENT)
+AI_listen_text.set_text(" ")
+AI_listen_text.set_long_mode(lv.label.LONG.WRAP)
+AI_listen_text.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+AI_listen_text.add_style(style_font_28_green_bg_gray, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+#chat结果1
+msg_detail_cont_obj = lv.obj(AI_end_screen_list_screen)
+msg_detail_cont_obj.set_pos(0, 0)
+msg_detail_cont_obj.set_size(LCD_SIZE_W-10,lv.SIZE.CONTENT)
+msg_detail_cont_obj.add_style(style_wechat_r_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+AI_label = lv.label(msg_detail_cont_obj)
+AI_label.set_pos(5, 0)
+AI_label.set_size(LCD_SIZE_W-10-5, lv.SIZE.CONTENT)
+AI_label.set_long_mode(lv.label.LONG.WRAP)
+AI_label.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+AI_label.add_style(style_font_28_black_bg_gray, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+#222222222222222222222222222222222222
+AI_end_screen_list_screen2 = lv.obj(AI_talk_end_screen)
+AI_end_screen_list_screen2.set_pos(5, 5)
+AI_end_screen_list_screen2.set_size(LCD_SIZE_W-5,LCD_SIZE_H-60)
+AI_end_screen_list_screen2.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+AI_end_screen_list_screen2.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+AI_end_screen_list_screen2.set_flex_flow(lv.FLEX_FLOW.COLUMN)#自动排成一列对齐
+
+#chat结果2
+msg_detail_cont_obj2 = lv.obj(AI_end_screen_list_screen2)
+msg_detail_cont_obj2.set_pos(0, 0)
+msg_detail_cont_obj2.set_size(LCD_SIZE_W-10,lv.SIZE.CONTENT)
+msg_detail_cont_obj2.add_style(style_wechat_r_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+AI_label2 = lv.label(msg_detail_cont_obj2)
+AI_label2.set_pos(5, 5)
+AI_label2.set_size(LCD_SIZE_W-10-5, lv.SIZE.CONTENT)
+AI_label2.set_long_mode(lv.label.LONG.WRAP)
+AI_label2.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+AI_label2.add_style(style_font_28_black_bg_gray, lv.PART.MAIN | lv.STATE.DEFAULT)
+AI_end_screen_list_screen2.add_flag(lv.obj.FLAG.HIDDEN) #隐藏2
+
+#开始对话
+AI_talk_screen = lv.obj(AI_screen)
+print("AI_talk_screen")
+AI_talk_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+AI_talk_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+AI_talk_screen.set_pos(0, 0)
+AI_talk_screen.set_size(LCD_SIZE_W, LCD_SIZE_H)
+
+
+al_talk_screen_title1 = lv.label(AI_talk_screen)
+al_talk_screen_title1.set_pos(0, 10)
+al_talk_screen_title1.set_size(LCD_SIZE_W, 40)
+al_talk_screen_title1.set_text("AI智能助手")
+al_talk_screen_title1.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+al_talk_screen_title1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+al_talk_screen_icon1 = lv.img(AI_talk_screen)
+al_talk_screen_icon1.set_size(75,24)
+al_talk_screen_icon1.set_pos((LCD_SIZE_W-75)//2,45)
+al_talk_screen_icon1.set_src("U:/static/AI/AI_LISTEN_GIF001.png")
+al_talk_screen_icon1.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+al_talk_screen_icon = lv.label(AI_talk_screen)
+al_talk_screen_icon.set_pos(int(4),int(LCD_SIZE_H-60))
+al_talk_screen_icon.set_size(230,60)
+al_talk_screen_icon.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+al_talk_screen_icon.set_text("开始对话")
+al_talk_screen_icon.set_long_mode(lv.label.LONG.WRAP)
+al_talk_screen_icon.add_flag(lv.obj.FLAG.CLICKABLE)
+# create style style_screen_label_1_main_main_default
+al_talk_screen_icon_main_main_default = lv.style_t()
+al_talk_screen_icon_main_main_default.init()
+al_talk_screen_icon_main_main_default.set_radius(30)
+al_talk_screen_icon_main_main_default.set_bg_color(lv.color_make(0x37,0xbf,0x12))
+al_talk_screen_icon_main_main_default.set_bg_grad_color(lv.color_make(0x37,0xbf,0x12))
+al_talk_screen_icon_main_main_default.set_bg_grad_dir(lv.GRAD_DIR.NONE)
+al_talk_screen_icon_main_main_default.set_bg_opa(255)
+al_talk_screen_icon_main_main_default.set_text_color(lv.color_make(0xff,0xff,0xff))
+al_talk_screen_icon_main_main_default.set_text_font_v2("font_28.bin",28,0)
+al_talk_screen_icon_main_main_default.set_text_letter_space(2)
+al_talk_screen_icon_main_main_default.set_text_line_space(0)
+al_talk_screen_icon_main_main_default.set_text_align(lv.TEXT_ALIGN.CENTER)
+al_talk_screen_icon_main_main_default.set_pad_left(0)
+al_talk_screen_icon_main_main_default.set_pad_right(0)
+al_talk_screen_icon_main_main_default.set_pad_top(3)
+al_talk_screen_icon_main_main_default.set_pad_bottom(0)
+
+# add style for screen_label_1
+al_talk_screen_icon.add_style(al_talk_screen_icon_main_main_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+#没有网络数据
+AI_no_net_screen = lv.obj(AI_screen)
+print("AI_no_net_screen")
+AI_no_net_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+AI_no_net_screen.set_pos(0, 0)
+AI_no_net_screen.set_size(LCD_SIZE_W, LCD_SIZE_H)
+AI_no_net_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+AI_no_net_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+
+al_no_sim_popup_screen_title1 = lv.label(AI_no_net_screen)
+al_no_sim_popup_screen_title1.set_pos(0, 5)
+al_no_sim_popup_screen_title1.set_size(LCD_SIZE_W, 20)
+al_no_sim_popup_screen_title1.set_text("AI智能助手")
+al_no_sim_popup_screen_title1.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+al_no_sim_popup_screen_title1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+al_no_sim_popup_screen_icon = lv.img(AI_no_net_screen)
+al_no_sim_popup_screen_icon.set_size(22,22)
+al_no_sim_popup_screen_icon.set_pos((LCD_SIZE_W-22)//2,30)
+al_no_sim_popup_screen_icon.set_src("U:/static/AI/ai_warning.png")
+al_no_sim_popup_screen_icon.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+al_no_sim_popup_screen_title2 = lv.label(AI_no_net_screen)
+al_no_sim_popup_screen_title2.set_pos(0, 56)
+al_no_sim_popup_screen_title2.set_size(LCD_SIZE_W, 20)
+al_no_sim_popup_screen_title2.set_text("启动失败")
+al_no_sim_popup_screen_title2.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+al_no_sim_popup_screen_title2.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+al_no_sim_popup_screen_title3 = lv.label(AI_no_net_screen)
+al_no_sim_popup_screen_title3.set_pos(0, 76)
+al_no_sim_popup_screen_title3.set_size(LCD_SIZE_W, 20)
+al_no_sim_popup_screen_title3.set_text("请先开启移动数据")
+al_no_sim_popup_screen_title3.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+al_no_sim_popup_screen_title3.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+al_no_sim_popup_screen_icon1 = lv.label(AI_no_net_screen)
+al_no_sim_popup_screen_icon1.set_pos(int(4),int(95))
+al_no_sim_popup_screen_icon1.set_size(120,25)
+al_no_sim_popup_screen_icon1.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+al_no_sim_popup_screen_icon1.set_text("确定")
+al_no_sim_popup_screen_icon1.set_long_mode(lv.label.LONG.WRAP)
+al_no_sim_popup_screen_icon1.add_flag(lv.obj.FLAG.CLICKABLE)
+# create style style_screen_label_1_main_main_default
+al_talk_screen_icon_main_main_default = lv.style_t()
+al_talk_screen_icon_main_main_default.init()
+al_talk_screen_icon_main_main_default.set_radius(30)
+al_talk_screen_icon_main_main_default.set_bg_color(lv.color_make(0x19,0x19,0x19))
+al_talk_screen_icon_main_main_default.set_bg_grad_color(lv.color_make(0x19,0x19,0x19))
+al_talk_screen_icon_main_main_default.set_bg_grad_dir(lv.GRAD_DIR.NONE)
+al_talk_screen_icon_main_main_default.set_bg_opa(255)
+al_talk_screen_icon_main_main_default.set_text_color(lv.color_make(0xff,0xff,0xff))
+al_talk_screen_icon_main_main_default.set_text_font_v2("font_28.bin",28,0)
+al_talk_screen_icon_main_main_default.set_text_letter_space(2)
+al_talk_screen_icon_main_main_default.set_text_line_space(0)
+al_talk_screen_icon_main_main_default.set_text_align(lv.TEXT_ALIGN.CENTER)
+al_talk_screen_icon_main_main_default.set_pad_left(0)
+al_talk_screen_icon_main_main_default.set_pad_right(0)
+al_talk_screen_icon_main_main_default.set_pad_top(3)
+al_talk_screen_icon_main_main_default.set_pad_bottom(0)
+
+# add style for screen_label_1
+al_no_sim_popup_screen_icon1.add_style(al_talk_screen_icon_main_main_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+#正在聆听
+AI_listen_screen = lv.obj(AI_screen)
+print("AI_listen_screen")
+AI_listen_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+AI_listen_screen.set_pos(0, 0)
+AI_listen_screen.set_size(LCD_SIZE_W, LCD_SIZE_H)
+AI_listen_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+AI_listen_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+
+ai_talk_requestion_obj = lv.obj(AI_listen_screen)
+ai_talk_requestion_obj.set_pos(15, 5)
+ai_talk_requestion_obj.set_size(LCD_SIZE_W-25, 40)
+ai_talk_requestion_obj.add_style(style_green_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+al_listen_screen_title1 = lv.label(ai_talk_requestion_obj)
+al_listen_screen_title1.set_pos(0, 5)
+al_listen_screen_title1.set_size(LCD_SIZE_W-25, 60)
+al_listen_screen_title1.set_text("识别中...")
+al_listen_screen_title1.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+al_listen_screen_title1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+al_listen_screen_icon1 = lv.img(AI_listen_screen)
+al_listen_screen_icon1.set_size(75,24)
+al_listen_screen_icon1.set_pos((LCD_SIZE_W-75)//2,60)
+al_listen_screen_icon1.set_src("U:/static/AI/AI_LISTEN_GIF001.png")
+al_listen_screen_icon1.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+al_listen_screen_icon_bt = lv.label(AI_listen_screen)
+al_listen_screen_icon_bt.set_text(" ")
+al_listen_screen_icon_bt.set_size(240, 190)
+al_listen_screen_icon_bt.set_pos(0,92)
+
+al_listen_screen_title4 = lv.label(AI_listen_screen)
+al_listen_screen_title4.set_pos(0, 100)
+al_listen_screen_title4.set_size(LCD_SIZE_W, 28)
+al_listen_screen_title4.set_text("正在聆听...")
+al_listen_screen_title4.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+al_listen_screen_title4.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+#正在思考
+AI_think_screen = lv.obj(AI_screen)
+print("AI_think_screen")
+AI_think_screen.set_pos(0, 0)
+AI_think_screen.set_size(LCD_SIZE_W, LCD_SIZE_H)
+AI_think_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+AI_think_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+AI_think_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+
+al_think_screen_title1 = lv.label(AI_think_screen)
+al_think_screen_title1.set_pos(0, 5)
+al_think_screen_title1.set_size(LCD_SIZE_W, 20)
+al_think_screen_title1.set_text("正在思考...")
+al_think_screen_title1.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+al_think_screen_title1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+al_think_screen_icon = lv.img(AI_think_screen)
+al_think_screen_icon.set_size(66,66)
+al_think_screen_icon.set_pos((LCD_SIZE_W-66)//2,25)
+al_think_screen_icon.set_src("U:/static/AI/AI_THINK001.png")
+
+al_think_screen_icon.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+al_think_screen_icon1 = lv.label(AI_listen_screen)
+al_think_screen_icon1.set_pos(int(4),int(LCD_SIZE_H-70))
+al_think_screen_icon1.set_size(230,50)
+al_think_screen_icon1.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+al_think_screen_icon1.set_text("取消")
+al_think_screen_icon1.set_long_mode(lv.label.LONG.WRAP)
+al_think_screen_icon1.add_flag(lv.obj.FLAG.CLICKABLE)
+# create style style_screen_label_1_main_main_default
+al_talk_screen_icon_main_main_default = lv.style_t()
+al_talk_screen_icon_main_main_default.init()
+al_talk_screen_icon_main_main_default.set_radius(30)
+al_talk_screen_icon_main_main_default.set_bg_color(lv.color_make(0x19,0x19,0x19))
+al_talk_screen_icon_main_main_default.set_bg_grad_color(lv.color_make(0x19,0x19,0x19))
+al_talk_screen_icon_main_main_default.set_bg_grad_dir(lv.GRAD_DIR.NONE)
+al_talk_screen_icon_main_main_default.set_bg_opa(255)
+al_talk_screen_icon_main_main_default.set_text_color(lv.color_make(253, 82, 19))
+al_talk_screen_icon_main_main_default.set_text_font_v2("font_28.bin",28,0)
+al_talk_screen_icon_main_main_default.set_text_letter_space(2)
+al_talk_screen_icon_main_main_default.set_text_line_space(0)
+al_talk_screen_icon_main_main_default.set_text_align(lv.TEXT_ALIGN.CENTER)
+al_talk_screen_icon_main_main_default.set_pad_left(0)
+al_talk_screen_icon_main_main_default.set_pad_right(0)
+al_talk_screen_icon_main_main_default.set_pad_top(3)
+al_talk_screen_icon_main_main_default.set_pad_bottom(0)
+
+# add style for screen_label_1
+al_think_screen_icon1.add_style(al_talk_screen_icon_main_main_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+# #连接超时
+AI_connect_timerout_screen = lv.obj(AI_screen)
+AI_connect_timerout_screen.set_pos(0, 0)
+AI_connect_timerout_screen.set_size(LCD_SIZE_W, LCD_SIZE_H)
+print("AI_connect_timerout_screen")
+AI_connect_timerout_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+AI_connect_timerout_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+AI_connect_timerout_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+
+al_connect_timerout_title1 = lv.label(AI_connect_timerout_screen)
+al_connect_timerout_title1.set_pos(0, 5)
+al_connect_timerout_title1.set_size(LCD_SIZE_W, 20)
+al_connect_timerout_title1.set_text("AI智能助手")
+al_connect_timerout_title1.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+al_connect_timerout_title1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+al_connect_timerout_icon = lv.img(AI_connect_timerout_screen)
+al_connect_timerout_icon.set_size(22,22)
+al_connect_timerout_icon.set_pos((LCD_SIZE_W-22)//2,30)
+al_connect_timerout_icon.set_src("U:/static/AI/ai_warning.png")
+al_connect_timerout_icon.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+al_connect_timerout_title2 = lv.label(AI_connect_timerout_screen)
+al_connect_timerout_title2.set_pos(0, 56)
+al_connect_timerout_title2.set_size(LCD_SIZE_W, 20)
+al_connect_timerout_title2.set_text("连接超时")
+al_connect_timerout_title2.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+al_connect_timerout_title2.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+al_connect_timerout_title3 = lv.label(AI_connect_timerout_screen)
+al_connect_timerout_title3.set_pos(0, 76)
+al_connect_timerout_title3.set_size(LCD_SIZE_W, 20)
+al_connect_timerout_title3.set_text("请重新对话")
+al_connect_timerout_title3.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+al_connect_timerout_title3.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+al_connect_timerout_icon1 = lv.label(AI_connect_timerout_screen)
+al_connect_timerout_icon1.set_pos(int(4),int(95))
+al_connect_timerout_icon1.set_size(120,25)
+al_connect_timerout_icon1.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+al_connect_timerout_icon1.set_text("确定")
+al_connect_timerout_icon1.set_long_mode(lv.label.LONG.WRAP)
+al_connect_timerout_icon1.add_flag(lv.obj.FLAG.CLICKABLE)
+# create style style_screen_label_1_main_main_default
+al_talk_screen_icon_main_main_default = lv.style_t()
+al_talk_screen_icon_main_main_default.init()
+al_talk_screen_icon_main_main_default.set_radius(30)
+al_talk_screen_icon_main_main_default.set_bg_color(lv.color_make(0x19,0x19,0x19))
+al_talk_screen_icon_main_main_default.set_bg_grad_color(lv.color_make(0x19,0x19,0x19))
+al_talk_screen_icon_main_main_default.set_bg_grad_dir(lv.GRAD_DIR.NONE)
+al_talk_screen_icon_main_main_default.set_bg_opa(255)
+al_talk_screen_icon_main_main_default.set_text_color(lv.color_make(0xff,0xff,0xff))
+al_talk_screen_icon_main_main_default.set_text_font_v2("font_28.bin",28,0)
+al_talk_screen_icon_main_main_default.set_text_letter_space(2)
+al_talk_screen_icon_main_main_default.set_text_line_space(0)
+al_talk_screen_icon_main_main_default.set_text_align(lv.TEXT_ALIGN.CENTER)
+al_talk_screen_icon_main_main_default.set_pad_left(0)
+al_talk_screen_icon_main_main_default.set_pad_right(0)
+al_talk_screen_icon_main_main_default.set_pad_top(3)
+al_talk_screen_icon_main_main_default.set_pad_bottom(0)
+
+# add style for screen_label_1
+al_connect_timerout_icon1.add_style(al_talk_screen_icon_main_main_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+#未检测到录音
+AI_not_listen_text_screen = lv.obj(AI_screen)
+AI_not_listen_text_screen.set_pos(0, 0)
+AI_not_listen_text_screen.set_size(LCD_SIZE_W, LCD_SIZE_H)
+print("AI_not_listen_text_screen")
+AI_not_listen_text_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+AI_not_listen_text_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+AI_not_listen_text_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+
+al_not_listen_title1 = lv.label(AI_not_listen_text_screen)
+al_not_listen_title1.set_pos(0, 5)
+al_not_listen_title1.set_size(LCD_SIZE_W, 20)
+al_not_listen_title1.set_text("AI智能助手")
+al_not_listen_title1.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+al_not_listen_title1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+al_not_listen_icon = lv.img(AI_not_listen_text_screen)
+al_not_listen_icon.set_size(22,22)
+al_not_listen_icon.set_pos((LCD_SIZE_W-22)//2,30)
+al_not_listen_icon.set_src("U:/static/AI/ai_warning.png")
+al_not_listen_icon.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+al_not_listen_title2 = lv.label(AI_not_listen_text_screen)
+al_not_listen_title2.set_pos(0, 56)
+al_not_listen_title2.set_size(LCD_SIZE_W, 20)
+al_not_listen_title2.set_text("未检测到录音数据")
+al_not_listen_title2.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+al_not_listen_title2.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+al_not_listen_title3 = lv.label(AI_not_listen_text_screen)
+al_not_listen_title3.set_pos(0, 76)
+al_not_listen_title3.set_size(LCD_SIZE_W, 20)
+al_not_listen_title3.set_text("请重新对话")
+al_not_listen_title3.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+al_not_listen_title3.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+al_not_listen_icon1 = lv.label(AI_not_listen_text_screen)
+al_not_listen_icon1.set_pos(int(4),int(95))
+al_not_listen_icon1.set_size(120,25)
+al_not_listen_icon1.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+al_not_listen_icon1.set_text("确定")
+al_not_listen_icon1.set_long_mode(lv.label.LONG.WRAP)
+al_not_listen_icon1.add_flag(lv.obj.FLAG.CLICKABLE)
+# create style style_screen_label_1_main_main_default
+al_talk_screen_icon_main_main_default = lv.style_t()
+al_talk_screen_icon_main_main_default.init()
+al_talk_screen_icon_main_main_default.set_radius(30)
+al_talk_screen_icon_main_main_default.set_bg_color(lv.color_make(0x19,0x19,0x19))
+al_talk_screen_icon_main_main_default.set_bg_grad_color(lv.color_make(0x19,0x19,0x19))
+al_talk_screen_icon_main_main_default.set_bg_grad_dir(lv.GRAD_DIR.NONE)
+al_talk_screen_icon_main_main_default.set_bg_opa(255)
+al_talk_screen_icon_main_main_default.set_text_color(lv.color_make(0xff,0xff,0xff))
+al_talk_screen_icon_main_main_default.set_text_font_v2("font_28.bin",28,0)
+al_talk_screen_icon_main_main_default.set_text_letter_space(2)
+al_talk_screen_icon_main_main_default.set_text_line_space(0)
+al_talk_screen_icon_main_main_default.set_text_align(lv.TEXT_ALIGN.CENTER)
+al_talk_screen_icon_main_main_default.set_pad_left(0)
+al_talk_screen_icon_main_main_default.set_pad_right(0)
+al_talk_screen_icon_main_main_default.set_pad_top(3)
+al_talk_screen_icon_main_main_default.set_pad_bottom(0)
+
+# add style for screen_label_1
+al_not_listen_icon1.add_style(al_talk_screen_icon_main_main_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+#阿里voice_chat状态枚举
+VC_State_None=0
+VC_State_Listening=1
+VC_State_Thinking=2
+VC_State_Responding=3
+VC_State_SpeechStart=4
+VC_State_SpeechEnd=5
+VC_State_TTSStart=6
+VC_State_TTSData=7
+VC_State_TTSFinish=8
+VC_State_TTSEnd=9
+VC_State_TTSError=10
+VC_State_DialogError=11
+VC_State_End=12
+
+#websocket发送数据编号
+AI_client_asr_num = 0
+AI_client_chat_num = 1
+AI_client_tts_num = 2
+AI_client_voice_chat_num = 3
+
+#ai平台选择
+AI_TYPE_BKRS = 0 #北科聚合平台ai
+AI_TYPE_voice_chat = 1 #阿里ai voice_chat
+class AIScreen(Screen):#AI_GUI
+ #
+ NAME = "AI_success"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = AI_screen
+ # self.meta_type = "popup"
+ self._1S_timer = osTimer()
+ self.Audio_buf_size = 8*1024
+ self.record_timer = osTimer()
+ self.record = audio.Record()
+ #self.record.end_callback(self.record_callback)
+ self.record.gain_set(4,10)
+ self.aud = audio.Audio(0)
+ self.audio_play_state = 1 #音频播放完状态
+ self.aud.setCallback(self.audio_cb)
+
+
+
+ self.AI_TYPE = AI_TYPE_voice_chat #AI类型,AI_TYPE_voice_chat:阿里云voice_chat;AI_TYPE_BKRS:北科聚合平台
+
+
+ self.AI_audio_queue_thread_id = 0
+ self.AI_send_data_queue_thread_id = 0
+
+ self.voice_chat_state = VC_State_None #阿里ai voice_chat状态
+ self.VC_dialog_id = None
+ self.VC_message_id=None
+ self.VC_task_id =None
+ self.VC_appkey = "j2QhAoOeBi5AUlrM"
+ self.AI_client_voice_chat = None
+ self.AI_client_voice_chat_recv_id = 0
+ self.AI_client_voice_chat_isconnect =0
+ self.record_pcm = None
+ self.play_pcm = None
+ self.VC_record_thread_id = 0
+ self.pingping_timerout = 0
+ self.VC_websocket_stop_flasg = 0
+ self.VC_record_TYPE = 1 #0:PCM 1:AMR
+ self.VC_play_TYPE = 0 #0:mp3 1:PCM
+
+ self.TTS_PRO_TYPE = 0 #TTS协议类型,=0:用长文本合成接口,=1用音频流合成接口
+ self.AI_client_chat_recv_id = 0
+ self.AI_client_tts_recv_id = 0
+ self.AI_client_asr_recv_id = 0
+ self.AI_client_asr = None
+ self.AI_client_asr_isconnect = 0 #是否连接成功
+
+ self.AI_client_chat = None
+ self.AI_client_chat_isconnect = 0 #是否连接成功
+
+ self.AI_client_chat_play_str = ""
+ self.AI_client_chat_end_flag = 0
+ self.AI_client_tts = None
+ self.AI_client_tts_isconnect = 0 #是否连接成功
+ self.AI_client_tts_timer = osTimer()
+ self.AI_client_tts_data_len = 0
+ self.AI_client_tts_data_total_len = 0 #单次tts总数据长度
+ self.AI_client_tts_str_total_len = 0 #单次已发送tts字符串长度
+ self.AI_client_tts_str_sen = '' #单次已发送tts字符串长度
+ self.AI_client_tts_tra_flag = 0
+ self.AI_client_tts_full_sentence_flag = 0 #完整的句子标识
+ self.tts_time_count = 0
+ self.tts_time_outcount = 0
+ self.timer_out_count = 0
+ self.img_show_count = 0
+ self.img_show_count_tmp = 0
+ self.img_show_count_flag = 0
+ self.tts_data_tmp = bytes()
+ self.press_state = 0
+ self.AI_label_answer = ""
+ self.AI_label_str = ""
+ self.AI_client_tts_play_data_len = 0
+ self.refresh_texttimer = osTimer()
+ self.AI_listen_text = ""
+ self.AI_listen_end = 0 #语音识别完成
+ self.refresh_count = 0
+ self.AI_send_data_queue = Queue(100)
+ self.AI_audio_queue = Queue(100)
+ self.page_num = 0
+ self.page_num_tmp = 0
+ self.text_max = 400 #一次最大显示字数
+ self.scroll_flag_next = 0
+ self.scroll_flag_prev = 0
+ self.hard_flag_next = 0
+ self.hard_flag_prev = 0
+ self.scroll_timer_count = 0
+ self.play_flag = 0
+ self.play_flag_init = 0
+ self.play_end = 0 #是否播放完成标识
+
+ AI_screen.add_event_cb(lambda e: EventMesh.callback_wrapper(self.button_cb(e,0)),
+ lv.EVENT.GESTURE, None)
+ AI_talk_end_screen.add_event_cb(lambda e: EventMesh.callback_wrapper(self.button_cb(e,0)),
+ lv.EVENT.GESTURE, None)
+ AI_no_net_screen.add_event_cb(lambda e: EventMesh.callback_wrapper(self.button_cb(e,0)),
+ lv.EVENT.GESTURE, None)
+ AI_listen_screen.add_event_cb(lambda e: EventMesh.callback_wrapper(self.button_cb(e,0)),
+ lv.EVENT.GESTURE, None)
+ AI_think_screen.add_event_cb(lambda e: EventMesh.callback_wrapper(self.button_cb(e,0)),
+ lv.EVENT.GESTURE, None)
+ AI_connect_timerout_screen.add_event_cb(lambda e: EventMesh.callback_wrapper(self.button_cb(e,0)),
+ lv.EVENT.GESTURE, None)
+ AI_not_listen_text_screen.add_event_cb(lambda e: EventMesh.callback_wrapper(self.button_cb(e,0)),
+ lv.EVENT.GESTURE, None)
+
+ al_talk_screen_icon.add_event_cb(lambda e: EventMesh.callback_wrapper(self.button_cb(e,1)),
+ lv.EVENT.SHORT_CLICKED, None)
+ # al_talk_screen_icon_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.button_cb(e,1)),
+ # lv.EVENT.SHORT_CLICKED, None)
+
+ al_no_sim_popup_screen_icon1.add_event_cb(lambda e: EventMesh.callback_wrapper(self.button_cb(e,2)), lv.EVENT.SHORT_CLICKED, None) #无网络按钮
+
+ # al_listen_screen_icon_bt.add_event_cb(lambda e: EventMesh.callback_wrapper(self.button_cb(e,3)), lv.EVENT.SHORT_CLICKED, None) #说话完成按钮
+ # al_listen_screen_icon.add_event_cb(lambda e: EventMesh.callback_wrapper(self.button_cb(e,3)), lv.EVENT.SHORT_CLICKED, None) #说话完成按钮
+
+ # al_think_screen_icon1_bt.add_event_cb(lambda e: EventMesh.callback_wrapper(self.button_cb(e,4)), lv.EVENT.SHORT_CLICKED, None) #思考界面取消按钮
+ al_think_screen_icon1.add_event_cb(lambda e: EventMesh.callback_wrapper(self.button_cb(e,4)), lv.EVENT.SHORT_CLICKED, None) #思考界面取消按钮
+
+ # al_connect_timerout_icon1_bt.add_event_cb(lambda e: EventMesh.callback_wrapper(self.button_cb(e,5)), lv.EVENT.SHORT_CLICKED, None) #连接超时 请重新对话按钮
+ al_connect_timerout_icon1.add_event_cb(lambda e: EventMesh.callback_wrapper(self.button_cb(e,5)), lv.EVENT.SHORT_CLICKED, None) #连接超时 请重新对话按钮
+
+ al_talk_end_screen_cancel_bt.add_event_cb(lambda e: EventMesh.callback_wrapper(self.button_cb(e,6)), lv.EVENT.SHORT_CLICKED, None) #对话结束 取消对话按钮
+ al_talk_end_screen_icon1.add_event_cb(lambda e: EventMesh.callback_wrapper(self.button_cb(e,6)), lv.EVENT.SHORT_CLICKED, None) #对话结束 取消对话按钮
+
+ # AI_press_label_bt.add_event_cb(lambda e: EventMesh.callback_wrapper(self.button_cb(e,7)), lv.EVENT.SHORT_CLICKED, None) #对话结束 继续对话按钮
+ al_talk_end_screen_icon2.add_event_cb(lambda e: EventMesh.callback_wrapper(self.button_cb(e,7)), lv.EVENT.SHORT_CLICKED, None) #对话结束 继续对话按钮
+
+ # al_not_listen_icon1_bt.add_event_cb(lambda e: EventMesh.callback_wrapper(self.button_cb(e,8)), lv.EVENT.SHORT_CLICKED, None)
+ al_not_listen_icon1.add_event_cb(lambda e: EventMesh.callback_wrapper(self.button_cb(e,8)), lv.EVENT.SHORT_CLICKED, None)
+ AI_end_screen_list_screen2.add_event_cb(self.scroll_event_cb, lv.EVENT.SCROLL_END, None)
+ AI_end_screen_list_screen.add_event_cb(self.scroll_event_cb, lv.EVENT.SCROLL_END, None)
+
+ def button_cb(self,e,msg):
+ code = e.get_code()
+ indev = lv.indev_get_act()
+ lv.indev_t.wait_release(indev)
+ dir = lv.indev_t.get_gesture_dir(indev)
+ if code == lv.EVENT.GESTURE:
+ if dir == lv.DIR.RIGHT:
+ if (AI_talk_end_screen.has_flag(lv.obj.FLAG.HIDDEN)) == False or (AI_listen_screen.has_flag(lv.obj.FLAG.HIDDEN)) == False or\
+ (AI_talk_screen.has_flag(lv.obj.FLAG.HIDDEN)) == False or (AI_no_net_screen.has_flag(lv.obj.FLAG.HIDDEN)) == False or \
+ (AI_connect_timerout_screen.has_flag(lv.obj.FLAG.HIDDEN)) == False or (AI_not_listen_text_screen.has_flag(lv.obj.FLAG.HIDDEN)) == False or \
+ (AI_think_screen.has_flag(lv.obj.FLAG.HIDDEN)) == False:
+ EventMesh.publish("return_prev_screen")
+ elif code == lv.EVENT.SHORT_CLICKED:
+ if msg == 1:
+ self.talking_cb(e)
+ pass
+ elif msg == 2:
+ self.img_cb(e)
+ pass
+ elif msg == 3:
+ self.listen_end_btcb(e)
+ pass
+ elif msg == 4:
+ self.think_bt_cb(e)
+ pass
+ elif msg == 5:
+ self.talk_end_continue_cb(e)
+ pass
+ elif msg == 6:
+ self.talk_end_cancel_cb(e)
+ pass
+ elif msg == 7:
+ self.talk_end_continue_cb(e)
+ pass
+ elif msg == 8:
+ self.talk_end_continue_cb(e)
+ pass
+
+ def clear_flag(self): #清标识
+ self.timer_out_count = 0
+ self.img_show_count = 0
+ self.img_show_count_tmp = 0
+ self.img_show_count_flag = 0
+ self.AI_listen_end = 0 #语音识别完成
+ self.refresh_count = 0
+ self.AI_listen_text = ""
+ self.AI_label_str = ""
+ self.AI_label_answer = ""
+ self.tts_time_count = 0
+ self.tts_time_outcount = 0
+
+ def talk_end_cancel_cb(self,e):#对话结束已经播放音频取消继续对话按钮
+ if self.play_flag == 1:
+ self.play_flag = 0
+ self.aud.stopPlayStream()
+ self.aud.stopAll()
+ print("talk_end_cancel_cb stop()\r\n")
+ EventMesh.publish("publish_message_event_ui",{"func":self.upload_img,"data":0})
+ else:
+ self.play_flag = 1
+ print("talk_end_cancel_cb start()\r\n")
+ EventMesh.publish("publish_message_event_ui",{"func":self.upload_img,"data":1})
+ return
+ self.Close()
+ self.AI_label_answer = ""
+ AI_no_net_screen.add_flag(lv.obj.FLAG.HIDDEN) #隐藏
+ AI_listen_screen.add_flag(lv.obj.FLAG.HIDDEN)
+ AI_think_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_connect_timerout_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_talk_end_screen.add_flag(lv.obj.FLAG.HIDDEN) #
+ AI_not_listen_text_screen.add_flag(lv.obj.FLAG.HIDDEN) #
+ AI_talk_screen.clear_flag(lv.obj.FLAG.HIDDEN) #
+ def upload_img(self,msg):
+ if al_talk_end_screen_icon1 != None:
+ if msg == 1:
+ al_talk_end_screen_icon1.set_src("U:/static/AI/ai_result_can_start.png")
+ else:
+ al_talk_end_screen_icon1.set_src("U:/static/AI/ai_result_can_stop.png")
+
+ def talk_end_continue_cb(self,e):#连接超时确定按钮回调或者继续对话按钮
+ self.Close()
+ self.AI_label_answer = ""
+ AI_no_net_screen.add_flag(lv.obj.FLAG.HIDDEN) #隐藏
+ AI_talk_end_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_think_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_talk_screen.add_flag(lv.obj.FLAG.HIDDEN) #
+ AI_connect_timerout_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_not_listen_text_screen.add_flag(lv.obj.FLAG.HIDDEN) #
+ AI_listen_screen.clear_flag(lv.obj.FLAG.HIDDEN)
+ al_listen_screen_title1.set_text("识别中...")
+ al_listen_screen_icon1.set_src("U:/static/AI/AI_LISTEN_GIF001.png")
+ self.AI_client_tts_timer.start(1000,1,self.AI_client_tts_timer_cb)
+ EventMesh.publish("publish_message_event_ui",{"func":self.talking,"data":e})
+
+ pass
+
+ def talk_connectout_cb(self,e):#连接超时确定按钮回调
+
+ pass
+
+ def think_bt_cb(self,e):#正在思考确定按钮回调 取消播放
+ if self.AI_TYPE == AI_TYPE_voice_chat:
+ self.AI_client_voice_chat_end_speech()
+ pass
+ else:
+ self.Close()
+ AI_no_net_screen.add_flag(lv.obj.FLAG.HIDDEN) #隐藏
+ AI_listen_screen.add_flag(lv.obj.FLAG.HIDDEN)
+ AI_think_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_connect_timerout_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_talk_end_screen.add_flag(lv.obj.FLAG.HIDDEN) #
+ AI_not_listen_text_screen.add_flag(lv.obj.FLAG.HIDDEN) #
+ AI_talk_screen.clear_flag(lv.obj.FLAG.HIDDEN) #
+
+ pass
+
+ def not_talk_cb(self):#没有说话或者没有检测到录音数据
+ self.Close()
+ AI_no_net_screen.add_flag(lv.obj.FLAG.HIDDEN) #隐藏
+ AI_listen_screen.add_flag(lv.obj.FLAG.HIDDEN)
+ AI_connect_timerout_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_talk_end_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_think_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_talk_screen.add_flag(lv.obj.FLAG.HIDDEN) #
+ AI_not_listen_text_screen.clear_flag(lv.obj.FLAG.HIDDEN) #
+
+ def scroll_event_cb(self,e):
+ try:
+
+ # 获取事件源对象
+ obj = e.get_target()
+ code = e.get_code()
+ # 如果事件是滚动条事件
+ if code == lv.EVENT.SCROLL_END:
+
+ # 获取滚动条对象
+
+ # 获取滚动条的位置
+ sb_value = obj.get_scroll_y()
+
+ # 获取对象的高度和内容的总高度
+ content_height = obj.get_scroll_bottom()#obj.get_child(0).get_height()+obj.get_child(1).get_height()
+ # 检查滚动条是否已经到达最大值,即内容是否已经到达底部
+ if self.hard_flag_next == 1 or self.hard_flag_prev == 1:
+ self.scroll_timer_count = 10 #滑动计时器初始化
+ if content_height < 0:
+ self.scroll_flag_next = 1
+ elif self.hard_flag_next == 1 and self.scroll_flag_next == 1 and content_height == 0:
+ print("下一页")
+
+ self.page_change(2,self.AI_label_str)
+ self.scroll_flag_next = 0
+ self.hard_flag_next = 0
+ else:
+ self.scroll_flag_next = 0
+ self.hard_flag_next = 0
+ if sb_value < 0:
+ self.scroll_flag_prev = 1
+ elif self.hard_flag_prev == 1 and self.scroll_flag_prev == 1 and sb_value == 0:
+ print("上一页")
+ self.page_change(1,self.AI_label_str)
+ self.scroll_flag_prev = 0
+ self.hard_flag_prev = 0
+ else:
+ self.scroll_flag_prev = 0
+ self.hard_flag_prev = 0
+ except Exception as e:
+ usys.print_exception(e)
+
+ def page_change(self,dir,text_str):#翻页,dir: = 0跳转第一页,=1上一页,=2下一页,=3最后一页,最后的内容
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ text_str_list = []
+ text_str_list_len = 0
+ while 1:#分割字符串,获取列表
+ str_tmp = split_string(text_str[text_str_list_len:],self.text_max,self.text_max+150)#按逗号,句号切割
+ if str_tmp =="" :#没找到句号或者逗号,切割字符串
+ str_tmp = sub_utf8_String(text_str[text_str_list_len:],self.text_max)#按中文切割字符串
+ #print("page_change:str_tmp:{}".format((str_tmp)))
+ #str_tmp = sub_utf8_String(text_str[text_str_list_len:],self.text_max)
+ text_str_list_len+=len(str_tmp)
+
+ if len(text_str) <= text_str_list_len:
+ text_str_list.append(str_tmp)
+ break
+ text_str_list.append(str_tmp)
+
+ if self.AI_client_chat_end_flag ==1:#char回答完后,使最后一页字数大于一页
+ #if len(text_str_list[-1]) < 50:
+ if len(self.AI_label_str ) <= len(text_str):
+ text_str_list[-1]+="\n\n\n\n~~~~~END~~~~~"
+ if len(text_str_list[-1])<30:
+ text_str_list[-1]+="\n\n"
+ else: #chat未完成,创造中
+ if dir != 3:
+ text_str_list[-1]+="\n\n 创作中...\n\n"
+
+ if dir == 0:#第一页
+ self.page_num = 0
+ if len(text_str_list)>self.page_num:
+ AI_label.set_text(text_str_list[self.page_num]+'\n ...{}/{}...'.format(self.page_num+1,len(text_str_list)))
+ AI_end_screen_list_screen2.scroll_to_y(0,lv.ANIM.OFF)
+ AI_end_screen_list_screen2.add_flag(lv.obj.FLAG.HIDDEN) #隐藏2
+ AI_end_screen_list_screen.clear_flag(lv.obj.FLAG.HIDDEN) #
+ elif dir == 1:#上一页
+ if self.page_num == 1: #第二页,
+
+ self.page_num-=1
+ if len(text_str_list)>self.page_num:
+ AI_label.set_text(text_str_list[self.page_num]+'\n ...{}/{}...'.format(self.page_num+1,len(text_str_list)))
+ #AI_label.set_text(text_str_list[self.page_num]+'\n ...{}/{}...'.format(self.page_num+1,len(text_str_list)))
+ scroll_bottom = AI_label.get_height()
+ print("page_change:scroll_bottom:{}".format(scroll_bottom))
+ AI_end_screen_list_screen.scroll_to_y(scroll_bottom,lv.ANIM.OFF)
+ AI_end_screen_list_screen2.add_flag(lv.obj.FLAG.HIDDEN) #隐藏2
+ AI_end_screen_list_screen.clear_flag(lv.obj.FLAG.HIDDEN) #
+ #AI_end_screen_list_screen.scroll_to_view(lv.ANIM.OFF)
+ elif self.page_num > 1:
+ self.page_num-=1
+ if len(text_str_list)>self.page_num:
+ AI_label2.set_text(text_str_list[self.page_num]+'\n ...{}/{}...'.format(self.page_num+1,len(text_str_list)))
+ scroll_bottom = AI_label2.get_height()
+ print("page_change:scroll_bottom:{}".format(scroll_bottom))
+
+ AI_end_screen_list_screen2.scroll_to_y(scroll_bottom,lv.ANIM.OFF)
+ #AI_end_screen_list_screen2.scroll_to_view(lv.ANIM.OFF)
+ elif dir == 2:#下一页
+ if len(text_str_list)<=self.page_num+1:#最大页
+ return
+ self.page_num+=1
+ if len(text_str_list)>self.page_num:
+ #AI_label2.set_text(' ...\n\n'+text_str_list[self.page_num]+'\n ...{}/{}...'.format(self.page_num+1,len(text_str_list)))
+ #print("page_change:next:{}".format(text_str_list[self.page_num]))
+ AI_label2.set_text(text_str_list[self.page_num]+'\n ...{}/{}...'.format(self.page_num+1,len(text_str_list)))
+ AI_end_screen_list_screen2.scroll_to_y(0,lv.ANIM.OFF)
+ if self.page_num == 1: #显示第二页
+ AI_end_screen_list_screen.add_flag(lv.obj.FLAG.HIDDEN) #隐藏1
+ AI_end_screen_list_screen2.clear_flag(lv.obj.FLAG.HIDDEN) #
+ elif dir == 3:#最后一页,最后的内容
+ if len(text_str_list)>1:#大于一页
+
+ self.page_num = len(text_str_list)-1
+ #if len(text_str_list)>self.page_num:
+ str_tmp = sub_utf8_String(text_str_list[self.page_num-1],self.text_max-80)#在开头加上上一页的最后30字节数据
+ #print("str_tmp123:{}".format(str_tmp))
+ if len(text_str_list[self.page_num-1])>len(str_tmp):
+ str_tmp = text_str_list[self.page_num-1][len(str_tmp):]
+ else:
+ str_tmp = ''
+ #
+ AI_label2.set_text(str_tmp+text_str_list[self.page_num])#+'\n ...{}/{}...'.format(self.page_num+1,len(text_str_list)))
+ scroll_bottom = AI_label2.get_height()
+ AI_end_screen_list_screen2.scroll_to(0,scroll_bottom,lv.ANIM.ON)
+ #print("最后内容,大于一页 scroll_bottom:{}".format(scroll_bottom))
+ if self.page_num_tmp == self.page_num:#解决切换页面的时候不跳动问题
+ # AI_label2.set_text("\n\n"+str_tmp+text_str_list[self.page_num])
+ # scroll_bottom = AI_label2.get_height()
+ AI_end_screen_list_screen2.scroll_to(0,scroll_bottom,lv.ANIM.ON)
+ else:
+ # AI_label2.set_text("\n\n\n\n\n\n"+str_tmp+text_str_list[self.page_num])
+ # scroll_bottom = AI_label2.get_height()
+ AI_end_screen_list_screen2.scroll_to(0,scroll_bottom,lv.ANIM.OFF)
+ self.page_num_tmp = self.page_num
+ #print("text_str_list[self.page_num]:{}".format(str_tmp+text_str_list[self.page_num]))
+ #AI_end_screen_list_screen2.scroll_to_view(lv.ANIM.OFF)
+ AI_end_screen_list_screen.add_flag(lv.obj.FLAG.HIDDEN) #隐藏1
+ AI_end_screen_list_screen2.clear_flag(lv.obj.FLAG.HIDDEN) #
+ if len(self.AI_label_str ) > len(text_str):#处理播放音频的时候,获取下一页数据
+ self.page_num-=1
+ elif len(text_str_list) == 1:#只有一页
+ self.page_num = 0
+ if len(text_str_list)>self.page_num:
+ AI_label.set_text(text_str_list[self.page_num])#+'\n ...{}/{}...'.format(self.page_num+1,len(text_str_list)))
+ scroll_bottom = AI_label.get_height()
+ #print("最后内容,只有一页 scroll_bottom:{}".format(scroll_bottom))
+ # if(scroll_bottom>200):
+ # scroll_bottom -= 200
+
+ AI_end_screen_list_screen.scroll_to(0,scroll_bottom,lv.ANIM.ON)
+ #AI_end_screen_list_screen.scroll_to_view(lv.ANIM.OFF)
+ AI_end_screen_list_screen2.add_flag(lv.obj.FLAG.HIDDEN) #隐藏2
+ AI_end_screen_list_screen.clear_flag(lv.obj.FLAG.HIDDEN) #
+ #print("page_change1:page_num:{},text_str_list len:{}".format(self.page_num,len(text_str_list)))
+
+
+ def listen_end_btcb(self,e):#说话完成确定按钮回调
+ if self.AI_listen_end == 1:#说话完成 已有录音文字返回
+ self.AI_listen_end = 0
+ self.refresh_count = 0
+ self.refresh_texttimer.stop()
+ self.record.stop()#关闭录音
+ self.record_timer.stop()#关闭定时器
+ if self.AI_listen_text != "":
+ self.AI_client_chat_send(self.AI_listen_text)
+ print("self.AI_listen_text:{}".format(self.AI_listen_text))
+ AI_talk_end_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_listen_screen.add_flag(lv.obj.FLAG.HIDDEN)
+ AI_talk_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_no_net_screen.add_flag(lv.obj.FLAG.HIDDEN) #
+ AI_connect_timerout_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_not_listen_text_screen.add_flag(lv.obj.FLAG.HIDDEN) #
+ AI_think_screen.clear_flag(lv.obj.FLAG.HIDDEN) #
+ al_think_screen_icon.set_src("U:/static/AI/AI_THINK009.png")
+ self.refresh_count = 0
+ self.timer_out_count = 0
+ self.img_show_count = 0
+ self.img_show_count_tmp = 0
+ self.img_show_count_flag = 0
+ self.refresh_texttimer.start(500,1,self.text_show_think)
+ else:
+ self.not_talk_cb()
+ return
+ try:
+ self.websocket_deconnect_asr()
+ except Exception as e:
+ usys.print_exception(e)
+ return
+ else:#没有识别到录音文字
+ self.not_talk_cb()
+
+ def ai_talk_end(self):#语言识别完 思考结束显示最后的文本和音频数据
+
+ self.play_end = 0
+ self.play_flag = 1
+ self.AI_label_answer = ""
+ AI_end_screen_list_screen.scroll_to(0, 0, lv.ANIM.OFF)
+ AI_label.set_pos(5, 10)
+ #AI_label.set_text(self.AI_label_answer)
+ AI_label.set_text("思考中...")
+ AI_label2.set_text(" ")
+ self.scroll_timer_count = 0
+ # self.AI_listen_text = "嗯。"
+ str_len = len(self.AI_listen_text)*20
+ if str_len > 165:
+ str_len = 165
+ print("len:{} str_len:{} self.AI_listen_text:{}\r\n".format(len(self.AI_listen_text),str_len,self.AI_listen_text))
+ # AI_end_screen_list_detail_screen1.set_pos(170-str_len,10)
+
+ # AI_listen_text.set_size(str_len,lv.SIZE.CONTENT)
+
+ # AI_listen_text.set_pos(0, 10)
+ # AI_listen_text.set_size(str_len,lv.SIZE.CONTENT)
+ AI_listen_text.set_text(self.AI_listen_text)
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ self.refresh_count = 0
+ AI_no_net_screen.add_flag(lv.obj.FLAG.HIDDEN) #隐藏
+ AI_listen_screen.add_flag(lv.obj.FLAG.HIDDEN)
+ AI_think_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_connect_timerout_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_talk_screen.add_flag(lv.obj.FLAG.HIDDEN) #
+ AI_not_listen_text_screen.add_flag(lv.obj.FLAG.HIDDEN) #
+ AI_talk_end_screen.clear_flag(lv.obj.FLAG.HIDDEN) #
+ al_talk_end_screen_icon1.set_src("U:/static/AI/ai_result_can_start.png")
+ AI_end_screen_list_screen2.add_flag(lv.obj.FLAG.HIDDEN) #隐藏2
+ AI_end_screen_list_screen.clear_flag(lv.obj.FLAG.HIDDEN) #
+
+ def ai_talk_end_show_text_cb(self,data):
+ #AI_label.set_text(self.AI_label_answer)
+ #print("ai_talk_end_show_text_cb:scroll_timer_count{}".format(self.scroll_timer_count))
+ if self.scroll_timer_count <= 0:
+ self.page_change(3,self.AI_label_answer)#刷新到最后内容
+ pass
+
+ def connect_timerout_popup(self,msg):#连接超时弹窗提示
+ EventMesh.publish("publish_message_event_ui",{"func":self.connect_timerout_popup_cb,"data":msg})
+
+ def connect_timerout_popup_cb(self,msg):
+ self.Close()
+ AI_talk_screen.add_flag(lv.obj.FLAG.HIDDEN) #
+ AI_no_net_screen.add_flag(lv.obj.FLAG.HIDDEN) #隐藏
+ AI_listen_screen.add_flag(lv.obj.FLAG.HIDDEN)
+ AI_talk_end_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_not_listen_text_screen.add_flag(lv.obj.FLAG.HIDDEN) #
+ AI_think_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_connect_timerout_screen.clear_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ if msg == 1: #连接超时
+ al_connect_timerout_title2.set_text("连接超时")
+ else:
+ al_connect_timerout_title2.set_text("网络连接异常")
+
+
+ def text_show_think(self,*argc):
+ EventMesh.publish("publish_message_event_ui",{"func":self.text_show_think_cb,"data":0})
+
+ def text_show_think_cb(self,data): #文本刷新
+ if self.img_show_count_flag == 1:
+ self.refresh_texttimer.stop()
+ return
+ if self.AI_label_str != "":
+ self.timer_out_count = 1
+ self.img_show_count_flag = 1
+ self.refresh_texttimer.stop()
+ self.ai_talk_end()
+ return
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ self.timer_out_count += 1
+ if self.timer_out_count > 2*30: #说话了服务器没有返回结果数据
+ self.timer_out_count = 0
+ #连接超时
+ self.img_show_count = 0
+ self.img_show_count_tmp = 0
+ self.connect_timerout_popup(1)
+ return
+
+ if self.img_show_count > 10:
+ self.img_show_count_tmp+=1
+ self.img_show_count_tmp = self.img_show_count-self.img_show_count_tmp
+ if self.img_show_count_tmp >= 10:
+ self.img_show_count = 1
+ al_think_screen_icon.set_src("U:/static/AI/AI_THINK{}.png".format("%03d"%(self.img_show_count_tmp)))
+ else:
+ self.img_show_count+=1
+ self.img_show_count_tmp = 0
+ al_think_screen_icon.set_src("U:/static/AI/AI_THINK{}.png".format("%03d"%(self.img_show_count)))
+
+
+ self.refresh_count+=1
+ if self.refresh_count > 3:
+ self.refresh_count = 0
+ if self.refresh_count == 1:
+ al_think_screen_title1.set_text("正在思考.")
+ elif self.refresh_count == 2:
+ al_think_screen_title1.set_text("正在思考..")
+ elif self.refresh_count == 3:
+ al_think_screen_title1.set_text("正在思考...")
+ pass
+
+ def think_end_result(self):
+ EventMesh.publish("publish_message_event_ui",{"func":self.think_end_result_cb,"data":0})
+ def think_end_result_cb(self,data):
+ if self.timer_out_count > 1:
+ if self.img_show_count_flag == 1:
+ return
+ self.timer_out_count = 0
+ self.img_show_count_flag = 1
+ self.refresh_texttimer.stop()
+ self.ai_talk_end()
+
+ def img_cb(self,e): #无网络 无数据按钮回调
+ self.refresh_texttimer.stop()
+ AI_no_net_screen.add_flag(lv.obj.FLAG.HIDDEN) #隐藏
+ AI_listen_screen.add_flag(lv.obj.FLAG.HIDDEN)
+ AI_think_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_connect_timerout_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_not_listen_text_screen.add_flag(lv.obj.FLAG.HIDDEN) #
+ AI_talk_end_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_talk_screen.clear_flag(lv.obj.FLAG.HIDDEN) #
+ pass
+ def initialization(self):
+ self.play_flag = 1
+ self.play_end = 0
+ self.TTS_PRO_TYPE = 0
+ AI_listen_screen.add_flag(lv.obj.FLAG.HIDDEN)
+ AI_think_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_connect_timerout_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_no_net_screen.add_flag(lv.obj.FLAG.HIDDEN) #开启显示
+ AI_talk_end_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_not_listen_text_screen.add_flag(lv.obj.FLAG.HIDDEN) #
+ AI_talk_screen.clear_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ self.aud.setVolume(11)#设置最大声录音
+
+ self.AI_label_answer = ""
+ self.AI_client_chat_play_str = ''
+ self.AI_init()
+ self.AI_client_tts_data_len = 0
+ self.AI_client_tts_data_total_len = 0
+ self.AI_client_tts_str_total_len = 0
+ self.AI_client_tts_tra_flag = 0
+ #EventMesh.publish("publish_message_event_ui",{"func":self.websocket_connect,"data":""})
+
+ def websocket_connect(self,data):
+ if self.AI_TYPE == AI_TYPE_voice_chat:
+ self.websocket_connect_voice_chat()
+ else:
+ self.websocket_connect_asr()
+ self.websocket_connect_chat()
+ self.websocket_connect_tts()
+
+ pass
+
+ def audio_cb(self,event):
+ if event == 0:
+ self.audio_play_state =1
+ EventMesh.publish("set_audio_state", 1)
+ print('audio-play start.')
+ elif event == 7:
+ self.audio_play_state = 0
+ EventMesh.publish("set_audio_state", 0)
+ print('audio-play finish.!!!!!!')
+ def AI_init(self):
+ self.AI_audio_queue_thread_id = _thread.start_new_thread(self.AI_audio_queue_thread, ())
+ self.AI_send_data_queue_thread_id = _thread.start_new_thread(self.AI_send_data_queue_thread, ())
+
+
+
+ #按下录音
+ def talking_cb(self,e):
+ self.press_state = 0
+ self.refresh_count = 0
+ self.refresh_texttimer.stop()
+ signal = EventMesh.publish("screen_get_sig")
+ if signal == -1 or EventMesh.publish("get_sim_Status") != 1:#网络不正常
+ AI_listen_screen.add_flag(lv.obj.FLAG.HIDDEN)
+ AI_think_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_talk_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_talk_end_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_connect_timerout_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_not_listen_text_screen.add_flag(lv.obj.FLAG.HIDDEN) #
+ AI_no_net_screen.clear_flag(lv.obj.FLAG.HIDDEN) #开启显示
+ al_no_sim_popup_screen_title3.set_text("无SIM卡")
+
+ elif signal == None or signal == 0 or signal == 99:
+ AI_listen_screen.add_flag(lv.obj.FLAG.HIDDEN)
+ AI_think_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_talk_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_talk_end_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_connect_timerout_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_not_listen_text_screen.add_flag(lv.obj.FLAG.HIDDEN) #
+ AI_no_net_screen.clear_flag(lv.obj.FLAG.HIDDEN) #开启显示
+ al_no_sim_popup_screen_title3.set_text("请先开启移动数据")
+
+ else:
+ AI_no_net_screen.add_flag(lv.obj.FLAG.HIDDEN) #隐藏
+ AI_talk_end_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_think_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_talk_screen.add_flag(lv.obj.FLAG.HIDDEN) #
+ AI_connect_timerout_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_not_listen_text_screen.add_flag(lv.obj.FLAG.HIDDEN) #
+ AI_listen_screen.clear_flag(lv.obj.FLAG.HIDDEN)
+ al_listen_screen_title1.set_text("识别中...")
+ al_listen_screen_icon1.set_src("U:/static/AI/AI_LISTEN_GIF001.png")
+ self.timer_out_count = 0
+ self.refresh_count = 0
+ self.img_show_count = 0
+ self.img_show_count_tmp = 0
+
+ EventMesh.publish("publish_message_event_ui",{"func":self.talking,"data":e})
+
+ def talk_ars_end(self):#asr结束调用
+ print("talk_ars_end!!!!!!!!!!!")
+ self.AI_send_data_queue.clear()#清掉发送数据队列
+ self.AI_listen_end = 1
+ self.audio_play_state = 0
+ if self.AI_TYPE == AI_TYPE_voice_chat:
+ if self.VC_record_TYPE == 1:
+ self.record.stop()#关闭录音
+ else:
+ pass
+ if self.record_pcm != None:
+ print("talk_ars_end:record_pcm.close()!!!!!!!!!!!!!!!!!!")
+ try:
+ self.record_pcm.stream_stop()
+ self.record_pcm.close()
+ except Exception as e:
+ usys.print_exception(e)
+ self.record_pcm=None
+ else:
+ self.record.stop()#关闭录音
+ self.record_timer.stop()#关闭定时器
+ self.timer_out_count = 0
+
+ Record_read_buf = bytearray(self.Audio_buf_size)
+ for i in range(10):
+ Record_len = self.record.stream_read(Record_read_buf, self.Audio_buf_size)
+ print("Record_len:!!!!!!{}\r\n".format(Record_len))
+ if Record_len <= 0:
+ break
+ print("talk_ars_end2!!!!!!!!!!!\r\n")
+
+ try:
+ self.websocket_deconnect_asr()
+ except Exception as e:
+ usys.print_exception(e)
+ if self.AI_listen_text == "":
+ return
+ self.AI_client_chat_send(self.AI_listen_text)
+
+
+ def text_show_refresh(self,*argc):
+ EventMesh.publish("publish_message_event_ui",{"func":self.text_show_refresh_cb,"data":0})
+
+ def text_show_refresh_cb(self,data):
+ if self.AI_listen_end == 1 or self.timer_out_count >= 120:#语音识别结束
+ self.record.stop()#关闭录音
+ self.record_timer.stop()#关闭定时器
+ if self.AI_listen_text != "":
+ self.img_show_count_tmp+=1
+ if self.img_show_count_tmp > 2:
+ self.AI_listen_end = 0
+ self.refresh_count = 0
+ self.refresh_texttimer.stop()
+ self.timer_out_count = 0
+ print("self.AI_listen_text:{}".format(self.AI_listen_text))
+ #正在思考
+ AI_talk_end_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_listen_screen.add_flag(lv.obj.FLAG.HIDDEN)
+ AI_talk_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_no_net_screen.add_flag(lv.obj.FLAG.HIDDEN) #
+ AI_connect_timerout_screen.add_flag(lv.obj.FLAG.HIDDEN) #先隐藏
+ AI_not_listen_text_screen.add_flag(lv.obj.FLAG.HIDDEN) #
+ AI_think_screen.clear_flag(lv.obj.FLAG.HIDDEN) #
+ al_think_screen_icon.set_src("U:/static/AI/AI_THINK009.png")
+ self.refresh_count = 0
+ self.timer_out_count = 0
+ self.img_show_count = 0
+ self.img_show_count_tmp = 0
+ self.img_show_count_flag = 0
+ self.refresh_texttimer.start(500,1,self.text_show_think)
+ else:
+
+ self.not_talk_cb()
+ return
+ try:
+ self.websocket_deconnect_asr()
+ except Exception as e:
+ usys.print_exception(e)
+ return
+
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ self.timer_out_count += 1
+
+ self.img_show_count+=1
+ if self.img_show_count > 11:
+ self.img_show_count = 1
+ # print("self.img_show_count:{}\r\n".format(self.img_show_count))
+ al_listen_screen_icon1.set_src("U:/static/AI/AI_LISTEN_GIF{}.png".format("%03d"%(self.img_show_count)))
+
+ self.refresh_count+=1
+ if self.refresh_count > 3:
+ self.refresh_count =0
+ if self.refresh_count == 1:
+ al_listen_screen_title4.set_text("正在聆听.")
+ elif self.refresh_count == 2:
+ al_listen_screen_title4.set_text("正在聆听..")
+ elif self.refresh_count == 3:
+ al_listen_screen_title4.set_text("正在聆听...")
+ pass
+ #按下录音
+ def talking(self,e):
+ #self.AI_client_tts_send("创建客户端, debug=True输出日志")#TTS语音播放AI结果
+ #return
+ if 1:#EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#有卡时触发sos报警 无卡时自动关机
+ al_listen_screen_title1.set_text("识别中...")
+ print("talking1")
+ #self.AI_list.add_flag(lv.obj.FLAG.HIDDEN)#隐藏列表选项方框
+ try:
+ print("talking2")
+ self.Close()
+ print("talking3")
+ self.AI_init()
+ except Exception as e:
+ usys.print_exception(e)
+
+ self.audio_play_state = 1
+ if 1:#self.audio_play_state == 0:
+
+ if self.AI_TYPE == AI_TYPE_voice_chat:
+
+ self.AI_client_voice_chat_start_requset()#先开始对话
+ self._1S_timer.start(1000,1,self._1S_timer_cb)
+ #self.AI_client_voice_chat_speak_requset()
+
+ self._1S_timer.start(1000,1,self._1S_timer_cb)
+ else:
+
+
+
+ self._1S_timer.start(1000,1,self._1S_timer_cb)
+ self.AI_client_tts_timer.start(1000,1,self.AI_client_tts_timer_cb)
+ self.record_timer.start(1*1000,1,self.record_timer_cb)
+ self.refresh_texttimer.start(500,1,self.text_show_refresh)
+ #self.AI_list.add_flag(lv.obj.FLAG.HIDDEN)#隐藏列表选项方框
+
+ # AI_label.clear_flag(lv.obj.FLAG.HIDDEN)
+ # AI_label.set_text("语音识别中...")
+ # AI_listen_text.clear_flag(lv.obj.FLAG.HIDDEN)
+ #AI_listen_text.set_text("{}S".format(str(self.countdown)))
+ self.press_state = 1
+ self.record.stream_start(audio.Record.AMRNB, 8000, 60)
+ self.AI_client_asr_start()
+ else:
+ EventMesh.publish("load_screen", {"screen": "no_sim_popup_screen"})
+
+ #松开确认结果
+ def sending_cb(self,e):
+ EventMesh.publish("publish_message_event_ui",{"func":self.sending,"data":e})
+ def sending(self,e):
+ if self.press_state == 1:
+ if 1:#EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#有卡时触发sos报警 无卡时自动关机
+ self.record.stop()#关闭录音
+ self.record_timer.stop()#关闭定时器
+ self.audio_play_state = 0
+
+ else:
+ self.press_state = 0
+ #EventMesh.publish("load_screen", {"screen": "no_sim_popup_screen"})
+ else:
+ pass
+ def _1S_timer_cb(self,*argc):
+ # print("get_audio_state !!!!!{} {} {}\r\n".format(self.play_end,EventMesh.publish("get_audio_state"),self.play_flag))
+
+ if (self.play_end == 1 and EventMesh.publish("get_audio_state") == 0 ) or self.play_flag == 0: #字符串为0 或者暂停需要自动熄屏
+ # print("self.play_end!!!!!\r\n")
+ pass
+ else:
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ if self.scroll_timer_count > 0:
+ self.scroll_timer_count-=1
+
+ #定时器
+ def record_timer_cb(self,*argc):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+
+ if self.AI_TYPE == AI_TYPE_voice_chat:
+ self.pingping_timerout+=1
+ if self.pingping_timerout>6:
+ self.pingping_timerout=0
+ self.AI_client_voice_chat_ping()
+ pass
+ # Record_read_buf = self.record_pcm.read(2048)
+ # if self.voice_chat_state == VC_State_SpeechStart:
+ # self.AI_client_voice_chat_send(read_buf)
+ else:
+ Record_read_buf = bytearray(self.Audio_buf_size)
+ Record_len = self.record.stream_read(Record_read_buf, self.Audio_buf_size)
+ print("record_timer_cb:{}".format(Record_len))
+ if Record_len > 0:
+ read_buf = bytes(Record_read_buf[:Record_len])
+ self.AI_client_asr_send(read_buf)
+ #获取trace_id
+ def get_trace_id(self):
+ t = utime.mktime(utime.localtime())
+ t = t*1000+urandom.randint(0, 1000)
+ md5_data = "{}".format(t)#md5签名
+ sign_data = ""
+ hash_obj = uhashlib.md5(md5_data)
+ res = hash_obj.digest()
+
+ # 转成十六进制表示
+ sign_data = ubinascii.hexlify(res)
+ sign_data = sign_data.decode('ascii')
+ return sign_data
+ #####################################################
+ #阿里voice_chat
+ # VC_State_None=0
+ # VC_State_Listening=1
+ # VC_State_Thinking=2
+ # VC_State_Responding=3
+ # VC_State_TTSStart=4
+ # VC_State_TTSData=5
+ # VC_State_TTSFinish=6
+ # VC_State_TTSEnd=7
+ # VC_State_TTSError=8
+ # VC_State_DialogError=9
+ # VC_State_End=10
+ def websocket_connect_voice_chat(self):
+ self.record_timer.start(1*1000,1,self.record_timer_cb)
+ print("websocket_connect_voice_chat:{}!!!!!!!!!!!!!!!!!!!!!".format(self.AI_client_voice_chat_isconnect))
+ # 创建客户端, debug=True输出日志, ip和端口需要自己填写, 或者是域名
+ try:
+ # Headers = {'X-NLS-Token':'0c8b8f05a46f423096be64a9c4c46310'}
+ # self.AI_client_voice_chat = uwebsocket.Client.connect('wss://nls-gateway-cn-beijing.aliyuncs.com/ws/v1',headers=Headers, debug=False)
+ self.AI_client_voice_chat = uwebsocket.Client.connect('ws://118.145.158.207:22080/voice-chat/ws', debug=False)
+ except Exception as e: #网络连接异常
+ usys.print_exception(e)
+ print("websocket_connect_voice_chat error!!!\r\n")
+ self.connect_timerout_popup(2)
+ return
+ # 线程接收数据
+ if self.AI_client_voice_chat_recv_id != 0:
+ try:
+ _thread.stop_thread(self.AI_client_voice_chat_recv_id)
+ except Exception as e:
+ usys.print_exception(e)
+ self.AI_client_voice_chat_recv_id = 0
+ self.AI_client_voice_chat_recv_id = _thread.start_new_thread(self.AI_client_voice_chat_recv, (self.AI_client_voice_chat,))
+ self.AI_client_voice_chat_isconnect = 1
+
+ def websocket_deconnect_voice_chat(self):
+ if self.AI_client_voice_chat_isconnect == 1:
+ self.AI_client_voice_chat_isconnect = 0
+ self.AI_client_voice_chat.close()
+ #websocket发送ping
+ def AI_client_voice_chat_ping(self):
+ pass
+ if self.AI_client_voice_chat_isconnect == 1:
+ #self.AI_client_voice_chat.write_frame(0x09,b'ping ping')
+ self.AI_client_voice_chat_send("ping")
+ print("websocket ping ping")
+
+ #websocket发送数据
+ def AI_client_voice_chat_send(self,data_str):
+ if isinstance(data_str, str):#是字符串
+ print("AI_client_voice_chat_send:{}".format(data_str))
+ pass
+ else:
+ print("AI_client_voice_chat_send:len{}".format(len(data_str)))
+ self.AI_send_data_queue.put([AI_client_voice_chat_num,data_str])
+
+ #Ai VC读数据
+ def AI_client_voice_chat_recv(self,cli):
+ while True:
+ try:
+ # 死循环接收数据
+ utime.sleep_ms(1)
+ recv_data = cli.recv()
+ if not recv_data:
+ # 服务器关闭连接或客户端关闭连接
+ print("AI_client_voice_chat_recv close")
+ #self.AI_client_voice_chat_isconnect = 0
+ #self.websocket_deconnect_voice_chat()
+ break
+ try:
+ if isinstance(recv_data, str):#返回的是字符串
+ print("VC:recv_data:{}".format(recv_data))
+ jsload_data = ujson.loads(recv_data)
+ #print("AI_client_voice_chat_recv jsload_data = {}".format(jsload_data))
+
+ if jsload_data["event"] == "Started" :#会话开始
+ payload = jsload_data["payload"]
+ self.VC_dialog_id = payload["dialog_id"]
+ self.VC_task_id = jsload_data["task_id"]
+ print("VC:Started!!!!!!!!\r\n")
+ if jsload_data["event"] == "SpeechContent" :#asr转译
+ print("VC:SpeechContent!!!!!!!!\r\n")
+ payload = jsload_data["payload"]
+ if(payload['finished'] == True):#asr结束
+ self.voice_chat_state == VC_State_SpeechEnd
+
+ self.talk_ars_end()
+ pass
+ else:
+ self.AI_listen_end = 0
+ self.AI_listen_text = str(payload['text'])#asr文本
+ al_listen_screen_title1.set_text(str(payload['text']))
+ if jsload_data["event"] == "SpeechEnded" :#服务器下发说话结束
+ self.voice_chat_state == VC_State_SpeechEnd
+ if jsload_data["event"] == "RespondingContent" :#chat回答
+
+ payload = jsload_data["payload"]
+ self.AI_label_str=str(payload['text'])#chat文本
+ self.AI_client_chat_play_str=str(payload['text'])
+ self.AI_client_tts_str_sen = str(payload['text'])
+
+
+
+
+ if(payload['finished'] == True):#chat回答 结束,开始tts
+ self.voice_chat_state = VC_State_TTSStart
+ self.AI_client_chat_end_flag = 1
+ pass
+ else:
+
+ self.AI_client_chat_end_flag = 0
+ self.AI_client_tts_data_len = 0
+ #utime.sleep_ms(5)
+
+ if jsload_data["event"] == "RespondingStarted" :#音频开始下发
+ self.timer_out_count = 2
+ self.think_end_result()#文本显示
+ #self.tts_fd = open('/usr/tesr.pcm','w')
+ pass
+ if jsload_data["event"] == "RespondingEnded" :#音频下发结束
+
+ #self.tts_fd.close()
+ pass
+ elif jsload_data["event"] == "DialogStateChanged" :#状态切换事件
+ payload = jsload_data["payload"]
+ if payload["state"] == "Listening":
+ self.voice_chat_state = VC_State_Listening
+ self.AI_client_voice_chat_send_speech()#开始上传语音
+ if payload["state"] == "Thinking":#准备开始TTS
+ self.voice_chat_state = VC_State_Thinking
+
+ self.AI_label_str = ""
+ self.AI_client_chat_end_flag = 0
+ self.AI_client_tts_data_len = 0
+ self.AI_client_tts_data_total_len = 0
+ if payload["state"] == "Responding":
+ self.voice_chat_state = VC_State_Responding
+ elif jsload_data["event"] == "RequestAccepted" :#请求上传语音被允许
+ #self.voice_chat_state = VC_State_Responding
+ #self.AI_client_voice_chat_send_speech()#开始上传语音
+ pass
+ else:#下发音频数据
+ #填充头
+ #self.tts_fd.write(recv_data)
+ #recv_data_len = len(recv_data)
+ # data_len_b = recv_data_len.to_bytes(4,'little')#数据长度转16进制数组
+ # h_data = [ 0x52 ,0x49 ,0x46 ,0x46 #,0x24 ,0x00 ,0x00 ,0x00 #文件标识、文件大小
+ # ,0x57 ,0x41 ,0x56 ,0x45 ,0x66 ,0x6D ,0x74 ,0x20 #文件格式、格式块标识符
+ # ,0x10 ,0x00 ,0x00 ,0x00 ,0x01 ,0x00 ,0x01 ,0x00 ,0x80 ,0x3E ,0x00 ,0x00 #格式块大小4、音频格式2、声道数2、采样率4
+ # ,0x80 ,0x3E ,0x00 ,0x00 ,0x02 ,0x00 ,0x10 ,0x00 ,0x64 ,0x61 ,0x74 ,0x61]#每秒字节数4、数据块对齐2、位深度2、data4
+ # h_data_b = bytes(h_data)
+ # file_len = recv_data_len+len(h_data_b)+4+4
+ # file_len_b = file_len.to_bytes(4,'little')#文件长度转16进制数组
+ # h_data_b = h_data_b[:4]+file_len_b+h_data_b[4:]+data_len_b
+ self.AI_client_tts_data_total_len += len(recv_data)
+ self.AI_client_tts_data_len += len(recv_data)
+ #if self.AI_client_tts_data_total_len >10*1024:
+ self.AI_audio_queue.put([recv_data,self.AI_client_tts_str_sen])
+ print("下发音频数据:{}".format(len(recv_data)))
+ except Exception as e:
+ usys.print_exception(e)
+
+ except Exception as e:
+ usys.print_exception(e)
+ break
+ self.AI_client_voice_chat_isconnect = 0
+ self.AI_client_voice_chat_recv_id = 0
+ def get_new_message_id(self):
+ message_id = self.get_trace_id()+"aaa"+self.get_trace_id()
+ self.VC_message_id=message_id[:32]
+ return self.VC_message_id
+
+ def get_new_task_id(self):
+ task_id = self.get_trace_id()+"aaa"+self.get_trace_id()
+ self.VC_task_id=task_id[:32]
+ return self.VC_task_id
+ #开始录音
+ def VC_Speech_Start(self):
+ self.voice_chat_state = VC_State_SpeechStart
+ if self.VC_record_thread_id != 0:
+ try:
+ _thread.stop_thread(self.VC_record_thread_id)
+ except Exception as e:
+ usys.print_exception(e)
+ self.VC_record_thread_id = 0
+ self.VC_record_thread_id = _thread.start_new_thread(self.VC_record_thread,())
+ def VC_Speech_End(self):
+ self.voice_chat_state = VC_State_SpeechEnd
+ if self.VC_record_thread_id != 0:
+ try:
+ _thread.stop_thread(self.VC_record_thread_id)
+ except Exception as e:
+ usys.print_exception(e)
+ self.VC_record_thread_id = 0
+
+ #获取录音数据
+ def VC_record_thread(self):
+ ##return
+ print("VC_record_thread start!!!!!!!!!!!!!!!!!!!!\r\n")
+ count = 0
+ # try:
+ # uos.remove('/usr/tesr.pcm')
+ # except Exception as e:
+ # usys.print_exception(e)
+ #record_data_queue = Queue(100)
+ #fd = open('/usr/tesr.amr','w')
+ #self.VC_websocket_stop_flasg = 1
+ if self.VC_record_TYPE == 1:
+ h_data= [0x23,0x21 ,0x41 ,0x4D ,0x52 ,0x0A ]
+ h_data_b = bytes(h_data)
+ self.AI_client_voice_chat_send(h_data_b)
+ while True:
+ try:
+ # 死循环接收数据
+ #if self.voice_chat_state == VC_State_SpeechStart:
+ Record_read_buf = bytearray(self.Audio_buf_size)
+
+ Record_len = 0
+ if self.VC_record_TYPE == 0:#pcm
+ if self.record_pcm ==None:
+ break
+ Record_len = self.record_pcm.stream_read(Record_read_buf, self.Audio_buf_size)
+ if Record_len <= 0:
+ try:
+ if self.record_pcm != None:
+ try:
+ self.record_pcm.stream_stop()
+ self.record_pcm.close()
+ self.record_pcm = None
+ except Exception as e:
+ usys.print_exception(e)
+ if self.record_pcm == None:
+ ret = self.record_pcm = audio.Audio.PCM(0,1,16000,0,1,2)
+ print("audio.Audio.PCM:ret:{}".format(ret))
+ ret = self.record_pcm.stream_read_start()
+ print("self.record_pcm.stream_read_start:ret:{}".format(ret))
+ except Exception as e:
+ usys.print_exception(e)
+ utime.sleep_ms(100)
+
+ else :
+
+ Record_len = self.record.stream_read(Record_read_buf, self.Audio_buf_size)
+ utime.sleep_ms(1000)
+
+ #Record_len = 1024*2
+ print("VC_record_thread:{}".format(Record_len))
+ if Record_len > 0:
+ read_buf = bytes(Record_read_buf[:Record_len])
+ #fd.write(read_buf)
+ #record_data_queue.put(read_buf)
+ self.AI_client_voice_chat_send(read_buf)
+ #print("VC_record_thread:{}".format(len(Record_read_buf)))
+ count+=len(read_buf)
+ if count>=500*1024:#结束
+ self.AI_client_voice_chat_end_speech()
+ break
+ utime.sleep_ms(40)
+ if self.voice_chat_state != VC_State_SpeechStart:
+ break
+ except Exception as e:
+ usys.print_exception(e)
+ break
+ # while True:
+ # if record_data_queue.empty()!=True:
+ # self.AI_client_voice_chat_send(record_data_queue.get())
+ # else:
+ # break
+ #self.AI_client_voice_chat_end_speech()
+ #fd.close()
+ #self.VC_websocket_stop_flasg = 0
+ #if self.AI_TYPE == AI_TYPE_voice_chat:
+
+ print("VC_record_thread:exit")
+ self.VC_record_thread_id = 0#线程退出
+ #开始会话
+ def AI_client_voice_chat_start_requset(self):
+ json_data = \
+ {
+ "header":{
+ "trace_id":self.get_trace_id(),
+ "event":"Start"
+ },
+ "payload":{
+ "device_id":"test_device12345678_id",
+ "user_agent":"python",
+ "in_format":"pcm",
+ "out_format":"mp3",
+ "sample_rate":16000,
+ "space_time": 100
+ }
+ }
+ if self.VC_play_TYPE == 1:
+ json_data["payload"]["out_format"]='pcm'
+ if self.VC_record_TYPE == 1 :
+ json_data["payload"]["in_format"]='amr'
+ json_data["payload"]["sample_rate"]=8000
+ self.record.stream_start(audio.Record.AMRWB, 8000, 60)
+ pass
+ else:
+ print("record_pcm.stream_read_start()!!!!!!!!!!!!")
+ if self.record_pcm != None:
+ try:
+ self.record_pcm.stream_stop()
+ self.record_pcm.close()
+ self.record_pcm = None
+ except Exception as e:
+ usys.print_exception(e)
+ if self.record_pcm == None:
+ ret = self.record_pcm = audio.Audio.PCM(0,1,16000,0,1,2)
+ print("audio.Audio.PCM:ret:{}".format(ret))
+ ret = self.record_pcm.stream_read_start()
+ print("self.record_pcm.stream_read_start:ret:{}".format(ret))
+ self.AI_client_voice_chat_send(ujson.dumps(json_data))
+ self.voice_chat_state = VC_State_None
+ #请求上传语音
+ def AI_client_voice_chat_speak_requset(self):
+ json_data = \
+ {
+ "header": {
+ "namespace": "VoiceChat",
+ "name": "RequestToSpeak",
+ "appkey": self.VC_appkey,
+ "message_id":self.VC_message_id,
+ "task_id": self.VC_task_id
+ },
+ "payload": {
+ "dialog_id": self.VC_dialog_id,
+ }
+ }
+ self.AI_client_voice_chat_send(ujson.dumps(json_data))
+ #开始上传语音
+ def AI_client_voice_chat_send_speech(self):
+ json_data = \
+ {
+ "header":{
+ "trace_id":"ailaqbo0r6o",
+ "event":"SendSpeech"
+ },
+ "payload":
+ {
+ "dialog_id":self.VC_dialog_id
+ }
+ }
+ self.AI_client_voice_chat_send(ujson.dumps(json_data))
+ self.VC_Speech_Start()#开启线程获取录音数据
+ #结束上传语音
+ def AI_client_voice_chat_end_speech(self):
+ json_data = \
+ {
+ "header":{
+ "trace_id":"ailaqbo0r6o",
+ "event":"StopSpeech"
+ },
+ "payload":{
+ "dialog_id":self.VC_dialog_id
+ }
+ }
+ self.AI_client_voice_chat_send(ujson.dumps(json_data))
+ self.VC_Speech_End()#停止线程录音
+ #####################################################
+ #北科聚合平台
+ #####################################################
+ #AI识别链路
+ def websocket_connect_chat(self):
+ print("websocket_connect_chat:{}!!!!!!!!!!!!!!!!!!!!!".format(self.AI_client_chat_isconnect))
+ #if self.AI_client_chat_isconnect == 0:
+ # 创建客户端, debug=True输出日志, ip和端口需要自己填写, 或者是域名
+ try:
+
+ self.AI_client_chat = uwebsocket.Client.connect('wss://nls-gateway-cn-beijing.aliyuncs.com/ws/v1',headers=Headers, debug=False)
+ except Exception as e: #网络连接异常
+ usys.print_exception(e)
+ print("websocket_connect_chat error!!!\r\n")
+ self.connect_timerout_popup(2)
+ return
+ # 线程接收数据
+ if self.AI_client_chat_recv_id != 0:
+ try:
+ _thread.stop_thread(self.AI_client_chat_recv_id)
+ except Exception as e:
+ usys.print_exception(e)
+ self.AI_client_chat_recv_id = 0
+ self.AI_client_chat_recv_id = _thread.start_new_thread(self.AI_client_chat_recv, (self.AI_client_chat,))
+ self.AI_client_chat_isconnect = 1
+ def websocket_deconnect_chat(self):
+ if self.AI_client_chat_isconnect == 1:
+ self.AI_client_chat_isconnect = 0
+ self.AI_client_chat.close()
+
+ def AI_client_chat_send(self,data_str):
+ chat_data_str = "{\"type\":\"chat\",\"content\":\"%s\"}"%(data_str)
+ #self.AI_client_chat.send(chat_data_str)
+ self.AI_send_data_queue.put([AI_client_chat_num,chat_data_str])
+ #Ai chat读数据
+ def AI_client_chat_recv(self,cli):
+ while True:
+ try:
+ # 死循环接收数据
+ recv_data = cli.recv()
+ if not recv_data:
+ # 服务器关闭连接或客户端关闭连接
+ print("AI_client_chat_recv close")
+ #self.AI_client_chat_isconnect = 0
+ #self.websocket_deconnect_chat()
+ break
+ try:
+ #print("AI_client_chat_recv recv_data = {}".format(recv_data))
+ jsload_data = ujson.loads(recv_data)
+ #print("AI_client_chat_recv jsload_data = {}".format(jsload_data))
+ chat_data = jsload_data["content"]
+ if chat_data:
+ #self.AI_client_tts_send(jsload_data["content"])#TTS语音播放AI结果
+ print("AI_client_chat_recv chat_data = {}".format(chat_data))
+ self.AI_label_str+=str(chat_data)
+ self.AI_client_chat_play_str+=str(chat_data)
+ self.think_end_result()
+ if self.TTS_PRO_TYPE == 1:
+ AI_label.set_text(self.AI_label_str)
+ # EventMesh.publish("system_sleep_rest")#防止黑屏
+ else:
+ # if self.AI_label_str:
+ # self.AI_client_tts_send(self.AI_label_str)#TTS语音播放AI结果
+ print("AI_client_chat_recv chat_data start\r\n")
+ if jsload_data['type']=='start':
+ self.AI_label_str = ""
+ self.AI_client_chat_end_flag = 0
+ self.AI_client_tts_data_len = 0
+ self.websocket_connect_tts() #连接tts
+ #
+ elif jsload_data['type']=='end':
+ print("chat end!!!!!!!!!!!!!!")
+ self.AI_client_chat_end_flag = 1
+ if len(self.AI_client_chat_play_str) > 100:
+ utime.sleep_ms(100)
+ except Exception as e:
+ usys.print_exception(e)
+
+ except Exception as e:
+ usys.print_exception(e)
+ break
+ self.AI_client_chat_isconnect = 0
+ self.AI_client_chat_recv_id = 0
+##############################################################################
+ #文字转语音链路
+ def websocket_connect_tts(self):
+ print("websocket_connect_tts:{}!!!!!!!!!!!!!!!!!!!!!!".format(self.AI_client_tts_isconnect))
+ if self.AI_client_tts_isconnect == 0:
+ try:
+ # self.AI_client_tts = uwebsocket.Client.connect('ws://40.67.151:9099/tts/', debug=False)
+ self.AI_client_tts = uwebsocket.Client.connect('ws://118.145.158.207:80/tts/long-text-stream', debug=False)
+ except Exception as e: #网络连接异常
+ usys.print_exception(e)
+ print("websocket_connect_tts ERROR:{}\r\n".format(e))
+ self.connect_timerout_popup(2)
+ return
+ print("websocket_connect_tts:self.AI_client_tts {}\r\n".format(self.AI_client_tts))
+ # 线程接收数据
+ if self.AI_client_tts_recv_id != 0:
+ try:
+ _thread.stop_thread(self.AI_client_tts_recv_id)
+ except Exception as e:
+ usys.print_exception(e)
+ self.AI_client_tts_recv_id = 0
+ #_thread.stack_size(20*1024)
+ self.AI_client_tts_recv_id = _thread.start_new_thread(self.AI_client_tts_recv, (self.AI_client_tts,))
+ #_thread.stack_size(8*1024)
+ self.AI_client_tts_isconnect = 1
+ self.AI_client_tts_start()
+ def websocket_deconnect_tts(self):
+ if self.AI_client_tts_isconnect == 1:
+ self.AI_client_tts_isconnect = 0
+ try:
+ self.AI_client_tts.close()
+ except Exception as e:
+ usys.print_exception(e)
+ def AI_client_tts_timer_cb(self,*argc):
+ # EventMesh.publish("system_sleep_rest")#防止黑屏
+ self.tts_time_count+=1
+ if self.play_flag == 0:
+ return
+ if self.TTS_PRO_TYPE == 1:
+ #tts数据入队
+ self.AI_client_tts_put_data()
+ #print("AI_audio_queue.size:{},AI_send_data_queue.size:{} self.AI_client_chat_play_str:{} self.AI_client_tts_tra_flag:{}\r\n".format(self.AI_audio_queue.size(),self.AI_send_data_queue.size(),self.AI_client_chat_play_str,self.AI_client_tts_tra_flag) )
+ #字符串分段发送,等待播放缓存变小
+ if len(self.AI_client_chat_play_str) > 0 and self.AI_client_tts_data_len < 150*1024 :#and (self.AI_client_tts_str_total_len <100 or self.AI_client_tts_str_total_len - self.AI_client_tts_data_total_len//672 < 60)缓存200k以下,且tts发送文字字节数比返回音频数据少60字节
+
+ self.tts_time_outcount+=1
+ # play_str = split_string(self.AI_client_chat_play_str,40)#
+ # if play_str =="":#没找到句号或者逗号,切割字符串
+ if self.TTS_PRO_TYPE == 1:
+ play_str = sub_utf8_String(self.AI_client_chat_play_str,20)#按中文切割字符串
+ self.AI_client_tts_str_total_len += len(play_str)
+ elif self.TTS_PRO_TYPE == 0:
+ if self.AI_audio_queue.size() >= 4 or self.AI_client_tts_tra_flag == 1 or (self.tts_time_outcount < 3 and len(self.AI_client_chat_play_str) < 100):#存了超过4句,就等小于3次在转化
+ return
+ play_str = split_string(self.AI_client_chat_play_str,50,100)#按逗号,句号切割
+ if play_str =="" or len(play_str) > 100:#没找到句号或者逗号,切割字符串
+ play_str = sub_utf8_String(self.AI_client_chat_play_str,100)#按中文切割字符串
+ self.AI_client_tts_tra_flag = 1
+ self.AI_client_tts_str_sen = play_str
+ if len(play_str) == 0:
+ return
+ self.AI_client_tts_send(play_str)#TTS语音播放AI结果
+ self.AI_client_chat_play_str = self.AI_client_chat_play_str[len(play_str):]
+ #print("TTS play:len{},data{}".format(len(play_str),play_str))
+ if self.TTS_PRO_TYPE == 1 and len(self.AI_client_chat_play_str) <=0 and self.AI_client_chat_end_flag ==1 :
+ self.AI_client_chat_end_flag=0
+ self.AI_client_tts_end()
+
+ def AI_client_tts_send(self,data_str):
+ data_l = {}
+ if self.TTS_PRO_TYPE == 1:
+
+ data_l ={"header": {"event": "RunSynthesis","trace_id": self.get_trace_id()},"payload": {"text":"%s"%(data_str)}}
+ elif self.TTS_PRO_TYPE == 0:
+ data_l ={
+ "header": {
+ "event": "LongTextStream",
+ "trace_id": self.get_trace_id()
+ },
+ "payload": {
+ "voice":"zhixiaomei",#"xiaoyun",
+ "format":"mp3",
+ "sample_rate":8000,
+ "volume":90,
+ "speech_rate":30,
+ "text":"%s"%(data_str)
+ }
+ }
+ json_data = ujson.dumps(data_l)
+ self.AI_send_data_queue.put([AI_client_tts_num,json_data])
+ def AI_client_tts_start(self):
+ data_l ={"header": {"event": "StartSynthesis","trace_id": self.get_trace_id()},
+ "payload": {"voice":"xiaoyun","format":"mp3","sample_rate":8000,"volume":60,"speech_rate":1,}}
+ #print("\r\nAI_client_tts_start!!!!!!!!!!!!\r\n")
+ json_data = ujson.dumps(data_l)
+ #print("AI_client_tts_send:{}".format(json_data))
+ self.record.stop()#关闭录音
+ self.record_timer.stop()#关闭定时器
+ self.tts_time_count = 0
+ self.tts_data_tmp = b''
+
+ self.AI_client_tts_data_total_len = 0
+ self.AI_client_tts_str_total_len= 0
+
+ #self.AI_client_tts_str_sen = ""
+ if self.TTS_PRO_TYPE == 1:
+ self.AI_client_tts_data_len = 0
+ self.AI_client_tts_tra_flag = 1
+ self.AI_client_tts.send(json_data)
+ utime.sleep_ms(100)
+ #self.AI_send_data_queue.put([AI_client_tts_num,json_data])
+ def AI_client_tts_end(self):
+ if self.TTS_PRO_TYPE == 1:
+ data_l ={"header": {"event": "StopSynthesis","trace_id": self.get_trace_id()}}
+ json_data = ujson.dumps(data_l)
+ self.AI_send_data_queue.put([AI_client_tts_num,json_data])
+ #TTS数据入队
+ def AI_client_tts_put_data(self):
+ #存够5k数据或者3秒超时
+ if (self.AI_client_tts_full_sentence_flag == 1 and len(self.tts_data_tmp) >30*1024) \
+ or self.tts_time_count >= 3 \
+ or (self.AI_client_tts_full_sentence_flag == 1 and self.AI_client_tts_tra_flag == 1 and len(self.tts_data_tmp) >5*1024):
+ self.AI_client_tts_full_sentence_flag == 0
+ #self.AI_client_tts_data_len +=len(self.tts_data_tmp)
+ if self.AI_client_tts_tra_flag == 1:#第一个数据去掉头
+ self.tts_data_tmp = self.tts_data_tmp[9:]
+ if len(self.tts_data_tmp)>0:
+ self.AI_audio_queue.put([self.tts_data_tmp,self.AI_client_tts_str_sen])
+ print("入:{},{}".format(len(self.tts_data_tmp),self.AI_client_tts_data_len))
+ self.tts_time_count = 0
+ self.tts_data_tmp = b''
+ if self.TTS_PRO_TYPE == 1:
+ self.AI_client_tts_tra_flag = 0
+ gc.collect()#GC主动回收内存
+ #文字转语音链路读数据
+ def AI_client_tts_recv(self,cli):
+ recv_data_len_same_count = 0
+ recv_data_len = 0
+ while True:
+ try:
+ # 死循环接收数据
+
+ recv_data = cli.recv()
+ if not recv_data:
+ # 服务器关闭连接或客户端关闭连接
+ print("AI_client_tts_recv close!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n")
+ print("AI_client_tts_recv close!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n")
+ break
+ try:
+ # print("AI_client_tts_recv :{}".format(len(recv_data)))
+ #结束标志{"header":{"event":"EndSynthesis","msg":"success","status":20000000,"task_id":"ffd727e620000803280c5a6498d0e321"}}
+ if isinstance(recv_data, str):
+ print("AI_client_tts_recv:str recv_data:{}".format(recv_data))
+ if recv_data.find('\"event\":\"EndSynthesis\"') != -1:
+ print("EndSynthesis!!!!!!!!!!!!!!!!!\r\n")
+ print("EndSynthesis!!!!!!!!!!!!!!!!!!\r\n")
+ #self.tts_data_tmp=self.tts_data_tmp[9:-100]
+ try:
+ self.websocket_deconnect_tts()#断开
+ except Exception as e: #网络连接异常
+ usys.print_exception(e)
+
+
+ self.tts_time_count = 60#立即发送剩余数据
+ self.AI_client_tts_put_data()
+
+ self.AI_client_tts_full_sentence_flag = 1
+ break
+ if recv_data.find('\"msg\":\"success\"') == -1:
+ break
+ else:
+ #判断是否是一个完整的句子
+ recv_data_len_tmp = len(recv_data)
+ if self.TTS_PRO_TYPE == 1:
+ print("recv_data_len_same_count:{}".format(recv_data_len_same_count))
+ if recv_data_len == recv_data_len_tmp:
+ recv_data_len_same_count+=1
+ else:
+ if recv_data_len_same_count > 2:#认为是完整的句子
+ self.AI_client_tts_full_sentence_flag = 1
+ print("self.AI_client_tts_full_sentence_flag = 1!!!!!!!!!!!!")
+ recv_data_len_same_count = 0
+ recv_data_len = recv_data_len_tmp
+ self.tts_data_tmp+=recv_data
+ self.AI_client_tts_data_len+=recv_data_len_tmp
+ self.AI_client_tts_data_total_len += recv_data_len_tmp
+ if self.TTS_PRO_TYPE == 1:
+ self.AI_client_tts_put_data()
+ #utime.sleep_ms(1000)
+ except Exception as e:
+ usys.print_exception(e)
+ # print(recv_data)
+ # print(type(recv_data))
+ mem = gc.mem_free()
+ print('2剩余内存RAM:{} KB'.format(mem / 1024))
+ except Exception as e:
+ usys.print_exception(e)
+ break
+ self.AI_client_tts_isconnect = 0
+ self.AI_client_tts_recv_id = 0
+ self.AI_client_tts_tra_flag = 0
+#######################################################################
+ #语音转文字链路
+ def websocket_connect_asr(self):
+ print("websocket_connect_asr:{}!!!!!!!!!!!!!!!!!!!!".format(self.AI_client_asr_isconnect))
+ try:
+ self.websocket_deconnect_asr()#先断一次,预防出错
+ except Exception as e:
+ usys.print_exception(e)
+
+ try:
+ self.AI_client_asr = uwebsocket.Client.connect('ws://118.145.158.207:80/asr/ws', debug=False)
+ except Exception as e: #网络连接异常
+ usys.print_exception(e)
+ print("websocket_connect_asr error!!!\r\n")
+ self.connect_timerout_popup(2)
+ return
+ # 线程接收数据
+ if self.AI_client_asr_recv_id != 0:
+ try:
+ _thread.stop_thread(self.AI_client_asr_recv_id)
+ except Exception as e:
+ usys.print_exception(e)
+ self.AI_client_asr_recv_id = 0
+ self.AI_client_asr_recv_id = _thread.start_new_thread(self.AI_client_asr_recv, (self.AI_client_asr,))
+ self.AI_client_asr_isconnect = 1
+ def websocket_deconnect_asr(self):
+ if self.AI_client_asr_isconnect == 1:
+ self.AI_client_asr_isconnect = 0
+ self.AI_client_asr.close()
+ def AI_client_asr_send(self,data_bytes):
+ #self.AI_client_asr.send(data_bytes)
+ self.AI_send_data_queue.put([AI_client_asr_num,data_bytes])
+ def AI_client_asr_start(self):
+ self.AI_send_data_queue.put([AI_client_asr_num,"{\"header\":{\"event\":\"StartTranscription\",\"trace_id\":\"%s\"},\"payload\":{\"format\":\"amr\",\"sample_rate\":8000}}"%(self.get_trace_id())])
+ #语音转文字链路读数据
+ def AI_client_asr_recv(self,cli):
+
+ while True:
+ try:
+ # 死循环接收数据
+ recv_data = cli.recv()
+ if not recv_data:
+ # 服务器关闭连接或客户端关闭连接
+ print("AI_client_asr_recv close")
+ #self.AI_client_asr_isconnect = 0
+ #self.websocket_deconnect_asr()
+ break
+ try:
+ if isinstance(recv_data, str):
+ jsload_data = ujson.loads(recv_data)
+ print("jsload_data = {}".format(jsload_data))
+ if recv_data.find('\"result\"') == -1:
+ #if jsload_data["result"] == None:
+ print("continue recv_data:{}".format(recv_data))
+ continue
+ if jsload_data["result"] == None:
+ print("continue recv_data:{}".format(recv_data))
+ continue
+ if jsload_data["result"]["result"]:
+ self.AI_listen_text = str(jsload_data["result"]["result"])
+ al_listen_screen_title1.set_text(str(jsload_data["result"]["result"]))
+ # AI_listen_text.set_text(str(jsload_data["result"]["result"]))
+ if jsload_data["result"]["is_end"] == True: #{"type":"chat","content":"你好"}
+ self.talk_ars_end()
+ break
+ #chat_data = bytearray(chat_data_str)
+ # AI_label.set_text("思考中...")
+ # self.AI_client_chat_send(str(jsload_data["result"]["result"]))
+ # print("chat_data:{}".format(str(jsload_data["result"]["result"])))
+ # self.record.stop()#关闭录音
+ # self.record_timer.stop()#关闭定时器
+
+ # try:
+ # self.websocket_deconnect_asr()
+ # break
+ # except Exception as e:
+ # usys.print_exception(e)
+ elif jsload_data["result"]["is_end"] == False:
+ self.AI_listen_end = 0
+ # AI_label.set_text("语音识别中...")
+ except Exception as e:
+ print("error recv_data:{}".format(recv_data))
+ usys.print_exception(e)
+
+ except Exception as e:
+ usys.print_exception(e)
+ break
+ self.AI_client_asr_isconnect = 0
+ self.AI_client_asr_recv_id = 0
+ ###############################################
+ #发送数据队列
+ def AI_send_data_queue_thread(self):
+ while True:
+ #data[0]是websocket连接对象编号,data[1]是数据
+ if self.VC_websocket_stop_flasg == 1:
+ utime.sleep_ms(1)
+ continue
+ data = self.AI_send_data_queue.get()
+ if data != None:
+ try:
+ #data["func"](data["data"])
+ # self.record.stop()
+ # self.aud.playStream(4, data)
+ # self.record.stream_start(audio.Record.AMRNB, 8000, 60)
+ # 发送数据
+ #bytes_data = bytes(data[1])
+ #data[0].send(data[1])
+ if data[0] == AI_client_chat_num:
+ if self.AI_client_chat_isconnect == 0:
+ try:
+ self.websocket_connect_chat()
+ except Exception as e: #网络连接异常
+ usys.print_exception(e)
+ if self.AI_client_chat != None:
+ tmp = self.AI_client_chat.send(data[1])
+ print("chat send_data:{} tmp:{}".format(len(data[1]),tmp))
+ if data[0] == AI_client_asr_num:
+ if isinstance(data[1], str):
+ print("ASR:AI_client_asr_isconnect:{},data:{}",self.AI_client_asr_isconnect,data[1])
+ if self.AI_client_asr_isconnect == 0:
+ try:
+ self.websocket_connect_asr()
+ except Exception as e: #网络连接异常
+ usys.print_exception(e)
+ print("asr send_data:{}".format(len(data[1])))
+ if self.AI_client_asr != None:
+ self.AI_client_asr.send(data[1])
+ if data[0] == AI_client_tts_num:
+ if self.AI_client_tts_isconnect == 0:
+ try:
+ self.websocket_connect_tts()
+ except Exception as e: #网络连接异常
+ usys.print_exception(e)
+ print("tts send_data:{}".format((data[1])))
+ if self.AI_client_tts != None:
+ self.AI_client_tts.send(data[1])
+ if data[0] == AI_client_voice_chat_num:
+ if self.AI_client_voice_chat_isconnect == 0:
+ try:
+ self.websocket_connect_voice_chat()
+ except Exception as e: #网络连接异常
+ usys.print_exception(e)
+ self.pingping_timerout = 0
+ #print("VC: send_data len:{}".format(len(data[1])))
+ if self.AI_client_voice_chat != None:
+ self.AI_client_voice_chat.send(data[1])
+ #print("VC: send_data end")
+ except Exception as e:
+ print("DeviceInfo_queue_thread:ERROR:{}".format(e))
+ usys.print_exception(e)
+ if data[0] == AI_client_chat_num:
+ self.AI_client_chat_isconnect = 0
+ try:
+ self.websocket_connect_chat()
+ except Exception as e: #网络连接异常
+ usys.print_exception(e)
+ if data[0] == AI_client_asr_num:
+ self.AI_client_asr_isconnect = 0
+ try:
+ self.websocket_connect_asr()
+ except Exception as e: #网络连接异常
+ usys.print_exception(e)
+ if data[0] == AI_client_tts_num:
+ count =10
+ while 1:
+ count-=1
+ if count<=0:
+ break
+ self.AI_client_tts_isconnect = 0
+ try:
+ self.websocket_connect_tts()
+ except Exception as e: #网络连接异常
+ usys.print_exception(e)
+ #self.AI_client_tts_start()
+ if self.AI_client_tts_isconnect == 1:
+ try:
+ if self.AI_client_tts != None:
+ self.AI_client_tts.send(data[1])
+ break
+ except Exception as e:
+ usys.print_exception(e)
+ if data[0] == AI_client_voice_chat_num:
+ self.AI_client_voice_chat_isconnect = 0
+ try:
+ self.websocket_connect_voice_chat()
+ except Exception as e: #网络连接异常
+ usys.print_exception(e)
+
+ ############################################
+ # 音频队列
+ def AI_audio_queue_thread(self):
+
+ while True:
+ try:
+ if 1: #self.audio_play_state == 0:
+ print("AI_audio_queue_thread")
+ if self.play_flag == 1:
+ self.play_flag_init = 1
+ data = self.AI_audio_queue.get()
+ #self.AI_client_tts_data_len=len(data)
+ print("audio_queue:len:{},data{} self.play_flag:{}\r\n".format(len(data[0]),len(data[1]),self.play_flag))
+ if len(data[0]) > 1:
+ if self.TTS_PRO_TYPE == 0:
+ if self.play_flag == 1:
+ if self.AI_TYPE == AI_TYPE_voice_chat:
+ self.AI_label_answer=data[1]
+ else :
+ self.AI_label_answer+=data[1]
+ EventMesh.publish("publish_message_event_ui",{"func":self.ai_talk_end_show_text_cb,"data":0})
+ # AI_label.set_text(self.AI_label_answer)
+ try:
+ if self.play_flag == 1:
+ if self.VC_play_TYPE == 1:
+ if self.play_pcm == None:
+ self.play_pcm = audio.Audio.PCM(0,1,16000,1,1,2)
+ self.play_pcm.setVolume(11)
+ ret = self.play_pcm.stream_write_start()
+ print("self.record_pcm.stream_write_start:ret:{}".format(ret))
+ write_buf = bytearray(data[0])
+ ret = self.play_pcm.stream_write(write_buf,len(write_buf))
+ #ret= self.aud.playStream(1, data[0])#播放音频流
+ print("play_pcm.stream_write:{}".format(ret))
+ else:
+
+ tmp= self.aud.playStream(3, data[0])#播放音频流
+
+ if tmp != 0:
+ print("2playStream:error tmp:{} data len:{}!!!!!!!!!!!!".format(tmp,len(data[0])))
+ # # #播放失败的时候填充WAV头
+ # data_len = len(data[0])
+ # data_len_b = data_len.to_bytes(4,'little')#数据长度转16进制数组
+ # h_data = [ 0x52 ,0x49 ,0x46 ,0x46 #,0x24 ,0x00 ,0x00 ,0x00 #文件标识、文件大小
+ # ,0x57 ,0x41 ,0x56 ,0x45 ,0x66 ,0x6D ,0x74 ,0x20 #文件格式、格式块标识符
+ # ,0x10 ,0x00 ,0x00 ,0x00 ,0x01 ,0x00 ,0x01 ,0x00 ,0x80 ,0x3E ,0x00 ,0x00 #格式块大小4、音频格式2、声道数2、采样率4
+ # ,0x80 ,0x3E ,0x00 ,0x00 ,0x02 ,0x00 ,0x10 ,0x00 ,0x64 ,0x61 ,0x74 ,0x61]#每秒字节数4、数据块对齐2、位深度2、data4
+ # h_data_b = bytes(h_data)
+ # file_len = data_len+len(h_data_b)+4+4
+ # file_len_b = file_len.to_bytes(4,'little')#文件长度转16进制数组
+ # h_data_b = h_data_b[:4]+file_len_b+h_data_b[4:]+data_len_b
+ # #self.aud.playStream(2, h_data_b)#播放音频流
+ # tmp= self.aud.playStream(2, h_data_b+data[0])#播放音频流
+ # print("3playStream:tmp:{} !!!!!!!!!!!!".format(tmp))
+ self.AI_client_tts_data_len -=len(data[0])
+ if len(self.AI_client_chat_play_str) == 0: #播放完了
+ self.play_end = 1
+ print("出:{},{}!!!".format(len(data[0]),self.AI_client_tts_data_len))
+ mem = gc.mem_free()
+ print('1剩余内存RAM:{} KB'.format(mem / 1024))
+ except Exception as e:
+ print("AI_audio_queue_thread:ERROR:")
+ usys.print_exception(e)
+ else:
+ if self.play_flag_init == 1:
+ self.play_flag_init = 0
+ self.aud.stopPlayStream()
+ utime.sleep_ms(2)
+ except Exception as e:
+ print("AI_audio_queue_thread:ERROR:")
+ usys.print_exception(e)
+
+ def lcd_off(self):
+ self.play_flag = 0
+ self.aud.stopPlayStream()
+ self.aud.stopAll()
+ EventMesh.publish("publish_message_event_ui",{"func":self.upload_img,"data":0})
+ self._1S_timer.stop()
+
+ def lcd_on(self):
+ # self.play_flag = 1
+ # EventMesh.publish("publish_message_event_ui",{"func":self.upload_img,"data":1})
+ self._1S_timer.start(1000,1,self._1S_timer_cb)
+
+ def Close(self):
+ try:
+ #销毁线程
+ if self.AI_audio_queue_thread_id != 0:
+ try:
+ _thread.stop_thread(self.AI_audio_queue_thread_id)
+ except Exception as e:
+ usys.print_exception(e)
+ self.AI_audio_queue_thread_id = 0
+ if self.AI_send_data_queue_thread_id != 0:
+ try:
+ _thread.stop_thread(self.AI_send_data_queue_thread_id)
+ except Exception as e:
+ usys.print_exception(e)
+ self.AI_send_data_queue_thread_id = 0
+ if self.AI_client_chat_recv_id != 0:
+ try:
+ _thread.stop_thread(self.AI_client_chat_recv_id)
+ except Exception as e:
+ usys.print_exception(e)
+ self.AI_client_chat_recv_id = 0
+ if self.AI_client_tts_recv_id != 0:
+ try:
+ _thread.stop_thread(self.AI_client_tts_recv_id)
+ except Exception as e:
+ usys.print_exception(e)
+ self.AI_client_tts_recv_id = 0
+ if self.AI_client_asr_recv_id != 0:
+ try:
+ _thread.stop_thread(self.AI_client_asr_recv_id)
+ except Exception as e:
+ usys.print_exception(e)
+ self.AI_client_asr_recv_id = 0
+ if self.AI_client_voice_chat_recv_id != 0:
+ try:
+ _thread.stop_thread(self.AI_client_voice_chat_recv_id)
+ except Exception as e:
+ usys.print_exception(e)
+ self.AI_client_voice_chat_recv_id = 0
+ if self.VC_record_thread_id != 0:
+ try:
+ _thread.stop_thread(self.VC_record_thread_id)
+ except Exception as e:
+ usys.print_exception(e)
+ self.VC_record_thread_id = 0
+ except Exception as e:
+ usys.print_exception(e)
+
+ if self.record_pcm != None:
+ print("Close:record_pcm.close()!!!!!!!!!!!!!!!!!!")
+ try:
+ self.record_pcm.stream_stop()
+ self.record_pcm.close()
+ except Exception as e:
+ usys.print_exception(e)
+ self.record_pcm=None
+
+ if self.play_pcm != None:
+ print("Close:play_pcm.close()!!!!!!!!!!!!!!!!!!")
+ try:
+ self.play_pcm.stream_stop()
+ self.play_pcm.close()
+ except Exception as e:
+ usys.print_exception(e)
+ self.play_pcm=None
+
+ self._1S_timer.stop()
+ self.AI_send_data_queue.clear()
+ print("close:AI_send_data_queue:size:{}".format(self.AI_send_data_queue.size()))
+ self.AI_audio_queue.clear()
+ self.AI_client_tts_str_sen = ''
+ self.record_timer.stop()
+ self.AI_client_tts_timer.stop()
+ self.aud.stopPlayStream()
+ self.aud.stopAll()
+ self.AI_client_chat_play_str = ""
+ self.AI_client_tts_tra_flag = 0
+ self.record.stop()#关闭录音
+ Record_read_buf = bytearray(self.Audio_buf_size)
+ for i in range(10):
+ Record_len = self.record.stream_read(Record_read_buf, self.Audio_buf_size)
+ print("Record_len:!!!!!!{}\r\n".format(Record_len))
+ if Record_len <= 0:
+ break
+ self.AI_label_answer = ""
+ self.refresh_count = 0
+ self.refresh_texttimer.stop()
+ self.clear_flag()
+ num = EventMesh.publish("get_volum_size")
+ if num == None:
+ num = 8
+ self.aud.setVolume(num)#恢复原始音量
+ try:
+ self.websocket_deconnect_asr()
+ self.websocket_deconnect_tts()
+ self.websocket_deconnect_chat()
+ self.websocket_deconnect_voice_chat()
+ except Exception as e:
+ usys.print_exception(e)
+
+ def done_bottom_to_top(self):
+ print("done_bottom_to_top:")
+ self.hard_flag_next = 1
+
+ def done_top_to_bottom(self):
+ # self.timer_start_cb()
+ print("done_top_to_bottom")
+ self.hard_flag_prev = 1
+ pass
+
+ def done_return(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ # def done_left_to_right(self):
+ # # print("ai done_right_to_left\r\n")
+ # if (AI_talk_end_screen.has_flag(lv.obj.FLAG.HIDDEN)) == False or (AI_listen_screen.has_flag(lv.obj.FLAG.HIDDEN)) == False or\
+ # (AI_talk_screen.has_flag(lv.obj.FLAG.HIDDEN)) == False or (AI_no_net_screen.has_flag(lv.obj.FLAG.HIDDEN)) == False or \
+ # (AI_connect_timerout_screen.has_flag(lv.obj.FLAG.HIDDEN)) == False or (AI_not_listen_text_screen.has_flag(lv.obj.FLAG.HIDDEN)) == False or \
+ # (AI_think_screen.has_flag(lv.obj.FLAG.HIDDEN)) == False:
+ # EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+ pass
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+ pass
+
--- /dev/null
+from common import Abstract, LogAdapter
+import EventMesh
+import uwebsocket
+import usys
+import gc
+import urandom
+import uhashlib
+import ubinascii
+import ujson
+import osTimer
+import _thread
+from queue import Queue
+import utime
+import audio
+import uos
+from machine import Pin
+from machine import ExtInt
+from machine import WDT
+import modem
+import sim
+import net
+import base64
+import ucryptolib
+import urandom as random
+import request
+import ql_fs
+from misc import Power,USB,PowerKey
+import ntptime
+import machine
+import dataCall
+import constants
+import versions
+try:
+ import VAD
+except Exception as e:
+ usys.print_exception(e)
+#dev_type = "G10"
+#dev_type = "7PIN_BK"#小瑞
+#dev_type = "7PIN_BK_coze"#k扣子小瑞
+#dev_type = "7PIN_BK_EU"#英文小瑞
+#dev_type = "7PIN_coze"#柒牌扣子
+#dev_type = "7PIN"#柒牌
+#dev_type = 'momo'#食梦貘
+#dev_type = 'sjgq'#四季甘泉
+#dev_type = 'szbst'#深圳百事通
+dev_type = 'jswm'#金三完美
+#dev_type = 'jswm_BOX'#金三完美柒牌盒子
+#dev_type = 'csh'#慈善会
+class AI_led(Abstract):
+ def __init__(self):
+ if dev_type == "G10" or dev_type == 'jswm':
+ self.led_red = Pin(Pin.GPIO36, Pin.OUT, Pin.PULL_PD, 0)
+ self.led_green = Pin(Pin.GPIO44, Pin.OUT, Pin.PULL_PD, 1)
+ self.led_blue = Pin(Pin.GPIO21, Pin.OUT, Pin.PULL_PD, 1)
+ elif dev_type == "7PIN_BK_EU":
+ self.led_red = Pin(Pin.GPIO36, Pin.OUT, Pin.PULL_PD, 0)
+ #self.led_green = Pin(Pin.GPIO21, Pin.OUT, Pin.PULL_PD, 1)
+ self.led_green = Pin(Pin.GPIO8, Pin.OUT, Pin.PULL_PD, 1)
+ self.led_blue = Pin(Pin.GPIO19, Pin.OUT, Pin.PULL_PD, 1)
+ else:
+ self.led_red = Pin(Pin.GPIO36, Pin.OUT, Pin.PULL_PD, 0)
+ self.led_green = Pin(Pin.GPIO21, Pin.OUT, Pin.PULL_PD, 1)
+ self.led_blue = Pin(Pin.GPIO19, Pin.OUT, Pin.PULL_PD, 1)
+
+ #=1 红灯闪,=2白灯闪,=3绿灯闪,=4全部灯闪
+ self.led_flicker_flag = 0
+ self.led_flicker_on_off_flag = 0
+ self.led_flicker_timer = osTimer()
+
+ EventMesh.subscribe("open_led_red",self.open_led_red)
+ EventMesh.subscribe("open_led_blue",self.open_led_blue)
+ EventMesh.subscribe("open_led_green",self.open_led_green)
+ EventMesh.subscribe("open_led_all",self.open_led_all)
+ EventMesh.subscribe("open_led_red_blue",self.open_led_red_blue)
+ EventMesh.subscribe("open_led_red_green",self.open_led_red_green)
+ EventMesh.subscribe("flicker_led_red",self.flicker_led_red)
+ EventMesh.subscribe("flicker_led_blue",self.flicker_led_blue)
+ EventMesh.subscribe("flicker_led_green",self.flicker_led_green)
+ EventMesh.subscribe("flicker_led_all",self.flicker_led_all)
+ EventMesh.subscribe("close_led",self.close_led)
+ EventMesh.publish("open_led_red")
+
+ def flicker_led_red(self,event,msg):
+ self.led_flicker_flag = 1
+ self.led_flicker_timer.start(1500, 1, self.led_flicker_timer_cb)
+
+ def flicker_led_blue(self,event,msg):
+ self.led_flicker_flag = 2
+ self.led_flicker_timer.start(1500, 1, self.led_flicker_timer_cb)
+
+ def flicker_led_green(self,event,msg):
+ self.led_flicker_flag = 3
+ self.led_flicker_timer.start(1500, 1, self.led_flicker_timer_cb)
+
+ def flicker_led_all(self,event,msg):
+ self.led_flicker_flag = 4
+ self.led_flicker_timer.start(1500, 1, self.led_flicker_timer_cb)
+
+ def led_flicker_timer_cb(self, *args, **kwargs):
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.led_flicker_timer_cb_})
+ def led_flicker_timer_cb_(self):
+ if self.led_flicker_flag == 0:
+ self.led_flicker_timer.stop()
+ return
+ if self.led_flicker_on_off_flag == 0:
+ self.led_red.write(0)
+ self.led_blue.write(0)
+ self.led_green.write(0)
+ self.led_flicker_on_off_flag = 1
+ else:
+ self.led_flicker_on_off_flag = 0
+ if self.led_flicker_flag == 1:
+ self.led_blue.write(0)
+ self.led_green.write(0)
+ self.led_red.write(1)
+ elif self.led_flicker_flag == 2:
+ self.led_red.write(0)
+ self.led_green.write(0)
+ self.led_blue.write(1)
+ elif self.led_flicker_flag == 3:
+ self.led_red.write(0)
+ self.led_blue.write(0)
+ self.led_green.write(1)
+ elif self.led_flicker_flag == 4:
+ self.led_blue.write(1)
+ self.led_green.write(1)
+ self.led_red.write(1)
+
+ def open_led_red(self,event,msg):
+ #print("open_led_red")
+ self.led_flicker_flag = 0
+ #self.led_red.write(0)
+ self.led_blue.write(0)
+ self.led_green.write(0)
+ self.led_red.write(1)
+
+ def open_led_blue(self,event,msg):
+ #print("open_led_blue")
+ self.led_flicker_flag = 0
+ self.led_red.write(0)
+ #self.led_blue.write(0)
+ self.led_green.write(0)
+ self.led_blue.write(1)
+
+ def open_led_green(self,event,msg):
+ #print("open_led_green")
+ self.led_flicker_flag = 0
+ self.led_red.write(0)
+ self.led_blue.write(0)
+ #self.led_green.write(0)
+ self.led_green.write(1)
+
+ def open_led_red_blue(self,event,msg):
+ #print("open_led_blue")
+ self.led_flicker_flag = 0
+ self.led_red.write(1)
+ #self.led_blue.write(0)
+ self.led_green.write(0)
+ self.led_blue.write(1)
+
+ def open_led_red_green(self,event,msg):
+ #print("open_led_blue")
+ self.led_flicker_flag = 0
+ self.led_red.write(1)
+ #self.led_blue.write(0)
+ self.led_green.write(1)
+ self.led_blue.write(0)
+
+ def open_led_all(self,event,msg):
+ #print("open_led_all")
+ self.led_flicker_flag = 0
+ #self.led_red.write(0)
+ self.led_blue.write(1)
+ self.led_green.write(1)
+ self.led_red.write(1)
+
+ def close_led(self,event,msg):
+ #print("close_led")
+ self.led_flicker_flag = 0
+ self.led_red.write(0)
+ self.led_blue.write(0)
+ self.led_green.write(0)
+def set_ipv4_datacall():
+ # 获取第一路的APN,ipType 等信息
+ pdpCtx = dataCall.getPDPContext(1)
+ if pdpCtx != -1:
+ if pdpCtx[0] != 0:
+ # 如果不是用户需要的ipv4,使用如下方式配置,使用如下方式配置
+ ret = dataCall.setPDPContext(1, 0,pdpCtx[1],pdpCtx[2],pdpCtx[3],pdpCtx[4])
+ if ret == 0:
+ print('配置成功。')
+ # cfun0/1后按照配置的信息进行拨号
+ net.setModemFun(0)
+ net.setModemFun(1)
+ else:
+ print('配置失败。')
+ else:
+ print('已经配置为IPv4')
+ else:
+ print('获取PDP Context失败。')
+audio_buf = ['chaobingfatis', 'chenggong', 'didianguanji', 'IMEIhao', 'jianquancuowu', 'key_prompt', 'liuliangtishi', 'Low_power_warning', 'R_CHARGE_FULL', 'R_CHARGE_IN', 'R_CHARGE_OUT', 'R_READ_TIME_0', 'R_READ_TIME_1', 'R_READ_TIME_2', 'R_READ_TIME_3', 'R_READ_TIME_4', 'R_READ_TIME_5', 'R_READ_TIME_6', 'R_READ_TIME_7', 'R_READ_TIME_8', 'R_READ_TIME_9', 'R_READ_TIME_A', 'R_READ_TIME_B', 'R_READ_TIME_C', 'R_READ_TIME_D', 'R_READ_TIME_E', 'R_READ_TIME_F', 'R_READ_TIME_G', 'R_READ_TIME_H', 'R_READ_TIME_I', 'R_READ_TIME_J', 'R_READ_TIME_K', 'R_READ_TIME_L', 'R_READ_TIME_M', 'R_READ_TIME_N', 'R_READ_TIME_O', 'R_READ_TIME_P', 'R_READ_TIME_Q', 'R_READ_TIME_R', 'R_READ_TIME_S', 'R_READ_TIME_T', 'R_READ_TIME_U', 'R_READ_TIME_V', 'R_READ_TIME_W', 'R_READ_TIME_X', 'R_READ_TIME_Y', 'R_READ_TIME_Z', 'send_tone', 'shouhou', 'xinhaoruo1', 'zhengzaiguanji']
+class AI_dev(Abstract):
+ # AI
+ def __init__(self):
+ # if(dev_type != "7PIN"):
+ # set_ipv4_datacall()
+ self.is_wdt = 0 #是否开启看门狗
+
+ self.VBATT_tab = {"charge_full":4300,"100" :4250 , "90":4179 , "80":4070, "60": 3883, "40":3770, "20":3699, "10":3652,"5":3600,}
+ self.KeyAI_status = 0
+ self.KeyAI_timer_count = 0
+ self.KeyAI_long_press = 0
+ self.KeyAI_press = 0
+ if self.is_wdt == 1:
+ self.wdt = WDT(30) #开启看门狗
+ # self.wdt_timer = osTimer()
+ # self.wdt_timer.start(5000, 1, self.wdt_timer_cb)
+ count = 0
+ while True:
+ count += 1
+ if count > 20 :
+ break
+ data = dataCall.getInfo(1, 0)
+ print("data call INFO {}".format(data))
+ if data[2][0]:
+ self.network_state = 1
+ break
+ print("等待网络 {}...".format(count))
+ utime.sleep_ms(500)
+ self.KeyAI_timer = osTimer()
+ if dev_type == "G10" :
+ self.extint_AI = ExtInt(ExtInt.GPIO19,ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.keyAI_extint_cb)
+ self.pwk_key = ExtInt(ExtInt.GPIO26, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.pwk_extint_cb)
+ elif dev_type == 'jswm':
+ self.extint_AI = ExtInt(ExtInt.GPIO26,ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.keyAI_extint_cb)
+ self.pwk_key = ExtInt(ExtInt.GPIO19, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.pwk_extint_cb)
+ elif dev_type == "7PIN_BK_EU":
+ self.pwk_key = ExtInt(ExtInt.GPIO41, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.pwk_extint_cb)
+ self.extint_AI = ExtInt(ExtInt.GPIO5,ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.keyAI_extint_cb)
+ else:
+ self.pwk_key = ExtInt(ExtInt.GPIO41, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.pwk_extint_cb)
+ #self.extint_AI = ExtInt(ExtInt.GPIO19,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)
+ self.extint_AI.enable()
+ self.pwk_key_status = 0
+ self.pwk_key_timer_count = 0
+ self.pwk_key_long_press = 0
+ self.pwk_key_press = 0
+ self.pwk_key_timer = osTimer()
+ #self.pwk_key = ExtInt(ExtInt.GPIO26, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_DISABLE, self.pwk_extint_cb)
+
+ self.pwk_key.enable()
+ print("AI_dev:1")
+ self.btnInfo_queue = Queue(100)
+ self.btnInfo_queue_count = 0
+ _thread.stack_size(16*1024)
+ self.btnInfo_queue_thread_id = _thread.start_new_thread(self.btnInfo_queue_thread, ())
+ _thread.stack_size(8*1024)
+ EventMesh.subscribe("publish_AI_btnInfo",self.publish_AI_btnInfo)
+ EventMesh.subscribe("get_battery",self.get_battery)
+ EventMesh.subscribe("audio_montage_play",self.audio_montage_play)
+ EventMesh.subscribe("paly_iccid_imei",self.paly_iccid_imei)
+ EventMesh.subscribe("paly_device_res_error",self.paly_device_res_error)
+ EventMesh.subscribe("Power_off",self.pwk_key_Long_Press)
+
+ print("AI_dev:2")
+ self.pk = PowerKey()
+ self.pk.powerKeyEventRegister(self.powerKey_callback)
+ self.usb = USB()
+ self.usb.setCallback(self.usb_event_cb)
+ self.usb_status = self.usb.getStatus()
+ self.usb_charge_flag = 0
+ self.Low_power_warning_timer = 0
+ self.AI_dev_timer = osTimer()
+ self.AI_dev_timer.start(10000, 1, self.AI_dev_timer_cb)
+ print("AI_dev:AI_dev_timer")
+ self.aud = audio.Audio(0)
+ self.Low_power_warning_flag = 0
+ self.VC_TTS_volume = EventMesh.publish("get_storage_config","VC_TTS_volume")#音量配置
+ if self.VC_TTS_volume == None:
+ self.VC_TTS_volume = 100
+ self.aud.setVolume(self.VC_TTS_volume //10)
+ #self.aud.play(1,0,'U:/static/xianyikaiji.mp3')#开机音频
+ #EventMesh.publish("audio_montage_play",["xianyikaiji.mp3"])
+ #EventMesh.publish("publish_AI_btnInfo",{"func":self.ntptime_cb})
+ self.check_rest_timer_count = 0
+ print("AI_dev:end")
+ def ntptime_cb(self):
+ #ntptime.settime(8)
+ print("timer:{}!!!!!!!!\r\n".format(utime.localtime()))
+ def usb_event_cb(self, state):
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.usb_event,"data":state})
+
+ def usb_event(self, state):
+ status = state
+ self.usb_charge_flag = 0
+ if status == 1:#插入USB
+ print("charge R_CHARGE_in")
+ self.usb_status = 1
+ VC_satrt_flag = EventMesh.publish("get_VC_satrt_flag")#获取vc是否在运行
+ if VC_satrt_flag == None:
+ VC_satrt_flag = 0
+ if VC_satrt_flag == 0:
+ self.aud.stop()
+ #EventMesh.publish("flicker_led_red")#充电闪灯
+ #self.aud.play(1,1,'U:/static/R_CHARGE_IN.mp3')
+ EventMesh.publish("open_led_red")#充电红灯常亮
+ EventMesh.publish("audio_montage_play",["R_CHARGE_IN.mp3"])
+ self.Low_power_warning_flag = 0
+ pass
+ elif status == 0:#拨出usbs
+ self.usb_status = 0
+ VC_satrt_flag = EventMesh.publish("get_VC_satrt_flag")#获取vc是否在运行
+ if VC_satrt_flag == None:
+ VC_satrt_flag = 0
+ if VC_satrt_flag == 0:
+ self.aud.stop()
+ EventMesh.publish("close_led")
+ EventMesh.publish("audio_montage_play",["R_CHARGE_OUT.mp3"])
+ #self.aud.play(1,1,'U:/static/R_CHARGE_OUT.mp3')
+ def btnInfo_queue_thread(self):
+ while True:
+ data = self.btnInfo_queue.get()
+ self.btnInfo_queue_count-=1
+ #EventMesh.debug_log("Info_queue:data = {}".format(data))
+ if data != None:
+ try:
+ if "data" in data :
+ data["func"](data["data"])
+ else :
+ data["func"]()
+ except Exception as e:
+ #EventMesh.debug_log("btnInfo_queue:ERROR:{}".format(e))
+ usys.print_exception(e)
+ print("ui_queue_thread:ERROR:{} \r\n data:{}".format(e,data["data"]))
+ def publish_AI_btnInfo(self,event,msg):
+ #print("publish_AI_btnInfo 1")
+ self.btnInfo_queue.put(msg)
+ self.btnInfo_queue_count+=1
+ if self.btnInfo_queue_count > 80:
+ self.btnInfo_queue_count =0
+ print("事件处理线程队列出问题,重启!!!!!!!!!!!!!!")
+ print("线程:{} 队列:{}".format(_thread.threadIsRunning(self.btnInfo_queue_thread_id),self.btnInfo_queue.size()))
+ # if _thread.threadIsRunning(self.btnInfo_queue_thread_id):
+ # _thread.stop_thread(self.btnInfo_queue_thread_id)
+ # _thread.stack_size(10*1024)
+ # self.btnInfo_queue_thread_id = _thread.start_new_thread(self.btnInfo_queue_thread, ())
+ # _thread.stack_size(8*1024)
+ # self.btnInfo_queue.clear()
+ # self.btnInfo_queue = Queue(100)
+ EventMesh.publish("VC_error") #播放报错
+ utime.sleep_ms(1000)
+ self.aud.stopPlayStream()
+ self.aud.stopAll()
+ Power.powerRestart()
+ EventMesh.publish("set_storage_config",["powerRestart",1])
+ #print("publish_AI_btnInfo 2")
+ def powerKey_callback(self, status):
+ print("powerKey_callback:{}".format(status))
+
+ def pwk_extint_cb(self,args):#pwk
+ try:
+ self.pwk_key_status = int(args[1])
+ if self.pwk_key_status == 0:
+ self.pwk_key_status = 1
+ else:
+ self.pwk_key_status = 0
+ pass
+ if self.pwk_key_status == 0:#按下
+
+ if self.pwk_key_press == 0 :
+ self.pwk_key.disable()
+ self.pwk_key_press = 1
+ self.pwk_key_long_press = 0
+ self.pwk_key_timer.start(100, 1, self.pwk_key_timer_cb)
+ self.pwk_key_timer_count = 0
+ #EventMesh.publish("AI_key_press")
+ except Exception as e:
+ usys.print_exception(e)
+ def pwk_key_timer_cb(self, *args, **kwargs):
+ # EventMesh.publish("publish_AI_btnInfo",{"func":self.pwk_key_timer_cb_})
+ # def pwk_key_timer_cb_(self) :
+ try:
+ self.pwk_key_status = self.pwk_key.read_level()
+ self.pwk_key_timer_count +=1
+ if self.pwk_key_timer_count >= 10*3: #长按3s
+ #print("pwk_key_long_press {}".format(self.pwk_key_long_press))
+ if self.pwk_key_long_press == 0:
+ self.pwk_key_long_press = 1
+ #EventMesh.publish("AI_key_long_press")
+ EventMesh.publish("audio_montage_play",["zhengzaiguanji.mp3"])
+ #self.aud.play(1,0,'U:/static/zhengzaiguanji.mp3')#关机音频
+ EventMesh.publish("open_led_red")
+ utime.sleep_ms(2000)
+ self.aud.stopPlayStream()
+ self.aud.stopAll()
+ Power.powerDown()
+ #print("AI_key_release")
+ #EventMesh.publish("pwk_key_long_press")
+ #EventMesh.publish("publish_AI_btnInfo",{"func":self.pwk_key_Long_Press})
+ if self.pwk_key_status == 1:#松开
+ #print("pwk_key_timer_cb:{}".format(self.pwk_key_timer_count))
+ key_count = 5
+ if dev_type == "7PIN_BK" or dev_type == "7PIN_BK_EU"or dev_type == "7PIN_BK_coze":
+ key_count = 3
+ if self.pwk_key_timer_count >= key_count: #防抖200ms
+ #EventMesh.publish("AI_key_release")
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.pwk_key_release})
+ self.pwk_key.enable()
+ self.pwk_key_timer.stop()
+ self.pwk_key_timer_count = 0
+ self.pwk_key_press = 0
+
+ except Exception as e:
+ usys.print_exception(e)
+
+ def keyAI_extint_cb(self,args):#call 2
+ try:
+ #print("AI_btn:keyAI_extint_cb{}".format(args[1]))
+ self.KeyAI_status = int(args[1])
+ if self.KeyAI_status == 0:
+ self.KeyAI_status = 1
+ else:
+ self.KeyAI_status = 0
+
+ if self.KeyAI_status == 0:#按下
+ if self.KeyAI_press == 0 :
+ EventMesh.publish(constants.EVENT.SYSTEM_UP)#唤醒休眠
+ self.extint_AI.disable()
+ self.KeyAI_press = 1
+ self.KeyAI_long_press = 0
+ self.KeyAI_timer.start(100, 1, self.KeyAI_timer_cb)
+ self.KeyAI_timer_count = 0
+ #EventMesh.publish("AI_key_press")
+ if dev_type == "7PIN" or dev_type == "7PIN_coze" :
+ self.aud.aud_tone_play(10,200)#播放按键音
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_key_press})
+ except Exception as e:
+ usys.print_exception(e)
+ def KeyAI_timer_cb(self, *args, **kwargs):
+ # EventMesh.publish("publish_AI_btnInfo",{"func":self.KeyAI_timer_cb_})
+ # def KeyAI_timer_cb_(self):
+ try:
+ 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})
+ elif self.KeyAI_timer_count >= 10*8:#关机
+ if dev_type == 'jswm' or dev_type == 'jswm_BOX':
+ EventMesh.publish("audio_montage_play",["zhengzaiguanji.mp3"])
+ #self.aud.play(1,0,'U:/static/zhengzaiguanji.mp3')#关机音频
+ EventMesh.publish("open_led_red")
+ utime.sleep_ms(2000)
+ self.aud.stopPlayStream()
+ self.aud.stopAll()
+ Power.powerDown()
+ if self.KeyAI_status == 1:#松开
+ #print("KeyAI_timer_cb:{}".format(self.KeyAI_timer_count))
+ key_count = 5
+ 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
+ #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
+
+ except Exception as e:
+ usys.print_exception(e)
+
+ def AI_key_press(self):
+ self.check_rest_timer_count = 0
+ print("AI_key_press")
+ EventMesh.publish("AI_key_press")
+
+ def AI_key_long_press(self):
+ self.check_rest_timer_count = 0
+ print("AI_key_long_press")
+ EventMesh.publish("AI_key_long_press")
+
+ def AI_key_release(self):
+ print("AI_key_release")
+ EventMesh.publish("AI_key_release")
+
+ def pwk_key_Long_Press(self,event=None,msg=None):
+ self.check_rest_timer_count = 0
+ print("pwk_key_long_press!!!!!!!")
+ print("pwk_key_long_press!!!!!!!")
+
+ # EventMesh.publish("paly_iccid_imei")
+ # return
+ EventMesh.publish("audio_montage_play",["zhengzaiguanji.mp3"])
+ #self.aud.play(1,0,'U:/static/zhengzaiguanji.mp3')#关机音频
+ EventMesh.publish("open_led_red")
+ utime.sleep_ms(3000)
+ self.aud.stopPlayStream()
+ self.aud.stopAll()
+ Power.powerDown()
+ #print("AI_key_release")
+ #EventMesh.publish("pwk_key_long_press")
+
+ def pwk_key_release(self):
+ self.check_rest_timer_count = 0
+ #print("pwk_key_release")
+ EventMesh.publish("pwk_key_release")
+
+
+ def wdt_timer_cb(self, *args, **kwargs):
+ if self.is_wdt == 1:
+ self.wdt.feed()
+
+ def AI_dev_timer_cb(self, *args, **kwargs):
+ #print("AI_dev_timer_cb")
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_dev_timer_event})
+ def AI_dev_timer_event(self):
+ if self.is_wdt == 1:
+ self.wdt.feed()
+ VC_satrt_flag = EventMesh.publish("get_VC_satrt_flag")#获取vc是否在运行
+ if VC_satrt_flag == None:
+ VC_satrt_flag = 0
+ Vbatt = Power.getVbatt()
+ if self.usb_status == 1 and VC_satrt_flag == 0:
+ EventMesh.publish("open_led_red")#充电红灯常亮
+ if self.usb_status == 1 and Vbatt>=self.VBATT_tab["charge_full"]and VC_satrt_flag == 0:#充电充满
+ EventMesh.publish("open_led_green")
+ if self.usb_charge_flag == 0 :
+ EventMesh.publish("audio_montage_play",["R_CHARGE_FULL.mp3"])
+ #self.aud.play(1,0,'U:/static/R_CHARGE_FULL.mp3')#充电已满
+ self.usb_charge_flag = 1
+ if self.usb_status == 0 and Vbatt<self.VBATT_tab["20"]and VC_satrt_flag == 0 and self.Low_power_warning_flag ==0:#低电报警
+ self.Low_power_warning_flag = 1
+ EventMesh.publish("flicker_led_red")
+ #self.aud.play(1,0,'Low_power_warning.mp3')
+ # self.Low_power_warning_timer+=1
+ # if self.Low_power_warning_timer >= 2:
+ # self.Low_power_warning_timer = 0
+ EventMesh.publish("audio_montage_play",["Low_power_warning.mp3"])
+ if self.usb_status == 0 and Vbatt>=self.VBATT_tab["20"]and VC_satrt_flag == 0:#没有充电,电量又正常,关灯
+ EventMesh.publish("close_led")
+
+ if self.usb_status == 0 and Vbatt<self.VBATT_tab["5"]:
+ EventMesh.publish("audio_montage_play",["didianguanji.mp3"])
+ utime.sleep_ms(4500)
+ self.aud.stopPlayStream()
+ self.aud.stopAll()
+ Power.powerDown()
+
+ self.check_rest_timer_count += 1
+ if self.check_rest_timer_count >= 8640:#24小时没按键,则关机
+ self.pwk_key_Long_Press()
+
+ def get_battery(self, event=None, msg=None):
+ Vbatt = Power.getVbatt()
+ if Vbatt>self.VBATT_tab["90"]:
+ return 100
+ if Vbatt>self.VBATT_tab["80"]:
+ return 90
+ if Vbatt>self.VBATT_tab["60"]:
+ return 80
+ if Vbatt>self.VBATT_tab["40"]:
+ return 60
+ if Vbatt>self.VBATT_tab["20"]:
+ return 40
+ if Vbatt>self.VBATT_tab["10"]:
+ return 20
+ if Vbatt<=self.VBATT_tab["10"]:
+ return 10
+ def audio_montage_play(self,event,msg):
+ self.aud.stopPlayStream()
+ self.aud.stopAll()
+ str_data='mp3files='
+ for i in msg:
+ try:
+ str_tmp = i.replace(".mp3","")
+ str_data+="{}.mp3+".format(audio_buf.index(str_tmp))
+ except Exception as e:
+ usys.print_exception(e)
+ str_data = str_data[:-1]
+ print("audio_montage_play:{}".format(str_data))
+ self.aud.montage_play('U:/static/audio.bin',1,1,str_data)
+
+ def paly_iccid_imei(self,event,msg):
+ str_data = 'mp3files={}.mp3+'.format(audio_buf.index("liuliangtishi"))#流量提示
+ imei = modem.getDevImei()
+ iccid = sim.getIccid()
+ print("paly_iccid_imei:ICCID:{}".format(iccid))
+ if iccid != -1 and len(iccid) > 5:
+ iccid = iccid.upper()
+ if len(iccid) <20:
+ for i in range(20-len(iccid)):
+ iccid = "0"+iccid
+ str_data += '{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+'.format(audio_buf.index("R_READ_TIME_{}".format(iccid[0]))\
+ ,audio_buf.index("R_READ_TIME_{}".format(iccid[1])),audio_buf.index("R_READ_TIME_{}".format(iccid[2])),audio_buf.index("R_READ_TIME_{}".format(iccid[3])),\
+ audio_buf.index("R_READ_TIME_{}".format(iccid[4])),audio_buf.index("R_READ_TIME_{}".format(iccid[5])),audio_buf.index("R_READ_TIME_{}".format(iccid[6])),audio_buf.index("R_READ_TIME_{}".format(iccid[7])),\
+ audio_buf.index("R_READ_TIME_{}".format(iccid[8])),audio_buf.index("R_READ_TIME_{}".format(iccid[9])),audio_buf.index("R_READ_TIME_{}".format(iccid[10])),audio_buf.index("R_READ_TIME_{}".format(iccid[11])),\
+ audio_buf.index("R_READ_TIME_{}".format(iccid[12])),audio_buf.index("R_READ_TIME_{}".format(iccid[13])),audio_buf.index("R_READ_TIME_{}".format(iccid[14])),audio_buf.index("R_READ_TIME_{}".format(iccid[15])),\
+ audio_buf.index("R_READ_TIME_{}".format(iccid[16])),audio_buf.index("R_READ_TIME_{}".format(iccid[17])),audio_buf.index("R_READ_TIME_{}".format(iccid[18])),audio_buf.index("R_READ_TIME_{}".format(iccid[19])))
+ str_data += '{}.mp3+'.format(audio_buf.index("shouhou"))#可联系售后解决,联系方式见售后客服电话是400-886-8777或到微信公众号柒牌SEVENBRAND自行充值:
+ self.aud.montage_play('U:/static/audio.bin',1,1,str_data)
+ #鉴权出错,播放imei号
+ def paly_device_res_error(self,event,msg):
+ str_data = 'mp3files={}.mp3+'.format(audio_buf.index("jianquancuowu"))#AI功能异常,请联系客户查询,设备号为:
+ imei = modem.getDevImei()
+ imei = imei.upper()
+ str_data += '{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3+{}.mp3'.format(audio_buf.index("R_READ_TIME_{}".format(imei[0]))\
+ ,audio_buf.index("R_READ_TIME_{}".format(imei[1])),audio_buf.index("R_READ_TIME_{}".format(imei[2])),audio_buf.index("R_READ_TIME_{}".format(imei[3])),\
+ audio_buf.index("R_READ_TIME_{}".format(imei[4])),audio_buf.index("R_READ_TIME_{}".format(imei[5])),audio_buf.index("R_READ_TIME_{}".format(imei[6])),audio_buf.index("R_READ_TIME_{}".format(imei[7])),\
+ audio_buf.index("R_READ_TIME_{}".format(imei[8])),audio_buf.index("R_READ_TIME_{}".format(imei[9])),audio_buf.index("R_READ_TIME_{}".format(imei[10])),audio_buf.index("R_READ_TIME_{}".format(imei[11])),\
+ audio_buf.index("R_READ_TIME_{}".format(imei[12])),audio_buf.index("R_READ_TIME_{}".format(imei[13])),audio_buf.index("R_READ_TIME_{}".format(imei[14])))
+ #print("str_data:{}".format(str_data))
+ self.aud.montage_play('U:/static/audio.bin',1,1,str_data)
+
+#存储信息
+class getStorageDataManager(Abstract):#获取内存数据
+ def __init__(self):
+ self.config_data = {}
+ check = ql_fs.path_exists("/usr/static/storage_file/config.json")
+ if check == True:
+ with open("/usr/static/storage_file/config.json","r") as fd:
+ self.config_data = ujson.load(fd)
+ else :
+ self.config_data = {'old_time': 0, 'flip_sw': 0}
+ pass
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("set_storage_data", self.set_storage_data)
+ EventMesh.subscribe("set_storage_config", self.set_storage_config)
+ EventMesh.subscribe("get_storage_data", self.get_storage_data)
+ EventMesh.subscribe("get_storage_config", self.get_storage_config)
+
+ def set_storage_data(self, event, msg):
+ # EventMesh.debug_log("set_storage_data:{}".format(msg))
+ if msg != None:
+ self.config_data = msg
+ with open("/usr/static/storage_file/config.json",'w+',encoding="utf-8") as fd:
+ ujson.dump(self.config_data,fd)
+
+
+ def set_storage_config(self,event,msg):
+ # EventMesh.debug_log("set_storage_key_data1:{}".format(msg))
+ if len(msg) >= 2:
+ self.config_data[msg[0]]=msg[1]
+ # EventMesh.debug_log("set_storage_key_data2:{}".format(self.config_data[msg[0]]))
+ #EventMesh.publish("publish_message_event_ui",{"func":self.set_storage_save,"data":0})
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.set_storage_save})
+ def set_storage_save(self):
+ with open("/usr/static/storage_file/config.json",'w+',encoding="utf-8") as fd:
+ ujson.dump(self.config_data,fd)
+ def get_storage_data(self, event, msg):
+ # EventMesh.debug_log("get_storage_data:{}".format(self.config_data))
+ return self.config_data
+ def get_storage_config(self,event,msg):
+ # EventMesh.debug_log("get_storage_key_data1:{}".format(msg))
+ b = msg in self.config_data.keys()
+ if b == True:
+ # EventMesh.debug_log("get_storage_key_data2:{}".format(self.config_data[msg]))
+ return self.config_data[msg]
+ else :
+ return None
+ # try:
+ # return self.config_data[msg]
+ # except:
+ # EventMesh.debug_log("get_storage_key_data:none key:{}",msg)
+ # return None
+#设备资源授权平台
+class device_res_author(Abstract):
+
+ def __init__(self) :
+ print("device_res_author __init__ start !!!!!!!!!!!!!!!!!")
+ self.deviceId = modem.getDevImei()#"876226002022574"
+ self.SHA1_BLOCK_SIZE = 64
+ self.PAD_BLOCK_SIZE = 16
+ self.SHA256 = uhashlib.sha256
+ self.pad = lambda s: s + chr(self.PAD_BLOCK_SIZE - len(s) % self.PAD_BLOCK_SIZE) * (self.PAD_BLOCK_SIZE - len(s) % self.PAD_BLOCK_SIZE)
+ # 除去补16字节的多余字符
+ self.unpad = lambda s: s[:-s[-1]]
+ #K01
+ # self.key = b"MWrMZjdtcPhj41jWuoqFAhTmqyFluqj1"
+ # self.pid = "qAtdDOGXgXYjT2HGFr3a"
+ #G15
+ # self.key = b"3LWfBicxfRZ3ZAqmZCFuvMdGUXdAFWkb"
+ # self.pid = "qLx4Pu4mSUQxyfVKGLXG"
+ #7pin
+ self.key = b"uKLrChwrxA1LklgBc3VwawYjUkbT3BgX"
+ self.pid = "cqxJZi5CNgzjS3mX21Zw"
+ # if dev_type == 'jswm' or dev_type == 'jswm_BOX':#金三完美
+ # self.key = b"FuXG4ptpGbzvKbdB4vpUypisbENgy2nB"
+ # self.pid = "DieBeXahZHLrjSnORbgN"
+ self.dev_res_timer = osTimer()
+ self.dev_res_timer.start(20000, 1, self.dev_timer_cb)
+ self.dev_res_timerCount = 0
+ self.ud_token_timer = osTimer()
+ self.ud_token_timer.start(10000, 1, self.ud_token_timer_cb)
+ self.ud_token_timer_Count = 0
+ self.dev_token = None
+ self.res_error_count = 0
+ self.ntptime_flag = 0
+ EventMesh.subscribe("get_dev_token", self.get_dev_token)
+ EventMesh.subscribe("update_dev_token", self.update_dev_token)
+ EventMesh.subscribe("dev_active", self.dev_active)
+ EventMesh.subscribe("dev_sign_in", self.dev_sign_in)
+ EventMesh.subscribe("dev_NTP", self.dev_NTP)
+ #EventMesh.publish_async("dev_NTP",thread_size = 8192)
+
+ # count = 0
+ # while True:
+ # if self.ntptime_flag == 1:
+ # break
+ # utime.sleep_ms(1)
+ # count+=1
+ # if count>600:
+ # break
+ # EventMesh.publish_async("dev_active",thread_size = 8192)
+ # EventMesh.publish_async("dev_sign_in",thread_size = 8192)
+
+ self.dev_NTP()#获取时间
+ self.dev_active() #设备激活
+ self.dev_sign_in() #设备登入
+ print("device_res_author __init__ end !!!!!!!!!!!!!!!!!")
+
+ def get_dev_token(self, event, msg):
+ return self.dev_token
+ #网络校时
+ def dev_NTP(self, event=None, msg=None):
+ response = None
+ try:
+ print("dev_NTP1")
+ url =None
+ if dev_type == "7PIN_BK_EU":#英文小瑞
+ url = "http://dmp-global.raisound.com/bz-api/dev/time"
+ else:
+ url = "http://dmp.raisound.com/bz-api/dev/time"
+ response = request.get(url,timeout=5)
+ data = response.json()
+ print("dev_NTP:{}".format(data))
+ if data:
+ try:
+ timeSecond = data["data"]["timestamp"]//1000
+
+ next_alarm_time = utime.localtime(timeSecond)
+ print("timeSecond {} next_alarm_time {}".format(timeSecond,next_alarm_time))
+ machine.RTC().datetime((next_alarm_time[0],next_alarm_time[1],next_alarm_time[2],next_alarm_time[6],next_alarm_time[3],next_alarm_time[4],next_alarm_time[5],0))
+ self.ntptime_flag = 1
+ except Exception as e:
+ usys.print_exception(e)
+ except Exception as e:
+ usys.print_exception(e)
+ if response != None:
+ response.close()
+ print("dev_NTP end")
+ def dev_timer_cb(self, *args): #设备资源管理鉴权平台定时器
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.dev_timer_cb_})
+
+ def dev_timer_cb_(self):
+ #if EventMesh.DEV_RES_MANAGE_AUTHEN_PLATFORM == 1:
+ try:
+ if self.dev_token == None:
+ if self.ntptime_flag == 0:
+ self.ntptime_flag = 1
+ EventMesh.publish_async("dev_NTP",thread_size = 8192)
+ #EventMesh.publish("publish_AI_btnInfo",{"func":self.dev_NTP})
+ print("timer:{}!!!!!!!!\r\n".format(utime.localtime()))
+ EventMesh.publish_async("dev_active",thread_size = 8192)
+ EventMesh.publish_async("dev_sign_in",thread_size = 8192)
+ # self.dev_active() #设备激活
+ # self.dev_sign_in() #设备登入
+ self.dev_res_timerCount+=1
+ if self.dev_res_timerCount > 3: #开机一分钟内没有获取到密码和token 等下一次更新令牌在走登入 激活流程
+ self.dev_res_timerCount=0
+ self.dev_res_timer.stop()
+ except Exception as e:
+ usys.print_exception(e)
+ def ud_token_timer_cb(self, *args):
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.ud_token_timer_cb_})
+
+ def ud_token_timer_cb_(self):
+ try:
+ #print("ud_token_timer_!!!!")
+ self.ud_token_timer_Count+=1
+ if self.ud_token_timer_Count >= 720: #定时10*3000s时更新token
+ self.ud_token_timer_Count = 0
+ EventMesh.publish_async("dev_sign_in",thread_size = 8192)
+ except Exception as e:
+ usys.print_exception(e)
+ def get_sim_Status(self):
+ return sim.getStatus()
+ def HMAC(self,k, m):
+
+ KEY_BLOCK = k + (b'\0' * (self.SHA1_BLOCK_SIZE - len(k)))
+ KEY_INNER = bytes((x ^ 0x36) for x in KEY_BLOCK)
+ KEY_OUTER = bytes((x ^ 0x5C) for x in KEY_BLOCK)
+ inner_message = KEY_INNER + m
+ outer_message = KEY_OUTER + self.SHA256(inner_message).digest()
+ return self.SHA256(outer_message)
+ def get_hmac_sha256(self,k, m):
+ data = self.HMAC(k, m).digest()
+ # print("HMAC(k, m).digest():", data)
+ # print("HMAC(k, m).digest():", ubinascii.hexlify(data))
+ hex_data = ubinascii.hexlify(data)
+ hex_data = hex_data.decode('ascii')
+ return hex_data
+ # 加密函数
+ def aes_CBC_Encrypt(self,data, key, iv): # CBC模式的加密函数,data为明文,key为16字节密钥,iv为16字节的偏移量
+ key = key.encode('utf-8')
+ iv = iv.encode('utf-8') # CBC 模式下的偏移量
+ data = self.pad(data) # 补位
+ data = data.encode('utf-8')
+ aes = ucryptolib.aes(key,ucryptolib.MODE_CBC,iv)
+ result = base64.b64encode(aes.encrypt(data))
+ return str(result, 'utf-8') # 以字符串的形式返回
+
+ # 解密函数
+ def aes_CBC_Decrypt(self,data, key, iv): # CBC模式的解密函数,data为密文,key为16字节密钥
+ key = key.encode('utf-8')
+ iv = iv.encode('utf-8')
+
+ aes = ucryptolib.aes(key,ucryptolib.MODE_CBC,iv) #CBC模式
+
+ # decrypt AES解密 B64decode为base64 转码
+ result = aes.decrypt(base64.b64decode(data))
+ result = self.unpad(result) # 除去补16字节的多余字符
+ return str(result, 'utf-8') # 以字符串的形式返回
+ #激活接口 没有密码走激活
+ def dev_active(self, event=None, msg=None):
+ signal = net.csqQueryPoll()
+ if signal == -1 or self.get_sim_Status() != 1:#网络不正常
+ print("dev_active 无 SIM卡!!!!!!!!\r\n")
+ return
+ print("dev_active 1\r\n")
+ # 签名内容: = deviceId+pid+timeStamp
+ dev_pass = ""
+ dev_pass = EventMesh.publish("get_storage_config","dev_pass")
+ print("dev_pass:{}\r\n".format(dev_pass))
+ if dev_pass == None:
+ dev_pass = ""
+ if dev_pass == "" or dev_pass == None:
+ try:
+ date_tmp = utime.localtime() #获取当前时间
+ print("date_tmp:{}\r\n".format(date_tmp)) #转换时间戳s
+ timeStamp = (utime.mktime(date_tmp))*1000#获取时间戳ms
+ deviceId = self.deviceId #"876226002022574" #以imei号
+ pid = self.pid
+ key = self.key
+ sign_data = "{}{}{}".format(deviceId,pid,timeStamp) #签名内容
+ print("sign_data:{}\r\n".format(sign_data))
+ sha256_hex = self.get_hmac_sha256(key,sign_data)
+ print("sha256_hex:{}\r\n".format(sha256_hex))
+
+ data = {
+ "deviceId":"{}".format(deviceId), #设备名
+ "pid":pid, #产品PID
+ "sign":"{}".format(sha256_hex), #HMACSHA256签名后的数据
+ "timeStamp":timeStamp, #要以ms的形式
+ "signMethod":"HMACSHA256" #签名方式 HMACSHA256
+ }
+ print(ujson.dumps(data))
+ headers_T ={"Content-Type":"application/json"}
+ url =None
+ if dev_type == "7PIN_BK_EU":#英文小瑞
+ url = "http://dmp-global.raisound.com/bz-api/dev/auth/active"
+ else:
+ url = "http://dmp.raisound.com/bz-api/dev/auth/active"
+ data =ujson.dumps(data)
+ response = None
+ response_result = 0
+ try:
+ response = request.put(url,data=data,headers = headers_T,timeout=5)
+ response_result = 1
+ except Exception as e:
+ usys.print_exception(e)
+ print("put error!!!!!\r\n")
+ response_result = 0
+
+ IV = "" #偏移量
+ PASSWORD= "" #服务器返回后的加密内容 密码
+ if response_result == 1: #访问成功ip
+ if response.status_code == 200:
+ print("headers:{}".format(response.headers))
+ content = response.content
+ c = next(content)
+ # "api.xcloudtech.com"
+ # d_server_port = 9000
+ data = ujson.loads(c)
+ # data = response.json()
+ print("data-{}".format(data))
+ if data != None:
+ if "success" in data:
+ if data['success'] == True:
+ if "data" in data:
+ data_tmp = data["data"]
+ if "nonce" in data_tmp: #偏移量
+ IV = data_tmp["nonce"]
+ if "password" in data_tmp:
+ PASSWORD = data_tmp["password"]
+ # EventMesh.publish("set_storage_config",["dev_pass",PASS])
+ if data["code"] == 20001:#鉴权成功
+ pass
+ elif data["code"] > 50000:#
+ self.res_error_count+=1
+ if self.res_error_count>=3:
+ self.res_error_count = 0
+
+ EventMesh.publish("paly_device_res_error")
+ if data["code"] == 50003:#时间错误
+ self.ntptime_flag = 0
+ if PASSWORD != None and IV != None:
+ if len(PASSWORD) != 0 and len(IV) != 0:
+ password = PASSWORD
+ iv = IV
+ #解密 之后保存本地下一次登入做使用
+ decrypt_data = self.aes_CBC_Decrypt(password, self.key, iv) #对服务器下发的密码进行解密
+ print("decrypt_data {}".format(decrypt_data))
+ EventMesh.publish("set_storage_config",["dev_pass",decrypt_data])
+ print("IV:{}\r\n PASS:{}".format(IV,PASSWORD))
+ if response != None:
+ response.close()
+ except Exception as e:
+ usys.print_exception(e)
+ print("dev_active end\r\n")
+ return [response_result,PASSWORD,IV]
+ #随机生成16个字节的字符串作为加密的IV 偏移量
+ def generate_random_string(self,length=16):
+ random_str = ""
+ chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
+ for i in range(length):
+ random_str+=chars[random.randint(0,length)]
+ return random_str
+
+ #设备登入 没有Token 走登入获取token
+ def dev_sign_in(self, event=None, msg=None):
+ signal = net.csqQueryPoll()
+ if signal == -1 or self.get_sim_Status() != 1:#网络不正常
+ print("dev_sign_in 无 SIM卡!!!!!!!!\r\n")
+ return
+ print("dev_sign_in 1")
+ token = ""
+ try:
+ token = self.dev_token
+ dev_pass = EventMesh.publish("get_storage_config","dev_pass")
+ #print("token:{}\r\n".format(token))
+ if token == None:
+ token = ""
+ if dev_pass == None:
+ dev_pass = ""
+ if len(dev_pass) == 0:#没有密码
+ return
+ #if token == None or token == "":
+ if 1: #返回结果成功
+ #获取本地保存的密码
+ decrypt_data=EventMesh.publish("get_storage_config","dev_pass")
+ # decrypt_data = self.aes_CBC_Decrypt(password, self.key, iv) #对服务器下发的密码进行解密
+ print("decrypt_data {}".format(decrypt_data))
+ #随机生成16个字符串 设备生成做加密使用
+ random_string = self.generate_random_string(16) #随机的16个字符串
+ enc_iv = random_string #加密的IV偏移量
+ #设备端进行密码加密
+ encrypt_data = self.aes_CBC_Encrypt(decrypt_data, self.key, enc_iv)
+ print("encrypt_data {}".format(encrypt_data))
+
+ #登入数据
+ deviceId = self.deviceId
+ sign_in_data = {
+ "deviceId":"{}".format(deviceId), #设备ID
+ "password":"{}".format(encrypt_data), #加密的数据
+ "nonce":"{}".format(random_string) #随机的16个字符串
+ }
+ print(ujson.dumps(sign_in_data))
+ sign_url =None
+ if dev_type == "7PIN_BK_EU":#英文小瑞
+ sign_url = "http://dmp-global.raisound.com/bz-api/dev/auth/sign_in" #登入地址
+ else:
+ sign_url = "http://dmp.raisound.com/bz-api/dev/auth/sign_in" #登入地址
+ headers_T ={"Content-Type":"application/json"}
+ response_result = 0
+ response = 0
+ try:
+ response = request.post(sign_url,data=ujson.dumps(sign_in_data),headers = headers_T,timeout=5)
+ response_result = 1
+ except Exception as e:
+ usys.print_exception(e)
+ print("post error!!!!!\r\n")
+ response_result = 0
+ # {'msg': '', 'code': 20001, 'success': True,
+ # 'data': {'deviceId': '876226002022574',
+ # 'token': '95436a9e09fd0ff89feb8825257dca982f'}
+ # }
+
+ #self.dev_token = ""
+ if response_result == 1:
+ if response.status_code == 200:
+ content = response.content
+ c = next(content)
+ data = ujson.loads(c)
+ print("data-{}".format(data))
+ if data != None:
+ if "success" in data:
+ if data['success'] == True: #登入成功
+ if "data" in data:
+ data_tmp = data["data"]
+ if "token" in data_tmp: #token
+ self.dev_token = data_tmp["token"]
+ if data["code"] == 50003:#时间错误
+ self.ntptime_flag = 0
+ print("token:{}\r\n".format(self.dev_token))
+ if response != None:
+ response.close()
+ pass
+ except Exception as e:
+ print("post error!!!!!\r\n")
+ response_result = 0
+ print("dev_sign_in end")
+ #获取新的令牌 更新token
+ def update_dev_token(self, event=None, msg=None):
+ print("update_dev_token")
+ try:
+ dev_pass = ""
+ dev_pass = EventMesh.publish("get_storage_config","dev_pass")
+
+ if dev_pass == None:
+ dev_pass = ""
+ if len(dev_pass) == 0: #没有密码走激活
+ print("no dev_pass:{}\r\n".format(dev_pass))
+ EventMesh.publish("dev_active")
+ token = self.dev_token
+ if token == None:
+ token = ""
+ if len(token) == 0: #没有token走登入
+ print("no dev_token:{}\r\n".format(token))
+ #self.dev_sign_in()
+ EventMesh.publish("dev_sign_in")
+ dev_tokenip =None
+ if dev_type == "7PIN_BK_EU":#英文小瑞
+ dev_tokenip = "http://dmp-global.raisound.com/bz-api/dev/auth/token" #设备新令牌更新地址
+ else:
+ dev_tokenip = "http://dmp.raisound.com/bz-api/dev/auth/token" #设备新令牌更新地址
+ token = self.dev_token
+ if token == None:
+ token = ""
+ if len(token) != 0:
+ response_result=0
+ response = None
+ headers_T = {"bz-dt":"{}".format(token)}
+ try:
+ response = request.get(dev_tokenip,headers = headers_T,timeout=5)
+ response_result = 1
+ except Exception as e:
+ print("get error!!!!!\r\n")
+ response_result = 0
+ if response_result == 1:
+ if response.status_code == 200:
+ try:
+ headers_data = response.headers
+ # print("headers_data!!!!! headers_data:{}\r\n".format(headers_data))
+ if "bz-dt" in headers_data: #bz-dt字段是否在头部数据里面 如果有就需要更新
+ bz_dt = headers_data["bz-dt"]
+ self.dev_token = bz_dt.replace(" ", "") #去掉所有的空格符
+ print("update_dev_token:{}".format(self.dev_token))
+ except Exception as e:
+ print("headers_data!!!!! error\r\n")
+ if response != None:
+ response.close()
+ except Exception as e:
+ usys.print_exception(e)
+ print("update_dev_token end")
+
+#OTA升级
+class OTA():
+ def __init__(self):
+ #EventMesh.subscribe("min_sys_ota",self.min_sys_ota)
+ self.downloadFileVoURL1= ""
+ self.downloadFileVoURL2= ""
+ #小系统升级,返回0,没有升级;返回,1有升级,正在执行升级;返回2,电压不够
+ def min_sys_ota(self,event=None,msg=None):
+ print("min_sys_ota")
+ signal = net.csqQueryPoll()
+ if signal == -1 or sim.getStatus() != 1:#网络不正常
+ print("min_sys_ota 无 SIM卡!!!!!!!!\r\n")
+ return 0
+ # return 0
+ response = None
+ ret_str =0
+ self.downloadFileVoURL1= ""
+ self.downloadFileVoURL2= ""
+ try:
+ sourceVersion = versions.Build_Time
+ sourceVersion = "7PIN-"+sourceVersion[:10]+"-"+sourceVersion[11:-3]
+ print("sourceVersion:{}".format(sourceVersion))
+ sourceVersion = sourceVersion.replace(" ", "0")
+ print("sourceVersion2:{}".format(sourceVersion))
+ #url = "http://iot.api.thisiot.com/ota/task?deviceId=860132060348836&sourceVersion=2024-12-20-15:35-1"
+ url =None
+ if dev_type == "7PIN_BK_EU":#英文小瑞
+ url = "http://dmp-global.raisound.com/bz-api/ota/task?deviceId={}&sourceVersion={}".format(modem.getDevImei(),sourceVersion)
+ if dev_type == "7PIN" or dev_type == "7PIN_coze":#柒牌
+ url = "http://ota.qipai.com/bz-cmp-api/api/task?deviceId={}&sourceVersion={}".format(modem.getDevImei(),sourceVersion)
+ else:
+ url = "http://dmp.raisound.com/bz-api/ota/task?deviceId={}&sourceVersion={}".format(modem.getDevImei(),sourceVersion)
+
+ print(url)
+ response = request.get(url,timeout=5)
+ if response.status_code == 200:
+ data = response.json()
+ print("OTA升级请求:{}".format(data))
+
+ if data:
+ try:
+ if data["code"] == 20007:#有新版本
+ if "fileList"in data["data"]:
+ if len(data["data"]["fileList"]) == 2:
+ for fileList in data["data"]["fileList"]:
+ if fileList["fileName"] == "dfota_2.bin":
+ self.downloadFileVoURL2 = fileList["url"]
+ elif fileList["fileName"] == "dfota_1.bin":
+ self.downloadFileVoURL1 = fileList["url"]
+
+ if data["code"] == 20006:#已是最新版本
+ ret_str = 0
+
+ except Exception as e:
+ usys.print_exception(e)
+ else:
+ print("min_sys_ota get error")
+ response.close()
+ except Exception as e:
+ usys.print_exception(e)
+ if response != None:
+ response.close()
+
+ print("min_sys_ota:downloadFileVoURL1:{},\ndownloadFileVoURL2:{}".format(self.downloadFileVoURL1,self.downloadFileVoURL2))
+ print("min_sys_ota end")
+ if self.downloadFileVoURL2!="" and self.downloadFileVoURL1!="":
+ battery = EventMesh.publish("get_battery")
+ if battery>=40:
+ self.ota_timer = osTimer()
+ self.ota_timer.start(15000, 0, self.ota_timer_cb)
+ ret_str = 1
+ else:
+ ret_str = 2
+ return ret_str
+
+ def ota_timer_cb(self, *args, **kwargs):
+ import fota
+ fota_obj = fota()
+ fota_obj.httpDownload(url1=self.downloadFileVoURL1,url2=self.downloadFileVoURL2)
+ #ota升级结果返回,开机时调用一次即可
+ def ota_result(self,event=None,msg=None):
+ response = None
+ try:
+ currentVersion = versions.Build_Time
+ currentVersion = "7PIN-"+currentVersion[:10]+"-"+currentVersion[11:-3]
+ print("currentVersion1:{}".format(currentVersion))
+ currentVersion = currentVersion.replace(" ", "0")
+ print("currentVersion2:{}".format(currentVersion))
+ url =None
+ if dev_type == "7PIN_BK_EU":#英文小瑞
+ url = "http://dmp-global.raisound.com/bz-api/ota/result?deviceId={}¤tVersion={}".format(modem.getDevImei(),currentVersion)
+ if dev_type == "7PIN" or dev_type == "7PIN_coze":#柒牌
+ url = "http://ota.qipai.com/bz-cmp-api/api/result?deviceId={}¤tVersion={}".format(modem.getDevImei(),currentVersion)
+ else:
+ url = "http://dmp.raisound.com/bz-api/ota/result?deviceId={}¤tVersion={}".format(modem.getDevImei(),currentVersion)
+ print(url)
+ response = request.post(url,timeout=5)
+ if response.status_code == 200:
+ data = response.json()
+ print("OTA升级结果上报:{}".format(data))
+ else:
+ print("ota_result error!!!!")
+ for i in response.text:
+ print(i)
+ response.close()
+ except Exception as e:
+ usys.print_exception(e)
+ if response != None:
+ response.close()
+ #ICCID上传
+ def pots_ICCID(self,event=None,msg=None):
+ response = None
+ try:
+ iccid = sim.getIccid()
+ if iccid != -1 and len(iccid) > 5:
+ print("pots_ICCID:{}".format(iccid))
+ #Headers = {'Transfer-Encodong':'chunked'}
+ token = EventMesh.publish("get_dev_token")
+ headers_T = None
+ if token:
+ headers_T = {"bz-dt":"{}".format(token)}
+ #http://dmp.raisound.com/bz-api/dev/iccid?deviceId=866610001099679&iccid=89860002192307889057
+ url =None
+ if dev_type == "7PIN_BK_EU":#英文小瑞
+ url = "http://dmp-global.raisound.com/bz-api/dev/iccid?deviceId={}&iccid={}".format(modem.getDevImei(),iccid)
+ else:
+ url = "http://dmp.raisound.com/bz-api/dev/iccid?deviceId={}&iccid={}".format(modem.getDevImei(),iccid)
+ print("{} H:{}".format(url,headers_T))
+ response = request.post(url,headers = headers_T,timeout=5)
+ if response.status_code == 200:
+ data = response.json()
+ print("pots_ICCID:{}".format(data))
+ else:
+ print("pots_ICCID error!!!!")
+ for i in response.text:
+ print(i)
+ response.close()
+ except Exception as e:
+ usys.print_exception(e)
+ if response != None:
+ response.close()
+#阿里VC状态枚举
+VC_State_None=0
+VC_State_Listening=1#听
+VC_State_SpeechStart=2#说开始
+VC_State_SpeechIng=3#正在说
+VC_State_SpeechEnd=4#说结束
+VC_State_RequestToRespond=5 #TTS请求或者chat请求
+VC_State_Thinking=6#想(chat)
+VC_State_Responding=7#音频播放
+VC_State_TTSStart=8
+VC_State_TTSData=9
+VC_State_TTSFinish=10
+VC_State_TTSEnd=11
+VC_State_TTSError=12
+VC_State_DialogError=13
+VC_State_End=14
+
+VC_record_TYPE_PCM = 0
+VC_record_TYPE_AMR = 1
+VC_play_TYPE_PCM = 0
+VC_play_TYPE_MP3 = 1
+
+#websocket发送数据编号
+# AI_client_asr_num = 0
+# AI_client_chat_num = 1
+# AI_client_tts_num = 2
+AI_client_VC_num = 3
+AI_client_asr_num = 4
+
+
+class AI_VC(Abstract):
+ # AI
+
+ def __init__(self):
+ # import voiceCall
+ # voiceCall.callStart("10086")
+ # return
+ try:
+ self.http_get_config()#获取/更新配置参数
+ except Exception as e:
+ usys.print_exception(e)
+ self.VC_30S_timer = osTimer()
+ self.VC_30S_timer.start(30000, 1, self.VC_30S_timer_cb)
+ self.get_config_timer_count = 0
+ self.record_data_save_flag = 0 #是否保存录音文件
+ self.play_data_save_flag = 0#是否保存tts数据到文件
+ self.record_fd = None
+ self.play_fd = None
+ self.is_VC_ACK = 0 #是否开启ack应答模式
+ self.is_long_record = 0 #是否开启长录音模式(语音打断模式)
+ self.ai_OTA = OTA()
+ self.is_auth = 1 #是否开启dmp鉴权
+ #self.VC_mode = 1 #0:短按连续问答模式 1:长按录音模式
+ self.VC_mode = EventMesh.publish("get_storage_config","VC_mode")#
+ if self.VC_mode == None :
+ self.VC_mode = 0
+ self.is_up_error= 0 #是否上传错误id
+ self.Close_flag =0 #=1时,连续对话播放完音频就退出
+
+ self.error_data = []
+ self.asr_taskid = ""
+ self.VC_taskid = ""
+ self.VC_server = 2 #0柒牌正式服务器,1:测试服务器1,2:测试服务器2
+
+ self.server_ip = EventMesh.publish("get_storage_config","server_ip")#
+ if self.server_ip == None:
+ if self.VC_server == 1:#
+ self.server_ip="118.145.158.207:22083"
+ elif self.VC_server == 2:#
+ self.server_ip="118.145.158.207:22082"
+ elif self.VC_server == 4:#
+ self.server_ip="118.145.158.207:22084"
+ elif self.VC_server == 5:#
+ self.server_ip="amp-wss.raisound.com"
+ elif self.VC_server == 6:#
+ self.server_ip="118.145.158.207:22080"
+ elif self.VC_server == 7:#
+ self.server_ip="118.145.158.207:22080"
+ elif self.VC_server == 8:#
+ self.server_ip="115.190.94.208:22080"
+ elif self.VC_server == 86:#
+ self.server_ip="118.145.158.207:22086"
+ else:
+ #self.server_ip="sevenpin.qipai.com.cn"
+ self.server_ip="118.145.158.207:22082"
+ if dev_type == 'jswm' or dev_type == 'jswm_BOX':#
+ #self.server_ip="115.190.94.208:22080"
+ self.server_ip="118.145.158.207:22086"
+ elif dev_type == "7PIN" or dev_type == "7PIN_coze":
+ #self.server_ip="sevenpin.qipai.com.cn"
+ # self.server_ip="220.160.104.34"
+ # self.server_ip="118.145.158.207:22082"
+ # self.server_ip="118.145.158.207:22080/22087"
+ self.server_ip="ai.qipai.com"
+ elif dev_type == "G10":
+ self.server_ip="115.190.94.208:22080"
+ elif dev_type == "sjgq":
+ self.server_ip="118.145.158.207:22084"
+ elif dev_type == "7PIN_BK" or dev_type == 'csh'or dev_type == "7PIN_BK_coze"or dev_type == 'momo':
+ self.server_ip="amp.raisound.com"
+ #self.server_ip="118.145.158.207:22086"
+ elif dev_type == "7PIN_BK_EU":
+ #self.server_ip="amp-global.raisound.com"
+ self.server_ip="amp-cdn-test.raisound.com"
+
+ #开机提示音
+ self.power_on_tone = EventMesh.publish("get_storage_config","power_on_tone")#
+ if dev_type != "7PIN" and dev_type != "7PIN_coze"and dev_type != "jswm" and dev_type != 'jswm_BOX' and dev_type != "7PIN_BK":
+ self.power_on_tone = None
+ if self.power_on_tone == None:
+ if dev_type == "G10":
+ self.power_on_tone = "已开机,您好!我是北科瑞讯智能 AI bot_name"
+ elif dev_type == "7PIN_BK"or dev_type == "7PIN_BK_coze":
+ self.power_on_tone = "-bot_name来了!我们一起来愉快地聊天吧!"
+ elif dev_type == "7PIN_BK_EU":
+ self.power_on_tone = "Hi. May I help you ?"
+ elif dev_type == 'momo':
+ self.power_on_tone = "DuloDulo,我是上古神兽食梦貘,主人可以叫我momo,我来自《山海经》,是一只以梦为食的神秘灵兽,每当颜色朦胧、人们入睡时,我就会悄悄飞到人们的床头,用我长长的鼻子把噩梦统统吞噬掉,只留下甜甜的美梦。从今往后,就由我守护在主人身边,一起度过每一个星河璀璨的夜晚。"
+ elif dev_type == "sjgq":
+ self.power_on_tone = "您好!我是巴马四季甘泉的智能助手。我可以为你解答各种各样的问题,像是有关巴马四季甘泉知识库、中基长寿科学产品、卫斯曼院士国际先进医疗中心的问题,还有日常生活与工作、旅游信息、健康咨询、教育与学习、情感交流、全球资讯、世界文化等方面的问题哦。你有没有这方面的问题想要问我呀?"
+ elif dev_type == "szbst":
+ self.power_on_tone = "深圳百事通来了!请问您有什么需要我帮忙的吗?"
+ elif dev_type == 'jswm'or dev_type == 'jswm_BOX':
+ self.power_on_tone = "我来陪你聊天了"
+ elif dev_type == 'csh':
+ self.power_on_tone = "欢迎使用助手小福"
+ else:
+ self.power_on_tone = "您好!我是世界首创柒牌男装AI生活好帮手-bot_name, 很高兴为您服务,我可以帮您解答柒牌公司知识库、日常生活与工作、旅游信息、健康与运动咨询、教育与学习、情感交流、全球资讯、世界文化等问题!请问您有什么需要我帮忙的吗?"
+
+
+ self.VC_record_TYPE = VC_record_TYPE_PCM #0:PCM 1:AMR
+ self.VC_play_TYPE = VC_play_TYPE_PCM #0:PCM 1:mp3
+ self.VC_record_samplerate = 16000
+ self.VC_play_samplerate = 16000
+ self.VAD_data_len = 640 #10ms数据
+ self.is_VAD = 0#=1打开vad打断
+ # ARG_sample_rate, // 采样率
+ # ARG_channel, // 通道数
+ # ARG_frame_size, // 每帧字节数
+ # ARG_energy_threshold, // 能量阈值
+ # ARG_voice_time, // 语音持续时间阈值(ms)
+ # ARG_silence_time, // 静音持续时间阈值(ms)
+ # ARG_silence_start_threshold, // 静音开始阈值(ms)
+ self.vad = None
+ if self.is_VAD == 1:
+ self.vad = VAD.VAD(self.VC_record_samplerate ,1,self.VAD_data_len,600,100,300,100)
+ self.speech_rate = EventMesh.publish("get_storage_config","speech_rate")#语速配置
+ if self.speech_rate == None:
+ self.speech_rate = 0
+
+ self.vad_silence = EventMesh.publish("get_storage_config","vad_silence")#语速配置
+ if self.vad_silence == None:
+ if dev_type == "7PIN" or dev_type == "7PIN_coze":
+ self.vad_silence = 200
+ else:
+ self.vad_silence = 300
+
+ self.VC_TTS_voice_type = EventMesh.publish("get_storage_config","VC_TTS_voice_type")#音色配置
+ if self.VC_TTS_voice_type == None :
+ if dev_type == "G10" or dev_type == "7PIN_BK"or dev_type == "szbst" :
+ self.VC_TTS_voice_type = {
+ "女":{
+ "bot_name":"小瑞",
+ "voice":"zh_female_wanwanxiaohe_moon_bigtts" ,
+ "lang":"zh-cn"
+ },
+ "男":{
+ "bot_name":"小瑞",
+ "voice":"zh_male_wennuanahu_moon_bigtts" ,
+ "lang":"zh-cn"
+ },
+ "童":{
+ "bot_name":"小瑞",
+ "voice":"ICL_zh_female_huoponvhai_tob" ,
+ "lang":"zh-cn"
+ },
+ "粤":{
+ "bot_name":"小瑞",
+ "voice":"zh_female_wanqudashu_moon_bigtts" ,
+ "lang":"zh-hk"
+ },
+ "四川":{
+ "bot_name":"小瑞",
+ "voice":"zh_female_daimengchuanmei_moon_bigtts",
+ "lang":"&lang=zh-cn-sc"
+ },
+ "瑞小蜜":{
+ "bot_name":"瑞小蜜",
+ "voice":"zh_male_tiancaitongsheng_mars_bigtts",
+ "lang":"&lang=zh-cn-sc" ,
+ "bot_id":"7491251662036811816",#瑞小蜜
+ },
+ "瑞小粉":{
+ "bot_name":"瑞小粉",
+ "voice":"ICL_zh_female_tiaopigongzhu_tob",
+ "bot_id":"7501268622456045603",#瑞小粉
+ "lang":"&lang=zh-cn-sc"
+ },
+ "个性":{
+ "bot_name":"小瑞",
+ "voice":"zh_male_sunwukong_mars_bigtts" ,
+ "lang":"zh-cn"
+ }
+
+ }
+ elif dev_type == "7PIN_BK_coze":
+ self.VC_TTS_voice_type = {
+ "女":{
+ "bot_name":"小瑞",
+ "voice":"7468518753626488869" ,
+ "lang":"zh-cn"
+ },
+ "男":{
+ "bot_name":"小瑞",
+ "voice":"7426720361732980745" ,
+ "lang":"zh-cn"
+ },
+ "童":{
+ "bot_name":"小瑞",
+ "voice":"7468512265151676443" ,
+ "lang":"zh-cn"
+ },
+ "粤":{
+ "bot_name":"啊瑞",
+ "voice":"7481299960428888103" ,
+ "lang":"zh-hk"
+ },
+ "四川":{
+ "bot_name":"小瑞",
+ "voice":"7426720361732931593",
+ "lang":"&lang=zh-cn-sc"
+ },
+ "个性":{
+ "bot_name":"小瑞",
+ "voice":"7468512265134850099" ,
+ "lang":"zh-cn"
+ }
+
+ }
+ elif dev_type == "7PIN_BK_EU":
+ self.VC_TTS_voice_type = {
+ "女":{
+ "bot_name":"Rose",
+ "voice":"zh_female_shuangkuaisisi_emo_v2_mars_bigtts" ,
+ "lang":"zh-cn"
+ },
+ "男":{
+ "bot_name":"Jack",
+ "voice":"zh_male_wennuanahu_moon_bigtts" ,
+ "lang":"zh-cn"
+ },
+ "童":{
+ "bot_name":"Ray",
+ "voice":"zh_female_mengyatou_mars_bigtts" ,
+ "lang":"zh-cn"
+ },
+
+ }
+ elif dev_type == "csh":
+ self.VC_TTS_voice_type = {
+ "女":{
+ "bot_name":"小福",
+ "voice":"zh_female_wanwanxiaohe_moon_bigtts" ,
+ "lang":"zh-cn"
+ },
+ "男":{
+ "bot_name":"小福",
+ "voice":"zh_male_wennuanahu_moon_bigtts" ,
+ "lang":"zh-cn"
+ },
+ "童":{
+ "bot_name":"小福",
+ "voice":"ICL_zh_female_huoponvhai_tob" ,
+ "lang":"zh-cn"
+ },
+ "粤":{
+ "bot_name":"小福",
+ "voice":"zh_female_wanqudashu_moon_bigtts" ,
+ "lang":"zh-hk"
+ },
+ "四川":{
+ "bot_name":"小福",
+ "voice":"zh_female_daimengchuanmei_moon_bigtts",
+ "lang":"&lang=zh-cn-sc"
+ },
+ }
+ elif dev_type == 'jswm'or dev_type == 'jswm_BOX':
+ self.VC_TTS_voice_type = {
+
+ "林悦":{
+ "bot_name":"林悦",
+ #"voice":"ICL_zh_female_xingganyujie_tob",
+ "voice":"zh_female_yuanqinvyou_moon_bigtts" ,
+ "lang":"&lang=zh-cn-sc" ,
+ "bot_id":"7490824341572075555",#AI语音APP女神经理
+ "workflow_id":"",
+ "openai_option":{
+ # "model": "intimate-pro-32k-250115",
+ # "system":{
+ # "type": "file",
+ # "content": "1567d9e19ac09269d8ce6c887494ff01",
+ # },
+ },
+
+ },
+ "黄文新":{
+ "bot_name":"黄文新",
+ "voice":"zh_male_wennuanahu_moon_bigtts" ,
+ "lang":"zh-cn" ,
+ "bot_id":"7490825075302973440",#开朗男友
+ "workflow_id":"",
+ "openai_option":{
+ # "model": "intimate-pro-32k-250115",
+ # "system":{
+ # "type": "file",
+ # "content": "2731e1e9d7150807795c4b5ab1e01e1b",
+ # },
+ },
+ },
+
+ }
+ elif dev_type == 'momo':
+ self.VC_TTS_voice_type = {
+ "女":{
+ "bot_name":"食梦貘",
+ "voice":"zh_female_linjia_mars_bigtts" ,
+ "lang":"zh-cn"
+ },
+ "男":{
+ "bot_name":"食梦貘",
+ "voice":"zh_male_yangguangqingnian_mars_bigtts" ,
+ "lang":"zh-cn"
+ },
+ "童":{
+ "bot_name":"食梦貘",
+ "voice":"ICL_zh_female_huoponvhai_tob" ,
+ "lang":"zh-cn"
+ },
+ }
+ elif dev_type == 'sjgq':
+ self.VC_TTS_voice_type = {
+ "女":{
+ "bot_name":"小巴",
+ "voice":"zh_female_wanwanxiaohe_moon_bigtts" ,
+ "lang":"zh-cn"
+ },
+ "男":{
+ "bot_name":"小巴",
+ "voice":"zh_male_wennuanahu_moon_bigtts" ,
+ "lang":"zh-cn"
+ },
+ "童":{
+ "bot_name":"小巴",
+ "voice":"ICL_zh_female_huoponvhai_tob" ,
+ "lang":"zh-cn"
+ },
+ }
+ elif dev_type == "7PIN_coze":
+ self.VC_TTS_voice_type = {
+ "女":{
+ "bot_name":"柒妹妹",
+ "voice":"7468518753626488869" ,
+ "lang":"zh-cn"
+ },
+ "男":{
+ "bot_name":"柒先生",
+ "voice":"7426720361732980745" ,
+ "lang":"zh-cn"
+ },
+ "童":{
+ "bot_name":"柒乐乐",
+ "voice":"7468512265151676443" ,
+ "lang":"zh-cn"
+ },
+ "粤":{
+ "bot_name":"柒先生",
+ "voice":"7481299960428888103" ,
+ "lang":"zh-hk"
+ },
+ "四川":{
+ "bot_name":"柒妹妹",
+ "voice":"7426720361732931593",
+ "lang":"&lang=zh-cn-sc"
+ },
+ "个性":{
+ "bot_name":"柒先生",
+ "voice":"7468512265134850099" ,
+ "lang":"zh-cn"
+ }
+
+ }
+ else:
+ #女,男,童,粤,川,个性声
+ self.VC_TTS_voice_type = {
+ "女":{
+ "bot_name":"柒妹妹",
+ "voice":"zh_female_wanwanxiaohe_moon_bigtts" ,
+ "lang":"zh-cn"
+ },
+ "男":{
+ "bot_name":"柒先生",
+ "voice":"zh_male_wennuanahu_moon_bigtts" ,
+ "lang":"zh-cn"
+ },
+ "童":{
+ "bot_name":"柒乐乐",
+ "voice":"ICL_zh_female_huoponvhai_tob" ,
+ "lang":"zh-cn"
+ },
+ "粤":{
+ "bot_name":"柒先生",
+ "voice":"zh_female_wanqudashu_moon_bigtts" ,
+ "lang":"zh-hk"
+ },
+ "四川":{
+ "bot_name":"柒妹妹",
+ "voice":"zh_female_daimengchuanmei_moon_bigtts",
+ "lang":"&lang=zh-cn-sc"
+ },
+ "个性":{
+ "bot_name":"柒先生",
+ "voice":"zh_male_sunwukong_mars_bigtts" ,
+ "lang":"zh-cn"
+ },
+ "英语":{
+ "bot_name":"柒先生",
+ "voice":"en_male_smith_mars_bigtts" ,
+ "lang":"zh-cn"
+ }
+
+
+ }
+
+ # self.VC_TTS_voice_type = {0:"zh_female_xinlingjitang_moon_bigtts",1:"zh_male_wennuanahu_moon_bigtts",2:"ICL_zh_female_huoponvhai_tob",
+ # 3:"aliyun::longjiaxin",4:"zh_female_daimengchuanmei_moon_bigtts"}
+ #self.VC_TTS_voice_type = ["aliyun::longxiaoxia","aliyun::longnan","aliyun::longling"]
+
+ #EventMesh.publish("set_storage_config",["VC_TTS_voice_type",self.VC_TTS_voice_type])
+
+ try:
+ self.VC_TTS_voice_key = EventMesh.publish("get_storage_config","VC_TTS_voice_key")#音色配置
+ if self.VC_TTS_voice_key == None :
+ if dev_type == "7PIN_BK"or dev_type == "7PIN_BK_EU"or dev_type == "7PIN_BK_coze":
+ self.VC_TTS_voice_key = "童"
+ #self.VC_TTS_voice_key = "男"
+ elif dev_type == 'momo':
+ self.VC_TTS_voice_key = "女"
+ elif dev_type == "jswm"or dev_type == 'jswm_BOX':
+ self.VC_TTS_voice_key = "林悦"
+ else:
+ self.VC_TTS_voice_key = "男"
+ if self.VC_TTS_voice_key in self.VC_TTS_voice_type:
+ pass
+ else:
+ self.VC_TTS_voice_key = list(self.VC_TTS_voice_type.keys())[0]
+ print("音色配置:{}:{}\r\n\r\n".format(self.VC_TTS_voice_key,self.VC_TTS_voice_type[self.VC_TTS_voice_key]))
+ self.VC_TTS_volume = EventMesh.publish("get_storage_config","VC_TTS_volume")#音量配置
+ except Exception as e:
+ usys.print_exception(e)
+ #配置词
+ self.commands_mode = 2 #=1用大模型判断命令,=0用服务器本地插件判断命令 =2用设备本地判断方式
+ if dev_type == "7PIN_BK"or dev_type == "7PIN_BK_EU"or dev_type == "7PIN_BK_coze":
+ self.commands_mode = 2
+ self.commands = [
+ {
+ "command": "切换音色",#命令
+ "patterns": [ #多种问法,说法
+ "声音改成", "声音改为", "改成", "改为", "换成", "切换成", "变成", "声音"
+ "使用", "设置声音为", "把声音改成", "声音切换到", "用","声音切换的"
+ ],
+ "exact_matches": ["声音改成", "声音改为", "改成", "改为"],#精确匹配的完整短语
+ "has_param": True,# 是否包含参数
+ "param_regexp": r"(?P<cmd_parameter>(男|难|女|童|同|粤|广东话|粤语|四川话|川普|四川口音))",#参数提取正则表达式
+ "require_full_match": False,#是否要求完全匹配
+ "negative_patterns": [],#否定模式(避免误触发)
+ "keyword_threshold": 0.6#关键词匹配阈值
+ },
+ {
+ "command": "音量加大",
+ "patterns": [
+ "音量加大","音量大", "声音大" ,"声音加大","听不清楚","声音太小","太小声了"
+ ],
+ "exact_matches": [],
+ "has_param": False,
+ "param_regexp": "",
+ "require_full_match": False,
+ "negative_patterns": ["声音太大"],
+ "keyword_threshold": 1
+ },
+ {
+ "command": "音量减小",
+ "patterns": [
+ "音量减小","音量小", "声音小","你太吵了","声音太大","太大声了"
+ ],
+ "exact_matches": [],
+ "has_param": False,
+ "param_regexp": "",
+ "require_full_match": False,
+ "negative_patterns": ["声音太小"],
+ "keyword_threshold": 0.8
+ },
+ {
+ "command": "关机",
+ "patterns": [
+ "关机", "关闭电源"
+ ],
+ "exact_matches": ["关机", "关闭电源"],
+ "has_param": False,
+ "param_regexp": "",
+ "require_full_match": True,
+ "negative_patterns": [],
+ "keyword_threshold": 0.8
+ },
+ {
+ "command": "进入工厂模式",
+ "patterns": [
+ "进入工厂模式"
+ ],
+ "exact_matches": ["进入工厂模式"],
+ "has_param": False,
+ "param_regexp": "",
+ "require_full_match": True,
+ "negative_patterns": [],
+ "keyword_threshold": 0.8
+ },
+ {
+
+ "command": "再见",
+ "patterns": [
+ "再见","拜拜","我要走了"
+ ],
+ "exact_matches": [],
+ "has_param": False,
+ "param_regexp": "",
+ "require_full_match": False,
+ "negative_patterns": [],
+ "keyword_threshold": 0.8
+ },
+ {
+
+ "command": "查询信号",
+ "patterns": [
+ "查询信号","信号怎样","信号是多少","信号怎么样"
+ ],
+ "exact_matches": [],
+ "has_param": False,
+ "param_regexp": "",
+ "require_full_match": False,
+ "negative_patterns": ["查询"],
+ "keyword_threshold": 0.8
+ },
+ {
+
+ "command": "查询卡号",
+ "patterns": [
+ "查询卡号","卡号","iccid号","ICCID号"
+ ],
+ "exact_matches": [],
+ "has_param": False,
+ "param_regexp": "",
+ "require_full_match": False,
+ "negative_patterns": ["查询"],
+ "keyword_threshold": 0.8
+ },
+ {
+
+ "command": "查询设备号",
+ "patterns": [
+ "设备号","查询设备号","查询IMEI号"
+ ],
+ "exact_matches": [],
+ "has_param": False,
+ "param_regexp": "",
+ "require_full_match": False,
+ "negative_patterns": ["查询"],
+ "keyword_threshold": 0.8
+ },
+ {
+ "command": "OTA升级",
+ "patterns": [
+ "OTA升级"
+ ],
+ "exact_matches": ["OTA升级"],
+ "has_param": False,
+ "param_regexp": "",
+ "require_full_match": True,
+ "negative_patterns": [],
+ "keyword_threshold": 1
+ },
+ {
+ "command": "查询服务器地址",
+ "patterns": [
+ "查询服务器地址"
+ ],
+ "exact_matches": [],
+ "has_param": False,
+ "param_regexp": "",
+ "require_full_match": False,
+ "negative_patterns": ["查询"],
+ "keyword_threshold": 0.9
+ }
+ ,
+ {
+ "command": "切换对话模式",
+ "patterns": [
+ "切换对话模式","切换兑换模式"
+ ],
+ "exact_matches": [],
+ "has_param": False,
+ "param_regexp": "",
+ "require_full_match": False,
+ "negative_patterns": [],
+ "keyword_threshold": 0.8
+ },
+ {
+ "command": "查询版本",
+ "patterns": [
+ "查询版本号","软件版本"
+ ],
+ "exact_matches": [],
+ "has_param": False,
+ "param_regexp": "",
+ "require_full_match": False,
+ "negative_patterns": ["查询"],
+ "keyword_threshold": 0.6
+ },
+ ]
+ if self.VC_TTS_volume == None:
+ self.VC_TTS_volume = 100
+ self.AI_audio_queue_thread_id = 0
+ self.AI_audio_queue_thread_lock = 0
+ self.AI_VC_send_data_queue_thread_id = 0
+ self.AI_VC_send_data_queue_thread_lock = 0
+ self.AI_ASR_send_data_queue_thread_id = 0
+ self.AI_ASR_send_data_queue_thread_lock = 0
+ self.AI_record_tmp_queue = Queue(100)
+ self.AI_ASR_send_data_queue = Queue(200)
+ self.AI_VC_send_data_queue = Queue(100)
+ self.AI_audio_queue = Queue(100)
+ #self.AI_WS_connect_Queue = Queue(100) #释放用
+ self.AI_TTS_str = ""
+ self.AI_ASR_str = ""
+ self.AI_ASR_flag = 0
+ self.AI_ASR_str_tmp = ""
+ self.AI_ASR_send_buf_len = 0
+ self.AI_ASR_text_tmp = ""
+ self.AI_ASR_text_repet_count = 0
+ # #开始线程
+ # if self.AI_audio_queue_thread_id ==0:
+ # self.AI_audio_queue_thread_id = _thread.start_new_thread(self.AI_audio_queue_thread, ())
+ # else:
+ # print("AI_VC_start :AI_audio_queue_thread_id != 0 ")
+ # if self.AI_VC_send_data_queue_thread_id == 0:
+ # self.AI_VC_send_data_queue_thread_id = _thread.start_new_thread(self.AI_VC_send_data_queue_thread, ())
+
+ self.VC_state = VC_State_None #阿里ai VC状态
+ self.VC_dialog_id = ""#
+ self.VC_message_id=None
+ self.VC_task_id =None
+ self.AI_client_VC = None
+ self.AI_client_VC_recv_id = 0
+ self.AI_client_VC_recv_lock = 0
+ self.AI_client_VC_isconnect =0
+ self.AI_client_VC_debug =0
+
+ self.asr_state = VC_State_None #阿里VC_ASR VC状态
+ self.key_state = 0
+
+ self.AI_client_asr = None
+ self.AI_client_asr_recv_id = 0
+ self.AI_client_asr_recv_lock = 0
+ self.AI_client_asr_isconnect =0
+ self.AI_ASR_timer = osTimer()
+ self.AI_ASR_timer_count = 0
+ self.AI_client_asr_debug =0
+ self.AI_ASR_check_timeout = 0
+ self.AI_ASR_error_timeout = 0
+ self.VC_Thinking_timerout = 0
+
+ self.record_pcm = None
+ self.play_pcm = None
+ self.VC_record_thread_id = 0
+ self.VC_record_thread_lock = 0
+ self.VC_pingping_timerout = 0
+ self.asr_pingping_timerout = 0
+ self.factory_timer = osTimer()
+ self._1S_timer = osTimer()
+ self.Audio_buf_size = 16*1024
+ self.record = audio.Record()
+ #self.record.end_callback(self.record_callback)
+ self.record.gain_set(4,10)
+ #self.record.gain_set(4,12)
+ self.aud = audio.Audio(0)
+ self.aud.setCallback(self.audio_cb)
+ #self.aud.setVolume(self.VC_TTS_volume //10)
+ self.audio_play_state = 1 #音频播放完状态
+ self.close_timerout = 0
+ self.LocalRespondingEnded_timerout = 0
+
+ self.VC_Play_flag = 0
+ self.play_flag = 0
+ self.VC_record_state_flag = 0
+ self.AI_key_long_press_flag = 0
+ self.websocket_error_count = 0
+
+ self.tts_in_data_len = 0
+ self.tts_out_data_len = 0
+ self.VC_satrt_flag = 0
+ self.session_id = ""
+ EventMesh.subscribe("AI_key_press", self.AI_key_press)
+ EventMesh.subscribe("AI_key_release", self.AI_key_release)
+ EventMesh.subscribe("AI_key_long_press", self.AI_key_long_press)
+ EventMesh.subscribe("pwk_key_release", self.pwk_key_release)
+ EventMesh.subscribe("get_AI_audio_queue", self.get_AI_audio_queue)
+ EventMesh.subscribe("get_VC_satrt_flag", self.get_VC_satrt_flag)
+ EventMesh.subscribe("VC_error", self.VC_error)
+
+ EventMesh.publish("close_led")
+
+ self.bot_name = "柒先生"
+ try:
+ if "bot_name" in self.VC_TTS_voice_type[self.VC_TTS_voice_key]:
+ self.bot_name = self.VC_TTS_voice_type[self.VC_TTS_voice_key]["bot_name"]
+ else:
+ print("not bot_name!!!!!!!!!!!!!!!!!!!!!!")
+ except Exception as e:
+ usys.print_exception(e)
+ try:
+ if self.ai_OTA.min_sys_ota()==1:
+ #if 0:
+ self.AI_TTS_str = "检测到有新版本需要升级啦!升级时可千万别断电或乱按哦,升级完成后设备会自动重启,重启就代表升级成功"
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_VC_start})
+ # if self.ai_OTA.min_sys_ota()==2:
+ # self.AI_TTS_str = "检测到有新版本需要升级啦!电量低于40%,无法保证升级正常执行,请充满电后重启设备再次升级!"
+ # EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_VC_start})
+ else:
+ try:
+ self.ai_OTA.ota_result()
+ self.ai_OTA.pots_ICCID()
+ except Exception as e:
+ usys.print_exception(e)
+ #开机提示语,如果联网失败,直接提示信号弱
+
+
+ #EventMesh.publish("get_storage_config",["powerRestart",1])
+ powerRestart = EventMesh.publish("get_storage_config","powerRestart")#=1非正常重启
+ if powerRestart == None:
+ powerRestart = 0
+ if powerRestart == 1:
+ EventMesh.publish("set_storage_config",["powerRestart",0])
+
+ else:
+ pass
+ self.AI_TTS_str = self.power_on_tone.replace("bot_name", self.bot_name)
+ print("开机提示:{}".format(self.AI_TTS_str))
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_VC_start})
+
+
+
+ except Exception as e:
+ usys.print_exception(e)
+
+
+ def post_processor_after_instantiation(self):
+ pass
+ def get_AI_audio_queue(self, event, msg):
+ return self.AI_audio_queue
+ def get_VC_satrt_flag(self, event, msg):
+ return self.VC_satrt_flag
+
+
+ def VC_30S_timer_cb(self, *args): #
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_30S_timer_cb_})
+
+ def VC_30S_timer_cb_(self):
+ self.get_config_timer_count += 1
+ if self.get_config_timer_count >= 2*60*2:#2小时更新配置参数
+ self.get_config_timer_count = 0
+ try:
+ self.http_get_config()#获取/更新配置参数
+ except Exception as e:
+ usys.print_exception(e)
+ #提交错误id
+ def ud_error(self,error_data):
+ response = None
+ if self.is_up_error == 1:
+ try:
+ # currentVersion = versions.Build_Time
+ # currentVersion = "7PIN-"+currentVersion[:10]+"-"+currentVersion[11:-3]
+ url = "http://{}/health?task_id={}".format(self.server_ip,error_data[0]+error_data[1])
+ print(url)
+ response = request.get(url,timeout=5)
+ if response.status_code == 200:
+
+ print("ud_error:ok")
+ else:
+ print("ud_error error!!!!")
+ for i in response.text:
+ print(i)
+ response.close()
+ except Exception as e:
+ usys.print_exception(e)
+ if response != None:
+ response.close()
+ #获取配置参数
+ def http_get_config(self, event=None, msg=None):
+ print("http_get_config")
+
+ response = None
+ #http://180.184.206.142/bz-api/dev/config?deviceId=xxx
+ try:
+ url=None
+ if dev_type == "7PIN_BK_EU":#英文小瑞
+ url = "http://dmp-global.raisound.com/bz-api/dev/config/{}".format(modem.getDevImei())
+ elif dev_type == "7PIN" or dev_type == "7PIN_coze":#柒牌
+ url = "http://ota.qipai.com/bz-cmp-api/api/config/{}".format(modem.getDevImei())
+ else:
+ url = "http://dmp.raisound.com/bz-api/dev/config/{}".format(modem.getDevImei())
+
+
+ print(url)
+ response = request.get(url,timeout=5)
+ if response.status_code == 200:
+ data = response.json()
+ print("http_get_config:{}".format(data))
+
+ if data:
+ try:
+ if data["code"] == 20000:#有配置
+ if data["data"] :
+ if "version" in data["data"]:
+ config_version = EventMesh.publish("get_storage_config","config_version")#音量配置
+ if config_version != data["data"]["version"]:
+ config_version = data["data"]["version"]
+ EventMesh.publish("set_storage_config",["config_version",config_version])
+ if "VC_TTS_voice_type" in data["data"]:
+ self.VC_TTS_voice_type = data["data"]["VC_TTS_voice_type"]
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_type",self.VC_TTS_voice_type])
+ print("配置VC_TTS_voice_type成功")
+ if "server_ip" in data["data"]:
+ self.server_ip = data["data"]["server_ip"]
+ EventMesh.publish("set_storage_config",["server_ip",self.server_ip])
+ print("配置server_ip成功")
+ if "power_on_tone" in data["data"]:
+ self.power_on_tone = data["data"]["power_on_tone"]
+ EventMesh.publish("set_storage_config",["power_on_tone",self.power_on_tone])
+ print("配置power_on_tone成功")
+
+ except Exception as e:
+ usys.print_exception(e)
+ else:
+ print("status_code:{}".format(response.status_code))
+ print("http_get_config:error!!!!!!!!!!")
+ response.close()
+ except Exception as e:
+ usys.print_exception(e)
+ if response != None:
+ response.close()
+
+ def audio_cb(self,event):
+ if event == 0:
+ self.audio_play_state =1
+ #EventMesh.publish("set_audio_state", 1)
+ print('audio-play start.')
+ elif event == 7:
+ self.audio_play_state = 0
+ #EventMesh.publish("set_audio_state", 0)
+ print('audio-play finish.!!!!!!')
+
+ def AI_key_press(self, event, msg):#按键按下
+ print("AI_key_press")
+ self.get_config_timer_count = 0
+ self.key_state = 1
+ self.Close()
+ # if dev_type == "7PIN" :
+ # self.aud.aud_tone_play(10,200)#播放按键音
+ #self.aud.aud_tone_play(10,200)#播放按键音
+ self.AI_TTS_str = ""#"你好,有什么吩咐"
+ self.AI_ASR_str = ""
+ self.AI_ASR_str_tmp = ""
+ self.VC_state = VC_State_None
+ # if self.VC_state != VC_State_None:
+ # EventMesh.publish("publish_AI_btnInfo",{"func":self.Close})
+ # EventMesh.publish("publish_AI_btnInfo",{"func":utime.sleep_ms,'data':(10)})
+ #if self.VC_record_state_flag >1:#如果在录音,就先停止录音
+ self.VC_Speech_End()
+
+ self.VC_Speech_Start()
+ self.AI_VC_start()
+ # if dev_type != "7PIN":
+ # self.chenggong_tone()
+ # self.Close()
+ # self.AI_VC_start()
+ self.AI_key_long_press_flag = 0
+
+
+ def AI_key_release(self, event, msg):#按键弹起
+ print("AI_key_release123")
+ self.key_state = 0
+ if self.AI_key_long_press_flag == 1 :#有长按
+ #self.AI_client_VC_end_speech()
+ #EventMesh.publish("publish_AI_btnInfo",{"func":utime.sleep_ms,'data':(1000)})
+ #EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_client_asr_StopTranscription_requset})
+ #self.AI_client_asr_StopTranscription_requset()#请求停止
+ if self.VC_mode == 1 :#长按单次问答模式
+ # if self.AI_ASR_str_tmp != "":
+ print("AI_key_release:asr_str:{}".format(self.AI_ASR_str))
+ # EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_VC_start})
+ self.AI_client_VC_end_speech()
+ pass
+
+ else :
+ if self.VC_mode == 1 :#长按单次问答模式
+ # try:
+ # EventMesh.publish("publish_AI_btnInfo",{"func":self.Close})
+ # except Exception as e:
+ # usys.print_exception(e)
+ #EventMesh.publish("publish_AI_btnInfo",{"func":self.key_prompt}) #提示请您按住中间的按钮开始讲话,讲完松开即可
+ if dev_type == "7PIN_BK_EU":
+ self.AI_TTS_str = "Please press and hold the button to speak. "
+ else:
+ self.AI_TTS_str = "请您按住中间的按钮开始讲话,讲完松开即可 "
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_VC_start})
+ pass
+
+ #self.VC_Speech_End()
+ def AI_key_long_press(self, event, msg):#按键长按
+ print("AI_key_long_press")
+ if dev_type == 'jswm' or dev_type == 'jswm_BOX' :
+ self.Close()
+ else:
+ self.AI_key_long_press_flag = 1
+
+ def pwk_key_release(self, event, msg):#电源键短按,关闭
+ print("pwk_key_release")
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.Close})
+
+ def key_prompt(self):
+ EventMesh.publish("audio_montage_play",["key_prompt.mp3"])
+ #self.aud.play(1,1,'U:/static/key_prompt.mp3')#提示请您按住中间的按钮开始讲话,讲完松开即可
+ def VC_error(self, event, msg):#错误播报
+ self.websocket_error()
+ #EventMesh.publish("publish_AI_btnInfo",{"func":self.websocket_error})
+ def set_VC_record_state_flag(self,data):
+
+ self.VC_record_state_flag = data
+ print("set_VC_record_state_flag:{}".format(self.VC_record_state_flag))
+ #开始录音,不缓存,直接发
+ def VC_Speech_Start_now(self):
+ self.VC_Speech_Start()
+ if self.VC_record_state_flag == 1:
+ self.VC_record_state_flag =2
+ print("VC_Speech_Start_now:{}".format(self.VC_record_state_flag))
+ #开始录音,先缓存到buf,等服务器响应再发
+ def VC_Speech_Start(self):
+ try:
+
+ #self.VC_state = VC_State_SpeechStart
+ print("VC_Speech_Start VC_record_state_flag:{} self.AI_ASR_flag:{}!!!!!!!!".format(self.VC_record_state_flag,self.AI_ASR_flag))
+ if self.AI_ASR_flag != 0:
+ return
+
+ if self.VC_record_state_flag == 0:
+
+ self.VC_record_thread_close()#关闭录音线程
+ _thread.stack_size(self.Audio_buf_size+8*1024)
+ self.VC_record_thread_id = _thread.start_new_thread(self.VC_record_thread,())
+ _thread.stack_size(8*1024)
+ print("self.VC_record_thread_id:{}".format(self.VC_record_thread_id))
+ try:
+
+ if self.VC_record_TYPE == VC_record_TYPE_AMR :
+ try :
+ self.record.stream_start(audio.Record.AMRNB, self.VC_record_samplerate, 0)
+ except Exception as e:
+ usys.print_exception(e)
+ elif self.VC_record_TYPE == VC_record_TYPE_PCM:
+ print("record_pcm.stream_read_start()!!!!!!!!!!!!")
+ self.record.stream_start(audio.Record.WAV, self.VC_record_samplerate, 0)
+ # if self.record_pcm != None:
+ # try:
+ # self.record_pcm.stream_stop()
+ # self.record_pcm.close()
+ # self.record_pcm = None
+ # except Exception as e:
+ # usys.print_exception(e)
+ # if self.record_pcm == None:
+ # ret = self.record_pcm = audio.Audio.PCM(0,1,16000,0,1,2)
+ # print("audio.Audio.PCM:ret:{}".format(ret))
+ # ret = self.record_pcm.stream_read_start()
+ # print("self.record_pcm.stream_read_start:ret:{}".format(ret))
+ except Exception as e:
+ usys.print_exception(e)
+
+ self.VC_record_state_flag = 1
+
+ except Exception as e:
+ self.websocket_error()
+ self.VC_record_state_flag = 1
+ self.VC_Speech_End()#关闭录音
+ usys.print_exception(e)
+ #停止录音
+ def VC_Speech_End(self):
+ try:
+ self.AI_ASR_flag = 0
+ self.AI_ASR_str_tmp = ""
+ self.AI_ASR_str = ""
+ #EventMesh.publish("publish_AI_btnInfo",{"func":self.websocket_deconnect_asr})
+
+ if self.VC_record_state_flag == 0:
+ return
+ #self.AI_client_asr_StopTranscription_requset()#请求停止
+ if self.VC_record_TYPE == VC_record_TYPE_AMR:
+ self.record.stream_stop()
+ self.record.stop()#关闭录音
+ Record_read_buf = bytearray(self.Audio_buf_size)
+ for i in range(10):
+ Record_len = self.record.stream_read(Record_read_buf, self.Audio_buf_size)
+ print("Record_len:!!!!!!{}".format(Record_len))
+ if Record_len <= 0:
+ break
+ elif self.VC_record_TYPE == VC_record_TYPE_PCM:
+ self.record.stream_stop()
+ self.record.stop()#关闭录音
+ Record_read_buf = bytearray(self.Audio_buf_size)
+ for i in range(10):
+ Record_len = self.record.stream_read(Record_read_buf, self.Audio_buf_size)
+ print("Record_len:!!!!!!{}".format(Record_len))
+ if Record_len <= 0:
+ break
+ # if self.record_pcm != None:
+ # try:
+ # self.record_pcm.stream_stop()
+ # self.record_pcm.close()
+ # self.record_pcm = None
+ # except Exception as e:
+ # usys.print_exception(e)
+ except Exception as e:
+ usys.print_exception(e)
+ self.VC_record_thread_close()#关闭录音线程
+ if self.AI_record_tmp_queue.empty() != True:
+ self.AI_record_tmp_queue.clear()
+
+ self.VC_record_state_flag = 0
+ print("VC_Speech_End VC_record_state_flag:{}!!!!!!!!".format(self.VC_record_state_flag))
+ #关闭录音线程
+ def VC_record_thread_close(self):
+ if self.VC_record_thread_id != 0:
+ count =50
+ while True:
+ count -= 1
+ if self.VC_record_thread_lock == 1:
+ self.VC_record_thread_lock = 2
+ if self.VC_record_thread_lock == 0 or count <=0:
+ break
+ else:
+ print("VC_record_thread_thread going:{}...".format(count))
+ utime.sleep_ms(1)
+ self.VC_record_thread_lock = 0
+ print("VC_record_thread_thread_close")
+ try:
+ _thread.stop_thread(self.VC_record_thread_id)
+ except Exception as e:
+ usys.print_exception(e)
+ self.VC_record_thread_id = 0
+ #获取录音数据
+ def VC_record_thread(self):
+ ##return
+ print("VC_record_thread start!!!!!!!!!!!!!!!!!!!!\r\n")
+ count = 0
+ RequestToSpeak_flag = 0
+ # try:
+ # uos.remove('/usr/test.pcm')
+ # except Exception as e:
+ # usys.print_exception(e)
+ #record_data_queue = Queue(100)
+ #fd = open('/usr/test.pcm','w')
+ # if self.VC_record_TYPE == 1:
+ # h_data= [0x23,0x21 ,0x41 ,0x4D ,0x52 ,0x0A ]
+ # h_data_b = bytes(h_data)
+ # self.AI_client_VC_send(h_data_b)
+ AI_record_tmp_queue_len = 0
+ vad_buf = bytearray()
+ VAD_data_count = 0
+ vad_state = 0
+ self.VAD_count = 0
+ while True:
+ try:
+ if self.VC_record_thread_lock == 2:
+ break
+ self.VC_record_thread_lock = 1
+ # 死循环接收数据
+ #if self.VC_state == VC_State_SpeechStart:
+ Record_read_buf = bytearray(self.Audio_buf_size)
+
+ Record_len = 0
+ if self.VC_record_TYPE == VC_record_TYPE_PCM:#pcm
+ Record_len = self.record.stream_read(Record_read_buf, self.Audio_buf_size)
+ #utime.sleep_ms(60)
+
+ else :
+
+ Record_len = self.record.stream_read(Record_read_buf, self.Audio_buf_size)
+ utime.sleep_ms(600)
+
+ #Record_len = 1024*2
+ #print("VC_record_thread:{}".format(Record_len))
+ if Record_len > 0:
+ read_buf = bytes(Record_read_buf[:Record_len])
+ print("Record_len:{}".format(Record_len))
+ #VAD检测
+ if self.is_VAD == 1:
+ vad_state = 0
+ tmp_c = 1000
+ while True:
+ tmp_c -=1
+ if tmp_c <=0:
+ break
+ #vad_buf_len = len(vad_buf)
+ if VAD_data_count == 0:#没数据的时候
+ vad_buf = Record_read_buf[:self.VAD_data_len]
+ VAD_data_count = self.VAD_data_len
+ self.vad.custom_vad_reset()#重置vad
+ else:#有数据的时候
+ if Record_len - VAD_data_count < self.VAD_data_len :#剩余长度不够一次填充,先保留,但不填算法
+ vad_buf = Record_read_buf[VAD_data_count:Record_len]
+ VAD_data_count = 0
+ break
+ else:#剩余长度够填一次数据
+ vad_buf = Record_read_buf[VAD_data_count:VAD_data_count+self.VAD_data_len]
+ VAD_data_count += len(vad_buf)
+ #print("vad_buf_len:{},{}".format(len(vad_buf),VAD_data_count))
+
+ if len(vad_buf) >= self.VAD_data_len:
+ vad_state = self.vad.custom_vad_process(vad_buf,len(vad_buf))#给vad数据
+ #print("vad_state:{}".format(vad_state))
+
+ if VAD_data_count >= Record_len:
+ VAD_data_count = 0
+ break
+ if vad_state == 1:
+ print("检测到VAD=1!!!!!!!!!!!!!")
+ print("检测到VAD=1!!!!!!!!!!!!!")
+ print("检测到VAD=1!!!!!!!!!!!!!")
+
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Play_Pause,"data":1})#停止音频
+ # EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_client_VC_RequestToSpeak})#打断
+ # RequestToSpeak_flag = 1
+
+ self.VAD_count+=1
+ if self.VAD_count >= 20:
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_client_VC_RequestToSpeak})#打断
+
+ else:
+ if self.VAD_count != 0:
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Play_Pause,"data":0})#恢复音频播放
+ self.VAD_count = 0
+ if self.VC_state >= VC_State_TTSStart:
+ pass
+ if vad_state == 1:
+ self.AI_record_tmp_queue.put(read_buf)#入缓存队列
+ AI_record_tmp_queue_len += len(read_buf)
+
+
+ else:
+ VAD_data_count = 0
+ if self.VC_record_state_flag <=1 :#没发送前先存起来
+ self.AI_record_tmp_queue.put(read_buf)
+ AI_record_tmp_queue_len += len(read_buf)
+ else:
+ AI_record_tmp_queue_len = 0
+ while True:
+ if self.AI_record_tmp_queue.empty() == True:
+ break
+ else:
+ pass
+ self.AI_client_VC_send(self.AI_record_tmp_queue.get()) #发送之前存的数据
+ self.AI_client_VC_send(read_buf)
+
+ if self.record_data_save_flag == 1:
+ if self.record_fd == None:
+ try:
+ uos.remove('/usr/record_data.pcm')
+ except Exception as e:
+ usys.print_exception(e)
+ self.record_fd = open('/usr/record_data.pcm','w')
+ if self.record_fd != None:
+ self.record_fd.write(read_buf)
+ print("write record:{}".format(len(read_buf)))
+ # count+=Record_len
+ # if count >150*1024:
+ # self.record_fd.close()
+ #self.record_fd = None
+
+
+
+
+ #print("VC_record_thread:{}".format(len(read_buf)))
+ #count+=len(read_buf)
+ # if count>=500*1024:#结束
+ # self.AI_client_VC_end_speech()
+ # break
+ # count+=1
+ # if count %10 == 0:
+ # print("VC_record_thread on line {} asr recv :{} send:{}".format(self.VC_record_state_flag,_thread.threadIsRunning(self.AI_client_asr_recv_id),_thread.threadIsRunning(self.AI_VC_send_data_queue_thread_id)))
+
+ # if self.VC_state >= VC_State_SpeechEnd:
+ # break
+
+ except Exception as e:
+ usys.print_exception(e)
+ #break
+ self.VC_record_thread_lock = 0
+ utime.sleep_ms(100)
+ #fd.close()
+ print("VC_record_thread:exit")
+ self.VC_record_thread_id = 0#线程退出
+ self.VC_record_thread_lock = 0
+###################################################### VC ###################################################################################
+ def websocket_connect_VC(self):
+ print("websocket_connect_VC:{} e:{}!!!!!!!!!!!!!!!!!!!!!".format(self.AI_client_VC_isconnect,self.AI_client_VC_debug))
+ if self.AI_client_VC_isconnect == 1:
+ return
+ # 创建VC客户端
+ try:
+ signal = net.csqQueryPoll()
+ if signal == -1 or sim.getStatus() != 1:#网络正常
+ self.websocket_error()
+ return
+
+ req_str = ""
+ ack = ""
+ if self.is_VC_ACK == 1:
+ ack = "ack=1"
+ lang = "lang=zh-cn"#普通话测试环境
+ try:
+ if "loang" in self.VC_TTS_voice_type[self.VC_TTS_voice_key]:
+ lang = self.VC_TTS_voice_type[self.VC_TTS_voice_key]["lang"]
+ else:
+ print("not lang!!!!!!!!!!!!!!!!!!!!!!")
+ except Exception as e:
+ usys.print_exception(e)
+
+ #女,男,童,粤,川
+ self.bot_name = "柒先生"
+ try:
+ if "bot_name" in self.VC_TTS_voice_type[self.VC_TTS_voice_key]:
+ self.bot_name = self.VC_TTS_voice_type[self.VC_TTS_voice_key]["bot_name"]
+ else:
+ print("not bot_name!!!!!!!!!!!!!!!!!!!!!!")
+ except Exception as e:
+ usys.print_exception(e)
+
+ # Headers = {'X-NLS-Token':'0c8b8f05a46f423096be64a9c4c46310'}
+ # self.AI_client_VC = uwebsocket.Client.connect('wss://nls-gateway-cn-beijing.aliyuncs.com/ws/v1',headers=Headers, debug=False)
+ token = EventMesh.publish("get_dev_token")
+ print("token:{}".format(token))
+
+ req_str = "vc/chat?is_auth={}".format(self.is_auth)
+ if dev_type == '7PIN_BK_coze' or dev_type == '7PIN_coze':
+ req_str = "vc/coze?is_auth={}".format(self.is_auth)
+ elif dev_type == 'jswm' or dev_type == 'jswm_BOX':
+ req_str = "vc/agent?is_auth={}".format(self.is_auth)
+
+ if(token):
+ url = 'ws://{}/{}&dt={}'.format(self.server_ip,req_str,token)
+ else:
+ url = 'ws://{}/{}'.format(self.server_ip,req_str)
+ #url = 'ws://115.190.94.208:22080/vc/coze?dt={}'.format(token)
+
+ print("VC VC:url{}".format(url))
+ self.AI_client_VC = uwebsocket.Client.connect(url, debug=True)
+ #self.AI_WS_connect_Queue.put(self.AI_client_VC)
+
+
+ print("websocket_connect_VC:OK!!!!!!!!!!!!!!!!!!!!!")
+ except Exception as e: #网络连接异常
+ usys.print_exception(e)
+ print("websocket_connect_VC error!!!\r\n")
+ str_error = str(e)
+ if str_error.find("[Errno 22] EINVAL")!= -1:
+ print("websocket_connect_VC:str_error:{}".format(str_error))
+ print("[Errno 22] EINVAL!!!\r\n")
+ print("[Errno 22] EINVAL!!!\r\n")
+ print("[Errno 22] EINVAL!!!\r\n")
+ print("[Errno 22] EINVAL!!!\r\n")
+ self.websocket_error()
+ EventMesh.publish("set_storage_config",["powerRestart",1])#调试临时关闭
+ utime.sleep_ms(1000)
+ self.aud.stopPlayStream()
+ self.aud.stopAll()
+ Power.powerRestart()
+
+ self.websocket_error()
+ return
+ #print("AI_client_VC:{}".format(self.AI_client_VC))
+ if self.AI_client_VC == None:
+ EventMesh.publish("update_dev_token")#获取token
+ self.websocket_error()
+ return
+ self.AI_client_VC_debug+=1
+ utime.sleep_ms(10)
+ self.AI_client_VC.settimeout(5)
+ #self.AI_VC_send_data_queue_thread_close()#关闭发送线程
+ if self.AI_VC_send_data_queue_thread_id == 0:
+ _thread.stack_size(self.Audio_buf_size+8*1024)
+ self.AI_VC_send_data_queue_thread_id = _thread.start_new_thread(self.AI_VC_send_data_queue_thread, ())
+ _thread.stack_size(8*1024)
+ print("AI_VC_start :AI_VC_send_data_queue_thread_id :{} ".format(self.AI_VC_send_data_queue_thread_id))
+ self.AI_client_VC_recv_thread_close()#关闭读线程
+ # 线程接收数据
+ _thread.stack_size(self.Audio_buf_size+8*1024)
+ self.AI_client_VC_recv_id = _thread.start_new_thread(self.AI_client_VC_recv, (self.AI_client_VC,))
+ _thread.stack_size(8*1024)
+ self.AI_client_VC_isconnect = 1
+ print("websocket_connect_VC end")
+
+ def websocket_error(self,TTS_str=None):
+ print("websocket_error1!!!!")
+ self.Close()
+ print("websocket_error1.1!!!!")
+ print("websocket_error!!!!")
+ print("websocket_error!!!!")
+ self.VC_Thinking_timerout = 0
+ self.VC_satrt_flag = 0
+ self.AI_TTS_str = ""
+ self.AI_ASR_str = ""
+ self.AI_ASR_str_tmp = ""
+ self.AI_ASR_flag = 0
+ self.VC_Speech_End()
+ EventMesh.publish("close_led")
+ if TTS_str == None:
+ self.websocket_error_count+=1
+ # if self.websocket_error_count <=3:
+ # EventMesh.publish("audio_montage_play",["xinhaoruo1.mp3"])
+ if self.websocket_error_count <10 :
+ EventMesh.publish("audio_montage_play",["xinhaoruo1.mp3"])
+ elif self.websocket_error_count >=10:
+ EventMesh.publish("paly_iccid_imei")
+ # else:
+ # EventMesh.publish("audio_montage_play",["R_SIM_FAILE.mp3"])
+ #self.aud.play(1,1,'U:/static/R_SIM_FAILE.mp3')
+ if self.websocket_error_count <3 :
+ utime.sleep_ms(3000)
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_VC_start})
+ else:
+ print("websocket_error:tts:{}".format(TTS_str))
+ self.AI_TTS_str = TTS_str
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_VC_start})
+ self.Close_flag = 1
+ print("websocket_error2")
+
+
+ print("websocket_error4")
+
+
+ def websocket_deconnect_VC(self):
+ #print("websocket_deconnect_VC {}!!!!!!!".format(self.AI_client_VC_isconnect))
+ print("websocket_deconnect_VC!!!!!!!")
+ self.AI_client_VC_recv_thread_close()#关闭读线程
+ self.AI_client_VC_recv_id = 0
+ if self.AI_client_VC_isconnect == 1 or self.AI_client_VC!=None:
+ try:
+ self.AI_client_VC_isconnect = 0
+ count = 500
+ while True:#等待发完数据
+ count-=1
+ if count <=0 or self.AI_VC_send_data_queue_thread_lock == 0:
+ break
+ utime.sleep_ms(1)
+
+ try:
+ self.AI_client_VC.close()
+ self.AI_client_VC_debug -=1
+ #self.AI_client_VC=None
+ except Exception as e:
+ usys.print_exception(e)
+ try :
+ self.AI_client_VC.close()
+ self.AI_client_VC_debug -=1
+ #self.AI_client_VC=None
+ except Exception as e:
+ usys.print_exception(e)
+ try :
+ self.AI_client_VC._close()
+ except Exception as e:
+ usys.print_exception(e)
+ self.AI_client_VC = None
+ except Exception as e:
+ usys.print_exception(e)
+ print("websocket_deconnect_VC {}!!!!!!!".format(self.AI_client_VC_isconnect))
+ #websocket发送ping
+ def AI_client_VC_ping(self):
+ pass
+ if self.AI_client_VC_isconnect == 1:
+ #self.AI_client_VC.write_frame(0x09,b'ping ping')
+ self.AI_client_VC_send("ping")
+ print("VC: ping ping")
+
+ #websocket发送数据
+ def AI_client_VC_send(self,data_str):
+ # if isinstance(data_str, str):#是字符串
+ # print("AI_client_VC_send:{}".format(data_str))
+ # pass
+ # else:
+ # print("AI_client_VC_send:len{}".format(len(data_str)))
+ self.AI_VC_send_data_queue.put([AI_client_VC_num,data_str])
+ #关闭数据发送线程
+ def AI_VC_send_data_queue_thread_close(self):
+ if self.AI_VC_send_data_queue_thread_id != 0:
+ count =500
+ while True:
+ count -= 1
+ if self.AI_VC_send_data_queue_thread_lock == 0 or count <=0:
+ break
+ else:
+ self.AI_VC_send_data_queue_thread_lock = 2
+ print("AI_VC_send_data_queue_thread going:{}...".format(count))
+ utime.sleep_ms(1)
+ if self.AI_VC_send_data_queue.empty()!=True:
+ self.AI_VC_send_data_queue.clear()
+ self.AI_VC_send_data_queue_thread_lock = 0
+ print("AI_VC_send_data_queue_thread_close")
+ try:
+ _thread.stop_thread(self.AI_VC_send_data_queue_thread_id)
+ except Exception as e:
+ usys.print_exception(e)
+ self.AI_VC_send_data_queue_thread_id = 0
+ #发送数据队列
+ def AI_VC_send_data_queue_thread(self):
+ print("AI_VC_send_data_queue_thread:start")
+ count_t = 0
+ while True:
+ if self.AI_VC_send_data_queue_thread_lock == 2:
+ print("AI_VC_send_data_queue_thread,该退出了")
+ break
+ if self.AI_VC_send_data_queue.empty() :#不能去掉,去掉会卡死
+ self.AI_VC_send_data_queue_thread_lock = 0
+ count_t+=1
+ # if count_t%200 == 0:
+ # print("self.AI_VC_send_data_queue.empty")
+ utime.sleep_ms(1)
+ else:
+ #data[0]是websocket连接对象编号,data[1]是数据
+ #print("AI_VC_send_data_queue_thread:get")
+
+ self.AI_VC_send_data_queue_thread_lock = 1
+ data = self.AI_VC_send_data_queue.get()
+
+
+ #print("AI_VC_send_data_queue_thread:num{} len{}".format(data[0],len(data[1])))
+ if data != None:
+ try:
+ #data["func"](data["data"])
+ # 发送数据
+ #bytes_data = bytes(data[1])
+ #data[0].send(data[1])
+ #print("AI_VC_send_data_queue_thread:len:{}".format(len(data[1])))
+ #print("AI_VC_send_data_queue_thread on line asr recv :{} vc recv:{}".format(_thread.threadIsRunning(self.AI_client_asr_recv_id),_thread.threadIsRunning(self.AI_client_VC_recv_id)))
+ if data[0] == AI_client_VC_num:
+
+ if isinstance(data[1], str):#是字符串
+ self.VC_pingping_timerout = 0
+ print("VC VC: send_data:{}".format(data[1]))
+ else:
+ print("VC: send_data len:{}".format(len(data[1])))
+ if self.AI_client_VC != None and self.AI_client_VC_isconnect == 1:
+ self.AI_client_VC.send(data[1])
+ else:
+ print("VC VC: send_data:ERROR:{}".format(len(data[1])))
+ #print("VC: send_data end")
+
+ #print("VC: send_data end")
+ except Exception as e:
+ print("DeviceInfo_queue_thread:ERROR:{}".format(e))
+ usys.print_exception(e)
+ if data[0] == AI_client_VC_num:
+ #self.websocket_error()
+ pass
+
+
+ try:
+ if self.AI_client_VC_isconnect != 0:
+ print("VC发送数据错误,退出")
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.websocket_error,"data":"VC发送出错了,请重试"})
+ self.ud_error(["VC",self.VC_taskid])
+ except Exception as e: #网络连接异常
+ usys.print_exception(e)
+
+ utime.sleep_ms(1)
+ self.AI_VC_send_data_queue_thread_lock = 0
+ #VC关闭读线程
+ def AI_client_VC_recv_thread_close(self):
+ if self.AI_client_VC_recv_id != 0:
+ count =500
+ while True:
+ count -= 1
+ if self.AI_client_VC_recv_lock == 1:
+ self.AI_client_VC_recv_lock = 2
+ if self.AI_client_VC_recv_lock == 0 or count <=0:
+ break
+ else:
+ print("AI_client_VC_recv_thread going:{}...".format(count))
+ utime.sleep_ms(1)
+ self.AI_client_VC_recv_lock = 0
+ print("AI_client_VC_recv_thread_close")
+ try:
+ _thread.stop_thread(self.AI_client_VC_recv_id)
+ except Exception as e:
+ usys.print_exception(e)
+ self.AI_client_VC_recv_id = 0
+ #Ai VC websocket返回数据
+ def AI_client_VC_recv(self,cli):
+ count = 0
+ asr_led_flag = 0
+ tts_led_flag = 0
+ while True:
+ try:
+ # 死循环接收数据
+ self.AI_client_VC_recv_lock = 0
+
+ count+=1
+ if self.VC_state >= VC_State_TTSStart and (self.tts_in_data_len - self.tts_out_data_len > 64*1024 or count>5):
+ count = 0
+ utime.sleep_ms(1)
+ if self.VC_state < VC_State_TTSStart:
+ utime.sleep_ms(1)
+ recv_data = cli.recv()
+ if self.AI_client_VC_recv_lock == 2:
+ print("AI_client_VC_recv 该退出了")
+ break
+ self.AI_client_VC_recv_lock = 1
+ self.close_timerout = 0#服务器有返回清零退出时间
+ if recv_data == "websocket close":
+ # 服务器关闭连接
+ print("VC 服务器关闭连接!!!!!!!!!!!!!!!!!!!!!!!!!!!")
+ #self.AI_client_VC_isconnect = 0
+ #self.websocket_deconnect_VC()
+ #EventMesh.publish("publish_AI_btnInfo",{"func":self.websocket_deconnect_asr})
+ # #EventMesh.publish("publish_AI_btnInfo",{"func":utime.sleep_ms,'data':(1500)})
+ #EventMesh.publish("publish_AI_btnInfo",{"func":self.websocket_connect_asr})
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.websocket_error,"data":"VC连接断开了,请重试"})
+ self.ud_error(["VC",self.VC_taskid])
+ break
+ elif recv_data == "":#客户端关闭连接
+ print("VC VC :客户端关闭连接")
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.websocket_error,"data":"VC连接断开了,请重试"})
+ self.ud_error(["VC",self.VC_taskid])
+ break
+ try:
+ self.websocket_error_count = 0
+ if isinstance(recv_data, str):#返回的是字符串
+ print("VC VC:recv_data:{}".format(recv_data))
+ jsload_data = ujson.loads(recv_data)
+ #print("AI_client_VC_recv jsload_data = {}".format(jsload_data))
+
+ if jsload_data["event"] == "started" :#会话开始
+ #payload = jsload_data["payload"]
+ # self.VC_dialog_id = payload["dialog_id"]
+ # self.VC_task_id = jsload_data["task_id"]
+ EventMesh.publish("open_led_blue")
+
+ print("VC:Started!!!!!!!!\r\n")
+ if self.AI_TTS_str == "":
+ #开始上传语音
+ if dev_type != "7PIN" and dev_type != "7PIN_coze":
+ self.chenggong_tone()
+ if self.VC_mode == 0 :
+ self.VC_record_state_flag =2
+ else:
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_client_VC_send_speech})
+
+
+ else:
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_client_VC_synthesis})
+ self.VC_state = VC_State_None
+ elif jsload_data["event"] == "config.update" :#配置更新中,需要停止录音
+ self.VC_state = VC_State_End
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Speech_End})
+
+ elif jsload_data["event"] == "asr.started" :#asr开始
+ self.VC_state = VC_State_SpeechStart
+ if self.VC_mode == 1 :
+ self.VC_record_state_flag = 2
+ EventMesh.publish("open_led_blue")
+ elif jsload_data["event"] == "asr.result" :#asr结果
+ self.AI_ASR_str = jsload_data["payload"]["content"]
+
+ EventMesh.publish("open_led_blue")
+ elif jsload_data["event"] == "asr.completed" :#asr 终止的标识
+ print("self.commands_mode:{}".format(self.commands_mode))
+ if self.commands_mode ==2:
+ ret= self.check_text(self.AI_ASR_str)
+ if ret == 0:#配置指令
+
+ if self.AI_VC_send_data_queue.empty()!=True:
+ self.AI_VC_send_data_queue.clear()
+ if self.AI_ASR_send_data_queue.empty()!=True:
+ self.AI_ASR_send_data_queue.clear()
+ self.AI_ASR_send_buf_len = 0
+ EventMesh.publish("open_led_all")
+ try:
+
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Speech_End})
+ 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)
+ continue
+ elif ret == 1:#不处理
+ pass
+ #self.VC_Speech_End()
+ #EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Speech_End})
+ if self.record_data_save_flag == 1:
+ if self.record_fd :
+ self.record_fd.close()
+ self.record_fd = None
+ # if dev_type != "7PIN" :
+ #EventMesh.publish("publish_AI_btnInfo",{"func":self.send_tone})
+ elif jsload_data["event"] == "vad.silence" :#VAD 终止的标识
+ pass
+ #EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Speech_End})
+ elif jsload_data["event"] == "llm.created" :#会话开始
+ EventMesh.publish("open_led_red_green")#
+ self.VC_state = VC_State_Thinking
+ # EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Play_Start})
+ pass
+ elif jsload_data["event"] == "llm.delta" :#llm返回数据
+ if self.is_VAD == 0:
+ if self.VC_record_state_flag == 1:#llm返回数据还没停止,就先停止
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Speech_End})
+ elif jsload_data["event"] == "tts.started" :#tts开始
+ self.VC_state = VC_State_TTSStart
+ if self.is_VAD == 0:
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Speech_End})
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Play_Start})
+
+ #self.VC_Play_Start()
+ EventMesh.publish("open_led_green")#绿色
+ elif jsload_data["event"] == "tts.completed" :#tts结束
+ EventMesh.publish("open_led_green")#绿色
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Play_Start})
+ self.LocalRespondingEnded_timerout = 8
+ self.VC_state = VC_State_TTSEnd
+ pass
+
+ elif jsload_data["event"] == "canceled" :#打断
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Speech_Start_now})#开始录音
+ self.VC_state = VC_State_None
+ elif jsload_data["event"] == "completed" :#会话结束
+ #EventMesh.publish("open_led_green")#绿色
+
+ self.LocalRespondingEnded_timerout = 8
+ self.VC_state = VC_State_End
+ pass
+ elif jsload_data["event"] == "command" :#命令匹配
+ ret = -1
+ try:
+ if self.commands_mode ==1:
+ if len(jsload_data["payload"]["functions"])>0:
+
+ cmd = jsload_data["payload"]["functions"][0]["function"]["arguments"]
+ print("llm:cmd:{}".format(cmd))
+ cmd = ujson.loads(cmd)
+ ret = self.check_text_llm(cmd)
+ elif self.commands_mode ==0:
+
+ cmd = jsload_data["payload"]
+ print("server:cmd:{}".format(cmd))
+ ret = self.check_text_server(cmd)
+ except Exception as e:
+ usys.print_exception(e)
+ if ret == -1:
+ if self.AI_TTS_str =="":
+ self.AI_TTS_str = "抱歉,没找到对应操作,可以换个说法试试"
+ #EventMesh.publish("publish_AI_btnInfo",{"func":utime.sleep_ms,'data':(10)})
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Speech_End})
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.websocket_deconnect_VC})
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_VC_start})
+ elif jsload_data["event"] == "failed":#接口返回错误
+ if jsload_data["payload"]["error"] == "concurrency_limit_exceeded":
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.concurrency_limit_exceeded_tone})
+
+ #utime.sleep_ms(4000)
+
+ else:
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.websocket_error,"data":jsload_data["payload"]["message"]})
+ pass
+ else:#下发音频数据
+ #self.AI_ASR_str = ""#下发音频后清掉asr结果
+
+
+ EventMesh.publish("open_led_green")#绿色
+
+ print("下发音频数据1:{}".format(len(recv_data)))
+
+ if self.play_data_save_flag == 1:
+ if self.play_fd ==None:
+ try:
+ uos.remove('/usr/play_data.pcm')
+ except Exception as e:
+ usys.print_exception(e)
+ self.play_fd = open('/usr/play_data.pcm','w')
+ if self.play_fd !=None:
+ self.play_fd.write(recv_data)
+ # print("下发音频数据2:{}".format(len(recv_data)))
+ #if self.VC_state >= VC_State_TTSStart:
+ #self.put_record_data([recv_data,""])
+ if self.VC_play_TYPE == VC_play_TYPE_PCM:
+ if self.play_pcm != None:
+ try:
+ #print("play_pcm.stream_write !!!")
+ buf_len = self.play_pcm.stream_get_buf_len()
+ count_tmp = 1000
+ while buf_len < len(recv_data):
+ utime.sleep_ms(1)
+ count_tmp-=1
+ if count_tmp<=0:
+ break
+ buf_len = self.play_pcm.stream_get_buf_len()
+ #print("buf已满,等待释放:buf_len:{},count_tmp:{}".format(buf_len,count_tmp))
+ except Exception as e:
+ usys.print_exception(e)
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.put_record_data,"data":[recv_data,""]})
+ utime.sleep_ms(1)
+ except Exception as e:
+ usys.print_exception(e)
+
+ except Exception as e:
+ error_str = str(e)
+ #print("VC VC:e:{}".format(error_str))
+ if error_str.find("[Errno 110] ETIMEDOUT")!= -1 or error_str.find("[Errno 115] ")!= -1:
+ print("VC VC:recv 正常报错:{}".format(error_str))
+ pass
+ else:
+ usys.print_exception(e)
+ #self.websocket_error()
+ print("VC VC :读数据报错,退出")
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.websocket_error,"data":"VC出错了,请重试"})
+ self.ud_error(["VC",self.VC_taskid])
+ break
+ self.AI_client_VC_isconnect = 0
+ self.AI_client_VC_recv_id = 0
+ self.AI_client_VC_recv_lock = 0
+ print("AI_client_VC_recv END!!!!!!!!!!!!!!!!!!!!!!!!!!!")
+
+ def put_record_data(self,data):
+ #print("下发音频数据1:{}".format(len(data[0])))
+ ret=self.AI_audio_queue.put(data)
+ self.tts_in_data_len += len(data[0])
+ #print("下发音频数据2:{},{}".format(len(data[0]),self.tts_in_data_len))
+ def check_text_server(self,cmd):
+ # if len(text)>60:
+ # return -1
+ try:
+ text = cmd["command"]
+ if text.find("切换音色") != -1 :
+ try:
+ text = cmd["params"]["cmd_parameter"]
+ for key in self.VC_TTS_voice_type:
+ if text.find(key) != -1 :
+ self.VC_TTS_voice_key = key
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+ self.AI_TTS_str = "更改成功"
+ return 0
+ except Exception as e:
+ usys.print_exception(e)
+ if text.find("男") != -1 :
+ if "男" in self.VC_TTS_voice_type:
+ self.VC_TTS_voice_key = "男"
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+ # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
+ #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功
+ self.AI_TTS_str = "更改成功"
+ return 0
+ if text.find("女") != -1 :
+ if "女" in self.VC_TTS_voice_type:
+ self.VC_TTS_voice_key = "女"
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+ # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
+ #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功
+ self.AI_TTS_str = "更改成功"
+ return 0
+ if text.find("同声") != -1 or text.find("童") != -1 :
+ if "童" in self.VC_TTS_voice_type:
+ self.VC_TTS_voice_key = "童"
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+ # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
+ #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功
+ self.AI_TTS_str = "更改成功"
+ return 0
+ if text.find("粤") != -1 or text.find("越野") != -1 or text.find("广东话") != -1:
+ if "粤" in self.VC_TTS_voice_type:
+ self.VC_TTS_voice_key = "粤"
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+ # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
+ #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功
+ self.AI_TTS_str = "更改成功"
+ return 0
+ if text.find("四川") != -1 :
+ if "四川" in self.VC_TTS_voice_type:
+ self.VC_TTS_voice_key = "四川"
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+ # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
+ #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功
+ self.AI_TTS_str = "更改成功"
+ return 0
+ if text.find("个性") != -1 :
+ if "个性" in self.VC_TTS_voice_type:
+ self.VC_TTS_voice_key = "个性"
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+ # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
+ #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功
+ self.AI_TTS_str = "更改成功"
+ return 0
+ if text.find("英语") != -1 :
+ if "英语" in self.VC_TTS_voice_type:
+ self.VC_TTS_voice_key = "英语"
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+ # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
+ #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功
+ self.AI_TTS_str = "更改成功"
+ return 0
+ self.AI_TTS_str = "更改失败,没找到对应声音"
+ return 0
+ if text.find("切换对话模式") != -1:
+ if self.VC_mode == 0:
+ self.VC_mode = 1
+ self.AI_TTS_str = "已切换到单对话模式"
+ else:
+ self.VC_mode = 0
+ self.AI_TTS_str = "已切换到长对话模式"
+ EventMesh.publish("set_storage_config",["VC_mode",self.VC_mode])
+ # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
+ #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功
+
+ return 0
+ if text.find("音量") != -1:
+ if text.find("加") != -1 :
+ self.VC_TTS_volume += 10
+ if self.VC_TTS_volume > 100:
+ #EventMesh.publish("audio_montage_play",["yinliangyizuida.mp3"])
+ #self.aud.play(1,0,'U:/static/yinliangyizuida.mp3')#音量已最大
+ self.AI_TTS_str = "音量已最大"
+ self.VC_TTS_volume = 100
+ else:
+ self.aud.setVolume(self.VC_TTS_volume //10)
+ EventMesh.publish("set_storage_config",["VC_TTS_volume",self.VC_TTS_volume])
+ #EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
+ #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#配置成功
+ self.AI_TTS_str = "配置成功,当前音量 {}".format(self.VC_TTS_volume)
+
+ return 0
+ if text.find("减") != -1:
+ self.VC_TTS_volume -= 10
+ if self.VC_TTS_volume < 0:
+ self.VC_TTS_volume = 0
+ #EventMesh.publish("audio_montage_play",["yinliangyizuixiao.mp3"])
+ #self.aud.play(1,0,'U:/static/yinliangyizuixiao.mp3')#音量已最小
+ self.AI_TTS_str = "音量已最小"
+ else:
+ self.aud.setVolume(self.VC_TTS_volume //10)
+ EventMesh.publish("set_storage_config",["VC_TTS_volume",self.VC_TTS_volume])
+ #EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
+ #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#配置成功
+ self.AI_TTS_str = "配置成功,当前音量 {}".format(self.VC_TTS_volume)
+ return 0
+
+ if text.find("进入工厂模式") != -1 :
+ self.factory_mode()
+ return 1
+ if text.find("查询") != -1:
+
+ if text.find("信号") != -1 :
+ signal = net.csqQueryPoll()
+
+ self.AI_TTS_str = "当前信号{}".format(signal)
+ return 0
+ if text.find("电量") != -1 :
+ battery = EventMesh.publish("get_battery")
+ print("电量查询:{}".format(battery))
+ #EventMesh.publish("audio_montage_play",["dianliangshengyu{}.mp3".format(battery)])
+ #self.aud.play(1,0,'U:/static/dianliangshengyu{}.mp3'.format(battery))#电量剩余
+ self.AI_TTS_str = "电量剩余百分之{}".format(battery)
+ return 0
+ if text.find("电压") != -1 :
+ Vbatt = Power.getVbatt()
+ #EventMesh.publish("audio_montage_play",["dianliangshengyu{}.mp3".format(battery)])
+ #self.aud.play(1,0,'U:/static/dianliangshengyu{}.mp3'.format(battery))#电量剩余
+ self.AI_TTS_str = "当前电池电压{}".format(Vbatt)
+ return 0
+
+ if text.find("卡号") != -1 :
+ iccid = sim.getIccid()
+ if iccid != -1 and len(iccid) > 5:
+ print("iccid{}".format(iccid))
+ self.AI_TTS_str = "当前卡号为:{}".format(iccid)
+ else:
+ self.AI_TTS_str = "卡号查询失败"
+ return 0
+ if text.find("设备号") != -1 :
+ imei = modem.getDevImei()
+ if imei != -1 and len(imei) > 5:
+ print("IMEI:{}".format(imei))
+ self.AI_TTS_str = "当前设备号为:{}".format(imei)
+ else:
+ self.AI_TTS_str = "设备号查询失败"
+ return 0
+ if text.find("版本") != -1 :
+ sourceVersion = versions.Build_Time
+ self.AI_TTS_str ="Mr-Seven-"+sourceVersion
+ return 0
+ if text.find("服务器地址") != -1 :
+ self.AI_TTS_str ="服务器地址"+self.server_ip
+ return 0
+ if text.find("升级") != -1 and (text.find("OTA") != -1 or text.find("ota") != -1):
+ if self.ai_OTA.min_sys_ota()==1:
+ self.AI_TTS_str = "有新版本,准备开始升级,升级过程会多次重启设备,请保证流量充足及电量充足"
+ else:
+ self.AI_TTS_str = "当前已是最新版本"
+ return 0
+
+ if len(text)<20 and (text.find("再见") != -1 or text.find("拜拜") != -1 or text.find("关闭对话") != -1):
+ #EventMesh.publish("publish_AI_btnInfo",{"func":self.Close})
+ self.AI_TTS_str = "好嘞,再见,我们下次再聊"
+ self.Close_flag = 1
+ return 0
+ if len(text)<12 and (text.find("关机") != -1 ):
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.Close})
+ EventMesh.publish("Power_off")
+ return 1
+ except Exception as e:
+ usys.print_exception(e)
+ return -1
+ def check_text_llm(self,cmd):
+ try:
+ text = cmd["command"]["chinese_description"]
+ if text.find("切换音色") != -1:
+ text = cmd["command"]["params_json"]
+ try:
+ for key in self.VC_TTS_voice_type:
+ if text.find(key) != -1 :
+ self.VC_TTS_voice_key = key
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+ self.AI_TTS_str = "了解,声音已切换"
+ return 0
+ except Exception as e:
+ usys.print_exception(e)
+ if text.find("男") != -1 :
+ if "男" in self.VC_TTS_voice_type:
+ self.VC_TTS_voice_key = "男"
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+
+ self.AI_TTS_str = "了解,声音已切换"
+ return 0
+ if text.find("女") != -1 :
+ if "女" in self.VC_TTS_voice_type:
+ self.VC_TTS_voice_key = "女"
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+
+ self.AI_TTS_str = "了解,声音已切换"
+ return 0
+ if text.find("同声") != -1 or text.find("童") != -1 :
+ if "童" in self.VC_TTS_voice_type:
+ self.VC_TTS_voice_key = "童"
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+
+ self.AI_TTS_str = "了解,声音已切换"
+ return 0
+ if text.find("粤") != -1 or text.find("越野") != -1 or text.find("广东话") != -1:
+ if "粤" in self.VC_TTS_voice_type:
+ self.VC_TTS_voice_key = "粤"
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+
+ self.AI_TTS_str = "了解,声音已切换"
+ return 0
+ if text.find("四川") != -1 :
+ if "四川" in self.VC_TTS_voice_type:
+ self.VC_TTS_voice_key = "四川"
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+
+ self.AI_TTS_str = "了解,声音已切换"
+ return 0
+ if text.find("个性") != -1 :
+ if "个性" in self.VC_TTS_voice_type:
+ self.VC_TTS_voice_key = "个性"
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+
+ self.AI_TTS_str = "了解,声音已切换"
+ return 0
+ if text.find("英语") != -1 :
+ if "英语" in self.VC_TTS_voice_type:
+ self.VC_TTS_voice_key = "英语"
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+
+ self.AI_TTS_str = "了解,声音已切换"
+ return 0
+ self.AI_TTS_str = "很抱歉,没找到对应声音"
+ return 0
+ if text.find("切换对话模式") != -1:
+ if self.VC_mode == 0:
+ self.VC_mode = 1
+ self.AI_TTS_str = "了解,已切换到单对话模式"
+ else:
+ self.VC_mode = 0
+ self.AI_TTS_str = "了解,已切换到长对话模式"
+ EventMesh.publish("set_storage_config",["VC_mode",self.VC_mode])
+
+
+ return 0
+ if text.find("音量调整") != -1:
+ text = cmd["command"]["params_json"]
+ text = ujson.loads(text)
+ volume = text["n"]
+ if volume >100 or volume<0:
+ self.AI_TTS_str = "音量调整超出范围了,只能0-100哦"
+ else:
+ self.VC_TTS_volume = volume
+ self.aud.setVolume(self.VC_TTS_volume //10)
+ EventMesh.publish("set_storage_config",["VC_TTS_volume",self.VC_TTS_volume])
+ self.AI_TTS_str = "了解,音量已经调整,当前音量是{}".format(self.VC_TTS_volume)
+ return 0
+ if text.find("音量增大") != -1:
+ self.VC_TTS_volume += 10
+ if self.VC_TTS_volume > 100:
+
+ self.AI_TTS_str = "音量已经是最大啦"
+ self.VC_TTS_volume = 100
+ else:
+ self.aud.setVolume(self.VC_TTS_volume //10)
+ EventMesh.publish("set_storage_config",["VC_TTS_volume",self.VC_TTS_volume])
+
+ self.AI_TTS_str = "了解,音量已经调大了,当前音量是{}".format(self.VC_TTS_volume)
+
+ return 0
+ if text.find("音量减小") != -1:
+ self.VC_TTS_volume -= 10
+ if self.VC_TTS_volume < 0:
+ self.VC_TTS_volume = 0
+ #EventMesh.publish("audio_montage_play",["yinliangyizuixiao.mp3"])
+ #self.aud.play(1,0,'U:/static/yinliangyizuixiao.mp3')#音量已最小
+ self.AI_TTS_str = "音量已经是最小啦"
+ else:
+ self.aud.setVolume(self.VC_TTS_volume //10)
+ EventMesh.publish("set_storage_config",["VC_TTS_volume",self.VC_TTS_volume])
+
+ self.AI_TTS_str = "好嘞,音量已经调小了,当前音量是{}".format(self.VC_TTS_volume)
+ return 0
+
+ if text.find("语速增大") != -1:
+ self.speech_rate += 10
+ if self.speech_rate > 50:
+
+ self.AI_TTS_str = "语速已经是最快了"
+ self.speech_rate = 50
+ else:
+
+ EventMesh.publish("set_storage_config",["speech_rate",self.speech_rate])
+
+ self.AI_TTS_str = "明白,语速已经调快了,当前语速是{}".format(self.speech_rate)
+
+ return 0
+ if text.find("语速减小") != -1:
+ self.speech_rate -= 10
+ if self.speech_rate < -50:
+ self.speech_rate = -50
+ #EventMesh.publish("audio_montage_play",["yinliangyizuixiao.mp3"])
+ #self.aud.play(1,0,'U:/static/yinliangyizuixiao.mp3')#音量已最小
+ self.AI_TTS_str = "语速已经是最慢了"
+ else:
+ EventMesh.publish("set_storage_config",["speech_rate",self.speech_rate])
+
+ self.AI_TTS_str = "明白,语速已经调慢了,当前语速是{}".format(self.speech_rate)
+ return 0
+
+ if text.find("进入工厂模式") != -1 :
+ self.factory_mode()
+ return 1
+ if text.find("查询") != -1:
+ if text.find("信号") != -1 :
+ signal = net.csqQueryPoll()
+
+ self.AI_TTS_str = "当前信号{}".format(signal)
+ return 0
+ if text.find("电量") != -1 :
+ battery = EventMesh.publish("get_battery")
+ print("电量查询:{}".format(battery))
+ #EventMesh.publish("audio_montage_play",["dianliangshengyu{}.mp3".format(battery)])
+ #self.aud.play(1,0,'U:/static/dianliangshengyu{}.mp3'.format(battery))#电量剩余
+ self.AI_TTS_str = "电量剩余百分之{}".format(battery)
+ return 0
+ if text.find("电压") != -1 :
+ Vbatt = Power.getVbatt()
+ #EventMesh.publish("audio_montage_play",["dianliangshengyu{}.mp3".format(battery)])
+ #self.aud.play(1,0,'U:/static/dianliangshengyu{}.mp3'.format(battery))#电量剩余
+ self.AI_TTS_str = "当前电池电压{}".format(Vbatt)
+ return 0
+
+ if text.find("卡号") != -1 :
+ iccid = sim.getIccid()
+ if iccid != -1 and len(iccid) > 5:
+ print("iccid{}".format(iccid))
+ self.AI_TTS_str = "当前卡号为:{}".format(iccid)
+ else:
+ self.AI_TTS_str = "卡号查询失败"
+ return 0
+ if text.find("设备号") != -1 :
+ imei = modem.getDevImei()
+ if imei != -1 and len(imei) > 5:
+ print("IMEI:{}".format(imei))
+ self.AI_TTS_str = "当前设备号为:{}".format(imei)
+ else:
+ self.AI_TTS_str = "设备号查询失败"
+ return 0
+ if text.find("版本") != -1 :
+ sourceVersion = versions.Build_Time
+ self.AI_TTS_str ="Mr-Seven-"+sourceVersion
+ return 0
+ if text.find("服务器地址") != -1 :
+ self.AI_TTS_str ="服务器地址"+self.server_ip
+ return 0
+ if text.find("升级") != -1 and (text.find("OTA") != -1 or text.find("ota") != -1):
+ if self.ai_OTA.min_sys_ota()==1:
+ self.AI_TTS_str = "有新版本,准备开始升级,升级过程会多次重启设备,请保证流量充足及电量充足"
+ else:
+ self.AI_TTS_str = "当前已是最新版本"
+ return 0
+
+ if len(text)<20 and (text.find("再见") != -1 or text.find("拜拜") != -1 or text.find("关闭对话") != -1):
+ #EventMesh.publish("publish_AI_btnInfo",{"func":self.Close})
+ self.AI_TTS_str = "好嘞,再见,我们下次再聊"
+ self.Close_flag = 1
+ return 0
+ if len(text)<12 and (text.find("关机") != -1 ):
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.Close})
+ EventMesh.publish("Power_off")
+ return 1
+ except Exception as e:
+ usys.print_exception(e)
+ self.AI_TTS_str = cmd["command"]["fail_prompt"]
+ return -1
+ def check_text(self,text):
+ print("check_text:len:{}".format(len(text)))
+ if len(text)>60:
+ return -1
+ try:
+ if isinstance(text, str):
+ if dev_type != 'jswm' and dev_type != 'jswm_BOX':#金三完美,不使用设备切换角色
+ # if len(text)<25 and (text.find("你好") != -1 or text.find("您好") != -1) :
+ # try:
+ # for key in self.VC_TTS_voice_type:
+ # if text.find(key) != -1 :
+ # self.VC_TTS_voice_key = key
+ # EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+ # self.AI_TTS_str = "嗨,{}来了,有什么吩咐".format(self.VC_TTS_voice_key)
+ # return 0
+ # except Exception as e:
+ # usys.print_exception(e)
+ # return -1
+ if text.find("声音") != -1 and text.find("改") != -1:
+ try:
+ for key in self.VC_TTS_voice_type:
+ if text.find(key) != -1 :
+ self.VC_TTS_voice_key = key
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+ self.AI_TTS_str = "更改成功"
+ return 0
+ except Exception as e:
+ usys.print_exception(e)
+ if text.find("男") != -1 :
+ if "男" in self.VC_TTS_voice_type:
+ self.VC_TTS_voice_key = "男"
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+ # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
+ #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功
+ self.AI_TTS_str = "更改成功"
+ return 0
+ if text.find("女") != -1 :
+ if "女" in self.VC_TTS_voice_type:
+ self.VC_TTS_voice_key = "女"
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+ # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
+ #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功
+ self.AI_TTS_str = "更改成功"
+ return 0
+ if text.find("同声") != -1 or text.find("童") != -1 :
+ if "童" in self.VC_TTS_voice_type:
+ self.VC_TTS_voice_key = "童"
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+ # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
+ #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功
+ self.AI_TTS_str = "更改成功"
+ return 0
+ if text.find("粤") != -1 or text.find("越野") != -1 or text.find("广东话") != -1:
+ if "粤" in self.VC_TTS_voice_type:
+ self.VC_TTS_voice_key = "粤"
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+ # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
+ #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功
+ self.AI_TTS_str = "更改成功"
+ return 0
+ if text.find("四川") != -1 :
+ if "四川" in self.VC_TTS_voice_type:
+ self.VC_TTS_voice_key = "四川"
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+ # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
+ #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功
+ self.AI_TTS_str = "更改成功"
+ return 0
+ if text.find("个性") != -1 :
+ if "个性" in self.VC_TTS_voice_type:
+ self.VC_TTS_voice_key = "个性"
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+ # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
+ #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功
+ self.AI_TTS_str = "更改成功"
+ return 0
+ if text.find("英语") != -1 :
+ if "英语" in self.VC_TTS_voice_type:
+ self.VC_TTS_voice_key = "英语"
+ EventMesh.publish("set_storage_config",["VC_TTS_voice_key",self.VC_TTS_voice_key])
+ # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
+ #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功
+ self.AI_TTS_str = "更改成功"
+ return 0
+ self.AI_TTS_str = "更改失败,没找到对应声音"
+ return 0
+ if text.find("切换对话模式") != -1:
+ if dev_type == "7PIN_BK_EU":
+ if self.VC_mode == 0:
+ self.VC_mode = 1
+ self.AI_TTS_str = "change dialogue mode"
+ else:
+ self.VC_mode = 0
+ self.AI_TTS_str = "pushtalk mode"
+ else:
+ if self.VC_mode == 0:
+ self.VC_mode = 1
+ self.AI_TTS_str = "已切换到单对话模式"
+ else:
+ self.VC_mode = 0
+ self.AI_TTS_str = "已切换到长对话模式"
+ EventMesh.publish("set_storage_config",["VC_mode",self.VC_mode])
+ # EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
+ #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功
+
+ return 0
+ if text.find("音量") != -1:
+ if text.find("加") != -1 :
+ self.VC_TTS_volume += 10
+ if self.VC_TTS_volume > 100:
+ #EventMesh.publish("audio_montage_play",["yinliangyizuida.mp3"])
+ #self.aud.play(1,0,'U:/static/yinliangyizuida.mp3')#音量已最大
+ self.AI_TTS_str = "音量已最大"
+ self.VC_TTS_volume = 100
+ else:
+ self.aud.setVolume(self.VC_TTS_volume //10)
+ EventMesh.publish("set_storage_config",["VC_TTS_volume",self.VC_TTS_volume])
+ #EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
+ #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#配置成功
+ self.AI_TTS_str = "配置成功,当前音量 {}".format(self.VC_TTS_volume)
+
+ return 0
+ if text.find("减") != -1:
+ self.VC_TTS_volume -= 10
+ if self.VC_TTS_volume < 0:
+ self.VC_TTS_volume = 0
+ #EventMesh.publish("audio_montage_play",["yinliangyizuixiao.mp3"])
+ #self.aud.play(1,0,'U:/static/yinliangyizuixiao.mp3')#音量已最小
+ self.AI_TTS_str = "音量已最小"
+ else:
+ self.aud.setVolume(self.VC_TTS_volume //10)
+ EventMesh.publish("set_storage_config",["VC_TTS_volume",self.VC_TTS_volume])
+ #EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
+ #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#配置成功
+ self.AI_TTS_str = "配置成功,当前音量 {}".format(self.VC_TTS_volume)
+ return 0
+
+ if text.find("进入工厂模式") != -1 :
+ self.factory_mode()
+ return 1
+ if text.find("查询") != -1:
+
+ if text.find("信号") != -1 :
+ signal = net.csqQueryPoll()
+
+ self.AI_TTS_str = "当前信号{}".format(signal)
+ return 0
+ if text.find("电量") != -1 :
+ battery = EventMesh.publish("get_battery")
+ print("电量查询:{}".format(battery))
+ #EventMesh.publish("audio_montage_play",["dianliangshengyu{}.mp3".format(battery)])
+ #self.aud.play(1,0,'U:/static/dianliangshengyu{}.mp3'.format(battery))#电量剩余
+ self.AI_TTS_str = "电量剩余百分之{}".format(battery)
+ return 0
+ if text.find("电压") != -1 :
+ Vbatt = Power.getVbatt()
+ #EventMesh.publish("audio_montage_play",["dianliangshengyu{}.mp3".format(battery)])
+ #self.aud.play(1,0,'U:/static/dianliangshengyu{}.mp3'.format(battery))#电量剩余
+ self.AI_TTS_str = "当前电池电压{}".format(Vbatt)
+ return 0
+
+ if text.find("卡号") != -1 :
+ iccid = sim.getIccid()
+ if iccid != -1 and len(iccid) > 5:
+ print("iccid{}".format(iccid))
+ self.AI_TTS_str = "当前卡号为:{}".format(iccid)
+ else:
+ self.AI_TTS_str = "卡号查询失败"
+ return 0
+ if text.find("设备号") != -1 :
+ imei = modem.getDevImei()
+ if imei != -1 and len(imei) > 5:
+ print("IMEI:{}".format(imei))
+ self.AI_TTS_str = "当前设备号为:{}".format(imei)
+ else:
+ self.AI_TTS_str = "设备号查询失败"
+ return 0
+ if text.find("版本") != -1 :
+ sourceVersion = versions.Build_Time
+ self.AI_TTS_str ="Mr-Seven-"+sourceVersion
+ return 0
+ if text.find("服务器地址") != -1 :
+ self.AI_TTS_str ="服务器地址"+self.server_ip
+ return 0
+
+ if text.find("讲话") != -1 or text.find("说话") != -1:
+ if text.find("快") != -1 and text.find("太") == -1 :
+ self.speech_rate += 10
+ if self.speech_rate > 50:
+
+ self.AI_TTS_str = "语速已经是最快了"
+ self.speech_rate = 50
+ else:
+
+ EventMesh.publish("set_storage_config",["speech_rate",self.speech_rate])
+
+ self.AI_TTS_str = "明白,语速已经调快了,当前语速是{}".format(self.speech_rate)
+
+ return 0
+ if text.find("慢") != -1 and text.find("太") == -1 :
+ self.speech_rate -= 10
+ if self.speech_rate < -50:
+ self.speech_rate = -50
+ #EventMesh.publish("audio_montage_play",["yinliangyizuixiao.mp3"])
+ #self.aud.play(1,0,'U:/static/yinliangyizuixiao.mp3')#音量已最小
+ self.AI_TTS_str = "语速已经是最慢了"
+ else:
+ EventMesh.publish("set_storage_config",["speech_rate",self.speech_rate])
+
+ self.AI_TTS_str = "明白,语速已经调慢了,当前语速是{}".format(self.speech_rate)
+ return 0
+ if len(text)<22 and(text.find("聆听") != -1 or text.find("明天")!= -1) :
+ #print("text len :{}".format(len(text)))
+ if text.find("快") != -1 and text.find("太") == -1 :
+ self.vad_silence -= 200
+ if self.vad_silence < 100:
+
+ self.AI_TTS_str = "已经是最快了"
+ self.vad_silence = 100
+ else:
+ self.AI_TTS_str = "配置成功,当前语音断句速度是{}毫秒".format(self.vad_silence)
+ EventMesh.publish("set_storage_config",["vad_silence",self.vad_silence])
+ return 0
+ if text.find("慢") != -1 and text.find("太") == -1 :
+ self.vad_silence += 200
+ if self.vad_silence > 2000:
+ self.vad_silence = 2000
+ #EventMesh.publish("audio_montage_play",["yinliangyizuixiao.mp3"])
+ #self.aud.play(1,0,'U:/static/yinliangyizuixiao.mp3')#音量已最小
+ self.AI_TTS_str = "已经是最慢了"
+ else:
+ self.AI_TTS_str = "配置成功,当前语音断句速度是{}毫秒".format(self.vad_silence)
+ EventMesh.publish("set_storage_config",["vad_silence",self.vad_silence])
+ return 0
+ if text.find("升级") != -1 and (text.find("OTA") != -1 or text.find("ota") != -1):
+ if self.ai_OTA.min_sys_ota()==1:
+ self.AI_TTS_str = "有新版本,准备开始升级,升级过程会多次重启设备,请保证流量充足及电量充足"
+ else:
+ self.AI_TTS_str = "当前已是最新版本"
+ return 0
+
+ if len(text)<16 and (text.find("再见") != -1 or text.find("拜拜") != -1 or text.find("关闭对话") != -1):
+ #EventMesh.publish("publish_AI_btnInfo",{"func":self.Close})
+ if dev_type != "7PIN" and dev_type != "7PIN_coze":#柒牌
+ self.AI_TTS_str = "好嘞,再见,我们下次再聊"
+ self.Close_flag = 1
+ return 0
+ else:
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.Close})
+ return 1
+ if len(text)<12 and (text.find("关机") != -1 ):
+ if dev_type == "7PIN" or dev_type == "7PIN_coze":#柒牌
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.Close})
+ return 1
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.Close})
+ EventMesh.publish("Power_off")
+ return 1
+ except Exception as e:
+ usys.print_exception(e)
+ return -1
+ #获取trace_id
+ def get_trace_id(self):
+ t = utime.mktime(utime.localtime())
+ t = t*1000+urandom.randint(0, 1000)
+ md5_data = "{}".format(t)#md5签名
+ sign_data = ""
+ hash_obj = uhashlib.md5(md5_data)
+ res = hash_obj.digest()
+
+ # 转成十六进制表示
+ sign_data = ubinascii.hexlify(res)
+ sign_data = sign_data.decode('ascii')
+ return sign_data
+
+ def get_session_id(self,data = "session_id"):
+ t = utime.mktime(utime.localtime())
+ t = t*1000+urandom.randint(0, 1000)
+ md5_data = "{}{}".format(data,t)#md5签名
+ sign_data = ""
+ hash_obj = uhashlib.md5(md5_data)
+ res = hash_obj.digest()
+
+ # 转成十六进制表示
+ sign_data = ubinascii.hexlify(res)
+ sign_data = sign_data.decode('ascii')
+ return sign_data
+
+ def get_new_message_id(self):
+ message_id = self.get_trace_id()+"aaa"+self.get_trace_id()
+ self.VC_message_id=message_id[:32]
+ return self.VC_message_id
+ def get_new_task_id(self):
+ task_id = self.get_trace_id()+"aaa"+self.get_trace_id()
+ self.VC_task_id=task_id[:32]
+ return self.VC_task_id
+ #开始播放声音
+ def VC_Play_Start(self):
+ self.tts_in_data_len = 0
+ self.tts_out_data_len = 0
+ if self.VC_Play_flag == 0:
+ try:
+ if self.VC_play_TYPE == VC_play_TYPE_PCM:
+ if self.play_pcm == None:
+ self.play_pcm = audio.Audio.PCM(0,1,self.VC_play_samplerate,1,1,2)
+ #self.play_pcm.setVolume(11)
+ ret = self.play_pcm.stream_write_start()
+ print("self.record_pcm.stream_write_start:ret:{}".format(ret))
+ elif self.VC_play_TYPE == VC_play_TYPE_MP3:
+ pass
+ self.VC_Play_flag = 1
+ except Exception as e:
+ self.VC_Play_End()
+ usys.print_exception(e)
+ #暂停/继续声音播放 Pause_flag = 1暂停
+ def VC_Play_Pause(self,Pause_flag):
+ try:
+ if self.VC_play_TYPE == VC_play_TYPE_PCM:
+ if self.play_pcm != None:
+ self.play_pcm.stream_pause(Pause_flag)
+ except Exception as e:
+ self.VC_Play_End()
+ usys.print_exception(e)
+ #停止播放声音
+ def VC_Play_End(self):
+ self.VC_Play_flag = 0
+ if self.VC_play_TYPE == VC_play_TYPE_PCM:
+ if self.VC_play_samplerate == 8000:
+ self.aud.stopPlayStream()
+ self.aud.stopAll()
+ elif self.VC_play_samplerate == 16000:
+ if self.play_pcm != None:
+ print("Close:play_pcm.close()!!!!!!!!!!!!!!!!!!")
+ try:
+ self.play_pcm.stream_stop()
+ self.play_pcm.close()
+ except Exception as e:
+ usys.print_exception(e)
+ self.play_pcm=None
+ self.aud.stopPlayStream()
+ self.aud.stopAll()
+ elif self.VC_play_TYPE == VC_play_TYPE_MP3:
+ self.aud.stopPlayStream()
+ self.aud.stopAll()
+ if self.AI_audio_queue.empty()!=True:
+ self.AI_audio_queue.clear()
+
+
+ def _1S_timer_cb(self,*argc):
+ EventMesh.publish("publish_AI_btnInfo",{"func":self._1S_timer_cb_})
+
+ def _1S_timer_cb_(self):
+
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ self.close_timerout += 1
+ if self.close_timerout > 60 and self.VC_mode != 1 :#:#20秒没数据就close 长按单次问答模式不关
+
+ if self.VC_state >= VC_State_SpeechIng:
+ print("接口无响应,超时退出")
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.websocket_error,"data":"接口超时了。请重试"})
+ self.ud_error(["VC",self.VC_taskid])
+ else:
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.Close})
+
+ # print("get_audio_state !!!!!{} {} {}\r\n".format(self.play_end,EventMesh.publish("get_audio_state"),self.play_flag))
+ if self.LocalRespondingEnded_timerout>0 :#
+ self.LocalRespondingEnded_timerout -= 1
+ print("LocalRespondingEnded_timerout:{}".format(self.LocalRespondingEnded_timerout))
+ if self.LocalRespondingEnded_timerout <= 0 or self.play_pcm == None or(self.play_pcm != None and self.play_pcm.stream_is_empty() == 1) :#超时或者音频播放完,
+ self.LocalRespondingEnded_timerout = 0
+ if self.VC_mode == 1 :#长按单次问答模式
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.Close})
+ else:
+ EventMesh.publish("open_led_blue")
+ if self.Close_flag == 1:
+ self.Close_flag = 0
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.Close})
+ else:
+ #utime.sleep_ms(1000)
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Play_End})
+ #EventMesh.publish("publish_AI_btnInfo",{"func":self.chenggong_tone})
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Speech_Start_now})#开始录音
+ self.VC_state = VC_State_None
+ #通知服务器播放结束
+ #self.AI_client_VC_LocalRespondingEnded()
+
+ self.VC_pingping_timerout+=1
+ if self.VC_pingping_timerout>3:
+ self.VC_pingping_timerout=0
+ self.AI_client_VC_ping()
+ # self.asr_pingping_timerout += 1
+ # if self.asr_pingping_timerout>3:
+ # self.asr_pingping_timerout=0
+ # self.AI_client_asr_ping()
+ if self.VC_Thinking_timerout > 0 and self.VC_Thinking_timerout < 100:#VC Thinking超时后重新开始
+ print("VC_Thinking_timerout:{}!!!!!!!!!!!!!!!!!!!!!".format(self.VC_Thinking_timerout))
+ self.VC_Thinking_timerout -=1
+ if self.VC_Thinking_timerout == 0:
+ self.VC_Thinking_timerout = 100
+ print("Thinking重试,重试!!!!!!!!!!!!!!!!!!!!!")
+ self.VC_state = VC_State_None
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_VC_start})
+ pass
+
+ #VC开始
+ def AI_VC_start(self):
+ print("AI_VC_start1")
+ self.VC_satrt_flag = 1
+ if self.VC_Thinking_timerout < 100:
+ self.VC_Thinking_timerout = 0
+ EventMesh.publish("open_led_all")
+ self.VC_Play_End()#关闭音频播放
+ print("AI_VC_start2")
+ #self.aud.aud_tone_play(16,200)#播放按键音
+ self.LocalRespondingEnded_timerout = 0
+ self.close_timerout = 0
+
+
+ #
+ if self.AI_client_VC_isconnect == 0:#没连接的时候请求开始
+ self.websocket_connect_VC()#连接服务器
+
+ #utime.sleep_ms(50)
+ else:
+ print("self.VC_state :{}".format(self.VC_state ))
+
+ if self.AI_client_VC_isconnect == 0:
+ return
+ self.AI_client_VC_start_requset()
+ print("AI_VC_start3")
+
+ self.VC_state = VC_State_None
+ if self.AI_TTS_str == "":#没有tts要播放的时候才开始录音
+ #开始asr录音
+ self.VC_Speech_Start()#开启线程获取录音数据
+
+
+ # pass
+ print("AI_VC_start4")
+ #self.VC_Play_Start()
+ #EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Play_Start})
+ #开始线程
+
+ # if self.AI_VC_send_data_queue_thread_id == 0:
+ # _thread.stack_size(self.Audio_buf_size+8*1024)
+ # self.AI_VC_send_data_queue_thread_id = _thread.start_new_thread(self.AI_VC_send_data_queue_thread, ())
+ # _thread.stack_size(8*1024)
+ # print("AI_VC_start :AI_VC_send_data_queue_thread_id :{} ".format(self.AI_VC_send_data_queue_thread_id))
+
+ if self.AI_audio_queue_thread_id ==0:
+ _thread.stack_size(24*1024)
+ self.AI_audio_queue_thread_id = _thread.start_new_thread(self.AI_audio_queue_thread, ())
+ _thread.stack_size(8*1024)
+ print("AI_VC_start :AI_audio_queue_thread_id :{} ".format(self.AI_audio_queue_thread_id))
+ else:
+ print("AI_VC_start :AI_audio_queue_thread_id != 0 ")
+ self._1S_timer.start(1000,1,self._1S_timer_cb)
+ # self.VC_pingping_timerout = 0
+ # self.asr_pingping_timerout = 0
+ print("AI_VC_start5")
+ #开始会话
+ def AI_client_VC_start_requset(self):
+ voice="zh_male_wennuanahu_moon_bigtts"
+ try:
+ voice = self.VC_TTS_voice_type[self.VC_TTS_voice_key]["voice"]
+ except Exception as e:
+ usys.print_exception(e)
+ #voice="zh_female_dongmanxiaoyang_moon_bigtts"
+
+ json_data = \
+ {
+ "header": {
+ "event": "Start",
+ "trace_id": self.get_trace_id(),
+ },
+ "payload": {
+ "simple_response": True,#不返回llm过程文本
+ "device_id": modem.getDevImei(),
+
+ "user_agent": "AudioClient/1.0",
+ "dialog_attributes": {
+ #"provider": "doubao",
+ "provider": "coze",
+
+ "cfg": {
+ "disable_empty_prompt" : True,#拦截空字符请求大模型
+ "custom_variables": {
+ "name": self.bot_name,
+ },
+ "greeting":{
+ "enabled":False,
+ "content":""
+ },
+ "openai_option":{
+ },
+
+ "bot_option": {
+ "use_workflow": True,
+ #"input_format": "text",
+ "bot_id":"7462617881076351002",#语言助手
+ "workflow_id":"7462621757327196187",
+
+ }
+ }
+ },
+ "outbound_attributes": {
+ "provider": "volcengine",
+ "cfg": {
+ "format": "pcm",
+ "sample_rate": self.VC_play_samplerate,
+ "bit_rate": 16,
+ "channel": 1,
+ "volume": self.VC_TTS_volume,
+ #"voice": "7426720361732980745",
+ "voice": voice,#音色
+ "speech_rate": self.speech_rate,#语速
+ "chunk_interval_ms": 30, # 配置每段音频入队间隔时间 100ms
+ }
+ },
+ "inbound_attributes": {
+ "provider": "xun-fei",#
+ #"provider": "volcengine",
+ "disable_vad":True,
+ "vad_silence":self.vad_silence,
+ "interrupt_options":{
+ "concatenate_results":True,
+ "thinking_time_only": True,
+ },
+ "cfg": {
+ "format": "pcm",
+ "sample_rate": self.VC_record_samplerate,
+ "bit_rate": 16,
+ "channel": 1,
+ "enable_punctuation": True,
+ "enable_itn":True,
+ "keywords":[]
+ }
+ },
+ "commands":self.commands,
+ }
+ }
+ # "bot_id":"7481164663863459850",#鸭子
+ # "workflow_id":"7480485093845991443",
+ # "bot_id":"7462617881076351002",#语言助手
+ # "workflow_id":"7462621757327196187",
+ # "bot_id":"7469964258592931852",#深圳百事通
+ # "workflow_id":"7469968083063603241",
+ # "bot_id":"7411071327182438412",#柒牌
+ # "workflow_id":"7469049680291610636",
+ if dev_type == "7PIN_BK"or dev_type == "7PIN_BK_coze"or dev_type == "G10":#小瑞
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]="7462617881076351002"#语言助手
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]="7462621757327196187"
+ # json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]="7486697248416989193"#极简
+ # json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]="7486698347416649778"
+ #json_data["payload"]["dialog_attributes"]["provider"]="doubao"#豆包
+ json_data["payload"]["inbound_attributes"]["provider"]="volcengine"#火山
+ #json_data["payload"]["inbound_attributes"]["vad_silence"] = 200
+ #if self.VC_TTS_voice_type[self.VC_TTS_voice_key]["bot_id"] !="":
+ if "bot_id" in self.VC_TTS_voice_type[self.VC_TTS_voice_key]:
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]=self.VC_TTS_voice_type[self.VC_TTS_voice_key]["bot_id"]
+ if "workflow_id" in self.VC_TTS_voice_type[self.VC_TTS_voice_key]:
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]= self.VC_TTS_voice_type[self.VC_TTS_voice_key]["workflow_id"]
+ else:
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]=""
+ if json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"] == "":
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["use_workflow"]=False
+
+
+ keywords = []#热词
+ for key in self.VC_TTS_voice_type:
+ keywords.append(key)
+ json_data["payload"]["inbound_attributes"]["cfg"]["keywords"] = keywords
+ elif dev_type == "7PIN_BK_EU":
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]="7493368740600446995"#英文
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]="7493369551587213323"
+ json_data["payload"]["inbound_attributes"]["provider"]="volcengine"#火山
+ elif dev_type == "csh":
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]="7490852493640384538"#慈善会
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["use_workflow"]=False
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]=""
+ json_data["payload"]["inbound_attributes"]["provider"]="volcengine"#火山
+ elif dev_type == "7PIN" :#柒牌
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]=""#
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]=""
+ #json_data["payload"]["inbound_attributes"]["vad_silence"] = 1000
+ elif dev_type == "7PIN_coze":
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]=""#
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]=""
+ #
+ elif dev_type == 'momo':#食梦貘
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]="7491256313561825332"
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]=""
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["use_workflow"]=False
+ json_data["payload"]["inbound_attributes"]["provider"]="volcengine"#火山
+ if "bot_id" in self.VC_TTS_voice_type[self.VC_TTS_voice_key]:
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]=self.VC_TTS_voice_type[self.VC_TTS_voice_key]["bot_id"]
+ if "workflow_id" in self.VC_TTS_voice_type[self.VC_TTS_voice_key]:
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]= self.VC_TTS_voice_type[self.VC_TTS_voice_key]["workflow_id"]
+ else:
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]=""
+ if json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"] == "":
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["use_workflow"]=False
+
+
+ keywords = []#热词
+ for key in self.VC_TTS_voice_type:
+ keywords.append(key)
+ json_data["payload"]["inbound_attributes"]["cfg"]["keywords"] = keywords
+ elif dev_type == 'sjgq':#四季甘泉
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]="7472201279826690111"
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]="472203898494500914"
+ pass
+ elif dev_type == 'szbst':#深圳百事通
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]="7469964258592931852"
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]="7469968083063603241"
+ elif dev_type == 'jswm' or dev_type == 'jswm_BOX':#金三完美
+ #json_data["payload"]["device_id"]= "WangQunTestID"
+ if self.VC_TTS_voice_type[self.VC_TTS_voice_key]["bot_id"] !="":
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["bot_id"]=self.VC_TTS_voice_type[self.VC_TTS_voice_key]["bot_id"]
+ if self.VC_TTS_voice_type[self.VC_TTS_voice_key]["workflow_id"] == "":
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["use_workflow"]=False
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]= ""
+ else:
+ json_data["payload"]["dialog_attributes"]["cfg"]["bot_option"]["workflow_id"]= self.VC_TTS_voice_type[self.VC_TTS_voice_key]["workflow_id"]
+ json_data["payload"]["inbound_attributes"]["provider"]="volcengine"#火山
+ if self.VC_TTS_voice_type[self.VC_TTS_voice_key]["openai_option"] :
+ json_data["payload"]["dialog_attributes"]["cfg"]["openai_option"] =self.VC_TTS_voice_type[self.VC_TTS_voice_key]["openai_option"]
+ keywords = []#热词
+ for key in self.VC_TTS_voice_type:
+ keywords.append(key)
+ json_data["payload"]["inbound_attributes"]["cfg"]["keywords"] = keywords
+
+ if self.commands_mode !=0 :
+ json_data["payload"]["commands"] = []
+ if self.VC_mode == 0 :#and dev_type != "7PIN_BK_coze":#长对话模式打开vad
+ json_data["payload"]["inbound_attributes"]["disable_vad"] = False
+ self.VC_state = VC_State_None
+ self.AI_client_VC_send(ujson.dumps(json_data))
+
+ #开始上传语音
+ def AI_client_VC_send_speech(self):
+ json_data = \
+ {
+ "header": {
+ "event": "audio.create",
+
+ },
+ }
+
+ if self.VC_mode == 1:#单对话模式
+ self.AI_client_VC_send(ujson.dumps(json_data))
+
+
+
+
+
+
+ self.VC_state = VC_State_SpeechStart
+ #结束上传语音
+ def AI_client_VC_end_speech(self):
+ json_data = \
+ {
+ "header": {
+ "event": "audio.completed",
+
+ },
+ }
+ self.AI_client_VC_send(ujson.dumps(json_data))
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_Speech_End})
+
+
+ #客户端打断对话
+ def AI_client_VC_RequestToSpeak(self):
+ json_data = \
+ {
+ "event": "cancel",
+ "payload": {}
+ }
+ print("AI_client_VC_RequestToSpeak!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
+ # EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_init})
+ # EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_client_VC_send,"data":ujson.dumps(json_data)})
+ # utime.sleep_ms(1)
+ self.websocket_deconnect_VC()
+ self.AI_audio_queue_thread_close()
+ self.VC_state = VC_State_None
+ #self.Close()
+ self.AI_VC_start()
+ #TTS播放
+ def AI_client_VC_synthesis(self):
+ json_data = \
+ {
+ "event": "synthesis",
+ "payload": {
+ "text": self.AI_TTS_str
+ }
+ }
+ self.AI_TTS_str = ""
+ print("AI_client_VC_synthesis!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
+ # if self.VC_state == VC_State_RequestToRespond:
+ # print("AI_client_VC_RequestToRespond 重复 tts_str:{}\nasr_str:{}".format(self.AI_TTS_str,self.AI_ASR_str))
+ self.AI_client_VC_send(ujson.dumps(json_data))
+
+ def chenggong_tone(self):
+ EventMesh.publish("audio_montage_play",["chenggong.mp3"])
+ def send_tone(self):
+ EventMesh.publish("audio_montage_play",["send_tone.mp3"])
+ def concurrency_limit_exceeded_tone(self):
+ self.Close()
+ EventMesh.publish("audio_montage_play",["chaobingfatis.mp3"]) #播放超并发提醒
+ #给服务器回应ack
+
+
+ ############################################
+ #关闭音频播放线程
+ def AI_audio_queue_thread_close(self):
+ print("AI_audio_queue_thread_close1!!!!!!!!!!!!!!!!!!!!!!")
+ if self.AI_audio_queue_thread_id != 0:
+ count =500
+ while True:
+ count -= 1
+ if self.AI_audio_queue_thread_lock == 0 or count <=0:
+ break
+ else:
+ self.AI_audio_queue_thread_lock = 2
+ print("AI_audio_queue_thread going:{}...".format(count))
+ utime.sleep_ms(1)
+ self.AI_audio_queue_thread_lock = 0
+ print("AI_audio_queue_thread_close2!!!!!!!!!!!!!!!!!")
+ try:
+ _thread.stop_thread(self.AI_audio_queue_thread_id)
+ except Exception as e:
+ usys.print_exception(e)
+ self.AI_audio_queue_thread_id = 0
+ # 音频队列
+ def AI_audio_queue_thread(self):
+ print("AI_audio_queue_thread start")
+ count = 0
+ if self.AI_audio_queue.empty()!=True:
+ self.AI_audio_queue.clear()
+ print("音频数据还有剩余!!!!!!!!!!!!")
+ while True:
+ try:
+ if self.AI_audio_queue_thread_lock == 2:
+ print("AI_audio_queue_thread 该退出了")
+ break
+ #
+ count+=1
+ if count%500 == 1:
+ print("AI_audio_queue_thread on")
+ utime.sleep_ms(1)
+ #print("AI_audio_queue_thread")
+ if self.AI_audio_queue.empty() :
+ self.AI_audio_queue_thread_lock = 0
+
+
+ else:
+ self.AI_audio_queue_thread_lock = 1
+ data = self.AI_audio_queue.get()
+ self.close_timerout = 0
+ if self.play_flag == 0:
+ self.play_flag =1
+ #self.AI_client_tts_data_len=len(data)
+ #print("audio_queue:len:{}".format(len(data[0])))
+
+ if len(data[0]) > 10:
+ for i in range(5):
+ if self.VC_Play_flag == 0:
+ self.VC_Play_Start()
+ utime.sleep_ms(2)
+ else:
+ break
+ try:
+ if self.VC_play_TYPE == VC_play_TYPE_PCM:
+ # if self.VC_play_samplerate == 8000:
+ # tmp= self.aud.playStream(1,data[0] )
+ # else:
+ write_buf = bytearray(data[0])
+ #print("play_pcm.stream_write1 len:{}".format(len(write_buf)))
+ if self.play_pcm != None:
+ #print("play_pcm.stream_write !!!")
+ ret = self.play_pcm.stream_write(write_buf,len(write_buf))
+ #ret= self.aud.playStream(1, data[0])#播放音频流
+ self.tts_out_data_len += ret
+ #print("play_pcm.stream_write2:{}".format(self.tts_out_data_len))
+ elif self.VC_play_TYPE == VC_play_TYPE_MP3:
+ tmp= self.aud.playStream(3, data[0])#播放音频流
+
+ if tmp != 0:
+ print("2playStream:error tmp:{} data len:{}!!!!!!!!!!!!".format(tmp,len(data[0])))
+ # # #播放失败的时候填充WAV头
+ # data_len = len(data[0])
+ # data_len_b = data_len.to_bytes(4,'little')#数据长度转16进制数组
+ # h_data = [ 0x52 ,0x49 ,0x46 ,0x46 #,0x24 ,0x00 ,0x00 ,0x00 #文件标识、文件大小
+ # ,0x57 ,0x41 ,0x56 ,0x45 ,0x66 ,0x6D ,0x74 ,0x20 #文件格式、格式块标识符
+ # ,0x10 ,0x00 ,0x00 ,0x00 ,0x01 ,0x00 ,0x01 ,0x00 ,0x80 ,0x3E ,0x00 ,0x00 #格式块大小4、音频格式2、声道数2、采样率4
+ # ,0x80 ,0x3E ,0x00 ,0x00 ,0x02 ,0x00 ,0x10 ,0x00 ,0x64 ,0x61 ,0x74 ,0x61]#每秒字节数4、数据块对齐2、位深度2、data4
+ # h_data_b = bytes(h_data)
+ # file_len = data_len+len(h_data_b)+4+4
+ # file_len_b = file_len.to_bytes(4,'little')#文件长度转16进制数组
+ # h_data_b = h_data_b[:4]+file_len_b+h_data_b[4:]+data_len_b
+ # #self.aud.playStream(2, h_data_b)#播放音频流
+ # tmp= self.aud.playStream(2, h_data_b+data[0])#播放音频流
+ # print("3playStream:tmp:{} !!!!!!!!!!!!".format(tmp))
+
+
+ mem = gc.mem_free()
+ #print('1剩余内存RAM:{} KB'.format(mem / 1024))
+ except Exception as e:
+ print("AI_audio_queue_thread:ERROR:")
+ usys.print_exception(e)
+
+ # if self.VC_state == VC_State_TTSEnd and self.AI_audio_queue.empty() :#self.AI_audio_queue为空且tts下发结束
+ # #通知服务器播放结束
+ # self.AI_client_VC_LocalRespondingEnded()
+ except Exception as e:
+ print("AI_audio_queue_thread:ERROR:")
+ usys.print_exception(e)
+ self.AI_audio_queue_thread_lock = 0
+ #print("AI_audio_queue_thread:exit")
+ def factory_mode(self):
+ print("factory_mode")
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.Close})
+ EventMesh.publish("publish_AI_btnInfo",{"func":self.factory_start})
+ def factory_start(self):
+ self.factory_timer.start(3000, 1, self.factory_timer_cb)
+ def factory_timer_cb(self, *args, **kwargs):
+ print("factory_timer_cb play......")
+ #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#切换成功
+ EventMesh.publish("audio_montage_play",["xinhaoruo1.mp3"])
+
+ def Close(self):
+ self.VC_Thinking_timerout = 0
+ self.VC_satrt_flag = 0
+ self.AI_TTS_str = ""
+ self.AI_ASR_str = ""
+ self.AI_ASR_str_tmp = ""
+ self.AI_ASR_flag = 0
+ self.AI_ASR_check_timeout = 0
+ self.AI_ASR_error_timeout = 0
+ print("ai_VC Close1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
+ EventMesh.publish("close_led")
+ self.tts_in_data_len = 0
+ self.tts_out_data_len = 0
+ #必须先销毁线程,不然线程会容易报错
+
+ try:
+ self.AI_audio_queue_thread_close()#销毁音频线程
+ except Exception as e:
+ usys.print_exception(e)
+ try:
+ self.AI_VC_send_data_queue_thread_close()#销毁数据发送线程
+ except Exception as e:
+ usys.print_exception(e)
+
+ self.VC_Speech_End()
+
+ print("ai_VC Close1.1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
+ self.VC_init()
+ print("ai_VC Close1.2!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
+
+ try:
+ self.websocket_deconnect_VC()
+ except Exception as e:
+ usys.print_exception(e)
+
+
+
+
+
+ print("ai_VC Close1.3!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
+
+ print("ai_VC Close2!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
+
+
+ self.AI_ASR_timer.stop()
+ self._1S_timer.stop()
+ self.factory_timer.stop()
+
+ if self.record_data_save_flag == 1:
+ if self.record_fd :
+ self.record_fd.close()
+ self.record_fd = None
+ if self.play_data_save_flag == 1:
+ if self.play_fd !=None:
+ self.play_fd.close()
+ self.play_fd = None
+ print("ai_VC Close3!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n")
+
+ if self.AI_VC_send_data_queue.empty()!=True:
+ self.AI_VC_send_data_queue.clear()
+
+ self.AI_ASR_send_buf_len = 0
+ #self.AI_WS_connect_Queue.put(self.AI_client_VC)
+ EventMesh.publish("close_led")
+ # try:
+ # while True:
+ # if self.AI_WS_connect_Queue.empty()!=True:
+ # AI_WS_connect = self.AI_WS_connect_Queue.get()
+ # if AI_WS_connect :
+ # try:
+ # AI_WS_connect._close()
+ # AI_WS_connect = None
+ # except Exception as e:
+ # usys.print_exception(e)
+ # else:
+ # print("websocket链接已为空")
+ # else:
+ # break
+ # except Exception as e:
+ # usys.print_exception(e)
+
+ def VC_init2(self):
+ self.VC_init()
+
+ print("ai_VC VC_init2!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
+ try:
+ self.websocket_deconnect_VC()
+ except Exception as e:
+ usys.print_exception(e)
+ print("ai_VC Close3!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n")
+ self._1S_timer.stop()
+ if self.AI_VC_send_data_queue.empty()!=True:
+ self.AI_VC_send_data_queue.clear()
+
+ self.AI_ASR_send_buf_len = 0
+ if self.AI_audio_queue.empty()!=True:
+ self.AI_audio_queue.clear()
+ def VC_init(self):
+
+ print("VC_init:AI_VC_send_data_queue:size:{}".format(self.AI_VC_send_data_queue.size()))
+
+
+ print("VC_init2")
+ #self.VC_Speech_End()
+ print("VC_init3")
+ self.VC_Play_End()
+ print("VC_init4")
+
+ if self.AI_audio_queue.empty()!=True:
+ self.AI_audio_queue.clear()
+ # num = EventMesh.publish("get_volum_size")
+ # if num == None:
+ # num = 8
+ # self.aud.setVolume(num)#恢复原始音量
+
+
+{
+ "version": "202505151440",
+ "VC_TTS_voice_type": {
+ "班度": {
+ "bot_name": "班度",
+ "voice": "huoshan::zh_male_yuanboxiaoshu_moon_bigtts",
+ "lang": "zh-cn",
+ "bot_id":"7490824341572075555",#AI语音APP女神经理
+ "workflow_id":"",
+ },
+
+ },
+ "power_on_tone": "阿弥陀佛,施主既来,便是有缘。心中若有烦忧,直说无妨。"
+
+}
\ No newline at end of file
--- /dev/null
+import modem
+import osTimer
+import utime
+import lvgl as lv
+import EventMesh
+from machine import Timer
+from ui import Screen
+from common import Abstract, LogAdapter
+from machine import RTC
+import ujson
+import ql_fs
+from misc import Power
+import audio
+from ui import style_img,style_screen,style_font_youyuan_20
+import ntptime
+
+#ntptime.settime(timezone=8)
+"""
+可以添加/编辑闹钟时间、周期;
+最多添加三个闹钟;
+可以删除已有的闹钟;
+可以启用/禁用已有的闹钟;
+保存已添加/编辑的闹钟信息,并在下次运行时恢复。
+"""
+#标题高度
+TITLE_HEIGHT = 30
+#闹钟元素高度
+ALARM_HEIGHT = 75
+ALARM_WIDTH = 224
+#闹钟最大数量
+MAX_ALARM = 3
+#CONT的样式
+style_cont_alarm = lv.style_t()
+style_cont_alarm.init()
+style_cont_alarm.set_bg_color(lv.color_make(0x22, 0x28, 0x3D))
+style_cont_alarm.set_radius(0)
+style_cont_alarm.set_pad_left(0)
+style_cont_alarm.set_pad_right(0)
+style_cont_alarm.set_pad_top(0)
+style_cont_alarm.set_pad_bottom(0)
+
+#字体样式
+# style_font_white = lv.style_t()
+# style_font_white.init()
+# style_font_white.set_text_color(lv.color_make(0xff, 0xff, 0xff))
+# style_font_white.set_text_font_v2("font_28.bin",28,0)
+# style_font_white.set_border_width(0)
+# style_font_white.set_pad_left(0)
+# style_font_white.set_pad_right(0)
+# style_font_white.set_pad_top(0)
+# style_font_white.set_pad_bottom(0)
+
+style_font_yellow = lv.style_t()
+style_font_yellow.init()
+style_font_yellow.set_text_color(lv.color_make(0xF1, 0xA3, 0x3B))
+style_font_yellow.set_text_font_v2("font_28.bin",28,0)
+
+#背景样式
+style_alarm_screen_default = lv.style_t()
+style_alarm_screen_default.init()
+style_alarm_screen_default.set_bg_color(lv.color_make(0x00, 0x00, 0x00))
+style_alarm_screen_default.set_border_width(0)
+style_alarm_screen_default.set_pad_left(0)
+style_alarm_screen_default.set_pad_right(0)
+style_alarm_screen_default.set_pad_top(0)
+style_alarm_screen_default.set_pad_bottom(0)
+
+# -------------------------------------------clk_list screen----------------------------------------------------------
+clk_list_screen = lv.obj()
+print("clk_list_screen")
+clk_list_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+clk_list_title_bg= lv.btn(clk_list_screen)
+clk_list_title_bg.set_size(220,40)
+clk_list_title_bg.set_pos(10,10)
+clk_list_title_bg.add_style(style_cont_alarm, lv.PART.MAIN | lv.STATE.DEFAULT)
+clk_list_title_bg.set_ext_click_area(40)
+
+clk_list_title = lv.label(clk_list_title_bg)
+clk_list_title.set_pos(0, 15)
+clk_list_title.set_size(240, 40)
+clk_list_title.set_text("闹钟列表")
+clk_list_title.set_long_mode(lv.label.LONG.WRAP)
+clk_list_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+clk_list_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+# clk_list_add_btn = lv.btn(clk_list_screen)
+# clk_list_add_btn.set_pos(180,45)
+# clk_list_add_btn.set_size(50,20)
+# clk_list_add_btn.add_style(style_alarm_screen_default, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+# clk_list_add = lv.label(clk_list_screen)
+# clk_list_add.set_pos(180, 45)
+# clk_list_add.set_size(50, 20)
+# clk_list_add.set_text("添加")
+# clk_list_add.set_long_mode(lv.label.LONG.WRAP)
+# clk_list_add.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+# clk_list_add.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+# clk_list_add.set_ext_click_area(15)
+
+clk_list_screen1_1 = lv.obj(clk_list_screen)
+clk_list_screen1_1.set_pos(0, 65)
+clk_list_screen1_1.set_size(240, 255)
+clk_list_screen1_1.add_style(style_alarm_screen_default, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+
+no_add_alarm_img = lv.img(clk_list_screen1_1)
+no_add_alarm_img.set_pos(65, 0)
+no_add_alarm_img.set_size(110, 140)
+no_add_alarm_img.set_src("E:/static/IMAGE_IDLE_SCREEN_ALARM_ICON_NEW.png")
+no_add_alarm_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+#暂未添加闹钟
+no_add_alarm = lv.label(clk_list_screen1_1)
+no_add_alarm.set_pos(0, 170)
+no_add_alarm.set_size(240, 50)
+no_add_alarm.set_text("闹钟暂未设置")
+no_add_alarm.set_long_mode(lv.label.LONG.WRAP)
+no_add_alarm.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+no_add_alarm.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+# -------------------------------------------clk_edit screen----------------------------------------------------------
+
+clk_edit_screen = lv.obj()
+print("clk_edit_screen")
+clk_edit_screen.add_style(style_alarm_screen_default, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+clk_edit_title = lv.label(clk_edit_screen)
+clk_edit_title.set_pos(0, 0)
+clk_edit_title.set_size(240, TITLE_HEIGHT)
+clk_edit_title.set_text("编辑闹钟")
+clk_edit_title.set_long_mode(lv.label.LONG.WRAP)
+clk_edit_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+clk_edit_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+clk_edit_time = lv.btn(clk_edit_screen)
+clk_edit_time.set_size(224,75)
+clk_edit_time.set_pos(8,58)
+clk_edit_time.add_style(style_cont_alarm, lv.PART.MAIN | lv.STATE.DEFAULT)
+clk_edit_time_label = lv.label(clk_edit_time)
+clk_edit_time_label.set_pos(60, 15)
+clk_edit_time_label.set_size(100, 40)
+clk_edit_time_label.set_text("编辑时间")
+clk_edit_time_label.set_long_mode(lv.label.LONG.WRAP)
+clk_edit_time_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+clk_edit_time_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+clk_edit_weekday = lv.btn(clk_edit_screen)
+clk_edit_weekday.set_size(224,75)
+clk_edit_weekday.set_pos(8,137)
+clk_edit_weekday.add_style(style_cont_alarm, lv.PART.MAIN | lv.STATE.DEFAULT)
+clk_edit_weekday_label = lv.label(clk_edit_weekday)
+clk_edit_weekday_label.set_pos(60, 15)
+clk_edit_weekday_label.set_size(100, 40)
+clk_edit_weekday_label.set_text("编辑星期")
+clk_edit_weekday_label.set_long_mode(lv.label.LONG.WRAP)
+clk_edit_weekday_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+clk_edit_weekday_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+clk_delete_alarm = lv.btn(clk_edit_screen)
+clk_delete_alarm.set_size(224,75)
+clk_delete_alarm.set_pos(8,216)
+clk_delete_alarm.add_style(style_cont_alarm, lv.PART.MAIN | lv.STATE.DEFAULT)
+clk_delete_alarm_label = lv.label(clk_delete_alarm)
+clk_delete_alarm_label.set_pos(60, 15)
+clk_delete_alarm_label.set_size(100, 40)
+clk_delete_alarm_label.set_text("删除闹钟")
+clk_delete_alarm_label.set_long_mode(lv.label.LONG.WRAP)
+clk_delete_alarm_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+clk_delete_alarm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+# -------------------------------------------clk_repeat screen----------------------------------------------------------
+clk_repeat_screen = lv.obj()
+print("clk_repeat_screen")
+clk_repeat_screen.set_scrollbar_mode(0)
+clk_repeat_screen.add_style(style_alarm_screen_default, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+clk_repeat_btn = lv.btn(clk_repeat_screen)
+clk_repeat_btn.set_size(224,40)
+clk_repeat_btn.set_pos(9,40)
+clk_repeat_btn.add_style(style_cont_alarm, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+clk_repeat_label = lv.label(clk_repeat_btn)
+clk_repeat_label.set_pos(8, 10)
+clk_repeat_label.set_size(103, 40)
+clk_repeat_label.set_text("星期一")
+clk_repeat_label.set_long_mode(lv.label.LONG.DOT)
+clk_repeat_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+clk_repeat_label.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+
+clk_repeat_switch = lv.switch(clk_repeat_btn)
+clk_repeat_switch.set_pos(191, 5)
+clk_repeat_switch.set_size(24, 24)
+clk_repeat_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.MAIN)
+clk_repeat_switch.set_style_bg_color(lv.color_make(0xFF, 0xFF, 0xFF),lv.PART.INDICATOR)
+clk_repeat_switch.set_style_bg_color(lv.color_make(0xFF, 0xFF, 0xFF),lv.PART.KNOB)
+clk_repeat_switch.set_style_bg_color(lv.color_make(0xf1, 0xa3, 0x3b),lv.PART.KNOB| lv.STATE.CHECKED)
+clk_repeat_switch.set_ext_click_area(20)
+clk_repeat_switch.set_style_bg_color(lv.color_make(0xFF, 0xFF, 0xFF),lv.PART.INDICATOR| lv.STATE.CHECKED)
+
+clk_repeat_btn1 = lv.btn(clk_repeat_screen)
+clk_repeat_btn1.set_size(224,40)
+clk_repeat_btn1.set_pos(9,90)
+clk_repeat_btn1.add_style(style_cont_alarm, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+clk_repeat_label1 = lv.label(clk_repeat_btn1)
+clk_repeat_label1.set_pos(8, 10)
+clk_repeat_label1.set_size(103, 40)
+clk_repeat_label1.set_text("星期二")
+clk_repeat_label1.set_long_mode(lv.label.LONG.DOT)
+clk_repeat_label1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+clk_repeat_label1.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+
+clk_repeat_switch1 = lv.switch(clk_repeat_btn1)
+clk_repeat_switch1.set_pos(191, 5)
+clk_repeat_switch1.set_size(24, 24)
+clk_repeat_switch1.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.MAIN)
+clk_repeat_switch1.set_style_bg_color(lv.color_make(0xFF, 0xFF, 0xFF),lv.PART.INDICATOR)
+clk_repeat_switch1.set_style_bg_color(lv.color_make(0xFF, 0xFF, 0xFF),lv.PART.KNOB)
+clk_repeat_switch1.set_style_bg_color(lv.color_make(0xf1, 0xa3, 0x3b),lv.PART.KNOB| lv.STATE.CHECKED)
+clk_repeat_switch1.set_ext_click_area(20)
+clk_repeat_switch1.set_style_bg_color(lv.color_make(0xFF, 0xFF, 0xFF),lv.PART.INDICATOR| lv.STATE.CHECKED)
+
+
+clk_repeat_btn2 = lv.btn(clk_repeat_screen)
+clk_repeat_btn2.set_size(224,40)
+clk_repeat_btn2.set_pos(9,140)
+clk_repeat_btn2.add_style(style_cont_alarm, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+clk_repeat_label2 = lv.label(clk_repeat_btn2)
+clk_repeat_label2.set_pos(8, 10)
+clk_repeat_label2.set_size(103, 40)
+clk_repeat_label2.set_text("星期三")
+clk_repeat_label2.set_long_mode(lv.label.LONG.DOT)
+clk_repeat_label2.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+clk_repeat_label2.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+
+
+clk_repeat_switch2 = lv.switch(clk_repeat_btn2)
+clk_repeat_switch2.set_pos(191, 5)
+clk_repeat_switch2.set_size(24, 24)
+clk_repeat_switch2.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.MAIN)
+clk_repeat_switch2.set_style_bg_color(lv.color_make(0xFF, 0xFF, 0xFF),lv.PART.INDICATOR)
+clk_repeat_switch2.set_style_bg_color(lv.color_make(0xFF, 0xFF, 0xFF),lv.PART.KNOB)
+clk_repeat_switch2.set_style_bg_color(lv.color_make(0xf1, 0xa3, 0x3b),lv.PART.KNOB| lv.STATE.CHECKED)
+clk_repeat_switch2.set_ext_click_area(20)
+clk_repeat_switch2.set_style_bg_color(lv.color_make(0xFF, 0xFF, 0xFF),lv.PART.INDICATOR| lv.STATE.CHECKED)
+
+clk_repeat_btn3 = lv.btn(clk_repeat_screen)
+clk_repeat_btn3.set_size(224,40)
+clk_repeat_btn3.set_pos(9,190)
+clk_repeat_btn3.add_style(style_cont_alarm, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+clk_repeat_label3 = lv.label(clk_repeat_btn3)
+clk_repeat_label3.set_pos(8, 10)
+clk_repeat_label3.set_size(103, 40)
+clk_repeat_label3.set_text("星期四")
+clk_repeat_label3.set_long_mode(lv.label.LONG.DOT)
+clk_repeat_label3.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+clk_repeat_label3.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+
+clk_repeat_switch3 = lv.switch(clk_repeat_btn3)
+clk_repeat_switch3.set_pos(191, 5)
+clk_repeat_switch3.set_size(24, 24)
+clk_repeat_switch3.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.MAIN)
+clk_repeat_switch3.set_style_bg_color(lv.color_make(0xFF, 0xFF, 0xFF),lv.PART.INDICATOR)
+clk_repeat_switch3.set_style_bg_color(lv.color_make(0xFF, 0xFF, 0xFF),lv.PART.KNOB)
+clk_repeat_switch3.set_style_bg_color(lv.color_make(0xf1, 0xa3, 0x3b),lv.PART.KNOB| lv.STATE.CHECKED)
+clk_repeat_switch3.set_ext_click_area(20)
+clk_repeat_switch3.set_style_bg_color(lv.color_make(0xFF, 0xFF, 0xFF),lv.PART.INDICATOR| lv.STATE.CHECKED)
+
+clk_repeat_btn4 = lv.btn(clk_repeat_screen)
+clk_repeat_btn4.set_size(224,40)
+clk_repeat_btn4.set_pos(9,240)
+clk_repeat_btn4.add_style(style_cont_alarm, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+clk_repeat_label4 = lv.label(clk_repeat_btn4)
+clk_repeat_label4.set_pos(8, 10)
+clk_repeat_label4.set_size(103, 40)
+clk_repeat_label4.set_text("星期五")
+clk_repeat_label4.set_long_mode(lv.label.LONG.DOT)
+clk_repeat_label4.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+clk_repeat_label4.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+
+clk_repeat_switch4 = lv.switch(clk_repeat_btn4)
+clk_repeat_switch4.set_pos(191, 5)
+clk_repeat_switch4.set_size(24, 24)
+clk_repeat_switch4.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.MAIN)
+clk_repeat_switch4.set_style_bg_color(lv.color_make(0xFF, 0xFF, 0xFF),lv.PART.INDICATOR)
+clk_repeat_switch4.set_style_bg_color(lv.color_make(0xFF, 0xFF, 0xFF),lv.PART.KNOB)
+clk_repeat_switch4.set_style_bg_color(lv.color_make(0xf1, 0xa3, 0x3b),lv.PART.KNOB| lv.STATE.CHECKED)
+clk_repeat_switch4.set_ext_click_area(20)
+clk_repeat_switch4.set_style_bg_color(lv.color_make(0xFF, 0xFF, 0xFF),lv.PART.INDICATOR| lv.STATE.CHECKED)
+
+clk_repeat_btn5 = lv.btn(clk_repeat_screen)
+clk_repeat_btn5.set_size(224,40)
+clk_repeat_btn5.set_pos(9,290)
+clk_repeat_btn5.add_style(style_cont_alarm, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+clk_repeat_label5 = lv.label(clk_repeat_btn5)
+clk_repeat_label5.set_pos(8, 10)
+clk_repeat_label5.set_size(103, 40)
+clk_repeat_label5.set_text("星期六")
+clk_repeat_label5.set_long_mode(lv.label.LONG.DOT)
+clk_repeat_label5.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+clk_repeat_label5.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+
+clk_repeat_switch5 = lv.switch(clk_repeat_btn5)
+clk_repeat_switch5.set_pos(191, 5)
+clk_repeat_switch5.set_size(24, 24)
+clk_repeat_switch5.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.MAIN)
+clk_repeat_switch5.set_style_bg_color(lv.color_make(0xFF, 0xFF, 0xFF),lv.PART.INDICATOR)
+clk_repeat_switch5.set_style_bg_color(lv.color_make(0xFF, 0xFF, 0xFF),lv.PART.INDICATOR| lv.STATE.CHECKED)
+clk_repeat_switch5.set_style_bg_color(lv.color_make(0xFF, 0xFF, 0xFF),lv.PART.KNOB)
+clk_repeat_switch5.set_style_bg_color(lv.color_make(0xf1, 0xa3, 0x3b),lv.PART.KNOB| lv.STATE.CHECKED)
+clk_repeat_switch5.set_ext_click_area(20)
+
+clk_repeat_btn6 = lv.btn(clk_repeat_screen)
+clk_repeat_btn6.set_size(224,40)
+clk_repeat_btn6.set_pos(9,340)
+clk_repeat_btn6.add_style(style_cont_alarm, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+clk_repeat_label6 = lv.label(clk_repeat_btn6)
+clk_repeat_label6.set_pos(8, 10)
+clk_repeat_label6.set_size(103, 40)
+clk_repeat_label6.set_text("星期日")
+clk_repeat_label6.set_long_mode(lv.label.LONG.DOT)
+clk_repeat_label6.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+clk_repeat_label6.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+
+clk_repeat_switch6 = lv.switch(clk_repeat_btn6)
+clk_repeat_switch6.set_pos(191, 5)
+clk_repeat_switch6.set_size(24, 24)
+clk_repeat_switch6.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.MAIN)
+clk_repeat_switch6.set_style_bg_color(lv.color_make(0xFF, 0xFF, 0xFF),lv.PART.INDICATOR)
+clk_repeat_switch6.set_style_bg_color(lv.color_make(0xFF, 0xFF, 0xFF),lv.PART.KNOB)
+clk_repeat_switch6.set_style_bg_color(lv.color_make(0xf1, 0xa3, 0x3b),lv.PART.KNOB| lv.STATE.CHECKED)
+clk_repeat_switch6.set_ext_click_area(20)
+clk_repeat_switch6.set_style_bg_color(lv.color_make(0xFF, 0xFF, 0xFF),lv.PART.INDICATOR| lv.STATE.CHECKED)
+
+# -------------------------------------------clk_repeat screen----------------------------------------------------------
+clk_time_screen = lv.obj()
+print("clk_time_screen")
+clk_time_screen.set_scrollbar_mode(0)
+clk_time_screen.add_style(style_alarm_screen_default, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+#hour的样式
+style_roller_hour_main = lv.style_t()
+style_roller_hour_main.init()
+style_roller_hour_main.set_radius(6)
+style_roller_hour_main.set_bg_color(lv.color_make(0x00, 0x00, 0x00))
+style_roller_hour_main.set_bg_opa(102)
+style_roller_hour_main.set_border_width(0)
+
+style_roller_hour_selected = lv.style_t()
+style_roller_hour_selected.init()
+style_roller_hour_selected.set_radius(6)
+style_roller_hour_selected.set_bg_color(lv.color_make(0x2c, 0x2c, 0x2f))
+style_roller_hour_selected.set_border_width(0)
+
+#创建hour的roller
+clk_time_roller_1 = lv.roller(clk_time_screen)
+clk_time_roller_1.set_width(50)
+clk_time_roller_1.set_pos(60, 50)
+clk_time_roller_1.set_options(
+ "00\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23",
+ lv.roller.MODE.NORMAL)
+clk_time_roller_1.set_visible_row_count(5)
+clk_time_roller_1.add_style(style_roller_hour_main, lv.PART.MAIN | lv.STATE.DEFAULT)
+clk_time_roller_1.add_style(style_roller_hour_selected, lv.PART.SELECTED | lv.STATE.DEFAULT)
+
+#min的样式
+#创建min的roller
+clk_time_roller_2 = lv.roller(clk_time_screen)
+clk_time_roller_2.set_width(50)
+clk_time_roller_2.set_pos(130, 50)
+clk_time_roller_2.set_options(
+ "00\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59",
+ lv.roller.MODE.NORMAL)
+clk_time_roller_2.set_visible_row_count(5)
+clk_time_roller_2.add_style(style_roller_hour_main, lv.PART.MAIN | lv.STATE.DEFAULT)
+clk_time_roller_2.add_style(style_roller_hour_selected, lv.PART.SELECTED | lv.STATE.DEFAULT)
+
+#完成按钮
+alarm_ok= lv.btn(clk_time_screen)
+alarm_ok.set_size(150,40)
+alarm_ok.set_pos(45,250)
+alarm_ok.add_style(style_cont_alarm, lv.PART.MAIN | lv.STATE.DEFAULT)
+alarm_ok.set_ext_click_area(20)
+
+label_ok = lv.label(alarm_ok)
+label_ok.set_pos(30, 20)
+label_ok.set_size(100, 40)
+label_ok.set_text("完成")
+label_ok.set_long_mode(lv.label.LONG.DOT)
+label_ok.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+label_ok.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+
+#闹钟信息
+alarm_list = [{'hour': 16, 'repeart': 10, 'idx': 0, 'enabled': 0, 'days': [], 'minute': 39},
+ {'hour': 16, 'repeart': 10, 'idx': 1, 'enabled': 0, 'days': [], 'minute': 39}]
+#用于显示闹钟列表不包含开关机信息
+
+class ClockManager(Abstract):
+ def __init__(self):
+ super().__init__()
+ self.rtc = RTC()
+ self.days = 0
+ self.idx = 0
+ self.rtc.enable_alarm(1)
+ IFEXIST = ql_fs.path_exists("/ext/static/storage_file/alarm_msg.json")
+ self.check_alarm_list = []
+ if IFEXIST == True:
+ with open("/ext/static/storage_file/alarm_msg.json","r",encoding='utf-8') as fd:
+ self.check_alarm_list = ujson.load(fd)
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("push_clock_info", self.set)
+ EventMesh.subscribe("read_alarminjson", self.read_alarminjson)
+ EventMesh.subscribe("add_alarm", self.add_alarm)
+ EventMesh.subscribe("remove_alarm", self.remove_alarm)
+ EventMesh.subscribe("set_rtc_alarm", self.set_rtc_alarm)
+ EventMesh.subscribe("get_alarm_indx", self.get_alarm_indx)
+ EventMesh.subscribe("get_check_alarm_list", self.get_check_alarm_list)
+
+
+
+ def get_check_alarm_list(self, event, msg):
+ alarm_len = 0
+ global alarm_list
+ EventMesh.publish("read_alarminjson")
+ alarm_len = len(alarm_list)
+ return alarm_len
+
+
+ def set(self, event, msg):
+ global alarm_list
+ print("msg = {}".format(msg))
+ idx = msg.get("idx")
+ print("修改第{}个闹钟信息{}".format(idx,alarm_list[idx]))
+ alarm_list[idx]["hour"] = msg["hour"]
+ alarm_list[idx]["minute"] = msg["minute"]
+ alarm_list[idx]["days"] = msg["days"]
+ alarm_list[idx]["enabled"] = msg["enabled"]
+ alarm_list[idx]["repeart"] = msg["repeart"]
+ with open("/ext/static/storage_file/alarm_msg.json", 'w+',encoding='utf-8') as fd:
+ ujson.dump(alarm_list,fd)
+
+ def read_alarminjson(self, event, msg):
+ IFEXIST = ql_fs.path_exists("/ext/static/storage_file/alarm_msg.json")
+ global alarm_list
+ print("IFEXIST:{}".format(IFEXIST))
+ if IFEXIST == True:
+ with open("/ext/static/storage_file/alarm_msg.json","r",encoding='utf-8') as fd:
+ alarm_list = ujson.load(fd)
+ return alarm_list
+
+ def add_alarm(self, event, msg):
+
+ global alarm_list
+ EventMesh.publish("read_alarminjson")
+ idx = len(alarm_list)
+
+ # msg = ['1','06:90','23:59']
+ count = 1
+ new = 0
+ num = 0
+ print("msg:{}".format(msg))
+ # if msg[0] == 1:
+ # msg_new = msg[1]
+ for i in range(0,2):#开关机固定是 idx 0 1
+ off_msg1 = msg[i+1]
+ msg_tmp1 = off_msg1.split(':')
+ start_hour = int(msg_tmp1[0])
+ start_min = int(msg_tmp1[1])
+ enable = int(msg[0])
+ EventMesh.publish("set_boot_off_time",[msg[0],msg[1],msg[2]])
+ if alarm_list and new == 0 :
+ for x in range(0,5):
+ # print("count :{} self.alarm_list:111111{} len(self.alarm_list):{}".format(count,alarm_list,len(alarm_list)))
+ if new == 1 and count > len(alarm_list):
+ break
+ tmp = alarm_list[count-1]['idx']
+ if tmp == 0 or tmp == 1:#覆盖旧的
+ alarm_list[count-1] = {"idx": tmp, "hour": start_hour, "minute": start_min, "days":[0,1,2,3,4,5,6], "enabled": enable,"repeart":10}
+ count+=1
+ if count > len(alarm_list):
+ new = 1
+ # print("self.alarm_list:5555 {}".format(alarm_list))
+ break
+ else:#添加最新的
+ count+=1
+ if tmp == 2 or tmp == 3 or tmp == 4:#添加最新的
+ msg_tmp = EventMesh.publish("get_boot_off_time")
+ # print("msg_tmp all_data {}".format(msg_tmp))
+ if msg_tmp != None:
+ if len(msg_tmp[0]) > 0:#只有关机时间长度为0时才添加新元素 不是就覆盖原来旧的数据
+ # print("self.alarm_list:444444 {}".format(alarm_list))
+ if count > len(alarm_list):
+ new = 1
+ continue
+ else:
+ alarm_list.append({"idx": num, "hour": start_hour, "minute": start_min, "days":[0,1,2,3,4,5,6], "enabled": enable,"repeart":10})
+ # print("self.alarm_list:7777777 {}".format(alarm_list))
+ if count > len(alarm_list):
+ new = 1
+ break
+ count+=1
+ # print("self.alarm_list:111111 {}".format(alarm_list))
+
+ else:#添加最新的
+ alarm_list.append({"idx": num, "hour": start_hour, "minute": start_min, "days":[0,1,2,3,4,5,6], "enabled": enable,"repeart":10})
+ new = 1
+ num+=1
+ # print("add_here-----idx:{} msg:{} alarm_list:{}".format(idx,msg,alarm_list))
+
+ # else:
+ # msg_tmp = msg[1]
+ # # print("alarm_list:{} alarm_new_old:{} msg_tmp:{}",alarm_new,alarm_new_old,msg_tmp)
+ # num = 2
+ # count = 1
+ # j=0
+ # new = 0
+ # for j in range(0,3):
+ # alarm_day = []
+ # alarm_week = []
+ # alarm_total_data = []
+ # alarm_total_data = msg_tmp.split(',')[j]
+
+ # b = alarm_total_data.find('-')
+ # if b != -1:
+ # alarm_data = alarm_total_data.split('-')#-作为分隔符
+ # alarm_switch = int(alarm_data[1])#开关
+ # alarm_day_num = int(alarm_data[2])#天
+ # alarm_time = alarm_data[0]#时间
+ # alarm_time_tmp = alarm_time.split(':')#冒号分隔时间 时 分
+ # alarm_time_hour = int(alarm_time_tmp[0])
+ # alarm_time_min = int(alarm_time_tmp[1])
+ # if alarm_day_num == 3:
+ # alarm_week = alarm_data[3]#星期
+
+ # if alarm_day_num == 2:#每一天
+ # alarm_day = [1,2,3,4,5,6,0]
+ # elif alarm_day_num == 3:#自定义
+ # for i in range(0,7):
+ # if alarm_week[i] != '0':
+ # alarm_day.append(i)
+ # if alarm_list and new == 0 :
+ # for x in range(0,5):
+
+ # print("count :{} self.alarm_new:111111{} len(self.alarm_new):{} ".format(count,alarm_list,len(alarm_list)))
+
+ # tmp = alarm_list[count-1]['idx']
+ # if tmp == 2 or tmp == 3 or tmp == 4 :#覆盖旧的
+ # alarm_list[count-1] = {"idx": tmp, "hour": alarm_time_hour, "minute": alarm_time_min, "days":alarm_day, "enabled": alarm_switch,"repeart":1}
+ # count+=1
+ # if count > len(alarm_list):
+ # new = 1
+ # print("self.alarm_list:5555 {}".format(alarm_list))
+ # break
+ # else:#添加最新的
+ # count+=1
+ # if tmp == 0 or tmp == 1:#添加最新的
+ # msg_data = EventMesh.publish("get_boot_off_time")
+ # print("msg_data all_data {}".format(msg_data))
+ # if msg_data != None:
+ # if msg_data[1] > 0:#只有关机时间长度为0时才添加新元素 不是就覆盖原来旧的数据
+ # print("self.alarm_list:444444 {}".format(alarm_list))
+ # if count > len(alarm_list):
+ # new = 1
+ # continue
+ # else:
+ # alarm_list.append({"idx": num, "hour": alarm_time_hour, "minute": alarm_time_min, "days":alarm_day, "enabled": alarm_switch,"repeart":alarm_day_num})
+ # print("self.alarm_list:7777777 {}".format(alarm_list))
+ # if count > len(alarm_list):
+ # new = 1
+ # break
+ # count+=1
+ # print("self.alarm_list:111111 {}".format(alarm_list))
+ # else:#添加最新的
+ # alarm_list.append({"idx": num, "hour": alarm_time_hour, "minute": alarm_time_min, "days":alarm_day, "enabled": alarm_switch,"repeart":alarm_day_num})
+ # new = 1
+ # num+=1
+
+ print("alarm_list----len- :{}".format(len(alarm_list)))
+ with open("/ext/static/storage_file/alarm_msg.json", 'w+',encoding='utf-8') as fd:
+ ujson.dump(alarm_list,fd)
+ EventMesh.publish("push_update_alarm_show")
+
+
+
+
+
+
+ def remove_alarm(self, event, msg):
+ global alarm_list
+ print("ddddddddddddddddddd:",msg)
+ idx = msg.get("idx")
+ print("delete_here1-----{},{}:".format(idx,msg))
+
+ for i, alarm in enumerate(alarm_list):
+ print("delete_here2-----{},{}:".format(i,alarm))
+
+ if alarm["idx"] == idx:
+ del alarm_list[i]
+ print("delete_here3-----",alarm_list)
+
+ #删除闹钟后,对idx重新排序
+ if alarm_list:
+ for j in range(i,len(alarm_list)):
+ alarm_list[j]["idx"] -= 1
+ print("delete_here4-----",alarm_list)
+
+ with open("/ext/static/storage_file/alarm_msg.json", 'w+',encoding='utf-8') as fd:
+ ujson.dump(alarm_list,fd)
+
+
+ def get_alarm_indx(self,event,msg):
+ return self.idx
+
+ def _rtc_callback(self,args):
+ print("---!!!!!!alarm_ring!!!!!!!---,idx:",args)
+ global alarm_list
+ EventMesh.publish("read_alarminjson")
+ idx = self.idx
+ print("单次闹钟关闭:{} alarm_list:{}".format(idx,alarm_list))
+ #判断是否是单次闹钟,如果是,则将开关状态设置为关闭
+ # for i in range(len(alarm_list)):
+ # if alarm_list[i]["idx"] == self.idx:
+ # idx = i
+ if not alarm_list[idx]["days"] :
+ print("关闭1:",alarm_list[idx]["days"])
+ print("关闭2:",alarm_list [idx]["days"])
+ alarm_list[idx]["enabled"] = False
+ with open("/ext/static/storage_file/alarm_msg.json", 'w+',encoding='utf-8') as fd:
+ ujson.dump(alarm_list,fd)
+ EventMesh.publish("set_rtc_alarm")
+ #设置下一个闹钟,定时开关机功能
+ if 0 :
+ msg_data = EventMesh.publish("get_boot_off_time")
+ print("msg_tmp:{}".format(msg_data))
+
+ msg_tmp = msg_data[0]
+ off_tmp2 = msg_tmp[2]
+ msg_tmp2 = off_tmp2.split(':')
+ end_min = int(msg_tmp2[0])*60+int(msg_tmp2[1])
+
+ rtc_now_time = self.rtc.datetime()
+ current = rtc_now_time[4]*60+rtc_now_time[5]
+
+ print("end_min:{} current:{} off_tmp2:{}".format(end_min,current,off_tmp2))
+ if end_min == current:#结束的时间分钟等于关机时间分钟数则关机
+ EventMesh.publish("load_screen", {"screen": "poweroff_comfirm"})
+ return
+
+
+
+ get_hr_state = EventMesh.publish("get_hr_state")
+ get_spo2_state = EventMesh.publish("get_spo2_state")
+ if get_hr_state != None or get_spo2_state != None:
+ if get_hr_state != 1 and get_spo2_state != 1:
+ EventMesh.publish("load_screen", {"screen": "popup_alarm"})
+ # def _reset_rtc_alarm_time(self, args):
+ # print("---alarm_ring---")
+
+ def set_rtc_alarm(self,event,msg):
+ global alarm_list
+ EventMesh.publish("read_alarminjson")
+ rtc_now_time = self.rtc.datetime()
+
+ # print("00获取所有闹钟信息:{}".format(alarm_list))
+ new_alarm_list = [(alarm['hour'], alarm['minute'], alarm['days'],alarm["idx"]) for alarm in alarm_list if alarm['enabled']]
+
+ print("01获取开启的闹钟:{}".format(new_alarm_list))
+ start_day = 0 # 周日
+ start_minute = 0 # 0点
+ end_minute = 60*24*7
+ minute_list = []
+
+ if not new_alarm_list:
+ print("02当前并没有开启的闹钟,退出闹钟设置程序:{}".format(new_alarm_list))
+ self.rtc.enable_alarm(0)
+ return
+
+ for alarm in new_alarm_list:
+ hour, minute, days,idx = alarm
+ #如果没有选择day,则表示是单次闹钟
+ if days:
+ for day in days:
+ minute_list.append(hour*60 + minute + (day-start_day)*24*60)
+
+ else:
+ #如果当前时间没超过闹钟设置时间,则设置为今天,否则设置为明天
+ if (hour*60 + minute) > (rtc_now_time[4]*60 + rtc_now_time[5]):
+ minute_list.append(hour*60 + minute + (rtc_now_time[3]-start_day)*24*60)
+ print("设置单次闹钟:{}".format(new_alarm_list))
+
+ else:
+ minute_list.append(hour*60 + minute + (rtc_now_time[3]-start_day+1)*24*60)
+
+ total_minutes = sorted(minute_list)
+ print("02以周日00:00为起点,计算所有开启闹钟的total_min并排序:{}".format(total_minutes))
+
+ #获取当前时间 (2020, 9, 11, 5, 15, 43, 23, 0)
+ # rtc_now_time = (2020, 9, 11, 6, 11, 43, 23, 0)
+ # rtc_now_time = self.rtc.datetime()
+
+ print("03当前的rtc时间:{}".format(rtc_now_time))
+
+ current_minute = rtc_now_time[4]*60 + rtc_now_time[5] + (rtc_now_time[3]-start_day)*24*60
+ print("04当前的rtc_total_minutes:{}".format(current_minute))
+
+ if current_minute in minute_list:
+ print("当前时间和闹钟列表时间重复,删除重复的时间")
+ minute_list.remove(current_minute)
+
+ minute_list.append(current_minute)
+
+ # 对分钟数列表进行排序,并获取当前时间分钟数所在的位置
+ minute_list = sorted(minute_list)
+ current_index = minute_list.index(current_minute)
+
+ print("05将当前时间插入min_list后的min_list:{}".format(minute_list))
+ print("06当前时间所在位置:{}".format(current_index))
+
+ next_index = current_index + 1
+ if next_index >= len(minute_list):
+ next_minute = minute_list[0]
+ print("07下一个闹钟的分钟数:", next_minute)
+ else:
+ next_minute = minute_list[next_index]
+ print("07下一个闹钟的分钟数:", next_minute)
+
+ if next_minute >= current_minute:
+ interval_minute = next_minute - current_minute
+ print("08距离下一次响铃的的分钟数:", interval_minute)
+ else:
+ interval_minute = end_minute - current_minute + next_minute
+ print("08距离下一次响铃的的分钟数:", interval_minute)
+
+ #反向获取时间戳
+ time = utime.localtime()
+ print("09获取utime的时间戳:", time)
+ rtc_mktime = utime.mktime(time)
+ print("10反向获取utime的mktime:", rtc_mktime)
+
+ #加上下一次响铃需要的时间
+ next_alarm_mktime = rtc_mktime + interval_minute*60
+ print("11下一次响铃的mktime:", next_alarm_mktime)
+
+ #格式化时间戳,得到下一次闹钟的时间
+ next_alarm_time = utime.localtime(next_alarm_mktime)
+ print("12下一次响铃的准确时间:", next_alarm_time)
+ #将时间转换为rtc的格式
+ data_l = [2021, 7, 9, 5, 12, 30, 0, 0]
+ #给rtc时间赋值
+ data_l[0] = next_alarm_time[0] #year
+ data_l[1] = next_alarm_time[1] #month
+ data_l[2] = next_alarm_time[2] #day
+ data_l[4] = next_alarm_time[3] #hour
+ data_l[5] = next_alarm_time[4] #minute
+ #转换为元组
+ data_e=tuple(data_l)
+ print("13将该时间转换为RTC元组:", data_e)
+
+ for alarm in alarm_list:
+ if not alarm["days"] and alarm["enabled"]:
+ print("关闭666:",alarm["idx"])
+ if alarm["hour"] == data_l[4] and alarm["minute"]==data_l[5]:
+ self.idx = alarm["idx"]
+ #设置rtc闹钟时间
+ self.rtc.register_callback(self._rtc_callback)
+
+ FLAG = self.rtc.set_alarm(data_e)
+ if FLAG == 0:
+ print("14成功设置rtc的到期时间:", data_e)
+ else:
+ print("14设置rtc的到期时间失败:", data_e)
+
+ self.rtc.enable_alarm(1)
+
+#闹钟弹窗
+popup_alarm_screen = lv.obj()
+print("popup_alarm_screen")
+popup_alarm_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+popup_alarm_img = lv.img(popup_alarm_screen)
+popup_alarm_img.set_pos(63, 60)
+popup_alarm_img.set_size(110, 140)
+popup_alarm_img.set_src("E:/static/IMAGE_IDLE_SCREEN_ALARM_ICON_NEW.png")
+popup_alarm_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+popup_alarm_time = lv.label(popup_alarm_screen)
+popup_alarm_time.set_pos(0, 230)
+popup_alarm_time.set_size(240, 50)
+popup_alarm_time.set_text(" ")
+popup_alarm_time.set_long_mode(lv.label.LONG.WRAP)
+popup_alarm_time.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+popup_alarm_time.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+#闹钟列表
+class PopupAlarmScreen(Screen):
+ NAME = "popup_alarm"
+ def __init__(self):
+ super().__init__()
+ self.meta = popup_alarm_screen
+ self.timer = osTimer()
+ self.aud = audio.Audio(0)
+ self.alarm_count = 0
+ self.meta_type = "popup"
+
+ def initialization(self):
+ self.alarm_count = 0
+ self.timer.start(1000,1,self.exit_alarm_page)
+ time = EventMesh.publish("screen_get_time")#获取系统时间
+ popup_alarm_time.set_text("{}:{}".format("%02d"%(time[0][0]),"%02d"%(time[0][1])))
+
+
+ def Close(self):
+ self.alarm_count=0
+ self.timer.stop()
+ self.aud.stop()
+
+ def exit_alarm_page(self,*arges):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ self.alarm_count+=1
+ if self.alarm_count > 60:
+ self.alarm_count = 0
+ self.aud.stop()
+ self.timer.stop()
+ EventMesh.publish("return_prev_screen")
+ return
+ play_state = EventMesh.publish("get_audio_state")#音频播放状态
+ if play_state != None:
+ if play_state == 0:#在上一个界面在播放音频时切换界面则关闭 以免一直播放
+ self.aud.stop()
+ self.aud.play(1, 1, 'E:/static/audio_audio_haixiu.mp3') #播放声音
+
+ def close_timer(self):
+ self.alarm_count=0
+ self.timer.stop()
+ self.aud.stop()
+
+ def done_left_to_right(self):
+ self.close_timer()
+ EventMesh.publish("return_prev_screen")
+
+ def done_right_to_left(self):
+ self.close_timer()
+ EventMesh.publish("return_prev_screen")
+
+ def done_bottom_to_top(self):
+ self.close_timer()
+ EventMesh.publish("return_prev_screen")
+
+ def done_top_to_bottom(self):
+ self.close_timer()
+ EventMesh.publish("return_prev_screen")
+
+ def done_return(self):
+ self.close_timer()
+ EventMesh.publish("return_prev_screen")
+
+ def done_click(self):
+ self.close_timer()
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ self.close_timer()
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ self.close_timer()
+ EventMesh.publish("return_prev_screen")
+
+#闹钟列表
+class ClkListScreen(Screen):
+ NAME = "clk_list"
+ def __init__(self):
+ super().__init__()
+ self.meta = clk_list_screen
+ self.clock_list = []
+ self.MXA_clk_num = 3#有两个开关机隐藏的
+ self.contact_detail_listt_dict = []
+ # clk_list_add_btn.add_event_cb(lambda e: self.add_alarm_btn(e),
+ # lv.EVENT.PRESSED, None)
+ self.weekdays_list = ["日","一","二","三","四","五","六"]
+ EventMesh.subscribe("push_update_alarm_show", self.update_show_info)
+ self.alarm_show_list = lv.obj(clk_list_screen)
+ self.alarm_show_list.set_pos(0, 65)
+ self.alarm_show_list.set_size(240, 255)
+ self.alarm_show_list.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ self.alarm_show_list.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+ self.timer=osTimer()
+ for i in range(self.MXA_clk_num):
+
+ _btn = lv.btn(self.alarm_show_list)
+ _btn.add_flag(lv.obj.FLAG.CLICKABLE)
+ _btn.add_style(style_cont_alarm, lv.PART.MAIN | lv.STATE.DEFAULT)
+ _btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.edit_alarm(e)),
+ lv.EVENT.CLICKED, None)
+ _btn.add_flag(lv.obj.FLAG.HIDDEN)
+ _btn_label1 = lv.label(_btn)
+ _btn_label2 = lv.label(_btn)
+ _btn_label2.set_long_mode(lv.label.LONG.DOT)
+ _btn_label2.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ _btn_label3 = lv.label(_btn)
+ _btn_label3.set_long_mode(lv.label.LONG.DOT)
+ _btn_label3.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ self.contact_detail_listt_dict.append({"_btn":_btn,"_btn_label1":_btn_label1,"_btn_label2":_btn_label2,"_btn_label3":_btn_label3})
+
+ def initialization(self):
+ EventMesh.publish("read_alarminjson")
+ EventMesh.publish("set_rtc_alarm")
+ print("n闹钟列表初始化!!")
+ self.alarm_draw_btn()
+
+ def update_show_info(self,event,msg):
+ EventMesh.publish("read_alarminjson")
+ self.timer.start(1*1000,0,self.delay_update)
+ def delay_update(self,*agrs):
+ EventMesh.publish("set_rtc_alarm")
+ self.alarm_draw_btn()
+
+
+ def alarm_draw_btn(self):
+ get_alarm_data = EventMesh.publish("get_storage_config","normal_alarm")
+ print("get_alarm_data",get_alarm_data)
+ if get_alarm_data != None and get_alarm_data != []:
+
+ if len(get_alarm_data) != 0:
+ # print("nalarm_list:{}".format(alarm_list))
+ no_add_alarm_img.add_flag(lv.obj.FLAG.HIDDEN)
+ no_add_alarm.add_flag(lv.obj.FLAG.HIDDEN)
+ # self.alarm_show_list.delete()#先删除一次控件
+ # self.alarm_show_list = lv.obj(clk_list_screen)
+ # self.alarm_show_list.set_pos(0, 65)
+ # self.alarm_show_list.set_size(240, 255)
+ # self.alarm_show_list.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ # self.alarm_show_list.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+ #print("菜单的孩子个数:",clk_list_screen1.get_child_cnt())
+ num = 0
+ count = 0
+ clock_nums = len(get_alarm_data)#3-2 = 1 0
+ # for i ,each in enumerate(self.clock_list):
+ for i in range(0,self.MXA_clk_num):
+ if i >= clock_nums:
+ self.contact_detail_listt_dict[i]["_btn"].add_flag(lv.obj.FLAG.HIDDEN)
+ continue
+ hour = get_alarm_data[i]["hour"]
+ min = get_alarm_data[i]["min"]
+
+ day = get_alarm_data[i]["day"]
+
+ print("count1:{}".format(count))
+ #_btn = lv.btn(self.alarm_show_list)
+ self.contact_detail_listt_dict[count]["_btn"].set_size(230,75)
+ self.contact_detail_listt_dict[count]["_btn"].set_pos(8,79*count)
+ # self.contact_detail_listt_dict[i]["_btn"].add_style(style_cont_alarm, lv.PART.MAIN | lv.STATE.DEFAULT)
+ # self.contact_detail_listt_dict[i]["_btn"].add_event_cb(lambda e: EventMesh.callback_wrapper(self.edit_alarm(e)),
+ # lv.EVENT.CLICKED, None)
+
+
+ # print("------刷新闹钟列表噢:{} num:{}",each,num)
+ #_btn_label1 = lv.label(_btn)
+ self.contact_detail_listt_dict[count]["_btn_label1"].set_pos(50, 0)
+ self.contact_detail_listt_dict[count]["_btn_label1"].set_size(0, 0)
+ self.contact_detail_listt_dict[count]["_btn_label1"].set_text(" ")
+
+ #_btn_label2 = lv.label(_btn)
+ self.contact_detail_listt_dict[count]["_btn_label2"].set_pos(8, 10)
+ self.contact_detail_listt_dict[count]["_btn_label2"].set_size(97, 40)
+ self.contact_detail_listt_dict[count]["_btn_label2"].set_text("%02d" %(hour) + ":"+"%02d" %(min))
+ # _btn_label2.set_text(str(each["days"]))
+
+ # _btn_label2.set_long_mode(lv.label.LONG.DOT)
+ # _btn_label2.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ self.contact_detail_listt_dict[count]["_btn_label2"].set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+
+ _new_list = sorted(day)
+ _output = [self.weekdays_list[x] for x in _new_list]
+ #_btn_label3 = lv.label(_btn)
+ self.contact_detail_listt_dict[count]["_btn_label3"].set_pos(5, 44)
+ self.contact_detail_listt_dict[count]["_btn_label3"].set_size(200, 40)
+ print("_new_list:{} ".format(_new_list))
+ if day == []:
+ self.contact_detail_listt_dict[count]["_btn_label3"].set_text("一次")
+ elif len(day) > 6:
+ self.contact_detail_listt_dict[count]["_btn_label3"].set_text("每天")
+ else:
+ self.contact_detail_listt_dict[count]["_btn_label3"].set_text(",".join(_output))
+ # _btn_label3.set_long_mode(lv.label.LONG.DOT)
+ # _btn_label3.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ self.contact_detail_listt_dict[count]["_btn_label3"].set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+ self.contact_detail_listt_dict[count]["_btn"].clear_flag(lv.obj.FLAG.HIDDEN)
+ # _btn_switch = lv.switch(_btn)
+ # _btn_switch.set_pos(178, 29)
+ # _btn_switch.set_size(50, 25)
+ # _btn_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.INDICATOR)
+ # _btn_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.INDICATOR| lv.STATE.CHECKED)
+ # _btn_switch.add_event_cb(lambda e:
+ # self.switch_event_cb(e),
+ # lv.EVENT.VALUE_CHANGED,
+ # None)
+
+ # _btn_switch.set_style_bg_color(lv.color_make(0xf1, 0xa3, 0x3b),lv.PART.KNOB| lv.STATE.CHECKED)
+ # _btn_switch.set_style_bg_color(lv.color_make(0x3d, 0x3d, 0x3d),lv.PART.KNOB)
+
+ # _btn_switch.set_ext_click_area(40)
+ # if each["enabled"]:
+ # _btn_switch.add_state(lv.STATE.CHECKED)
+ # else:
+ # _btn_switch.clear_state(lv.STATE.CHECKED)
+ count+=1
+ if count == 0:
+ no_add_alarm_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ no_add_alarm.clear_flag(lv.obj.FLAG.HIDDEN)
+ self.alarm_show_list.add_flag(lv.obj.FLAG.HIDDEN)
+ else :
+ no_add_alarm_img.add_flag(lv.obj.FLAG.HIDDEN)
+ no_add_alarm.add_flag(lv.obj.FLAG.HIDDEN)
+ self.alarm_show_list.clear_flag(lv.obj.FLAG.HIDDEN)
+ else:
+ no_add_alarm_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ no_add_alarm.clear_flag(lv.obj.FLAG.HIDDEN)
+ self.alarm_show_list.add_flag(lv.obj.FLAG.HIDDEN)
+ else:
+ no_add_alarm_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ no_add_alarm.clear_flag(lv.obj.FLAG.HIDDEN)
+ self.alarm_show_list.add_flag(lv.obj.FLAG.HIDDEN)
+
+ def edit_alarm(self, e):#暂时屏蔽
+ return
+ idx = int(e.get_target().get_child(0).get_text())
+ print("edit!!!!!!!!!!!!:",idx)
+ clock_info = self.clock_list[idx]
+ clock_info["idx"] = idx
+
+ EventMesh.publish("load_screen", {"screen": "new_edit_clk","meta": clock_info})
+
+ def add_alarm_btn(self, e):
+
+ if len(self.clock_list) >= 3:
+ return
+ print("!!!!!!!!!!!!!!!!!------")
+ EventMesh.publish("add_alarm")
+ self.alarm_draw_btn()
+
+ # def switch_event_cb(self, e):
+ # obj = e.get_target()
+ # idx = int(e.get_target().get_parent().get_child(0).get_text())
+ # clock_info = self.clock_list[idx]
+ # print("修改闹钟开关:",self.clock_list[idx])
+ # clock_info["idx"] = idx
+ # if obj.has_state(lv.STATE.CHECKED):
+ # print("ON ~~~")
+ # clock_info["enabled"] = True
+ # else:
+ # print("OFF ~~~")
+ # clock_info["enabled"] = False
+ # EventMesh.publish("push_clock_info", clock_info)
+ # EventMesh.publish("set_rtc_alarm")
+
+ # print("sw_event_cb ~~~")
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
+
+
+
+
+class NewEditClk(Screen):
+ NAME = "new_edit_clk"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = clk_edit_screen
+ clk_edit_weekday.add_event_cb(lambda e: EventMesh.callback_wrapper(self.edit_weekday(e)), lv.EVENT.CLICKED, None)
+ clk_edit_time.add_event_cb(lambda e: EventMesh.callback_wrapper(self.edit_time(e)), lv.EVENT.CLICKED, None)
+ clk_delete_alarm.add_event_cb(lambda e: EventMesh.callback_wrapper(self.delete_alarm(e)), lv.EVENT.CLICKED, None)
+
+ def initialization(self):
+ print("hahahahh",self.meta_info["idx"])
+
+ def delete_alarm(self, e):
+ EventMesh.publish("remove_alarm",self.meta_info)
+
+ EventMesh.publish("load_screen", {"screen": "clk_list"})
+
+
+ def edit_weekday(self,e):
+ self.load_screen(e, {"screen": "clk_period",
+ "meta": self.meta_info})
+
+ def edit_time(self,e):
+ self.load_screen(e, {"screen": "clk_time",
+ "meta": self.meta_info})
+
+ def done_return(self):
+ EventMesh.publish("load_screen", {"screen": "clk_list"})
+
+ def btn1_release(self):
+ EventMesh.publish("load_screen", {"screen": "clk_list"})
+
+ def btn8_press(self):
+ EventMesh.publish("load_screen", {"screen": "clk_list"})
+
--- /dev/null
+import modem
+import sim
+import osTimer
+# import ALIPAY
+from common import Lock, Abstract, LogAdapter
+import utime
+import lvgl as lv
+import EventMesh
+from machine import Timer
+import constants
+from misc import Power
+import pm
+from ui import Screen
+from code import code_128_generate_barcode
+import code128
+style_font_youyuan_20 = lv.style_t()
+style_font_youyuan_20.init()
+style_font_youyuan_20.set_text_color(lv.color_make(0xff, 0xff, 0xff))
+style_font_youyuan_20.set_text_font_v2("font_28.bin",28,0)
+
+style_btn_alipay = lv.style_t()
+style_btn_alipay.init()
+style_btn_alipay.set_radius(20)
+style_btn_alipay.set_bg_opa(lv.OPA.COVER)
+style_btn_alipay.set_bg_color(lv.palette_main(lv.PALETTE.BLUE))
+style_btn_alipay.set_bg_grad_color(lv.palette_darken(lv.PALETTE.BLUE, 2))
+style_btn_alipay.set_bg_grad_dir(lv.GRAD_DIR.VER)
+
+style_cont_alipay = lv.style_t()
+style_cont_alipay.init()
+style_cont_alipay.set_radius(20)
+style_cont_alipay.set_bg_opa(lv.OPA.COVER)
+style_cont_alipay.set_bg_color(lv.color_make(0xff, 0xff, 0xff))
+
+
+class Alipay(Abstract):
+ """
+ 支付宝
+ """
+ def __init__(self):
+ self.imei = modem.getDevImei()
+ if self.imei == None :
+ self.imei = "1111"
+ self.iccid = sim.getIccid()
+ if self.iccid == -1 :
+ self.iccid = "1111"
+ self.imsi = sim.getImsi()
+ if self.imsi == -1:
+ self.imsi = "1111"
+ self.mac = "123456"
+ self.sn = modem.getDevSN()
+ self.vendor = "ZHSX"
+ self.product_name = "ZHSX"
+ self. product_model = modem.getDevModel()
+ self.pk_alipay = "voPuTFiLcdA"
+ self.pk_aliyun = "a1c7Ojs6HMR"
+ self.ps_aliyun = "TxPFIJ5F1kwa0zO3"
+ self.product_type = 0
+ self.timer_Alipay = osTimer()
+ self.Alipay_Ui_isOpen = 0
+ self.Alipay_init_flag = 0
+ EventMesh.subscribe("alipay_unbind", self.alipay_unbind)
+
+ EventMesh.subscribe("alipay_1", self.alipay_1)
+ EventMesh.subscribe("get_payment_code", self.get_payment_code)
+ EventMesh.subscribe("get_collect_code", self.get_collect_code)
+ EventMesh.subscribe("get_parent_code", self.get_parent_code)
+ EventMesh.subscribe("get_alipay_init", self.get_alipay_init)
+ EventMesh.subscribe("alipay_exit", self.alipay_exit)
+ EventMesh.subscribe("id2_clean_data", self.id2_clean_data)
+ EventMesh.subscribe("Alipay_init", self.Alipay_init)
+ EventMesh.subscribe("get_Alipay_Ui_isOpen",self.get_Alipay_Ui_isOpen)
+ EventMesh.subscribe("set_Alipay_Ui_isOpen",self.set_Alipay_Ui_isOpen)
+
+ self.is_simcard_identify = 255
+ self.is_init = 255
+ self.upay_bound = 0 #绑定结果
+ self.alipay = ALIPAY(self.imei, self.iccid,self.imsi, self.mac, self.sn,self.vendor, self.product_name, self. product_model, self.pk_alipay , self.pk_aliyun, self.ps_aliyun,0)
+ #self.alipay = ALIPAY("867387060319491", "898604293619F0549750","460044917509047", "123456", "P1Q22I80C0007530P","ZHIHUISHIXUN", "ZHIHUISHIXUN", "EC800M", "uHTfYqOlGlA" , "a15PcyZ3IHA", "kOGGPhtXAg1Lz1vg",0)
+ #self.alipay.register_print()
+ self.alipay.set_log_limit(5)
+ #self.alipay.set_log_limit(0)
+
+ #self.timer_Alipay.start(20000, 1, self.timeout_Alipay)
+ def post_processor_after_instantiation(self):
+ print("post_processor_after_instantiation")
+ EventMesh.publish_async("Alipay_init","",40*1024)
+
+
+ def get_Alipay_Ui_isOpen(self, event, msg):
+ return self.Alipay_Ui_isOpen
+ def set_Alipay_Ui_isOpen(self, event, msg):
+ self.Alipay_Ui_isOpen = msg
+ def Alipay_init(self, event, msg):
+ if self.Alipay_init_flag == 1:
+ print("Alipay_init:reuse!!!!!!!!")
+ #self.Alipay_init_flag = 0
+ return
+ self.Alipay_init_flag = 1
+ #print("timeout_Alipay1:{}".format(EventMesh.publish(constants.EVENT.GET_CONNECT)))
+ #time = utime.localtime()
+
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1 and self.alipay != None and (self.is_simcard_identify != 0 ):#or time[3] == 0 or time[3] == 12):
+ #if self.alipay != None and (self.is_simcard_identify != 0 or time[3] == 0 or time[3] == 12):
+ self.is_simcard_identify = self.alipay.start_simcard_identify()
+ print("is_simcard_identify:%d"%self.is_simcard_identify)
+
+ #if self.is_simcard_identify == 0 and EventMesh.publish(constants.EVENT.GET_CONNECT) == 1 and self.is_init != 0:
+ if self.is_init != 0:
+ id2_st = bytearray([0])
+ id2_ret = self.alipay.id2_init()
+ #print("id2_ret:%d"%id2_ret)
+ self.alipay.id2_check_status(id2_st)
+ #print("id2_st:",str(id2_st))
+ if id2_st[0] == 1:
+ self.is_init = self.alipay.pay_init(90000, 90000,\
+ 2000, 2000, \
+ 100, 40*1024, \
+ self.upay_display_notify_cb, 0)
+ #alipay.pay_init(90000, 90000,2000, 2000,200, 40*1024,upay_display_notify_cb, 0)
+
+ if self.is_init == 0 :
+ self.alipay.enable_collectioncode(1)
+ else :
+ print("id2_st:",str(id2_st))
+ print("self.is_pay_init:%d"%self.is_init)
+ self.Alipay_init_flag = 0
+
+ def upay_display_notify_cb(self,arg):
+ #print("upay_display_notify_cb!!!!!!!!!!!!!!!!!!!!")
+ cmd = arg[0]
+ rsp_code = arg[1]
+ result = arg[2]
+ result_len = arg[3]
+ userdata = arg[4]
+ if EventMesh.publish("get_Alipay_Ui_isOpen") == 0:
+ return
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ print("upay_display_notify_cb:\r\ncmd:{}\r\nrsp_code:{}".format(cmd,rsp_code))
+
+ if rsp_code == 4 :
+ # 打印获取到的绑定码
+ print("bindcode[%d]: %s\n"%(result_len, result))
+ #查询绑定结果
+ utime.sleep_ms(1000)
+ cmd_t = 2 #UPAY_MSG_GET_BINDING_RESULT;
+ userdata_t = None
+ args = None
+ ret = self.alipay.msg_send(cmd_t,args,userdata_t)
+ #EventMesh.subscribe("get_binding_code", self.get_binding_code)
+ #EventMesh.publish("load_screen", {"screen": "alipay_invite","meta":{"result":result,"result_len":result_len}})
+ EventMesh.publish("load_screen", {"screen": "alipay_invite","meta":str(result)})
+
+ #case UPAY_RSP_PROCESSING:
+ elif rsp_code == 1:
+ #轮询绑定结果
+ if cmd == 2 :
+ print("upay_display_notify_cb: bind processing\n")
+
+ elif rsp_code == 5:
+ #获取付款码回调
+ print("upay_display_notify_cb: paycode[%d]: %s\n"%( result_len, result))
+ # EventMesh.publish("load_screen", {"screen": "alipay_paycode","meta":str(result)})
+ EventMesh.publish("set_alipay_code",str(result))
+ # 查询付款结果
+ print("upay_display_notify_cb: get payment result\n")
+ utime.sleep_ms(500)
+ cmd_t = 4
+ userdata_t = None
+ args = None
+ ret = self.alipay.msg_send(cmd_t,args,userdata_t)
+
+ elif rsp_code == 6:
+ #打印获取到的收款码
+ print("upay_display_notify_cb: collectioncode[%d]: %s\n"%(result_len, result))
+ EventMesh.publish("load_screen", {"screen": "alipay_collect","meta":str(result)})
+ utime.sleep_ms(500)
+
+ elif rsp_code == 7:
+ #打印家长控制码
+ print("upay_display_notify_cb: parentctrlcode[%d]: %s\n"%(result_len, result) )
+ EventMesh.publish("load_screen", {"screen": "alipay_parent","meta":str(result)})
+
+
+ elif rsp_code == 8:
+ #付款结果
+ print("upay_display_notify_cb: order result, bitmap size %d\n"%(result_len))
+ EventMesh.publish("load_screen", {"screen": "alipay_pay_success","meta":str(result)})
+
+ elif rsp_code == 3:
+ #绑定成功
+ print("upay_display_notify_cb: bind complete\n")
+ EventMesh.publish("load_screen", {"screen": "alipay_success"})
+
+ self.upay_bound = 1
+
+ elif rsp_code == 2:
+ # 绑定进度
+ print("upay_display_notify_cb: bind progress %s\n"%(str(result)))
+ EventMesh.publish("load_screen", {"screen": "alipay_inviting"})
+
+ elif rsp_code == 11:
+ # 解绑成功
+ print("upay_display_notify_cb: unbind complete\n")
+
+
+ elif rsp_code == 9:
+ #主扫码解析结果
+ print("%s: recv scancode info\n")
+ #upay_scancode_info_t *scancode_info = (upay_scancode_info_t *)result
+ seller_name = result[10]#未验证
+ amount = result[20]#未验证
+ print("upay_display_notify_cb: seller name %s, amount %s\n"%(seller_name, amount))
+
+ #发起主扫支付
+ cmd_t = 7 #UPAY_MSG_POST_SCAN_PAYMENT;
+ args = amount
+ userdata_t = None
+ print("upay_display_notify_cb: ---------------------------- post scan payment\n")
+ ret = self.alipay.msg_send(cmd_t,args,userdata_t)
+
+ elif rsp_code == 20:
+ if cmd == 6 :
+ print("TODO:show 网络异常,请重试")
+
+ elif rsp_code == 21:
+ if cmd == 6 :
+ print("TODO:show 二维码无法识别")
+
+ elif rsp_code == 46:
+ if cmd == 6 :
+ print("TODO:show 网络异常,请重试")
+
+ elif rsp_code == 48:
+ if cmd == 6 :
+ print("TODO:show 网络异常,请重试")
+
+ elif rsp_code == 37:
+ if cmd == 6 :
+ print("TODO:show 网络异常,请重试")
+
+ elif rsp_code == 49:
+ if cmd == 6:
+ print("TODO:show 网络异常,请重试")
+
+ elif rsp_code == 50:
+ if cmd == 6:
+ print("TODO:show 网络异常,请重试")
+
+ elif rsp_code == 10:
+ #发起主扫支付结果
+ print("upay_display_notify_cb: post scan payment complete\n")
+
+ elif rsp_code == 18:
+ # 发起主扫支付结果
+ print("upay_display_notify_cb: post scan payment failed\n")
+
+ elif rsp_code == 19:
+ # 发起主扫支付结果
+ print("upay_display_notify_cb: post scan payment failed\n")
+
+ elif rsp_code == 42:
+ #发起主扫支付结果
+ print("upay_display_notify_cb: post scan payment failed\n")
+
+ elif rsp_code == 43:
+ # 发起主扫支付结果
+ print("upay_display_notify_cb: post scan payment failed\n")
+
+ elif rsp_code == 44:
+ # 服务端已解绑
+ print("upay_display_notify_cb: not bind !\n")
+
+ def get_binding_code(self, event, msg):
+ return self.result
+
+ def alipay_unbind(self, event, msg):
+ self.alipay.unbind()
+
+ def get_payment_code(self, event, msg):
+ if self.is_init == 0 :
+ args = ""
+ userdata = ""
+ ret = self.alipay.msg_send(3,args,userdata)
+
+ def get_collect_code(self, event, msg):
+ if self.is_init == 0 :
+ args = ""
+ userdata = ""
+ ret = self.alipay.msg_send(5,args,userdata)
+
+ def get_parent_code(self, event, msg):
+ if self.is_init == 0 :
+ args = ""
+ userdata = ""
+ ret = self.alipay.msg_send(8,args,userdata)
+ def get_alipay_init(self, event, msg):
+ return self.is_init
+
+ def alipay_exit(self, event, msg):
+ if self.is_init == 0 :
+ args = ""
+ userdata = ""
+ ret = self.alipay.msg_send(11,args,userdata) #发送退出程序命令
+ print("alipay_exit")
+ def id2_clean_data(self, event, msg):
+ return self.alipay.id2_clean_data()
+ def alipay_1(self, event, msg):
+ #本地判断是否绑定
+ check_bind = self.alipay.check_bind_status()
+ check_bind_online = self.alipay.check_bind_status()
+ print("check_bind:{} check_bind_online:{}".format(check_bind,check_bind_online))
+ if check_bind == 4: #已绑定
+ EventMesh.publish("load_screen", {"screen": "alipay_1_1"})
+ # if self.is_init == 0 :
+ # args = ""
+ # userdata = ""
+ # ret = self.alipay.msg_send(3,args,userdata) #发送获取付款码消息
+ # ret = self.alipay.msg_send(5,args,userdata) #发送获取收款码消息
+ elif check_bind == 5: #未绑定
+ #EventMesh.publish("load_screen", {"screen": "alipay_invite"})
+ if self.is_init == 0 :
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 0:
+ EventMesh.publish("connect_failed_event")
+ else:
+ EventMesh.publish("connect_ok_event")
+ args = ""
+ userdata = ""
+ print("--000--")
+ ret = self.alipay.msg_send(1,args,userdata) #发送获取绑定码消息
+ print("alipay_1 send msg:HELIOS_PAY_MSG_GET_BIND_CODE:{}".format(ret))
+ else :
+ print("check bind error!!!")
+
+
+style_alipay_screen_default = lv.style_t()
+style_alipay_screen_default.init()
+style_alipay_screen_default.set_radius(0)
+style_alipay_screen_default.set_bg_color(lv.color_make(0x00, 0x00, 0x00))
+style_alipay_screen_default.set_bg_opa(255)
+style_alipay_screen_default.set_border_width(0)
+style_alipay_screen_default.set_pad_left(0)
+style_alipay_screen_default.set_pad_right(0)
+style_alipay_screen_default.set_pad_top(0)
+style_alipay_screen_default.set_pad_bottom(0)
+
+style_alipay_img_default = lv.style_t()
+style_alipay_img_default.init()
+style_alipay_img_default.set_img_opa(255)
+style_alipay_img_default.set_img_recolor_opa(0)
+style_alipay_img_default.set_img_recolor(lv.color_make(0xff,0xff,0xff))
+
+alipay_open_screen = lv.obj()
+print("alipay_open_screen")
+alipay_open_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+# add style for watchface
+alipay_open_screen.add_style(style_alipay_screen_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+#进入图片
+AlipayOpen_img = lv.img(alipay_open_screen)
+AlipayOpen_img.set_pos(int(70),int(80))
+AlipayOpen_img.set_size(100,100)
+AlipayOpen_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+AlipayOpen_img.add_flag(lv.obj.FLAG.CLICKABLE)
+AlipayOpen_img.set_src("E:/static/APP/alipay/1.jpg")
+AlipayOpen_img.add_style(style_alipay_img_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+
+AlipayOpen_label = lv.label(alipay_open_screen)
+AlipayOpen_label.set_pos(0, 250)
+AlipayOpen_label.set_size(240, 50)
+AlipayOpen_label.set_long_mode(lv.label.LONG.WRAP)
+AlipayOpen_label.set_text("网络错误,请重试")
+AlipayOpen_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+AlipayOpen_label.add_flag(lv.obj.FLAG.HIDDEN)
+AlipayOpen_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+class AlipayOpenScreen(Screen):
+ NAME = "alipay_open"
+ #打开支付宝
+ def __init__(self):
+ super().__init__()
+ self.meta = alipay_open_screen
+ self.timer_AlipayOpen = osTimer()
+ self.timer_AlipayOpen_count = 0
+ self.flag = 0
+ EventMesh.subscribe("connect_failed_event",self.connect_failed_event)
+ EventMesh.subscribe("connect_ok_event",self.connect_ok_event)
+
+ def connect_failed_event(self, event, msg):
+ AlipayOpen_label.clear_flag(lv.obj.FLAG.HIDDEN)
+
+ def connect_ok_event(self, event, msg):
+ AlipayOpen_label.add_flag(lv.obj.FLAG.HIDDEN)
+
+ def initialization(self):
+
+ self.flag = 0
+ state = EventMesh.publish(constants.EVENT.GET_CONNECT)
+ print("AlipayOpenScreen:state ",state,EventMesh.publish("get_alipay_init"))
+
+ #初始化成功 未联网
+ #初始化失败 已联网
+
+ if (EventMesh.publish(constants.EVENT.GET_CONNECT) == 0 and EventMesh.publish("get_alipay_init") != 0) or EventMesh.publish("get_alipay_init") != 0:
+ AlipayOpen_label.clear_flag(lv.obj.FLAG.HIDDEN)
+ else:
+ AlipayOpen_label.add_flag(lv.obj.FLAG.HIDDEN)
+ if EventMesh.publish("get_alipay_init") == 0:
+ print("get_alipay_init ok:")
+ # AlipayOpen_label.add_flag(lv.obj.FLAG.HIDDEN)
+ if self.flag == 0:
+ self.flag = 1
+ EventMesh.publish("alipay_1")
+ else:
+ print("get_alipay_init failed:")
+ # AlipayOpen_label.clear_flag(lv.obj.FLAG.HIDDEN)
+ print("timeout_AlipayOpen:",self.flag)
+ EventMesh.publish_async("Alipay_init","",40*1024)
+ self.timer_AlipayOpen_count = 0
+ self.timer_AlipayOpen.start(1000, 1, self.timeout_AlipayOpen)
+ EventMesh.publish("set_Alipay_Ui_isOpen",1)
+
+
+ def timeout_AlipayOpen(self, *args):
+ #print("timeout_AlipayOpen:",self.flag)
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ state = EventMesh.publish(constants.EVENT.GET_CONNECT)
+ print("AlipayOpenScreen:state",state)
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 0:
+ if self.timer_AlipayOpen_count > 10:
+ self.timer_AlipayOpen_count = 0
+ EventMesh.publish("return_prev_screen")
+ else:
+ if EventMesh.publish("get_alipay_init") == 0:
+ #print("timeout_AlipayOpen:2")
+ if self.flag == 0:
+ self.flag = 1
+ EventMesh.publish("alipay_1")
+ else :
+ #print("timeout_AlipayOpen:!!!!!!!!!!",self.timer_AlipayOpen_count)
+ if self.timer_AlipayOpen_count>10 or self.timer_AlipayOpen_count == 0:
+ if self.timer_AlipayOpen_count > 10:
+ self.timer_AlipayOpen_count = 0
+ EventMesh.publish("return_prev_screen")
+ return
+ EventMesh.publish_async("Alipay_init","",40*1024)
+ self.timer_AlipayOpen_count = 1
+ self.timer_AlipayOpen_count+=1
+ # self.timer_AlipayOpen.stop()
+ # self.timer_AlipayOpen.start(10000, 1, self.timeout_AlipayOpen)
+
+ def post_processor_after_initialization(self):
+ pass
+ def done_return(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def Close(self):
+ self.flag = 0
+ self.timer_AlipayOpen.stop()
+ EventMesh.publish("set_Alipay_Ui_isOpen",0)
+
+ pass
+
+ def btn1_release(self):
+ EventMesh.publish("return_alipay")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+alipay_1_1_screen = lv.obj()
+print("alipay_1_1_screen")
+alipay_1_1_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+# add style for watchface
+alipay_1_1_screen.add_style(style_alipay_screen_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+#付款码
+alipay_imgbtn_3 = lv.img(alipay_1_1_screen)
+alipay_imgbtn_3.set_pos(8,10)
+alipay_imgbtn_3.set_size(224,69)
+alipay_imgbtn_3.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+alipay_imgbtn_3.add_flag(lv.obj.FLAG.CLICKABLE)
+alipay_imgbtn_3.set_src("E:/static/APP/alipay/1_13.png")
+alipay_imgbtn_3.add_style(style_alipay_img_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+#收钱
+alipay_imgbtn_2 = lv.img(alipay_1_1_screen)
+alipay_imgbtn_2.set_pos(8,86)
+alipay_imgbtn_2.set_size(224,69)
+alipay_imgbtn_2.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+alipay_imgbtn_2.add_flag(lv.obj.FLAG.CLICKABLE)
+alipay_imgbtn_2.set_src("E:/static/APP/alipay/1_12.png")
+alipay_imgbtn_2.add_style(style_alipay_img_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+#家长设置
+alipay_imgbtn_1 = lv.img(alipay_1_1_screen)
+alipay_imgbtn_1.set_pos(8,168)
+alipay_imgbtn_1.set_size(224,69)
+alipay_imgbtn_1.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+alipay_imgbtn_1.add_flag(lv.obj.FLAG.CLICKABLE)
+alipay_imgbtn_1.set_src("E:/static/APP/alipay/1_11.png")
+alipay_imgbtn_1.add_style(style_alipay_img_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+class Alipay_1_1(Screen):
+ NAME = "alipay_1_1"
+ #已绑定,显示功能列表
+ def __init__(self):
+ super().__init__()
+ self.timer = osTimer()
+ self.meta = alipay_1_1_screen
+ #付款码
+ alipay_imgbtn_3.add_event_cb(lambda e: EventMesh.callback_wrapper(self.alipay_paycode(e)),
+ lv.EVENT.PRESSED, None)
+ #收钱
+ alipay_imgbtn_2.add_event_cb(lambda e: EventMesh.callback_wrapper(self.alipay_collect(e)),
+ lv.EVENT.PRESSED, None)
+ #家长设置
+ alipay_imgbtn_1.add_event_cb(lambda e: EventMesh.callback_wrapper(self.alipay_parent(e)),
+ lv.EVENT.PRESSED, None)
+
+ def initialization(self):
+ EventMesh.publish("set_Alipay_Ui_isOpen",1)
+
+ def Close(self):
+ EventMesh.publish("set_Alipay_Ui_isOpen",0)
+ pass
+
+ def alipay_paycode(self,e):
+ self.timer.start(1*1000,1,self.fun)
+ # Alipay.alipay.msg_send(3,"","") #发送获取付款码消息
+
+ def fun(self,*agrc):
+ # print("alipay_paycode!!!!!!!!!!!")
+ if EventMesh.publish("get_alipay_page_paycode") != 1:
+ EventMesh.publish("get_payment_code")
+ infor = EventMesh.publish("get_alipay_code")
+ if infor != None:
+ EventMesh.publish("update_show_defargc")
+ if EventMesh.publish("get_alipay_page_paycode") == 1:
+ self.timer.stop()
+ EventMesh.publish("load_screen", {"screen": "alipay_paycode"})
+ # EventMesh.publish("get_payment_code")
+
+ def alipay_collect(self,e):
+ EventMesh.publish("get_collect_code")
+ # EventMesh.publish("load_screen", {"screen": "alipay_collect"})
+ def Close(self):
+ self.timer.stop()
+
+ def alipay_parent(self,e):
+ EventMesh.publish("get_parent_code")
+
+ def done_return(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn1_release(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+alipay_invite_screen = lv.obj()
+print("alipay_invite_screen")
+alipay_invite_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+# add style for watchface
+alipay_invite_screen.add_style(style_alipay_screen_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+#背景
+alipay_invite_bg = lv.img(alipay_invite_screen)
+alipay_invite_bg.center()
+alipay_invite_bg.set_size(240,320)
+alipay_invite_bg.set_src("E:/static/APP/alipay/1_2.png")
+alipay_invite_bg.add_style(style_alipay_img_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+#提示词
+alipay_invite_label = lv.label(alipay_invite_bg)
+alipay_invite_label.set_pos(0, 28)
+alipay_invite_label.set_size(240, 50)
+alipay_invite_label.set_long_mode(lv.label.LONG.WRAP)
+alipay_invite_label.set_text("请家长用手机支付宝扫一扫")
+alipay_invite_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+alipay_invite_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+#二维码
+alipay_invite_bg_color = lv.palette_lighten(lv.PALETTE.LIGHT_BLUE, 5)
+alipay_invite_fg_color = lv.palette_darken(lv.PALETTE.BLUE, 4)
+
+alipay_invite_alipay_qr = lv.qrcode(alipay_invite_bg, 150, alipay_invite_fg_color, alipay_invite_bg_color)
+alipay_invite_alipay_qr.set_pos(41,103)
+# Add a border with alipay_invite_bg_color
+alipay_invite_alipay_qr.set_style_border_color(alipay_invite_bg_color, 0)
+alipay_invite_alipay_qr.set_style_border_width(5, 0)
+class Alipay_invite(Screen):
+ NAME = "alipay_invite"
+ #未绑定,获取二维码显示
+ def __init__(self):
+ super().__init__()
+ self.meta = alipay_invite_screen
+ self.alipay_invite_time = osTimer()
+
+
+ def initialization(self):
+ EventMesh.publish("set_Alipay_Ui_isOpen",1)
+
+
+
+ def post_processor_after_initialization(self):
+ # 二维码数据
+ self.alipay_invite_time.start(1000, 1, self.alipay_invite)
+ self.alipay_qr_data = str(self.meta_info)
+ print("alipay_invite:",str(self.meta_info))
+ alipay_invite_alipay_qr.update(self.alipay_qr_data,len(self.alipay_qr_data))
+
+ def alipay_invite(self, *args):
+ print("alipay_invite:")
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+
+ def Close(self):
+ print("alipay_exit:")
+ self.alipay_invite_time.stop()
+ EventMesh.publish("set_Alipay_Ui_isOpen",0)
+ pass
+ def lcd_off(self):
+ self.alipay_invite_time.stop()
+
+ def lcd_on(self):
+ self.alipay_invite_time.start(1000, 1, self.alipay_invite)
+
+ def done_return(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn1_release(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+alipay_inviting_screen = lv.obj()
+print("alipay_inviting_screen")
+alipay_inviting_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+# add style for watchface
+alipay_inviting_screen.add_style(style_alipay_screen_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+#提示词
+alipay_inviting_label = lv.label(alipay_inviting_screen)
+alipay_inviting_label.set_pos(0, 158)
+alipay_inviting_label.set_size(240, 24)
+alipay_inviting_label.set_long_mode(lv.label.LONG.WRAP)
+alipay_inviting_label.set_text("绑定中,不要走开")
+alipay_inviting_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+alipay_inviting_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+class Alipay_inviting(Screen):
+ NAME = "alipay_inviting"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = alipay_inviting_screen
+ self.timer_alipay_inviting = osTimer()
+
+ def initialization(self):
+ EventMesh.publish("set_Alipay_Ui_isOpen",1)
+ self.timer_alipay_inviting.start(1000, 1, self.timeout_alipay_inviting)
+ def post_processor_after_initialization(self):
+ pass
+
+ def timeout_alipay_inviting(self, *args):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+
+ def Close(self):
+ self.timer_alipay_inviting.stop()
+ EventMesh.publish("set_Alipay_Ui_isOpen",0)
+ pass
+
+ def btn1_release(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+alipay_success_screen = lv.obj()
+print("alipay_success_screen")
+alipay_success_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+# add style for watchface
+alipay_success_screen.add_style(style_alipay_screen_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+#背景
+alipay_success_bg = lv.img(alipay_success_screen)
+alipay_success_bg.set_pos(56,30)
+alipay_success_bg.set_size(128,127)
+alipay_success_bg.set_src("E:/static/APP/alipay/1_2_1.png")
+alipay_success_bg.add_style(style_alipay_img_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+#提示词
+alipay_success_label = lv.label(alipay_success_screen)
+alipay_success_label.set_pos(0, 168)
+alipay_success_label.set_size(240, 29)
+alipay_success_label.set_long_mode(lv.label.LONG.WRAP)
+alipay_success_label.set_text("绑定成功")
+alipay_success_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+alipay_success_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+class Alipay_success(Screen):
+ NAME = "alipay_success"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = alipay_success_screen
+ self.timer_Alipay_success = osTimer()
+
+ def initialization(self):
+ self.timer_Alipay_success.start(1000, 0, self.timeout_Alipay_success)
+ EventMesh.publish("set_Alipay_Ui_isOpen",1)
+
+ def post_processor_after_initialization(self):
+ pass
+
+ def timeout_Alipay_success(self, *args, **kwargs):
+ EventMesh.publish("load_screen", {"screen": "alipay_1_1"})
+ self.timer_Alipay_success.stop()
+
+
+ def Close(self):
+ self.timer_Alipay_success.stop()
+ EventMesh.publish("set_Alipay_Ui_isOpen",0)
+ pass
+
+ def btn1_release(self):
+ EventMesh.publish("load_screen", {"screen": "alipay_1_1"})
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+alipay_paycode_screen = lv.obj()
+print("alipay_paycode_screen")
+alipay_paycode_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+# add style for watchface
+alipay_paycode_screen.add_style(style_alipay_screen_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+
+
+# alipay_paycode = lv.tileview(alipay_paycode_screen)
+# alipay_paycode.center()
+# alipay_paycode.set_size(240, 320)
+# alipay_paycode.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+# alipay_paycode.add_style(style_alipay_screen_default, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+# # 1 - 二维码界面
+# alipay_qrcode = alipay_paycode.add_tile(0, 0, lv.DIR.LEFT | lv.DIR.RIGHT)
+# alipay_paycode_bg_color = lv.palette_lighten(lv.PALETTE.LIGHT_BLUE, 5)
+# alipay_paycode_fg_color = lv.palette_darken(lv.PALETTE.BLUE, 4)
+# #二维码
+# alipay_paycode_alipay_qr = lv.qrcode(alipay_qrcode, 150, alipay_paycode_fg_color, alipay_paycode_bg_color)
+# alipay_paycode_alipay_qr.set_pos(45,61)
+# alipay_paycode_alipay_qr.set_style_border_color(alipay_paycode_bg_color, 0)
+# alipay_paycode_alipay_qr.set_style_border_width(5, 0)
+
+# #提示词
+# alipay_paycode_label = lv.label(alipay_qrcode)
+# alipay_paycode_label.set_pos(0, 33)
+# alipay_paycode_label.set_size(240, 30)
+# alipay_paycode_label.set_long_mode(lv.label.LONG.WRAP)
+# alipay_paycode_label.set_text("收银员扫一扫完成付款")
+# alipay_paycode_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+# alipay_paycode_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+# # 2 - 条形码界面
+# alipay_barcode = alipay_paycode.add_tile(1, 0, lv.DIR.LEFT | lv.DIR.RIGHT)
+
+# alipay_paycode_cont = lv.obj(alipay_barcode)
+# alipay_paycode_cont.set_size(240,150)
+# alipay_paycode_cont.set_pos(0,85)
+# alipay_paycode_cont.add_style(style_cont_alipay, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+# alipay_barcode_label = lv.label(alipay_barcode)
+# alipay_barcode_label.set_pos(0, 33)
+# alipay_barcode_label.set_size(240, 30)
+# alipay_barcode_label.set_long_mode(lv.label.LONG.WRAP)
+# alipay_barcode_label.set_text("收银员扫一扫完成付款")
+# alipay_barcode_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+# alipay_barcode_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+# alipay_barcode_num = lv.label(alipay_barcode)
+# alipay_barcode_num.set_pos(0, 240)
+# alipay_barcode_num.set_size(240, 30)
+# alipay_barcode_num.set_long_mode(lv.label.LONG.WRAP)
+# alipay_barcode_num.set_text(" ")
+# alipay_barcode_num.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+# alipay_barcode_num.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+#提示词
+
+
+
+# 1 - 条形码界面
+# alipay_barcode = alipay_paycode.add_tile(0, 0, lv.DIR.LEFT | lv.DIR.RIGHT)
+
+alipay_paycode_label = lv.label(alipay_paycode_screen)
+alipay_paycode_label.set_pos(0, 3)
+alipay_paycode_label.set_size(240, 25)
+alipay_paycode_label.set_long_mode(lv.label.LONG.WRAP)
+alipay_paycode_label.set_text("向商家付款")
+alipay_paycode_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+alipay_paycode_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+# alipay_paycode_cont = lv.obj(alipay_paycode_screen)
+# alipay_paycode_cont.set_size(240,280)
+# alipay_paycode_cont.set_pos(0,40)
+# alipay_paycode_cont.add_style(style_cont_alipay, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+style_font_youyuan_black_20 = lv.style_t()
+style_font_youyuan_black_20.init()
+style_font_youyuan_black_20.set_text_color(lv.color_make(0xff, 0xff, 0xff))
+style_font_youyuan_black_20.set_text_font_v2("font_28.bin",28,0)
+
+# alipay_barcode_num = lv.label(alipay_paycode_screen)
+# alipay_barcode_num.set_pos(0, 130)
+# alipay_barcode_num.set_size(240, 30)
+# alipay_barcode_num.set_long_mode(lv.label.LONG.WRAP)
+# alipay_barcode_num.set_text(" ")
+# alipay_barcode_num.add_style(style_font_youyuan_black_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+# 2 - 二维码界面
+
+# alipay_qrcode = alipay_paycode.add_tile(0, 0, lv.DIR.LEFT | lv.DIR.RIGHT)
+alipay_paycode_bg_color = lv.palette_lighten(lv.PALETTE.LIGHT_BLUE, 5)
+alipay_paycode_fg_color = lv.palette_darken(lv.PALETTE.BLUE, 4)
+#二维码
+alipay_paycode_alipay_qr = lv.qrcode(alipay_paycode_screen, 150, alipay_paycode_fg_color, alipay_paycode_bg_color)
+alipay_paycode_alipay_qr.set_pos(45,150)
+alipay_paycode_alipay_qr.set_style_border_color(alipay_paycode_bg_color, 0)
+alipay_paycode_alipay_qr.set_style_border_width(5, 0)
+
+style_bar = lv.style_t()
+style_bar.init()
+style_bar.set_radius(0)
+style_bar.set_bg_color(lv.color_make(0x00, 0x00, 0x00))
+style_bar.set_bg_opa(255)
+style_bar.set_border_width(0)
+style_bar.set_pad_left(0)
+style_bar.set_pad_right(0)
+style_bar.set_pad_top(0)
+style_bar.set_pad_bottom(0)
+
+container = lv.obj(alipay_paycode_screen)
+container.set_size(240, 100)
+container.set_pos(0, 33)
+container.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+container.add_style(style_bar,lv.PART.MAIN | lv.STATE.DEFAULT)
+
+line_bar = []
+def code_128_generate_barcode1(screen, data, width=180, height=80):
+
+ left_curr_line = 0
+ show_play = 0
+ # 删除上次的container
+ # old_container = screen.get_child(-1)
+ # if old_container:
+ # old_container.delete()
+
+ # 生成二进制码
+ binary_data = code128.encode(data)
+ if not binary_data:
+ return 0
+ # print("binary_data is ",binary_data)
+
+
+
+ # 计算每个条的宽度
+ bar_width = width // (len(binary_data))
+ # print("bar_width is :{} len(binary_data):{}".format(bar_width,len(binary_data)))
+ # 按照二进制码中的1和0,分别创建LVGL矩形对象
+ for i in range(len(binary_data)):
+ if(len(line_bar) == i):
+ line_tmp = lv.obj(container)
+ line_tmp.add_style(style_bar, lv.PART.MAIN | lv.STATE.DEFAULT)
+ line_bar.append(line_tmp)
+
+ real_width = bar_width * 1
+ line_bar[i].set_size(1,90)
+ left = (width - len(binary_data))//2#240-152 = 88 //2 ==44
+ line_bar[i].set_pos(left+left_curr_line,0)
+ if binary_data[i] == 0xff:
+ line_bar[i].set_style_bg_color(lv.color_make(0xff, 0xff, 0xff), lv.PART.MAIN | lv.STATE.DEFAULT)
+ else:
+ line_bar[i].set_style_bg_color(lv.color_make(0x00, 0x00, 0x00), lv.PART.MAIN | lv.STATE.DEFAULT)
+ left_curr_line += real_width
+ show_play = 1
+ print("show_play:",show_play)
+ return show_play
+
+class Alipay_paycode(Screen):
+ NAME = "alipay_paycode"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = alipay_paycode_screen
+ self.timer = osTimer()
+ EventMesh.subscribe("set_alipay_code",self.set_alipay_code)
+ EventMesh.subscribe("get_alipay_code",self.get_alipay_code)
+ EventMesh.subscribe("get_alipay_page_paycode",self.get_alipay_page_paycode)
+ EventMesh.subscribe("update_show_defargc",self.update_show_defargc)
+ self.alipay_qr_data = {}
+ self.count = 0
+ self.update_page_state = 0
+# if EventMesh.publish("get_alipay_page_paycode") == 0:
+# EventMesh.publish("load_screen", {"screen": "alipay_paycode","meta":str(result)})
+ def post_processor_after_initialization(self):
+ self.alipay_qr_data = EventMesh.publish("get_alipay_code")
+ print("self.alipay_qr_data:",str(self.alipay_qr_data))
+ alipay_paycode_alipay_qr.update(self.alipay_qr_data,len(self.alipay_qr_data))
+ self.update_page_state = code_128_generate_barcode1(alipay_paycode_screen,self.alipay_qr_data,240,100)
+
+ def initialization(self):
+ print("alipay_paycode:initialization")
+ self.count = 0
+ self.timer.start(1*1000,1,self.update_alipy)
+ EventMesh.publish("set_Alipay_Ui_isOpen",1)
+ def update_alipy(self,e):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ if self.count == 0 or self.count >= 10:
+ if self.count >= 10:
+ self.count = 0
+ EventMesh.publish("get_payment_code")
+ EventMesh.publish("publish_message_event_ui",{"func":self.update_show,"data":0})
+ self.count+=1
+
+ def update_show_defargc(self, event, msg):
+ if self.alipay_qr_data != {}:
+ print("alipay_paycode:update_show")
+ alipay_paycode_alipay_qr.update(self.alipay_qr_data,len(self.alipay_qr_data))
+ self.update_page_state = code_128_generate_barcode1(alipay_paycode_screen,self.alipay_qr_data,240,100)
+
+ def update_show(self,data):
+ if self.alipay_qr_data != {}:
+ print("alipay_paycode:update_show")
+ alipay_paycode_alipay_qr.update(self.alipay_qr_data,len(self.alipay_qr_data))
+ self.update_page_state = code_128_generate_barcode1(alipay_paycode_screen,self.alipay_qr_data,240,100)
+
+ def get_alipay_page_paycode(self, event, msg):#获取
+ return self.update_page_state
+
+ def get_alipay_code(self, event, msg):#获取
+ return self.alipay_qr_data
+
+ def set_alipay_code(self, event, msg):#获取
+ self.alipay_qr_data = msg
+
+ def lcd_on(self):
+ self.count = 0
+ self.timer.start(1*1000,1,self.update_alipy)
+
+ def lcd_off(self):
+ self.count = 0
+ self.timer.stop()
+
+ def Close(self):
+ self.update_page_state = 0
+ self.timer.stop()
+ EventMesh.publish("set_Alipay_Ui_isOpen",0)
+ pass
+ def done_click(self):
+ EventMesh.publish("get_payment_code")
+ EventMesh.publish("publish_message_event_ui",{"func":self.update_show,"data":0})
+
+
+ def done_return(self):
+ EventMesh.publish("load_screen", {"screen": "alipay_1_1"})
+
+ def btn1_release(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn8_press(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
+alipay_pay_success_screen = lv.obj()
+print("alipay_pay_success_screen")
+alipay_pay_success_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+# add style for watchface
+alipay_pay_success_screen.add_style(style_alipay_screen_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+ #支付成功LOGO
+alipay_pay_bg = lv.img(alipay_pay_success_screen)
+alipay_pay_bg.set_pos(82, 120)
+alipay_pay_bg.set_size(78,78)
+alipay_pay_bg.set_src("E:/static/APP/alipay/1_13_1_1.png")
+alipay_pay_bg.add_flag(lv.obj.FLAG.CLICKABLE)
+alipay_pay_bg.add_style(style_alipay_img_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+
+#付款金额
+# alipay_pay_label = lv.label(alipay_pay_success_screen)
+# alipay_pay_label.set_pos(0, 220)
+# alipay_pay_label.set_size(240, 45)
+# alipay_pay_label.set_long_mode(lv.label.LONG.WRAP)
+# alipay_pay_label.set_text(" ")
+# alipay_pay_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+# alipay_pay_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+#完成按钮
+alipay_pay_text = lv.label(alipay_pay_success_screen)
+alipay_pay_text.set_text("支付完成")
+alipay_pay_text.set_pos(0, 220)
+alipay_pay_text.set_size(240,45)
+alipay_pay_text.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+alipay_pay_text.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+class Alipay_pay_success(Screen):
+ NAME = "alipay_pay_success"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = alipay_pay_success_screen
+ alipay_pay_bg.add_event_cb(lambda e: EventMesh.callback_wrapper(self.button_cb(e)), lv.EVENT.CLICKED, None)
+
+ def post_processor_after_initialization(self):
+ print("money:",str(self.meta_info))
+ # alipay_pay_label.set_text(str(self.meta_info))
+
+ def button_cb(self,e):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def initialization(self):
+ EventMesh.publish("set_Alipay_Ui_isOpen",1)
+
+
+ def done_click(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def Close(self):
+ EventMesh.publish("set_Alipay_Ui_isOpen",0)
+ pass
+
+ def done_return(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn1_release(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn8_press(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+alipay_collect_screen = lv.obj()
+print("alipay_collect_screen")
+alipay_collect_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+# add style for watchface
+alipay_collect_screen.add_style(style_alipay_screen_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+#二维码
+alipay_collect_bg_color = lv.palette_lighten(lv.PALETTE.LIGHT_BLUE, 5)
+alipay_collect_bg_fg_color = lv.palette_darken(lv.PALETTE.BLUE, 4)
+
+alipay_collect_alipay_qr = lv.qrcode(alipay_collect_screen, 150, alipay_collect_bg_fg_color, alipay_collect_bg_color)
+alipay_collect_alipay_qr.set_pos(33,22)
+# Add a border with bg_color
+alipay_collect_alipay_qr.set_style_border_color(alipay_collect_bg_color, 0)
+alipay_collect_alipay_qr.set_style_border_width(5, 0)
+
+#提示词
+alipay_collect_label = lv.label(alipay_collect_screen)
+alipay_collect_label.set_pos(0, 204)
+alipay_collect_label.set_size(240, 50)
+alipay_collect_label.set_long_mode(lv.label.LONG.WRAP)
+alipay_collect_label.set_text("请对方使用支付宝扫码")
+alipay_collect_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+alipay_collect_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+class Alipay_collect(Screen):
+ NAME = "alipay_collect"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = alipay_collect_screen
+
+
+
+ def initialization(self):
+ EventMesh.publish("set_Alipay_Ui_isOpen",1)
+
+ def post_processor_after_initialization(self):
+ self.alipay_qr_data = str(self.meta_info)
+ print("alipay_collect:",str(self.meta_info))
+ alipay_collect_alipay_qr.update(self.alipay_qr_data,len(self.alipay_qr_data))
+
+ def Close(self):
+ EventMesh.publish("set_Alipay_Ui_isOpen",0)
+ pass
+
+ def done_return(self):
+ EventMesh.publish("load_screen", {"screen": "alipay_1_1"})
+
+ def btn1_release(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn8_press(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+alipay_parent_screen = lv.obj()
+print("alipay_parent_screen")
+alipay_parent_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+# add style for watchface
+alipay_parent_screen.add_style(style_alipay_screen_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+#家长头像
+alipay_parent_bg = lv.img(alipay_parent_screen)
+alipay_parent_bg.set_pos(8,12)
+alipay_parent_bg.set_size(81,81)
+alipay_parent_bg.set_src("E:/static/APP/alipay/1_11_1.png")
+alipay_parent_bg.add_style(style_alipay_img_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+#提示词
+alipay_parent_label = lv.label(alipay_parent_screen)
+alipay_parent_label.set_pos(96, 12)
+alipay_parent_label.set_size(240-96, 29)
+alipay_parent_label.set_long_mode(lv.label.LONG.WRAP)
+alipay_parent_label.set_text("家长设置")
+alipay_parent_label.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+alipay_parent_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+alipay_parent_label1 = lv.label(alipay_parent_screen)
+alipay_parent_label1.set_pos(96, 43)
+alipay_parent_label1.set_size(240-96, 29)
+alipay_parent_label1.set_long_mode(lv.label.LONG.WRAP)
+alipay_parent_label1.set_text("零花钱管理")
+alipay_parent_label1.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+alipay_parent_label1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+alipay_parent_label2 = lv.label(alipay_parent_screen)
+alipay_parent_label2.set_pos(96, 71)
+alipay_parent_label2.set_size(240-96, 29)
+alipay_parent_label2.set_long_mode(lv.label.LONG.WRAP)
+alipay_parent_label2.set_text("解绑退钱")
+alipay_parent_label2.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+alipay_parent_label2.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+#家长码
+alipay_parent_bg_color = lv.palette_lighten(lv.PALETTE.LIGHT_BLUE, 5)
+alipay_parent_fg_color = lv.palette_darken(lv.PALETTE.BLUE, 4)
+
+alipay_parent_alipay_qr = lv.qrcode(alipay_parent_screen, 150, alipay_parent_fg_color, alipay_parent_bg_color)
+alipay_parent_alipay_qr.set_pos(45,171)
+# Add a border with bg_color
+alipay_parent_alipay_qr.set_style_border_color(alipay_parent_bg_color, 0)
+alipay_parent_alipay_qr.set_style_border_width(5, 0)
+alipay_parent_alipay_qr.set_style_border_width(5, 0)
+
+class Alipay_parent(Screen):
+ NAME = "alipay_parent"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = alipay_parent_screen
+
+
+
+ def initialization(self):
+ EventMesh.publish("set_Alipay_Ui_isOpen",1)
+
+ def post_processor_after_initialization(self):
+ self.alipay_qr_data = str(self.meta_info)
+ print("alipay_parent:",str(self.meta_info))
+ alipay_parent_alipay_qr.update(self.alipay_qr_data,len(self.alipay_qr_data))
+
+ def Close(self):
+ EventMesh.publish("set_Alipay_Ui_isOpen",0)
+ pass
+
+ def done_return(self):
+ EventMesh.publish("load_screen", {"screen": "alipay_1_1"})
+
+ def btn1_release(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn8_press(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
\ No newline at end of file
--- /dev/null
+import osTimer
+import lvgl as lv
+import EventMesh
+import osTimer
+import constants
+import ujson
+import ql_fs
+import audio
+from machine import Pin
+from ui import style_screen,style_font_youyuan_20,style_btn,style_img,Screen,style_contact_btn
+import audio
+import utime
+# import ALIPAY
+import usys
+from misc import Power
+factorymode_cont_y = 0
+factorymode_screen = lv.obj()
+print("factorymode_screen")
+factorymode_screen.center()
+factorymode_screen.set_size(240, 320)
+factorymode_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+style_btn_1 = lv.style_t()
+style_btn_1.init()
+style_btn_1.set_bg_opa(0)
+style_btn_1.set_shadow_opa(0)
+style_btn_1.set_border_width(0)
+style_btn_1.set_bg_color(lv.color_make(0x00, 0xff, 0x2a))
+style_btn_1.set_bg_grad_color(lv.color_make(0x00, 0xff, 0x2a))
+style_btn_1.set_bg_grad_dir(lv.GRAD_DIR.NONE)
+
+style_font_W_B_28 = lv.style_t()
+style_font_W_B_28.init()
+style_font_W_B_28.set_text_color(lv.color_make(0xff, 0xff, 0xff))
+style_font_W_B_28.set_text_font_v2("font_28.bin",28,0)
+style_font_W_B_28.set_bg_color(lv.color_make(0x00, 0xff, 0x2a))
+
+factorymode_title = lv.label(factorymode_screen)
+factorymode_title.set_pos(0, 10)
+factorymode_title.set_size(240, 40)
+factorymode_title.set_text("-工厂模式-")
+factorymode_title.set_long_mode(lv.label.LONG.WRAP)
+factorymode_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+factorymode_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+factorymode_cont_style = lv.style_t()
+factorymode_cont_style.init()
+factorymode_cont_style.set_radius(0)
+factorymode_cont_style.set_bg_color(lv.color_make(0x00, 0x00, 0x00))
+factorymode_cont_style.set_bg_grad_color(lv.color_make(0x00, 0x00, 0x00))
+factorymode_cont_style.set_bg_grad_dir(lv.GRAD_DIR.VER)
+factorymode_cont_style.set_bg_opa(255)
+factorymode_cont_style.set_border_width(0)
+factorymode_cont_style.set_pad_left(0)
+factorymode_cont_style.set_pad_right(0)
+factorymode_cont_style.set_pad_top(0)
+factorymode_cont_style.set_pad_bottom(0)
+
+factorymode_cont = lv.obj(factorymode_screen)
+factorymode_cont.set_pos(0, 50)
+factorymode_cont.set_size(240, 270)
+factorymode_cont.add_style(factorymode_cont_style,lv.PART.MAIN | lv.STATE.DEFAULT)
+
+factorymode_location = lv.btn(factorymode_cont)
+factorymode_location.set_pos(0, factorymode_cont_y)
+factorymode_location.set_size(240, 60)
+factorymode_location_label = lv.label(factorymode_location)
+factorymode_location_label.set_text("定位测试")
+factorymode_location.set_style_pad_all(0, lv.STATE.DEFAULT)
+factorymode_location_label.align(lv.ALIGN.LEFT_MID, 70, 0)
+factorymode_location_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+factorymode_location_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+factorymode_location.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+factorymode_cont_y+=60
+factorymode_bat_test = lv.btn(factorymode_cont)
+factorymode_bat_test.set_pos(0, factorymode_cont_y)
+factorymode_bat_test.set_size(240, 60)
+factorymode_bat_test_label = lv.label(factorymode_bat_test)
+factorymode_bat_test_label.set_text("电池测试")
+factorymode_bat_test.set_style_pad_all(0, lv.STATE.DEFAULT)
+factorymode_bat_test_label.align(lv.ALIGN.LEFT_MID, 70, 0)
+factorymode_bat_test_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+factorymode_bat_test_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+factorymode_bat_test.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+factorymode_cont_y+=60
+factorymode_hsensor_test = lv.btn(factorymode_cont)
+factorymode_hsensor_test.set_pos(0, factorymode_cont_y)
+factorymode_hsensor_test.set_size(240, 60)
+factorymode_hsensor_test_label = lv.label(factorymode_hsensor_test)
+factorymode_hsensor_test_label.set_text("心率测试")
+factorymode_hsensor_test.set_style_pad_all(0, lv.STATE.DEFAULT)
+factorymode_hsensor_test_label.align(lv.ALIGN.LEFT_MID, 70, 0)
+factorymode_hsensor_test_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+factorymode_hsensor_test_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+factorymode_hsensor_test.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+
+factorymode_cont_y+=60
+factorymode_step = lv.btn(factorymode_cont)
+factorymode_step.set_pos(0, factorymode_cont_y)
+factorymode_step.set_size(240, 60)
+factorymode_step_label = lv.label(factorymode_step)
+factorymode_step_label.set_text("计步测试")
+factorymode_step.set_style_pad_all(0, lv.STATE.DEFAULT)
+factorymode_step_label.align(lv.ALIGN.LEFT_MID, 70, 0)
+factorymode_step_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+factorymode_step_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+factorymode_step.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+factorymode_cont_y+=60
+factorymode_log = lv.btn(factorymode_cont)
+factorymode_log.set_pos(0, factorymode_cont_y)
+factorymode_log.set_size(240, 60)
+factorymode_log_label = lv.label(factorymode_log)
+factorymode_log_label.set_text("日志")
+factorymode_log.set_style_pad_all(0, lv.STATE.DEFAULT)
+factorymode_log_label.align(lv.ALIGN.LEFT_MID, 70, 0)
+factorymode_log_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+factorymode_log_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+factorymode_log.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+# factorymode_cont_y+=200
+# factorymode_alipay_init = lv.btn(factorymode_cont)
+# factorymode_alipay_init.set_pos(0, factorymode_cont_y)
+# factorymode_alipay_init.set_size(240, 60)
+# factorymode_alipay_init_label = lv.label(factorymode_alipay_init)
+# factorymode_alipay_init_label.set_text("支付宝初始化")
+# factorymode_alipay_init.set_style_pad_all(0, lv.STATE.DEFAULT)
+# factorymode_alipay_init_label.align(lv.ALIGN.LEFT_MID, 70, 0)
+# factorymode_alipay_init_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+# factorymode_alipay_init_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+# factorymode_alipay_init.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+class FactoryModeScreen(Screen):
+ NAME = "factorymode"
+ def __init__(self):
+ super().__init__()
+ self.meta = factorymode_screen
+ factorymode_location.add_event_cb(lambda e: EventMesh.callback_wrapper(self.load_screen(e, {"screen": "FactoryModeLocation"})), lv.EVENT.CLICKED, None)
+ #factorymode_alipay_init.add_event_cb(lambda e: EventMesh.callback_wrapper(self.load_screen(e, {"screen": "FactoryModeAlipayInit"})), lv.EVENT.CLICKED, None)
+ factorymode_bat_test.add_event_cb(lambda e: EventMesh.callback_wrapper(self.load_screen(e, {"screen": "FactoryModeBatTest"})), lv.EVENT.CLICKED, None)
+ factorymode_hsensor_test.add_event_cb(lambda e: EventMesh.callback_wrapper(self.load_screen(e, {"screen": "FactoryModeHsensorTest"})), lv.EVENT.CLICKED, None)
+ factorymode_log.add_event_cb(lambda e: EventMesh.callback_wrapper(self.load_screen(e, {"screen": "FactoryModeLog"})), lv.EVENT.CLICKED, None)
+
+ factorymode_step.add_event_cb(lambda e: EventMesh.callback_wrapper(self.load_screen(e, {"screen": "FactoryModestep"})), lv.EVENT.CLICKED, None)
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+#显示txt日志
+FactoryModeLog_screen = lv.obj()
+FactoryModeLog_screen.center()
+FactoryModeLog_screen.set_size(240, 320)
+FactoryModeLog_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+FactoryModeLog_label_obj = lv.obj(FactoryModeLog_screen)
+FactoryModeLog_label_obj.center()
+FactoryModeLog_label_obj.set_size(240, 290)
+FactoryModeLog_label_obj.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+FactoryModeLog_label_obj.set_pos(0, 0)
+
+FactoryModeLog_label = lv.label(FactoryModeLog_label_obj)
+FactoryModeLog_label.set_text("")
+FactoryModeLog_label.set_size(240, lv.SIZE.CONTENT)
+FactoryModeLog_label.set_pos(0, 0)
+FactoryModeLog_label.set_long_mode(lv.label.LONG.WRAP)
+FactoryModeLog_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+FactoryModeLog_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+FactoryModeLogClean_btn = lv.btn(FactoryModeLog_screen)
+FactoryModeLogClean_btn.set_pos(5, 290)
+FactoryModeLogClean_btn.set_size(110, 30)
+FactoryModeLogClean_btn.add_style(style_btn_1, lv.PART.MAIN | lv.STATE.DEFAULT)
+FactoryModeLogClean_btn.set_style_pad_all(0, lv.STATE.DEFAULT)
+FactoryModeLogClean_label = lv.label(FactoryModeLogClean_btn)
+FactoryModeLogClean_label.set_text("清空日志")
+FactoryModeLogClean_label.align(lv.ALIGN.CENTER, 0, 0)
+FactoryModeLogClean_label.add_style(style_font_W_B_28, lv.PART.MAIN | lv.STATE.DEFAULT)
+FactoryModeLogClean_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+FactoryModeLogClean_label.set_style_text_color(lv.color_make(0x16, 0x2c, 0xd4), lv.STATE.DEFAULT)
+#FactoryModeLogClean_label.set_style_bg_color(lv.color_make(0x00, 0xff, 0x2a), lv.PART.MAIN | lv.STATE.DEFAULT)
+
+FactoryModeLogNext_btn = lv.btn(FactoryModeLog_screen)
+FactoryModeLogNext_btn.set_pos(120, 290)
+FactoryModeLogNext_btn.set_size(110, 30)
+FactoryModeLogNext_btn.add_style(style_btn_1, lv.PART.MAIN | lv.STATE.DEFAULT)
+FactoryModeLogNext_btn.set_style_pad_all(0, lv.STATE.DEFAULT)
+FactoryModeLogNext_label = lv.label(FactoryModeLogNext_btn)
+FactoryModeLogNext_label.set_text("下一页")
+FactoryModeLogNext_label.align(lv.ALIGN.CENTER, 0, 0)
+FactoryModeLogNext_label.add_style(style_font_W_B_28, lv.PART.MAIN | lv.STATE.DEFAULT)
+FactoryModeLogNext_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+FactoryModeLogNext_label.set_style_text_color(lv.color_make(0x16, 0x2c, 0xd4), lv.STATE.DEFAULT)
+#FactoryModeLogNext_label.set_style_bg_color(lv.color_make(0x00, 0xff, 0x2a), lv.PART.MAIN | lv.STATE.DEFAULT)
+screen_log_len = 250
+class FactoryModeLogScreen(Screen):
+ NAME = "FactoryModeLog"
+ def __init__(self):
+ super().__init__()
+ self.meta = FactoryModeLog_screen
+ self.Log_timer_count = 0
+ self.Log_timer = osTimer()
+ self.log_data = ""
+ self.log_count = 0
+ FactoryModeLogClean_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.LogClean_cb(e)), lv.EVENT.CLICKED, None)
+ FactoryModeLogNext_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.LogNext_cb(e)), lv.EVENT.CLICKED, None)
+ def initialization(self):
+ print("FactoryModeLogScreen")
+ self.Log_timer.start(1000,1,self.Log_timer_cb)
+ with open("/ext/log.txt","r",encoding="utf-8") as fd:
+ self.log_data = fd.read()
+ print(self.log_data)
+ if len(self.log_data) < screen_log_len:
+ FactoryModeLog_label.set_text("第1页\n"+self.log_data)
+ else:
+ FactoryModeLog_label.set_text("第1页 {}/{}\n".format(self.log_count+1,0,len(self.log_data))+self.log_data[:screen_log_len])
+ self.log_count = 0
+ def post_processor_after_initialization(self):
+ pass
+
+ def LogClean_cb(self,e):
+ self.log_data = ""
+ with open("/ext/log.txt","w",encoding="utf-8") as fd:
+ fd.write("")
+
+ def LogNext_cb(self,e):
+ self.log_count += 1
+ if self.log_count*screen_log_len > len(self.log_data):
+ if self.log_count != 1:
+ FactoryModeLog_label.set_text("末尾页\n".format(self.log_count+1)+self.log_data[(self.log_count-1)*screen_log_len:])
+ self.log_count = 0
+ else :
+ FactoryModeLog_label.set_text("第{}页 {}/{}\n".format(self.log_count+1,(self.log_count)*screen_log_len,len(self.log_data))+self.log_data[(self.log_count-1)*screen_log_len:(self.log_count)*screen_log_len])
+
+ def Log_timer_cb(self,e):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+
+
+ def Close(self):
+ self.Log_timer.stop()
+ self.log_data = ""
+ pass
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
+#显示x y z 三轴数据
+FactoryModestep_screen = lv.obj()
+FactoryModestep_screen.center()
+FactoryModestep_screen.set_size(240, 320)
+FactoryModestep_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+FactoryMode_step_label = lv.label(FactoryModestep_screen)
+FactoryMode_step_label.set_text(" ")
+FactoryMode_step_label.set_pos(0, 40)
+FactoryMode_step_label.set_size(240, 40)
+FactoryMode_step_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+FactoryMode_step_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+
+
+FactoryMode_xyz_label = lv.label(FactoryModestep_screen)
+FactoryMode_xyz_label.set_text(" ")
+FactoryMode_xyz_label.set_pos(0, 100)
+FactoryMode_xyz_label.set_size(240, 100)
+FactoryMode_xyz_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+FactoryMode_xyz_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+#FactoryModeLogNext_label.set_style_bg_color(lv.color_make(0x00, 0xff, 0x2a), lv.PART.MAIN | lv.STATE.DEFAULT)
+
+class FactoryModestepScreen(Screen):
+ NAME = "FactoryModestep"
+ def __init__(self):
+ super().__init__()
+ self.meta = FactoryModestep_screen
+ self.Log_timer_count = 0
+ self.Log_timer = osTimer()
+
+ def initialization(self):
+ step = EventMesh.publish(constants.EVENT.GET_STEP)
+ FactoryMode_step_label.set_text("步数{}".format(step[0]))
+ FactoryMode_xyz_label.set_text("X:{}\nY:{}\nZ:{}".format(step[1],step[2],step[3]))
+ self.Log_timer.start(1*1000,1,self.step_cb)
+
+ def post_processor_after_initialization(self):
+
+ pass
+
+ def step_cb(self,*argc):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ step = EventMesh.publish(constants.EVENT.GET_STEP)
+ print("FactoryModestepScreen",step)
+ FactoryMode_step_label.set_text("{}".format(step[0]))
+ FactoryMode_xyz_label.set_text("X:{}\nY:{}\nZ:{}".format(step[1],step[2],step[3]))
+ pass
+
+
+
+ def Close(self):
+ self.Log_timer.stop()
+ self.log_data = ""
+ pass
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
+
+
+#hsensor测试
+FactoryModeHsensorTest_screen = lv.obj()
+FactoryModeHsensorTest_screen.center()
+FactoryModeHsensorTest_screen.set_size(240, 320)
+FactoryModeHsensorTest_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+FactoryModeHsensorTest_label = lv.label(FactoryModeHsensorTest_screen)
+FactoryModeHsensorTest_label.set_text(" 佩戴状态")
+FactoryModeHsensorTest_label.set_size(240, 260)
+FactoryModeHsensorTest_label.set_pos(0, 0)
+FactoryModeHsensorTest_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+FactoryModeHsensorTest_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+FactoryModeHsensorCali_btn = lv.btn(FactoryModeHsensorTest_screen)
+FactoryModeHsensorCali_btn.set_pos(5, 260)
+FactoryModeHsensorCali_btn.set_size(110, 35)
+FactoryModeHsensorCali_btn.add_style(style_btn_1, lv.PART.MAIN | lv.STATE.DEFAULT)
+FactoryModeHsensorCali_btn.set_style_pad_all(0, lv.STATE.DEFAULT)
+FactoryModeHsensorCali_label = lv.label(FactoryModeHsensorCali_btn)
+FactoryModeHsensorCali_label.set_text("活体校准")
+FactoryModeHsensorCali_label.align(lv.ALIGN.CENTER, 0, 0)
+FactoryModeHsensorCali_label.add_style(style_font_W_B_28, lv.PART.MAIN | lv.STATE.DEFAULT)
+FactoryModeHsensorCali_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+FactoryModeHsensorCali_label.set_style_text_color(lv.color_make(0x16, 0x2c, 0xd4), lv.STATE.DEFAULT)
+#FactoryModeHsensorCali_label.set_style_bg_color(lv.color_make(0x00, 0xff, 0x2a), lv.PART.MAIN | lv.STATE.DEFAULT)
+
+FactoryModeHsensorLeakLight_btn = lv.btn(FactoryModeHsensorTest_screen)
+FactoryModeHsensorLeakLight_btn.set_pos(120, 260)
+FactoryModeHsensorLeakLight_btn.set_size(110, 35)
+FactoryModeHsensorLeakLight_btn.add_style(style_btn_1, lv.PART.MAIN | lv.STATE.DEFAULT)
+FactoryModeHsensorLeakLight_btn.set_style_pad_all(0, lv.STATE.DEFAULT)
+FactoryModeHsensorLeakLight_label = lv.label(FactoryModeHsensorLeakLight_btn)
+FactoryModeHsensorLeakLight_label.set_text("漏光检测")
+FactoryModeHsensorLeakLight_label.align(lv.ALIGN.CENTER, 0, 0)
+FactoryModeHsensorLeakLight_label.add_style(style_font_W_B_28, lv.PART.MAIN | lv.STATE.DEFAULT)
+FactoryModeHsensorLeakLight_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+FactoryModeHsensorLeakLight_label.set_style_text_color(lv.color_make(0x16, 0x2c, 0xd4), lv.STATE.DEFAULT)
+#FactoryModeHsensorLeakLight_label.set_style_bg_color(lv.color_make(0x00, 0xff, 0x2a), lv.PART.MAIN | lv.STATE.DEFAULT)
+
+class FactoryModeHsensorTestScreen(Screen):
+ NAME = "FactoryModeHsensorTest"
+ def __init__(self):
+ super().__init__()
+ self.meta = FactoryModeHsensorTest_screen
+ self.hsensorTest_timer_count = 0
+ self.hsensorTest_timer = osTimer()
+ self.Hsensor = None
+ FactoryModeHsensorCali_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.HsensorCali_cb(e)), lv.EVENT.CLICKED, None)
+ FactoryModeHsensorLeakLight_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.HsensorLeakLight_cb(e)), lv.EVENT.CLICKED, None)
+ def initialization(self):
+ print("FactoryModeHsensorTestScreen")
+ self.hsensorTest_timer.start(1000,1,self.hsensorTest_timer_cb)
+ if self.Hsensor == None:
+ self.Hsensor = EventMesh.publish("get_Hsensor")
+ #EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)
+ def post_processor_after_initialization(self):
+ pass
+
+ def HsensorCali_cb(self,e):
+ print("打开校准模式")
+ self.Hsensor.set_sar(1)
+ self.Hsensor.open_test(255) #打开校准模式
+ utime.sleep_ms(500)
+ self.Hsensor.open_heart()
+ self.hsensorTest_timer_count = 5
+
+ def HsensorLeakLight_cb(self,e):
+ print("打开漏光检测")
+ self.Hsensor.open_test(6) #打开漏光检测
+ # utime.sleep_ms(500)
+ # self.Hsensor.open_heart()
+ self.hsensorTest_timer_count = 5
+
+ def hsensorTest_timer_cb(self,e):
+
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ w_data = EventMesh.publish(constants.EVENT.GET_WEAR)#佩戴数据
+
+ #print("FactoryModeHsensorTest{}".format(data))
+ try:
+ c_data = self.Hsensor.get_test_data()#校准数据和工厂数据
+ text_data = " 佩戴状态\n红外:{}活体:{}佩戴:{}\n{},{} \n{},{} \n{},{}\n校准数据:{},{},{},{}\n漏光数据:{},{},{}".format(
+ c_data[3],c_data[4],w_data,c_data[5],c_data[6],c_data[7],c_data[8],c_data[9],c_data[10],
+ c_data[11],c_data[12],c_data[13],c_data[14],c_data[0],c_data[1],c_data[2],)
+ FactoryModeHsensorTest_label.set_text(text_data)
+ #print("aaa:{},{},{}".format(c_data[9],c_data[13],c_data[14]))
+ except Exception as e:
+ FactoryModeHsensorTest_label.set_text("佩戴状态:\n{}".format(w_data))
+ if(self.hsensorTest_timer_count != 0):
+ self.hsensorTest_timer_count -= 1
+ if self.hsensorTest_timer_count == 0:
+ self.Hsensor.close()
+ self.Hsensor.init()
+
+ def Close(self):
+ self.hsensorTest_timer.stop()
+ #EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
+ pass
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
+#电池测试
+FactoryModeBatTest_screen = lv.obj()
+FactoryModeBatTest_screen.center()
+FactoryModeBatTest_screen.set_size(240, 320)
+FactoryModeBatTest_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+FactoryModeBatTest_label = lv.label(FactoryModeBatTest_screen)
+FactoryModeBatTest_label.set_text("Vbat:0V")
+FactoryModeBatTest_label.set_size(240, 100)
+FactoryModeBatTest_label.set_pos(50, 100)
+FactoryModeBatTest_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+FactoryModeBatTest_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+class FactoryModeBatTestScreen(Screen):
+ NAME = "FactoryModeBatTest"
+ def __init__(self):
+ super().__init__()
+ self.meta = FactoryModeBatTest_screen
+ self.BatTest_timer = osTimer()
+
+ def initialization(self):
+ print("FactoryModeBatTestScreen")
+ self.BatTest_timer.start(1000,1,self.BatTest_timer_cb)
+
+ def post_processor_after_initialization(self):
+ pass
+
+ def BatTest_timer_cb(self,e):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ temp = Power.getVbatt()
+ FactoryModeBatTest_label.set_text("Vbat:{}V".format(temp))
+
+ def Close(self):
+ self.BatTest_timer.stop()
+ pass
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
+# FactoryModeAlipayInit_screen = lv.obj()
+# FactoryModeAlipayInit_screen.center()
+# FactoryModeAlipayInit_screen.set_size(240, 320)
+# FactoryModeAlipayInit_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+# FactoryModeAlipayInit_label = lv.label(FactoryModeAlipayInit_screen)
+# FactoryModeAlipayInit_label.set_text("支付宝初始化成功")
+# FactoryModeAlipayInit_label.set_size(240, 100)
+# FactoryModeAlipayInit_label.set_pos(50, 100)
+# FactoryModeAlipayInit_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+# FactoryModeAlipayInit_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+# import atcmd
+
+# class FactoryModeAlipayInitScreen(Screen):
+# NAME = "FactoryModeAlipayInit"
+# def __init__(self):
+# super().__init__()
+# self.meta = FactoryModeAlipayInit_screen
+
+# def initialization(self):
+# ret =EventMesh.publish("id2_clean_data")
+# print("id2_clean_data:ret:{}".format(ret))
+
+# def post_processor_after_initialization(self):
+# resp=bytearray(50)
+# atcmd.sendSync('AT+RSTSET\r\n',resp,'',200) #清nv
+# print("AT+RSTSET:{}".format(resp))
+# utime.sleep(5)
+# Power.powerRestart()
+# def Close(self):
+# pass
+
+# def done_return(self):
+# EventMesh.publish("load_screen", {"screen": "factorymode"})
+
+# def btn1_release(self):
+# EventMesh.publish("load_screen", {"screen": "factorymode"})
+
+# def btn8_press(self):
+# EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+FactoryModeLocation_screen = lv.obj()
+print("FactoryModeLocation_screen")
+FactoryModeLocation_screen.center()
+FactoryModeLocation_screen.set_size(240, 320)
+FactoryModeLocation_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+# FactoryModeLocation_WIFI_label = lv.label(FactoryModeLocation_screen)
+# FactoryModeLocation_WIFI_label.set_text("WIFI:")
+# FactoryModeLocation_WIFI_label.set_size(240, 120)
+# FactoryModeLocation_WIFI_label.set_pos(0, 0)
+# FactoryModeLocation_WIFI_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+# FactoryModeLocation_WIFI_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+# FactoryModeLocation_CALL_label = lv.label(FactoryModeLocation_screen)
+# FactoryModeLocation_CALL_label.set_text("CALL:")
+# FactoryModeLocation_CALL_label.set_size(240, 100)
+# FactoryModeLocation_CALL_label.set_pos(0, 120)
+# FactoryModeLocation_CALL_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+# FactoryModeLocation_CALL_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+FactoryModeLocation_GNSS_label = lv.label(FactoryModeLocation_screen)
+FactoryModeLocation_GNSS_label.set_text("GNSS:\n")
+FactoryModeLocation_GNSS_label.set_size(240, lv.SIZE.CONTENT)
+FactoryModeLocation_GNSS_label.set_pos(0, 0)
+FactoryModeLocation_GNSS_label.set_long_mode(lv.label.LONG.WRAP)
+FactoryModeLocation_GNSS_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+FactoryModeLocation_GNSS_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+class FactoryModeLocationScreen(Screen):
+ NAME = "FactoryModeLocation"
+ def __init__(self):
+ super().__init__()
+ self.meta = FactoryModeLocation_screen
+ EventMesh.subscribe("PUSH_LOCATION_DATA",self.GET_LOCATION_DATA)
+ self.timer_FactoryModeLocation = osTimer()
+ self.time_count = 0
+ self.time_GNSS = 0
+ self.GNSS_status = 0
+ self.timer_c = 0
+ def initialization(self):
+ FactoryModeLocation_GNSS_label.set_text("GNSS:\n")
+ # FactoryModeLocation_WIFI_label.set_text("WIFI:")
+ # FactoryModeLocation_CALL_label.set_text("CALL:")
+ self.timer_FactoryModeLocation.start(1000, 1, self.timer_FactoryModeLocation_cb)
+ self.time_count = utime.mktime(utime.localtime())
+ self.time_GNSS = 0
+ self.GNSS_status = 0
+ def post_processor_after_initialization(self):
+ #utime.sleep_ms(1000)
+ EventMesh.publish(constants.EVENT.START_LOCATION_TEST) #测试模式
+
+ def timer_FactoryModeLocation_cb(self, *args, **kwargs):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ self.timer_c += 1
+ if self.timer_c >= 7:
+ get_location_flag = EventMesh.publish("get_location_flag")
+ self.timer_c = 0
+ if get_location_flag != None:
+ if(get_location_flag == 0):
+ EventMesh.publish(constants.EVENT.START_LOCATION_TEST) #测试模式
+ self.time_count = utime.mktime(utime.localtime())
+
+ def GET_LOCATION_DATA(self, event, msg):
+ # print("GPS:{}".format(msg[0]))
+ # print("WIFI:{}".format(msg[1]))
+ # print("CALL:{}".format(msg[2]))
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ _DATA = ""
+ time_tmp = utime.mktime(utime.localtime())
+
+
+ if len(msg[0]) > 1 : #GPS
+ GNSS_DATA = "GNSS:------\n"
+ gnss_data = msg[0][0]
+ if gnss_data :
+ GNSS_DATA = GNSS_DATA + "{},{},{}\n".format("A",gnss_data["latitude"],gnss_data["longitude"])
+
+ self.time_GNSS = time_tmp-self.time_count
+ EventMesh.txt_log("test location time:{}".format(self.time_GNSS))
+ self.time_count = utime.mktime(utime.localtime())
+ else:
+
+ GNSS_DATA = GNSS_DATA + "{},{},{}\n".format("V",0,0)
+ _DATA += "定位时间:{};{}秒\n".format(self.time_GNSS,time_tmp-self.time_count)
+
+ GSV_dict = msg[0][1]
+ #print("GET_LOCATION_DATA:{}".format(GSV_dict))
+ if GSV_dict :
+ count = 0
+ try:
+ for j in range(200):
+ for key in GSV_dict :
+
+ if(key != j):
+ continue
+ #print("GSV_dict[key]:len:{}".format(len(GSV_dict[key])))
+ if GSV_dict[key] >= 1 :
+ GNSS_DATA+=" {:<3}:[{:<3}] ".format(key,GSV_dict[key])#:<3 宽度为3左对齐
+ count+=1
+ if count % 2 == 0:
+ GNSS_DATA+="\n"
+
+ if count > 50:
+ break
+ except Exception as e:
+ usys.print_exception(e)
+ #print("GxGSV:{}".format(GNSS_DATA))
+ _DATA += GNSS_DATA
+ #FactoryModeLocation_GNSS_label.set_text(GNSS_DATA)
+ if msg[1] != [] : #WIFI
+ WIFI_len = len(msg[1][1])
+ _DATA += "\nWIFI:------\n"
+ if WIFI_len > 3:
+ WIFI_len = 3
+ for i in range(WIFI_len) :
+ _DATA += "{}".format(msg[1][1][i])
+ if msg[2] != [] :#基站
+ #print("CALL data:".format(msg[2][0]))
+ if len(msg[2]) >= 2 :
+ _DATA += "CALL:------\n{}".format(msg[2][0])
+ #FactoryModeLocation_CALL_label.set_text("CALL:{}".format(msg[2][0]))
+ print("GET_LOCATION_DATA:data:{}".format(_DATA))
+ FactoryModeLocation_GNSS_label.set_text(_DATA)
+ self.timer_c = 0
+ def Close(self):
+ EventMesh.publish(constants.EVENT.CLOSE_LOCATION)
+ self.timer_FactoryModeLocation.stop()
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
\ No newline at end of file
--- /dev/null
+import osTimer
+import lvgl as lv
+import EventMesh
+import osTimer
+import constants
+import ujson
+import ql_fs
+import audio
+from machine import Pin
+from ui import style_font_youyuan_20,style_screen,Screen,style_font_youyuan_20_black,style_img
+import audio
+from machine import Pin
+import utime
+import _thread
+from protocol import ProtoCol,UnicodeHexStr_To_Utf8Str
+import usys
+import log
+Testlog = log.getLogger("WechatLog")
+log.set_output(usys.stdout)
+is_appwechat_log = 0
+def Wechat_log(str):
+ if(is_appwechat_log == 1) :
+ Testlog.info(str)
+
+style_wechat_r_btn = lv.style_t()
+style_wechat_r_btn.init()
+style_wechat_r_btn.set_bg_color(lv.color_make(0x00, 0xff, 0x2a))
+style_wechat_r_btn.set_border_width(0)
+style_wechat_r_btn.set_shadow_opa(0)
+
+
+style_wechat_s_btn = lv.style_t()
+style_wechat_s_btn.init()
+style_wechat_s_btn.set_bg_color(lv.color_make(0xff, 0xff, 0xff))
+style_wechat_s_btn.set_border_width(0)
+style_wechat_s_btn.set_shadow_opa(0)
+
+style_common_bg_rect_btn_pressed = lv.style_t()
+style_common_bg_rect_btn_pressed.init()
+style_common_bg_rect_btn_pressed.set_bg_color(lv.color_make(0x1E, 0x26, 0xff))
+style_common_bg_rect_btn_pressed.set_bg_opa(100)
+style_common_bg_rect_btn_pressed.set_border_width(0)
+style_common_bg_rect_btn_pressed.set_shadow_opa(0)
+
+style_wechat_btn = lv.style_t()
+style_wechat_btn.init()
+style_wechat_btn.set_bg_color(lv.color_make(0x1E, 0x26, 0xff))
+style_wechat_btn.set_border_width(0)
+style_wechat_btn.set_shadow_opa(0)
+
+# -------------------------------------------wechat screen----------------------------------------------------------
+wechat_screen = lv.obj()
+print("wechat_screen")
+wechat_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+wechat_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+wechat_screen_list_screen = lv.obj(wechat_screen)
+wechat_screen_list_screen.set_pos(0, 0)
+wechat_screen_list_screen.set_size(240, 260)
+wechat_screen_list_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+wechat_screen_list_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+
+wechat_press_btn = lv.btn(wechat_screen)
+wechat_press_btn.set_pos(10, 264)
+wechat_press_btn.set_size(220, 56)
+wechat_press_btn.add_style(style_wechat_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+wechat_press_btn.add_style(style_common_bg_rect_btn_pressed, lv.PART.MAIN | lv.STATE.PRESSED)
+wechat_press_btn.set_style_radius(30,0)
+
+wechat_press_label = lv.label(wechat_screen)
+wechat_press_label.set_text("请按住说话")
+wechat_press_label.set_size(240, 38)
+wechat_press_label.set_pos(0,282)
+wechat_press_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+wechat_press_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+wechat_label = lv.label(wechat_screen_list_screen)
+wechat_label.set_pos(0, 140)
+wechat_label.set_size(240, 40)
+wechat_label.set_long_mode(lv.label.LONG.WRAP)
+wechat_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+wechat_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+wechat_press_label_countdown = lv.label(wechat_screen_list_screen)
+wechat_press_label_countdown.set_pos(0, 100)
+wechat_press_label_countdown.set_size(240, 40)
+wechat_press_label_countdown.set_text(" ")
+wechat_press_label_countdown.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+wechat_press_label_countdown.set_long_mode(lv.label.LONG.WRAP)
+wechat_press_label_countdown.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+
+
+
+
+
+class WechatScreen(Screen):
+ NAME = "wechat"
+
+ def __init__(self):
+ super().__init__()
+ self.MXA_MSG = 10
+ self.wechat_recode_list = {}
+ self.wechat_num = 0
+ self.volum_size = 8
+ self.msg_tmp = ""
+ check_txt = ql_fs.path_exists("/ext/static/storage_file/wechat_record.json")
+ if check_txt == True :
+ with open("/ext/static/storage_file/wechat_record.json","r") as fd:#音频文件编号
+ self.wechat_recode_list = ujson.load(fd)
+ if not self.wechat_recode_list:
+ self.wechat_recode_list = {"num":0}
+ self.wechat_num = 0
+ else:
+ b = str("num") in self.wechat_recode_list.keys()
+ if b == True:
+ self.wechat_num = self.wechat_recode_list["num"]
+ else :
+ self.wechat_recode_list = {"num":0}
+ with open("/ext/static/storage_file/wechat_record.json","w",encoding="utf-8") as fd:
+ ujson.dump(self.wechat_recode_list,fd)
+ # if self.wechat_num != 0:
+ # with open("/ext/static/storage_file/wechat_record.json","r",encoding="utf-8") as fd:#音频文件记录
+ # self.wechat_recode_list = ujson.load(fd)#读取每一个amr音频文件的时长ui_setting.py
+
+ self.record_test = audio.Record()
+ self.record_test.gain_set(4,12)
+ self.aud = audio.Audio(0)
+ # self.aud.set_pa(Pin.GPIO29)
+
+
+
+
+
+ self.meta = wechat_screen
+ wechat_press_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.talking_cb(e)),
+ lv.EVENT.LONG_PRESSED, None)
+ wechat_press_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.sending_cb(e)),
+ lv.EVENT.RELEASED, None)
+ self.timer = osTimer()
+ self.second_timer = osTimer()
+ self.play_timer = osTimer()
+
+
+
+ self.startY = 0
+ self.startWidth = 0
+ self.check_json = 0
+ self.wechat_list = lv.obj(wechat_screen_list_screen)
+ self.wechat_list.set_pos(0, 0)
+ self.wechat_list.set_size(240, 261)
+ self.wechat_list.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ self.wechat_list.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+ self.wechat_list.set_flex_flow(lv.FLEX_FLOW.COLUMN)#自动排成一列对齐
+ #建立控件
+ self.wechat_list_dict = []
+ for i in range(self.MXA_MSG):
+ wechat_obj = lv.obj(self.wechat_list)
+ wechat_obj.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+ wechat_btn = lv.btn(wechat_obj)
+ wechat_btn.add_style(style_wechat_s_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+ _btn_label1 = lv.label(wechat_btn)
+ _btn_label1.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+ _btn_label2 = lv.label(wechat_btn)
+ _btn_img = lv.img(wechat_btn)
+ wechat_obj.add_flag(lv.obj.FLAG.HIDDEN)
+ wechat_btn.add_flag(lv.obj.FLAG.CLICKABLE)
+ wechat_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.play_label_cb(e)),
+ lv.EVENT.CLICKED, None)
+ self.wechat_list_dict.append({"num":i,"wechat_obj":wechat_obj,"wechat_btn":wechat_btn,"_btn_label1":_btn_label1,"_btn_label2":_btn_label2,"_btn_img":_btn_img})
+
+ EventMesh.subscribe("wechat_updata_list_show", self.wechat_updata_list_show)
+ EventMesh.subscribe("get_wechat_data", self.get_wechat_data)
+ EventMesh.subscribe("set_wechat_data", self.set_wechat_data)
+
+ EventMesh.subscribe("get_aduio_state", self.get_aduio_state)
+ EventMesh.subscribe("get_send_state", self.get_send_state)
+
+ self.countdown = 1
+ self.count_img = 0
+ self.paay_btn_count = 0
+ self.paay_btn_old_count = 99999
+ self.play_text = None
+ self.play_sec = 0
+ self.sec_num = 0
+ self.countdown_old = 0
+ self.press_state = 0
+ self.ble_send = 0
+ self.wechat_show = 0
+ self.wechat_show_list = 0
+ #self.old_num = self.wechat_num
+
+
+ def initialization(self):
+ Wechat_log("initialization1")
+ self.aud.setVolume(11)#设置最大声录音
+ wechat_label.set_text(" ")
+ wechat_label.add_flag(lv.obj.FLAG.HIDDEN)
+ wechat_press_label_countdown.add_flag(lv.obj.FLAG.HIDDEN)
+ self.wechat_list.clear_flag(lv.obj.FLAG.HIDDEN)
+ #读取json文件中的字典放到self.phonebook中
+ #创建btn
+ #self.updata_list_show(1)
+ EventMesh.publish("publish_message_event_ui",{"func":self.updata_list_show,"data":2})
+ utime.sleep_ms(50)
+ EventMesh.publish("publish_message_event_ui",{"func":self.updata_list_show,"data":0})
+ self.count_img = 0
+ self.play_sec = 0
+ self.ble_send = 0
+ # utime.sleep(1)
+ # for j in range( 200):
+ # self.updata_list_show(1)
+ Wechat_log("initialization2")
+
+ def get_wechat_data(self,event, msg):
+ return [self.MXA_MSG ,self.wechat_recode_list]
+
+ def set_wechat_data(self, event, msg):
+ Wechat_log("set_wechat_data1")
+ self.MXA_MSG = msg[0]
+ self.wechat_recode_list = msg[1]
+ self.wechat_num = self.wechat_recode_list["num"]
+ with open("/ext/static/storage_file/wechat_record.json","w",encoding="utf-8") as fd:
+ ujson.dump(self.wechat_recode_list,fd)
+ #写编号
+ Wechat_log("set_wechat_data2:{} ".format(self.wechat_num))
+
+
+ def reciving(self,e):
+ Wechat_log("reciving1")
+ #self.updata_list_show(0)
+ EventMesh.publish("publish_message_event_ui",{"func":self.updata_list_show,"data":0})
+ Wechat_log("reciving2")
+ #接收到新的消息,刷新界面
+ def wechat_updata_list_show(self, event, msg):
+ Wechat_log("wechat_updata_list_show1")
+ if (self.wechat_list.has_flag(lv.obj.FLAG.HIDDEN)) == False:
+ # wechat_label.clear_flag(lv.obj.FLAG.HIDDEN)
+ # wechat_label.set_text("接收中")
+ #self.updata_list_show(2)
+ EventMesh.publish("publish_message_event_ui",{"func":self.updata_list_show,"data":2})
+ self.timer.start(200, 0, self.reciving)
+ self.paay_btn_count -= 1
+ # if self.paay_btn_count <= 0:
+ # self.paay_btn_count = 0
+ if self.paay_btn_count >= 0:
+ self.paay_btn_old_count = self.paay_btn_count
+ Wechat_log("wechat_updata_list_show2")
+ # def handle_message_event(self,data):
+ # if data[0] == "updata_list_show":
+ # self.updata_list_show(data[1])
+ # return 1
+
+ #index=0 不改变列表控件显示到lcd上;index=2只更新列表控件,不显示;index=1更新列表并显示控件
+ def updata_list_show(self,index):
+ Wechat_log("updata_list_show1")
+ global wechat_screen_list_screen
+ if self.press_state != 1:
+ if self.wechat_num != 0:
+ if index == 0:
+ self.wechat_list.clear_flag(lv.obj.FLAG.HIDDEN)
+ wechat_label.add_flag(lv.obj.FLAG.HIDDEN)
+ elif index == 2 or index == 1:
+
+ #读取json文件中的键作为label文本;
+ Wechat_log("self.wechat_recode_list:{}".format(self.wechat_recode_list))
+
+ if index == 2:
+ self.wechat_list.add_flag(lv.obj.FLAG.HIDDEN)
+ j = 1
+ if len(self.wechat_recode_list)-1 == self.MXA_MSG:
+ j = self.wechat_num+1
+ wechat_btn_end = 0
+ for i in range(self.MXA_MSG):
+ if j > self.MXA_MSG:
+ j = 1
+ key = "%02d"%(j)
+ if j > len(self.wechat_recode_list) -1:
+ self.wechat_list_dict[i]["wechat_obj"].add_flag(lv.obj.FLAG.HIDDEN)
+ continue
+ j+=1
+
+ #Wechat_log("wechat_list_dict:num:{}".format(self.wechat_list_dict[i]["num"]))
+ value = self.wechat_recode_list[key]
+
+ self.startY = 64*i
+
+ if value.find("S:") != -1 or value.find("R:") != -1:
+ self.msg_tmp = value[2:]
+ self.msg_tmp = int(self.msg_tmp)
+ self.startWidth = 55+self.msg_tmp*10
+
+ elif value.find("T:") != -1:#文字显示
+ self.msg_tmp = value[2:]
+ self.startWidth = 230
+
+ #wechat_btn = lv.btn(self.wechat_list)
+ # if value.find("R:") != -1:self.wechat_list_dict[i]
+ self.wechat_list_dict[i]["wechat_obj"].set_size(240,lv.SIZE.CONTENT)
+ if value.find("R:") != -1 or value.find("T:") != -1 :#显示文字:
+ if value.find("T:") != -1:
+ self.wechat_list_dict[i]["wechat_btn"].set_size(self.startWidth,lv.SIZE.CONTENT)
+ else:
+ self.wechat_list_dict[i]["wechat_btn"].set_size(self.startWidth,62)
+
+ self.wechat_list_dict[i]["wechat_btn"].set_pos(10,0 )
+ #self.wechat_list_dict[i]["wechat_btn"].add_style(style_wechat_s_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+ self.wechat_list_dict[i]["wechat_btn"].set_style_bg_color(lv.color_make(0xff, 0xff, 0xff), lv.PART.MAIN | lv.STATE.DEFAULT)
+ elif value.find("S:") != -1 :
+ self.wechat_list_dict[i]["wechat_btn"].set_size(self.startWidth,62)
+ self.wechat_list_dict[i]["wechat_btn"].set_pos(230-self.startWidth,0 )
+ #for k in range(100):
+ #self.wechat_list_dict[i]["wechat_btn"].add_style(style_wechat_r_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+ self.wechat_list_dict[i]["wechat_btn"].set_style_bg_color(lv.color_make(0x00, 0xff, 0x2a), lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ #_btn_label1 = lv.label(wechat_btn)
+ if value.find("R:") != -1:
+ self.wechat_list_dict[i]["_btn_label1"].set_size(0, 0)
+ self.wechat_list_dict[i]["_btn_label1"].set_pos(35, 18)
+ self.wechat_list_dict[i]["_btn_label1"].set_text(str(self.msg_tmp)+'\"')
+
+ elif value.find("S:") != -1:
+ self.wechat_list_dict[i]["_btn_label1"].set_size(0, 0)
+ self.wechat_list_dict[i]["_btn_label1"].set_pos(self.startWidth-78, 18)
+ self.wechat_list_dict[i]["_btn_label1"].set_text(str(self.msg_tmp)+'\"')
+ elif value.find("T:") != -1:
+ self.wechat_list_dict[i]["_btn_label1"].set_size(216, lv.SIZE.CONTENT)
+ self.wechat_list_dict[i]["_btn_label1"].set_pos(0, 0)
+ print("self.msg_tmp:{}".format(self.msg_tmp))
+ self.msg_tmp = self.msg_tmp.replace(':',':\n',1)
+ print("self.msg_tmp:{}".format(self.msg_tmp))
+ self.wechat_list_dict[i]["_btn_label1"].set_text(str(self.msg_tmp))
+ self.wechat_list_dict[i]["_btn_label1"].set_long_mode(lv.label.LONG.WRAP)
+ #self.wechat_list_dict[i]["_btn_label1"].add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+ #_btn_label2 = lv.label(wechat_btn)
+ self.wechat_list_dict[i]["_btn_label2"].set_size(0, 0)
+ if value.find("R:") != -1:
+ self.wechat_list_dict[i]["_btn_label2"].set_text('R:'+key)
+ elif value.find("S:") != -1:
+ self.wechat_list_dict[i]["_btn_label2"].set_text('S:'+key)
+ elif value.find("T:") != -1:
+ self.wechat_list_dict[i]["_btn_label2"].set_text('T:'+key)
+ if value.find("R:") != -1 or value.find("S:") != -1:
+ #_btn_img = lv.img(wechat_btn)
+ self.wechat_list_dict[i]["_btn_img"].set_size(30, 30)
+ if value.find("R:") != -1:
+ self.wechat_list_dict[i]["_btn_img"].set_pos(5, 10)
+ self.wechat_list_dict[i]["_btn_img"].set_src("E:/static/APP/wechat/R_3.png")
+ elif value.find("S:") != -1:
+ self.wechat_list_dict[i]["_btn_img"].set_pos(self.startWidth-50, 10)
+ self.wechat_list_dict[i]["_btn_img"].set_src("E:/static/APP/wechat/S_3.png")
+ self.wechat_list_dict[i]["_btn_img"].add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ self.wechat_list_dict[i]["_btn_img"].clear_flag(lv.obj.FLAG.HIDDEN)
+ else :
+ self.wechat_list_dict[i]["_btn_img"].add_flag(lv.obj.FLAG.HIDDEN)
+ self.wechat_list_dict[i]["wechat_obj"].clear_flag(lv.obj.FLAG.HIDDEN)
+
+ wechat_btn_end = i
+ self.wechat_list_dict[wechat_btn_end]["wechat_obj"].scroll_to_view(lv.ANIM.OFF)
+
+ # bottom_btn1 = self.wechat_list.get_child(-1)
+ # bottom_btn1.scroll_to_view(lv.ANIM.ON)
+ Wechat_log("updata_list_show2")
+
+ def talking_cb(self,e):
+ Wechat_log("talking_cb1")
+ EventMesh.publish("publish_message_event_ui",{"func":self.talking,"data":e})
+ Wechat_log("talking_cb2")
+ #按下录音
+ def talking(self,e):
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#有卡时触发sos报警 无卡时自动关机
+ Wechat_log("talking1")
+ self.play_timer.stop()
+ self.aud.stop()
+ self.wechat_list.add_flag(lv.obj.FLAG.HIDDEN)#隐藏列表选项方框
+ self.countdown = 1
+ wechat_label.clear_flag(lv.obj.FLAG.HIDDEN)
+ wechat_label.set_text("松开发送")
+ wechat_press_label_countdown.clear_flag(lv.obj.FLAG.HIDDEN)
+ wechat_press_label_countdown.set_text("{}S".format(str(self.countdown)))
+
+
+ #self.updata_list_show(2)#不需要显示语音列表
+ #按下说话
+ if self.wechat_num >= self.MXA_MSG:
+ self.wechat_num = 0
+ self.wechat_num += 1
+ self.wechat_show = self.wechat_num
+ self.wechat_recode_list["num"] = self.wechat_num
+ Wechat_log("talking1.0")
+ self.record_test.start("/ext/static/storage_file/{}.amr".format(self.wechat_num),16)
+ self.second_timer.start(1000, 1, self.reduce_second)
+ self.press_state = 1
+ self.ble_send = 1
+ #松开发送
+ Wechat_log("talking2")
+ else:
+ EventMesh.publish("load_screen", {"screen": "no_sim_popup_screen"})
+
+
+ def sending_cb(self,e):
+ if self.press_state == 1:
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#有卡时触发sos报警 无卡时自动关机
+ Wechat_log("sending_cb1")
+ EventMesh.publish("publish_message_event_ui",{"func":self.sending,"data":e})
+ #self.sending(e)
+ Wechat_log("sending_cb2")
+ else:
+ self.press_state = 0
+ EventMesh.publish("load_screen", {"screen": "no_sim_popup_screen"})
+ else:
+ pass
+
+ #松手0.2秒后显示
+ def hide_label(self,*args):
+ Wechat_log("hide_label1")
+ if self.ble_send != 1:
+ wechat_label.add_flag(lv.obj.FLAG.HIDDEN)
+ wechat_label.set_text(" ")
+ #self.updata_list_show(0)
+ EventMesh.publish("publish_message_event_ui",{"func":self.updata_list_show,"data":0})
+ Wechat_log("hide_label2")
+ #松开发送
+ def sending(self,e):
+ Wechat_log("sending1")
+ if self.press_state == 1:
+ # wechat_label.clear_flag(lv.obj.FLAG.HIDDEN)
+ # wechat_label.set_text("发送中")
+ wechat_press_label_countdown.add_flag(lv.obj.FLAG.HIDDEN)
+ wechat_press_label_countdown.set_text(" ")
+
+ if self.countdown >= 15:
+ self.countdown = 15
+ #松开发送数据
+ #num.txt为记录的最后编号
+ #record.json文件里的json元素为记录编号,json键值:"S:"开头为发送的语音,"R:"为接收的语音,后面跟随语音长度;"T:"为接收的文字信息。
+
+ #写序号
+ self.record_test.stop() #停止錄音
+ self.second_timer.stop() #停止计时器
+ self.countdown_old = self.countdown
+ # Wechat_log("self.countdown :{} self.wechat_num:{} self.wechat_recode_list:{} self.wechat_show:{}".format(self.countdown,self.wechat_num,self.wechat_recode_list,self.wechat_show))
+ self.wechat_recode_list["%02d"%(self.wechat_show)] = "S:{}".format(str(self.countdown))
+ self.wechat_recode_list["num"] = self.wechat_show
+
+ #读音频amr二进制数据
+
+ #修改或添加词典键值
+ self.press_state = 0
+ self.ble_send = 0
+ ##隐藏显示文本 显示列表显示框
+ EventMesh.publish("publish_message_event_ui",{"func":self.updata_list_show,"data":2})
+ self.timer.start(200, 0, self.hide_label)
+ with open("/ext/static/storage_file/wechat_record.json","w+",encoding="utf-8") as fd:
+ ujson.dump(self.wechat_recode_list,fd)
+ Wechat_log("send wechat data!!!!!!!!!!!!!!!!!!!!!")
+ path = "/ext/static/storage_file/{}.amr".format(self.wechat_show)
+ with open(path,"rb") as fd:
+ buf = bytearray(ql_fs.path_getsize(path))
+ fd.readinto(buf)
+ senddata = [self.countdown_old,buf]
+ EventMesh.publish(constants.PROTOCOL.TKS_SEND,senddata)
+
+
+ Wechat_log("sending2")
+
+ def play_img_cb(self,*args):
+ Wechat_log("play_img_cb1")
+ EventMesh.publish("publish_message_event_ui",{"func":self.play_img,"data":args})
+ Wechat_log("play_img_cb2")
+ def play_img(self,*args):
+ Wechat_log("play_img1")
+ if self.paay_btn_count < 0 or self.paay_btn_count>= self.MXA_MSG:
+ self.play_timer.stop()
+ return
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ # Wechat_log("self.count_img :{} self.play_text:{}".format(self.count_img,self.play_text))
+ self.count_img+=1
+ if self.count_img > 3:
+ self.count_img = 1
+
+ text = self.wechat_list_dict[self.paay_btn_count]["_btn_label2"].get_text()
+ self.play_text = text[0:2] #区分左右喇叭动画显示 "R":左边 "S:"右边 "T:":左边
+ if self.play_text == "R:":
+ self.wechat_list_dict[self.paay_btn_count]["_btn_img"].set_src("E:/static/APP/wechat/R_{}.png".format(self.count_img))
+ elif self.play_text == "S:":
+ self.wechat_list_dict[self.paay_btn_count]["_btn_img"].set_src("E:/static/APP/wechat/S_{}.png".format(self.count_img))
+
+ self.sec_num+=1
+ if self.sec_num % 2 == 0:
+ # Wechat_log("self.play_sec:{}".format(self.play_sec))
+ if self.play_sec > 0:
+ self.play_sec -= 1
+ if self.play_sec == 0:
+ self.play_timer.stop()
+ if self.play_text == "R:":
+ self.wechat_list_dict[self.paay_btn_count]["_btn_img"].set_src("E:/static/APP/wechat/R_3.png")
+ elif self.play_text == "S:":
+ self.wechat_list_dict[self.paay_btn_count]["_btn_img"].set_src("E:/static/APP/wechat/S_3.png")
+ get_play = EventMesh.publish("get_audio_state")
+ if get_play != None:
+ if get_play == 0:
+ self.play_timer.stop()
+ if self.play_text == "R:":
+ self.wechat_list_dict[self.paay_btn_count]["_btn_img"].set_src("E:/static/APP/wechat/R_3.png")
+ elif self.play_text == "S:":
+ self.wechat_list_dict[self.paay_btn_count]["_btn_img"].set_src("E:/static/APP/wechat/S_3.png")
+ Wechat_log("play_img2")
+ def play_label_cb(self,e): #lvgl按钮回调
+ Wechat_log("play_label_cb1")
+ #Wechat_log("play_label_cb.0:e:{}".format(e.get_code()))
+ paay_btn = e.get_target()
+ for i in range(self.MXA_MSG):
+ if(self.wechat_list_dict[i]["wechat_btn"] == paay_btn):
+ Wechat_log("play_label_cb:wechat_btn = e.get_target():i:{}".format(i))
+ self.paay_btn_count = i
+ break
+ EventMesh.publish("publish_message_event_ui",{"func":self.play_label,"data":paay_btn})#发到另外一个线程执行更改ui
+ Wechat_log("play_label_cb2")
+ #utime.sleep_ms(1000)
+ #点击播放
+ def play_label(self,play_btn):#另外一个线程实际执行的地方
+ Wechat_log("play_label1")
+ self.sec_num = 0
+ # Wechat_log("play_label self.play_text:{}".format(self.play_text))
+ if self.paay_btn_old_count <= self.MXA_MSG: #停止东画还原到3图标
+ text = self.wechat_list_dict[self.paay_btn_old_count]["_btn_label2"].get_text()
+ self.play_text = text[0:2]
+ if self.play_text == "R:":
+ self.wechat_list_dict[self.paay_btn_old_count]["_btn_img"].set_src("E:/static/APP/wechat/R_3.png")
+ elif self.play_text == "S:":
+ self.wechat_list_dict[self.paay_btn_old_count]["_btn_img"].set_src("E:/static/APP/wechat/S_3.png")
+
+ self.count_img = 0 #喇叭动画显示的数量
+
+
+ text = self.wechat_list_dict[self.paay_btn_count]["_btn_label2"].get_text()
+ self.play_text = text[0:2] #区分左右喇叭动画显示 "R":左边 "S:"右边 "T:":左边
+ Wechat_log("self.play_text2:{}".format(self.play_text))
+ play_img_s = self.wechat_list_dict[self.paay_btn_count]["_btn_label1"].get_text()
+ play_img_s = play_img_s.split('"')
+ play_img_s = play_img_s[0]#获取实际显示秒数 '"'前面实际的秒数
+
+ if self.play_text == "R:" or self.play_text == "S:":
+ if self.play_text == "R:":
+ self.play_sec = 15
+ else:
+ self.play_sec = int(play_img_s)
+
+ self.play_timer.start(500, 1, self.play_img_cb)
+ # Wechat_log("play_label self.count_img :{} self.play_text:{} play_img_s:{} self.play_sec:{}".format(self.count_img,self.play_text,play_img_s,self.play_sec))
+
+ num_amr = self.wechat_list_dict[self.paay_btn_count]["_btn_label2"].get_text()
+ num_amr = num_amr.split(':')
+ num_amr = num_amr[1]#获取实际秒数
+ i = int(num_amr)
+ # Wechat_log("num:{}".format(i))
+ if self.play_text == "R:" or self.play_text == "S:":#过滤掉文字显示 不需要播放音频文件
+ self.aud = audio.Audio(0)
+ self.aud.stop()#
+ self.aud.play(1, 1, '/ext/static/storage_file/{}.amr'.format(i)) #文件名前面要加上路径
+ self.paay_btn_old_count = self.paay_btn_count
+ Wechat_log("play_label2")
+
+ #获取是否在录音
+ def get_aduio_state(self, event, msg):
+ return self.press_state
+
+ def get_send_state(self, event, msg):
+ return self.ble_send
+
+
+ def Close(self):
+ Wechat_log("Close1")
+ self.play_timer.stop()
+ self.record_test.stop() #停止錄音
+ self.second_timer.stop() #停止计时器
+ self.aud.stop()
+ num = EventMesh.publish("get_volum_size")
+ if num == None:
+ num = 8
+ self.aud.setVolume(num)#恢复原始音量
+ Wechat_log("Close2")
+
+ def reduce_second(self,*args):
+ if self.countdown < 15:
+ self.countdown += 1
+ else:
+ self.countdown = 15
+ self.sending_cb(0)
+
+ if self.countdown >= 15:
+ self.countdown = 15
+ wechat_press_label_countdown.set_text("{}S".format(str(self.countdown)))
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+#微聊弹窗
+
+wechat_popup_screen = lv.obj()
+print("wechat_popup_screen")
+wechat_popup_screen.center()
+wechat_popup_screen.set_size(240, 320)
+wechat_popup_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+wechat_popup_title = lv.label(wechat_popup_screen)
+wechat_popup_title.set_pos(0, 150)
+wechat_popup_title.set_size(240, 40)
+wechat_popup_title.set_text("你有新的微聊消息")
+wechat_popup_title.set_long_mode(lv.label.LONG.WRAP)
+wechat_popup_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+wechat_popup_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+class NewWechatPopupScreen(Screen):
+ NAME = "wechat_popup"
+ def __init__(self):
+ super().__init__()
+ self.meta = wechat_popup_screen
+ self.meta_type = "popup"
+ def done_left_to_right(self):
+ # EventMesh.publish("wechat_updata_list_show")
+ EventMesh.publish("return_prev_screen")
+
+ def done_right_to_left(self):
+ # EventMesh.publish("wechat_updata_list_show")
+ EventMesh.publish("return_prev_screen")
+
+ def done_bottom_to_top(self):
+ # EventMesh.publish("wechat_updata_list_show")
+ EventMesh.publish("return_prev_screen")
+
+ def done_top_to_bottom(self):
+ # EventMesh.publish("wechat_updata_list_show")
+ EventMesh.publish("return_prev_screen")
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+ def done_click(self):
+ # EventMesh.publish("wechat_updata_list_show")
+ EventMesh.publish("load_screen", {"screen": "wechat"})
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
+
+
+
+
--- /dev/null
+from common import Abstract
+import machine
+import osTimer
+from misc import PowerKey
+import EventMesh
+from machine import Pin
+from machine import ExtInt
+from misc import Power
+import constants
+import _thread
+from queue import Queue
+import usys
+class BtnDevice(Abstract):
+
+ def __init__(self, tp=None):
+ self.pk = PowerKey()
+ self.__pwk_timer = osTimer()
+ self.__key22_timer = osTimer()
+
+ # self.keypad = machine.KeyPad(4, 1)
+ self.__PowerDownTimeOut = 5000
+ self.__tp = tp
+ self.pwk_press = 0
+ self.pwk_count = 0
+ self.GPIO26_status = 1
+ self.GPIO26_flag = 0
+ self.powerKey_status = 0
+
+ self.GPIO22_status = 1
+ self.key22_press = 0
+ self.sos_key = 0
+ self.key22_count = 0
+ self.key22_press_count = 0
+ self.GPIO22_flag = 0
+ self.pin_timer = osTimer()
+ self.btnInfo_queue = Queue()
+ _thread.stack_size(10*1024+192)
+ _thread.start_new_thread(self.btnInfo_queue_thread, ())
+ _thread.stack_size(8*1024)
+
+ EventMesh.subscribe("publish_message_event_btnInfo",self.publish_message_event_btnInfo)
+
+
+ def btnInfo_queue_thread(self):
+ while True:
+ data = self.btnInfo_queue.get()
+ #EventMesh.debug_log("Info_queue:data = {}".format(data))
+ if data != None:
+ try:
+ data["func"](data["data"])
+ except Exception as e:
+ EventMesh.debug_log("btnInfo_queue:ERROR:{}".format(e))
+ usys.print_exception(e)
+ def publish_message_event_btnInfo(self,event,msg):
+ self.btnInfo_queue.put(msg)
+
+ def post_processor_after_instantiation(self):
+ # self.keypad.init()
+ # self.keypad.set_callback(self.key_callback)
+ self.pk.powerKeyEventRegister(self.powerKey_callback)
+ if self.__tp:
+ self.__tp.set_callback(self.__ui_callback)
+
+ self.extint = ExtInt(ExtInt.GPIO26, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_DISABLE, self.pwk_extint_cb)
+ self.extint.enable()
+
+ self.sos_key = ExtInt(ExtInt.GPIO22, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.sos_extint_cb)
+ self.sos_key.enable()
+
+ def publish_call2key_btn_event_cb(self, *args, **kwargs):
+ EventMesh.publish("publish_message_event_btnInfo",{"func":self.soaKey_press_cb,"data":0})
+
+ def sos_extint_cb(self,args):#call 2
+ # self.GPIO22_status = self.sos_key.read_level()
+ self.GPIO22_status = int(args[1])
+ if self.GPIO22_status == 0:
+ self.GPIO22_status = 1
+ else:
+ self.GPIO22_status = 0
+ pass
+ # EventMesh.debug_log('key17_extint_cb',args,self.KeyCall2_status,self.WeChatKey_status,self.GPIO26_status,self.KeyCall1_status,self.sosKey_status) # args[0]:gpio号 args[1]:上升沿或下降沿
+ if self.GPIO22_status == 0:#按下
+ if self.key22_press == 0 :
+ self.__key22_timer.stop()
+ self.key22_count = 0
+ self.key22_press = 1
+ self.GPIO22_flag = 0
+ self.__key22_timer.start(100, 1, self.publish_call2key_btn_event_cb)
+
+
+ def soaKey_press_cb(self, data):
+ '''KEY2:联动屏幕右下角或返回键长按关机'''
+ if self.key22_press == 1 :
+ self.key22_count += 1
+
+ if self.key22_count >= 5000//100:
+ if self.GPIO22_flag == 0:
+ self.GPIO22_flag = 1
+
+ EventMesh.publish("btn8_long_press")
+ return
+ if self.GPIO22_status == 1:#松开
+ self.__key22_timer.stop()
+ self.key22_count = 0
+ self.key22_press = 0
+ self.GPIO22_flag = 0
+ return
+ if self.GPIO22_status == 1:#松开
+ self.__key22_timer.stop()
+ self.key22_count = 0
+ self.key22_press = 0
+ self.GPIO22_flag = 0
+ EventMesh.publish("btn1_press")
+
+
+ def pwk_extint_cb(self,args):
+ #print('### interrupt {} '.format(args)) # args[0]:gpio号 args[1]:上升沿或下降沿
+
+ #print('==pwr:', status)# 0 1 0
+ self.GPIO26_status = self.extint.read_level()
+ #print("1GPIO_extint_cb:self.GPIO26_status:{} self.pwk_press:{} args:{}".format(self.GPIO26_status,self.pwk_press,args))
+ if self.GPIO26_status == 0:#按下
+ if(self.pwk_press == 0) :
+ self.pwk_press = 1
+ self.key22_count = 0
+ self.key22_press = 0
+ self.key22_press_count = 0
+ self.GPIO22_flag = 0
+ self.__pwk_timer.start(100, 1, self.pwk_press_cb)
+ print("1GPIO_extint_cb:self.__pwk_timer.start!!!!\n")
+ def pwk_press_cb(self, *args):
+ '''KEY2:联动屏幕右下角或返回键长按关机'''
+ if self.pwk_press == 1 :
+ #print("3pwk_press_cb:self.pwk_count:{} self.GPIO26_status:{}".format(self.pwk_count,self.GPIO26_status))
+ self.pwk_count += 1
+ #
+ if(self.pwk_count >= 1): #防抖100ms
+ if self.pwk_count > (15000//100): #长按
+ self.pwk_count = 0
+ self.pwk_press = 0
+ self.__pwk_timer.stop()
+ self.GPIO26_flag = 0
+ # print("power end")
+ Power.powerDown()
+
+ return
+ # elif self.pwk_count > (self.__PowerDownTimeOut//100): #长按
+ # if self.GPIO26_flag == 0:
+ # self.GPIO26_flag = 1
+ # EventMesh.publish("btn8_long_press")
+ # return
+ # if self.GPIO26_status == 1:#松开
+ # self.__pwk_timer.stop()
+ # self.pwk_count = 0
+ # self.pwk_press = 0
+ # self.GPIO26_flag = 0
+ # return
+ if self.GPIO26_status == 1:#松开
+ self.__pwk_timer.stop()
+ self.pwk_count = 0
+ self.pwk_press = 0
+ self.GPIO26_flag = 0
+ EventMesh.publish("btn8_press")
+
+
+
+ def __ui_callback(self, para):
+ # print("para = {}".format(para))
+ if para == 0:
+ EventMesh.publish("done_left_to_right")
+ #print("<-")
+ elif para == 1:
+ EventMesh.publish("done_right_to_left")
+ #print("->")
+ elif para == 2:
+ EventMesh.publish("done_bottom_to_top")
+ #print("^")
+ elif para == 3:
+ EventMesh.publish("done_top_to_bottom")
+ #print("V")
+ elif para == 4:
+ EventMesh.publish("done_return")
+ #print("return")
+ elif para == 5:
+ EventMesh.publish("done_click")
+ #print("CLICK")
+ elif para == 6:
+ EventMesh.publish("done_press")
+ #print("press")
+ elif (para == 6):
+ EventMesh.publish("done_error")
+ #print("error")
+
+ def key_callback(self, l_list):
+ print("key_callback:",str(l_list))
+ if l_list[0] == 1:
+ # 马达震动预留
+ pass
+ if (l_list[1] == 3) and (l_list[2] == 0):
+ if l_list[0] == 1:
+ #self.pwk_press = 0
+ EventMesh.publish("btn1_press")
+ else:
+ pass
+ # EventMesh.publish("btn1_press")
+
+
+
+
+ def powerKey_callback(self, status):
+ print('==pwr:', status)# 0 1 0
+ self.powerKey_status = status
+ if self.pwk_press == 1: #按按钮时不处理
+ return
+
+
+
+
+ def start(self):
+ self.post_processor_after_instantiation()
--- /dev/null
+"""
+// ic type: cst8xx
+// proj name: CSW_2312310_CST816D_COB_DWS_KP818_AKL_G5_K5.hex
+// check sum: 0xedcc
+// create time: 2024/1/4 11:21:21
+"""
+
+app_bin_816d = [
+0x00, 0x00, 0x00, 0x3c, 0xcc, 0xed,
+0x02, 0x2d, 0x1b, 0x75, 0x91, 0xcc, 0x75, 0x91, 0x00, 0x32, 0x32, 0x22, 0x02, 0x00, 0x03, 0x02,
+0x30, 0x6b, 0x85, 0x09, 0x82, 0x85, 0x08, 0x83, 0x75, 0xf0, 0x09, 0xe5, 0x25, 0x02, 0x10, 0x59,
+0x00, 0x02, 0x33, 0xac, 0xe4, 0x7b, 0x02, 0xfa, 0xf9, 0xf8, 0xaf, 0x00, 0xae, 0x00, 0xad, 0x00,
+0xac, 0x00, 0x12, 0x0f, 0x42, 0xef, 0x25, 0x00, 0xff, 0xee, 0x35, 0x00, 0xfe, 0xed, 0x35, 0x00,
+0xfd, 0xec, 0x35, 0x00, 0xfc, 0xab, 0x00, 0xaa, 0x00, 0xa9, 0x00, 0xa8, 0x00, 0x12, 0x0f, 0x42,
+0xef, 0x24, 0xe0, 0xfb, 0xee, 0x34, 0xff, 0xfa, 0xed, 0x34, 0xff, 0xf9, 0xec, 0x34, 0xff, 0xf8,
+0x85, 0x44, 0x82, 0x85, 0x43, 0x83, 0x22, 0x74, 0x1c, 0x93, 0x24, 0x64, 0xff, 0xe4, 0x33, 0xfe,
+0xe4, 0xfc, 0xfd, 0x12, 0x0e, 0xb7, 0xe4, 0x7b, 0x64, 0xfa, 0xf9, 0xf8, 0x12, 0x0f, 0x42, 0x8f,
+0x00, 0x8e, 0x00, 0x8d, 0x00, 0x8c, 0x00, 0xae, 0x00, 0xaf, 0x00, 0xab, 0x00, 0xaa, 0x00, 0xa9,
+0x00, 0xa8, 0x00, 0xe4, 0xfc, 0xfd, 0xc3, 0x02, 0x0f, 0xd4, 0x78, 0x6b, 0xe6, 0xff, 0x24, 0x0d,
+0xf8, 0xe4, 0xf2, 0xa8, 0x07, 0xe8, 0x24, 0x16, 0xf8, 0xe4, 0xf2, 0x08, 0xf2, 0xa8, 0x07, 0xe8,
+0x24, 0x18, 0xf8, 0xe4, 0xf2, 0x08, 0xf2, 0xef, 0x04, 0xf9, 0x7a, 0x00, 0x7b, 0xfe, 0xef, 0x24,
+0x2b, 0xf8, 0x7c, 0x00, 0x7d, 0xfe, 0x7e, 0x00, 0x7f, 0x04, 0x12, 0x0c, 0x68, 0x78, 0x6b, 0xe6,
+0xff, 0x24, 0x05, 0xf8, 0xe4, 0xf2, 0xef, 0x04, 0xf9, 0x7a, 0x00, 0x7b, 0xfe, 0xef, 0x24, 0x07,
+0x7f, 0x06, 0xf8, 0x7c, 0x00, 0x7d, 0xfe, 0x7e, 0x00, 0x02, 0x0c, 0x68, 0xeb, 0x25, 0xe0, 0x25,
+0xe0, 0x24, 0x61, 0xf8, 0xe2, 0xfe, 0x08, 0xe2, 0xff, 0x22, 0xe6, 0xff, 0x24, 0x2b, 0xf8, 0xe2,
+0xfc, 0x08, 0xe2, 0xfd, 0xa8, 0x07, 0xe8, 0x04, 0xf8, 0xec, 0xf2, 0x08, 0xed, 0xf2, 0x78, 0x6b,
+0xe6, 0xff, 0x24, 0x2d, 0xf8, 0xe2, 0xfc, 0x08, 0xe2, 0xfd, 0xa8, 0x07, 0xe8, 0x22, 0xab, 0x00,
+0xaa, 0x00, 0xa9, 0x00, 0xa8, 0x00, 0x93, 0xff, 0xe4, 0xfc, 0xfd, 0x12, 0x0e, 0xb7, 0xa8, 0x04,
+0xa9, 0x05, 0xaa, 0x06, 0xab, 0x07, 0x22, 0xab, 0x00, 0xaa, 0x00, 0xa9, 0x00, 0xe5, 0x00, 0x75,
+0xf0, 0x02, 0xa4, 0xf5, 0x82, 0x85, 0xf0, 0x83, 0x02, 0x0d, 0xe6, 0x74, 0x1d, 0x93, 0x24, 0x64,
+0xff, 0xe4, 0x33, 0xfe, 0xe4, 0xfc, 0xfd, 0x12, 0x0e, 0xb7, 0xe4, 0x7b, 0x64, 0xfa, 0xf9, 0xf8,
+0x12, 0x0f, 0x42, 0x8f, 0x00, 0x8e, 0x00, 0x8d, 0x00, 0x8c, 0x00, 0xae, 0x00, 0xaf, 0x00, 0xab,
+0x00, 0xaa, 0x00, 0xa9, 0x00, 0xa8, 0x00, 0xe4, 0xfc, 0xfd, 0xc3, 0x02, 0x0f, 0xd4, 0xaf, 0x00,
+0xef, 0x33, 0x95, 0xe0, 0xfe, 0xef, 0x25, 0xe0, 0xff, 0xee, 0x33, 0xfe, 0x74, 0xb5, 0x2f, 0xf5,
+0x82, 0x74, 0x00, 0x3e, 0xf5, 0x83, 0x22, 0x78, 0x6d, 0xa6, 0x07, 0x78, 0x70, 0xe6, 0x78, 0x6e,
+0xf6, 0x90, 0x00, 0xb7, 0xe0, 0xff, 0xa3, 0xe0, 0x90, 0x00, 0xb5, 0xcf, 0xf0, 0xa3, 0xef, 0xf0,
+0x08, 0x76, 0xff, 0x22, 0x7e, 0x00, 0x7d, 0x00, 0x7f, 0x04, 0x7b, 0x01, 0x7a, 0x00, 0x79, 0xb5,
+0x02, 0x10, 0x98, 0xef, 0x2b, 0xff, 0xee, 0x3a, 0xfe, 0xed, 0x39, 0xfd, 0xec, 0x38, 0xfc, 0x22,
+0xab, 0x00, 0xaa, 0x00, 0xa9, 0x00, 0x85, 0x00, 0x82, 0x75, 0x83, 0x00, 0xe5, 0x00, 0x12, 0x0c,
+0xe6, 0xe5, 0x00, 0x25, 0xe0, 0x24, 0xb5, 0xf5, 0x82, 0xe4, 0x34, 0x00, 0xf5, 0x83, 0x22, 0x74,
+0x15, 0x93, 0x08, 0x26, 0x25, 0xe0, 0x24, 0x5f, 0xf8, 0xe2, 0xfc, 0x08, 0xe2, 0xfd, 0xef, 0x25,
+0xe0, 0x24, 0x60, 0xf8, 0xe2, 0x2d, 0xff, 0x18, 0xe2, 0x3c, 0xc3, 0x13, 0xf5, 0x00, 0xef, 0x13,
+0xf5, 0x00, 0xd3, 0x74, 0x10, 0x93, 0x95, 0x00, 0x74, 0x0f, 0x93, 0x95, 0x00, 0x22, 0xe5, 0x00,
+0x25, 0xe0, 0xff, 0xe5, 0x00, 0x33, 0xfe, 0xef, 0x24, 0xff, 0xff, 0xee, 0x34, 0xff, 0xfe, 0xe4,
+0xfc, 0xfd, 0x22, 0xeb, 0x7b, 0x64, 0x2f, 0xff, 0xea, 0x3e, 0xfe, 0xe9, 0x3d, 0xfd, 0xe8, 0x3c,
+0xfc, 0xe4, 0xfa, 0xf9, 0xf8, 0x22, 0x74, 0x1c, 0x93, 0x24, 0x64, 0xff, 0xe4, 0x33, 0xfe, 0xe4,
+0xfc, 0xfd, 0x12, 0x0e, 0xb7, 0xe4, 0x7b, 0x64, 0xfa, 0xf9, 0xf8, 0x12, 0x0f, 0x42, 0x8f, 0x00,
+0x8e, 0x00, 0x8d, 0x00, 0x8c, 0x00, 0x22, 0xe5, 0x00, 0x25, 0xe0, 0x24, 0x6d, 0xf8, 0xe6, 0xff,
+0x33, 0x95, 0xe0, 0xfe, 0xad, 0x00, 0xed, 0x33, 0x95, 0xe0, 0xfc, 0xc3, 0x22, 0x93, 0xfd, 0x12,
+0x0d, 0x08, 0x7c, 0x00, 0x7d, 0x32, 0x12, 0x0d, 0x1a, 0xe5, 0x28, 0x2f, 0xf5, 0x2e, 0xe5, 0x27,
+0x3e, 0xf5, 0x2d, 0xd3, 0xe5, 0x2e, 0x94, 0x00, 0xe5, 0x2d, 0x64, 0x80, 0x94, 0x80, 0x22, 0x7a,
+0x00, 0x79, 0x02, 0x7b, 0xfe, 0x7e, 0x00, 0x7f, 0x06, 0x02, 0x0c, 0x68, 0x75, 0xf0, 0x2f, 0xa4,
+0x24, 0x02, 0xf8, 0xee, 0xf2, 0x08, 0xef, 0xf2, 0x22, 0xeb, 0x25, 0xe0, 0x25, 0xe0, 0x24, 0x60,
+0xf8, 0xe2, 0x2f, 0xf5, 0x26, 0x18, 0xe2, 0x3e, 0xf5, 0x25, 0x22, 0x13, 0x2d, 0xff, 0xee, 0x3c,
+0xfe, 0x7c, 0x00, 0x7d, 0x03, 0x02, 0x0d, 0x08, 0x25, 0xe0, 0x24, 0x60, 0xf8, 0xe2, 0x2f, 0xff,
+0x18, 0xe2, 0x3e, 0xfe, 0x22, 0x7e, 0x00, 0x7f, 0x04, 0x7d, 0xff, 0x7b, 0x00, 0x7a, 0x00, 0x79,
+0x6d, 0x02, 0x10, 0x98, 0x24, 0x09, 0xf8, 0xec, 0xf2, 0x08, 0xed, 0xf2, 0x78, 0x6b, 0xe6, 0x24,
+0x0e, 0xf8, 0xe2, 0xc3, 0x22, 0x74, 0x01, 0x93, 0xfe, 0x74, 0x02, 0x93, 0xff, 0xe4, 0xfc, 0xfd,
+0x02, 0x10, 0x17, 0x74, 0x1a, 0x93, 0xff, 0x33, 0x95, 0xe0, 0xfe, 0xfd, 0xfc, 0xeb, 0x2f, 0x22,
+0xaf, 0x00, 0xef, 0x33, 0x95, 0xe0, 0xfe, 0xef, 0x25, 0xe0, 0xff, 0xee, 0x33, 0xab, 0x00, 0xaa,
+0x00, 0xa9, 0x00, 0x8f, 0x82, 0xf5, 0x83, 0x02, 0x0d, 0xe6, 0xae, 0x00, 0xaf, 0x00, 0xab, 0x07,
+0xaa, 0x06, 0xc3, 0xe5, 0x00, 0x9b, 0xfb, 0xe5, 0x00, 0x9a, 0xfa, 0xe5, 0x00, 0x94, 0x00, 0xf9,
+0xe5, 0x00, 0x94, 0x00, 0x22, 0x85, 0x42, 0x82, 0x85, 0x41, 0x83, 0x74, 0x04, 0x93, 0xfe, 0x74,
+0x05, 0x93, 0xff, 0x22, 0x78, 0x6b, 0xe6, 0xff, 0x24, 0x07, 0xf9, 0x7a, 0x00, 0x7b, 0xfe, 0xef,
+0x22, 0xeb, 0x25, 0xe0, 0x24, 0x6d, 0xf8, 0xe6, 0x22, 0xae, 0x00, 0xaf, 0x00, 0xab, 0x00, 0xaa,
+0x00, 0xa9, 0x00, 0xa8, 0x00, 0x22, 0xe5, 0x00, 0x25, 0xe0, 0xff, 0xe5, 0x00, 0x33, 0xab, 0x07,
+0xfa, 0xe4, 0xf9, 0xf8, 0x22, 0xf8, 0x7c, 0x00, 0x7d, 0xfe, 0x7e, 0x00, 0x7f, 0x04, 0x02, 0x0c,
+0x68, 0xf8, 0xe2, 0xfc, 0x08, 0xe2, 0xfd, 0xc3, 0xe5, 0x00, 0x9d, 0xf5, 0x00, 0xe5, 0x00, 0x9c,
+0xf5, 0x00, 0xa8, 0x07, 0xe8, 0x22, 0x2f, 0xff, 0xe0, 0x3e, 0xfe, 0xd3, 0xe5, 0x00, 0x9f, 0xe5,
+0x00, 0x9e, 0x22, 0xc3, 0xe5, 0x00, 0x95, 0x00, 0xff, 0xe5, 0x00, 0x95, 0x00, 0xfe, 0x22, 0xe4,
+0xfa, 0xf9, 0xf8, 0xee, 0x33, 0x95, 0xe0, 0xfd, 0xfc, 0x22, 0x74, 0x18, 0x93, 0xfb, 0x7c, 0x00,
+0x7d, 0x0a, 0x12, 0x0d, 0x1a, 0xad, 0x03, 0x7c, 0x00, 0x12, 0x10, 0x6b, 0xef, 0x22, 0xc3, 0xe5,
+0x00, 0x95, 0x00, 0xff, 0xe5, 0x00, 0x95, 0x00, 0xfe, 0xe4, 0x95, 0x00, 0xfd, 0xe4, 0x95, 0x00,
+0xfc, 0x22, 0xe4, 0x93, 0xfd, 0x7c, 0x00, 0x74, 0x03, 0x93, 0xfe, 0x74, 0x04, 0x93, 0xff, 0x22,
+0xc3, 0x74, 0x64, 0x95, 0x23, 0xff, 0xe4, 0x94, 0x00, 0xfe, 0xe4, 0xfc, 0xfd, 0x22, 0x9d, 0xfd,
+0xe4, 0x94, 0x00, 0xfc, 0xe5, 0x22, 0x75, 0xf0, 0x0a, 0xa4, 0x22, 0x25, 0xe0, 0x24, 0x5f, 0xf8,
+0xe2, 0x22, 0xc3, 0xe5, 0x00, 0x95, 0x00, 0xfb, 0xe5, 0x00, 0x95, 0x00, 0xfa, 0xe4, 0x95, 0x00,
+0xf9, 0xe4, 0x95, 0x00, 0x22, 0xe5, 0x00, 0x25, 0x00, 0xff, 0xe5, 0x00, 0x35, 0x00, 0xfe, 0xe4,
+0x35, 0x00, 0xfd, 0xe4, 0x35, 0x00, 0xfc, 0x22, 0x7e, 0x00, 0x7f, 0x06, 0x7d, 0x00, 0x7b, 0xfe,
+0x02, 0x10, 0x98, 0x93, 0xff, 0xe4, 0xfc, 0xfd, 0x12, 0x10, 0x17, 0x12, 0x0e, 0xb7, 0xe4, 0x7b,
+0x02, 0xfa, 0xf9, 0xf8, 0x22, 0xf8, 0xe2, 0x2f, 0xf5, 0x28, 0x18, 0xe2, 0x3e, 0xf5, 0x27, 0x22,
+0xea, 0x33, 0x95, 0xe0, 0xf9, 0xf8, 0xe4, 0xfc, 0xfd, 0x02, 0x0e, 0xb7, 0x85, 0x42, 0x82, 0x85,
+0x41, 0x83, 0x74, 0x05, 0x93, 0x22, 0xff, 0xed, 0x33, 0x95, 0xe0, 0xfc, 0xef, 0x2d, 0xff, 0xe4,
+0x3c, 0xc3, 0x13, 0xef, 0x13, 0x22, 0x24, 0x03, 0xf8, 0xec, 0xf2, 0x08, 0xed, 0xf2, 0x22, 0xf5,
+0x83, 0xe5, 0x82, 0x2d, 0xf5, 0x82, 0xe5, 0x83, 0x3c, 0xf5, 0x83, 0xef, 0xf0, 0x22, 0xe5, 0x00,
+0x25, 0xe0, 0x24, 0x6e, 0xf8, 0xe6, 0x22, 0xf5, 0x00, 0xea, 0x3e, 0xf5, 0x00, 0xe9, 0x3d, 0xf5,
+0x00, 0xe8, 0x3c, 0xf5, 0x00, 0x22, 0x78, 0x6b, 0xe6, 0xff, 0x24, 0x05, 0xf8, 0xe2, 0x22, 0x74,
+0x1e, 0x93, 0xfe, 0xa8, 0x07, 0xe8, 0x24, 0x0e, 0xf8, 0xe2, 0xc3, 0x9e, 0x22, 0x24, 0x02, 0xf8,
+0xc3, 0xe2, 0x9d, 0xf5, 0x29, 0x18, 0xe2, 0x9c, 0xf5, 0x28, 0x22, 0x24, 0x04, 0xf8, 0xc3, 0xe2,
+0x9d, 0xf5, 0x2b, 0x18, 0xe2, 0x9c, 0xf5, 0x2a, 0x22, 0xf8, 0xe2, 0xfc, 0x08, 0xe2, 0x2f, 0xff,
+0xee, 0x3c, 0xfe, 0xef, 0x78, 0x02, 0x22, 0x75, 0xf0, 0x2f, 0xa4, 0x24, 0x04, 0x22, 0xff, 0xae,
+0xf0, 0xe4, 0xfc, 0xfd, 0x22, 0x78, 0x6b, 0xe6, 0xff, 0x24, 0x2b, 0x22, 0x78, 0x6b, 0xe6, 0x24,
+0x0f, 0xf8, 0x22, 0xef, 0x2b, 0xff, 0xee, 0x3a, 0xfe, 0xe9, 0x3d, 0xfd, 0xe8, 0x3c, 0xfc, 0x22,
+0xef, 0x75, 0xf0, 0x2f, 0xa4, 0x24, 0x01, 0xf8, 0x22, 0xe4, 0x7f, 0x01, 0xfe, 0xfd, 0xfc, 0x22,
+0xab, 0x00, 0xaa, 0x00, 0xa9, 0x00, 0x22, 0xc3, 0xe5, 0x00, 0x9f, 0xf5, 0x00, 0xe5, 0x00, 0x9e,
+0xf5, 0x00, 0x22, 0x78, 0x58, 0x12, 0x10, 0x0b, 0x78, 0x54, 0x12, 0x10, 0x17, 0xeb, 0x22, 0xe5,
+0x30, 0x25, 0x30, 0xf5, 0x30, 0xe5, 0x2f, 0x33, 0xf5, 0x2f, 0x22, 0xc3, 0xe5, 0x26, 0x95, 0x28,
+0xff, 0xe5, 0x25, 0x95, 0x27, 0xfe, 0x22, 0xe5, 0x00, 0xf0, 0xa3, 0xe5, 0x00, 0xf0, 0x22, 0xf9,
+0x7a, 0x00, 0x7b, 0xfe, 0x75, 0xf0, 0x02, 0xe5, 0x00, 0x22, 0x13, 0xfb, 0xaa, 0x06, 0xe4, 0xf9,
+0xf8, 0x22, 0xf8, 0xe4, 0xf2, 0x08, 0x74, 0x80, 0xf2, 0xa8, 0x07, 0xe8, 0x22, 0xe4, 0xfc, 0xfd,
+0xeb, 0x25, 0x00, 0xff, 0xea, 0x35, 0x00, 0x22, 0x75, 0xf0, 0x2f, 0xa4, 0x24, 0x02, 0x22, 0xce,
+0xa2, 0xe7, 0x13, 0xce, 0x13, 0x22, 0x78, 0x6b, 0xe6, 0x24, 0x1a, 0xf8, 0x22, 0x78, 0x6b, 0xe6,
+0x24, 0x0d, 0xf8, 0x22, 0xd3, 0xe5, 0x35, 0x95, 0x37, 0xe5, 0x34, 0x95, 0x36, 0x22, 0x33, 0xfe,
+0x7c, 0x00, 0x7d, 0x03, 0x02, 0x0d, 0x1a, 0x24, 0x40, 0xff, 0xe4, 0x3e, 0xfe, 0x22, 0xe5, 0x00,
+0x25, 0xe0, 0x24, 0x6d, 0x22, 0xe5, 0x00, 0x25, 0xe0, 0x24, 0x6e, 0x22, 0x8f, 0x22, 0x8d, 0x23,
+0x12, 0x04, 0xd6, 0x70, 0x03, 0x02, 0x0b, 0x41, 0x12, 0x00, 0x60, 0x12, 0x04, 0xdf, 0x50, 0x06,
+0x12, 0x00, 0x9a, 0x02, 0x07, 0x1f, 0x12, 0x05, 0xcd, 0xe2, 0x70, 0x50, 0x12, 0x05, 0x25, 0x12,
+0x01, 0x14, 0x12, 0x04, 0xed, 0x12, 0x01, 0x0e, 0x12, 0x04, 0xfb, 0x12, 0x00, 0x60, 0x74, 0x17,
+0x93, 0x75, 0x34, 0x00, 0xf5, 0x35, 0xaf, 0x2b, 0xae, 0x2a, 0x12, 0x3b, 0x31, 0xc0, 0x06, 0xc0,
+0x07, 0xaf, 0x29, 0xae, 0x28, 0x12, 0x3b, 0x31, 0xd0, 0xe0, 0x2f, 0xff, 0xd0, 0xe0, 0x3e, 0xfe,
+0xd3, 0xef, 0x95, 0x35, 0xee, 0x95, 0x34, 0x40, 0x08, 0x12, 0x05, 0xcd, 0x74, 0x01, 0xf2, 0x80,
+0x23, 0xe4, 0xf5, 0x28, 0xf5, 0x29, 0xf5, 0x2a, 0xf5, 0x2b, 0x80, 0x18, 0x78, 0x6b, 0xe6, 0xff,
+0x24, 0x07, 0x12, 0x01, 0x14, 0x12, 0x04, 0xed, 0x78, 0x6b, 0xe6, 0xff, 0x24, 0x09, 0x12, 0x01,
+0x14, 0x12, 0x04, 0xfb, 0x12, 0x04, 0x10, 0xc0, 0x04, 0x12, 0x01, 0x30, 0x78, 0x6b, 0xe6, 0x24,
+0x16, 0x12, 0x00, 0xf3, 0x12, 0x03, 0xd3, 0xd0, 0x00, 0x12, 0x0e, 0xb7, 0xc0, 0x04, 0xc0, 0x05,
+0xc0, 0x06, 0xc0, 0x07, 0xaf, 0x23, 0xab, 0x07, 0xae, 0x28, 0xaf, 0x29, 0x12, 0x03, 0xcf, 0x12,
+0x0e, 0xb7, 0xd0, 0x03, 0xd0, 0x02, 0xd0, 0x01, 0xd0, 0x00, 0x12, 0x02, 0x33, 0x12, 0x34, 0x7d,
+0x8e, 0x28, 0x8f, 0x29, 0x12, 0x04, 0x10, 0xc0, 0x04, 0x12, 0x01, 0x30, 0x78, 0x6b, 0xe6, 0x24,
+0x18, 0x12, 0x00, 0xf3, 0x12, 0x03, 0xd3, 0xd0, 0x00, 0x12, 0x0e, 0xb7, 0xc0, 0x04, 0xc0, 0x05,
+0xc0, 0x06, 0xc0, 0x07, 0xaf, 0x23, 0xab, 0x07, 0xae, 0x2a, 0xaf, 0x2b, 0x12, 0x03, 0xcf, 0x12,
+0x0e, 0xb7, 0xd0, 0x03, 0xd0, 0x02, 0xd0, 0x01, 0xd0, 0x00, 0x12, 0x02, 0x33, 0x12, 0x34, 0x7d,
+0x8e, 0x2a, 0x8f, 0x2b, 0x78, 0x6b, 0xe6, 0xff, 0x24, 0x16, 0xf8, 0xe5, 0x28, 0xf2, 0x08, 0xe5,
+0x29, 0xf2, 0xa8, 0x07, 0xe8, 0x24, 0x18, 0xf8, 0xe5, 0x2a, 0xf2, 0x08, 0xe5, 0x2b, 0xf2, 0x12,
+0x00, 0x60, 0x74, 0x1e, 0x93, 0xff, 0x12, 0x02, 0xfc, 0x9f, 0x50, 0x03, 0x02, 0x0b, 0x1a, 0x78,
+0x6b, 0xe6, 0xfb, 0x24, 0x07, 0xf8, 0xe2, 0xfe, 0x08, 0xe2, 0xfd, 0xac, 0x06, 0xe5, 0x28, 0xa2,
+0xe7, 0x13, 0xfe, 0xe5, 0x29, 0x12, 0x02, 0xcb, 0xa8, 0x03, 0xe8, 0x04, 0x12, 0x05, 0x09, 0x12,
+0x05, 0xbf, 0xd8, 0xfb, 0xff, 0x12, 0x00, 0x60, 0x74, 0x01, 0x93, 0xfc, 0x74, 0x02, 0x93, 0xfd,
+0x12, 0x3a, 0x19, 0x8e, 0x24, 0x8f, 0x25, 0x78, 0x6b, 0xe6, 0xfb, 0x24, 0x09, 0xf8, 0xe2, 0xfe,
+0x08, 0xe2, 0xfd, 0xac, 0x06, 0xe5, 0x2a, 0xa2, 0xe7, 0x13, 0xfe, 0xe5, 0x2b, 0x12, 0x02, 0xcb,
+0xa8, 0x03, 0xe8, 0x24, 0x03, 0x12, 0x05, 0x09, 0x12, 0x05, 0xbf, 0xd8, 0xfb, 0xff, 0x12, 0x00,
+0x60, 0x74, 0x03, 0x93, 0xfc, 0x74, 0x04, 0x93, 0xfd, 0x12, 0x3a, 0x19, 0x8e, 0x26, 0x8f, 0x27,
+0x12, 0x00, 0x60, 0x74, 0x1e, 0x93, 0x24, 0x0a, 0xff, 0xe4, 0x33, 0xfe, 0x78, 0x6b, 0xe6, 0xfd,
+0x24, 0x0e, 0xf8, 0xe2, 0xc3, 0x9f, 0xee, 0x64, 0x80, 0xf8, 0x74, 0x80, 0x98, 0x50, 0x59, 0xa8,
+0x05, 0xe8, 0x24, 0x16, 0x12, 0x00, 0xf3, 0x12, 0x3b, 0x31, 0x12, 0x00, 0x60, 0x74, 0x1e, 0x93,
+0xfd, 0x78, 0x6b, 0xe6, 0xf9, 0x24, 0x0e, 0xf8, 0xe2, 0xc3, 0x12, 0x04, 0x1e, 0x24, 0x8d, 0xf5,
+0x82, 0xe4, 0x34, 0x00, 0x12, 0x04, 0xaf, 0xa8, 0x01, 0xe8, 0x24, 0x18, 0x12, 0x00, 0xf3, 0x12,
+0x3b, 0x31, 0x12, 0x00, 0x60, 0x74, 0x1e, 0x93, 0xfd, 0x12, 0x02, 0xfc, 0x12, 0x04, 0x1e, 0x24,
+0xa1, 0xf5, 0x82, 0xe4, 0x34, 0x00, 0x12, 0x04, 0xaf, 0x75, 0x38, 0x00, 0x75, 0x39, 0x80, 0x75,
+0x3a, 0x00, 0x75, 0x3b, 0x80, 0x02, 0x09, 0x89, 0x12, 0x04, 0x24, 0x24, 0x96, 0xf9, 0x74, 0x00,
+0x35, 0xf0, 0xfa, 0x7b, 0x01, 0xc0, 0x03, 0xc0, 0x02, 0xc0, 0x01, 0x78, 0x6b, 0xe6, 0x24, 0x16,
+0x12, 0x00, 0xf3, 0x12, 0x3b, 0x31, 0xad, 0x07, 0xd0, 0x01, 0xd0, 0x02, 0xd0, 0x03, 0x12, 0x39,
+0x3b, 0x8e, 0x34, 0x8f, 0x35, 0x12, 0x04, 0x24, 0x24, 0xaa, 0xf9, 0x74, 0x00, 0x35, 0xf0, 0xfa,
+0x7b, 0x01, 0xc0, 0x03, 0xc0, 0x02, 0xc0, 0x01, 0x78, 0x6b, 0xe6, 0x24, 0x18, 0x12, 0x00, 0xf3,
+0x12, 0x3b, 0x31, 0xad, 0x07, 0xd0, 0x01, 0xd0, 0x02, 0xd0, 0x03, 0x12, 0x39, 0x3b, 0x8e, 0x36,
+0x8f, 0x37, 0x12, 0x05, 0xd4, 0x40, 0x18, 0xe5, 0x35, 0xae, 0x34, 0x78, 0x03, 0xc3, 0x33, 0xce,
+0x33, 0xce, 0xd8, 0xf9, 0xff, 0xe5, 0x37, 0x24, 0x01, 0xfd, 0xe4, 0x35, 0x36, 0x80, 0x16, 0xe5,
+0x37, 0xae, 0x36, 0x78, 0x03, 0xc3, 0x33, 0xce, 0x33, 0xce, 0xd8, 0xf9, 0xff, 0xe5, 0x35, 0x24,
+0x01, 0xfd, 0xe4, 0x35, 0x34, 0xfc, 0x12, 0x0d, 0x1a, 0xab, 0x07, 0xaa, 0x06, 0x78, 0x6b, 0xe6,
+0xf9, 0x24, 0x10, 0x12, 0x00, 0xf3, 0x12, 0x02, 0xd1, 0xef, 0x2b, 0xff, 0xee, 0x3a, 0xfe, 0xef,
+0x78, 0x02, 0xce, 0xc3, 0x13, 0xce, 0x13, 0xd8, 0xf9, 0xfb, 0xaa, 0x06, 0xc3, 0x94, 0x28, 0xea,
+0x94, 0x00, 0x50, 0x06, 0x7a, 0x00, 0x7b, 0x28, 0x80, 0x0d, 0xd3, 0xeb, 0x94, 0x46, 0xea, 0x94,
+0x00, 0x40, 0x04, 0x7a, 0x00, 0x7b, 0x46, 0x7c, 0x00, 0x7d, 0x0a, 0xaf, 0x03, 0xae, 0x02, 0x12,
+0x0d, 0x08, 0xef, 0x24, 0xf0, 0xf5, 0x39, 0xee, 0x34, 0xfe, 0xf5, 0x38, 0xeb, 0x25, 0xe0, 0xff,
+0xea, 0x33, 0xfe, 0xc3, 0x74, 0xd0, 0x9f, 0xf5, 0x3b, 0xe4, 0x9e, 0xf5, 0x3a, 0x12, 0x05, 0xd4,
+0x40, 0x12, 0x85, 0x38, 0x34, 0x85, 0x39, 0x35, 0x85, 0x3a, 0x38, 0x85, 0x3b, 0x39, 0x85, 0x34,
+0x3a, 0x85, 0x35, 0x3b, 0x78, 0x6b, 0xe6, 0xff, 0x24, 0x10, 0xf8, 0xea, 0xf2, 0x08, 0xeb, 0xf2,
+0xa8, 0x07, 0xe8, 0x24, 0x12, 0x12, 0x00, 0xf3, 0x12, 0x02, 0xd1, 0xe5, 0x39, 0x2f, 0xff, 0xe5,
+0x38, 0x3e, 0xfe, 0xef, 0x78, 0x02, 0xce, 0xc3, 0x13, 0xce, 0x13, 0xd8, 0xf9, 0xf5, 0x39, 0x8e,
+0x38, 0x78, 0x6b, 0xe6, 0xfb, 0x24, 0x14, 0x12, 0x00, 0xf3, 0x12, 0x02, 0xd1, 0xe5, 0x3b, 0x2f,
+0xff, 0xe5, 0x3a, 0x3e, 0xfe, 0xef, 0x78, 0x02, 0xce, 0xc3, 0x13, 0xce, 0x13, 0xd8, 0xf9, 0xf5,
+0x3b, 0x8e, 0x3a, 0xeb, 0x24, 0x12, 0xf8, 0xe5, 0x38, 0xf2, 0x08, 0xe5, 0x39, 0xf2, 0xe9, 0x24,
+0x14, 0xf8, 0xe5, 0x3a, 0xf2, 0x08, 0xe5, 0x3b, 0xf2, 0x12, 0x0b, 0x70, 0x7c, 0x00, 0x7d, 0x02,
+0x12, 0x0d, 0x6f, 0xc0, 0x06, 0xc0, 0x07, 0x12, 0x0b, 0x84, 0xd0, 0xe0, 0x2f, 0xf5, 0x35, 0xd0,
+0xe0, 0x3e, 0xf5, 0x34, 0x12, 0x00, 0x60, 0xae, 0x34, 0xaf, 0x35, 0x12, 0x03, 0xda, 0x25, 0x35,
+0xf5, 0x35, 0xee, 0x35, 0x34, 0xf5, 0x34, 0xd3, 0xe5, 0x35, 0x95, 0x39, 0xe5, 0x34, 0x95, 0x38,
+0x40, 0x06, 0x85, 0x38, 0x34, 0x85, 0x39, 0x35, 0x78, 0x6b, 0xe6, 0x24, 0x07, 0x12, 0x00, 0xf3,
+0xc3, 0xe5, 0x39, 0x95, 0x35, 0xfd, 0xe5, 0x38, 0x95, 0x34, 0xfc, 0x12, 0x10, 0x6b, 0x8f, 0x2f,
+0x8e, 0x2e, 0x8d, 0x2d, 0x8c, 0x2c, 0xae, 0x24, 0xaf, 0x25, 0xab, 0x07, 0xaa, 0x06, 0xae, 0x34,
+0xaf, 0x35, 0x12, 0x04, 0x80, 0xef, 0x25, 0x2f, 0xff, 0xee, 0x35, 0x2e, 0xfe, 0xed, 0x35, 0x2d,
+0xfd, 0xec, 0x35, 0x2c, 0xfc, 0xc0, 0x06, 0xc0, 0x07, 0xe5, 0x38, 0xc3, 0x13, 0xfe, 0xe5, 0x39,
+0x12, 0x05, 0x9a, 0xd0, 0x07, 0xd0, 0x06, 0x12, 0x05, 0x33, 0xc0, 0x06, 0xc0, 0x07, 0xae, 0x38,
+0xaf, 0x39, 0xab, 0x07, 0xaa, 0x06, 0xe4, 0xd0, 0x07, 0xd0, 0x06, 0x12, 0x0f, 0x42, 0x8f, 0x2f,
+0x8e, 0x2e, 0x8d, 0x2d, 0x8c, 0x2c, 0x12, 0x0b, 0x84, 0x7c, 0x00, 0x7d, 0x02, 0x12, 0x0d, 0x6f,
+0xc0, 0x06, 0xc0, 0x07, 0x12, 0x0b, 0x70, 0xd0, 0xe0, 0x2f, 0xf5, 0x37, 0xd0, 0xe0, 0x3e, 0xf5,
+0x36, 0x12, 0x00, 0x60, 0xae, 0x36, 0xaf, 0x37, 0x12, 0x03, 0xda, 0x25, 0x37, 0xf5, 0x37, 0xee,
+0x35, 0x36, 0xf5, 0x36, 0xd3, 0xe5, 0x37, 0x95, 0x3b, 0xe5, 0x36, 0x95, 0x3a, 0x40, 0x06, 0x85,
+0x3a, 0x36, 0x85, 0x3b, 0x37, 0x78, 0x6b, 0xe6, 0x24, 0x09, 0x12, 0x00, 0xf3, 0xc3, 0xe5, 0x3b,
+0x95, 0x37, 0xfd, 0xe5, 0x3a, 0x95, 0x36, 0xfc, 0x12, 0x10, 0x6b, 0x8f, 0x33, 0x8e, 0x32, 0x8d,
+0x31, 0x8c, 0x30, 0xae, 0x26, 0xaf, 0x27, 0xab, 0x07, 0xaa, 0x06, 0xae, 0x36, 0xaf, 0x37, 0x12,
+0x04, 0x80, 0xef, 0x25, 0x33, 0xff, 0xee, 0x35, 0x32, 0xfe, 0xed, 0x35, 0x31, 0xfd, 0xec, 0x35,
+0x30, 0xfc, 0xc0, 0x06, 0xc0, 0x07, 0xe5, 0x3a, 0xc3, 0x13, 0xfe, 0xe5, 0x3b, 0x12, 0x05, 0x9a,
+0xd0, 0x07, 0xd0, 0x06, 0x12, 0x05, 0x33, 0xc0, 0x06, 0xc0, 0x07, 0xae, 0x3a, 0xaf, 0x3b, 0xab,
+0x07, 0xaa, 0x06, 0xe4, 0xd0, 0x07, 0xd0, 0x06, 0x12, 0x0f, 0x42, 0x8f, 0x33, 0x8e, 0x32, 0x8d,
+0x31, 0x8c, 0x30, 0x12, 0x00, 0x60, 0x74, 0x16, 0x93, 0xf4, 0x60, 0x2e, 0x78, 0x6b, 0xe6, 0xff,
+0x24, 0x0d, 0xf8, 0xe2, 0xb4, 0x01, 0x1b, 0xa8, 0x07, 0xe8, 0x04, 0xf8, 0xe5, 0x2e, 0xf2, 0x08,
+0xe5, 0x2f, 0xf2, 0xa8, 0x07, 0xe8, 0x24, 0x03, 0xf8, 0xe5, 0x32, 0xf2, 0x08, 0xe5, 0x33, 0xf2,
+0x80, 0x08, 0x78, 0x6b, 0x12, 0x00, 0xfa, 0x12, 0x04, 0xa6, 0x78, 0x6b, 0xe6, 0xff, 0x04, 0x12,
+0x01, 0x14, 0x24, 0x07, 0x12, 0x04, 0xa8, 0x78, 0x6b, 0xe6, 0xff, 0x24, 0x03, 0x12, 0x01, 0x14,
+0x12, 0x02, 0xf4, 0x94, 0x14, 0x50, 0x03, 0xe2, 0x04, 0xf2, 0x12, 0x05, 0x2c, 0x74, 0x01, 0xf2,
+0x22, 0x12, 0x05, 0x2c, 0xe2, 0xd3, 0x94, 0x00, 0x40, 0x03, 0xe2, 0x14, 0xf2, 0xe2, 0x70, 0x1f,
+0x78, 0x6b, 0xe6, 0xff, 0x24, 0x0e, 0xf8, 0xe4, 0xf2, 0xa8, 0x07, 0xe8, 0x24, 0x12, 0x12, 0x05,
+0xa2, 0x24, 0x14, 0x12, 0x05, 0xa2, 0x24, 0x10, 0xf8, 0xe4, 0xf2, 0x08, 0x74, 0x28, 0xf2, 0x22,
+0x78, 0x6b, 0xe6, 0x24, 0x0a, 0xf8, 0xc3, 0xe2, 0x95, 0x27, 0xff, 0x18, 0xe2, 0x95, 0x26, 0xfe,
+0x12, 0x3b, 0x31, 0x22, 0x78, 0x6b, 0xe6, 0x24, 0x08, 0xf8, 0xc3, 0xe2, 0x95, 0x25, 0xff, 0x18,
+0xe2, 0x95, 0x24, 0xfe, 0x12, 0x3b, 0x31, 0x22, 0xe7, 0x09, 0xf6, 0x08, 0xdf, 0xfa, 0x80, 0x46,
+0xe7, 0x09, 0xf2, 0x08, 0xdf, 0xfa, 0x80, 0x3e, 0x88, 0x82, 0x8c, 0x83, 0xe7, 0x09, 0xf0, 0xa3,
+0xdf, 0xfa, 0x80, 0x32, 0xe3, 0x09, 0xf6, 0x08, 0xdf, 0xfa, 0x80, 0x78, 0xe3, 0x09, 0xf2, 0x08,
+0xdf, 0xfa, 0x80, 0x70, 0x88, 0x82, 0x8c, 0x83, 0xe3, 0x09, 0xf0, 0xa3, 0xdf, 0xfa, 0x80, 0x64,
+0x89, 0x82, 0x8a, 0x83, 0xe0, 0xa3, 0xf6, 0x08, 0xdf, 0xfa, 0x80, 0x58, 0x89, 0x82, 0x8a, 0x83,
+0xe0, 0xa3, 0xf2, 0x08, 0xdf, 0xfa, 0x80, 0x4c, 0x80, 0xd2, 0x80, 0xfa, 0x80, 0xc6, 0x80, 0xd4,
+0x80, 0x69, 0x80, 0xf2, 0x80, 0x33, 0x80, 0x10, 0x80, 0xa6, 0x80, 0xea, 0x80, 0x9a, 0x80, 0xa8,
+0x80, 0xda, 0x80, 0xe2, 0x80, 0xca, 0x80, 0x33, 0x89, 0x82, 0x8a, 0x83, 0xec, 0xfa, 0xe4, 0x93,
+0xa3, 0xc8, 0xc5, 0x82, 0xc8, 0xcc, 0xc5, 0x83, 0xcc, 0xf0, 0xa3, 0xc8, 0xc5, 0x82, 0xc8, 0xcc,
+0xc5, 0x83, 0xcc, 0xdf, 0xe9, 0xde, 0xe7, 0x80, 0x0d, 0x89, 0x82, 0x8a, 0x83, 0xe4, 0x93, 0xa3,
+0xf6, 0x08, 0xdf, 0xf9, 0xec, 0xfa, 0xa9, 0xf0, 0xed, 0xfb, 0x22, 0x89, 0x82, 0x8a, 0x83, 0xec,
+0xfa, 0xe0, 0xa3, 0xc8, 0xc5, 0x82, 0xc8, 0xcc, 0xc5, 0x83, 0xcc, 0xf0, 0xa3, 0xc8, 0xc5, 0x82,
+0xc8, 0xcc, 0xc5, 0x83, 0xcc, 0xdf, 0xea, 0xde, 0xe8, 0x80, 0xdb, 0x89, 0x82, 0x8a, 0x83, 0xe4,
+0x93, 0xa3, 0xf2, 0x08, 0xdf, 0xf9, 0x80, 0xcc, 0x88, 0xf0, 0xef, 0x60, 0x01, 0x0e, 0x4e, 0x60,
+0xc3, 0x88, 0xf0, 0xed, 0x24, 0x02, 0xb4, 0x04, 0x00, 0x50, 0xb9, 0xf5, 0x82, 0xeb, 0x24, 0x02,
+0xb4, 0x04, 0x00, 0x50, 0xaf, 0x23, 0x23, 0x45, 0x82, 0x23, 0x90, 0x0b, 0xe8, 0x73, 0xbb, 0x01,
+0x06, 0x89, 0x82, 0x8a, 0x83, 0xe0, 0x22, 0x50, 0x02, 0xe7, 0x22, 0xbb, 0xfe, 0x02, 0xe3, 0x22,
+0x89, 0x82, 0x8a, 0x83, 0xe4, 0x93, 0x22, 0xbb, 0x01, 0x0c, 0xe5, 0x82, 0x29, 0xf5, 0x82, 0xe5,
+0x83, 0x3a, 0xf5, 0x83, 0xe0, 0x22, 0x50, 0x06, 0xe9, 0x25, 0x82, 0xf8, 0xe6, 0x22, 0xbb, 0xfe,
+0x06, 0xe9, 0x25, 0x82, 0xf8, 0xe2, 0x22, 0xe5, 0x82, 0x29, 0xf5, 0x82, 0xe5, 0x83, 0x3a, 0xf5,
+0x83, 0xe4, 0x93, 0x22, 0xbb, 0x01, 0x06, 0x89, 0x82, 0x8a, 0x83, 0xf0, 0x22, 0x50, 0x02, 0xf7,
+0x22, 0xbb, 0xfe, 0x01, 0xf3, 0x22, 0xf8, 0xbb, 0x01, 0x0d, 0xe5, 0x82, 0x29, 0xf5, 0x82, 0xe5,
+0x83, 0x3a, 0xf5, 0x83, 0xe8, 0xf0, 0x22, 0x50, 0x06, 0xe9, 0x25, 0x82, 0xc8, 0xf6, 0x22, 0xbb,
+0xfe, 0x05, 0xe9, 0x25, 0x82, 0xc8, 0xf2, 0x22, 0xef, 0x8d, 0xf0, 0xa4, 0xa8, 0xf0, 0xcf, 0x8c,
+0xf0, 0xa4, 0x28, 0xce, 0x8d, 0xf0, 0xa4, 0x2e, 0xfe, 0x22, 0xbc, 0x00, 0x0b, 0xbe, 0x00, 0x29,
+0xef, 0x8d, 0xf0, 0x84, 0xff, 0xad, 0xf0, 0x22, 0xe4, 0xcc, 0xf8, 0x75, 0xf0, 0x08, 0xef, 0x2f,
+0xff, 0xee, 0x33, 0xfe, 0xec, 0x33, 0xfc, 0xee, 0x9d, 0xec, 0x98, 0x40, 0x05, 0xfc, 0xee, 0x9d,
+0xfe, 0x0f, 0xd5, 0xf0, 0xe9, 0xe4, 0xce, 0xfd, 0x22, 0xed, 0xf8, 0xf5, 0xf0, 0xee, 0x84, 0x20,
+0xd2, 0x1c, 0xfe, 0xad, 0xf0, 0x75, 0xf0, 0x08, 0xef, 0x2f, 0xff, 0xed, 0x33, 0xfd, 0x40, 0x07,
+0x98, 0x50, 0x06, 0xd5, 0xf0, 0xf2, 0x22, 0xc3, 0x98, 0xfd, 0x0f, 0xd5, 0xf0, 0xea, 0x22, 0xc2,
+0xd5, 0xec, 0x30, 0xe7, 0x09, 0xb2, 0xd5, 0xe4, 0xc3, 0x9d, 0xfd, 0xe4, 0x9c, 0xfc, 0xee, 0x30,
+0xe7, 0x15, 0xb2, 0xd5, 0xe4, 0xc3, 0x9f, 0xff, 0xe4, 0x9e, 0xfe, 0x12, 0x0d, 0x1a, 0xc3, 0xe4,
+0x9d, 0xfd, 0xe4, 0x9c, 0xfc, 0x80, 0x03, 0x12, 0x0d, 0x1a, 0x30, 0xd5, 0x07, 0xc3, 0xe4, 0x9f,
+0xff, 0xe4, 0x9e, 0xfe, 0x22, 0xc5, 0xf0, 0xf8, 0xa3, 0xe0, 0x28, 0xf0, 0xc5, 0xf0, 0xf8, 0xe5,
+0x82, 0x15, 0x82, 0x70, 0x02, 0x15, 0x83, 0xe0, 0x38, 0xf0, 0x22, 0xbb, 0x01, 0x0a, 0x89, 0x82,
+0x8a, 0x83, 0xe0, 0xf5, 0xf0, 0xa3, 0xe0, 0x22, 0x50, 0x06, 0x87, 0xf0, 0x09, 0xe7, 0x19, 0x22,
+0xbb, 0xfe, 0x07, 0xe3, 0xf5, 0xf0, 0x09, 0xe3, 0x19, 0x22, 0x89, 0x82, 0x8a, 0x83, 0xe4, 0x93,
+0xf5, 0xf0, 0x74, 0x01, 0x93, 0x22, 0xbb, 0x01, 0x10, 0xe5, 0x82, 0x29, 0xf5, 0x82, 0xe5, 0x83,
+0x3a, 0xf5, 0x83, 0xe0, 0xf5, 0xf0, 0xa3, 0xe0, 0x22, 0x50, 0x09, 0xe9, 0x25, 0x82, 0xf8, 0x86,
+0xf0, 0x08, 0xe6, 0x22, 0xbb, 0xfe, 0x0a, 0xe9, 0x25, 0x82, 0xf8, 0xe2, 0xf5, 0xf0, 0x08, 0xe2,
+0x22, 0xe5, 0x83, 0x2a, 0xf5, 0x83, 0xe9, 0x93, 0xf5, 0xf0, 0xa3, 0xe9, 0x93, 0x22, 0xbb, 0x01,
+0x0d, 0xc5, 0x82, 0x29, 0xc5, 0x82, 0xc5, 0x83, 0x3a, 0xc5, 0x83, 0x02, 0x0d, 0xa5, 0x50, 0x11,
+0xc5, 0x82, 0x29, 0xf8, 0x08, 0xe5, 0xf0, 0x26, 0xf6, 0x18, 0xf5, 0xf0, 0xe5, 0x82, 0x36, 0xf6,
+0x22, 0xbb, 0xfe, 0x11, 0xc5, 0x82, 0x29, 0xf8, 0x08, 0xe2, 0x25, 0xf0, 0xf5, 0xf0, 0xf2, 0x18,
+0xe2, 0x35, 0x82, 0xf2, 0x22, 0xf8, 0xe5, 0x82, 0x29, 0xf5, 0x82, 0xe5, 0x83, 0x2a, 0xf5, 0x83,
+0x74, 0x01, 0x93, 0x25, 0xf0, 0xf5, 0xf0, 0xe4, 0x93, 0x38, 0x22, 0xbb, 0x01, 0x0a, 0x89, 0x82,
+0x8a, 0x83, 0xf0, 0xe5, 0xf0, 0xa3, 0xf0, 0x22, 0x50, 0x06, 0xf7, 0x09, 0xa7, 0xf0, 0x19, 0x22,
+0xbb, 0xfe, 0x06, 0xf3, 0xe5, 0xf0, 0x09, 0xf3, 0x19, 0x22, 0xf8, 0xbb, 0x01, 0x11, 0xe5, 0x82,
+0x29, 0xf5, 0x82, 0xe5, 0x83, 0x3a, 0xf5, 0x83, 0xe8, 0xf0, 0xe5, 0xf0, 0xa3, 0xf0, 0x22, 0x50,
+0x09, 0xe9, 0x25, 0x82, 0xc8, 0xf6, 0x08, 0xa6, 0xf0, 0x22, 0xbb, 0xfe, 0x09, 0xe9, 0x25, 0x82,
+0xc8, 0xf2, 0xe5, 0xf0, 0x08, 0xf2, 0x22, 0xe8, 0x8f, 0xf0, 0xa4, 0xcc, 0x8b, 0xf0, 0xa4, 0x2c,
+0xfc, 0xe9, 0x8e, 0xf0, 0xa4, 0x2c, 0xfc, 0x8a, 0xf0, 0xed, 0xa4, 0x2c, 0xfc, 0xea, 0x8e, 0xf0,
+0xa4, 0xcd, 0xa8, 0xf0, 0x8b, 0xf0, 0xa4, 0x2d, 0xcc, 0x38, 0x25, 0xf0, 0xfd, 0xe9, 0x8f, 0xf0,
+0xa4, 0x2c, 0xcd, 0x35, 0xf0, 0xfc, 0xeb, 0x8e, 0xf0, 0xa4, 0xfe, 0xa9, 0xf0, 0xeb, 0x8f, 0xf0,
+0xa4, 0xcf, 0xc5, 0xf0, 0x2e, 0xcd, 0x39, 0xfe, 0xe4, 0x3c, 0xfc, 0xea, 0xa4, 0x2d, 0xce, 0x35,
+0xf0, 0xfd, 0xe4, 0x3c, 0xfc, 0x22, 0x75, 0xf0, 0x08, 0x75, 0x82, 0x00, 0xef, 0x2f, 0xff, 0xee,
+0x33, 0xfe, 0xcd, 0x33, 0xcd, 0xcc, 0x33, 0xcc, 0xc5, 0x82, 0x33, 0xc5, 0x82, 0x9b, 0xed, 0x9a,
+0xec, 0x99, 0xe5, 0x82, 0x98, 0x40, 0x0c, 0xf5, 0x82, 0xee, 0x9b, 0xfe, 0xed, 0x9a, 0xfd, 0xec,
+0x99, 0xfc, 0x0f, 0xd5, 0xf0, 0xd6, 0xe4, 0xce, 0xfb, 0xe4, 0xcd, 0xfa, 0xe4, 0xcc, 0xf9, 0xa8,
+0x82, 0x22, 0xb8, 0x00, 0xc1, 0xb9, 0x00, 0x59, 0xba, 0x00, 0x2d, 0xec, 0x8b, 0xf0, 0x84, 0xcf,
+0xce, 0xcd, 0xfc, 0xe5, 0xf0, 0xcb, 0xf9, 0x78, 0x18, 0xef, 0x2f, 0xff, 0xee, 0x33, 0xfe, 0xed,
+0x33, 0xfd, 0xec, 0x33, 0xfc, 0xeb, 0x33, 0xfb, 0x10, 0xd7, 0x03, 0x99, 0x40, 0x04, 0xeb, 0x99,
+0xfb, 0x0f, 0xd8, 0xe5, 0xe4, 0xf9, 0xfa, 0x22, 0x78, 0x18, 0xef, 0x2f, 0xff, 0xee, 0x33, 0xfe,
+0xed, 0x33, 0xfd, 0xec, 0x33, 0xfc, 0xc9, 0x33, 0xc9, 0x10, 0xd7, 0x05, 0x9b, 0xe9, 0x9a, 0x40,
+0x07, 0xec, 0x9b, 0xfc, 0xe9, 0x9a, 0xf9, 0x0f, 0xd8, 0xe0, 0xe4, 0xc9, 0xfa, 0xe4, 0xcc, 0xfb,
+0x22, 0x75, 0xf0, 0x10, 0xef, 0x2f, 0xff, 0xee, 0x33, 0xfe, 0xed, 0x33, 0xfd, 0xcc, 0x33, 0xcc,
+0xc8, 0x33, 0xc8, 0x10, 0xd7, 0x07, 0x9b, 0xec, 0x9a, 0xe8, 0x99, 0x40, 0x0a, 0xed, 0x9b, 0xfd,
+0xec, 0x9a, 0xfc, 0xe8, 0x99, 0xf8, 0x0f, 0xd5, 0xf0, 0xda, 0xe4, 0xcd, 0xfb, 0xe4, 0xcc, 0xfa,
+0xe4, 0xc8, 0xf9, 0x22, 0xeb, 0x9f, 0xf5, 0xf0, 0xea, 0x9e, 0x42, 0xf0, 0xe9, 0x9d, 0x42, 0xf0,
+0xe8, 0x9c, 0x45, 0xf0, 0x22, 0xe8, 0x60, 0x0f, 0xec, 0xc3, 0x13, 0xfc, 0xed, 0x13, 0xfd, 0xee,
+0x13, 0xfe, 0xef, 0x13, 0xff, 0xd8, 0xf1, 0x22, 0xe8, 0x60, 0x0f, 0xef, 0xc3, 0x33, 0xff, 0xee,
+0x33, 0xfe, 0xed, 0x33, 0xfd, 0xec, 0x33, 0xfc, 0xd8, 0xf1, 0x22, 0xe6, 0xfc, 0x08, 0xe6, 0xfd,
+0x08, 0xe6, 0xfe, 0x08, 0xe6, 0xff, 0x22, 0xe6, 0xfb, 0x08, 0xe6, 0xf9, 0x08, 0xe6, 0xfa, 0x08,
+0xe6, 0xcb, 0xf8, 0x22, 0xe4, 0x93, 0xf8, 0x74, 0x01, 0x93, 0xf9, 0x74, 0x02, 0x93, 0xfa, 0x74,
+0x03, 0x93, 0xfb, 0x22, 0xec, 0xf6, 0x08, 0xed, 0xf6, 0x08, 0xee, 0xf6, 0x08, 0xef, 0xf6, 0x22,
+0xd0, 0x83, 0xd0, 0x82, 0xe4, 0x93, 0xf6, 0x08, 0x74, 0x01, 0x93, 0xf6, 0x08, 0x74, 0x02, 0x93,
+0xf6, 0x08, 0x74, 0x03, 0x93, 0xf6, 0x74, 0x04, 0x73, 0xa4, 0x25, 0x82, 0xf5, 0x82, 0xe5, 0xf0,
+0x35, 0x83, 0xf5, 0x83, 0x22, 0x8a, 0x83, 0x89, 0x82, 0xe4, 0x73, 0xec, 0x8e, 0xf0, 0xa4, 0xcc,
+0xc5, 0xf0, 0xcc, 0xcd, 0xf8, 0xef, 0xa4, 0xce, 0xc5, 0xf0, 0x2d, 0xfd, 0xe4, 0x3c, 0xfc, 0xe8,
+0xa4, 0x2e, 0xc8, 0xc5, 0xf0, 0x3d, 0xfd, 0xe4, 0x3c, 0xfc, 0xef, 0xa4, 0xff, 0xe5, 0xf0, 0x28,
+0xfe, 0xe4, 0x3d, 0xfd, 0xe4, 0x3c, 0xfc, 0x22, 0xef, 0x4e, 0x60, 0x12, 0xef, 0x60, 0x01, 0x0e,
+0xed, 0xbb, 0x01, 0x0b, 0x89, 0x82, 0x8a, 0x83, 0xf0, 0xa3, 0xdf, 0xfc, 0xde, 0xfa, 0x22, 0x89,
+0xf0, 0x50, 0x07, 0xf7, 0x09, 0xdf, 0xfc, 0xa9, 0xf0, 0x22, 0xbb, 0xfe, 0xfc, 0xf3, 0x09, 0xdf,
+0xfc, 0xa9, 0xf0, 0x22, 0x90, 0x36, 0x03, 0x7d, 0x1f, 0x12, 0x33, 0x47, 0xee, 0x44, 0x80, 0xf5,
+0x8f, 0x8f, 0x8e, 0x75, 0x8a, 0xa0, 0x75, 0x8a, 0x0a, 0xe4, 0x90, 0x00, 0xc3, 0xf0, 0x90, 0x00,
+0xc9, 0xe0, 0x70, 0x03, 0x02, 0x11, 0xd7, 0x14, 0x70, 0x03, 0x02, 0x12, 0x02, 0x24, 0xfc, 0x70,
+0x03, 0x02, 0x13, 0xbf, 0x04, 0x60, 0x03, 0x02, 0x13, 0xf8, 0xe4, 0xf5, 0x18, 0x78, 0x73, 0xf6,
+0x90, 0x36, 0x12, 0x93, 0x70, 0x0e, 0x75, 0x3f, 0x36, 0x75, 0x40, 0x2a, 0x12, 0x3b, 0x47, 0x8f,
+0x18, 0x02, 0x11, 0xc6, 0xe4, 0xf5, 0x1a, 0xf5, 0x1b, 0x75, 0x3f, 0x38, 0x75, 0x40, 0x9e, 0x12,
+0x14, 0xeb, 0x12, 0x33, 0x34, 0x12, 0x20, 0xaa, 0xe4, 0xf5, 0x19, 0x12, 0x33, 0x19, 0xe4, 0x93,
+0xff, 0xe5, 0x19, 0xc3, 0x9f, 0x50, 0x33, 0xaf, 0x19, 0x12, 0x3b, 0x57, 0xac, 0x06, 0xad, 0x07,
+0x12, 0x33, 0x19, 0x74, 0x2c, 0x93, 0x75, 0xf0, 0xc8, 0xa4, 0xff, 0xd3, 0xed, 0x9f, 0xec, 0x95,
+0xf0, 0x40, 0x13, 0xe4, 0x7f, 0x01, 0xfe, 0xfd, 0xfc, 0xa9, 0x19, 0xa8, 0x01, 0x12, 0x0f, 0xf8,
+0xef, 0x42, 0x1b, 0xee, 0x42, 0x1a, 0x05, 0x19, 0x80, 0xc1, 0xe5, 0x1a, 0x90, 0x01, 0xab, 0xf0,
+0xa3, 0xe5, 0x1b, 0xf0, 0xe4, 0xf5, 0x19, 0xae, 0x1a, 0xaf, 0x1b, 0xe4, 0xfc, 0xfd, 0xe5, 0x19,
+0x25, 0xe0, 0x25, 0xe0, 0x24, 0x13, 0xf5, 0x82, 0xe4, 0x34, 0x36, 0xf5, 0x83, 0x12, 0x10, 0x24,
+0xc3, 0x12, 0x0f, 0xd4, 0x60, 0x07, 0x05, 0x19, 0xe5, 0x19, 0xb4, 0x04, 0xda, 0xe5, 0x19, 0xc3,
+0x94, 0x04, 0x50, 0x19, 0x85, 0x19, 0x18, 0x75, 0xf0, 0x9d, 0xe5, 0x19, 0xa4, 0x24, 0x2a, 0xf5,
+0x82, 0xe5, 0xf0, 0x34, 0x36, 0xaf, 0x82, 0xf5, 0x3f, 0x8f, 0x40, 0x80, 0x09, 0xe4, 0xf5, 0x18,
+0x75, 0x3f, 0x36, 0x75, 0x40, 0x2a, 0x90, 0x01, 0xaa, 0xe5, 0x18, 0xf0, 0x90, 0x01, 0xf0, 0x74,
+0x40, 0xf0, 0xa3, 0xf0, 0x02, 0x13, 0xf8, 0xe4, 0x78, 0x73, 0xf6, 0x12, 0x31, 0x4b, 0xef, 0x64,
+0x01, 0x60, 0xf8, 0x12, 0x14, 0xeb, 0xaf, 0x40, 0xae, 0x3f, 0x12, 0x3a, 0xee, 0xe5, 0x40, 0x24,
+0x79, 0xff, 0xe4, 0x35, 0x3f, 0xfe, 0x12, 0x3a, 0x9e, 0x12, 0x33, 0x51, 0xa3, 0x04, 0xf0, 0x02,
+0x13, 0xfd, 0xe4, 0xf5, 0x18, 0x78, 0x47, 0xf6, 0x90, 0x01, 0xff, 0xe0, 0xb4, 0x01, 0x09, 0x90,
+0x00, 0xc9, 0x74, 0x05, 0xf0, 0x02, 0x13, 0xfd, 0x78, 0x73, 0x76, 0x01, 0x12, 0x33, 0x34, 0x12,
+0x20, 0xaa, 0x78, 0x47, 0xa6, 0x07, 0x12, 0x33, 0x19, 0x74, 0x63, 0x93, 0x70, 0x03, 0x74, 0x62,
+0x93, 0x60, 0x1b, 0x08, 0xe6, 0xf5, 0x19, 0x08, 0xe6, 0xf5, 0x1a, 0x08, 0xe6, 0xfe, 0x08, 0xe6,
+0xff, 0x78, 0x48, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x08, 0xa6, 0x19, 0x08, 0xa6, 0x1a, 0x7f, 0x5f,
+0xe5, 0x40, 0x24, 0x79, 0xfd, 0xe4, 0x35, 0x3f, 0xfc, 0x12, 0x2e, 0x51, 0x8f, 0x18, 0x12, 0x33,
+0x34, 0x75, 0x20, 0x36, 0x75, 0x21, 0x23, 0xad, 0x18, 0x12, 0x1b, 0xb4, 0x8f, 0x18, 0x78, 0x47,
+0xe6, 0x64, 0x02, 0x70, 0x6f, 0xf5, 0x19, 0xe5, 0x18, 0x64, 0x05, 0x60, 0x05, 0xe5, 0x18, 0xb4,
+0x0c, 0x03, 0x43, 0x18, 0x80, 0x78, 0x47, 0xa6, 0x0a, 0xe5, 0x0a, 0x70, 0x03, 0x78, 0x4c, 0xf6,
+0xe5, 0x19, 0xd3, 0x94, 0x03, 0x50, 0x51, 0x74, 0x01, 0x7e, 0x00, 0xa8, 0x19, 0x08, 0x80, 0x05,
+0xc3, 0x33, 0xce, 0x33, 0xce, 0xd8, 0xf9, 0xff, 0x78, 0x47, 0xe6, 0xfd, 0xef, 0x5d, 0x60, 0x30,
+0x12, 0x33, 0x19, 0x75, 0xf0, 0x09, 0xe5, 0x19, 0x12, 0x10, 0x59, 0x74, 0x36, 0x93, 0xfe, 0x74,
+0x37, 0x93, 0x08, 0xa6, 0x06, 0x08, 0xf6, 0x12, 0x33, 0x19, 0x75, 0xf0, 0x09, 0xe5, 0x19, 0x12,
+0x10, 0x59, 0x74, 0x38, 0x93, 0xfe, 0x74, 0x39, 0x93, 0x08, 0xa6, 0x06, 0x08, 0xf6, 0x80, 0x08,
+0x05, 0x19, 0x80, 0xac, 0xe4, 0x78, 0x47, 0xf6, 0x78, 0x4c, 0xe6, 0x70, 0x03, 0x02, 0x13, 0x72,
+0xe5, 0x18, 0x70, 0x12, 0x90, 0x01, 0xea, 0xe0, 0x30, 0xe2, 0x0b, 0x78, 0x89, 0xe2, 0x24, 0x01,
+0xf2, 0x18, 0xe2, 0x34, 0x00, 0xf2, 0x78, 0x52, 0xe6, 0x60, 0x07, 0x90, 0x01, 0xea, 0xe0, 0x20,
+0xe0, 0x0c, 0xe5, 0x18, 0xb4, 0xaa, 0x0f, 0x90, 0x01, 0xea, 0xe0, 0x30, 0xe1, 0x08, 0x90, 0x00,
+0xc8, 0xe0, 0x04, 0xf0, 0x80, 0x08, 0x90, 0x00, 0xc8, 0xe0, 0x60, 0x02, 0x14, 0xf0, 0x90, 0x36,
+0x08, 0xe4, 0x93, 0x75, 0xf0, 0x64, 0xa4, 0xff, 0xd3, 0x78, 0x89, 0xe2, 0x9f, 0x18, 0xe2, 0x95,
+0xf0, 0x50, 0x1b, 0x12, 0x33, 0x19, 0x74, 0x9c, 0x93, 0x24, 0x02, 0xff, 0xe4, 0x33, 0xfe, 0x90,
+0x00, 0xc8, 0xe0, 0xd3, 0x9f, 0xee, 0x64, 0x80, 0xf8, 0x74, 0x80, 0x98, 0x40, 0x14, 0x7f, 0x01,
+0x12, 0x3b, 0x52, 0xe4, 0x78, 0x4c, 0xf6, 0x78, 0x52, 0xf6, 0x78, 0x4d, 0x76, 0x04, 0x78, 0x53,
+0x76, 0x04, 0x12, 0x33, 0x34, 0x78, 0x47, 0xe6, 0xf5, 0x20, 0xad, 0x18, 0x12, 0x14, 0xfa, 0x78,
+0x4c, 0xe6, 0x60, 0x19, 0x90, 0x36, 0x06, 0x7d, 0x64, 0x12, 0x33, 0x47, 0xc3, 0x78, 0x75, 0xe6,
+0x9f, 0x18, 0xe6, 0x9e, 0x50, 0x67, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x80, 0x60, 0x90, 0x01, 0xfe,
+0xe0, 0x70, 0x17, 0x78, 0x75, 0xe6, 0x18, 0x46, 0x60, 0x09, 0x08, 0xe6, 0x16, 0x18, 0x70, 0x0a,
+0x16, 0x80, 0x07, 0x78, 0x74, 0x76, 0x00, 0x08, 0x76, 0x14, 0x12, 0x33, 0x51, 0x80, 0x3e, 0x12,
+0x33, 0x19, 0xe4, 0x93, 0x90, 0x01, 0xcb, 0xf0, 0x90, 0x01, 0xff, 0xe0, 0xb4, 0x01, 0x2e, 0x75,
+0x1f, 0x01, 0x75, 0x20, 0x01, 0x75, 0x21, 0x40, 0x75, 0x22, 0x01, 0x75, 0x23, 0x01, 0x75, 0x24,
+0x80, 0x7b, 0x01, 0x7a, 0x01, 0x79, 0xc0, 0x12, 0x1d, 0x77, 0xe4, 0x90, 0x01, 0xff, 0xf0, 0x75,
+0x8a, 0xa0, 0x90, 0x00, 0xc0, 0xf0, 0x80, 0xd0, 0xe4, 0x90, 0x00, 0xc9, 0xf0, 0x90, 0x01, 0xe5,
+0xe0, 0x64, 0x03, 0x60, 0x0b, 0x90, 0x01, 0xb5, 0xe0, 0x64, 0x03, 0x60, 0x03, 0x02, 0x14, 0x96,
+0x90, 0x36, 0x0e, 0xe4, 0x93, 0xf5, 0x18, 0x7f, 0x01, 0x12, 0x39, 0xf3, 0xe5, 0x18, 0x70, 0x05,
+0x90, 0xff, 0x11, 0x80, 0x0d, 0xe5, 0x18, 0xb4, 0x01, 0x0c, 0x90, 0xff, 0x10, 0xe0, 0x44, 0x18,
+0xf0, 0xa3, 0xe0, 0x44, 0x18, 0xf0, 0x90, 0x01, 0xb5, 0xe0, 0xb4, 0x03, 0x15, 0x90, 0xff, 0x12,
+0xe0, 0x54, 0xe3, 0xf0, 0x90, 0xff, 0x11, 0xe0, 0x54, 0xe3, 0xf0, 0x90, 0xff, 0x10, 0xe0, 0x54,
+0xe3, 0xf0, 0x75, 0x8f, 0x87, 0x75, 0x8e, 0xff, 0x75, 0x8d, 0x87, 0x75, 0x8c, 0xff, 0x12, 0x33,
+0x2b, 0x75, 0x8a, 0xa0, 0xf0, 0xe5, 0x89, 0x30, 0xe7, 0x08, 0x12, 0x33, 0x20, 0x50, 0x03, 0xe0,
+0x04, 0xf0, 0x75, 0x91, 0xc3, 0xe4, 0xf5, 0x91, 0xe5, 0x89, 0x30, 0xe7, 0x08, 0x12, 0x33, 0x20,
+0x50, 0x03, 0xe0, 0x04, 0xf0, 0x12, 0x33, 0x2b, 0x75, 0x8a, 0xa0, 0xf0, 0x75, 0x8a, 0xa0, 0xf0,
+0x75, 0x8a, 0xa0, 0xf0, 0x80, 0xc8, 0x75, 0x18, 0x27, 0x75, 0x19, 0x10, 0xe5, 0x89, 0x30, 0xe7,
+0x08, 0x12, 0x33, 0x20, 0x50, 0x03, 0xe0, 0x04, 0xf0, 0x90, 0x00, 0xc3, 0xe0, 0xff, 0xc3, 0x78,
+0x73, 0x96, 0x50, 0x36, 0xe5, 0x19, 0x15, 0x19, 0xac, 0x18, 0x70, 0x02, 0x15, 0x18, 0x4c, 0x60,
+0x29, 0xe5, 0x89, 0x30, 0xe7, 0x0c, 0x75, 0x89, 0x80, 0xef, 0xc3, 0x94, 0xff, 0x50, 0x03, 0xe0,
+0x04, 0xf0, 0x75, 0x91, 0xc1, 0xe4, 0xf5, 0x91, 0xe5, 0x89, 0x30, 0xe7, 0x08, 0x12, 0x33, 0x20,
+0x50, 0x03, 0xe0, 0x04, 0xf0, 0x12, 0x33, 0x2b, 0x80, 0xbf, 0x22, 0xaf, 0x40, 0xae, 0x3f, 0x12,
+0x23, 0x88, 0xaf, 0x40, 0xae, 0x3f, 0x12, 0x3a, 0x3c, 0x22, 0x8b, 0x1c, 0x8a, 0x1d, 0x89, 0x1e,
+0x8d, 0x1f, 0x90, 0x01, 0xfa, 0xe0, 0xf5, 0x21, 0xe4, 0xf5, 0x22, 0x85, 0x20, 0x20, 0xe5, 0x1f,
+0x60, 0x04, 0x90, 0x00, 0xcb, 0xf0, 0x7d, 0x01, 0x7f, 0x12, 0x12, 0x34, 0x39, 0x75, 0x23, 0x01,
+0x75, 0x24, 0x00, 0x78, 0x78, 0xe6, 0xff, 0x70, 0x0b, 0x74, 0x20, 0x25, 0x24, 0xf5, 0x24, 0xe4,
+0x35, 0x23, 0xf5, 0x23, 0x74, 0x00, 0x2f, 0xf9, 0xe4, 0x34, 0x01, 0xfa, 0x7b, 0x01, 0xa8, 0x24,
+0xac, 0x23, 0x7d, 0x01, 0x7e, 0x00, 0x7f, 0x20, 0x12, 0x0c, 0x68, 0x7e, 0x00, 0x7f, 0x0b, 0x7d,
+0xff, 0xe5, 0x24, 0x24, 0x09, 0xfb, 0xe4, 0x35, 0x23, 0xfa, 0xa9, 0x03, 0x7b, 0x01, 0x12, 0x10,
+0x98, 0x05, 0x24, 0xe5, 0x24, 0xae, 0x23, 0x70, 0x02, 0x05, 0x23, 0x14, 0xf5, 0x82, 0x8e, 0x83,
+0xe4, 0xf0, 0x12, 0x2d, 0x00, 0x90, 0x00, 0x0a, 0x12, 0x2c, 0xb8, 0xff, 0x90, 0x00, 0x04, 0x12,
+0x0c, 0xa7, 0x2f, 0xf5, 0x22, 0x90, 0x00, 0x05, 0x12, 0x0c, 0xa7, 0xb4, 0x04, 0x09, 0x12, 0x2c,
+0xc7, 0x70, 0x04, 0x90, 0x00, 0xca, 0xf0, 0x90, 0x00, 0xca, 0xe0, 0x60, 0x51, 0x14, 0xf0, 0xe0,
+0xff, 0x7e, 0x04, 0x60, 0x02, 0x7e, 0x08, 0x12, 0x2c, 0xee, 0x90, 0x00, 0x05, 0xee, 0x12, 0x0c,
+0xe6, 0xef, 0x60, 0x0b, 0x12, 0x2d, 0x0a, 0x12, 0x0d, 0xbb, 0xff, 0xae, 0xf0, 0x80, 0x10, 0x90,
+0x00, 0xcb, 0xe0, 0xff, 0xb4, 0x05, 0x02, 0x80, 0x02, 0x7f, 0x00, 0xef, 0x7f, 0x00, 0xfe, 0x12,
+0x2c, 0x9f, 0x12, 0x2c, 0xb5, 0xc4, 0x54, 0xf0, 0xfe, 0x12, 0x2d, 0x0a, 0x12, 0x0d, 0xbb, 0xfd,
+0xe5, 0xf0, 0x54, 0x0f, 0xfc, 0xe4, 0x2d, 0xff, 0xee, 0x3c, 0x8f, 0xf0, 0x80, 0x60, 0x12, 0x2c,
+0xb5, 0x70, 0x09, 0x12, 0x2c, 0xc7, 0x70, 0x04, 0xe5, 0x1f, 0x60, 0x57, 0x12, 0x2c, 0xcd, 0x12,
+0x2c, 0x9f, 0x12, 0x2c, 0xb5, 0x60, 0x17, 0xc4, 0x54, 0xf0, 0xfe, 0x12, 0x0d, 0xbb, 0x24, 0x00,
+0xff, 0xee, 0x35, 0xf0, 0xfe, 0x12, 0x2c, 0x7a, 0x12, 0x2c, 0xda, 0x12, 0x0e, 0x6b, 0x12, 0x2c,
+0xc1, 0x60, 0x35, 0xc4, 0x54, 0xf0, 0xfe, 0x90, 0x00, 0x06, 0x12, 0x0d, 0xe6, 0x24, 0x00, 0xff,
+0xee, 0x35, 0xf0, 0xfe, 0x12, 0x2c, 0x9f, 0x12, 0x2c, 0xee, 0x90, 0x00, 0x08, 0x12, 0x0d, 0xe6,
+0x24, 0x00, 0xff, 0xe5, 0xf0, 0x34, 0x10, 0xfe, 0x12, 0x2c, 0x9f, 0x12, 0x2c, 0xda, 0x12, 0x0e,
+0x6b, 0x80, 0x05, 0xe4, 0x90, 0x00, 0xcb, 0xf0, 0x90, 0x01, 0xfe, 0xe0, 0xd3, 0x94, 0xf0, 0x50,
+0x03, 0x02, 0x17, 0x01, 0x12, 0x2d, 0x00, 0xe5, 0x20, 0x60, 0x14, 0x12, 0x2c, 0xcf, 0x12, 0x2c,
+0x9f, 0x7e, 0x00, 0x7f, 0x08, 0x7d, 0x00, 0x12, 0x2d, 0x0a, 0x12, 0x10, 0x98, 0x80, 0x21, 0x12,
+0x2c, 0xcd, 0x12, 0x2c, 0x9f, 0x12, 0x2c, 0xee, 0x12, 0x0d, 0xbb, 0xff, 0xae, 0xf0, 0x12, 0x2c,
+0x7a, 0x90, 0x00, 0x06, 0x12, 0x2c, 0x93, 0x12, 0x2c, 0xee, 0x90, 0x00, 0x08, 0x12, 0x2c, 0x99,
+0x90, 0x01, 0x40, 0x74, 0x40, 0xf0, 0x90, 0x01, 0x60, 0x74, 0x60, 0xf0, 0x75, 0x2b, 0x01, 0x75,
+0x2c, 0x41, 0x75, 0x29, 0x01, 0x75, 0x2a, 0x61, 0xe4, 0xf5, 0x28, 0xaf, 0x28, 0x12, 0x3b, 0x57,
+0xe5, 0x2c, 0xfd, 0x24, 0x02, 0xf5, 0x2c, 0xe5, 0x2b, 0xfc, 0x34, 0x00, 0xf5, 0x2b, 0x12, 0x2d,
+0x11, 0xaf, 0x28, 0x12, 0x3a, 0xff, 0xef, 0xd3, 0x94, 0x1c, 0x40, 0x06, 0x7e, 0x0f, 0x7f, 0xff,
+0x80, 0x05, 0xaf, 0x28, 0x12, 0x3b, 0x25, 0xe5, 0x2a, 0xfd, 0x24, 0x02, 0xf5, 0x2a, 0xe5, 0x29,
+0xfc, 0x34, 0x00, 0xf5, 0x29, 0x12, 0x2d, 0x11, 0x05, 0x28, 0xe5, 0x28, 0xc3, 0x94, 0x10, 0x40,
+0xba, 0x78, 0x78, 0xe6, 0x7f, 0x00, 0x70, 0x02, 0x7f, 0x20, 0x78, 0x78, 0xa6, 0x07, 0xe5, 0x21,
+0x20, 0xe7, 0x2a, 0x30, 0xe6, 0x0a, 0x12, 0x2c, 0xb5, 0x70, 0x22, 0x12, 0x2c, 0xc7, 0x70, 0x1d,
+0xe5, 0x21, 0x30, 0xe5, 0x0f, 0x12, 0x2c, 0xc1, 0xff, 0x90, 0x00, 0x05, 0x12, 0x0c, 0xa7, 0x4f,
+0x54, 0x84, 0x70, 0x09, 0xe5, 0x21, 0x30, 0xe4, 0x0c, 0xe5, 0x1f, 0x60, 0x08, 0x90, 0x01, 0xed,
+0xe0, 0xff, 0x12, 0x32, 0xca, 0x22, 0x75, 0x89, 0x80, 0x90, 0x00, 0xc3, 0xe0, 0xc3, 0x94, 0xff,
+0x22, 0x43, 0xad, 0x04, 0x90, 0xff, 0x50, 0x74, 0x0f, 0xf0, 0x90, 0xff, 0x58, 0xf0, 0x85, 0x42,
+0x82, 0x85, 0x41, 0x83, 0x74, 0x26, 0x93, 0x90, 0xff, 0x48, 0xf0, 0x85, 0x42, 0x82, 0x85, 0x41,
+0x83, 0x74, 0x27, 0x93, 0x90, 0xff, 0x42, 0xf0, 0x90, 0xff, 0x40, 0x74, 0x6c, 0xf0, 0x90, 0xff,
+0x57, 0x74, 0xff, 0xf0, 0x90, 0xff, 0x56, 0xe4, 0xf0, 0x90, 0xff, 0x5f, 0x74, 0xff, 0xf0, 0x90,
+0xff, 0x5e, 0xe4, 0xf0, 0x85, 0x42, 0x82, 0x85, 0x41, 0x83, 0x22, 0x78, 0x61, 0xe6, 0xff, 0x78,
+0x84, 0xe2, 0xfc, 0x08, 0xe2, 0x2f, 0xf5, 0x82, 0xe4, 0x3c, 0xf5, 0x83, 0xe0, 0x22, 0xe5, 0x22,
+0x75, 0xf0, 0x0a, 0xa4, 0x24, 0x03, 0xf5, 0x82, 0xe4, 0x34, 0x02, 0xf5, 0x83, 0x22, 0x90, 0xff,
+0x54, 0xe0, 0x90, 0x01, 0xf0, 0xf0, 0x90, 0xff, 0x5c, 0xe0, 0x90, 0x01, 0xf1, 0xf0, 0x75, 0x8a,
+0xa0, 0xe4, 0x90, 0x00, 0xc0, 0xf0, 0x8c, 0x8f, 0x8d, 0x8e, 0x75, 0x8a, 0xa0, 0xf0, 0x90, 0xff,
+0x43, 0x74, 0x5f, 0xf0, 0xe5, 0x89, 0x22, 0xe5, 0x27, 0x75, 0xf0, 0x0a, 0xa4, 0x24, 0x05, 0xf5,
+0x82, 0xe4, 0x34, 0x02, 0xf5, 0x83, 0x22, 0x78, 0x61, 0xe6, 0xff, 0x24, 0xb7, 0xf5, 0x82, 0xe4,
+0x34, 0x02, 0xf5, 0x83, 0xe0, 0x90, 0xff, 0x54, 0xf0, 0x18, 0xe6, 0x24, 0xb7, 0xf5, 0x82, 0xe4,
+0x34, 0x02, 0xf5, 0x83, 0xe0, 0x90, 0xff, 0x5c, 0xf0, 0xef, 0xc3, 0x13, 0xff, 0xe5, 0x42, 0x24,
+0x1a, 0xf5, 0x82, 0xe4, 0x35, 0x41, 0xf5, 0x83, 0xe5, 0x82, 0x2f, 0xf5, 0x82, 0xe4, 0x35, 0x83,
+0xf5, 0x83, 0xe4, 0x93, 0x90, 0xff, 0x55, 0xf0, 0x22, 0xe0, 0xfc, 0xa3, 0xe0, 0xfd, 0xef, 0x75,
+0xf0, 0x0a, 0xa4, 0x24, 0x09, 0xf5, 0x82, 0xe4, 0x34, 0x02, 0xf5, 0x83, 0x22, 0xff, 0xa8, 0x0f,
+0x08, 0x08, 0xe6, 0xfa, 0x08, 0xe6, 0xf5, 0x82, 0x8a, 0x83, 0x22, 0x74, 0x28, 0x93, 0x90, 0xff,
+0x55, 0xf0, 0x90, 0x01, 0xf0, 0xe0, 0x90, 0xff, 0x54, 0xf0, 0x90, 0x01, 0xf1, 0xe0, 0x90, 0xff,
+0x5c, 0xf0, 0x90, 0xff, 0x48, 0xe0, 0xff, 0x7e, 0x00, 0xc3, 0x94, 0x07, 0xee, 0x94, 0x00, 0x22,
+0x75, 0x91, 0xc3, 0xe4, 0xf5, 0x91, 0xe5, 0x89, 0x22, 0xfd, 0x7c, 0x00, 0xe6, 0xfa, 0x08, 0xe6,
+0xfb, 0xc3, 0x9d, 0xff, 0xea, 0x9c, 0xfe, 0xef, 0x78, 0x03, 0x22, 0xce, 0xa2, 0xe7, 0x13, 0xce,
+0x13, 0x22, 0xad, 0x8e, 0xac, 0x8f, 0x75, 0x8a, 0xa0, 0xe4, 0x90, 0x00, 0xc0, 0x22, 0x90, 0xff,
+0x52, 0xe0, 0xfe, 0xa3, 0xe0, 0xa6, 0x06, 0x08, 0xf6, 0x90, 0xff, 0x5a, 0xe0, 0xfe, 0xa3, 0xe0,
+0x22, 0xe5, 0x27, 0x75, 0xf0, 0x0a, 0xa4, 0x24, 0x07, 0xf5, 0x82, 0xe4, 0x34, 0x02, 0xf5, 0x83,
+0x22, 0xd3, 0xe5, 0x2a, 0x94, 0x00, 0xe5, 0x29, 0x64, 0x80, 0x94, 0x80, 0x22, 0x90, 0xff, 0x52,
+0xe0, 0xfa, 0xa3, 0xe0, 0xc3, 0x9f, 0xea, 0x9e, 0x22, 0x90, 0xff, 0x5f, 0xf0, 0xed, 0x2b, 0xff,
+0xec, 0x3a, 0xfe, 0xef, 0x78, 0x03, 0x22, 0x7f, 0xb4, 0x7b, 0x01, 0x7a, 0x02, 0x79, 0x03, 0x02,
+0x10, 0x98, 0x90, 0xff, 0x5e, 0xf0, 0x90, 0xff, 0x56, 0xe0, 0xff, 0xa3, 0xe0, 0xd3, 0x9f, 0x22,
+0x75, 0x91, 0xc1, 0xe4, 0xf5, 0x91, 0xe5, 0x89, 0x22, 0x78, 0x84, 0xe2, 0xfc, 0x08, 0xe2, 0x22,
+0x74, 0xb7, 0x25, 0x22, 0xf5, 0x82, 0xe4, 0x34, 0x02, 0xf5, 0x83, 0xe0, 0xff, 0xe5, 0x26, 0x22,
+0xe5, 0x27, 0x75, 0xf0, 0x0a, 0xa4, 0x24, 0x08, 0xf5, 0x82, 0xe4, 0x34, 0x02, 0xf5, 0x83, 0x22,
+0xd3, 0x74, 0x05, 0x93, 0x9f, 0x74, 0x04, 0x93, 0x9e, 0x22, 0x75, 0xf0, 0x0a, 0xa4, 0x24, 0x0b,
+0xf5, 0x82, 0xe4, 0x34, 0x02, 0xf5, 0x83, 0x22, 0x90, 0xff, 0x43, 0x74, 0x9f, 0xf0, 0x22, 0x78,
+0x83, 0xe2, 0x90, 0xff, 0x40, 0xf0, 0x22, 0xe5, 0x42, 0x24, 0x2b, 0xff, 0xe4, 0x35, 0x41, 0xa9,
+0x07, 0x22, 0xef, 0x24, 0x01, 0xff, 0xee, 0x33, 0xfe, 0xef, 0x78, 0x07, 0x22, 0xe5, 0x22, 0xc3,
+0x78, 0x6a, 0x96, 0x22, 0xe0, 0xfc, 0xa3, 0xe0, 0xc3, 0x9f, 0x22, 0x8f, 0x23, 0x12, 0x05, 0x40,
+0xe2, 0xfb, 0x12, 0x00, 0x60, 0x12, 0x04, 0x02, 0x12, 0x0d, 0x1a, 0x8e, 0x2f, 0x8f, 0x30, 0xeb,
+0x70, 0x5f, 0x75, 0x24, 0x01, 0x12, 0x05, 0x6f, 0xe4, 0xf5, 0x29, 0xf5, 0x2a, 0x78, 0x61, 0xe2,
+0xfe, 0x08, 0xe2, 0xff, 0x78, 0x60, 0x12, 0x02, 0xc1, 0x78, 0x65, 0xe2, 0xfe, 0x08, 0xe2, 0xff,
+0x78, 0x64, 0x12, 0x04, 0x76, 0xc3, 0x74, 0x09, 0x93, 0x94, 0x00, 0x50, 0x05, 0x12, 0x05, 0x7b,
+0x80, 0x04, 0xae, 0x27, 0xaf, 0x28, 0x8e, 0x2d, 0x8f, 0x2e, 0x12, 0x00, 0x60, 0x74, 0x09, 0x93,
+0xfc, 0x74, 0x0a, 0x12, 0x02, 0x7d, 0x40, 0x06, 0xae, 0x2d, 0xaf, 0x2e, 0x80, 0x04, 0x7e, 0x00,
+0x7f, 0x01, 0x8e, 0x27, 0x8f, 0x28, 0x78, 0x69, 0xe2, 0xfe, 0x08, 0xe2, 0xff, 0x78, 0x68, 0x80,
+0x76, 0x78, 0x6c, 0xe6, 0x14, 0x6b, 0x70, 0x7a, 0xf5, 0x24, 0x12, 0x05, 0x6f, 0x12, 0x00, 0x60,
+0x74, 0x03, 0x93, 0xf5, 0x29, 0x74, 0x04, 0x93, 0xf5, 0x2a, 0x12, 0x00, 0xec, 0x12, 0x02, 0xb9,
+0xeb, 0x25, 0xe0, 0x25, 0xe0, 0x24, 0x5d, 0x12, 0x00, 0xf3, 0xeb, 0x25, 0xe0, 0x25, 0xe0, 0x24,
+0x5c, 0x12, 0x04, 0x75, 0xc3, 0x74, 0x0b, 0x93, 0x94, 0x00, 0x50, 0x05, 0x12, 0x05, 0x7b, 0x80,
+0x04, 0xae, 0x27, 0xaf, 0x28, 0x8e, 0x2d, 0x8f, 0x2e, 0x12, 0x00, 0x60, 0x74, 0x0b, 0x93, 0xfc,
+0x74, 0x0c, 0x12, 0x02, 0x7d, 0x40, 0x06, 0xae, 0x2d, 0xaf, 0x2e, 0x80, 0x04, 0x7e, 0x00, 0x7f,
+0x01, 0x8e, 0x27, 0x8f, 0x28, 0xeb, 0x25, 0xe0, 0x25, 0xe0, 0x24, 0x59, 0x12, 0x00, 0xf3, 0xeb,
+0x25, 0xe0, 0x25, 0xe0, 0x24, 0x58, 0xf8, 0xe2, 0x2f, 0xf5, 0x2c, 0x18, 0xe2, 0x3e, 0xf5, 0x2b,
+0x80, 0x7d, 0xeb, 0xfd, 0x7c, 0x00, 0xae, 0x2f, 0xaf, 0x30, 0x12, 0x0d, 0x08, 0xac, 0x06, 0xad,
+0x07, 0xe5, 0x2f, 0xc3, 0x13, 0xfe, 0xe5, 0x30, 0x13, 0x2d, 0xf5, 0x2a, 0xec, 0x3e, 0xf5, 0x29,
+0xeb, 0x25, 0xe0, 0x25, 0xe0, 0x24, 0x5d, 0x12, 0x00, 0xf3, 0xeb, 0x25, 0xe0, 0x25, 0xe0, 0x24,
+0x5c, 0x12, 0x02, 0xc0, 0xeb, 0x25, 0xe0, 0x25, 0xe0, 0x24, 0x65, 0x12, 0x00, 0xf3, 0xeb, 0x25,
+0xe0, 0x25, 0xe0, 0x24, 0x64, 0x12, 0x04, 0x75, 0xd3, 0xe5, 0x26, 0x95, 0x28, 0xe5, 0x27, 0x64,
+0x80, 0xf8, 0xe5, 0x25, 0x64, 0x80, 0x98, 0x40, 0x11, 0xe4, 0xf5, 0x24, 0x85, 0x27, 0x2b, 0x85,
+0x28, 0x2c, 0x85, 0x25, 0x27, 0x85, 0x26, 0x28, 0x80, 0x0f, 0x75, 0x24, 0x01, 0x85, 0x25, 0x2b,
+0x85, 0x26, 0x2c, 0x85, 0x27, 0x27, 0x85, 0x28, 0x28, 0x12, 0x00, 0xec, 0x12, 0x02, 0xb9, 0xc3,
+0xe5, 0x26, 0x95, 0x2c, 0xf5, 0x26, 0xe5, 0x25, 0x95, 0x2b, 0xf5, 0x25, 0xc3, 0x64, 0x80, 0x94,
+0x80, 0x50, 0x05, 0xe4, 0xf5, 0x25, 0xf5, 0x26, 0xc3, 0xe5, 0x28, 0x95, 0x2c, 0xf5, 0x28, 0xe5,
+0x27, 0x95, 0x2b, 0xf5, 0x27, 0xc3, 0x64, 0x80, 0x94, 0x80, 0x50, 0x05, 0xe4, 0xf5, 0x27, 0xf5,
+0x28, 0x85, 0x27, 0x2b, 0x85, 0x28, 0x2c, 0xae, 0x2b, 0xaf, 0x2c, 0x12, 0x03, 0xd3, 0xe4, 0x7b,
+0x80, 0xfa, 0xf9, 0xf8, 0x12, 0x01, 0x2b, 0xae, 0x2f, 0xaf, 0x30, 0x12, 0x04, 0x86, 0xc0, 0x06,
+0xc0, 0x07, 0xe5, 0x26, 0x25, 0x28, 0xcf, 0xe5, 0x25, 0x35, 0x27, 0xcf, 0x24, 0x01, 0xcf, 0x34,
+0x00, 0xab, 0x07, 0xfa, 0x33, 0x95, 0xe0, 0xf9, 0xf8, 0xd0, 0x07, 0xd0, 0x06, 0x12, 0x0f, 0x42,
+0xef, 0x12, 0x05, 0xe7, 0xe4, 0x3d, 0xfd, 0xe4, 0x3c, 0xfc, 0xe4, 0x7b, 0x80, 0xfa, 0xf9, 0xf8,
+0x12, 0x0f, 0x42, 0x8e, 0x2b, 0x8f, 0x2c, 0xe5, 0x24, 0x60, 0x0e, 0xe5, 0x2a, 0x25, 0x2c, 0xf5,
+0x2c, 0xe5, 0x29, 0x35, 0x2b, 0xf5, 0x2b, 0x80, 0x0d, 0xc3, 0xe5, 0x2a, 0x95, 0x2c, 0xf5, 0x2c,
+0xe5, 0x29, 0x95, 0x2b, 0xf5, 0x2b, 0xe5, 0x23, 0x12, 0x05, 0x17, 0xf8, 0xe5, 0x2b, 0xf2, 0x08,
+0xe5, 0x2c, 0xf2, 0x22, 0x8b, 0x1c, 0x8a, 0x1d, 0x89, 0x1e, 0x8d, 0x1f, 0xe4, 0xf5, 0x22, 0x90,
+0x00, 0x05, 0x12, 0x0c, 0xa7, 0xf5, 0x23, 0x90, 0x00, 0x0b, 0x12, 0x0c, 0xa7, 0x60, 0x08, 0xe4,
+0x78, 0x8a, 0xf2, 0x90, 0x00, 0xbf, 0xf0, 0xe5, 0x23, 0xb4, 0x80, 0x29, 0x78, 0x8a, 0x74, 0xff,
+0xf2, 0x12, 0x39, 0xa1, 0x90, 0x00, 0xb9, 0xe5, 0xf0, 0xf0, 0xa3, 0xef, 0xf0, 0x12, 0x39, 0xb2,
+0x90, 0x00, 0xbb, 0xe5, 0xf0, 0xf0, 0xa3, 0xef, 0xf0, 0xe4, 0xa3, 0xf0, 0xa3, 0xf0, 0xa3, 0xe0,
+0x04, 0xf0, 0x02, 0x1d, 0x48, 0xe5, 0x23, 0x64, 0x08, 0x60, 0x03, 0x02, 0x1c, 0xf5, 0x12, 0x39,
+0xa1, 0xc3, 0x90, 0x00, 0xba, 0xe0, 0x90, 0x00, 0xb9, 0x12, 0x1d, 0x6d, 0x8e, 0x24, 0x8f, 0x25,
+0x12, 0x39, 0xac, 0xc3, 0x90, 0x00, 0xbc, 0xe0, 0x90, 0x00, 0xbb, 0x12, 0x1d, 0x6d, 0x12, 0x39,
+0x9a, 0x74, 0x01, 0x93, 0xfc, 0x74, 0x02, 0x12, 0x39, 0xba, 0x40, 0x12, 0x90, 0x01, 0xec, 0xe0,
+0x30, 0xe0, 0x0b, 0x78, 0x8a, 0xe2, 0x54, 0xfe, 0xf2, 0xe4, 0x90, 0x00, 0xbf, 0xf0, 0xe5, 0x25,
+0x2f, 0xfd, 0xe5, 0x24, 0x3e, 0xfc, 0x12, 0x39, 0x9a, 0x74, 0x05, 0x93, 0xfb, 0xd3, 0xed, 0x9b,
+0xec, 0x94, 0x00, 0x40, 0x0b, 0x78, 0x8a, 0xe2, 0x54, 0xfc, 0xf2, 0xe4, 0x90, 0x00, 0xbf, 0xf0,
+0x12, 0x39, 0x9a, 0x74, 0x03, 0x93, 0xfc, 0x74, 0x04, 0x12, 0x39, 0xba, 0x40, 0x13, 0x78, 0x8a,
+0xe2, 0x20, 0xe1, 0x04, 0xe5, 0x1f, 0x60, 0x09, 0x75, 0x22, 0x0c, 0xe4, 0x78, 0x8a, 0xf2, 0xf5,
+0x1f, 0x78, 0x8a, 0xe2, 0x54, 0x3c, 0x70, 0x03, 0x02, 0x1d, 0x48, 0x12, 0x39, 0x9a, 0x74, 0x06,
+0x93, 0xfd, 0x7c, 0x00, 0xd3, 0xe5, 0x25, 0x9d, 0xe5, 0x24, 0x9c, 0x50, 0x09, 0xef, 0x9d, 0xee,
+0x9c, 0x50, 0x03, 0x02, 0x1d, 0x48, 0xd3, 0xef, 0x95, 0x25, 0xee, 0x95, 0x24, 0x40, 0x17, 0x12,
+0x39, 0xac, 0xd3, 0x90, 0x00, 0xbc, 0xe0, 0x9f, 0x90, 0x00, 0xbb, 0xe0, 0x95, 0xf0, 0x7f, 0x02,
+0x40, 0x02, 0x7f, 0x01, 0x80, 0x15, 0x12, 0x39, 0xa1, 0xd3, 0x90, 0x00, 0xba, 0xe0, 0x9f, 0x90,
+0x00, 0xb9, 0xe0, 0x95, 0xf0, 0x7f, 0x04, 0x40, 0x02, 0x7f, 0x03, 0x8f, 0x22, 0x78, 0x8a, 0xe2,
+0x54, 0xc3, 0xf2, 0x80, 0x53, 0xe5, 0x23, 0xb4, 0x04, 0x09, 0xe4, 0x90, 0x00, 0xbd, 0xf0, 0xa3,
+0xf0, 0x80, 0x45, 0x12, 0x39, 0x9a, 0x74, 0x01, 0x93, 0xfe, 0x74, 0x02, 0x93, 0xff, 0xd3, 0x90,
+0x00, 0xbe, 0xe0, 0x9f, 0x90, 0x00, 0xbd, 0xe0, 0x9e, 0x50, 0x07, 0x90, 0x01, 0xec, 0xe0, 0x20,
+0xe0, 0x26, 0x78, 0x8a, 0xe2, 0xff, 0x30, 0xe0, 0x1a, 0x90, 0x00, 0xbf, 0xe0, 0xfe, 0xd3, 0x94,
+0x02, 0x50, 0x0a, 0xee, 0x7e, 0x0b, 0xb4, 0x01, 0x02, 0x7e, 0x05, 0x8e, 0x22, 0xef, 0x54, 0xfe,
+0x78, 0x8a, 0xf2, 0xe4, 0x90, 0x00, 0xbf, 0xf0, 0xc3, 0x90, 0x00, 0xbd, 0xe0, 0x94, 0xff, 0x50,
+0x13, 0x12, 0x39, 0x9a, 0xe4, 0x93, 0xff, 0x90, 0x00, 0xbe, 0xe0, 0x2f, 0xf0, 0x90, 0x00, 0xbd,
+0xe0, 0x34, 0x00, 0xf0, 0xe5, 0x1f, 0xaf, 0x1f, 0x70, 0x02, 0xaf, 0x22, 0x22, 0x9f, 0xff, 0xe0,
+0x95, 0xf0, 0xfe, 0x12, 0x3b, 0x31, 0x22, 0x8b, 0x1c, 0x8a, 0x1d, 0x89, 0x1e, 0x43, 0xad, 0x04,
+0x90, 0xff, 0x40, 0xe0, 0x20, 0xe0, 0xf9, 0x43, 0x95, 0x80, 0x90, 0xff, 0x41, 0x74, 0x37, 0xf0,
+0x90, 0xff, 0x49, 0x74, 0x0d, 0xf0, 0xe4, 0xf5, 0x25, 0xf5, 0x25, 0x12, 0x34, 0xdd, 0xe5, 0x25,
+0xc3, 0x9f, 0x50, 0x22, 0xe9, 0x24, 0x0c, 0xf9, 0xe4, 0x3a, 0x12, 0x34, 0xce, 0xe4, 0xfd, 0x12,
+0x39, 0x6b, 0x12, 0x34, 0xc4, 0x7d, 0x08, 0x12, 0x32, 0x1e, 0x12, 0x34, 0xc4, 0xe4, 0xfd, 0x12,
+0x34, 0x39, 0x05, 0x25, 0x80, 0xd5, 0x90, 0xff, 0x4a, 0xe4, 0xf0, 0x90, 0xff, 0x50, 0x74, 0x0f,
+0xf0, 0x90, 0xff, 0x58, 0xe4, 0xf0, 0x90, 0xff, 0x40, 0x74, 0x08, 0xf0, 0x90, 0xff, 0x43, 0x74,
+0x9f, 0xf0, 0xab, 0x1c, 0xaa, 0x1d, 0xa9, 0x1e, 0x12, 0x0c, 0x8e, 0x90, 0xff, 0x48, 0xf0, 0x90,
+0x00, 0x01, 0x12, 0x0c, 0xa7, 0x90, 0xff, 0x42, 0xf0, 0x90, 0x00, 0x02, 0x12, 0x0c, 0xa7, 0x90,
+0xff, 0x55, 0xf0, 0x90, 0x00, 0x03, 0x12, 0x0c, 0xa7, 0x90, 0xff, 0x54, 0xf0, 0x90, 0xff, 0x5c,
+0xe4, 0xf0, 0xf5, 0x25, 0x12, 0x34, 0xdd, 0xe5, 0x25, 0xc3, 0x9f, 0x50, 0x5b, 0xe4, 0xf5, 0x26,
+0x75, 0x27, 0x64, 0x90, 0xff, 0x50, 0xe0, 0x20, 0xe7, 0x03, 0x43, 0x26, 0x01, 0xe5, 0x26, 0x64,
+0x01, 0x60, 0x03, 0xd5, 0x27, 0xed, 0x12, 0x34, 0xeb, 0x12, 0x34, 0xc4, 0x7d, 0x06, 0x12, 0x32,
+0x1e, 0x90, 0xff, 0x40, 0x74, 0x29, 0xf0, 0x90, 0xff, 0x40, 0xe0, 0x20, 0xe0, 0xf9, 0x12, 0x34,
+0xc4, 0x7d, 0x08, 0x12, 0x32, 0x1e, 0x90, 0xff, 0x52, 0xe0, 0xfe, 0xa3, 0xe0, 0xff, 0xab, 0x1f,
+0xe5, 0x21, 0xf9, 0x24, 0x02, 0xf5, 0x21, 0xe5, 0x20, 0xfa, 0x34, 0x00, 0xf5, 0x20, 0xee, 0x8f,
+0xf0, 0x12, 0x0e, 0x6b, 0x05, 0x25, 0x80, 0x9c, 0xe4, 0xf5, 0x25, 0x90, 0xff, 0x54, 0xf0, 0x75,
+0x28, 0x01, 0x12, 0x34, 0xf4, 0x74, 0xff, 0x12, 0x34, 0xc1, 0x7d, 0x07, 0x12, 0x32, 0x1e, 0x90,
+0xff, 0x55, 0x74, 0x64, 0xf0, 0xe4, 0xf5, 0x26, 0xf5, 0x27, 0x90, 0xff, 0x50, 0xe0, 0x30, 0xe7,
+0x10, 0x05, 0x27, 0xe5, 0x27, 0x70, 0x02, 0x05, 0x26, 0xb4, 0xe8, 0xee, 0xe5, 0x26, 0xb4, 0x03,
+0xe9, 0xe5, 0x28, 0x24, 0x02, 0x90, 0xff, 0x55, 0xf0, 0xe4, 0xf5, 0x26, 0xf5, 0x27, 0x00, 0x05,
+0x27, 0xe5, 0x27, 0x70, 0x02, 0x05, 0x26, 0xb4, 0xe8, 0xf4, 0xe5, 0x26, 0xb4, 0x03, 0xef, 0xe4,
+0xf5, 0x29, 0xf5, 0x26, 0xf5, 0x27, 0x90, 0xff, 0x50, 0xe0, 0x30, 0xe7, 0x03, 0x00, 0x80, 0x02,
+0x05, 0x29, 0x05, 0x27, 0xe5, 0x27, 0x70, 0x02, 0x05, 0x26, 0x64, 0x64, 0x45, 0x26, 0x70, 0xe6,
+0xe5, 0x29, 0xd3, 0x94, 0x28, 0x50, 0x0c, 0x12, 0x34, 0xeb, 0x05, 0x28, 0xe5, 0x28, 0xc3, 0x94,
+0x64, 0x40, 0xae, 0x12, 0x34, 0xf4, 0xe5, 0x28, 0x12, 0x34, 0xc1, 0x7d, 0x08, 0x12, 0x32, 0x1e,
+0x12, 0x34, 0xeb, 0x12, 0x34, 0xdd, 0x05, 0x25, 0xe5, 0x25, 0xc3, 0x9f, 0x50, 0x03, 0x02, 0x1e,
+0x7f, 0x90, 0xff, 0x50, 0xe4, 0xf0, 0xff, 0x22, 0xe4, 0x78, 0x67, 0xf6, 0x18, 0xe6, 0x14, 0x70,
+0x03, 0x02, 0x20, 0x08, 0x14, 0x70, 0x03, 0x02, 0x20, 0x79, 0x24, 0x02, 0x60, 0x03, 0x02, 0x20,
+0x9b, 0x12, 0x17, 0x94, 0xe4, 0x93, 0x78, 0x6a, 0xf6, 0x78, 0x65, 0xe6, 0x30, 0xe0, 0x08, 0x75,
+0x23, 0x05, 0x75, 0x24, 0x01, 0x80, 0x06, 0x75, 0x23, 0x08, 0xe4, 0xf5, 0x24, 0xe4, 0xf5, 0x22,
+0x12, 0x19, 0x7d, 0x50, 0x3f, 0x12, 0x19, 0x19, 0x25, 0x22, 0x12, 0x17, 0xa6, 0xf5, 0x25, 0xe5,
+0x22, 0x54, 0x01, 0xfd, 0xaf, 0x25, 0x12, 0x39, 0x6b, 0xad, 0x24, 0xaf, 0x25, 0x12, 0x34, 0x39,
+0xad, 0x23, 0xaf, 0x25, 0x12, 0x32, 0x1e, 0x78, 0x65, 0xe6, 0xb4, 0x03, 0x13, 0xe5, 0x22, 0x30,
+0xe0, 0x0e, 0xe4, 0xfd, 0xaf, 0x25, 0x12, 0x34, 0x39, 0x7d, 0x08, 0xaf, 0x25, 0x12, 0x32, 0x1e,
+0x05, 0x22, 0x80, 0xbc, 0x78, 0x62, 0xe6, 0xf5, 0x25, 0x75, 0x26, 0x10, 0x76, 0x40, 0x7e, 0x00,
+0x7f, 0x12, 0x7d, 0x10, 0x7b, 0x01, 0x7a, 0x02, 0x79, 0xb7, 0x12, 0x10, 0x98, 0xe5, 0x26, 0xd3,
+0x94, 0x01, 0x40, 0x3c, 0x12, 0x20, 0xa0, 0x12, 0x19, 0x7d, 0x50, 0x2c, 0x12, 0x17, 0x94, 0x74,
+0x02, 0x93, 0x75, 0xf0, 0xa3, 0xa4, 0xff, 0xae, 0xf0, 0x12, 0x17, 0xae, 0x12, 0x19, 0x84, 0xec,
+0x9e, 0x50, 0x08, 0x12, 0x19, 0x20, 0xf4, 0xfe, 0xef, 0x5e, 0xf0, 0x12, 0x19, 0x20, 0xc3, 0x13,
+0xfe, 0xef, 0x4e, 0xf0, 0x05, 0x22, 0x80, 0xcf, 0xe5, 0x26, 0xc3, 0x13, 0xf5, 0x26, 0x80, 0xbd,
+0x78, 0x62, 0xa6, 0x25, 0x78, 0x66, 0x76, 0x01, 0x12, 0x17, 0x94, 0x74, 0x05, 0x93, 0x25, 0xe0,
+0xf5, 0x25, 0x74, 0x04, 0x93, 0x33, 0xf5, 0x24, 0xe4, 0x78, 0x69, 0xf6, 0xfe, 0xfd, 0x12, 0x18,
+0xf7, 0x7e, 0x00, 0x7f, 0x24, 0x7d, 0x00, 0x7b, 0xfe, 0x7a, 0x00, 0x79, 0x5f, 0x12, 0x10, 0x98,
+0x75, 0x23, 0x04, 0x12, 0x32, 0x78, 0x12, 0x20, 0xa0, 0x12, 0x19, 0x7d, 0x50, 0x34, 0x12, 0x17,
+0xae, 0xe0, 0xfe, 0xa3, 0xe0, 0x78, 0x02, 0xce, 0xc3, 0x13, 0xce, 0x13, 0xd8, 0xf9, 0xff, 0xe5,
+0x22, 0x12, 0x17, 0xe9, 0xee, 0x8f, 0xf0, 0x12, 0x0d, 0xa5, 0xe5, 0x22, 0x12, 0x17, 0xe9, 0xe0,
+0xfe, 0xa3, 0xe0, 0xff, 0xe5, 0x22, 0x12, 0x19, 0x4a, 0xee, 0xf0, 0xa3, 0xef, 0xf0, 0x05, 0x22,
+0x80, 0xc7, 0xd5, 0x23, 0xc1, 0x78, 0x66, 0x76, 0x02, 0x12, 0x32, 0x78, 0x12, 0x27, 0x61, 0x78,
+0x6a, 0xe6, 0xfd, 0xe4, 0xff, 0x12, 0x30, 0xdb, 0x78, 0x67, 0xe6, 0x30, 0xe1, 0x04, 0x78, 0x69,
+0x76, 0x28, 0x78, 0x6a, 0xe6, 0xfd, 0xe4, 0xff, 0x02, 0x22, 0x21, 0xe4, 0x78, 0x66, 0xf6, 0x22,
+0x12, 0x27, 0x61, 0x12, 0x32, 0x78, 0xe4, 0xf5, 0x22, 0x22, 0x8b, 0x1c, 0x8a, 0x1d, 0x89, 0x1e,
+0xe4, 0xf5, 0x1f, 0xfe, 0x7f, 0x0c, 0xfd, 0x12, 0x10, 0x98, 0x7a, 0x00, 0x79, 0x02, 0x12, 0x04,
+0x58, 0x7a, 0x00, 0x79, 0x31, 0x12, 0x04, 0x58, 0x78, 0x72, 0xe6, 0x14, 0x60, 0x30, 0x04, 0x60,
+0x03, 0x02, 0x22, 0x1a, 0xe4, 0x78, 0x71, 0xf6, 0xff, 0x12, 0x3b, 0x52, 0x12, 0x1f, 0x28, 0x78,
+0x67, 0xe6, 0x30, 0xe4, 0x03, 0x02, 0x22, 0x1e, 0x7e, 0x00, 0x7f, 0x5e, 0x7d, 0x00, 0x7b, 0xfe,
+0x7a, 0x00, 0x79, 0x01, 0x12, 0x10, 0x98, 0x78, 0x72, 0x76, 0x01, 0x02, 0x22, 0x12, 0x12, 0x1f,
+0x28, 0x78, 0x67, 0xe6, 0xff, 0x30, 0xe4, 0x03, 0x02, 0x22, 0x1a, 0xef, 0x20, 0xe3, 0x03, 0x02,
+0x21, 0xbe, 0x90, 0x00, 0x8b, 0xe0, 0x30, 0xe1, 0x39, 0x7b, 0x00, 0x7a, 0x00, 0x79, 0x21, 0x12,
+0x2a, 0xad, 0xef, 0x60, 0x2d, 0x90, 0x00, 0x8b, 0x74, 0x02, 0xf0, 0x78, 0x06, 0x14, 0xf2, 0x78,
+0x02, 0x14, 0xf2, 0x08, 0xe5, 0x21, 0xf2, 0x12, 0x00, 0x60, 0x74, 0x03, 0x93, 0xfc, 0x74, 0x04,
+0x93, 0xfd, 0xec, 0xc3, 0x13, 0xfe, 0xed, 0x13, 0xff, 0xed, 0x2f, 0x78, 0x05, 0xf2, 0xec, 0x3e,
+0x18, 0xf2, 0x90, 0x00, 0x8b, 0xe0, 0x30, 0xe0, 0x5b, 0x75, 0x25, 0x00, 0x75, 0x26, 0x00, 0x75,
+0x27, 0x6d, 0x75, 0x28, 0x00, 0x75, 0x29, 0x00, 0x75, 0x2a, 0x6f, 0x7b, 0xfe, 0x7a, 0x00, 0x79,
+0x5f, 0x12, 0x29, 0xaf, 0xe4, 0xf5, 0x20, 0xe5, 0x20, 0x12, 0x03, 0x72, 0xff, 0xe5, 0x20, 0x12,
+0x05, 0x41, 0xef, 0xf2, 0xf4, 0x60, 0x1b, 0xe5, 0x20, 0x12, 0x05, 0xb8, 0xf9, 0xe4, 0xfa, 0x7b,
+0xfe, 0xad, 0x20, 0x12, 0x3b, 0x19, 0xe5, 0x20, 0x75, 0xf0, 0x2f, 0xa4, 0x24, 0x06, 0xf8, 0x74,
+0x01, 0xf2, 0x05, 0x20, 0xe5, 0x20, 0xc3, 0x94, 0x02, 0x40, 0xcc, 0x12, 0x2b, 0x9c, 0x90, 0x00,
+0x8b, 0x74, 0x01, 0xf0, 0x78, 0x67, 0xe6, 0x30, 0xe5, 0x04, 0x78, 0x71, 0x76, 0x01, 0x90, 0x00,
+0x8b, 0xe0, 0xf5, 0x1f, 0x78, 0x6b, 0x76, 0x01, 0xe4, 0xf5, 0x20, 0xe5, 0x20, 0xc3, 0x94, 0x02,
+0x50, 0x19, 0x90, 0x00, 0x8b, 0xe0, 0x30, 0xe0, 0x05, 0xaf, 0x20, 0x12, 0x3b, 0x3d, 0x12, 0x31,
+0xb9, 0x05, 0x20, 0x78, 0x6b, 0x74, 0x2f, 0x26, 0xf6, 0x80, 0xe0, 0xa8, 0x1e, 0xac, 0x1d, 0xad,
+0x1c, 0x12, 0x02, 0x9f, 0xe5, 0x1e, 0x24, 0x06, 0xf9, 0xe4, 0x35, 0x1d, 0xa8, 0x01, 0xfc, 0xad,
+0x1c, 0x7a, 0x00, 0x79, 0x31, 0x12, 0x02, 0xa3, 0x78, 0x0d, 0xe2, 0x70, 0x11, 0x78, 0x3c, 0xe2,
+0x70, 0x0c, 0x90, 0x00, 0x8b, 0x74, 0x03, 0xf0, 0x80, 0x04, 0xe4, 0x78, 0x72, 0xf6, 0xaf, 0x1f,
+0x22, 0x8f, 0x27, 0x8d, 0x28, 0x78, 0x69, 0xe6, 0x60, 0x01, 0x16, 0x12, 0x17, 0xe7, 0xe0, 0xfe,
+0xa3, 0xe0, 0xff, 0xe5, 0x27, 0x12, 0x17, 0xb0, 0x12, 0x19, 0x84, 0xf5, 0x2a, 0xec, 0x9e, 0xf5,
+0x29, 0x12, 0x19, 0x30, 0xe0, 0xf5, 0x2b, 0xe4, 0xf5, 0x2c, 0x12, 0x18, 0xd1, 0x40, 0x06, 0xae,
+0x29, 0xaf, 0x2a, 0x80, 0x04, 0x7e, 0x00, 0x7f, 0x00, 0xe5, 0x27, 0x25, 0xe0, 0x24, 0x5f, 0xf8,
+0xee, 0xf2, 0x08, 0xef, 0xf2, 0x90, 0x36, 0x0b, 0xe4, 0x93, 0x60, 0x07, 0x78, 0x69, 0xe6, 0xf5,
+0x2c, 0x80, 0x0f, 0x12, 0x18, 0xd1, 0x7f, 0x00, 0x40, 0x02, 0x7f, 0x01, 0xef, 0x78, 0x69, 0x56,
+0xf5, 0x2c, 0xe5, 0x2c, 0x60, 0x03, 0x02, 0x23, 0x3d, 0xaf, 0x2a, 0xae, 0x29, 0x12, 0x3b, 0x31,
+0x12, 0x17, 0x94, 0xc3, 0x12, 0x19, 0x41, 0x50, 0x0d, 0x12, 0x18, 0xd2, 0x40, 0x04, 0x05, 0x2b,
+0x80, 0x57, 0x15, 0x2b, 0x80, 0x53, 0x12, 0x18, 0xc1, 0xe0, 0xff, 0x33, 0x95, 0xe0, 0xfe, 0xef,
+0x25, 0x2a, 0xf5, 0x2a, 0xee, 0x35, 0x29, 0xf5, 0x29, 0xd3, 0xe5, 0x2a, 0x94, 0x78, 0x12, 0x18,
+0xd6, 0x40, 0x09, 0x12, 0x17, 0xe7, 0xe4, 0x75, 0xf0, 0x01, 0x80, 0x1a, 0xe5, 0x2a, 0x24, 0x78,
+0xe4, 0x35, 0x29, 0xc3, 0x64, 0x80, 0x94, 0x80, 0xe5, 0x27, 0x75, 0xf0, 0x0a, 0x50, 0x11, 0x12,
+0x17, 0xec, 0x74, 0xff, 0xf5, 0xf0, 0x12, 0x0d, 0xa5, 0x12, 0x18, 0xc1, 0xe4, 0xf0, 0x80, 0x06,
+0x12, 0x18, 0xc6, 0xe5, 0x2a, 0xf0, 0xe4, 0xf5, 0x2b, 0x12, 0x17, 0x94, 0x74, 0x01, 0x93, 0xff,
+0xd3, 0x64, 0x80, 0xf8, 0xe5, 0x2b, 0x64, 0x80, 0x98, 0x50, 0x17, 0xef, 0x33, 0x95, 0xe0, 0xfe,
+0xad, 0x2b, 0xed, 0x33, 0x95, 0xe0, 0xfc, 0xed, 0x2f, 0xec, 0x3e, 0xc3, 0x64, 0x80, 0x94, 0x80,
+0x50, 0x15, 0xe4, 0xf5, 0x2b, 0xe5, 0x27, 0x12, 0x17, 0xb0, 0xe0, 0xfe, 0xa3, 0xe0, 0xff, 0x12,
+0x17, 0xe7, 0xee, 0xf0, 0xa3, 0xef, 0xf0, 0x12, 0x19, 0x30, 0xe5, 0x2b, 0xf0, 0x78, 0x69, 0xe6,
+0x70, 0x3a, 0x12, 0x17, 0xe7, 0xe0, 0xfe, 0xa3, 0xe0, 0xff, 0xe5, 0x27, 0x12, 0x19, 0x4a, 0x12,
+0x19, 0x84, 0xff, 0xec, 0x9e, 0xfe, 0x12, 0x3b, 0x31, 0xaa, 0x06, 0xab, 0x07, 0x12, 0x17, 0x94,
+0x74, 0x04, 0x93, 0xfe, 0x74, 0x05, 0x93, 0xff, 0x7c, 0x00, 0x7d, 0x03, 0x12, 0x0d, 0x08, 0xd3,
+0xeb, 0x9f, 0xea, 0x9e, 0x40, 0x06, 0x78, 0x67, 0xe6, 0x44, 0x10, 0xf6, 0x05, 0x27, 0x15, 0x28,
+0xe5, 0x28, 0x60, 0x03, 0x02, 0x22, 0x2b, 0x22, 0x8e, 0x1c, 0x8f, 0x1d, 0xe4, 0x78, 0x66, 0xf6,
+0x85, 0x1c, 0x41, 0x85, 0x1d, 0x42, 0xe5, 0x1d, 0x24, 0x2c, 0xff, 0xe4, 0x35, 0x1c, 0xfa, 0xa9,
+0x07, 0x7b, 0xff, 0x78, 0x62, 0x7c, 0x00, 0x7d, 0x00, 0x7e, 0x00, 0x7f, 0x04, 0x12, 0x0c, 0x68,
+0x78, 0x84, 0x74, 0x01, 0xf2, 0x08, 0x74, 0xcc, 0xf2, 0x85, 0x1d, 0x82, 0x85, 0x1c, 0x83, 0xe4,
+0x93, 0xff, 0x7e, 0x00, 0xe5, 0x1d, 0x24, 0x06, 0xfd, 0xe4, 0x35, 0x1c, 0xfa, 0xa9, 0x05, 0x7b,
+0xff, 0x18, 0xe2, 0xfc, 0x08, 0xe2, 0xf8, 0x7d, 0x01, 0x12, 0x0c, 0x68, 0x90, 0x01, 0xa7, 0xe0,
+0xff, 0x12, 0x35, 0x7a, 0x90, 0x00, 0xc1, 0xe0, 0x64, 0x80, 0x70, 0x04, 0xa3, 0xe0, 0x64, 0x75,
+0x70, 0x44, 0xff, 0x85, 0x1d, 0x82, 0x85, 0x1c, 0x83, 0xe4, 0x93, 0xfe, 0xef, 0xc3, 0x9e, 0x50,
+0x35, 0xe4, 0xf5, 0x1f, 0x12, 0x19, 0x19, 0xfd, 0x12, 0x17, 0xa5, 0xfe, 0xe5, 0x1f, 0x90, 0x3b,
+0x5b, 0x93, 0xfb, 0xee, 0x6b, 0x60, 0x0b, 0xe5, 0x1f, 0xc3, 0x94, 0x0f, 0x50, 0x04, 0x05, 0x1f,
+0x80, 0xe2, 0xe5, 0x1f, 0x90, 0x3b, 0x6a, 0x93, 0xfe, 0xed, 0x2f, 0xf5, 0x82, 0xe4, 0x3c, 0xf5,
+0x83, 0xee, 0xf0, 0x0f, 0x80, 0xbd, 0x7e, 0x00, 0x7d, 0x00, 0x12, 0x18, 0xf7, 0x12, 0x17, 0x94,
+0x74, 0x02, 0x93, 0xff, 0x7e, 0x00, 0x7c, 0x10, 0x7d, 0x00, 0x12, 0x10, 0x6b, 0xe4, 0x7b, 0xc8,
+0xfa, 0xf9, 0xf8, 0x12, 0x0f, 0x42, 0x90, 0x02, 0x00, 0xee, 0xf0, 0xa3, 0xef, 0xf0, 0x78, 0x83,
+0x74, 0x09, 0xf2, 0x78, 0x64, 0xe6, 0xff, 0x20, 0xe3, 0x06, 0x78, 0x83, 0xe2, 0x44, 0x04, 0xf2,
+0xef, 0x20, 0xe2, 0x06, 0x78, 0x83, 0xe2, 0x44, 0x20, 0xf2, 0xe4, 0x78, 0x68, 0xf6, 0x43, 0x95,
+0x80, 0x78, 0x64, 0xe6, 0x7f, 0x00, 0x30, 0xe1, 0x02, 0x7f, 0x40, 0xef, 0x44, 0x37, 0x90, 0xff,
+0x41, 0xf0, 0x90, 0xff, 0x49, 0x74, 0x0d, 0xf0, 0x75, 0x1e, 0x11, 0xe5, 0x1e, 0xf4, 0x60, 0x0c,
+0xe4, 0xfd, 0xaf, 0x1e, 0x12, 0x34, 0x39, 0xe4, 0xfd, 0x12, 0x24, 0xcf, 0x75, 0x1e, 0x16, 0xe5,
+0x1e, 0xf4, 0x60, 0x0c, 0xe4, 0xfd, 0xaf, 0x1e, 0x12, 0x34, 0x39, 0x7d, 0x01, 0x12, 0x24, 0xcf,
+0x78, 0x65, 0xe6, 0x7f, 0x08, 0x30, 0xe0, 0x02, 0x7f, 0x05, 0x78, 0x87, 0xef, 0xf2, 0x22, 0xaf,
+0x1e, 0x12, 0x39, 0x6b, 0x7d, 0x08, 0xaf, 0x1e, 0x12, 0x32, 0x1e, 0x7d, 0x07, 0xaf, 0x1e, 0x12,
+0x32, 0x1e, 0x22, 0x8f, 0x23, 0x12, 0x05, 0x40, 0xe2, 0xff, 0x70, 0x04, 0xf5, 0x24, 0x80, 0x18,
+0x78, 0x6c, 0xe6, 0xfe, 0x14, 0xb5, 0x07, 0x09, 0xee, 0x25, 0xe0, 0x24, 0xfa, 0xf5, 0x24, 0x80,
+0x07, 0xef, 0x25, 0xe0, 0x24, 0xfe, 0xf5, 0x24, 0xe5, 0x24, 0x25, 0xe0, 0x24, 0x63, 0x12, 0x00,
+0xf3, 0xe5, 0x24, 0x12, 0x02, 0xd8, 0xe5, 0x24, 0x25, 0xe0, 0x24, 0x68, 0x12, 0x02, 0xdc, 0xe4,
+0xfc, 0xfd, 0x78, 0x54, 0x12, 0x10, 0x34, 0xe5, 0x24, 0x25, 0xe0, 0x24, 0x65, 0x12, 0x00, 0xf3,
+0xe5, 0x24, 0x25, 0xe0, 0x24, 0x62, 0x12, 0x02, 0xdc, 0xe5, 0x24, 0x25, 0xe0, 0x24, 0x6a, 0x12,
+0x02, 0xdc, 0xe4, 0xfc, 0xfd, 0x78, 0x58, 0x12, 0x10, 0x34, 0x12, 0x00, 0x60, 0x74, 0x07, 0x93,
+0xfe, 0x74, 0x08, 0x78, 0x58, 0x12, 0x04, 0x63, 0x12, 0x0e, 0xb7, 0xc0, 0x04, 0xc0, 0x05, 0xc0,
+0x06, 0xc0, 0x07, 0x12, 0x00, 0x60, 0x78, 0x58, 0x12, 0x03, 0x05, 0x12, 0x0e, 0xb7, 0xd0, 0x03,
+0xd0, 0x02, 0xd0, 0x01, 0xd0, 0x00, 0x12, 0x01, 0xc3, 0xc0, 0x04, 0xc0, 0x05, 0xc0, 0x06, 0xc0,
+0x07, 0x12, 0x00, 0x60, 0x74, 0x05, 0x93, 0xfe, 0x74, 0x06, 0x78, 0x54, 0x12, 0x04, 0x63, 0x12,
+0x01, 0x2b, 0xd0, 0x07, 0xd0, 0x06, 0xd0, 0x05, 0xd0, 0x04, 0xc3, 0xef, 0x9b, 0xff, 0xee, 0x9a,
+0xfe, 0xed, 0x99, 0xfd, 0xec, 0x98, 0xfc, 0x78, 0x5c, 0x12, 0x10, 0x34, 0x78, 0x5c, 0x12, 0x10,
+0x0b, 0xec, 0x33, 0x50, 0x0b, 0x78, 0x54, 0x12, 0x10, 0x40, 0x00, 0x00, 0x00, 0x01, 0x80, 0x5b,
+0x12, 0x05, 0x63, 0x7b, 0x02, 0x12, 0x02, 0x36, 0x12, 0x0f, 0x42, 0x78, 0x5c, 0x12, 0x10, 0x17,
+0x12, 0x01, 0xc3, 0xc0, 0x04, 0xc0, 0x05, 0xc0, 0x06, 0xc0, 0x07, 0x12, 0x05, 0x63, 0x2f, 0xfb,
+0xea, 0x3e, 0xfa, 0xe9, 0x3d, 0xf9, 0xe8, 0x3c, 0xf8, 0xd0, 0x07, 0xd0, 0x06, 0xd0, 0x05, 0xd0,
+0x04, 0x12, 0x0f, 0x42, 0x78, 0x54, 0x12, 0x10, 0x34, 0x12, 0x00, 0x60, 0x78, 0x54, 0x12, 0x03,
+0x05, 0xd3, 0x12, 0x0f, 0xd4, 0x40, 0x14, 0x12, 0x00, 0x60, 0x74, 0x02, 0x93, 0x24, 0xff, 0xff,
+0x74, 0x01, 0x93, 0x12, 0x02, 0x2c, 0x78, 0x54, 0x12, 0x10, 0x34, 0x78, 0x54, 0x12, 0x10, 0x0b,
+0xe5, 0x23, 0x12, 0x02, 0xac, 0x22, 0x8b, 0x1f, 0x8a, 0x20, 0x89, 0x21, 0x43, 0xad, 0x04, 0x43,
+0x95, 0x80, 0x90, 0xff, 0x41, 0x74, 0x80, 0xf0, 0x90, 0xff, 0x49, 0x74, 0x0d, 0xf0, 0xa3, 0xe4,
+0xf0, 0x90, 0xff, 0x42, 0x04, 0xf0, 0x90, 0xff, 0x55, 0x74, 0x7d, 0xf0, 0x90, 0xff, 0x54, 0xe4,
+0xf0, 0x90, 0xff, 0x5c, 0xf0, 0x90, 0xff, 0x48, 0x74, 0x10, 0xf0, 0xe4, 0xf5, 0x26, 0xf5, 0x27,
+0xf5, 0x28, 0xf5, 0x29, 0xf5, 0x25, 0xe4, 0x12, 0x3a, 0x6b, 0xf4, 0x60, 0x0d, 0xe4, 0xfd, 0x12,
+0x34, 0x39, 0x12, 0x3a, 0x73, 0x7d, 0x08, 0x12, 0x32, 0x1e, 0x12, 0x3a, 0x5d, 0xf4, 0x60, 0x0d,
+0xe4, 0xfd, 0x12, 0x34, 0x39, 0x12, 0x3a, 0x5d, 0x7d, 0x08, 0x12, 0x32, 0x1e, 0xe4, 0xff, 0x00,
+0x0f, 0xbf, 0xc8, 0xfb, 0x74, 0x03, 0x12, 0x3a, 0x6b, 0xf4, 0x60, 0x0d, 0xe4, 0xfd, 0x12, 0x39,
+0x6b, 0x12, 0x3a, 0x73, 0x7d, 0x07, 0x12, 0x32, 0x1e, 0x12, 0x3a, 0x5d, 0xf4, 0x60, 0x0d, 0x7d,
+0x01, 0x12, 0x39, 0x6b, 0x12, 0x3a, 0x5d, 0x7d, 0x07, 0x12, 0x32, 0x1e, 0x90, 0xff, 0x43, 0x74,
+0x9f, 0xf0, 0x90, 0xff, 0x50, 0x74, 0x07, 0xf0, 0x90, 0xff, 0x58, 0xf0, 0x90, 0xff, 0x40, 0x74,
+0x09, 0xf0, 0x75, 0x8a, 0xa0, 0xe4, 0x90, 0x00, 0xc0, 0xf0, 0x90, 0xff, 0x43, 0xe0, 0x30, 0xe4,
+0xf9, 0x90, 0xff, 0x43, 0x74, 0x9f, 0xf0, 0x90, 0xff, 0x52, 0xe0, 0xfe, 0xa3, 0xe0, 0x25, 0x27,
+0xf5, 0x27, 0xee, 0x35, 0x26, 0xf5, 0x26, 0x90, 0xff, 0x5a, 0xe0, 0xfe, 0xa3, 0xe0, 0x25, 0x29,
+0xf5, 0x29, 0xee, 0x35, 0x28, 0xf5, 0x28, 0x05, 0x25, 0xe5, 0x25, 0xc3, 0x94, 0x04, 0x50, 0x03,
+0x02, 0x26, 0x66, 0xe5, 0x27, 0xae, 0x26, 0x78, 0x02, 0xce, 0xc3, 0x13, 0xce, 0x13, 0xd8, 0xf9,
+0xff, 0xab, 0x22, 0xaa, 0x23, 0xa9, 0x24, 0xee, 0x8f, 0xf0, 0x12, 0x0e, 0x6b, 0xe5, 0x29, 0xae,
+0x28, 0x78, 0x02, 0xce, 0xc3, 0x13, 0xce, 0x13, 0xd8, 0xf9, 0xff, 0xab, 0x22, 0xaa, 0x23, 0xa9,
+0x24, 0x90, 0x00, 0x02, 0xee, 0x8f, 0xf0, 0x12, 0x0e, 0x8a, 0x12, 0x3a, 0x73, 0xf4, 0x60, 0x05,
+0xe4, 0xfd, 0x12, 0x32, 0x1e, 0x12, 0x3a, 0x5d, 0xf4, 0x60, 0x05, 0xe4, 0xfd, 0x12, 0x32, 0x1e,
+0x22, 0xe4, 0xf5, 0x27, 0xe5, 0x27, 0xc3, 0x78, 0x6a, 0x96, 0x50, 0x2b, 0x12, 0x19, 0x19, 0x25,
+0x27, 0x12, 0x17, 0xa6, 0xf5, 0x28, 0x78, 0x65, 0xe6, 0x54, 0x01, 0xfd, 0xaf, 0x28, 0x12, 0x34,
+0x39, 0x78, 0x65, 0xe6, 0xb4, 0x03, 0x0c, 0xe5, 0x27, 0x30, 0xe0, 0x07, 0xe4, 0xfd, 0xaf, 0x28,
+0x12, 0x34, 0x39, 0x05, 0x27, 0x80, 0xcd, 0x90, 0xff, 0x4a, 0x74, 0x71, 0xf0, 0x90, 0xff, 0x50,
+0x74, 0x0f, 0xf0, 0x90, 0xff, 0x58, 0xf0, 0x90, 0xff, 0x40, 0xe4, 0xf0, 0x12, 0x19, 0x58, 0x90,
+0xff, 0x54, 0xe4, 0xf0, 0x90, 0xff, 0x5c, 0xf0, 0x78, 0x63, 0xe6, 0x90, 0xff, 0x42, 0xf0, 0x90,
+0xff, 0x55, 0x74, 0x28, 0xf0, 0x90, 0xff, 0x48, 0x74, 0x02, 0xf0, 0x43, 0xad, 0x04, 0x12, 0x19,
+0x5f, 0x90, 0xff, 0x43, 0xe0, 0x20, 0xe4, 0x1d, 0xe5, 0x89, 0x30, 0xe7, 0x08, 0x12, 0x17, 0x46,
+0x50, 0x03, 0xe0, 0x04, 0xf0, 0x12, 0x19, 0x10, 0x30, 0xe7, 0xe6, 0x12, 0x17, 0x46, 0x50, 0xe1,
+0xe0, 0x04, 0xf0, 0x80, 0xdc, 0x12, 0x19, 0x58, 0xe4, 0x78, 0x86, 0xf2, 0x78, 0x61, 0xf6, 0x18,
+0x76, 0x01, 0x78, 0x6a, 0xe6, 0xc3, 0x13, 0x78, 0x68, 0xf6, 0x78, 0x63, 0xe6, 0x90, 0xff, 0x42,
+0xf0, 0x18, 0xe6, 0x90, 0xff, 0x48, 0xf0, 0x78, 0x64, 0xe6, 0x7f, 0x00, 0x20, 0xe4, 0x02, 0x7f,
+0x01, 0x90, 0x02, 0x02, 0xef, 0xf0, 0x12, 0x17, 0xf7, 0x08, 0x12, 0x17, 0x9d, 0xff, 0x7d, 0x06,
+0x12, 0x32, 0x1e, 0x78, 0x60, 0x12, 0x17, 0x9d, 0xff, 0x7d, 0x06, 0x12, 0x32, 0x1e, 0x78, 0x83,
+0xe2, 0xff, 0x90, 0xff, 0x40, 0xf0, 0x78, 0x64, 0xe6, 0x30, 0xe7, 0x3e, 0x43, 0xad, 0x04, 0xef,
+0xf0, 0x90, 0xff, 0x43, 0xe0, 0x20, 0xe4, 0x1d, 0xe5, 0x89, 0x30, 0xe7, 0x08, 0x12, 0x17, 0x46,
+0x50, 0x03, 0xe0, 0x04, 0xf0, 0x12, 0x19, 0x10, 0x30, 0xe7, 0xe6, 0x12, 0x17, 0x46, 0x50, 0xe1,
+0xe0, 0x04, 0xf0, 0x80, 0xdc, 0x7b, 0xff, 0x7a, 0x32, 0x79, 0x1e, 0x12, 0x28, 0x91, 0x12, 0x18,
+0xa6, 0xf0, 0x78, 0x68, 0xe6, 0x70, 0xca, 0x02, 0x32, 0x78, 0x53, 0xad, 0xfb, 0x12, 0x19, 0x5f,
+0x22, 0x15, 0x0f, 0x15, 0x0f, 0x15, 0x0f, 0xa8, 0x0f, 0xa6, 0x03, 0x08, 0xa6, 0x02, 0x08, 0xa6,
+0x01, 0x15, 0x0f, 0x12, 0x19, 0x58, 0x78, 0x87, 0xe2, 0xa8, 0x0f, 0xf6, 0x12, 0x17, 0x9b, 0xff,
+0xa8, 0x0f, 0xe6, 0xfd, 0x12, 0x18, 0x50, 0x12, 0x10, 0x69, 0x78, 0x65, 0xe6, 0x64, 0x03, 0x78,
+0x60, 0x60, 0x0d, 0x12, 0x17, 0x9d, 0xff, 0xa8, 0x0f, 0xe6, 0xfd, 0x12, 0x18, 0x50, 0x80, 0x08,
+0x12, 0x17, 0x9d, 0x12, 0x18, 0x4d, 0x7d, 0x08, 0x12, 0x10, 0x69, 0x90, 0xff, 0x52, 0xe0, 0xfe,
+0xa3, 0xe0, 0xff, 0x78, 0x61, 0xe6, 0x12, 0x18, 0x3f, 0xee, 0xf0, 0xa3, 0xef, 0xf0, 0x12, 0x18,
+0xb9, 0xff, 0x18, 0xe6, 0x12, 0x18, 0x3f, 0xee, 0xf0, 0xa3, 0xef, 0xf0, 0x90, 0x02, 0x02, 0xe0,
+0x60, 0x2e, 0x08, 0xe6, 0xff, 0x12, 0x17, 0xb0, 0x12, 0x18, 0x39, 0x12, 0x29, 0xa1, 0x12, 0x17,
+0x94, 0x12, 0x19, 0x40, 0x40, 0x1a, 0x78, 0x60, 0xe6, 0xff, 0x12, 0x17, 0xb0, 0x12, 0x18, 0x39,
+0x12, 0x29, 0xa1, 0x12, 0x17, 0x94, 0x12, 0x19, 0x40, 0x40, 0x05, 0xe4, 0x90, 0x02, 0x02, 0xf0,
+0x90, 0x02, 0x02, 0xe0, 0x70, 0x1b, 0x78, 0x61, 0x06, 0x06, 0x18, 0x06, 0x06, 0x78, 0x68, 0x16,
+0x78, 0x64, 0xe6, 0x7f, 0x00, 0x20, 0xe4, 0x02, 0x7f, 0x01, 0x90, 0x02, 0x02, 0xef, 0xf0, 0x80,
+0x05, 0xe4, 0x90, 0x02, 0x02, 0xf0, 0x78, 0x68, 0xe6, 0x70, 0x0a, 0x90, 0xff, 0x50, 0xf0, 0x90,
+0xff, 0x58, 0xf0, 0x80, 0x35, 0x12, 0x17, 0xf7, 0xa8, 0x0f, 0x76, 0x64, 0x90, 0xff, 0x58, 0xe0,
+0xff, 0x90, 0xff, 0x50, 0xe0, 0x4f, 0x30, 0xe7, 0x06, 0xa8, 0x0f, 0x16, 0xe6, 0x70, 0xed, 0x12,
+0x17, 0x9b, 0x12, 0x18, 0x4d, 0x7d, 0x06, 0x12, 0x10, 0x69, 0x78, 0x60, 0x12, 0x17, 0x9d, 0x12,
+0x18, 0x4d, 0x7d, 0x06, 0x12, 0x10, 0x69, 0x12, 0x19, 0x5f, 0xe5, 0x0f, 0x24, 0x04, 0xf5, 0x0f,
+0x22, 0xe0, 0xfe, 0xa3, 0xe0, 0xc3, 0x9d, 0xff, 0xee, 0x9c, 0xfe, 0x12, 0x3b, 0x31, 0x22, 0x8b,
+0x22, 0x8a, 0x23, 0x89, 0x24, 0x12, 0x2e, 0xe6, 0x12, 0x2f, 0x69, 0x12, 0x33, 0x19, 0x74, 0x55,
+0x93, 0xf5, 0x2b, 0xe4, 0xf5, 0x2c, 0x12, 0x33, 0x5c, 0x12, 0x0c, 0x8e, 0x70, 0x21, 0x12, 0x33,
+0x19, 0x74, 0x74, 0x93, 0xf5, 0x2d, 0xc3, 0x64, 0x80, 0x94, 0x80, 0x7f, 0x00, 0x50, 0x02, 0x7f,
+0x01, 0x12, 0x2a, 0x75, 0xee, 0x8f, 0xf0, 0x12, 0x0e, 0x1e, 0x75, 0x2c, 0x03, 0x80, 0x3a, 0x12,
+0x33, 0x5c, 0x12, 0x0c, 0x8e, 0xff, 0xe5, 0x2b, 0x14, 0x6f, 0x70, 0x2d, 0x12, 0x33, 0x19, 0x74,
+0x75, 0x93, 0xf5, 0x2d, 0xc3, 0x64, 0x80, 0x94, 0x80, 0xe5, 0x2b, 0x50, 0x06, 0x25, 0xe0, 0x14,
+0xff, 0x80, 0x05, 0x25, 0xe0, 0x24, 0xfe, 0xff, 0x12, 0x2a, 0x75, 0xee, 0x8f, 0xf0, 0x12, 0x0e,
+0x1e, 0xe5, 0x2b, 0x25, 0xe0, 0x24, 0xfd, 0xf5, 0x2c, 0xe5, 0x2c, 0x60, 0x47, 0x24, 0xff, 0xff,
+0xe4, 0x34, 0xff, 0xfe, 0xef, 0x25, 0xe0, 0xff, 0xee, 0x33, 0xab, 0x22, 0xaa, 0x23, 0xa9, 0x24,
+0x8f, 0x82, 0xf5, 0x83, 0x12, 0x0d, 0xe6, 0xff, 0xae, 0xf0, 0x75, 0xf0, 0x02, 0xe5, 0x2c, 0xa4,
+0xf5, 0x82, 0x85, 0xf0, 0x83, 0x12, 0x0d, 0xe6, 0x2f, 0xff, 0xee, 0x35, 0xf0, 0xfe, 0x12, 0x33,
+0x19, 0xd3, 0x74, 0x77, 0x93, 0x9f, 0x74, 0x76, 0x93, 0x9e, 0x40, 0x08, 0x12, 0x33, 0x5c, 0x74,
+0xff, 0x12, 0x0c, 0xd4, 0x22, 0x8f, 0x2c, 0xaf, 0x2d, 0xef, 0x33, 0x95, 0xe0, 0xfe, 0x12, 0x3b,
+0x31, 0xab, 0x22, 0xaa, 0x23, 0xa9, 0x24, 0x75, 0xf0, 0x02, 0xe5, 0x2c, 0xa4, 0xf5, 0x82, 0x85,
+0xf0, 0x83, 0x12, 0x0d, 0xe6, 0xfd, 0xac, 0xf0, 0xcf, 0xcd, 0xcf, 0xce, 0xcc, 0xce, 0x12, 0x0d,
+0x1a, 0x75, 0xf0, 0x02, 0xe5, 0x2c, 0xa4, 0xf5, 0x82, 0x85, 0xf0, 0x83, 0x22, 0x8b, 0x22, 0x8a,
+0x23, 0x89, 0x24, 0xe4, 0xf5, 0x27, 0xf5, 0x25, 0xf5, 0x26, 0xf5, 0x27, 0x85, 0x09, 0x82, 0x85,
+0x08, 0x83, 0xe4, 0x93, 0xff, 0xe5, 0x25, 0xc3, 0x9f, 0x40, 0x03, 0x02, 0x2b, 0x72, 0x12, 0x00,
+0x18, 0x74, 0x01, 0x93, 0xf5, 0x28, 0x12, 0x00, 0x12, 0x74, 0x02, 0x93, 0xf5, 0x29, 0x12, 0x00,
+0x12, 0x74, 0x04, 0x93, 0xfc, 0x74, 0x05, 0x93, 0xfd, 0xe5, 0x28, 0x25, 0xe0, 0x24, 0x5f, 0xf8,
+0xe2, 0xfe, 0x08, 0xe2, 0xff, 0xd3, 0x9d, 0xee, 0x9c, 0x40, 0x72, 0x7c, 0x00, 0x7d, 0x05, 0x12,
+0x0d, 0x08, 0xe5, 0x29, 0x25, 0xe0, 0x24, 0x60, 0xf8, 0xe2, 0x24, 0x01, 0xfd, 0x18, 0xe2, 0x34,
+0x00, 0xfc, 0x12, 0x0d, 0x1a, 0x8e, 0x2a, 0x8f, 0x2b, 0x12, 0x00, 0x12, 0x74, 0x03, 0x93, 0x30,
+0xe7, 0x2b, 0x54, 0x7f, 0xc3, 0x95, 0x2b, 0xff, 0xe4, 0x95, 0x2a, 0xfe, 0x12, 0x3b, 0x31, 0xc3,
+0x74, 0x03, 0x9f, 0xee, 0x64, 0x80, 0xf8, 0x74, 0x80, 0x98, 0x40, 0x2e, 0xaf, 0x25, 0x74, 0x01,
+0xa8, 0x07, 0x08, 0x80, 0x02, 0xc3, 0x33, 0xd8, 0xfc, 0x42, 0x26, 0x80, 0x1d, 0x12, 0x00, 0x12,
+0x74, 0x03, 0x93, 0xc3, 0x95, 0x2b, 0xe4, 0x95, 0x2a, 0x50, 0x0f, 0xaf, 0x25, 0x74, 0x01, 0xa8,
+0x07, 0x08, 0x80, 0x02, 0xc3, 0x33, 0xd8, 0xfc, 0x42, 0x26, 0x75, 0x27, 0x01, 0x05, 0x25, 0x02,
+0x2a, 0xbc, 0xe5, 0x26, 0x65, 0x0c, 0x60, 0x08, 0x85, 0x26, 0x0c, 0xe4, 0xf5, 0x0b, 0x80, 0x0e,
+0x05, 0x0b, 0xe5, 0x0b, 0xc3, 0x94, 0x03, 0x40, 0x05, 0x15, 0x0b, 0x85, 0x26, 0x0a, 0xab, 0x22,
+0xaa, 0x23, 0xa9, 0x24, 0xe5, 0x0a, 0x12, 0x0c, 0xd4, 0xaf, 0x27, 0x22, 0xe4, 0xf5, 0x22, 0xf5,
+0x23, 0xff, 0xfe, 0x78, 0x35, 0xe2, 0x25, 0xe0, 0xfd, 0x78, 0x06, 0xe2, 0x2d, 0xfd, 0x78, 0x0c,
+0xe2, 0xc4, 0x54, 0xf0, 0x2d, 0xfd, 0x78, 0x3b, 0xe2, 0xfc, 0xc4, 0x33, 0x54, 0xe0, 0x2d, 0x24,
+0xfe, 0x60, 0x25, 0x24, 0xf0, 0x60, 0x21, 0x14, 0x60, 0x26, 0x24, 0xf2, 0x60, 0x1a, 0x24, 0xfe,
+0x60, 0x2e, 0x24, 0xf1, 0x60, 0x0c, 0x14, 0x60, 0x3b, 0x24, 0x02, 0x70, 0x6c, 0xe4, 0xfd, 0xff,
+0x80, 0x22, 0x7d, 0x01, 0x7f, 0x01, 0x80, 0x0b, 0x75, 0x22, 0x00, 0x75, 0x23, 0x01, 0x80, 0x59,
+0xe4, 0xfd, 0xff, 0x12, 0x33, 0xf3, 0x8e, 0x22, 0x8f, 0x23, 0xe4, 0xfd, 0x7f, 0x01, 0x80, 0x0f,
+0x7d, 0x01, 0x7f, 0x01, 0x12, 0x33, 0xf3, 0x8e, 0x22, 0x8f, 0x23, 0x7d, 0x01, 0xe4, 0xff, 0x12,
+0x33, 0xf3, 0x80, 0x35, 0x7d, 0x01, 0x7f, 0x01, 0x12, 0x33, 0xf3, 0xc0, 0x06, 0xc0, 0x07, 0xe4,
+0xfd, 0xff, 0x12, 0x33, 0xf3, 0xd0, 0xe0, 0x2f, 0xf5, 0x23, 0xd0, 0xe0, 0x3e, 0xf5, 0x22, 0xe4,
+0xfd, 0x7f, 0x01, 0x12, 0x33, 0xf3, 0xc0, 0x06, 0xc0, 0x07, 0x7d, 0x01, 0xe4, 0xff, 0x12, 0x33,
+0xf3, 0xd0, 0xe0, 0x2f, 0xff, 0xd0, 0xe0, 0x3e, 0xfe, 0xd3, 0xe5, 0x23, 0x9f, 0xe5, 0x22, 0x9e,
+0x40, 0x27, 0x78, 0x24, 0x7c, 0x00, 0x7d, 0x00, 0x12, 0x02, 0x9f, 0x78, 0x02, 0x7c, 0x00, 0x7d,
+0xfe, 0x7b, 0xfe, 0x7a, 0x00, 0x79, 0x31, 0x12, 0x02, 0xa5, 0x78, 0x31, 0x7c, 0x00, 0x7d, 0xfe,
+0x7b, 0x00, 0x7a, 0x00, 0x79, 0x24, 0x12, 0x02, 0xa5, 0x22, 0xab, 0x25, 0xe5, 0x27, 0xf9, 0x24,
+0x02, 0xf5, 0x27, 0xe5, 0x26, 0xfa, 0x34, 0x00, 0xf5, 0x26, 0xee, 0x8f, 0xf0, 0x12, 0x0e, 0x6b,
+0x90, 0x00, 0x02, 0xab, 0x1c, 0xaa, 0x1d, 0xa9, 0x1e, 0x12, 0x0d, 0xe6, 0xff, 0xae, 0xf0, 0xab,
+0x25, 0xe5, 0x27, 0xf9, 0x24, 0x02, 0xf5, 0x27, 0xe5, 0x26, 0xfa, 0x34, 0x00, 0xf5, 0x26, 0xee,
+0x8f, 0xf0, 0x02, 0x0e, 0x6b, 0x90, 0x00, 0x05, 0xab, 0x1c, 0xaa, 0x1d, 0xa9, 0x1e, 0x02, 0x0c,
+0xa7, 0xab, 0x1c, 0xaa, 0x1d, 0xa9, 0x1e, 0x90, 0x00, 0x0b, 0x02, 0x0c, 0xa7, 0xe5, 0x1f, 0xfe,
+0x7c, 0x00, 0xe4, 0x25, 0x22, 0xff, 0xec, 0x3e, 0xfe, 0x22, 0xab, 0x25, 0xe5, 0x27, 0xf9, 0x24,
+0x02, 0xf5, 0x27, 0xe5, 0x26, 0xfa, 0x34, 0x00, 0xf5, 0x26, 0xe4, 0xf5, 0xf0, 0x22, 0xab, 0x1c,
+0xaa, 0x1d, 0xa9, 0x1e, 0x22, 0x75, 0x89, 0x80, 0x90, 0x00, 0xc3, 0xe0, 0xc3, 0x94, 0xff, 0x22,
+0x75, 0x25, 0x01, 0x85, 0x23, 0x26, 0x85, 0x24, 0x27, 0x22, 0xab, 0x25, 0xaa, 0x26, 0xa9, 0x27,
+0x22, 0x8d, 0x82, 0x8c, 0x83, 0xee, 0xf0, 0xa3, 0xef, 0xf0, 0x22, 0x78, 0xff, 0xe4, 0xf6, 0xd8,
+0xfd, 0x90, 0x00, 0x00, 0x7f, 0x00, 0x7e, 0x03, 0xe4, 0xf0, 0xa3, 0xdf, 0xfc, 0xde, 0xfa, 0x75,
+0x81, 0x79, 0x75, 0xa0, 0x00, 0x02, 0x2d, 0x73, 0x02, 0x35, 0x40, 0xe4, 0x93, 0xa3, 0xf8, 0xe4,
+0x93, 0xa3, 0x40, 0x03, 0xf6, 0x80, 0x01, 0xf2, 0x08, 0xdf, 0xf4, 0x80, 0x29, 0xe4, 0x93, 0xa3,
+0xf8, 0x54, 0x07, 0x24, 0x0c, 0xc8, 0xc3, 0x33, 0xc4, 0x54, 0x0f, 0x44, 0x20, 0xc8, 0x83, 0x40,
+0x04, 0xf4, 0x56, 0x80, 0x01, 0x46, 0xf6, 0xdf, 0xe4, 0x80, 0x0b, 0x01, 0x02, 0x04, 0x08, 0x10,
+0x20, 0x40, 0x80, 0x90, 0x3b, 0x4d, 0xe4, 0x7e, 0x01, 0x93, 0x60, 0xbc, 0xa3, 0xff, 0x54, 0x3f,
+0x30, 0xe5, 0x09, 0x54, 0x1f, 0xfe, 0xe4, 0x93, 0xa3, 0x60, 0x01, 0x0e, 0xcf, 0x54, 0xc0, 0x25,
+0xe0, 0x60, 0xa8, 0x40, 0xb8, 0xe4, 0x93, 0xa3, 0xfa, 0xe4, 0x93, 0xa3, 0xf8, 0xe4, 0x93, 0xa3,
+0xc8, 0xc5, 0x82, 0xc8, 0xca, 0xc5, 0x83, 0xca, 0xf0, 0xa3, 0xc8, 0xc5, 0x82, 0xc8, 0xca, 0xc5,
+0x83, 0xca, 0xdf, 0xe9, 0xde, 0xe7, 0x80, 0xbe, 0x90, 0x36, 0x0a, 0xe4, 0x93, 0x70, 0x05, 0x43,
+0x90, 0x10, 0x80, 0x03, 0x53, 0x90, 0xef, 0x90, 0x36, 0x0c, 0xe4, 0x93, 0xff, 0x7c, 0x01, 0x7d,
+0x00, 0x12, 0x35, 0x01, 0x90, 0x36, 0x0d, 0xe4, 0x93, 0xb4, 0x01, 0x07, 0x90, 0xff, 0x10, 0xe0,
+0x44, 0x18, 0xf0, 0x7e, 0x01, 0x7f, 0x00, 0x7d, 0x00, 0x7b, 0x01, 0x7a, 0x01, 0x79, 0x00, 0x12,
+0x10, 0x98, 0x7d, 0x01, 0x7f, 0x12, 0x12, 0x34, 0x39, 0x7d, 0x03, 0x7f, 0x12, 0x12, 0x32, 0x1e,
+0x90, 0xff, 0x1b, 0xe0, 0x54, 0xfb, 0xf0, 0x90, 0xff, 0x14, 0xe0, 0x44, 0x04, 0xf0, 0x90, 0x36,
+0x09, 0xe4, 0x93, 0x90, 0x01, 0xfa, 0xf0, 0x90, 0x36, 0x07, 0xe4, 0x93, 0x90, 0x01, 0xea, 0xf0,
+0x90, 0x36, 0x11, 0xe4, 0x93, 0x90, 0x01, 0xed, 0xf0, 0x78, 0xa7, 0x7c, 0x01, 0x7d, 0x01, 0x7b,
+0xff, 0x7a, 0x36, 0x79, 0x00, 0x7e, 0x00, 0x7f, 0x03, 0x12, 0x0c, 0x68, 0xe4, 0x90, 0x01, 0xec,
+0xf0, 0x90, 0x01, 0xfe, 0x04, 0xf0, 0xe4, 0x78, 0x78, 0xf6, 0x90, 0x00, 0xca, 0xf0, 0xa3, 0xf0,
+0x22, 0x8f, 0x1c, 0x8c, 0x1d, 0x8d, 0x1e, 0xe4, 0xff, 0x79, 0x01, 0xe4, 0xf5, 0x1f, 0xfe, 0x12,
+0x3b, 0x0c, 0xe5, 0x82, 0x2e, 0xf5, 0x82, 0xe4, 0x35, 0x83, 0xf5, 0x83, 0xe4, 0x93, 0x25, 0xe0,
+0x25, 0x1c, 0xf8, 0xe2, 0xfc, 0x08, 0xe2, 0xfd, 0x12, 0x3b, 0x0c, 0x74, 0x04, 0x93, 0xfa, 0x74,
+0x05, 0x93, 0xfb, 0xc3, 0xed, 0x9b, 0xec, 0x9a, 0x40, 0x02, 0x05, 0x1f, 0x0e, 0xbe, 0x04, 0xcf,
+0x12, 0x3b, 0x0c, 0x74, 0x06, 0x93, 0xfd, 0xe5, 0x1f, 0xc3, 0x9d, 0x50, 0x04, 0xe4, 0xf9, 0x80,
+0x04, 0x0f, 0xbf, 0x05, 0xb6, 0x90, 0x00, 0xcd, 0xe0, 0xb5, 0x01, 0x07, 0xe4, 0x90, 0x00, 0xcc,
+0xf0, 0x80, 0x28, 0x90, 0x00, 0xcc, 0xe0, 0x04, 0xf0, 0x85, 0x1e, 0x82, 0x85, 0x1d, 0x83, 0x74,
+0x23, 0x93, 0xff, 0x90, 0x00, 0xcc, 0xe0, 0xfd, 0x33, 0x95, 0xe0, 0xfc, 0xd3, 0xed, 0x9f, 0x74,
+0x80, 0xf8, 0x6c, 0x98, 0x40, 0x05, 0xe4, 0xf0, 0xa3, 0xe9, 0xf0, 0x90, 0x00, 0xcd, 0xe0, 0x7f,
+0x00, 0x60, 0x02, 0x7f, 0xaa, 0x22, 0xe4, 0x78, 0x54, 0xf6, 0x08, 0xf6, 0xfe, 0xfd, 0x12, 0x01,
+0xb8, 0x12, 0x02, 0xe5, 0xe4, 0xf9, 0xf5, 0x30, 0xf5, 0x2e, 0x75, 0x2f, 0xff, 0x78, 0x6c, 0xe6,
+0xff, 0xe9, 0xc3, 0x9f, 0x50, 0x5b, 0xe9, 0x12, 0x00, 0xed, 0xe9, 0x25, 0xe0, 0x25, 0xe0, 0x24,
+0x60, 0xf8, 0xe2, 0x2f, 0xf5, 0x32, 0x18, 0xe2, 0x3e, 0xf5, 0x31, 0x12, 0x03, 0x55, 0x78, 0x54,
+0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0xef, 0x2d, 0xfb, 0xee, 0x3c, 0xfa, 0xd3, 0xe5, 0x32, 0x9b, 0xe5,
+0x31, 0x9a, 0x40, 0x06, 0x75, 0x30, 0x01, 0x18, 0x80, 0x1d, 0xe5, 0x32, 0x2f, 0xff, 0xe5, 0x31,
+0x3e, 0xfe, 0xd3, 0xed, 0x9f, 0xec, 0x9e, 0x40, 0x15, 0xe5, 0x30, 0x60, 0x08, 0xe4, 0xf5, 0x30,
+0x12, 0x33, 0x63, 0x05, 0x2e, 0x78, 0x54, 0xa6, 0x31, 0x08, 0xa6, 0x32, 0x89, 0x2f, 0x09, 0x80,
+0x9c, 0xe5, 0x30, 0x60, 0x03, 0x12, 0x33, 0x63, 0x22, 0xe4, 0xfb, 0x12, 0x03, 0x71, 0xfa, 0xf4,
+0x60, 0x62, 0xea, 0x70, 0x0c, 0x12, 0x00, 0x60, 0x74, 0x11, 0x93, 0xf5, 0x2e, 0x74, 0x12, 0x80,
+0x1d, 0x78, 0x6c, 0xe6, 0x14, 0xb5, 0x02, 0x0c, 0x12, 0x00, 0x60, 0x74, 0x13, 0x93, 0xf5, 0x2e,
+0x74, 0x14, 0x80, 0x0a, 0x12, 0x00, 0x60, 0x74, 0x0f, 0x93, 0xf5, 0x2e, 0x74, 0x10, 0x93, 0xf5,
+0x2f, 0x78, 0x0d, 0xe2, 0x70, 0x05, 0x78, 0x3c, 0xe2, 0x60, 0x0e, 0xe5, 0x2f, 0x25, 0xe0, 0xff,
+0xe5, 0x2e, 0x12, 0x05, 0xde, 0x8e, 0x2e, 0x8f, 0x2f, 0xea, 0x12, 0x00, 0xed, 0xea, 0x25, 0xe0,
+0x12, 0x02, 0xd8, 0xc3, 0xef, 0x95, 0x2f, 0xee, 0x95, 0x2e, 0x50, 0x08, 0xeb, 0x25, 0xe0, 0x24,
+0x6d, 0xf8, 0x76, 0xff, 0x0b, 0xeb, 0x64, 0x02, 0x70, 0x91, 0x78, 0x6d, 0xe6, 0xb4, 0xff, 0x0a,
+0x78, 0x6f, 0xe6, 0xff, 0xf4, 0x60, 0x03, 0x12, 0x01, 0x97, 0x22, 0xef, 0x54, 0x07, 0xfe, 0x74,
+0x01, 0xa8, 0x06, 0x08, 0x80, 0x02, 0xc3, 0x33, 0xd8, 0xfc, 0xf9, 0xf4, 0xfe, 0xef, 0x54, 0xf0,
+0xf5, 0x3e, 0x64, 0x10, 0x70, 0x1e, 0xbd, 0x08, 0x02, 0x7d, 0x02, 0x90, 0xff, 0x12, 0xed, 0x30,
+0xe2, 0x05, 0xe0, 0x49, 0xf0, 0x80, 0x03, 0xe0, 0x5e, 0xf0, 0xe5, 0x82, 0x15, 0x82, 0x70, 0x14,
+0x15, 0x83, 0x80, 0x10, 0xe5, 0x3e, 0x13, 0x13, 0x54, 0x3f, 0x24, 0x11, 0xfb, 0xe4, 0x34, 0xff,
+0xf5, 0x83, 0x8b, 0x82, 0xed, 0x24, 0xfb, 0x60, 0x14, 0x14, 0x60, 0x20, 0x24, 0xfe, 0x70, 0x2a,
+0xe0, 0x5e, 0xf0, 0xe5, 0x82, 0x15, 0x82, 0x70, 0x1e, 0x15, 0x83, 0x80, 0x1a, 0xe0, 0x5e, 0xf0,
+0xe5, 0x82, 0x15, 0x82, 0x70, 0x02, 0x15, 0x83, 0xe0, 0x49, 0xf0, 0x22, 0xe0, 0x49, 0xf0, 0xe5,
+0x82, 0x15, 0x82, 0x70, 0x02, 0x15, 0x83, 0xe0, 0x5e, 0xf0, 0x22, 0xc0, 0xe0, 0xc0, 0x83, 0xc0,
+0x82, 0xc0, 0xd0, 0x75, 0xd0, 0x10, 0x78, 0x45, 0xa6, 0xa3, 0x08, 0xa6, 0xa6, 0x75, 0xa3, 0x08,
+0xe6, 0xff, 0x30, 0xe4, 0x07, 0x75, 0xd1, 0xdf, 0x78, 0x77, 0x76, 0x00, 0x78, 0x45, 0xe6, 0x30,
+0xe0, 0x40, 0xef, 0x20, 0xe0, 0x39, 0x78, 0x77, 0xe6, 0xff, 0x70, 0x18, 0x90, 0x02, 0xf8, 0xe0,
+0xfe, 0xf5, 0xd6, 0x18, 0xee, 0xf6, 0xc3, 0x94, 0x10, 0x50, 0x24, 0x78, 0x78, 0xe6, 0x25, 0xd6,
+0xf5, 0xd6, 0x80, 0x1b, 0x74, 0xf8, 0x2f, 0xf5, 0x82, 0xe4, 0x34, 0x02, 0xf5, 0x83, 0xe0, 0xff,
+0x78, 0x76, 0xe6, 0x06, 0x25, 0x0e, 0xf5, 0x82, 0xe4, 0x35, 0x0d, 0xf5, 0x83, 0xef, 0xf0, 0x78,
+0x77, 0x06, 0xd0, 0xd0, 0xd0, 0x82, 0xd0, 0x83, 0xd0, 0xe0, 0x32, 0xab, 0x07, 0xaa, 0x05, 0xe4,
+0x78, 0x67, 0xf6, 0xeb, 0x12, 0x17, 0xb0, 0xe0, 0xf5, 0x29, 0xa3, 0xe0, 0xf5, 0x2a, 0x78, 0x62,
+0xe6, 0x75, 0x27, 0x00, 0xf5, 0x28, 0xae, 0x27, 0xff, 0x7c, 0x00, 0x7d, 0xfc, 0x12, 0x0d, 0x08,
+0xd3, 0xe5, 0x2a, 0x9f, 0xe5, 0x29, 0x9e, 0x40, 0x06, 0x78, 0x67, 0xe6, 0x44, 0x20, 0xf6, 0x12,
+0x17, 0x94, 0x74, 0x05, 0x93, 0x25, 0xe0, 0xf5, 0x2a, 0x74, 0x04, 0x93, 0x33, 0xf5, 0x29, 0xeb,
+0x12, 0x17, 0xe9, 0xe0, 0xfe, 0xa3, 0xe0, 0x25, 0x2a, 0xff, 0xe5, 0x29, 0x3e, 0xfe, 0xeb, 0x12,
+0x17, 0xb0, 0xe0, 0xfc, 0xa3, 0xe0, 0xd3, 0x9f, 0xec, 0x9e, 0x40, 0x09, 0x78, 0x67, 0xe6, 0x44,
+0x02, 0xf6, 0x44, 0x08, 0xf6, 0x0b, 0x1a, 0xea, 0x70, 0x99, 0x22, 0xe4, 0xf5, 0x1c, 0x78, 0x1d,
+0x7c, 0x00, 0xfd, 0x7b, 0xff, 0x7a, 0x35, 0x79, 0xfd, 0xfe, 0x7f, 0x02, 0x12, 0x0c, 0x68, 0x75,
+0x22, 0x01, 0x75, 0x23, 0x00, 0x75, 0x24, 0xc4, 0x7b, 0x00, 0x7a, 0x00, 0x79, 0x1d, 0x12, 0x26,
+0x26, 0xe5, 0x1d, 0xf4, 0x60, 0x14, 0x90, 0x00, 0xc4, 0x12, 0x33, 0x3b, 0x40, 0x09, 0xd3, 0xef,
+0x94, 0xb8, 0xee, 0x94, 0x0b, 0x40, 0x03, 0x75, 0x1c, 0x01, 0xe5, 0x1e, 0xf4, 0x60, 0x14, 0x90,
+0x00, 0xc6, 0x12, 0x33, 0x3b, 0x40, 0x09, 0xd3, 0xef, 0x94, 0xb8, 0xee, 0x94, 0x0b, 0x40, 0x03,
+0x75, 0x1c, 0x01, 0x78, 0xb0, 0x7c, 0x01, 0x7d, 0x01, 0x7b, 0x01, 0x7a, 0x00, 0x79, 0xc4, 0x7e,
+0x00, 0x7f, 0x04, 0x12, 0x0c, 0x68, 0xaf, 0x1c, 0x22, 0x12, 0x04, 0xd6, 0x60, 0x11, 0xa8, 0x07,
+0xe8, 0x24, 0x0b, 0xf8, 0xe2, 0x7f, 0x80, 0x60, 0x02, 0x7f, 0x08, 0x8f, 0x22, 0x80, 0x1e, 0x78,
+0x6b, 0xe6, 0xff, 0x24, 0x0b, 0xf8, 0xe2, 0x60, 0x11, 0xa8, 0x07, 0xe8, 0x24, 0x0f, 0xf8, 0xe2,
+0x7f, 0x04, 0x60, 0x02, 0x7f, 0x08, 0x8f, 0x22, 0x80, 0x03, 0xe4, 0xf5, 0x22, 0xe5, 0x22, 0xb4,
+0x04, 0x0f, 0x12, 0x03, 0x64, 0x04, 0x12, 0x00, 0xe0, 0x78, 0x6b, 0xe6, 0x24, 0x05, 0xf8, 0xe4,
+0xf2, 0x78, 0x6b, 0xe6, 0xff, 0x24, 0x06, 0xf8, 0xe5, 0x22, 0xf2, 0xef, 0x04, 0x12, 0x03, 0x6a,
+0x24, 0x07, 0xf8, 0x7c, 0x00, 0x7d, 0xfe, 0x7e, 0x00, 0x7f, 0x06, 0x02, 0x0c, 0x68, 0xef, 0x54,
+0x07, 0x90, 0x3b, 0x79, 0x93, 0xfe, 0xf4, 0xf9, 0xef, 0x54, 0xf0, 0xff, 0x64, 0x10, 0x60, 0x11,
+0xef, 0x13, 0x13, 0x54, 0x3f, 0x24, 0x11, 0xf5, 0x82, 0xe4, 0x34, 0xff, 0xfa, 0xab, 0x82, 0x80,
+0x1a, 0xbd, 0x08, 0x02, 0x7d, 0x02, 0x7a, 0xff, 0x7b, 0x12, 0xed, 0x30, 0xe2, 0x05, 0x12, 0x3a,
+0x8e, 0x80, 0x03, 0x12, 0x3a, 0x96, 0xeb, 0x1b, 0x70, 0x01, 0x1a, 0xed, 0x30, 0xe1, 0x05, 0x12,
+0x3a, 0x8e, 0x80, 0x03, 0x12, 0x3a, 0x96, 0xeb, 0x1b, 0x70, 0x01, 0x1a, 0xed, 0x30, 0xe0, 0x04,
+0x12, 0x3a, 0x8e, 0x22, 0x12, 0x3a, 0x96, 0x22, 0x78, 0x68, 0xe6, 0xff, 0x78, 0x68, 0xe6, 0x60,
+0x29, 0xe5, 0x89, 0x30, 0xe7, 0x08, 0x12, 0x17, 0x46, 0x50, 0x03, 0xe0, 0x04, 0xf0, 0x12, 0x19,
+0x10, 0x30, 0xe7, 0x08, 0x12, 0x17, 0x46, 0x50, 0x03, 0xe0, 0x04, 0xf0, 0x78, 0x68, 0xe6, 0x6f,
+0x60, 0xda, 0xe6, 0xff, 0x12, 0x18, 0xa6, 0xf0, 0x80, 0xd2, 0xe4, 0xff, 0x78, 0x6a, 0xe6, 0xfe,
+0xef, 0xc3, 0x9e, 0x50, 0x14, 0x12, 0x18, 0x3e, 0xe0, 0xfc, 0xa3, 0xe0, 0xfd, 0xef, 0x12, 0x17,
+0xb0, 0xec, 0xf0, 0xa3, 0xed, 0xf0, 0x0f, 0x80, 0xe3, 0x22, 0x8f, 0x2d, 0xe4, 0xfd, 0x7f, 0x12,
+0x12, 0x34, 0x39, 0xaf, 0x2d, 0x15, 0x2d, 0xef, 0x60, 0x38, 0x75, 0xb1, 0x11, 0x75, 0xb4, 0x63,
+0x75, 0xb0, 0x0d, 0xe5, 0xb1, 0x20, 0xe0, 0x22, 0xe5, 0x89, 0x30, 0xe7, 0x08, 0x12, 0x2c, 0xf5,
+0x50, 0x03, 0xe0, 0x04, 0xf0, 0x75, 0x91, 0xc1, 0xe4, 0xf5, 0x91, 0xe5, 0x89, 0x30, 0xe7, 0xe3,
+0x12, 0x2c, 0xf5, 0x50, 0xde, 0xe0, 0x04, 0xf0, 0x80, 0xd9, 0xe4, 0xf5, 0xb0, 0x75, 0xb1, 0x01,
+0x80, 0xc1, 0x7d, 0x01, 0x7f, 0x12, 0x02, 0x34, 0x39, 0x85, 0x40, 0x82, 0x85, 0x3f, 0x83, 0x22,
+0x75, 0x89, 0x80, 0x90, 0x00, 0xc3, 0xe0, 0xc3, 0x94, 0xff, 0x22, 0x75, 0x8a, 0xa0, 0xe4, 0x90,
+0x00, 0xc0, 0xf0, 0x22, 0x7b, 0x00, 0x7a, 0x00, 0x79, 0x48, 0x22, 0xe0, 0xfe, 0xa3, 0xe0, 0xff,
+0xc3, 0x94, 0x78, 0xee, 0x94, 0x00, 0x22, 0xe4, 0x93, 0xff, 0x7e, 0x00, 0x7c, 0x00, 0x02, 0x0d,
+0x08, 0xe4, 0x78, 0x88, 0xf2, 0x08, 0xf2, 0x90, 0x00, 0xc8, 0xf0, 0x22, 0xab, 0x25, 0xaa, 0x26,
+0xa9, 0x27, 0x22, 0x78, 0x54, 0xe6, 0xfa, 0x08, 0xe6, 0xfb, 0xad, 0x2f, 0xaf, 0x2e, 0xef, 0xc3,
+0x94, 0x02, 0x50, 0x0e, 0xef, 0x25, 0xe0, 0x24, 0x6d, 0xf8, 0xa6, 0x05, 0xef, 0x12, 0x01, 0xe3,
+0x80, 0x24, 0xc3, 0x90, 0x00, 0xb6, 0xe0, 0x9b, 0x90, 0x00, 0xb5, 0xe0, 0x9a, 0x50, 0x06, 0x78,
+0x6d, 0xa6, 0x05, 0x80, 0x11, 0xc3, 0x90, 0x00, 0xb8, 0xe0, 0x9b, 0x90, 0x00, 0xb7, 0xe0, 0x9a,
+0x50, 0x09, 0x78, 0x6f, 0xa6, 0x05, 0xea, 0xf0, 0xa3, 0xeb, 0xf0, 0x22, 0xc0, 0xe0, 0xc0, 0xf0,
+0xc0, 0x83, 0xc0, 0x82, 0xc0, 0xd0, 0x75, 0xd0, 0x00, 0xc0, 0x00, 0xc0, 0x01, 0xc0, 0x02, 0xc0,
+0x03, 0xc0, 0x04, 0xc0, 0x05, 0xc0, 0x06, 0xc0, 0x07, 0x12, 0x19, 0x58, 0x12, 0x00, 0x0a, 0x7b,
+0xff, 0x7a, 0x2f, 0x79, 0xeb, 0x12, 0x28, 0x91, 0xd0, 0x07, 0xd0, 0x06, 0xd0, 0x05, 0xd0, 0x04,
+0xd0, 0x03, 0xd0, 0x02, 0xd0, 0x01, 0xd0, 0x00, 0xd0, 0xd0, 0xd0, 0x82, 0xd0, 0x83, 0xd0, 0xf0,
+0xd0, 0xe0, 0x32, 0x8f, 0x2a, 0x8d, 0x2b, 0xe5, 0x2b, 0x75, 0xf0, 0x2f, 0xa4, 0x24, 0x0a, 0x12,
+0x00, 0xf3, 0xe5, 0x2a, 0x12, 0x05, 0x17, 0x12, 0x34, 0x2a, 0xc0, 0x06, 0xc0, 0x07, 0xe5, 0x2b,
+0x75, 0xf0, 0x2f, 0xa4, 0x24, 0x08, 0x12, 0x00, 0xf3, 0xe5, 0x2a, 0x12, 0x05, 0xb8, 0x12, 0x34,
+0x2a, 0xd0, 0xe0, 0x2f, 0xff, 0xd0, 0xe0, 0x3e, 0xfe, 0x22, 0xf8, 0xe2, 0xfc, 0x08, 0xe2, 0xc3,
+0x9f, 0xff, 0xec, 0x9e, 0xfe, 0x12, 0x3b, 0x31, 0x22, 0x12, 0x3a, 0x7e, 0x60, 0x3e, 0xee, 0x64,
+0x01, 0x70, 0x18, 0xed, 0x60, 0x07, 0x78, 0x79, 0xe6, 0x4c, 0xf6, 0x80, 0x06, 0xec, 0xf4, 0x78,
+0x79, 0x56, 0xf6, 0x78, 0x79, 0xe6, 0x90, 0xff, 0x18, 0xf0, 0x22, 0xaf, 0x06, 0xef, 0x75, 0xf0,
+0x04, 0xa4, 0x24, 0x12, 0xff, 0xe5, 0xf0, 0x34, 0xff, 0x8f, 0x82, 0xf5, 0x83, 0xed, 0x60, 0x04,
+0xe0, 0x4c, 0xf0, 0x22, 0xe0, 0xff, 0xec, 0xf4, 0xfe, 0xef, 0x5e, 0xf0, 0x22, 0xc2, 0xd5, 0xe8,
+0x30, 0xe7, 0x0f, 0xb2, 0xd5, 0xe4, 0xc3, 0x9b, 0xfb, 0xe4, 0x9a, 0xfa, 0xe4, 0x99, 0xf9, 0xe4,
+0x98, 0xf8, 0xec, 0x30, 0xe7, 0x17, 0xb2, 0xd5, 0x12, 0x34, 0xb3, 0x12, 0x0f, 0x42, 0xe4, 0xc3,
+0x9b, 0xfb, 0xe4, 0x9a, 0xfa, 0xe4, 0x99, 0xf9, 0xe4, 0x98, 0xf8, 0x80, 0x03, 0x12, 0x0f, 0x42,
+0x30, 0xd5, 0x0d, 0xe4, 0xc3, 0x9f, 0xff, 0xe4, 0x9e, 0xfe, 0xe4, 0x9d, 0xfd, 0xe4, 0x9c, 0xfc,
+0x22, 0x12, 0x0c, 0xe6, 0xab, 0x1c, 0xe5, 0x1e, 0x24, 0x0c, 0xf9, 0xe4, 0x35, 0x1d, 0xfa, 0x7e,
+0x00, 0xe9, 0x25, 0x25, 0xf9, 0xee, 0x3a, 0xfa, 0x12, 0x0c, 0x8e, 0xff, 0x22, 0xab, 0x1c, 0xaa,
+0x1d, 0xa9, 0x1e, 0x90, 0x00, 0x0b, 0x12, 0x0c, 0xa7, 0xff, 0x22, 0x75, 0x8a, 0xa0, 0xe4, 0x90,
+0x00, 0xc0, 0xf0, 0x22, 0xab, 0x22, 0xaa, 0x23, 0xa9, 0x24, 0x85, 0x25, 0x82, 0x75, 0x83, 0x00,
+0x22, 0x8c, 0x0d, 0x8d, 0x0e, 0x12, 0x3a, 0xbd, 0x44, 0x18, 0x12, 0x3a, 0xb4, 0x90, 0xff, 0x14,
+0xe0, 0x44, 0x18, 0xf0, 0x90, 0xff, 0x1b, 0xe0, 0x44, 0x18, 0xf0, 0x75, 0xa3, 0x08, 0xef, 0x44,
+0x80, 0xf5, 0xa1, 0x75, 0xa6, 0x28, 0x75, 0xa2, 0xc1, 0xaf, 0x0e, 0x85, 0x0d, 0xd7, 0x8f, 0xd6,
+0x75, 0xd5, 0x02, 0x75, 0xd4, 0xf8, 0x75, 0xd2, 0x01, 0x75, 0xd1, 0xdf, 0x53, 0xac, 0xef, 0x22,
+0xc2, 0xaf, 0x12, 0x39, 0xc8, 0xe5, 0x9b, 0xb4, 0x5a, 0x16, 0xe5, 0x9a, 0xb4, 0xa5, 0x11, 0xe5,
+0x99, 0xb4, 0xf0, 0x0c, 0xe5, 0x98, 0xb4, 0x0f, 0x07, 0x90, 0xff, 0x85, 0xe0, 0x44, 0x20, 0xf0,
+0x75, 0x8a, 0x0a, 0xd2, 0xaf, 0x7f, 0x0a, 0x12, 0x35, 0xb3, 0x12, 0x3a, 0xdd, 0x12, 0x10, 0xc4,
+0x75, 0x8a, 0xa0, 0xe4, 0x90, 0x00, 0xc0, 0xf0, 0x80, 0xf3, 0xad, 0x07, 0x7f, 0x3a, 0x12, 0x35,
+0xe7, 0x90, 0x00, 0xc1, 0xe4, 0xf0, 0xa3, 0xef, 0xf0, 0x7f, 0x3b, 0x12, 0x35, 0xe7, 0xef, 0xfb,
+0x7a, 0x00, 0x90, 0x00, 0xc2, 0xe0, 0xfe, 0xe4, 0x2b, 0xff, 0xea, 0x3e, 0x90, 0x00, 0xc1, 0xf0,
+0xa3, 0xef, 0xf0, 0x90, 0x00, 0xc1, 0xe0, 0xb4, 0x80, 0x08, 0xa3, 0xe0, 0xb4, 0x67, 0x03, 0xbd,
+0xb6, 0xf1, 0x22, 0xe4, 0x90, 0x00, 0xc0, 0xf0, 0x90, 0x00, 0xc3, 0xf0, 0xef, 0x70, 0x0e, 0x75,
+0x88, 0x08, 0xf5, 0x8d, 0xf5, 0x8c, 0xf5, 0x8f, 0xf5, 0x8e, 0xf5, 0x88, 0x22, 0x75, 0x88, 0x08,
+0xe4, 0xf5, 0x8d, 0xf5, 0x8c, 0xef, 0x75, 0xf0, 0x20, 0xa4, 0xff, 0xe5, 0xf0, 0x44, 0x80, 0xf5,
+0x8f, 0x8f, 0x8e, 0x75, 0x88, 0xa0, 0x22, 0x90, 0xff, 0x00, 0x74, 0x02, 0xf0, 0x90, 0xff, 0x04,
+0xe4, 0xf0, 0x90, 0xff, 0x03, 0xef, 0xf0, 0x90, 0xff, 0x07, 0xe0, 0xff, 0x22, 0x11, 0x16, 0x00,
+0xb6, 0x11, 0x01, 0x0a, 0x14, 0x01, 0x02, 0x05, 0x3c, 0x70, 0x01, 0x00, 0x15, 0x01, 0x02, 0x01,
+0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00,
+0x00, 0x00, 0x03, 0x0a, 0x00, 0xc8, 0x03, 0xe8, 0x0f, 0x1e, 0x0e, 0x10, 0x3c, 0x01, 0x00, 0x50,
+0x10, 0x43, 0x41, 0x44, 0x51, 0x45, 0x52, 0x46, 0x53, 0x56, 0x54, 0x55, 0x17, 0x55, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x00, 0x28,
+0x05, 0x0b, 0x28, 0xff, 0xff, 0xff, 0xaa, 0x2e, 0x10, 0x01, 0x01, 0x0c, 0x0c, 0x01, 0x00, 0x96,
+0x00, 0x14, 0x02, 0x58, 0x09, 0x09, 0x85, 0x00, 0xc8, 0x00, 0x28, 0x02, 0x58, 0x0a, 0x02, 0x85,
+0x00, 0xc8, 0x00, 0x3c, 0x02, 0x58, 0x0a, 0x02, 0x85, 0x00, 0xc8, 0x00, 0x3c, 0x02, 0x58, 0x06,
+0x00, 0xef, 0x01, 0x3f, 0x00, 0x2d, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8,
+0x00, 0xf0, 0x00, 0xf0, 0x05, 0x01, 0x0a, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x64, 0x9c,
+0x00, 0x0a, 0x14, 0x02, 0x03, 0x09, 0x08, 0x00, 0xc8, 0x04, 0x00, 0x01, 0x0a, 0x0b, 0x00, 0xc8,
+0x04, 0x02, 0x03, 0x09, 0x08, 0x00, 0xc8, 0x04, 0x02, 0x03, 0x09, 0x08, 0x00, 0xc8, 0x04, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0a, 0x10, 0x3c, 0x01, 0x00, 0x50, 0x44, 0x41, 0x45,
+0x51, 0x46, 0x52, 0x56, 0x53, 0x55, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x00, 0x28, 0x05, 0x0b, 0x28,
+0xff, 0xff, 0xff, 0x64, 0x1e, 0x10, 0x01, 0x00, 0x08, 0x08, 0x85, 0x00, 0xc8, 0x00, 0x14, 0x02,
+0x58, 0x09, 0x09, 0x85, 0x00, 0xc8, 0x00, 0x28, 0x02, 0x58, 0x0a, 0x02, 0x85, 0x00, 0xc8, 0x00,
+0x3c, 0x02, 0x58, 0x0a, 0x02, 0x85, 0x00, 0xc8, 0x00, 0x3c, 0x02, 0x58, 0x05, 0x00, 0xf0, 0x00,
+0xf0, 0x00, 0x46, 0x00, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x2c, 0x01, 0x2c, 0x01,
+0x2c, 0x05, 0x01, 0x0a, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x64, 0x9c, 0x00, 0x0a, 0x14,
+0x02, 0x03, 0x07, 0x06, 0x01, 0x2c, 0x04, 0x00, 0x01, 0x08, 0x09, 0x01, 0x2c, 0x04, 0x02, 0x03,
+0x07, 0x06, 0x01, 0x2c, 0x04, 0x02, 0x03, 0x07, 0x06, 0x01, 0x2c, 0x04, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x05, 0x0a, 0x10, 0x3c, 0x01, 0x00, 0x50, 0x44, 0x41, 0x45, 0x51, 0x46, 0x52,
+0x56, 0x53, 0x55, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x1e,
+0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x00, 0x28, 0x05, 0x0b, 0x28, 0xff, 0xff, 0xff,
+0x64, 0x1e, 0x10, 0x01, 0x00, 0x08, 0x08, 0x85, 0x00, 0xc8, 0x00, 0x14, 0x02, 0x58, 0x09, 0x09,
+0x85, 0x00, 0xc8, 0x00, 0x28, 0x02, 0x58, 0x0a, 0x02, 0x85, 0x00, 0xc8, 0x00, 0x3c, 0x02, 0x58,
+0x0a, 0x02, 0x85, 0x00, 0xc8, 0x00, 0x3c, 0x02, 0x58, 0x05, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x46,
+0x00, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x2c, 0x01, 0x2c, 0x01, 0x2c, 0x05, 0x01,
+0x0a, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x64, 0x9c, 0x00, 0x0a, 0x14, 0x02, 0x03, 0x07,
+0x06, 0x01, 0x2c, 0x04, 0x00, 0x01, 0x08, 0x09, 0x01, 0x2c, 0x04, 0x02, 0x03, 0x07, 0x06, 0x01,
+0x2c, 0x04, 0x02, 0x03, 0x07, 0x06, 0x01, 0x2c, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x05, 0x0a, 0x10, 0x3c, 0x01, 0x00, 0x50, 0x44, 0x41, 0x45, 0x51, 0x46, 0x52, 0x56, 0x53, 0x55,
+0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
+0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x00, 0x28, 0x05, 0x0b, 0x28, 0xff, 0xff, 0xff, 0x64, 0x1e, 0x10,
+0x01, 0x00, 0x08, 0x08, 0x85, 0x00, 0xc8, 0x00, 0x14, 0x02, 0x58, 0x09, 0x09, 0x85, 0x00, 0xc8,
+0x00, 0x28, 0x02, 0x58, 0x0a, 0x02, 0x85, 0x00, 0xc8, 0x00, 0x3c, 0x02, 0x58, 0x0a, 0x02, 0x85,
+0x00, 0xc8, 0x00, 0x3c, 0x02, 0x58, 0x05, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x46, 0x00, 0x46, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x2c, 0x01, 0x2c, 0x01, 0x2c, 0x05, 0x01, 0x0a, 0x01, 0x04,
+0x00, 0x00, 0x00, 0x00, 0x02, 0x64, 0x9c, 0x00, 0x0a, 0x14, 0x02, 0x03, 0x07, 0x06, 0x01, 0x2c,
+0x04, 0x00, 0x01, 0x08, 0x09, 0x01, 0x2c, 0x04, 0x02, 0x03, 0x07, 0x06, 0x01, 0x2c, 0x04, 0x02,
+0x03, 0x07, 0x06, 0x01, 0x2c, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0e, 0x10,
+0x3c, 0x01, 0x00, 0x64, 0x10, 0x41, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x46, 0x45, 0x44, 0x43,
+0x17, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28,
+0x28, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xa0, 0x22, 0x10, 0x00, 0x00, 0x08,
+0x08, 0x85, 0x00, 0xc8, 0x00, 0x14, 0x02, 0x58, 0x09, 0x09, 0x85, 0x00, 0xc8, 0x00, 0x28, 0x02,
+0x58, 0x0a, 0x02, 0x85, 0x00, 0xc8, 0x00, 0x3c, 0x02, 0x58, 0x0a, 0x02, 0x85, 0x00, 0xc8, 0x00,
+0x3c, 0x02, 0x58, 0x07, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x01, 0x2c, 0x01, 0x2c, 0x01, 0x2c, 0x05, 0x01, 0x0a, 0x01, 0x04, 0x00, 0x00, 0x00,
+0x00, 0x02, 0x08, 0xfa, 0x00, 0x64, 0x14, 0x02, 0x03, 0x0b, 0x0a, 0x00, 0xc8, 0x04, 0x00, 0x01,
+0x0c, 0x0d, 0x00, 0x96, 0x04, 0x02, 0x03, 0x0b, 0x0a, 0x00, 0xc8, 0x04, 0x02, 0x03, 0x0b, 0x0a,
+0x00, 0xc8, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xe4, 0xf5, 0x3c, 0xf5, 0x3d,
+0xff, 0x12, 0x0c, 0x8e, 0x25, 0x3d, 0xf5, 0x3d, 0xe4, 0x35, 0x3c, 0xf5, 0x3c, 0x90, 0xff, 0xff,
+0x12, 0x0c, 0xa7, 0x12, 0x0c, 0xd4, 0x74, 0xff, 0x29, 0xf9, 0x74, 0xff, 0x3a, 0xfa, 0x0f, 0xbf,
+0x09, 0xdf, 0xed, 0x12, 0x0c, 0xd4, 0xae, 0x3c, 0xaf, 0x3d, 0x22, 0x12, 0x3a, 0x7e, 0x60, 0x29,
+0x90, 0xff, 0x13, 0xee, 0xd3, 0x94, 0x03, 0x40, 0x11, 0xaf, 0x06, 0xef, 0x75, 0xf0, 0x04, 0xa4,
+0x25, 0x82, 0xf5, 0x82, 0xe5, 0xf0, 0x35, 0x83, 0xf5, 0x83, 0xed, 0x60, 0x04, 0xe0, 0x4c, 0xf0,
+0x22, 0xe0, 0xff, 0xec, 0xf4, 0xfe, 0xef, 0x5e, 0xf0, 0x22, 0x85, 0x21, 0x82, 0x85, 0x20, 0x83,
+0x22, 0xab, 0x1c, 0xaa, 0x1d, 0xa9, 0x1e, 0x12, 0x0d, 0xbb, 0xff, 0x22, 0xab, 0x1c, 0xaa, 0x1d,
+0xa9, 0x1e, 0x90, 0x00, 0x02, 0x12, 0x0d, 0xe6, 0xff, 0x22, 0x93, 0xfd, 0xd3, 0x90, 0x00, 0xbe,
+0xe0, 0x9d, 0x90, 0x00, 0xbd, 0xe0, 0x9c, 0x22, 0x75, 0x9b, 0x5a, 0x75, 0x9a, 0xa5, 0x75, 0x99,
+0xf0, 0x75, 0x98, 0x0f, 0x75, 0xac, 0xff, 0x75, 0xad, 0xff, 0x90, 0xff, 0x88, 0x74, 0x40, 0xf0,
+0x74, 0xc0, 0xf0, 0x90, 0xff, 0x01, 0x74, 0x01, 0xf0, 0x75, 0x95, 0xf1, 0xe4, 0xf5, 0x96, 0x75,
+0x97, 0xc7, 0x22, 0xef, 0x60, 0x0f, 0x43, 0xac, 0x10, 0x12, 0x3a, 0xbd, 0x54, 0xe7, 0x12, 0x3a,
+0xb4, 0xe4, 0xf5, 0xa2, 0x22, 0x12, 0x3a, 0xb5, 0xa3, 0xe0, 0x44, 0x18, 0xf0, 0xa3, 0xe0, 0x54,
+0xe7, 0xf0, 0x75, 0xa2, 0xc1, 0x53, 0xac, 0xef, 0x22, 0xc3, 0xef, 0x94, 0x01, 0xee, 0x64, 0x80,
+0x94, 0x80, 0x50, 0x06, 0x7e, 0x00, 0x7f, 0x01, 0x80, 0x11, 0xd3, 0xef, 0x9d, 0xee, 0x9c, 0x40,
+0x0a, 0xed, 0x24, 0xff, 0xff, 0xec, 0x34, 0xff, 0xfe, 0x80, 0x00, 0x22, 0xe4, 0x78, 0x72, 0xf6,
+0x8f, 0x82, 0x8e, 0x83, 0x74, 0x55, 0x93, 0x78, 0x6c, 0xf6, 0xef, 0x24, 0x55, 0xf5, 0x44, 0xe4,
+0x3e, 0xf5, 0x43, 0x78, 0x00, 0xe2, 0x54, 0xfe, 0xf2, 0x54, 0xfb, 0xf2, 0x22, 0xab, 0x1f, 0xaa,
+0x20, 0xa9, 0x21, 0x90, 0x00, 0x01, 0x12, 0x0c, 0xa7, 0xff, 0x22, 0x90, 0xff, 0x50, 0xf0, 0x90,
+0xff, 0x58, 0xf0, 0xab, 0x1f, 0xaa, 0x20, 0xa9, 0x21, 0x12, 0x0c, 0x8e, 0xff, 0x22, 0xef, 0x54,
+0x07, 0x90, 0x3b, 0x79, 0x93, 0xfc, 0xef, 0xc4, 0x54, 0x0f, 0xfe, 0xef, 0xf4, 0x22, 0x8b, 0x82,
+0x8a, 0x83, 0xe0, 0x4e, 0xf0, 0x22, 0x8b, 0x82, 0x8a, 0x83, 0xe0, 0x59, 0xf0, 0x22, 0xe4, 0x90,
+0x00, 0xcd, 0xf0, 0x8f, 0x82, 0x8e, 0x83, 0x74, 0x23, 0x93, 0xff, 0xc3, 0x74, 0x40, 0x9f, 0x90,
+0x00, 0xcc, 0xf0, 0x22, 0xf0, 0x90, 0xff, 0x10, 0xe0, 0x54, 0xe7, 0xf0, 0x22, 0x90, 0xff, 0x12,
+0xe0, 0x54, 0xe7, 0xf0, 0x90, 0xff, 0x11, 0xe0, 0x22, 0xef, 0x75, 0xf0, 0x0a, 0xa4, 0x24, 0x03,
+0xf5, 0x82, 0xe4, 0x34, 0x02, 0xf5, 0x83, 0xe0, 0xfe, 0xa3, 0xe0, 0xff, 0x22, 0x12, 0x2d, 0xb8,
+0x78, 0x74, 0x76, 0x00, 0x08, 0x76, 0x28, 0x90, 0x00, 0xc9, 0x74, 0x04, 0xf0, 0x22, 0xef, 0x24,
+0x30, 0xf5, 0x09, 0xe4, 0x3e, 0xf5, 0x08, 0xe4, 0xf5, 0x0b, 0xf5, 0x0c, 0xf5, 0x0a, 0x22, 0x74,
+0xb7, 0x2f, 0xf5, 0x82, 0xe4, 0x34, 0x02, 0xf5, 0x83, 0xe0, 0xff, 0x22, 0x85, 0x1e, 0x82, 0x85,
+0x1d, 0x83, 0x75, 0xf0, 0x07, 0xef, 0x02, 0x10, 0x59, 0x8d, 0x22, 0xaf, 0x22, 0x12, 0x24, 0xe3,
+0xaf, 0x22, 0x02, 0x19, 0x8b, 0xef, 0x25, 0xe0, 0x24, 0x5f, 0xf8, 0xe2, 0xfe, 0x08, 0xe2, 0xff,
+0x22, 0xee, 0x30, 0xe7, 0x07, 0xc3, 0xe4, 0x9f, 0xff, 0xe4, 0x9e, 0xfe, 0x22, 0x12, 0x33, 0x19,
+0x74, 0x78, 0x93, 0xfd, 0x02, 0x05, 0xfc, 0x7f, 0x30, 0x12, 0x35, 0xe7, 0x22, 0x41, 0x00, 0xc8,
+0x00, 0x00, 0x78, 0x66, 0xa6, 0x07, 0x22, 0x12, 0x3a, 0xc9, 0x22, 0x11, 0x10, 0x41, 0x51, 0x52,
+0x53, 0x54, 0x55, 0x56, 0x46, 0x45, 0x44, 0x43, 0x17, 0x16, 0x11, 0x40, 0x41, 0x50, 0x51, 0x52,
+0x53, 0x54, 0x55, 0x46, 0x45, 0x44, 0x43, 0x42, 0x16, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40,
+0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0xb6, 0x02, 0x30, 0x21, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xed,
+]
+
+
+#endif /*CAPACITIVE_HYNITRON_CST816D_UPDATE_H__*/
--- /dev/null
+import lvgl as lv
+import code128
+# 界面风格1
+# style_bar = lv.style_t()
+# style_bar.init()
+# style_bar.set_border_width(0)
+# style_bar.set_radius(0)
+# style_bar.set_pad_top(0)
+# style_bar.set_pad_bottom(0)
+# style_bar.set_pad_left(0)
+# style_bar.set_pad_right(0)
+style_bar = lv.style_t()
+style_bar.init()
+style_bar.set_radius(0)
+style_bar.set_bg_color(lv.color_make(0x00, 0x00, 0x00))
+style_bar.set_bg_opa(255)
+style_bar.set_border_width(0)
+style_bar.set_pad_left(0)
+style_bar.set_pad_right(0)
+style_bar.set_pad_top(0)
+style_bar.set_pad_bottom(0)
+#screen = lv.obj()
+
+
+
+def code_128_generate_barcode(screen, data, width=180, height=80):
+
+ left_curr_line = 0
+
+ # 删除上次的container
+ old_container = screen.get_child(-1)
+ old_container.add_flag(lv.obj.FLAG.HIDDEN)
+
+ # 生成二进制码
+ binary_data = code128.encode(data)
+ if not binary_data:
+ return
+ # print("binary_data is ",binary_data)
+
+ # 在LVGL中创建一个容器对象
+ container = lv.obj(screen)
+ container.set_size(width, height)
+ container.set_pos(0, 33)
+ container.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ container.add_style(style_bar,lv.PART.MAIN | lv.STATE.DEFAULT)
+ container.add_flag(lv.obj.FLAG.HIDDEN)
+ # 计算每个条的宽度
+ bar_width = width // (len(binary_data))
+ # print("bar_width is :{} len(binary_data):{}".format(bar_width,len(binary_data)))
+ # 按照二进制码中的1和0,分别创建LVGL矩形对象
+ for i in range(len(binary_data)):
+ # print("left_curr_line is :{} width:{}".format(left_curr_line,width))
+ bar = lv.obj(container)
+ bar.add_style(style_bar, lv.PART.MAIN | lv.STATE.DEFAULT)
+ real_width = bar_width * 1
+ bar.set_size(1,90)
+ left = (width - len(binary_data))//2#240-152 = 88 //2 ==44
+ bar.set_pos(left+left_curr_line,0)
+ if binary_data[i] == 0xff:
+ bar.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff), lv.PART.MAIN | lv.STATE.DEFAULT)
+ else:
+ bar.set_style_bg_color(lv.color_make(0x00, 0x00, 0x00), lv.PART.MAIN | lv.STATE.DEFAULT)
+ left_curr_line += real_width
+ container.clear_flag(lv.obj.FLAG.HIDDEN)
+ old_container.clear_flag(lv.obj.FLAG.HIDDEN)
+ if old_container:
+ old_container.delete()
+
+
+# if __name__ == "__main__":
+# code_39_generate_barcode(screen,"A123 321")
+# lv.scr_load(screen)
+
--- /dev/null
+class PROTOCOL:
+ LK_SEND = "LK_SEND"
+ LK_RECV = "LK_RECV"
+
+ PING_SEND = "PING_SEND"
+ PING_RECV = "PING_RECV"
+
+ KA_SEND = "KA_SEND"
+ KA_RECV = "KA_RECV"
+
+ UD_SEND = "UD_SEND"
+ UD_RECV = "UD_RECV"
+
+ CR_SEND = "CR_SEND"
+ CR_RECV = "CR_RECV"
+
+ AL_SEND = "AL_SEND"
+ AL_RECV = "AL_RECV"
+
+ FIND_SEND = "FIND_SEND"
+ FIND_RECV = "FIND_RECV"
+
+ POWEROFF_SEND = "POWEROFF_SEND"
+ POWEROFF_RECV = "POWEROFF_RECV"
+
+ PHL_SEND = "PHL_SEND"
+ PHL_RECV = "PHL_RECV"
+
+ TK_SEND = "TK_SEND"
+ TK_RECV = "TK_RECV"
+
+ TKS_SEND = "TKS_SEND"
+ TKS_RECV = "TKS_RECV"
+
+ MESSAGE_SEND = "MESSAGE_SEND"
+ MESSAGE_RECV = "MESSAGE_RECV"
+
+ WT_SEND = "WT_SEND"
+ WT_RECV = "WT_RECV"
+
+ REMIND_SEND = "REMIND_SEND"
+ REMIND_RECV = "REMIND_RECV"
+
+ HRTSTART_SEND = "hrtstart_SEND"
+ HRTSTART_RECV = "hrtstart_RECV"
+
+ HEART_SEND = "heart_SEND"
+ HEART_RECV = "heart_RECV"
+
+ OXYGEN_SEND = "oxygen_SEND"
+ OXYGEN_RECV = "oxygen_RECV"
+
+ OXSTART_SEND = "oxstart_SEND"
+ OXSTART_RECV = "oxstart_RECV"
+
+ TEMP_SEND = "temp_SEND"
+ TEMP_RECV = "temp_RECV"
+
+ DLT_SEND = "DLT_SEND"
+ DLT_RECV = "DLT_RECV"
+
+ UPLOAD_SEND = "UPLOAD_SEND"
+ UPLOAD_RECV = "UPLOAD_RECV"
+
+ CENTER_SEND = "CENTER_SEND"
+ CENTER_RECV = "CENTER_RECV"
+
+ MONITOR_SEND = "MONITOR_SEND"
+ MONITOR_RECV = "MONITOR_RECV"
+
+ SOS_SEND = "SOS_SEND"
+ SOS_RECV = "SOS_RECV"
+
+ BOOTOFF_SEND = "BOOTOFF_SEND"
+ BOOTOFF_RECV = "BOOTOFF_RECV"
+
+ WDSTART_SEND ="wdstart_SEND"
+ WDSTART_RECV ="wdstart_RECV"
+
+
+ LOWBAT_SEND = "LOWBAT_SEND"
+ LOWBAT_RECV = "LOWBAT_RECV"
+
+ TIME_SEND = "Time_SEND"
+ TIME_RECV = "Time_RECV"
+
+ WLKEY_SEND = "WLKEY_SEND"
+ WLKEY_RECV = "WLKEY_RECV"
+
+ SILENCETIME2_SEND = "SILENCETIME2_SEND"
+ SILENCETIME2_RECV = "SILENCETIME2_RECV"
+
+ KEYBRD_SEND = "KEYBRD_SEND"
+ KEYBRD_RECV = "KEYBRD_RECV"
+
+ FALLDOWN_SEND = "FALLDOWN_SEND"
+ FALLDOWN_RECV = "FALLDOWN_RECV"
+
+ HELP_SEND = "HELP_SEND"
+ HELP_RECV = "HELP_RECV"
+
+ REMOVE_SEND = "REMOVE_SEND"
+ REMOVE_RECV = "REMOVE_RECV"
+
+ BLOOD_SEND = "blood_SEND"
+ BLOOD_RECV = "blood_RECV"
+
+ BLDSTART_SEND ="bldstart_SEND"
+ BLDSTART_RECV = "bldstart_RECV"
+
+ BGSTART_SEND = "bgstart_SEND"
+ BGSTART_RECV = "bgstart_RECV"
+
+ BLOODGLUSOCE_SEND = "bloodglucose_SEND"
+ BLOODGLUSOCE_RECV = "bloodglucose_RECV"
+
+ REMIND_CH_DRINK_SEND = "REMIND_CH_DRINK_SEND"
+ REMIND_CH_DRINK_RECV = "REMIND_CH_DRINK_RECV"
+
+ REMIND_CH_MEDICINE2_SEND = "REMIND_CH_MEDICINE2_SEND"
+ REMIND_CH_MEDICINE2_RECV = "REMIND_CH_MEDICINE2_RECV"
+
+ REMIND_CH_HOME_SEND = "REMIND_CH_HOME_SEND"
+ REMIND_CH_HOME_RECV = "REMIND_CH_HOME_RECV"
+
+ REMIND_CH_WAKEUP_SEND = "REMIND_CH_WAKEUP_SEND"
+ REMIND_CH_WAKEUP_RECV = "REMIND_CH_WAKEUP_RECV"
+
+ REMIND_CH_SLEEP_SEND = "REMIND_CH_SLEEP_SEND"
+ REMIND_CH_SLEEP_RECV = "REMIND_CH_SLEEP_RECV"
+
+ REMIND_CH_REST_SEND = "REMIND_CH_REST_SEND"
+ REMIND_CH_REST_RECV = "REMIND_CH_REST_RECV"
+
+ SLEEP_DATA_SEND = "SleepReport_SEND"
+ SLEEP_DATA_RECV = "SleepReport_RECV"
+
+ SLEEPTIME_SEND = "SLEEPTIME_SEND"
+ SLEEPTIME_RECV = "SLEEPTIME_RECV"
+
+ FACTORY_SEND = "FACTORY_SEND"
+ FACTORY_RECV = "FACTORY_RECV"
+
+ RESET_SEND = "RESET_SEND"
+ RESET_RECV = "RESET_RECV"
+
+ REMIND_CH_SIT_SEND = "REMIND_CH_SIT_SEND"
+ REMIND_CH_SIT_RECV = "REMIND_CH_SIT_RECV"
+
+ SCREEN_SHOW_SEND = "SCREEN_SHOW_SEND"
+ SCREEN_SHOW_RECV = "SCREEN_SHOW_RECV"
+
+ JPREG_SEND = "JPREG_SEND"
+ JPREG_RECV = "JPREG_RECV"
+
+ MEMBERS_SEND = "MEMBERS_SEND"
+ MEMBERS_RECV = "MEMBERS_RECV"
+
+ CALLING_SEND = "CALLING_SEND"
+ CALLING_RECV = "CALLING_RECV"
+
+
+ RCALLING_SEND = "RCALLING_SEND"
+ RCALLING_RECV = "RCALLING_RECV"
+
+ AGTALK_SEND = "AGTALK_SEND"
+ AGTALK_RECV = "AGTALK_RECV"
+
+ RTALK_SEND = "RTALK_SEND"
+ RTALK_RECV = "RTALK_RECV"
+
+ JMEMBERS_SEND = "JMEMBERS_SEND"
+ JMEMBERS_RECV = "JMEMBERS_RECV"
+
+ RINGING_SEND = "RINGING_SEND"
+ RINGING_RECV = "RINGING_RECV"
+
+ HANGUP_SEND = "HANGUP_SEND"
+ HANGUP_RECV = "HANGUP_RECV"
+
+ CALLCANCEL_SEND ="CALLCANCEL_SEND"
+ CALLCANCEL_RECV = "CALLCANCEL_RECV"
+
+
+class EVENT:
+ CHANNEL_SOCKET_SEND = "CHANNEL_SOCKET_SEND"
+ START_LOCATION = "START_LOCATION"
+ START_LOCATION_TEST = "START_LOCATION_TEST"
+ READ_LOCATION = "READ_LOCATION"
+ CLOSE_LOCATION = "CLOSE_LOCATION"
+ GPSOPEN = "GPSOPEN"
+ GPSCLOSE = "GPSCLOSE"
+ GPSINFO = "GPSINFO"
+ WIFISCANOPEN = "WIFISCANOPEN"
+ WIFIINFO = "WIFIINFO"
+
+ GET_KEY = "GET_KEY"
+ SET_KEY = "SET_KEY"
+ GET_IMEI = "GET_IMEI"
+ GET_CID = "GET_CID"
+ SET_CID = "SET_CID"
+ GET_IMSI = "GET_IMSI"
+ GET_PASSWORD = "GET_PASSWORD"
+ SET_PASSWORD = "SET_PASSWORD"
+ GET_BATTERY = "GET_BATTERY"
+ PERSISTENT_CONFIG_GET = "PERSISTENT_CONFIG_GET"
+ PERSISTENT_CONFIG_STORE = "PERSISTENT_CONFIG_STORE"
+ SET_PING = "SET_PING"
+ GET_PING = "GET_PING"
+ SET_CONNECT = "SET_CONNECT"
+ GET_CONNECT = "GET_CONNECT"
+ GET_STEP = "GET_STEP"
+ PUSH_STEP = "PUSH_STEP"
+ SYSTEM_SLEEP = "SYSTEM_SLEEP"
+ SYSTEM_UP = "SYSTEM_UP"
+ START_HEART = "START_HEART"
+ GET_HEART = "GET_HEART"
+ STOP_HEART = "STOP_HEART"
+ GET_WEAR = "GET_WEAR"
+ START_TEMP = "START_TEMP"
+ STOP_TEMP = "STOP_TEMP"
+ GET_TEMP = "GET_TEMP"
+ START_BLOOD_OXYGEN = "STARTT_BLOOD_OXYGEN"
+ GET_BLOOD_OXYGEN = "GET_BLOOD_OXYGEN"
+ STOP_BLOOD_OXYGEN = "STOP_BLOOD_OXYGEN"
--- /dev/null
+import lvgl as lv
+from machine import LCD, Pin
+from tp import cst816
+import _thread
+import utime
+import EventMesh
+from misc import PWM
+
+
+init_data = (
+
+ 0, 0, 0x11,
+ 2, 0, 120,
+
+ 0, 1, 0x36,
+ 1, 1, 0x00,
+
+ 0, 1, 0x35,
+ 1, 1, 0x00,
+
+ 0, 1, 0x3a,
+ 1, 1, 0x05,
+
+ 0, 5, 0xB2,
+ 1, 1, 0x0c,
+ 1, 1, 0x0c,
+ 1, 1, 0x00,
+ 1, 1, 0x33,
+ 1, 1, 0x33,
+
+ 0, 1, 0xB7,
+ 1, 1, 0x77,
+
+ 0, 1, 0xBB,
+ 1, 1, 0x2c,
+
+ 0, 1, 0xC0,
+ 1, 1, 0x2C,
+
+ 0, 1, 0xC2,
+ 1, 1, 0x01,
+
+ 0, 1, 0xC3,
+ 1, 1, 0x21,
+
+ 0, 1, 0xC4,
+ 1, 1, 0x20,
+
+ 0, 1, 0xC6,
+ 1, 1, 0x10,
+
+ 0, 2, 0xD0,
+ 1, 1, 0xA4,
+ 1, 1, 0xA1,
+
+ 0, 14, 0xE0,
+ 1, 1, 0xd0,
+ 1, 1, 0x03,
+ 1, 1, 0x08,
+ 1, 1, 0x0e,
+ 1, 1, 0x12,
+ 1, 1, 0x2d,
+ 1, 1, 0x42,
+ 1, 1, 0x45,
+ 1, 1, 0x53,
+ 1, 1, 0x29,
+ 1, 1, 0x16,
+ 1, 1, 0x15,
+ 1, 1, 0x22,
+ 1, 1, 0x24,
+
+ 0, 14, 0xE1,
+ 1, 1, 0xd0,
+ 1, 1, 0x03,
+ 1, 1, 0x08,
+ 1, 1, 0x0e,
+ 1, 1, 0x13,
+ 1, 1, 0x2c,
+ 1, 1, 0x42,
+ 1, 1, 0x54,
+ 1, 1, 0x50,
+ 1, 1, 0x2c,
+ 1, 1, 0x16,
+ 1, 1, 0x16,
+ 1, 1, 0x20,
+ 1, 1, 0x27,
+ #0, 0, 0x11,
+ 0, 0, 0x21,
+ 0, 0, 0x29,
+ #0, 1, 0xe7,
+ #1, 1, 0x11,
+)
+
+XSTART_H = 0xf0
+XSTART_L = 0xf1
+YSTART_H = 0xf2
+YSTART_L = 0xf3
+XEND_H = 0xE0
+XEND_L = 0xE1
+YEND_H = 0xE2
+YEND_L = 0xE3
+
+XSTART = 0xD0
+XEND = 0xD1
+YSTART = 0xD2
+YEND = 0xD3
+
+lcd = LCD()
+
+init_buf = bytearray(init_data)
+
+init_data2 = (
+ 0, 4, 0x2a,
+ 1, 1, XSTART_H,
+ 1, 1, XSTART_L,
+ 1, 1, XEND_H,
+ 1, 1, XEND_L,
+ 0, 4, 0x2b,
+ 1, 1, YSTART_H,
+ 1, 1, YSTART_L,
+ 1, 1, YEND_H,
+ 1, 1, YEND_L,
+ 0, 0, 0x2c,
+)
+invalid = bytearray(init_data2)
+
+init_data3 = (
+ 0, 0, 0x28,
+ 2, 0, 120,
+ 0, 0, 0x10,
+)
+displayoff = bytearray(init_data3)
+
+init_data4 = (
+ 0, 0, 0x11,
+ 2, 0, 20,
+ 0, 0, 0x29,
+)
+displayon = bytearray(init_data4)
+# CST816初始化
+# import initTP
+# initTP.HYN_Initial()
+# tp_cst816 = cst816(i2c_no = 2,irq=33, reset=32)
+# tp_cst816.activate()
+# tp_cst816.init()
+
+#print("cst816 init...")
+# from btn_device_ec800m import BtnDevice
+# btn_device = BtnDevice(None)
+# btn_device.start()
+
+lcd_ctrl = Pin(Pin.GPIO18, Pin.OUT, Pin.PULL_DISABLE, 1)
+lcd.lcd_init(init_buf, 240, 320, 52000, 1, 4, 0, invalid, displayon, displayoff, None,TESel = True,TEPin = 17)
+# gpio_backlight = Pin(Pin.GPIO37, Pin.OUT, Pin.PULL_DISABLE, 0)
+# gpio_backlight.write(1)
+PWM_backlight = PWM(PWM.PWM1, PWM.ABOVE_MS, 0, 1)
+PWM_backlight.open()
+
+LCD_SIZE_W = 240
+LCD_SIZE_H = 320
+# pwm.close()
+# 初始化lvgl
+lv.init()
+
+# Register SDL display driver.
+disp_buf1 = lv.disp_draw_buf_t()
+buf1_1 = bytearray(LCD_SIZE_W * LCD_SIZE_H * 2)
+#buf1_2= bytearray(LCD_SIZE_W * LCD_SIZE_H * 2)
+
+disp_buf1.init(buf1_1, None, len(buf1_1))
+disp_drv = lv.disp_drv_t()
+disp_drv.init()
+disp_drv.draw_buf = disp_buf1
+disp_drv.flush_cb = lcd.lcd_write
+disp_drv.hor_res = LCD_SIZE_W
+disp_drv.ver_res = LCD_SIZE_H
+disp_drv.register()
+
+
+# LVGL触摸注册
+indev_drv = lv.indev_drv_t()
+indev_drv.init()
+indev_drv.type = lv.INDEV_TYPE.POINTER
+#indev_drv.read_cb = tp_cst816.read
+indev_drv.long_press_time = 400
+indev_drv.register()
+gpio4 = Pin(Pin.GPIO33, Pin.OUT, Pin.PULL_PU, 0)
+
+# def indev_task():
+# while 1:
+# pos_s = tp_cst816.read_xy()
+# # import _thread
+# # x = _thread.get_heap_size()
+# # print('heap:',x)
+# if pos_s:
+# if 100 == pos_s[0] and 400 == pos_s[1]:
+# EventMesh.publish("done_return")
+# print("return")
+# utime.sleep_ms(200)
+# else:
+# utime.sleep_ms(200)
+
+# _thread.start_new_thread(indev_task,())
+
+# 启动lvgv线程
+lv.tick_inc(5)
+lv.task_handler()
+style_screen = lv.style_t()
+style_screen.init()
+style_screen.set_radius(0)
+style_screen.set_bg_color(lv.color_make(0x00, 0x00, 0x00))
+style_screen.set_bg_opa(255)
+style_screen.set_border_width(0)
+style_screen.set_pad_left(0)
+style_screen.set_pad_right(0)
+style_screen.set_pad_top(0)
+style_screen.set_pad_bottom(0)
+#开机画面
+style_font_youyuan_40 = lv.style_t()
+style_font_youyuan_40.init()
+style_font_youyuan_40.set_text_color(lv.color_make(0xff, 0xff, 0xff))
+style_font_youyuan_40.set_text_font_v2("font_40.bin",40,0)
+
+style_font_youyuan_black_40 = lv.style_t()
+style_font_youyuan_black_40.init()
+style_font_youyuan_black_40.set_text_color(lv.color_make(0x00, 0x00, 0x00))
+style_font_youyuan_black_40.set_text_font_v2("font_40.bin",40,0)
+
+style_font_youyuan_20_op = lv.style_t()
+style_font_youyuan_20_op.init()
+style_font_youyuan_20_op.set_text_color(lv.color_make(0xff, 0xff, 0xff))
+style_font_youyuan_20_op.set_text_font_v2("font_28.bin",28,0)
+
+power_on_screen = lv.obj()
+print("power_on_screen")
+power_on_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+power_on_label = lv.label(power_on_screen)
+power_on_label.set_pos(0, 150)
+power_on_label.set_size(240, 40)
+power_on_label.set_text("系统初始化中")
+power_on_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+power_on_label.add_style(style_font_youyuan_20_op, lv.PART.MAIN | lv.STATE.DEFAULT)
+print("power_on_screen init...")
+lv.scr_load(power_on_screen)
+utime.sleep_ms(200)
+print("power_on_screen end...")
+PWM_backlight = PWM(PWM.PWM1, PWM.ABOVE_MS, 6, 10)
+PWM_backlight.open()
--- /dev/null
+# Copyright (c) Quectel Wireless Solution, Co., Ltd.All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import ure
+import net
+import math
+import utime
+import osTimer
+import _thread
+import wifiScan
+import cellLocator
+
+from queue import Queue
+from machine import UART, Pin
+
+try:
+ from wifilocator import wifilocator
+except:
+ wifilocator = None
+
+from log import getLogger
+
+try:
+ import quecgnss
+except ImportError:
+ quecgnss = None
+
+log = getLogger(__name__)
+
+_gps_read_lock = _thread.allocate_lock()
+_gps_data_set_lock = _thread.allocate_lock()
+
+EE = 0.00669342162296594323
+EARTH_RADIUS = 6378.137 # Approximate Earth Radius(km)
+M_PI = math.pi
+
+
+class _loc_method(object):
+ gps = 0x1
+ cell = 0x2
+ wifi = 0x4
+
+
+class _gps_mode(object):
+ none = 0x0
+ internal = 0x1
+ external = 0x2
+
+
+def transformLat(x, y):
+ ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * math.sqrt(math.fabs(x))
+ ret += (20.0 * math.sin(6.0 * x * M_PI) + 20.0 * math.sin(2.0 * x * M_PI)) * 2.0 / 3.0
+ ret += (20.0 * math.sin(y * M_PI) + 40.0 * math.sin(y / 3.0 * M_PI)) * 2.0 / 3.0
+ ret += (160.0 * math.sin(y / 12.0 * M_PI) + 320 * math.sin(y * M_PI / 30.0)) * 2.0 / 3.0
+ return ret
+
+
+def transformLon(x, y):
+ ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * math.sqrt(math.fabs(x))
+ ret += (20.0 * math.sin(6.0 * x * M_PI) + 20.0 * math.sin(2.0 * x * M_PI)) * 2.0 / 3.0
+ ret += (20.0 * math.sin(x * M_PI) + 40.0 * math.sin(x / 3.0 * M_PI)) * 2.0 / 3.0
+ ret += (150.0 * math.sin(x / 12.0 * M_PI) + 300.0 * math.sin(x / 30.0 * M_PI)) * 2.0 / 3.0
+ return ret
+
+
+def WGS84ToGCJ02(lon, lat):
+ dLat = transformLat(lon - 105.0, lat - 35.0)
+ dLon = transformLon(lon - 105.0, lat - 35.0)
+ radLat = lat / 180.0 * M_PI
+ magic = math.sin(radLat)
+ magic = 1 - magic * magic * EE
+ sqrtMagic = math.sqrt(magic)
+
+ dLat = (dLat * 180.0) / ((EARTH_RADIUS * 1000 * (1 - EE)) / (magic * sqrtMagic) * M_PI)
+ dLon = (dLon * 180.0) / (EARTH_RADIUS * 1000 / sqrtMagic * math.cos(radLat) * M_PI)
+ lon02 = lon + dLon
+ lat02 = lat + dLat
+
+ return lon02, lat02
+
+
+class GPSMatch(object):
+ """This class is match gps NEMA 0183"""
+
+ def GxRMC(self, gps_data):
+ """Match Recommended Minimum Specific GPS/TRANSIT Data(RMC)
+
+ Args:
+ gps_data(str): GPS NMEA string.
+
+ Returns:
+ str: RMC NMEA string.
+ """
+ if gps_data:
+ rmc_re = ure.search(
+ r"\$G[NP]RMC,\d*\.*\d*,*[AV],*\d*\.*\d*,*[NS],*\d*\.*\d*,*[EW],*\d*\.*\d*,*\d*\.*\d*,*\d*,*\d*\.*\d*,*[EW]*,*[ADEN]*,*[SCUV]*\**(\d|\w)*",
+ gps_data)
+ if rmc_re:
+ return rmc_re.group(0)
+ return ""
+
+ def GxGGA(self, gps_data):
+ """Match Global Positioning System Fix Data(GGA)
+
+ Args:
+ gps_data(str): GPS NMEA string.
+
+ Returns:
+ str: GGA NMEA string.
+ """
+ if gps_data:
+ gga_re = ure.search(
+ r"\$G[BLPN]GGA,\d*\.*\d*,*\d*\.*\d*,*[NS],*\d*\.*\d*,*[EW],*[0126],*\d*,*\d*\.*\d*,*-*\d*\.*\d*,*M,*-*\d*\.*\d*,*M,*\d*,*\**(\d|\w)*",
+ gps_data)
+ if gga_re:
+ return gga_re.group(0)
+ return ""
+
+ def GxVTG(self, gps_data):
+ """Match Track Made Good and Ground Speed(VTG)
+
+ Args:
+ gps_data(str): GPS NMEA string.
+
+ Returns:
+ str: VTG NMEA string.
+ """
+ if gps_data:
+ vtg_re = ure.search(r"\$G[NP]VTG,\d*\.*\d*,*T,*\d*\.*\d*,*M,*\d*\.*\d*,*N,*\d*\.*\d*,*K,*[ADEN]*\*(\d|\w)*",
+ gps_data)
+ if vtg_re:
+ return vtg_re.group(0)
+ return ""
+
+ def GxGSV(self, gps_data):
+ """Mactch GPS Satellites in View(GSV)
+
+ Args:
+ gps_data(str): GPS NMEA string.
+
+ Returns:
+ str: GSV NMEA string.
+ """
+ if gps_data:
+ gsv_re = ure.search(
+ r"\$G[NP]GSV,\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*\**(\d|\w)*",
+ gps_data)
+ if gsv_re:
+ return gsv_re.group(0)
+ return ""
+
+ def GxGLL(self, gps_data):
+ """Geographic Position
+
+ Args:
+ gps_data(str): GPS NMEA string.
+
+ Returns:
+ str: GLL NMEA string.
+ """
+ if gps_data:
+ gll_re = ure.search(r"\$G[NP]GLL,\d*\.*\d*,*[NS]*,*\d*\.*\d*,*[EW]*,*\d*\.*\d*,*[AV]*,*[ADEN]*\**(\d|\w)*",
+ gps_data)
+ if gll_re:
+ return gll_re.group(0)
+
+ def GxGSA(self, gps_data):
+ """GNSS DOP and Active Satellites
+
+ Args:
+ gps_data(str): GPS NMEA string.
+
+ Returns:
+ str: GSA NMEA string.
+ """
+ if gps_data:
+ gsa_re = ure.search(
+ r"\$G[NP]GSA,[MA]*,*[123]*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*\.*\d*,*\d*\.*\d*,*\d*\.*\d*,*(\d|\w)*\**(\d|\w)*",
+ gps_data)
+ if gsa_re:
+ return gsa_re.group(0)
+
+
+class GPSParse(object):
+ """Parse details from gps data"""
+
+ def GxGGA_satellite_num(self, gga_data):
+ """Parse satellite num from GGA"""
+ if gga_data:
+ satellite_num_re = ure.search(r",[EW],[0126],\d+,", gga_data)
+ if satellite_num_re:
+ return satellite_num_re.group(0).split(",")[-2]
+ return ""
+
+ def GxGGA_latitude(self, gga_data):
+ """Parse latitude from GGA"""
+ if gga_data:
+ latitude_re = ure.search(r",[0-9]+\.[0-9]+,[NS],", gga_data)
+ if latitude_re:
+ latitude = latitude_re.group(0)[1:-3]
+ return str(float(latitude[:2]) + float(latitude[2:]) / 60)
+ return ""
+
+ def GxGGA_longitude(self, gga_data):
+ """Parse longitude from GGA"""
+ if gga_data:
+ longitude_re = ure.search(r",[0-9]+\.[0-9]+,[EW],", gga_data)
+ if longitude_re:
+ longitude = longitude_re.group(0)[1:-3]
+ return str(float(longitude[:3]) + float(longitude[3:]) / 60)
+ return ""
+
+ def GxGGA_altitude(self, gga_data):
+ """Parse altitude from GGA"""
+ if gga_data:
+ altitude_re = ure.search(r",-*[0-9]+\.[0-9]+,M,", gga_data)
+ if altitude_re:
+ return altitude_re.group(0)[1:-3]
+ return ""
+
+ def GxVTG_speed(self, vtg_data):
+ """Parse speed from VTG"""
+ if vtg_data:
+ speed_re = ure.search(r",N,\d+\.\d+,K,", vtg_data)
+ if speed_re:
+ return speed_re.group(0)[3:-3]
+ return ""
+
+ def GxGSV_satellite_num(self, gsv_data):
+ """Parse satellite num from GSV"""
+ if gsv_data:
+ satellite_num_re = ure.search(r"\$G[NP]GSV,\d+,\d+,\d+,", gsv_data)
+ if satellite_num_re:
+ return satellite_num_re.group(0).split(",")[-2]
+ return ""
+
+ def GxRMC_loc_status(self, rmc_data):
+ if rmc_data:
+ loc_status_re = ure.search(r"\$G[NP]RMC,\d*\.*\d*,[AV],", rmc_data)
+ if loc_status_re:
+ loc_status = loc_status_re.group(0).split(",")[-2]
+ return True if loc_status == "A" else False
+ return False
+
+ def __nmea_parse(self, nmea):
+ return tuple(nmea[1:].split("*")[0].split(",")) if nmea else ()
+
+ def GxRMC(self, rmc_data):
+ return self.__nmea_parse(rmc_data)
+
+ def GxGGA(self, gga_data):
+ return self.__nmea_parse(gga_data)
+
+ def GxGSV(self, gsv_data):
+ return self.__nmea_parse(gsv_data)
+
+ def GxGSA(self, gsa_data):
+ return self.__nmea_parse(gsa_data)
+
+ def GxVTG(self, vtg_data):
+ return self.__nmea_parse(vtg_data)
+
+ def GxGLL(self, gll_data):
+ return self.__nmea_parse(gll_data)
+
+
+class GPS(object):
+ """This class if for reading gps data.
+
+ Now support external gps and internal gps.
+
+ Sleep power consumption:
+ power off < backup < standby
+ """
+
+ __RMC = 0
+ __GGA = 1
+ __GSV = 2
+ __GSA = 3
+ __VTG = 4
+ __GLL = 5
+ __NMEA = 0b010111
+
+ def __init__(self, UARTn, buadrate, databits, parity, stopbits, flowctl, PowerPin, StandbyPin, BackupPin, gps_mode):
+ """Init GPS module
+
+ [description]
+
+ Args:
+ UARTn(int): UART No.
+ buadrate(int): baud rate
+ databits(int): data bits (5 ~ 8)
+ parity(int): parity (0 – NONE,1 – EVEN,2 - ODD)
+ stopbits(int): stop bit
+ flowctl(int): hardware control flow (0 – FC_NONE, 1 – FC_HW)
+ PowerPin(int): Power GIPO Pin
+ StandbyPin(int): Standby GPIO Pin
+ BackupPin(int): Back GPIO Pin
+ gps_mode(int): GPS mode
+ 0 - None
+ 1 - internal GPS
+ 2 - external GPS
+ """
+ self.__UARTn = UARTn
+ self.__buadrate = buadrate
+ self.__databits = databits
+ self.__parity = parity
+ self.__stopbits = stopbits
+ self.__flowctl = flowctl
+ self.__PowerPin = PowerPin
+ self.__StandbyPin = StandbyPin
+ self.__BackupPin = BackupPin
+ self.__gps_mode = gps_mode
+
+ self.__external_obj = None
+ self.__internal_obj = quecgnss
+ self.__gps_match = GPSMatch()
+ self.__gps_parse = GPSParse()
+ self.__gps_power_gpio = None
+ self.__gps_standby_gpio = None
+ self.__gps_backup_gpio = None
+
+ self.__external_retrieve_queue = None
+ self.__queue_size = 2
+ self.__first_break = 0
+ self.__break = 0
+ self.__gps_data = ""
+ self.__rmc_data = ""
+ self.__gga_data = ""
+ self.__vtg_data = ""
+ self.__gsv_data = ""
+ self.__gps_timer = osTimer()
+ self.__gps_data_check_timer = osTimer()
+
+ if self.__gps_mode & _gps_mode.external:
+ self.__external_init()
+ elif self.__gps_mode & _gps_mode.internal:
+ self.__internal_init()
+ #print("GPS:__init__%d",self.__gps_mode)
+ def __gps_power_control(self, GPIOn, onoff, method):
+ if method == "power_switch":
+ if self.__gps_power_gpio is None:
+ self.__gps_power_gpio = Pin(GPIOn, Pin.OUT, Pin.PULL_DISABLE, onoff)
+ gpio_obj = self.__gps_power_gpio
+ elif method == "standby":
+ if self.__gps_standby_gpio is None:
+ self.__gps_standby_gpio = Pin(GPIOn, Pin.OUT, Pin.PULL_DISABLE, onoff)
+ gpio_obj = self.__gps_standby_gpio
+ elif method == "backup":
+ if self.__gps_backup_gpio is None:
+ self.__gps_backup_gpio = Pin(GPIOn, Pin.OUT, Pin.PULL_DISABLE, onoff)
+ gpio_obj = self.__gps_backup_gpio
+ else:
+ raise TypeError("Param method %s is not compare." % method)
+
+ if gpio_obj.read() != onoff:
+ gpio_obj.write(onoff)
+ if gpio_obj.read() != onoff:
+ return False
+ return True
+
+ def __reverse_gps_data(self, this_gps_data):
+ """Reverse GPS data for regular match get the latest data"""
+ log.debug("this_gps_data: \n%s" % this_gps_data)
+ delimiter = "\r\n"
+ if this_gps_data:
+ _gps_data = self.__get_gps_data()
+ if _gps_data:
+ _gps_data = delimiter.join(_gps_data.split(delimiter)[::-1])
+ _gps_data += this_gps_data.strip().replace("\r", "").replace("\n", "").replace("$", delimiter + "$")
+ _gps_data = delimiter.join(_gps_data.split(delimiter)[::-1])
+ self.__set_gps_data(_gps_data)
+
+ def __read_latitude(self, gps_data):
+ """Read latitude from gps data"""
+ return self.__gps_parse.GxGGA_latitude(self.__gps_match.GxGGA(gps_data))
+
+ def __read_longitude(self, gps_data):
+ """Read longitude from gps data"""
+ return self.__gps_parse.GxGGA_longitude(self.__gps_match.GxGGA(gps_data))
+
+ def __read_altitude(self, gps_data):
+ """Read altitude from gps data"""
+ return self.__gps_parse.GxGGA_altitude(self.__gps_match.GxGGA(gps_data))
+
+ def __set_gps_data(self, gps_data):
+ self.__gps_data = gps_data
+
+ def __get_gps_data(self):
+ return self.__gps_data
+
+ def __gps_timer_callback(self, args):
+ """GPS read timer callback
+ When over time to get uart data, break queue wait
+ """
+ self.__break = 1
+ if self.__external_retrieve_queue is not None:
+ self.__external_retrieve_queue.put(False)
+
+ def __gps_data_check_callback(self, args):
+ """GPS read old data clean timer callback
+ When GPS read over time, clean old gps data, wait to read new gps data.
+ """
+ clean = False
+ if "" in (self.__rmc_data, self.__gga_data, self.__gsv_data):
+ clean = True
+ else:
+ if self.__nmea_statement_exist(self.__GSA) and not self.__gsa_data:
+ clean = True
+ elif self.__nmea_statement_exist(self.__VTG) and not self.__vtg_data:
+ clean = True
+ elif self.__nmea_statement_exist(self.__GLL) and not self.__gll_data:
+ clean = True
+
+ if clean:
+ self.__gps_nmea_data_clean()
+
+ def __external_init(self):
+ """External GPS init"""
+ self.__external_retrieve_queue = Queue(maxsize=self.__queue_size)
+
+ def __external_open(self):
+ """External GPS start, UART init"""
+ self.power_switch(1)
+ self.__external_obj = UART(
+ self.__UARTn,
+ self.__buadrate,
+ self.__databits,
+ self.__parity,
+ self.__stopbits,
+ self.__flowctl
+ )
+ self.__external_obj.set_callback(self.__external_retrieve_cb)
+
+ def __external_close(self):
+ """External GPS close, UART close, NOT GPS stop"""
+ self.__external_obj.close()
+
+ def __external_retrieve_cb(self, args):
+ """
+ GPS data retrieve callback from UART
+ When data comes, send a message to queue of data length
+ """
+ # log.debug("GPS __external_retrieve_cb args: %s" % str(args))
+ if self.__external_retrieve_queue.size() >= self.__queue_size:
+ self.__external_retrieve_queue.get()
+ self.__external_retrieve_queue.put(True)
+
+ def __internal_init(self):
+ """Internal GPS init"""
+ if self.__internal_obj:
+ if self.__internal_obj.init() != 0:
+ self.__internal_open()
+ log.error("GNSS INIT Failed.")
+ else:
+ log.debug("GNSS INIT Success.")
+ else:
+ log.error("Module quecgnss Import Error.")
+
+ def __internal_open(self):
+ """Internal GPS enable"""
+ if self.__internal_obj.get_state() == 0:
+ return True if self.__internal_obj.gnssEnable(1) == 0 else False
+ else:
+ return True
+
+ def __internal_close(self):
+ """Internal GPS close"""
+ return True if self.__internal_obj.gnssEnable(0) == 0 else False
+
+ def __nmea_statement_exist(self, nmea_item):
+ return (self.__NMEA & (0b1 << nmea_item)) >> nmea_item
+
+ def __gps_nmea_data_clean(self):
+ self.__set_gps_data("")
+ self.__rmc_data = ""
+ self.__gga_data = ""
+ self.__gsv_data = ""
+ self.__gsa_data = ""
+ self.__vtg_data = ""
+ self.__gll_data = ""
+
+ def __check_gps_valid(self, gps_data):
+ self.__reverse_gps_data(gps_data)
+
+ if not self.__rmc_data:
+ self.__rmc_data = self.__gps_match.GxRMC(self.__get_gps_data())
+ loc_status = self.__gps_parse.GxRMC_loc_status(self.__rmc_data)
+
+ if self.__rmc_data and loc_status:
+ if self.__nmea_statement_exist(self.__GGA) and not self.__gga_data:
+ self.__gga_data = self.__gps_match.GxGGA(self.__get_gps_data())
+ # if self.__nmea_statement_exist(self.__GSV) and not self.__gsv_data:
+ # self.__gsv_data = self.__gps_match.GxGSV(self.__get_gps_data())
+ # if self.__nmea_statement_exist(self.__GSA) and not self.__gsa_data:
+ # self.__gsa_data = self.__gps_match.GxGSA(self.__get_gps_data())
+ if self.__nmea_statement_exist(self.__VTG) and not self.__vtg_data:
+ self.__vtg_data = self.__gps_match.GxVTG(self.__get_gps_data())
+ # if self.__nmea_statement_exist(self.__GLL) and not self.__gll_data:
+ # self.__gll_data = self.__gps_match.GxGLL(self.__get_gps_data())
+
+ if self.__nmea_statement_exist(self.__GGA) and not self.__gga_data:
+ return False
+ # if self.__nmea_statement_exist(self.__GSV) and not self.__gsv_data:
+ # return False
+ # if self.__nmea_statement_exist(self.__GSA) and not self.__gsa_data:
+ # return False
+ # if self.__nmea_statement_exist(self.__VTG) and not self.__vtg_data:
+ # return False
+ # if self.__nmea_statement_exist(self.__GLL) and not self.__gll_data:
+ # return False
+ return True
+
+ return False
+
+ def __external_read(self):
+ """Read external GPS data
+
+ Return:
+ $GPTXT,01,01,02,ANTSTATUS=OPEN*2B
+ $GNRMC,073144.000,A,3149.330773,N,11706.946971,E,0.00,337.47,150422,,,D,V*07
+ $GNVTG,337.47,T,,M,0.00,N,0.00,K,D*22
+ $GNGGA,073144.000,3149.330773,N,11706.946971,E,2,19,0.66,85.161,M,-0.335,M,,*56
+ $GNGSA,A,3,01,195,06,03,21,194,19,17,30,14,,,0.94,0.66,0.66,1*02
+ $GNGSA,A,3,13,26,07,10,24,25,08,03,22,,,,0.94,0.66,0.66,4*03
+ $GPGSV,3,1,12,14,84,210,31,195,67,057,46,17,52,328,28,50,51,161,33,1*54
+ $GPGSV,3,2,12,194,49,157,33,03,48,090,37,19,36,305,32,06,34,242,32,1*58
+ $GPGSV,3,3,12,01,32,041,35,30,17,204,22,21,07,051,13,07,03,183,,1*6B
+ $BDGSV,5,1,18,07,86,063,30,10,75,322,30,08,60,211,34,03,52,192,33,1*71
+ $BDGSV,5,2,18,24,44,276,33,13,43,215,33,01,43,135,30,26,40,208,37,1*71
+ $BDGSV,5,3,18,02,38,230,,04,32,119,,22,26,135,30,19,25,076,,1*70
+ $BDGSV,5,4,18,05,17,251,,25,06,322,27,09,02,211,22,21,02,179,,1*78
+ $BDGSV,5,5,18,29,02,075,,20,01,035,,1*72
+ $GNGLL,3149.330773,N,11706.946971,E,073144.000,A,D*4E
+ """
+ self.__external_open()
+ log.debug("__external_read start")
+
+ while self.__break == 0:
+ self.__gps_timer.start(50, 0, self.__gps_timer_callback)
+ signal = self.__external_retrieve_queue.get()
+ log.debug("[first] signal: %s" % signal)
+ if signal:
+ to_read = self.__external_obj.any()
+ log.debug("[first] to_read: %s" % to_read)
+ if to_read > 0:
+ self.__set_gps_data(self.__external_obj.read(to_read).decode())
+ self.__gps_timer.stop()
+ self.__break = 0
+
+ self.__gps_nmea_data_clean()
+ self.__gps_data_check_timer.start(2000, 1, self.__gps_data_check_callback)
+ cycle = 0
+ while self.__break == 0:
+ self.__gps_timer.start(1500, 0, self.__gps_timer_callback)
+ signal = self.__external_retrieve_queue.get()
+ log.debug("[second] signal: %s" % signal)
+ if signal:
+ to_read = self.__external_obj.any()
+ log.debug("[second] to_read: %s" % to_read)
+ if to_read > 0:
+ if self.__check_gps_valid(self.__external_obj.read(to_read).decode()):
+ self.__break = 1
+
+ self.__gps_timer.stop()
+ cycle += 1
+ if cycle >= self.__retry:
+ self.__break = 1
+ if self.__break != 1:
+ utime.sleep(1)
+ self.__gps_data_check_timer.stop()
+ self.__break = 0
+
+ # To check GPS data is usable or not.
+ self.__gps_data_check_callback(None)
+ self.__external_close()
+ log.debug("__external_read data: %s" % self.__get_gps_data())
+ return self.__get_gps_data()
+
+ def __internal_read(self):
+ import EventMesh
+ log.debug("__internal_read start.")
+ """Read internal GPS data
+
+ Return:
+ $GPTXT,01,01,02,ANTSTATUS=OPEN*2B
+ $GNRMC,073144.000,A,3149.330773,N,11706.946971,E,0.00,337.47,150422,,,D,V*07
+ $GNVTG,337.47,T,,M,0.00,N,0.00,K,D*22
+ $GNGGA,073144.000,3149.330773,N,11706.946971,E,2,19,0.66,85.161,M,-0.335,M,,*56
+ $GNGSA,A,3,01,195,06,03,21,194,19,17,30,14,,,0.94,0.66,0.66,1*02
+ $GNGSA,A,3,13,26,07,10,24,25,08,03,22,,,,0.94,0.66,0.66,4*03
+ $GPGSV,3,1,12,14,84,210,31,195,67,057,46,17,52,328,28,50,51,161,33,1*54
+ $GPGSV,3,2,12,194,49,157,33,03,48,090,37,19,36,305,32,06,34,242,32,1*58
+ $GPGSV,3,3,12,01,32,041,35,30,17,204,22,21,07,051,13,07,03,183,,1*6B
+ $BDGSV,5,1,18,07,86,063,30,10,75,322,30,08,60,211,34,03,52,192,33,1*71
+ $BDGSV,5,2,18,24,44,276,33,13,43,215,33,01,43,135,30,26,40,208,37,1*71
+ $BDGSV,5,3,18,02,38,230,,04,32,119,,22,26,135,30,19,25,076,,1*70
+ $BDGSV,5,4,18,05,17,251,,25,06,322,27,09,02,211,22,21,02,179,,1*78
+ $BDGSV,5,5,18,29,02,075,,20,01,035,,1*72
+ $GNGLL,3149.330773,N,11706.946971,E,073144.000,A,D*4E
+ """
+
+ #self.__gps_nmea_data_clean()
+
+ cycle = 0
+ #while self.__break == 0:
+ gnss_data = quecgnss.read(1024*3)
+ #print("__internal_read")
+ #print(gnss_data)
+ if gnss_data and gnss_data[1]:
+ this_gps_data = gnss_data[1].decode() if len(gnss_data) > 1 and gnss_data[1] else ""
+ _gps_valid = self.__check_gps_valid(this_gps_data)
+ log.debug("_gps_valid: %s" % _gps_valid)
+
+ #print("_gps_valid:",_gps_valid)
+ #print(str(_gps_valid),self.__get_gps_data())
+ if _gps_valid == True :
+ #EventMesh.publish("time", [self.__get_gps_data(),"0",str(_gps_valid),"0"])
+ return self.__get_gps_data()
+ else :
+ EventMesh.publish("time", [self.__get_gps_data(),"0",str(_gps_valid),"0"])
+ return ""
+
+ def read(self, retry=30):
+ """For user to read gps data
+
+ Return: (res_code, gps_data)
+ res_code:
+ - 0: Success
+ - -1: Failed
+ gps_data:
+ $GPTXT,01,01,02,ANTSTATUS=OPEN*2B
+ $GNRMC,073144.000,A,3149.330773,N,11706.946971,E,0.00,337.47,150422,,,D,V*07
+ $GNVTG,337.47,T,,M,0.00,N,0.00,K,D*22
+ $GNGGA,073144.000,3149.330773,N,11706.946971,E,2,19,0.66,85.161,M,-0.335,M,,*56
+ $GNGSA,A,3,01,195,06,03,21,194,19,17,30,14,,,0.94,0.66,0.66,1*02
+ $GNGSA,A,3,13,26,07,10,24,25,08,03,22,,,,0.94,0.66,0.66,4*03
+ $GPGSV,3,1,12,14,84,210,31,195,67,057,46,17,52,328,28,50,51,161,33,1*54
+ $GPGSV,3,2,12,194,49,157,33,03,48,090,37,19,36,305,32,06,34,242,32,1*58
+ $GPGSV,3,3,12,01,32,041,35,30,17,204,22,21,07,051,13,07,03,183,,1*6B
+ $BDGSV,5,1,18,07,86,063,30,10,75,322,30,08,60,211,34,03,52,192,33,1*71
+ $BDGSV,5,2,18,24,44,276,33,13,43,215,33,01,43,135,30,26,40,208,37,1*71
+ $BDGSV,5,3,18,02,38,230,,04,32,119,,22,26,135,30,19,25,076,,1*70
+ $BDGSV,5,4,18,05,17,251,,25,06,322,27,09,02,211,22,21,02,179,,1*78
+ $BDGSV,5,5,18,29,02,075,,20,01,035,,1*72
+ $GNGLL,3149.330773,N,11706.946971,E,073144.000,A,D*4E
+ """
+ self.__retry = retry
+ gps_data = ""
+ if self.__gps_mode & _gps_mode.external:
+ gps_data = self.__external_read()
+ elif self.__gps_mode & _gps_mode.internal:
+ gps_data = self.__internal_read()
+
+ res = 0 if gps_data else -1
+ return (res, gps_data)
+
+ def read_coordinates(self, gps_data):
+ """Read positioning coordinates.
+
+ Params:
+ gps_data: read gps data.
+ map_coordinate_system: `WGS84` or GCJ02
+
+ Return:
+ (longitude, latitude, altitude)
+ """
+ latitude = self.__read_latitude(gps_data)
+ latitude = float(latitude) if latitude else latitude
+ longitude = self.__read_longitude(gps_data)
+ longitude = float(longitude) if longitude else longitude
+ altitude = self.__read_altitude(gps_data)
+ altitude = float(altitude) if altitude else altitude
+ return (longitude, latitude, altitude)
+
+ def power_switch(self, onoff):
+ """GPS module power switch
+
+ Params:
+ onoff: 0 -- off, 1 -- on
+ """
+ if self.__gps_mode & _gps_mode.external:
+ if self.__PowerPin is not None:
+ return self.__gps_power_control(self.__PowerPin, onoff, "power_switch")
+ else:
+ return False
+ elif self.__gps_mode & _gps_mode.internal:
+ # TODO: Interal GNSS power down will not be used this api.
+ if onoff == 0:
+ return self.__internal_close()
+ else:
+ return self.__internal_open()
+
+ def backup(self, onoff):
+ """GPS module low enery mode backup
+
+ Params:
+ onoff: 0 -- off, 1 -- on
+ """
+ if self.__BackupPin is not None:
+ return self.__gps_power_control(self.__BackupPin, onoff, "backup")
+ else:
+ return False
+
+ def standby(self, onoff):
+ """GPS module low enery mode standby
+
+ Params:
+ onoff: 0 -- off, 1 -- on
+ """
+ if self.__StandbyPin is not None:
+ return self.__gps_power_control(self.__StandbyPin, onoff, "standby")
+ else:
+ return False
+
+ def set_nmea_statement(self, nmea_statement):
+ """Set NMEA statement to check gps info valid
+
+ RMC, GGA, GSV must be required.
+
+ Args:
+ nmea_statement(int):
+ RMC - 0b1 << 0 (bit0), 0 - off, 1 - on
+ GGA - 0b1 << 1 (bit1), 0 - off, 1 - on
+ GSV - 0b1 << 2 (bit2), 0 - off, 1 - on
+ GSA - 0b1 << 3 (bit3), 0 - off, 1 - on
+ VTG - 0b1 << 4 (bit4), 0 - off, 1 - on
+ GLL - 0b1 << 5 (bit5), 0 - off, 1 - on
+
+ Returns:
+ bool: True - success, False - falied.
+ """
+ if nmea_statement >= 0b111:
+ self.__NMEA = nmea_statement
+ return True
+ return False
+
+
+class CellLocator(object):
+ """This class is for reading cell location data"""
+
+ def __init__(self, serverAddr, port, token, timeout, profileIdx):
+ self.__serverAddr = serverAddr
+ self.__port = port
+ self.__token = token
+ self.__timeout = timeout
+ self.__profileIdx = profileIdx
+
+ def read(self):
+ read_loc_res = self.__read_loc()
+ read_cell_res = self.__read_cell()
+ res = 0 if read_loc_res[0] == 0 or read_cell_res[0] == 0 else -1
+ return (res, read_loc_res[1], read_cell_res[1])
+
+ def __read_loc(self):
+ """Read cell location data.
+
+ Return: (res_code, loc_data)
+ res_code:
+ - 0: Success
+ - -1: Initialization failed
+ - -2: The server address is too long (more than 255 bytes)
+ - -3: Wrong key length, must be 16 bytes
+ - -4: The timeout period is out of range, the supported range is (1 ~ 300) s
+ - -5: The specified PDP network is not connected, please confirm whether the PDP is correct
+ - -6: Error getting coordinates
+ loc_data:
+ (117.1138, 31.82279, 550)
+ """
+ res = -1
+ loc_data = cellLocator.getLocation(
+ self.__serverAddr,
+ self.__port,
+ self.__token,
+ self.__timeout,
+ self.__profileIdx
+ )
+ if isinstance(loc_data, tuple) and len(loc_data) == 3:
+ res = 0
+ else:
+ res = loc_data
+ loc_data = ()
+
+ return (res, loc_data)
+
+ def __read_cell(self):
+ res = -1
+ near_cell = []
+ server_cell = []
+
+ near_cells = net.getCi()
+ if near_cells != -1 and isinstance(near_cells, list):
+ near_cell = list(map(str, near_cells))
+
+ server_cells = net.getCellInfo()
+ if server_cells != -1 and isinstance(server_cells, tuple):
+ server_cell = server_cells
+
+ res = 0 if near_cell or server_cell else -1
+ return (res, {"near_cell": near_cell, "server_cell": server_cell})
+
+
+class WiFiLocator(object):
+ """This class is for reading wifi location data"""
+
+ def __init__(self, token):
+ self.__wifilocator_obj = wifilocator(token)
+
+ def read(self):
+ read_loc_res = self.__read_loc()
+ read_mac_res = self.__read_mac()
+ res = 0 if read_loc_res[0] == 0 or read_mac_res[0] == 0 else -1
+ return (res, read_loc_res[1], read_mac_res[1])
+
+ def __read_loc(self):
+ """Read wifi location data.
+
+ Return: (res_code, loc_data)
+ res_code:
+ - 0: Success
+ - -1: The current network is abnormal, please confirm whether the dial-up is normal
+ - -2: Wrong key length, must be 16 bytes
+ - -3: Error getting coordinates
+ loc_data:
+ (117.1138, 31.82279, 550)
+ """
+ res = -1
+ loc_data = self.__wifilocator_obj.getwifilocator()
+ if isinstance(loc_data, tuple) and len(loc_data) == 3:
+ res = 0
+ else:
+ res = loc_data
+ loc_data = ()
+
+ return (res, loc_data)
+
+ def __read_mac(self):
+ res = -1
+ macs = []
+ if wifiScan.support():
+ if wifiScan.control(1) == 0:
+ if wifiScan.getState():
+ wifisacn_start = wifiScan.start()
+ if wifisacn_start != -1 and wifisacn_start[0] > 0:
+ macs = [i[0] for i in wifisacn_start[1]]
+ res = 0
+ wifiScan.control(0)
+ return (res, macs)
+
+
+class Location(object):
+ """This class is for reading location data from gps, cell, wifi"""
+ gps = None
+ cellLoc = None
+ wifiLoc = None
+
+ def __init__(self, loc_method, locator_init_params):
+ """Init Location module
+
+ 1. If loc_method include gps then init gps module;
+ 2. If loc_method inculde cell then init cell module;
+ 3. If loc_method Include wifi then init wifi module;
+
+ Args:
+ loc_method(int):
+ 1 - gps
+ 2 - cell
+ 3 - cell & gps
+ 4 - wifi
+ 5 - wifi & gps
+ 6 - wifi & cell
+ 7 - wifi & cell & gps
+ locator_init_params(dict):
+ gps_cfg(dict):GPS module init args
+ cell_cfg(dict):CELL module init args
+ wifi_cfg(dict):WIFI module init args
+ """
+ self.__loc_method = loc_method
+ self.__locator_init_params = locator_init_params
+ self.__locater_init()
+
+ def __locater_init(self):
+ """Init gps, cell, wifi by loc_method"""
+
+ if self.__loc_method & _loc_method.gps:
+ if self.gps is None:
+ _gps_cfg = self.__locator_init_params.get("gps_cfg", {})
+ if _gps_cfg:
+ self.gps = GPS(**_gps_cfg)
+ if _gps_cfg.get("nmea_cfg") is not None:
+ self.gps.set_nmea_statement(_gps_cfg.get("nmea_cfg"))
+ else:
+ raise ValueError("Invalid gps init parameters.")
+ else:
+ self.gps = None
+
+ if self.__loc_method & _loc_method.cell:
+ if self.cellLoc is None:
+ _cell_cfg = self.__locator_init_params.get("cell_cfg")
+ if _cell_cfg:
+ self.cellLoc = CellLocator(**_cell_cfg)
+ else:
+ raise ValueError("Invalid cell-locator init parameters.")
+ else:
+ self.cellLoc = None
+
+ if self.__loc_method & _loc_method.wifi:
+ if self.wifiLoc is None:
+ _wifi_cfg = self.__locator_init_params.get("wifi_cfg")
+ if _wifi_cfg:
+ self.wifiLoc = WiFiLocator(**_wifi_cfg)
+ else:
+ raise ValueError("Invalid wifi-locator init parameters.")
+ else:
+ self.wifiLoc = None
+
+ def __read_gps(self, retry):
+ """Read loction data from gps module
+
+ Return:
+ $GPTXT,01,01,02,ANTSTATUS=OPEN*2B
+ $GNRMC,073144.000,A,3149.330773,N,11706.946971,E,0.00,337.47,150422,,,D,V*07
+ $GNVTG,337.47,T,,M,0.00,N,0.00,K,D*22
+ $GNGGA,073144.000,3149.330773,N,11706.946971,E,2,19,0.66,85.161,M,-0.335,M,,*56
+ $GNGSA,A,3,01,195,06,03,21,194,19,17,30,14,,,0.94,0.66,0.66,1*02
+ $GNGSA,A,3,13,26,07,10,24,25,08,03,22,,,,0.94,0.66,0.66,4*03
+ $GPGSV,3,1,12,14,84,210,31,195,67,057,46,17,52,328,28,50,51,161,33,1*54
+ $GPGSV,3,2,12,194,49,157,33,03,48,090,37,19,36,305,32,06,34,242,32,1*58
+ $GPGSV,3,3,12,01,32,041,35,30,17,204,22,21,07,051,13,07,03,183,,1*6B
+ $BDGSV,5,1,18,07,86,063,30,10,75,322,30,08,60,211,34,03,52,192,33,1*71
+ $BDGSV,5,2,18,24,44,276,33,13,43,215,33,01,43,135,30,26,40,208,37,1*71
+ $BDGSV,5,3,18,02,38,230,,04,32,119,,22,26,135,30,19,25,076,,1*70
+ $BDGSV,5,4,18,05,17,251,,25,06,322,27,09,02,211,22,21,02,179,,1*78
+ $BDGSV,5,5,18,29,02,075,,20,01,035,,1*72
+ $GNGLL,3149.330773,N,11706.946971,E,073144.000,A,D*4E
+ """
+ if self.gps:
+ return self.gps.read(retry)[1]
+ return ""
+
+ def __read_cell(self):
+ """Read loction data from cell module
+
+ Return:
+ (117.1138, 31.82279, 550) or ()
+ """
+ if self.cellLoc:
+ cell_loc_data = self.cellLoc.read()
+ return (cell_loc_data[1], cell_loc_data[2])
+ return ()
+
+ def __read_wifi(self):
+ """Read loction data from wifi module
+
+ Return:
+ (117.1138, 31.82279, 550) or ()
+ """
+ if self.wifiLoc:
+ wifi_loc_data = self.wifiLoc.read()
+ return (wifi_loc_data[1], wifi_loc_data[2])
+ return ()
+
+ def read(self, retry=30):
+ """Read location data
+
+ args:
+ retry(int): gps read uart data retry count.
+
+ Returns:
+ dict:
+ key:
+ 1 - GPS data
+ 2 - CELL data
+ 4 - WIFI data
+ .e.g:
+ {
+ 1: "$GPGGA,XXX",
+ 2: (0.00, 0.00, 0.00),
+ 4: (0.00, 0.00, 0.00),
+ }
+ """
+ loc_data = {}
+
+ if self.__loc_method & _loc_method.gps:
+ loc_data[_loc_method.gps] = self.__read_gps(retry)
+
+ if self.__loc_method & _loc_method.cell:
+ loc_data[_loc_method.cell] = self.__read_cell()
+
+ if self.__loc_method & _loc_method.wifi:
+ loc_data[_loc_method.wifi] = self.__read_wifi()
+
+ return loc_data
+
+ def wgs84togcj02(self, Longitude, Latitude):
+ return WGS84ToGCJ02(Longitude, Latitude)
+
+
+if __name__ == '__main__':
+ _gps_cfg = {
+ "UARTn": UART.UART1,
+ "buadrate": 115200,
+ "databits": 8,
+ "parity": 0,
+ "stopbits": 1,
+ "flowctl": 0,
+ "PowerPin": Pin.GPIO2,
+ "StandbyPin": Pin.GPIO3,
+ "BackupPin": None,
+ "gps_mode": 0x01,
+ }
+ gps = GPS(**_gps_cfg)
+ print("read {}".format(gps.read(300)))
--- /dev/null
+import main_init
+main_init.main_init()
\ No newline at end of file
--- /dev/null
+import main_init
+main_init.main_init()
\ No newline at end of file
--- /dev/null
+import sms
+import atcmd
+import net
+import machine
+import EventMesh
+import usys
+
+
+resp=bytearray(50)
+# atcmd.sendSync('AT+log=52,1\r\n',resp,'',200)
+# EventMesh.debug_log("AT+log=52,1:{}".format(resp))
+from common import Abstract
+class App(object):
+ def __init__(self):
+ self.managers = []
+
+ def append_manager(self, manager):
+ try:
+ if isinstance(manager, Abstract):
+ manager.post_processor_after_instantiation()
+ self.managers.append(manager)
+ except Exception as e:
+ usys.print_exception(e)
+ return self
+
+ def start(self):
+ try:
+ for manager in self.managers:
+ manager.post_processor_before_initialization()
+ manager.initialization()
+ manager.post_processor_after_initialization()
+ except Exception as e:
+ usys.print_exception(e)
+
+class watchApp(App):
+ def __init__(self):
+ super(watchApp, self).__init__()
+ self.__ui = None
+
+ def set_ui(self, ui):
+ self.__ui = ui
+
+ def start(self):
+ if self.__ui is not None:
+ self.__ui.start()
+ super().start()
+
+
+#开机执行下面函数就可以配置成ipv4拨号
+import dataCall
+import net
+
+def set_ipv4_datacall():
+ # 获取第一路的APN,ipType 等信息
+ pdpCtx = dataCall.getPDPContext(1)
+ if pdpCtx != -1:
+ if pdpCtx[0] != 0:
+ # 如果不是用户需要的ipv4,使用如下方式配置,使用如下方式配置
+ ret = dataCall.setPDPContext(1, 0,pdpCtx[1],pdpCtx[2],pdpCtx[3],pdpCtx[4])
+ if ret == 0:
+ print('配置成功。')
+ # cfun0/1后按照配置的信息进行拨号
+ net.setModemFun(0)
+ net.setModemFun(1)
+ else:
+ print('配置失败。')
+ else:
+ print('已经配置为IPv4')
+ else:
+ print('获取PDP Context失败。')
+def main_init():
+# if __name__ == '__main__':
+ #set_ipv4_datacall()
+ import uos
+ import ql_fs
+ import utime
+ import EventMesh
+
+ if ql_fs.path_exists("/ext") == False:
+ ldev = uos.VfsLfs1(32, 32, 32, "ext_fs",0,3)
+ uos.mount(ldev,'/ext')
+ res = uos.statvfs("/ext")
+ res = list(res)
+ print('总ext空间:{} MB,剩余空间:{} MB'.format((((res[0] * res[2]) / 1024 / 1024)),((res[0] * res[3]) / 1024 / 1024)))
+ #print("init1:{}".format(utime.localtime()))
+ res = uos.statvfs("/usr")
+ res = list(res)
+ EventMesh.debug_log('总usr空间:{} MB,剩余空间:{} MB'.format((((res[0] * res[2]) / 1024 / 1024)),((res[0] * res[3]) / 1024 / 1024)))
+ EventMesh.debug_log("init1:{}".format(utime.localtime()))
+
+ import EventMesh
+ EventMesh.txt_log("power on............\n")
+ #print("init2:{}".format(utime.localtime()))
+ #from lcd import tp_cst816
+ #print("init3:{}".format(utime.localtime()))
+
+ from ui_main_menu import MainMenuScreen
+ # from ui_WatchFaceScreen import WatchFaceScreen
+
+ #from appFactoryMode import FactoryModestepScreen, FactoryModeLocationScreen,FactoryModeScreen ,FactoryModeBatTestScreen,FactoryModeHsensorTestScreen,FactoryModeLogScreen
+
+ # from mgr import setCallStateManager,setclassTimeManager,setSmsIndexManager,ConfigStoreManager,testSmsSetIPManager,playPowerAudioManager,sosInfoCallManager,getBootOffManager,getSosFlagManager,CountdownManager, LocationManager, getVolumSizeManager,gethistoryDataManager,getUpLoadDataManager, getplayAudiodStateManager,\
+ # AddrBookManager,MsgdetailManager,PhoneCallingManager,getOldTimeManager,getStorageDataManager,getBrightnessManager,getHrTimeManager,getTempTimeManager,getLowBatManager
+
+ from ui_health import HealthScreen
+ import ui as _ui
+
+
+ # import ui as _ui
+ EventMesh.debug_log("init4:{}".format(utime.localtime()))
+ ui = _ui.UI()
+ ui.post_processor_after_instantiation()
+
+
+
+
+ app = watchApp()
+ app.set_ui(ui)
+ # if EventMesh.model == "D15":
+ # from motor import motorEventManager
+ # app.append_manager(motorEventManager())
+ # try:
+ # app.append_manager(getStorageDataManager())
+ # except Exception as e:
+ # usys.print_exception(e)
+ try:
+ ui.add_screen(_ui.SystemInitScreen())
+ EventMesh.publish("load_screen", {"screen": "system_init"})
+ except Exception as e:
+ usys.print_exception(e)
+ try:
+ ui.add_screen(MainMenuScreen())
+ ui.add_screen(_ui.PopupScreen())
+ ui.add_screen(_ui.PhoneScreen())
+ ui.add_screen(_ui.HeartrateScreen())
+
+ ui.add_screen(_ui.PowerOnScreen())
+ except Exception as e:
+ usys.print_exception(e)
+
+ try:
+ try:
+ import usr.ai_VC_t as _ai
+ except Exception as e:
+ usys.print_exception(e)
+
+ try:
+ import usr.ai_VC as _ai
+ except Exception as e:
+ usys.print_exception(e)
+
+ try:
+ import usr.ai_VC_7PIN as _ai
+ except Exception as e:
+ usys.print_exception(e)
+ try:
+ import usr.ai_VC_G15 as _ai
+ except Exception as e:
+ usys.print_exception(e)
+ try:
+ import ai_VC as _ai
+ except Exception as e:
+ usys.print_exception(e)
+
+ #app.append_manager(intervManager())
+ try:
+ app.append_manager(_ai.getStorageDataManager())
+ except Exception as e:
+ usys.print_exception(e)
+ try:
+ app.append_manager(_ai.AI_led())
+ except Exception as e:
+ usys.print_exception(e)
+ try:
+ app.append_manager(_ai.AI_dev())
+ except Exception as e:
+ usys.print_exception(e)
+
+ try:
+ app.append_manager(_ai.device_res_author())
+ except Exception as e:
+ usys.print_exception(e)
+
+ try:
+
+ app.append_manager(_ai.AI_VC())
+ except Exception as e:
+ usys.print_exception(e)
+
+ except Exception as e:
+ usys.print_exception(e)
+ EventMesh.publish("load_screen", {"screen": "poweron"})#开机画面
+ EventMesh.debug_log("init21:{}".format(utime.localtime()))
+
+ EventMesh.debug_log("init11:{}".format(utime.localtime()))
+
+ #EventMesh.publish("open_power_on", 1)#
+ # pcr = protocol.ProtoColResolver()
+ # pcr.add_support(protocol.LK_ProtoCol())
+ # pcr.add_support(protocol.PING_ProtoCol())
+ # pcr.add_support(protocol.KA_ProtoCol())
+ # pcr.add_support(protocol.UD_ProtoCol())
+ # pcr.add_support(protocol.CR_ProtoCol())
+ # pcr.add_support(protocol.AL_ProtoCol())
+ # pcr.add_support(protocol.FIND_ProtoCol())
+ # pcr.add_support(protocol.POWEROFF_ProtoCol())
+ # pcr.add_support(protocol.PHL_ProtoCol())
+ # pcr.add_support(protocol.TK_ProtoCol())
+ # pcr.add_support(protocol.TKS_ProtoCol())
+ # pcr.add_support(protocol.MESSAGE_ProtoCol())
+ # pcr.add_support(protocol.WT_ProtoCol())
+ # pcr.add_support(protocol.REMIND_ProtoCol())
+ # pcr.add_support(protocol.HRSTART_ProtoCol())
+ # pcr.add_support(protocol.HEART_ProtoCol())
+ # pcr.add_support(protocol.OXYGEN_ProtoCol())
+ # pcr.add_support(protocol.OXYGEN_One_ProtoCol())
+ # pcr.add_support(protocol.TEMP_ProtoCol())
+ # pcr.add_support(protocol.DLT_ProtoCol())
+ # pcr.add_support(protocol.UPLOAD_ProtoCol())
+ # pcr.add_support(protocol.MONITOR_ProtoCol())
+ # # pcr.add_support(protocol.CENTER_ProtoCol())
+ # pcr.add_support(protocol.CENTER_ProtoCol())
+ # pcr.add_support(protocol.bootoff_ProtoCol())
+ # pcr.add_support(protocol.WDSTART_ProtoCol())
+ # pcr.add_support(protocol.LOWBAT_ProtoCol())
+ # pcr.add_support(protocol.sosHome_dial_ProtoCol())
+ # pcr.add_support(protocol.Time_ProtoCol())
+ # pcr.add_support(protocol.SILENCETIME2_ProtoCol())
+ # pcr.add_support(protocol.FALLDOWN_ProtoCol())
+ # pcr.add_support(protocol.HELP_ProtoCol())
+ # pcr.add_support(protocol.REMOVE_ProtoCol())
+ # pcr.add_support(protocol.UD_ProtoCol())
+ # pcr.add_support(protocol.bldstart_ProtoCol())
+ # pcr.add_support(protocol.blood_ProtoCol())
+ # pcr.add_support(protocol.bgstart_ProtoCol())
+ # pcr.add_support(protocol.bloodglucose_ProtoCol())
+ # pcr.add_support(protocol.REMIND_CHDRINK_ProtoCol())
+ # pcr.add_support(protocol.REMIND_CHMEDICINE2_ProtoCol())
+ # pcr.add_support(protocol.WLKEY_ProtoCol())
+ # pcr.add_support(protocol.REMIND_CH_WAKEUP_ProtoCol())
+ # pcr.add_support(protocol.REMIND_CH_SLEEP_ProtoCol())
+ # pcr.add_support(protocol.REMIND_CH_HOME_ProtoCol())
+ # pcr.add_support(protocol.REMIND_CH_REST_ProtoCol())
+ # pcr.add_support(protocol.SLEEP_DATA_ProtoCol())
+ # pcr.add_support(protocol.SLEEPTIME_ProtoCol())
+ # pcr.add_support(protocol.FACTORY_ProtoCol())
+ # pcr.add_support(protocol.RESET_ProtoCol())
+ # pcr.add_support(protocol.REMIND_CH_SIT_ProtoCol())
+ # pcr.add_support(protocol.SCREEN_SHOWProtoCol())
+
+
+
+
+
+ # sm = protocol.SockManager()
+ # sm.add_support_resolver(pcr)
+ # app.append_manager(sm)
+ EventMesh.debug_log("init11.0:{}".format(utime.localtime()))
+ app.start()
+
+ sms_data = sms.getSaveLoc()
+ if(sms_data != -1):
+ sms_lacv = sms_data[0][0]
+ if sms_lacv != 'SM':#每次开机设置一下短信的存储位置
+ sms.setSaveLoc('SM', 'SM', 'SM')
+ EventMesh.debug_log("init12:{}".format(utime.localtime()))
+ # timer_t = net.nitzTime()
+ # EventMesh.debug_log("timer_t:{}".format(timer_t))
+ # if(timer_t != -1):
+ # timeSecond = int(timer_t[1])
+ # if timeSecond != 0:
+ # next_alarm_time = utime.localtime(timeSecond)
+ # machine.RTC().datetime((next_alarm_time[0],next_alarm_time[1],next_alarm_time[2],next_alarm_time[6],next_alarm_time[3],next_alarm_time[4],next_alarm_time[5],0))
+
+
+
+ # EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
--- /dev/null
+from common import Abstract, LogAdapter
+import EventMesh
+import usocket
+import ql_fs
+import ujson
+import _thread
+import modem
+import utime
+import sim
+import net
+import dataCall
+import checkNet
+import osTimer
+import constants
+import sms
+import urandom
+from common import Lock, Abstract, LogAdapter
+#from location import GPS, GPSMatch,CellLocator
+from misc import USB, Power, ADC
+from machine import ExtInt, Pin,Timer,RTC,UART
+import EventMesh
+import usys
+import audio
+from machine import I2C
+from Gsensor import SC7A20
+import pm
+import ure
+try :
+ from Hsensor import GH3018
+except Exception as e:
+ print("Hsensor none GH3018:{}".format(e))
+#
+try :
+ from Hsensor import HX3918
+except Exception as e:
+ print("Hsensor none HX3918:{}".format(e))
+from machine import RTC
+import quecgnss
+import wifiScan
+import math
+import voiceCall
+from misc import PWM
+from queue import Queue
+class PhoneVolumeLevelManager(Abstract):
+ def __init__(self):
+ self.level = 0
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("push_add_phonering_level", self.add)
+ EventMesh.subscribe("push_reduce_phonering_level", self.reduce)
+ EventMesh.subscribe("get_phonering_level", self.get)
+
+ def add(self, event, msg):
+ if self.level < 7:
+ self.level = self.level + 1
+
+ def reduce(self, event, msg):
+ if self.level > 0:
+ self.level = self.level - 1
+
+ def get(self, event=None, msg=None):
+ return self.level
+
+class MsgVolumeLevelManager(Abstract):
+ def __init__(self):
+ self.level = 0
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("push_add_msgvolume_level", self.add)
+ EventMesh.subscribe("push_reduce_msgvolume_level", self.reduce)
+ EventMesh.subscribe("get_msgvolume_level", self.get)
+
+ def add(self, event, msg):
+ if self.level < 7:
+ self.level = self.level + 1
+
+ def reduce(self, event, msg):
+ if self.level > 0:
+ self.level = self.level - 1
+
+ def get(self, event=None, msg=None):
+ return self.level
+
+class AlarmVolumeLevelManager(Abstract):
+ def __init__(self):
+ self.level = 0
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("push_add_alarmvolume_level", self.add)
+ EventMesh.subscribe("push_reduce_alarmvolume_level", self.reduce)
+ EventMesh.subscribe("get_alarmvolume_level", self.get)
+
+ def add(self, event, msg):
+ if self.level < 7:
+ self.level = self.level + 1
+
+ def reduce(self, event, msg):
+ if self.level > 0:
+ self.level = self.level - 1
+
+ def get(self, event=None, msg=None):
+ return self.level
+
+class StopwatchManager(Abstract):
+ def __init__(self):
+ self.level = 0
+ self.ms_value = 0
+ self.sec_value = 0
+ self.min_value = 0
+ self.timer = Timer(Timer.Timer1)
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("stopwatch_start", self.start)
+ EventMesh.subscribe("stopwatch_stop", self.paused)
+ EventMesh.subscribe("stopwatch_reset", self.reset)
+ EventMesh.subscribe("get_stopwatch_ms", self.get_ms)
+ EventMesh.subscribe("get_stopwatch_sec", self.get_sec)
+ EventMesh.subscribe("get_stopwatch_min", self.get_min)
+
+ def start(self, event, msg):
+ self.timer.start(period=100, mode=self.timer.PERIODIC, callback=self.fun)
+
+ def paused(self, event, msg):
+ self.timer.stop()
+
+ def reset(self, event, msg):
+ self.timer.stop()
+ self.sec_value = 0
+ self.min_value = 0
+ self.ms_value = 0
+
+ def fun(self):
+ self.ms_value += 1
+ if self.ms_value > 9:
+ self.ms_value = 0
+ self.sec_value += 1
+ if self.sec_value > 60:
+ self.sec_value = 0
+ self.min_value += 1
+ if self.min_value > 60:
+ self.timer.stop()
+
+ def get_ms(self, event=None, msg=None):
+ return self.ms_value
+
+ def get_min(self, event=None, msg=None):
+ return self.min_value
+
+ def get_sec(self, event=None, msg=None):
+ return self.sec_value
+
+class CountdownManager(Abstract):
+ def __init__(self):
+ self.sec = 0
+ self.min = 0
+ self.hour = 0
+ self.timer = osTimer()
+ self.total = 0
+ self.time_cb = 0
+ self.time_play = 0
+ self.total_sec = 0
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("add_countdown_sec", self.add_sec)
+ EventMesh.subscribe("reduce_countdown_sec", self.reduce_sec)
+ EventMesh.subscribe("add_countdown_min", self.add_min)
+ EventMesh.subscribe("reduce_countdown_min", self.reduce_min)
+ EventMesh.subscribe("add_countdown_hour", self.add_hour)
+ EventMesh.subscribe("reduce_countdown_hour", self.reduce_hour)
+ EventMesh.subscribe("get_countdown_sec", self.get_sec)
+ EventMesh.subscribe("get_countdown_min", self.get_min)
+ EventMesh.subscribe("get_countdown_hour", self.get_hour)
+
+ EventMesh.subscribe("set_countdown_off_state", self.set_countdown_off_state)
+ EventMesh.subscribe("get_countdown_off_state", self.get_countdown_off_state)
+
+
+ EventMesh.subscribe("set_countdown_all_time", self.set_countdown_all_time)
+ EventMesh.subscribe("get_countdown_all_time", self.get_countdown_all_time)
+
+ EventMesh.subscribe("countdown_end_cb", self.countdown_end_cb)
+
+ EventMesh.subscribe("reset_time_countdown",self.reset)
+
+ def set_countdown_all_time(self, event, msg):
+ self.total = msg[0]
+ self.total_sec = msg[1]
+ # print("self.total:{} self.total_sec:{}".format(self.total,self.total_sec))
+
+
+ def get_countdown_all_time(self, event, msg):
+ return self.total
+
+ def set_countdown_off_state(self, event, msg):
+
+ self.time_cb = msg[0]
+ self.time_play = msg[1]
+ # print("self.time_cb:{} self.total_sec:{}".format(self.time_cb,self.time_play))
+
+
+ def get_countdown_off_state(self, event, msg):
+ return [self.time_cb,self.time_play]
+
+ def countdown_end_cb(self, event, msg):
+
+ if self.time_cb == 1 and self.time_play == 1:
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ reduce = time_tmp- self.total_sec
+ print("self.time_cb:{} self.time_play:{} self.total:{} self.total_sec:{}".format(self.time_cb,self.time_play, self.total,self.total_sec))
+ self.total = self.total - reduce
+ if self.total <= 0:
+ self.total = 0
+ self.time_cb = 0
+ self.time_play = 0
+ self.sec = 0
+ self.min = 0
+ self.hour = 0
+
+ EventMesh.publish("load_screen", {"screen": "countdown_end"})
+ return
+ self.total_sec = time_tmp
+
+
+ def add_sec(self, event, msg):
+ if self.sec < 59:
+ self.sec = self.sec + 1
+
+ def reduce_sec(self, event, msg):
+ if self.sec > 0:
+ self.sec = self.sec - 1
+
+ def add_min(self, event, msg):
+ if self.min < 59:
+ self.min = self.min + 1
+
+ def reduce_min(self, event, msg):
+ if self.min > 0:
+ self.min = self.min - 1
+
+ def add_hour(self, event, msg):
+ if self.hour < 99:
+ self.hour = self.hour + 1
+
+ def reduce_hour(self, event, msg):
+ if self.hour > 0:
+ self.hour = self.hour - 1
+
+ def get_sec(self, event=None, msg=None):
+ return self.sec
+
+ def get_min(self, event=None, msg=None):
+ return self.min
+
+ def get_hour(self, event=None, msg=None):
+ return self.hour
+
+
+
+ def reset(self, event=None, msg=None):
+ self.hour = 0
+ self.min = 0
+ self.sec = 0
+
+
+
+BATTERY_OCV_TABLE = {
+ "nix_coy_mnzo2": {
+ 55: {
+ 4270: 100, 4237: 95, 4179: 90, 4123: 85, 4070: 80, 4020: 75, 3963: 70, 3919: 65, 3882: 60, 3847: 55,
+ 3818: 50, 3794: 45, 3772: 40, 3752: 35, 3733: 30, 3716: 25, 3699: 20, 3677: 15, 3652: 10, 3629: 5, 3355: 0,
+ },
+ 20: {
+ 4270: 100, 4237: 95, 4179: 90, 4123: 85, 4070: 80, 4020: 75, 3963: 70, 3919: 65, 3882: 60, 3847: 55,
+ 3818: 50, 3794: 45, 3772: 40, 3752: 35, 3733: 30, 3716: 25, 3699: 20, 3677: 15, 3652: 10, 3629: 5, 3355: 0,
+ },
+ 0: {
+ 4270: 100, 4237: 95, 4179: 90, 4123: 85, 4070: 80, 4020: 75, 3963: 70, 3919: 65, 3882: 60, 3847: 55,
+ 3818: 50, 3794: 45, 3772: 40, 3752: 35, 3733: 30, 3716: 25, 3699: 20, 3677: 15, 3652: 10, 3629: 5, 3355: 0,
+ },
+ },
+}
+
+
+
+class Battery(object):
+ """This class is for battery info.
+
+ This class can get battery voltage and energy.
+ if adc_args is not None, use cbc to read battery
+
+ adc_args: (adc_num, adc_period, factor)
+
+ adc_num: ADC channel num
+ adc_period: Cyclic read ADC cycle period
+ factor: calculation coefficient
+ """
+
+ def __init__(self, adc_args=None, chrg_gpion=None, stdby_gpion=None):
+ self.__energy = 100
+ self.__temp = 55
+
+ # ADC params
+ self.__adc = None
+ if adc_args:
+ self.__adc_num, self.__adc_period, self.__factor = adc_args
+ if not isinstance(self.__adc_num, int):
+ raise TypeError("adc_args adc_num is not int number.")
+ if not isinstance(self.__adc_period, int):
+ raise TypeError("adc_args adc_period is not int number.")
+ if not isinstance(self.__factor, float):
+ raise TypeError("adc_args factor is not int float.")
+ self.__adc = ADC()
+
+ # Charge params
+ self.__charge_callback = None
+ self.__charge_status = None
+ self.__chrg_gpion = chrg_gpion
+ self.__stdby_gpion = stdby_gpion
+ self.__chrg_gpio = None
+ self.__stdby_gpio = None
+ self.__chrg_exint = None
+ self.__stdby_exint = None
+ if self.__chrg_gpion is not None and self.__stdby_gpion is not None:
+ self.__init_charge()
+
+ def __chrg_callback(self, args):
+ self.__update_charge_status()
+ if self.__charge_callback is not None:
+ self.__charge_callback(self.__charge_status)
+
+ def __stdby_callback(self, args):
+ self.__update_charge_status()
+ if self.__charge_callback is not None:
+ self.__charge_callback(self.__charge_status)
+
+ def __update_charge_status(self):
+ if self.__chrg_gpio.read() == 1 and self.__stdby_gpio.read() == 1:
+ self.__charge_status = 0
+ elif self.__chrg_gpio.read() == 0 and self.__stdby_gpio.read() == 1:
+ self.__charge_status = 1
+ elif self.__chrg_gpio.read() == 1 and self.__stdby_gpio.read() == 0:
+ self.__charge_status = 2
+ else:
+ raise TypeError("CHRG and STDBY cannot be 0 at the same time!")
+
+ def __init_charge(self):
+ self.__chrg_gpio = Pin(self.__chrg_gpion, Pin.IN, Pin.PULL_DISABLE)
+ self.__stdby_gpio = Pin(self.__stdby_gpion, Pin.IN, Pin.PULL_DISABLE)
+ self.__chrg_exint = ExtInt(self.__chrg_gpion, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.__chrg_callback)
+ self.__stdby_exint = ExtInt(self.__stdby_gpion, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU,
+ self.__stdby_callback)
+ self.__chrg_exint.enable()
+ self.__stdby_exint.enable()
+ self.__update_charge_status()
+
+ def __get_soc_from_dict(self, key, volt_arg):
+ """Get battery energy from map"""
+ if key in BATTERY_OCV_TABLE["nix_coy_mnzo2"]:
+ volts = sorted(BATTERY_OCV_TABLE["nix_coy_mnzo2"][key].keys(), reverse=True)
+ pre_volt = 0
+ volt_not_under = 0 # Determine whether the voltage is lower than the minimum voltage value of soc.
+ for volt in volts:
+ if volt_arg > volt:
+ volt_not_under = 1
+ soc1 = BATTERY_OCV_TABLE["nix_coy_mnzo2"][key].get(volt, 0)
+ soc2 = BATTERY_OCV_TABLE["nix_coy_mnzo2"][key].get(pre_volt, 0)
+ break
+ else:
+ pre_volt = volt
+ # print("__get_soc_from_dict:{}".format(soc2 - (soc2 - soc1) * (pre_volt - volt_arg) // (pre_volt - volt)))
+ if pre_volt == 0: # Input Voltarg > Highest Voltarg
+ return soc1
+ elif volt_not_under == 0:
+ return 0
+ else:
+ return soc2 - (soc2 - soc1) * (pre_volt - volt_arg) // (pre_volt - volt)
+
+ def __get_soc(self, temp, volt_arg, bat_type="nix_coy_mnzo2"):
+ """Get battery energy by temperature and voltage"""
+ if bat_type == "nix_coy_mnzo2":
+ if temp > 30:
+ return self.__get_soc_from_dict(55, volt_arg)
+ elif temp < 10:
+ return self.__get_soc_from_dict(0, volt_arg)
+ else:
+ return self.__get_soc_from_dict(20, volt_arg)
+
+ def __get_power_vbatt(self):
+ return int(sum([Power.getVbatt() for i in range(100)]) / 100)
+
+ def __get_adc_vbatt(self):
+ self.__adc.open()
+ utime.sleep_ms(self.__adc_period)
+ adc_list = list()
+ for i in range(self.__adc_period):
+ adc_list.append(self.__adc.read(self.__adc_num))
+ utime.sleep_ms(self.__adc_period)
+ adc_list.remove(min(adc_list))
+ adc_list.remove(max(adc_list))
+ adc_value = int(sum(adc_list) / len(adc_list))
+ self.__adc.close()
+ vbatt_value = adc_value * (self.__factor + 1)
+ return vbatt_value
+
+ def set_temp(self, temp):
+ """Set now temperature."""
+ if isinstance(temp, int) or isinstance(temp, float):
+ self.__temp = temp
+ return True
+ return False
+
+ def get_voltage(self):
+ """Get battery voltage"""
+ if self.__adc is None:
+ return self.__get_power_vbatt()
+ else:
+ return self.__get_adc_vbatt()
+
+ def get_energy(self,volt_arg ):
+ """Get battery energy"""
+ if( volt_arg == None) :
+ volt_arg = self.get_voltage()
+ self.__energy = self.__get_soc(self.__temp, volt_arg)
+ # print("get_energy:volt_arg {} __energy{}".format(volt_arg,self.__energy))
+ return self.__energy
+
+ def set_charge_callback(self, charge_callback):
+ if self.__chrg_gpion is not None and self.__stdby_gpion is not None:
+ if callable(charge_callback):
+ self.__charge_callback = charge_callback
+ return True
+ return False
+
+ def get_charge_status(self):
+ return self.__charge_status
+
+class BatteryManager(Abstract):
+ def __init__(self):
+ """电池管理器"""
+ self.battery = Battery()
+ self.low_battery = False
+
+ def post_processor_after_instantiation(self):
+ """订阅此类所有的事件到 EventMesh中"""
+ EventMesh.subscribe("get_battery", self.get_battery)
+
+ def get_battery(self, event=None, msg=None):
+ battery = self.battery.get_energy(msg)
+ return battery
+
+ def get_voltage(self, event=None, msg=None):
+ voltage = self.battery.get_voltage()
+ return voltage
+
+class ConfigStoreManager(Abstract):
+ """
+ 持久化落盘存储
+ """
+
+ def __init__(self):
+ self.file_name = "/ext/conf_store.json"
+ self.lock = Lock()
+ self.map = dict()
+
+ def post_processor_after_instantiation(self):
+ if ql_fs.path_exists(self.file_name):
+ self.map = ql_fs.read_json(self.file_name)
+ else:
+ self.__store()
+ EventMesh.subscribe("persistent_config_get", self.__read)
+ EventMesh.subscribe("persistent_config_store", self.__store)
+
+ def __read(self, event, msg):
+ with self.lock:
+ return self.map.get(msg)
+
+ def __store(self, event=None, msg=None):
+ if msg is None:
+ msg = dict()
+ with self.lock:
+ self.map.update(msg)
+ ql_fs.touch(self.file_name, self.map)
+
+class sosInfoCallManager(Abstract):
+ # 通讯录
+ def __init__(self):
+ pass
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("set_sos_info_call", self.set_sos_info_call)
+
+ def set_sos_info_call(self, event, msg):
+ hangup_mode = EventMesh.publish("get_hangup_mode")
+ if hangup_mode == 1:
+ EventMesh.publish("set_sos_flag",0)
+ EventMesh.publish("set_sos_num",0)
+ EventMesh.publish("set_hangup_mode",0)
+ print('hangup_mode disconnect',hangup_mode)
+ sos_flag = EventMesh.publish("get_sos_flag")
+ print('voicecall sos_flag',sos_flag)
+ if sos_flag == 0 :
+ EventMesh.publish("set_sos_num",0)
+ else:
+ num = EventMesh.publish("get_sos_num")
+ number = EventMesh.publish("get_dial_sos_number")
+ if number != None:
+ if len(number) > 0:
+ if num == None:
+ num = 0
+ num+=1
+ num_len = 0
+
+ if len(number) == 1:
+ num_len = len(number)
+ elif len(number) == 2:
+ num_len = len(number)+1
+ elif len(number) == 3:
+ num_len = len(number)+2
+ # print("number:{} number_len :{} num:{} num_len:{}".format(number,len(number),num,num_len))
+ if num > num_len :
+ if len(number) == 1:
+ number1 = str(number[0])
+ sms.sendPduMsg(number1, '我需要你的帮助', 'UCS2')
+ elif len(number) == 2:
+ number1 = str(number[0])
+ sms.sendPduMsg(number1, '我需要你的帮助', 'UCS2')
+
+ number2 = str(number[1])
+ sms.sendPduMsg(number2, '我需要你的帮助', 'UCS2')
+ elif len(number) == 3:
+ number1 = str(number[0])
+ sms.sendPduMsg(number1, '我需要你的帮助', 'UCS2')
+ number2 = str(number[1])
+ sms.sendPduMsg(number2, '我需要你的帮助', 'UCS2')
+ number3 = str(number[2])
+ sms.sendPduMsg(number3, '我需要你的帮助', 'UCS2')
+ EventMesh.publish("set_sos_flag",0)
+ EventMesh.publish("set_sos_num",0)
+ else:
+ # print("number:{} number_len :{}".format(number,len(number)))
+ EventMesh.publish("set_sos_num",num)
+ if len(number) == 1:
+ if len(number[0]) != 0:
+ EventMesh.publish("set_callnumer_cb",number[0])
+ print("phone 1")
+ elif len(number) == 2:
+ if num == 1 or num == 3:
+ print("phone 2")
+ if len(number[1]) != 0:
+ EventMesh.publish("set_callnumer_cb",number[1])
+ elif num == 2:
+ print("phone 3")
+ if len(number[0]) != 0:
+ EventMesh.publish("set_callnumer_cb",number[0])
+ elif len(number) == 3:
+ if num == 1 or num == 4:
+ if len(number[1]) != 0:
+ EventMesh.publish("set_callnumer_cb",number[1])
+ print("phone 4")
+ elif num == 2 or num == 5:
+ print("phone 5")
+ if len(number[2]) != 0:
+ EventMesh.publish("set_callnumer_cb",number[2])
+ elif num == 3:
+ if len(number[0]) != 0:
+ print("phone 6")
+ EventMesh.publish("set_callnumer_cb",number[0])
+
+WL_timer = osTimer()
+def WL_timer_cb(*args):
+ get_call = EventMesh.publish("get_call_state")
+ if get_call == 2:#只有拨进来才给接听
+ EventMesh.publish("answer_auto_event")
+
+def voice_callback(args):
+ print('voicecall iinfo:{}'.format(args))
+ if args[0] == 10:
+ get_UI_high_priority = EventMesh.publish("get_UI_high_priority")#如果在拨出去或者通话中屏蔽来电
+ if get_UI_high_priority == 1:
+ EventMesh.publish("set_interrup_incall",1)
+ return
+ print('voicecall incoming call, PhoneNO.: ', args[6])
+ size_len = len(str(args[6]))
+ tmp = []
+ tmp = args[6]
+ find_num = tmp[0]
+ b = tmp[0].isdigit()#判断是否不是数字开头 暂时不用 因为截取了+判断不了 判断号码是否大于11位数,如果大于11位数 并且第一个字符是数字就按照最后11位做存储
+
+ if b == True and size_len > 11:
+ tmp = tmp[size_len-11:]
+ WLKEY = EventMesh.publish("get_storage_config","WLKEY")
+ if WLKEY != None:
+ if WLKEY == "1" or WLKEY == "2":#开启了白名单
+ on_list_flag = 0
+ phonebook = EventMesh.publish("get_phonebook_list")
+ phonebook_list = phonebook[1]
+ print("voice_callback:phonebook_list{}".format(phonebook_list))
+ try:
+ for value in phonebook_list.values():
+ if value == args[6]:
+ on_list_flag = 1
+ break
+ except Exception as e:
+ usys.print_exception(e)
+ print("voice_callback:on_list_flag {}".format(on_list_flag))
+ if on_list_flag == 1:#在白名单里
+ if WLKEY == "2":
+ WL_timer.start(30000, 0, WL_timer_cb)
+ else:
+ print("voice_callback:不在白名单中,挂断")
+ voiceCall.callEnd()
+ return
+
+ EventMesh.publish("set_call_state",2)#设置
+ EventMesh.publish("load_screen", {"screen": "incoming_call","meta":str(tmp)})
+
+ elif args[0] == 11:
+ EventMesh.publish("set_UI_high_priority",0)
+ sos_flag = EventMesh.publish("get_sos_flag")
+ if sos_flag == 1:
+ sos_flag = 0
+ EventMesh.publish("close_sos_timer")
+ EventMesh.publish("set_sos_flag",0)
+ EventMesh.publish("set_sos_num",0)
+
+ print('voicecall connected, PhoneNO.: ', args[6])
+ size_len = len(str(args[6]))
+ tmp = []
+ tmp = args[6]
+ find_num = tmp[0]
+ b = tmp[0].isdigit()#判断是否不是数字开头 暂时不用 因为截取了+判断不了
+ if b == True and size_len > 11:
+ tmp = tmp[size_len-11:]
+ EventMesh.publish("set_call_state",1)#设置关机时间
+ EventMesh.publish("load_screen", {"screen": "on_call","meta":str(tmp)})
+
+ elif args[0] == 12:
+ set_interrup_call = EventMesh.publish("get_interrup_incall")#打断这次不需要来电的ui事件 以免通话中退出当前界面进不去了
+ if set_interrup_call == 1:
+ EventMesh.publish("set_interrup_incall",0)
+ return
+
+ EventMesh.publish("set_interrup_incall",0)
+ EventMesh.publish("set_UI_high_priority",0)
+
+ EventMesh.publish("return_prev_screen")
+
+ EventMesh.publish("set_sos_info_call")
+ print('voicecall disconnect end')
+ EventMesh.publish("set_call_state",0)#设置关机时间
+
+
+ elif args[0] == 13:
+ print('voicecall is waiting, PhoneNO.: ', args[6])
+ elif args[0] == 14:
+ EventMesh.publish("set_call_state",4)#设置关机时间
+
+ EventMesh.publish("set_UI_high_priority",0)
+ last_screen = EventMesh.publish("get_old_screen")#
+ print('voicecall dialing, PhoneNO.: ', args[6],last_screen,type(last_screen))
+ if last_screen == "dialing_noplay_popup":#预防挂断之后还会弹出这个界面
+ EventMesh.publish("load_screen", {"screen": "dialing"})
+ else:
+ voiceCall.callEnd()
+
+ elif args[0] == 15:
+ print('voicecall alerting, PhoneNO.: ', args[6])
+
+ elif args[0] == 16:
+ print('voicecall holding, PhoneNO.: ', args[6])
+
+class DeviceInfoManager(Abstract):
+
+ """
+ 设备信息管理
+ """
+
+ def __init__(self):
+
+ self.DeviceInfo_queue = Queue()
+ _thread.start_new_thread(self.DeviceInfo_queue_thread, ())
+ EventMesh.subscribe("publish_message_event_DeviceInfo",self.publish_message_event_DeviceInfo)
+ self.key = ""
+ self.imei = ""
+ self.cid = "ETEST20221014010"
+ self.imsi = ""
+ self.password = "000000"
+ #self.__city = None
+ #self.__location = None
+ self.timer_push_schedule = osTimer()
+ self.timer_pusht_test = osTimer()
+
+ #self.battery_push_schedule = osTimer()
+ self.check_battery_list = []
+
+ self.step = [0,0,0,0]
+ self.timer_push=0
+ self.timer_push_tmp=60
+ self.PING = "0" #绑定状态
+ self.connect = 0 #服务器连接状态
+ self.KA_time = 0
+ self.HR_time = 0
+ self.SENSOR_time = 0
+ self.HR_state = 0
+ self.HR_Onestate = 0
+ self.get_hr_state = 0
+ self.get_spo2_state = 0
+ self.set_hsenor_crt = 0
+ self.HR_OneTime = 0
+ self.Hr_Need_Open = 0
+ self.Spo2_Need_Open = 0
+ self.bat_time = 0
+ self.sms_full_flag = 0
+ self.clear_step = 0
+ self.test = 0
+ self.old_time = 0
+ self.UD_time = 0
+ self.upload_time = 0
+ self.UD_timeout = 7*60
+
+ self.temp_time = 0
+ self.temp_state = 0
+ self.temp_one_state = 0
+
+ self.vbat_count = 0
+
+ self.vbat_buf=[]
+
+ self.curr_battery_level = 4200
+ self.bat_count = 0
+
+ self.mearsure_btn = 0
+ self.mearsure_timer = 0
+
+ self.no_smi_count = 0
+ self.no_smi_state = 0
+
+ self.normal_oldtotalmin = 0 #上次响过的闹钟分钟数不等于当前的分钟数据需要清零否则下一个不会响铃
+ self.normal_flag =0
+ self.normal_count = 0
+
+ self.charge_full_count = 0
+
+ self.dev_state = 0
+
+ self.temp_warning = 0
+
+ self.wear = 1
+
+ self.GPS_step_t = 0#记录步数
+ self.usb = USB()
+ self.usb.setCallback(self.usb_event_cb)
+ self.log = LogAdapter(self.__class__.__name__)
+ self.rtc = RTC()
+ self.aud = audio.Audio(0)
+ print("DeviceInfoManager:1")
+ self.gsensor = SC7A20()
+ print("DeviceInfoManager:1.0")
+ self.gsensor.activate()
+ print("DeviceInfoManager:1.1")
+ self.gsensor.init()
+ print("DeviceInfoManager:2")
+ self.gsensor.set_callback(self.gsensor_cb)
+ try :
+ self.hsensor = HX3918()
+
+ except Exception as e:
+ print("Hsensor none HX3918:{}".format(e))
+ try :
+ self.hsensor = GH3018()
+ except Exception as e:
+ print("Hsensor none GH3018:{}".format(e))
+ #
+ self.hsensor.activate()
+ self.hsensor.init()
+ self.hsensor.close()
+ try :
+ self.hsensor.set_sar(1)
+ except Exception as e:
+ print("Hsensor none set_sar:{}".format(e))
+ self.old_temp_time = 0
+ # #print("hsensor.open_heart:%d\r\n"%(self.hsensor.open_heart()))
+ print("DeviceInfoManager:3")
+ self.i2c0 = I2C(I2C.I2C0, I2C.FAST_MODE)
+ self.stop_temp( None, None)
+
+ def post_processor_after_instantiation(self):
+ print("post_processor_after_instantiation:1")
+ """订阅此类所有的事件到 EventMesh中"""
+ voiceCall.setCallback(voice_callback)
+ EventMesh.subscribe("screen_get_ope", self.get_device_ope)
+ EventMesh.subscribe("screen_get_sig", self.get_signal)
+ EventMesh.subscribe("screen_get_time", self.get_time)
+ EventMesh.subscribe("about_get_imei", self.get_imei)
+ EventMesh.subscribe("about_get_iccid", self.get_ic_cid)
+ EventMesh.subscribe("get_sim_Status", self.get_sim_Status)
+ EventMesh.subscribe("about_get_phonenum", self.get_phone_num)
+ EventMesh.subscribe("screen_get_battery", self.get_battery)
+ EventMesh.subscribe("set_curr_battery_level", self.set_curr_battery_level)
+ EventMesh.subscribe("get_curr_battery_level", self.get_curr_battery_level)
+ EventMesh.subscribe("get_fw_version", self.get_device_fw_version)
+ EventMesh.subscribe("get_standby_time", self.get_standby_time)
+ EventMesh.subscribe(constants.EVENT.GET_STEP, self.get_step_count)
+ EventMesh.subscribe("sim_slot_get", self.sim_slot_get)
+ EventMesh.subscribe("sim_slot_switch", self.sim_slot_switch)
+ EventMesh.subscribe(constants.EVENT.GET_KEY, self.get_key)
+ EventMesh.subscribe(constants.EVENT.SET_KEY, self.set_key)
+ EventMesh.subscribe(constants.EVENT.GET_IMEI, self.get_imei)
+ EventMesh.subscribe(constants.EVENT.GET_CID, self.get_cid)
+ EventMesh.subscribe(constants.EVENT.SET_CID, self.set_cid)
+ EventMesh.subscribe(constants.EVENT.GET_IMSI, self.get_imsi)
+ EventMesh.subscribe(constants.EVENT.GET_PASSWORD, self.get_password)
+ EventMesh.subscribe(constants.EVENT.SET_PASSWORD, self.set_password)
+ EventMesh.subscribe(constants.EVENT.SET_PING, self.set_ping)
+ EventMesh.subscribe(constants.EVENT.GET_PING, self.get_ping)
+ EventMesh.subscribe(constants.EVENT.SET_CONNECT, self.set_connect)
+ EventMesh.subscribe(constants.EVENT.GET_CONNECT, self.get_connect)
+
+ EventMesh.subscribe("get_dev_state", self.get_dev_state)
+ EventMesh.subscribe("set_dev_state", self.set_dev_state)
+
+ EventMesh.subscribe(constants.EVENT.START_BLOOD_OXYGEN, self.start_blood_oxygen)
+ EventMesh.subscribe(constants.EVENT.START_HEART, self.start_heart)
+ EventMesh.subscribe(constants.EVENT.STOP_BLOOD_OXYGEN, self.stop_blood_oxygen)
+ EventMesh.subscribe(constants.EVENT.STOP_HEART, self.stop_heart)
+ EventMesh.subscribe(constants.EVENT.GET_BLOOD_OXYGEN, self.get_blood_oxygen)
+ EventMesh.subscribe(constants.EVENT.GET_HEART, self.get_heart)
+ EventMesh.subscribe(constants.EVENT.GET_WEAR, self.get_wear)
+ EventMesh.subscribe("get_Hsensor", self.get_Hsensor)
+ EventMesh.subscribe("Hsensor_set_sleep", self.Hsensor_set_sleep)
+
+ EventMesh.subscribe(constants.EVENT.START_TEMP, self.start_temp)
+ EventMesh.subscribe(constants.EVENT.STOP_TEMP, self.stop_temp)
+ EventMesh.subscribe(constants.EVENT.GET_TEMP, self.get_temp)
+
+ EventMesh.subscribe("optimize_temp",self.optimize_temp)
+
+ print("post_processor_after_instantiation:2")
+ self.timer_push_schedule.start(10000, 1, self.publish_event_cb)
+ # self.timer_pusht_test.start(2000, 1, self.publish_test)
+ # self.battery_push_schedule.start(3000, 1, self.__check_battery)
+ self.log.debug("post_processor_after_instantiation finished")
+ #EventMesh.publish(constants.EVENT.START_HEART)
+ # 设备开机立刻更新一次参数
+ self.publish_event_cb()
+
+ print("post_processor_after_instantiation:3")
+
+ def publish_message_event_DeviceInfo(self,event,msg):
+ self.DeviceInfo_queue.put(msg)
+
+ #DeviceInfo的消息队列处理,防止卡顿
+ def DeviceInfo_queue_thread(self):
+ while True:
+ data = self.DeviceInfo_queue.get()
+ #print("DeviceInfo_queue_thread:data = {}".format(data))
+ if data != None:
+ try:
+ data["func"](data["data"])
+ except Exception as e:
+ print("DeviceInfo_queue_thread:ERROR:{}".format(e))
+ usys.print_exception(e)
+
+
+ def gsensor_cb(self, para):
+ print("gsensor_cb:{}".format(para))
+ flip_sw = EventMesh.publish("get_storage_config","flip_sw")
+
+ if para == 0: #跌倒报警
+ pass
+ #EventMesh.publish("load_screen", {"screen": "FIND"})
+ elif para == 1: #抬腕
+
+ if flip_sw == 1:
+ EventMesh.publish(constants.EVENT.SYSTEM_UP)
+
+ elif para == 2: #放手
+ pass
+ # if flip_sw == 1:
+ # EventMesh.publish(constants.EVENT.SYSTEM_SLEEP)
+
+ def publish_event_cb(self, *args, **kwargs):
+ EventMesh.publish("publish_message_event_DeviceInfo",{"func":self.publish_event,"data":0})
+
+ def get_dev_state(self, event, msg):
+ return self.dev_state
+ def set_dev_state(self, event, msg):
+ self.dev_state = msg
+
+ def optimize_temp(self,event,msg):
+ temp = EventMesh.publish(constants.EVENT.GET_TEMP)
+ temp += 0.5
+ get_temp_time = EventMesh.publish("get_temp_time")
+ # print("temp:{}".format(temp))
+ if temp < 36 :#or temp > 37.5:
+ temp = urandom.randint(360, 365)/10
+ if temp > 37.5:
+
+ self.temp_warning += 1
+ print("temp_warning:{} get_temp_time{}".format(self.temp_warning,get_temp_time))
+
+ if self.temp_warning < 5:#高温没连续超过3次,和谐成37.5度以下
+ temp = 37+(urandom.randint(1, 4)/10)
+ else:
+ self.temp_warning = 0
+ else:
+ if self.temp_warning>=1:
+ self.temp_warning -= 1
+ if temp >= 40:
+ temp = 40
+ return temp
+
+ def publish_event(self,data):
+ """
+ 定时事件处理
+ :param args:
+ :param kwargs:
+ :return:
+ """
+
+ try :
+ self.timer_push = self.timer_push+1
+
+ #if self.timer_push > 10 :
+ # EventMesh.publish("time", self.get_time())
+ # EventMesh.publish("battery", self.get_battery())
+ # EventMesh.publish("signal", self.get_signal())
+
+ self.timer_push = 0
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ # print("date_tmp......01....{} time_tmp:{}\r\n".format(date_tmp,time_tmp))
+
+ """电量小于20% 5分钟提醒一次"""
+ get_low_btn = EventMesh.publish("get_low_bat_btn")#
+ battery = EventMesh.publish("screen_get_battery")
+ # print("get_low_btn:{} self.bat_time:{}".format(get_low_btn,self.bat_time))
+ if get_low_btn != None:#低电使能开关
+ if get_low_btn == 1:
+ self.bat_time+=10
+ # print("date_tmp:{} self.bat_time:{}".format(date_tmp,self.bat_time))
+
+ if self.bat_time > 5*60:
+ self.bat_time = 0
+ if battery[1] <= 20 and battery[1] > 0 and battery[0] != "1":
+ EventMesh.publish("load_screen", {"screen": "LOW_POWER"})
+ else:
+ self.bat_time = 0
+
+ EventMesh.publish("countdown_end_cb")
+ """定时检查是否关闭gps失败"""
+ # gnss_state = quecgnss.get_state()
+ # get_location_flag = EventMesh.publish("get_location_flag")
+ # if get_location_flag != None:
+ # # if gnss_state == 2 and get_location_flag == 0:
+ # # EventMesh.publish(constants.EVENT.GPSCLOSE)
+ # if(get_location_flag == 0):
+ # EventMesh.publish(constants.EVENT.START_LOCATION,constants.PROTOCOL.UD_SEND) #开始UD定位
+
+ """7分钟一次心跳"""
+ if math.fabs(time_tmp - self.KA_time) > 7*60: #7分钟一次心跳
+ self.KA_time = time_tmp
+ EventMesh.publish(constants.PROTOCOL.KA_SEND)
+
+ """定时定位"""
+ #EventMesh.publish("set_upload_data",3*60)
+ self.upload_time = EventMesh.publish("get_upload_data")
+ #print("self.upload_time:{} math.fabs(time_tmp - self.UD_time):{}".format(self.upload_time,math.fabs(time_tmp - self.UD_time)))
+ if self.upload_time != None :
+ if math.fabs(time_tmp - self.UD_time) > self.upload_time: #30分钟一次定位
+ self.UD_time = time_tmp
+ status_tmp = self.gsensor.get_status()#获取运动次数
+ #status_tmp = 4
+ #EventMesh.txt_log("status_count:{}".format(status_tmp))
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1 and status_tmp > 3 :
+ EventMesh.publish(constants.EVENT.START_LOCATION,constants.PROTOCOL.UD_SEND) #开始UD定位
+ self.gsensor.clean_status()#清除运动次数
+ else : #关闭定位
+ #EventMesh.txt_log("NO status")
+ print("NO status")
+ EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位
+ EventMesh.publish(constants.EVENT.PUSH_STEP, self.get_step_count())
+ except Exception as e:
+ usys.print_exception(e)
+ EventMesh.txt_log("publish_event1:".format(e))
+ try :
+ """电池平均值"""
+ temp = Power.getVbatt()
+ if self.bat_count < 10:
+ self.vbat_buf.append(temp)
+ self.bat_count += 1
+ else:
+ for i in range(9):
+ self.vbat_buf[i] = self.vbat_buf[i+1]
+ self.vbat_buf[9] = temp
+ curr_count = len(self.vbat_buf)
+ bat_total_value = 0
+ for i in range(curr_count):
+ bat_total_value += self.vbat_buf[i]
+ bat_total_value = bat_total_value//curr_count#一分钟更新一次电量 10个平均值
+ EventMesh.publish("set_curr_battery_level",bat_total_value)
+ # print("self.vbat_buf:{} curr_count :{} bat_total_value:{} temp:{}".format(self.vbat_buf,curr_count,bat_total_value,temp))
+ bat_tmp = EventMesh.publish("screen_get_battery")
+ self.vbat_count+=10
+ if self.vbat_count >= 60:
+ self.vbat_count = 0
+ if bat_tmp != None:
+ bat_value = bat_tmp[1]
+ if bat_value <= 0 and battery[0] != "1":
+
+ EventMesh.publish("load_screen", {"screen": "LOW_ONE_POWER"})
+ except Exception as e:
+ usys.print_exception(e)
+ EventMesh.txt_log("publish_event2:".format(e))
+ try :
+ """"隔天清步数"""
+ hour = 0
+ min = 0
+ hour = date_tmp[3]
+ min = date_tmp[4]
+ old_Timesec = EventMesh.publish("get_old_time_data")
+ if old_Timesec != None:
+ data = RTC().datetime()
+ hour = data[4]
+ min = data[5]
+ next_alarm_time = utime.localtime(int(old_Timesec))
+ # print("data[5]:{} {} next_alarm_time:{} old_Timesec:{}".format(data[1],data[2],next_alarm_time,old_Timesec))
+ month = next_alarm_time[1]
+ day = next_alarm_time[2]
+ year = next_alarm_time[0]
+ if month != data[1] or day != data[2] or year != data[0]:
+ step = EventMesh.publish("get_old_step_value")
+ self.gsensor.reset_step()
+ EventMesh.publish("set_old_step_value",0)
+
+ hr = EventMesh.publish("get_old_hr_data",)
+ if hr != 0:
+ EventMesh.publish("set_old_hr_data", 0)
+
+ spo2 = EventMesh.publish("get_old_spo2_data")
+ if spo2 != 0:
+ EventMesh.publish("set_old_spo2_data", 0)
+ EventMesh.publish("set_old_time_data",time_tmp)
+ if hour == 23:#清步数
+ if min == 59:
+ step = EventMesh.publish("get_old_step_value")
+ EventMesh.publish("set_old_time_data",time_tmp)
+ EventMesh.publish("set_old_step_value",0)
+ self.gsensor.reset_step()
+ hr = EventMesh.publish("get_old_hr_data")
+ if hr != 0:
+ EventMesh.publish("set_old_hr_data", 0)
+
+ spo2 = EventMesh.publish("get_old_spo2_data")
+ if spo2 != 0:
+ EventMesh.publish("set_old_spo2_data", 0)
+ else:
+ if self.clear_step == 1:
+ self.clear_step = 0
+ else:
+ if self.clear_step == 1:
+ self.clear_step = 0
+
+
+
+ """未联网提示关机"""
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 0:#未联网提示关机
+ if battery[0] == "0":
+ self.no_smi_count+=10
+ if self.no_smi_count > (15*60) and self.no_smi_state == 0:
+ self.no_smi_count = 0
+ self.no_smi_state = 1
+ EventMesh.publish("load_screen", {"screen": "no_sim_auto_screen"})
+ else:
+ self.no_smi_count = 0
+ self.no_smi_state = 0
+ else:
+ self.no_smi_count = 0
+ self.no_smi_state = 0
+ if battery[0] == "1":
+ if battery[1] >= 100:
+ if self.charge_full_count > 60 and self.charge_full_count % (60*10) == 0:#每十分钟提醒一次
+ EventMesh.publish("load_screen", {"screen": "charge_full"})
+ self.charge_full_count+=10
+ else:
+ self.charge_full_count = 0
+
+
+ """检测短信已满,提示是否清掉"""
+ msg_nums = sms.getMsgNums() #获取短信条数
+ if(msg_nums != -1):
+ sms_data = sms.getSaveLoc()
+ sms_max = sms_data[0][2]
+ if msg_nums >= sms_max-1:
+ self.sms_full_flag+=10
+ if self.sms_full_flag >= 120:
+ self.sms_full_flag=0
+ EventMesh.publish("load_screen", {"screen": "message_full"})
+ else:
+ self.sms_full_flag = 0
+ except Exception as e:
+ usys.print_exception(e)
+ EventMesh.txt_log("publish_event3:".format(e))
+
+ """定时测量心率,血氧,体温"""
+ WEAR = EventMesh.publish(constants.EVENT.GET_WEAR)#佩戴数据
+ if WEAR == None :
+ WEAR = 0
+
+ #佩戴检测
+ WEAR = EventMesh.publish(constants.EVENT.GET_WEAR)#佩戴数据
+ if self.wear != WEAR:
+ remove_sw = EventMesh.publish("get_storage_config","remove_sw")
+ if remove_sw == "1":#开启了佩戴检测的开关
+ dev_state = EventMesh.publish("get_dev_state")
+ if WEAR != 1:
+ tmp = 1 << 3
+ tmp = ~tmp
+ tmp = 1 << 20
+ dev_state = dev_state|tmp #第20位=1
+
+ print("佩戴检测:{}".format(dev_state))
+ EventMesh.publish("set_dev_state",dev_state)
+ EventMesh.publish(constants.EVENT.START_LOCATION,[constants.PROTOCOL.AL_SEND,dev_state]) #开始AL定位,发送报警
+ #EventMesh.publish(constants.PROTOCOL.HELP_SEND,65)
+ self.wear = WEAR
+
+ self.get_hr_state = EventMesh.publish("get_hr_state")
+ if self.get_hr_state == None :
+ self.get_hr_state = 0
+ self.get_spo2_state = EventMesh.publish("get_spo2_state")
+ if self.get_spo2_state == None :
+ self.get_spo2_state = 0
+ get_temp_time = EventMesh.publish("get_temp_time")
+ get_temp_state = EventMesh.publish("get_temp_state")
+ if get_temp_state == None :
+ get_temp_state = 0
+ hr_time = []
+ hr_time = EventMesh.publish("get_time_hr_spo2")#获取时间是否大于0
+ if hr_time == None:
+ hr_time = [0,0]
+ if get_temp_state != None : #突然脱腕
+ if get_temp_state > 1 and WEAR != 1:
+ EventMesh.publish(constants.EVENT.STOP_TEMP)
+ EventMesh.publish("set_temp_state",0)
+ if (self.get_hr_state > 1 or self.get_spo2_state > 1) and WEAR != 1:
+ if self.get_hr_state > 1 :
+ EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+ elif self.get_spo2_state > 1:
+ EventMesh.publish("set_spo2_state",0)#2代表后台进入测试
+ EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1 and battery[0] != "1" and WEAR == 1:
+
+ # print("get_temp_time:{} self.temp_one_state:{}".format(get_temp_time,self.temp_one_state))
+ if get_temp_time != None:#定时测量体温
+ if get_temp_time > 0:
+ if get_temp_state != None:
+ if get_temp_state == 0 or get_temp_state == 2 or get_temp_state == 3 :
+ if (time_tmp-self.temp_time) >= get_temp_time:#大于一个周期的时间,重新赋值
+ self.temp_one_state = 0
+ self.temp_state = 0
+ self.temp_time = time_tmp
+
+ if self.old_temp_time != get_temp_time:#重复修改测量间隔时间
+ self.temp_one_state = 0
+ self.temp_time = time_tmp#防止改变时间的时候正在开启测量突然10s就停止测量
+ self.temp_state = 0
+ self.old_temp_time = get_temp_time
+
+ if (time_tmp-self.temp_time) == 0 and self.temp_state == 0:#一开始就测量 测量一分钟停止测量体温
+ self.temp_state = 1
+ self.temp_one_state = 0
+ EventMesh.publish("set_temp_state",2)
+ print("AUTO temp:")
+ EventMesh.publish(constants.EVENT.START_TEMP)
+
+ elif (time_tmp-self.temp_time) >= 60 and self.temp_state == 1:
+ self.temp_state = 0
+ self.temp_one_state = 0
+ # temp = EventMesh.publish(constants.EVENT.GET_TEMP)
+ # temp += 0.5
+ # if temp < 25 or temp > 42:
+ # temp = 0
+ temp = EventMesh.publish("optimize_temp")
+ if temp == None:
+ temp = 0
+ tmp_f_tmp = 0
+ tmp_d_tmp = 0
+ if str(temp).find(".") != -1:
+ tmp_f = str(temp).split('.')[0]
+ tmp_f_tmp = int(tmp_f)
+
+ tmp_d = str(temp).split('.')[1][:1]
+ tmp_d_tmp = int(tmp_d)
+ else:
+ tmp_f_tmp = temp
+
+ if temp != 0:
+ EventMesh.publish("set_history_temp_value",temp)
+ EventMesh.publish(constants.PROTOCOL.TEMP_SEND,[tmp_f_tmp,tmp_d_tmp])
+ num = str(tmp_f_tmp)+"."+ str(tmp_d_tmp)
+ EventMesh.publish(constants.PROTOCOL.BTEMP2_SEND,[1,num])
+ EventMesh.publish(constants.EVENT.STOP_TEMP)
+ print("AUTO temp:{} tmp_f:{} tmp_f_tmp:{} tmp_d:{} tmp_d_tmp:{}".format(temp,tmp_f,tmp_f_tmp,tmp_d,tmp_d_tmp))
+ EventMesh.publish("set_temp_state",0)
+
+
+ if self.temp_state == 0 or get_temp_state == 3:#只有不在测量的时候才测单次的
+ if get_temp_state == 3:#单次测量
+ self.temp_one_state+=1
+ if self.temp_one_state == 1:
+ EventMesh.publish("set_temp_state",3)
+ print("AUTO one temp:1")
+ EventMesh.publish(constants.EVENT.START_TEMP)
+ elif self.temp_one_state > 6:
+ self.temp_one_state = 0
+ # temp = EventMesh.publish(constants.EVENT.GET_TEMP)
+ # temp += 0.5
+ # if temp < 25 or temp > 42:
+ # temp = 0
+ temp = EventMesh.publish("optimize_temp")
+ if temp == None:
+ temp = 0
+ tmp_f_tmp = 0
+ tmp_d_tmp = 0
+ if str(temp).find(".") != -1:
+ tmp_f = str(temp).split('.')[0]
+ tmp_f_tmp = int(tmp_f)
+
+ tmp_d = str(temp).split('.')[1][:1]
+ tmp_d_tmp = int(tmp_d)
+ else:
+ tmp_f_tmp = temp
+ if temp != None:
+ if temp != 0:
+ EventMesh.publish("set_history_temp_value",temp)
+ EventMesh.publish(constants.PROTOCOL.TEMP_SEND,[tmp_f_tmp,tmp_d_tmp])
+ num = str(tmp_f_tmp)+"."+ str(tmp_d_tmp)
+ EventMesh.publish(constants.PROTOCOL.BTEMP2_SEND,[1,num])
+ EventMesh.publish(constants.EVENT.STOP_TEMP)
+ print("once temp:{} tmp_f:{} tmp_f_tmp:{} tmp_d:{} tmp_d_tmp:{}".format(temp,tmp_f,tmp_f_tmp,tmp_d,tmp_d_tmp))
+ EventMesh.publish("set_temp_state",0)
+ else:
+ self.temp_one_state = 0
+ self.temp_state = 0
+ self.old_temp_time = 0
+
+ else:
+ self.old_temp_time = 0
+ get_temp_end_state = EventMesh.publish("get_temp_state")
+ if self.temp_state != 0:
+ if self.temp_state == 2:
+ self.temp_state = 0
+ EventMesh.publish(constants.EVENT.STOP_TEMP)
+ if get_temp_end_state == 1:
+ self.temp_one_state = 0
+
+ if get_temp_end_state == 3:#单次测量
+ self.temp_one_state+=1
+ if self.temp_one_state == 1:
+ print("AUTO one temp:2")
+ EventMesh.publish("set_temp_state",3)
+ EventMesh.publish(constants.EVENT.START_TEMP)
+ elif self.temp_one_state > 6:
+ self.temp_one_state = 0
+ # temp = EventMesh.publish(constants.EVENT.GET_TEMP)
+ # temp += 0.5
+ # if temp < 25 or temp > 42:
+ # temp = 0
+ temp = EventMesh.publish("optimize_temp")
+ if temp == None:
+ temp = 0
+ tmp_f_tmp = 0
+ tmp_d_tmp = 0
+ if str(temp).find(".") != -1:
+ tmp_f = str(temp).split('.')[0]
+ tmp_f_tmp = int(tmp_f)
+
+ tmp_d = str(temp).split('.')[1][:1]
+ tmp_d_tmp = int(tmp_d)
+ else:
+ tmp_f_tmp = temp
+ if temp != None:
+ if temp != 0:
+ EventMesh.publish("set_history_temp_value",temp)
+ EventMesh.publish(constants.PROTOCOL.TEMP_SEND,[tmp_f_tmp,tmp_d_tmp])
+ num = str(tmp_f_tmp)+"."+ str(tmp_d_tmp)
+ EventMesh.publish(constants.PROTOCOL.BTEMP2_SEND,[1,num])
+ EventMesh.publish(constants.EVENT.STOP_TEMP)
+ print("AUTO once temp:{} tmp_f:{} tmp_f_tmp:{} tmp_d:{} tmp_d_tmp:{}".format(temp,tmp_f,tmp_f_tmp,tmp_d,tmp_d_tmp))
+ EventMesh.publish("set_temp_state",0)
+
+ self.mearsure_btn = int(hr_time[0])
+ self.mearsure_timer = int(hr_time[1])
+ if self.mearsure_btn != None and self.mearsure_timer != None:
+ # print("hr......01....{} {}\r\n".format(hr_time[0],hr_time[1]))
+ if self.mearsure_btn > 0:
+ if self.mearsure_timer > 0:
+ #print("get_hr_state:{} get_spo2_state:{} self.old_time:{} mearsure_timer:{}".format(self.get_hr_state,self.get_spo2_state,self.old_time,mearsure_timer))
+ if self.get_hr_state != 1 and self.get_spo2_state != 1:
+ if self.get_hr_state == 0 and self.get_spo2_state == 0:
+ if self.HR_state == 0 or self.HR_state == 3:
+ self.HR_Onestate = 0
+ self.HR_OneTime = 0
+
+ if self.old_time != self.mearsure_timer:#重复修改测量间隔时间
+ self.SENSOR_time = time_tmp#防止改变时间的时候正在开启测量突然10s就停止测量
+ if self.get_hr_state == 2 and self.HR_state == 1:#自动检测的心率还在测量立马关了测试
+ heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
+ if heart_value >= 50 and heart_value != None:
+ EventMesh.publish("set_old_hr_data",heart_value)
+ EventMesh.publish("set_history_hr_value",heart_value)
+ EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)
+ print("stop debug1")
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+ self.HR_state = 0
+ elif self.get_spo2_state == 2 and self.HR_state == 2:
+ self.HR_state = 0
+ spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
+ if spo2_value > 85 and spo2_value != None:
+ EventMesh.publish("set_old_spo2_data",spo2_value)
+ EventMesh.publish("set_history_spo2_value",spo2_value)
+ EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value)
+ EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
+ self.old_time = self.mearsure_timer
+
+ if self.HR_state == 3 or self.HR_state == 0:#
+ if (time_tmp - self.SENSOR_time) >= self.mearsure_timer:
+ if self.get_spo2_state == 3 or self.get_hr_state == 3:#单次测量没有完毕优先测量间隔时间测量的
+ if self.get_hr_state == 3:
+ print("stop debug2")
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+ heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
+ if heart_value >= 50 and heart_value != None:
+ EventMesh.publish("set_old_hr_data",heart_value)
+ EventMesh.publish("set_history_hr_value",heart_value)
+ EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)
+
+ elif self.get_spo2_state == 3:
+ EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
+ spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
+ if spo2_value > 85 and spo2_value != None:
+ EventMesh.publish("set_history_spo2_value",spo2_value)
+ EventMesh.publish("set_old_spo2_data",spo2_value)
+ EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value)
+
+ self.HR_state = 0
+ self.SENSOR_time = time_tmp
+ self.SENSOR_time = time_tmp
+ self.HR_state = 0
+
+ #print("time_tmp :{} self.SENSOR_time :{} time_tmp - self.SENSOR_time:{} self.HR_state:{}".format(time_tmp,self.SENSOR_time,time_tmp - self.SENSOR_time,self.HR_state))
+ if (time_tmp - self.SENSOR_time) == 0 and self.HR_state == 0:
+ print("START_HEART:1")
+ EventMesh.publish("set_hr_state",2)#2代表后台进入测试
+ EventMesh.publish(constants.EVENT.START_HEART)
+ self.HR_state = 1
+ self.HR_Onestate = 0
+ self.HR_OneTime = 0
+ elif (time_tmp - self.SENSOR_time) >= 60 and self.HR_state == 1:
+ EventMesh.publish("set_hr_state",0)#2代表后台进入测试
+ print("stop debug3")
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+ heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
+ print("heart_value:{}".format(heart_value))
+ if heart_value >= 50 and heart_value != None:
+ EventMesh.publish("set_old_hr_data",heart_value)
+ EventMesh.publish("set_history_hr_value",heart_value)
+ EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据
+ #获取心率数据上传数据app
+ print("STOP_HEART:")
+
+ self.HR_state = 3
+ # EventMesh.publish("set_spo2_state",2)#2代表后台进入血氧测试
+ # EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧
+ # print("START_BLOOD_OXYGEN:")
+ # elif (time_tmp - self.SENSOR_time) >= 120 and self.HR_state == 2:#有需要再打开
+ # print("STOP_BLOOD_OXYGEN:")
+ # EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
+ # EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)#停止血氧测试
+ # spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
+ # print("spo2_value:{}".format(spo2_value))
+ # if spo2_value > 85 and spo2_value != None:
+ # EventMesh.publish("set_old_spo2_data",spo2_value)
+ # EventMesh.publish("set_history_spo2_value",spo2_value)
+ # EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value)
+ # self.HR_state = 3
+ else:
+ self.HR_state = 0
+ self.old_time = self.mearsure_timer
+
+ if self.HR_state == 3 or self.HR_state == 0:#只有不在测量的时候才测单次的
+ if self.get_spo2_state == 3 or self.get_hr_state == 3:#单次测量
+ self.HR_state = 0
+ self.HR_OneTime+=1
+ if self.HR_OneTime == 1 and self.HR_Onestate == 0:
+ print("hr..........\r\n")
+ if self.get_hr_state == 3:
+ self.Hr_Need_Open = 1
+ EventMesh.publish("set_hr_state",3)#2代表后台进入测试
+ EventMesh.publish(constants.EVENT.START_HEART)
+ else:
+ self.Hr_Need_Open = 0
+
+ if self.get_spo2_state == 3 and self.Hr_Need_Open == 0:
+ self.Spo2_Need_Open = 1
+ EventMesh.publish("set_spo2_state",3)#2代表后台进入测试
+ EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧
+ else:
+ self.Spo2_Need_Open = 0
+ self.HR_Onestate = 1
+ # print("self.HR_Onestate....3..:{} {} {} {} {}".format(self.HR_Onestate,self.get_hr_state,self.get_spo2_state,self.Hr_Need_Open,self.Spo2_Need_Open))
+ elif self.HR_OneTime > 6 and self.HR_Onestate == 1:
+ # print("self.HR_Onestate...4....:{} {} {} {} {}".format(self.HR_Onestate,self.get_hr_state,self.get_spo2_state,self.Hr_Need_Open,self.Spo2_Need_Open))
+ if self.Hr_Need_Open == 1:#需要关闭心率测量
+ print("stop debug4")
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+ heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
+ if heart_value >= 50 and heart_value != None:
+ EventMesh.publish("set_history_hr_value",heart_value)
+ EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据
+ EventMesh.publish("set_old_hr_data",heart_value)
+
+ if self.Spo2_Need_Open == 0 and self.get_spo2_state == 3:
+ EventMesh.publish("set_spo2_state",3)#2代表后台进入血氧测试
+ EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧
+
+ self.HR_Onestate = 2
+ self.set_hsenor_crt = 2#血氧关闭
+ else:
+ self.HR_Onestate = 0
+ self.HR_OneTime = 0
+ self.set_hsenor_crt = 0#
+
+ EventMesh.publish("set_hr_state",0)#2代表后台进入血氧测试
+ EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
+ else:
+ if self.Spo2_Need_Open == 1:#停止测试血氧
+ EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
+ EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)#K开血氧
+ spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
+
+ if spo2_value > 85 and spo2_value != None:
+ EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value)
+ EventMesh.publish("set_old_spo2_data",spo2_value)
+ EventMesh.publish("set_history_spo2_value",spo2_value)
+ if self.Hr_Need_Open == 0 and self.get_hr_state == 3:
+ EventMesh.publish("set_hr_state",3)#2代表后台进入测试
+ EventMesh.publish(constants.EVENT.START_HEART)
+ self.HR_Onestate = 2
+ self.set_hsenor_crt = 1#心率
+ else:
+ self.HR_Onestate = 0
+ self.HR_OneTime = 0
+ self.set_hsenor_crt = 2#血氧关闭
+
+
+ elif self.HR_OneTime > 6+6 and self.HR_Onestate == 2:
+ print("HR_OneTime:....05")
+ if self.set_hsenor_crt == 2:
+ EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
+ EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)#停止血氧测试
+ spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
+ if spo2_value > 85 and spo2_value != None:
+ EventMesh.publish("set_history_spo2_value",spo2_value)
+ EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value)
+ EventMesh.publish("set_old_spo2_data",spo2_value)
+ elif self.set_hsenor_crt == 1:
+ EventMesh.publish("set_hr_state",0)#0代表g关闭测试
+ print("stop debug5")
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+ heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
+ if heart_value >= 50 and heart_value != None:
+ EventMesh.publish("set_history_hr_value",heart_value)
+ EventMesh.publish("set_old_hr_data",heart_value)
+ EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据
+ self.HR_Onestate = 0
+ else:
+ if self.get_spo2_state == 2 or self.get_hr_state == 2:#单次测量
+ if self.get_hr_state == 2:
+ EventMesh.publish("set_hr_state",0)#2代表后台进入血氧测试
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+ elif self.get_spo2_state == 2:
+ EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
+ EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
+ self.HR_state = 0
+ self.HR_Onestate = 0
+ self.HR_OneTime = 0
+ self.set_hsenor_crt = 0
+ else:
+ #print("hr......01....{} {} self.HR_Onestate {} {}".format(self.get_hr_state,self.get_spo2_state,self.HR_OneTime,self.HR_Onestate))
+ self.SENSOR_time = time_tmp#进入最后一次的时间戳
+ self.old_time = 0
+
+ self.set_hsenor_crt = 0
+ if self.get_hr_state != 1 and self.get_spo2_state != 1:#没有设置间隔时间单次测量
+ if self.get_spo2_state == 3 or self.get_hr_state == 3:#单次测量
+ self.HR_state = 0
+ self.HR_OneTime+=1
+ if self.HR_OneTime == 1 and self.HR_Onestate == 0:
+ if self.get_hr_state == 3:
+ self.Hr_Need_Open = 1
+ EventMesh.publish("set_hr_state",3)#2代表后台进入测试
+ EventMesh.publish(constants.EVENT.START_HEART)
+ else:
+ self.Hr_Need_Open = 0
+
+ if self.get_spo2_state == 3 and self.Hr_Need_Open == 0:
+ self.Spo2_Need_Open = 1
+ EventMesh.publish("set_spo2_state",3)#2代表后台进入测试
+ EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧
+ else:
+ self.Spo2_Need_Open = 0
+ self.HR_Onestate = 1
+
+ elif self.HR_OneTime > 6 and self.HR_Onestate == 1:
+ print("stop_heart Onec ")
+ if self.Hr_Need_Open == 1:#需要关闭心率测量
+ print("stop debug6")
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+ heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
+ print("stop_heart heart_value:{}".format(heart_value))
+ if heart_value >= 50 and heart_value != None:
+ EventMesh.publish("set_old_hr_data",heart_value)
+ EventMesh.publish("set_history_hr_value",heart_value)
+ EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据
+ if self.Spo2_Need_Open == 0 and self.get_spo2_state == 3:
+ EventMesh.publish("set_spo2_state",3)#2代表后台进入血氧测试
+ EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧
+ self.HR_Onestate = 2
+ self.set_hsenor_crt = 2#血氧关闭
+ else:
+ self.HR_Onestate = 0
+ self.HR_OneTime = 0
+ self.set_hsenor_crt = 0#
+ EventMesh.publish("set_hr_state",0)#2代表后台进入血氧测试
+ EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
+ else:
+ if self.Spo2_Need_Open == 1:#停止测试血氧
+ EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
+ EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)#K开血氧
+ spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
+ print("spo2_value:{}.......01..".format(spo2_value))
+ if spo2_value > 85 and spo2_value != None:
+ EventMesh.publish("set_old_spo2_data",spo2_value)
+ EventMesh.publish("set_history_spo2_value",spo2_value)
+ EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value)
+ if self.Hr_Need_Open == 0 and self.get_hr_state == 3:
+ EventMesh.publish("set_hr_state",3)#2代表后台进入测试
+ EventMesh.publish(constants.EVENT.START_HEART)
+ self.HR_Onestate = 2
+ self.set_hsenor_crt = 1#心率
+ else:
+ self.HR_Onestate = 0
+ self.HR_OneTime = 0
+ self.set_hsenor_crt = 2#血氧关闭
+ print("STOP_BLOOD_OXYGEN:....06.....")
+
+ elif self.HR_OneTime > 6+6 and self.HR_Onestate == 2:
+ if self.set_hsenor_crt == 2:
+ EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
+ EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)#停止血氧测试
+ spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
+ if spo2_value > 85 and spo2_value != None:
+ EventMesh.publish("set_old_spo2_data",spo2_value)
+ EventMesh.publish("set_history_spo2_value",spo2_value)
+ EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value)
+ elif self.set_hsenor_crt == 1:
+ EventMesh.publish("set_hr_state",0)#0代表g关闭测试
+ print("stop debug7")
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+ heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
+ if heart_value >= 50 and heart_value != None:
+ EventMesh.publish("set_old_hr_data",heart_value)
+ EventMesh.publish("set_history_hr_value",heart_value)
+ EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据
+ self.HR_Onestate = 0
+ else:
+ if self.get_spo2_state == 2 or self.get_hr_state == 2:#单次测量
+ if self.get_hr_state == 2:
+ EventMesh.publish("set_hr_state",0)#2代表后台进入血氧测试
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+ elif self.get_spo2_state == 2:
+ EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
+ EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
+ self.HR_Onestate = 0
+ self.HR_OneTime = 0
+ self.old_time = 0
+ else:
+ self.old_temp_time = 0
+ self.old_time = 0
+ if battery[0] == "1":
+ get_hr_state = EventMesh.publish("get_hr_state")
+ get_spo2_state = EventMesh.publish("get_spo2_state")
+ if get_hr_state != None and get_spo2_state != None:
+ if get_hr_state == 2 or get_hr_state == 3:
+ EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率
+ print("stop debug8")
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+ elif get_spo2_state == 2 or get_spo2_state == 3:
+ EventMesh.publish("set_spo2_state",0)#2代表后台进入测试
+ EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
+
+ if get_temp_time != None:
+ get_temp_state = EventMesh.publish("get_temp_state")
+ if get_temp_state == 2 or get_temp_state == 3:
+ self.temp_one_state = 0
+ self.temp_state = 0
+ # temp = EventMesh.publish(constants.EVENT.GET_TEMP)
+ # temp += 0.5
+ # if temp < 25 or temp > 42:
+ # temp = 0
+ temp = EventMesh.publish("optimize_temp")
+ if temp == None:
+ temp = 0
+ tmp_f_tmp = 0
+ tmp_d_tmp = 0
+ if str(temp).find(".") != -1:
+ tmp_f = str(temp).split('.')[0]
+ tmp_f_tmp = int(tmp_f)
+
+ tmp_d = str(temp).split('.')[1][:1]
+ tmp_d_tmp = int(tmp_d)
+ else:
+ tmp_f_tmp = temp
+
+ EventMesh.publish("set_temp_state",0)
+ if temp != None:
+ if temp != 0:
+ EventMesh.publish("set_history_temp_value",temp)
+ EventMesh.publish(constants.PROTOCOL.TEMP_SEND,[tmp_f_tmp,tmp_d_tmp])
+ num = str(tmp_f_tmp)+"."+ str(tmp_d_tmp)
+ EventMesh.publish(constants.PROTOCOL.BTEMP2_SEND,[1,num])
+ EventMesh.publish(constants.EVENT.STOP_TEMP)
+ self.SENSOR_time = time_tmp
+ self.HR_Onestate = 0
+ self.HR_OneTime = 0
+ self.HR_state = 0
+ self.old_time = 0
+ self.set_hsenor_crt = 0
+
+
+ #quecgnss.gnssEnable(0)
+ self.normal_alarm()
+
+
+ #普通闹钟
+ def normal_alarm(self):
+ data = RTC().datetime()
+ hour = data[4]
+ min = data[5]
+
+ week = int(data[3])
+
+ date1 = data[1]
+ date2 = data[2]
+ cur_total_min = int(hour)*60+int(min)
+ # EventMesh.debug_log("self.normal_oldtotalmin",self.normal_oldtotalmin,cur_total_min,self.alarm_flag)
+ if self.normal_oldtotalmin == 0:
+ self.normal_oldtotalmin = cur_total_min #549
+ if self.normal_oldtotalmin != cur_total_min: #上次响过的闹钟分钟数不等于当前的分钟数据需要清零否则下一个不会响铃
+ if self.normal_flag == 1:
+ self.normal_flag = 0
+ self.normal_count = 0
+ normal_alarm = []
+ normal_alarm = EventMesh.publish("get_storage_config","normal_alarm")
+ # EventMesh.debug_log("sleep info2",sleep,cur_total_min)
+ if self.normal_flag == 1:#表示闹钟响过清除标志
+ self.normal_count+=1
+ if self.normal_count > 6:
+ self.normal_count = 0
+ self.normal_flag = 0
+ if normal_alarm != None:
+ if len(normal_alarm) != 0 and normal_alarm != []:
+ j = 0
+ for i in range(len(normal_alarm)):
+ # EventMesh.debug_log("normal_alarm normal_alarm 33",normal_alarm,j)
+ normalalarm_hour = normal_alarm[j]["hour"]
+ normalalarm_min = normal_alarm[j]["min"]
+ normalalarm_day = normal_alarm[j]["day"]
+ normalalarm_enale = normal_alarm[j]["enable"]
+ normalalarm_totalmin = int(normalalarm_hour)*60+int(normalalarm_min)
+ # EventMesh.debug_log("wake alarm",normalalarm_hour,sleep_min,sleep_day,sleep_enale,sleep_totalmin,week)
+ if normalalarm_day == []:#单次闹钟只响一次
+ if normalalarm_enale != 0:
+ if normalalarm_totalmin == cur_total_min:#14:00
+ self.normal_count = 0
+ self.normal_flag = 0
+ normal_alarm[j]["enable"] = 0
+
+ # EventMesh.debug_log("wakeup wakeup1",sleep,j)
+ EventMesh.publish("set_storage_config",["normal_alarm",normal_alarm])#删除之后重新保存
+ EventMesh.publish("push_update_alarm_show")
+ # new_data=EventMesh.publish("get_storage_config","normal_alarm")
+ # print("normal wakeup1",new_data,j)
+ EventMesh.publish("load_screen", {"screen": "popup_alarm"})
+ break
+ else:
+ if normalalarm_enale != 0 and (week in normalalarm_day):#记录响过的时间分钟数
+ if normalalarm_totalmin == cur_total_min and self.normal_flag == 0:#14:00
+ self.normal_flag = 1
+ self.normal_count = 0
+ self.normal_oldtotalmin = normalalarm_totalmin
+ EventMesh.publish("load_screen", {"screen": "popup_alarm"})
+ break
+ j+=1
+
+ def get_sim_Status(self, event, msg):
+ return sim.getStatus()
+ def get_device_ope(self, event, msg):
+ """
+ 获取设备运营商信息
+ :param event:
+ :param msg:
+ :return: 运营商
+ """
+ net_ope_map = {
+ "UNICOM": "中国联通HD",
+ "CMCC": "中国移动HD",
+ "CT": "中国电信HD"
+ }
+ """获取运营商"""
+ try:
+ short_eons = net.operatorName()[1]
+ except Exception:
+ return "无"
+ return net_ope_map.get(short_eons, None)
+
+ def get_signal(self, event=None, msg=None):
+ """
+ 获取信号事件
+ :param event:
+ :param msg:
+ :return: int 类型
+ """
+ return net.csqQueryPoll()
+
+ def get_time_bucket(self, time):
+ if time < 12:
+ return '上午'
+ else:
+ return '下午'
+
+ def get_week(self, week):
+ if week == 1:
+ return '一'
+ elif week == 2:
+ return '二'
+ elif week == 3:
+ return '三'
+ elif week == 4:
+ return '四'
+ elif week == 5:
+ return '五'
+ elif week == 6:
+ return '六'
+ elif week == 7 or week == 0:
+ return '日'
+
+ def get_time(self, event=None, msg=None):
+ """
+ 获取时间事件
+ :param event:
+ :param msg:
+ :return: HH:MM 格式
+ """
+ rtc_time = self.rtc.datetime()
+
+ date = ("%d月%d日" % (rtc_time[1], rtc_time[2]))
+ year = ("%04d年" % (rtc_time[0]))
+ week = ("星期%s"%(self.get_week(rtc_time[3])))
+ week_data = rtc_time[3]
+ time = [rtc_time[4], rtc_time[5]]
+ time_quantum = ("%s" % (self.get_time_bucket(rtc_time[4])))
+
+ result = [time, time_quantum, date , week,year,week_data]
+ #时分,上午下午,日期,星期,年 星期
+ return result
+
+ def get_step_count(self, event=None, msg=None):
+ """
+ 获取步数
+ """
+ XYZ = self.gsensor.get_x_y_z()
+ tmp = 0
+ step = [0,0,0,0]
+ tmp = self.gsensor.get_step()
+ # print("x:%d,y:%d,z:%d tmp %d",XYZ[0],XYZ[1],XYZ[2],tmp)
+ step[0]= tmp
+ step[1] = XYZ[0]
+ step[2] = XYZ[1]
+ step[3] = XYZ[2]
+
+ return step
+
+ def get_ic_cid(self, event, msg):
+ """
+ 获取ic cid事件
+ :param event:
+ :param msg:
+ :return: str ic cid
+ """
+ return sim.getIccid()
+
+ def get_phone_num(self, event, msg):
+ """
+ 获取电话号码事件
+ :param event:
+ :param msg:
+ :return: str number
+ """
+ return sim.getPhoneNumber()
+
+ def get_battery(self, event=None, msg=None):
+ """
+ 获取电池事件,暂时没支持
+ :param event:
+ :param msg:
+ :return:
+ """
+
+ charge_state = '0'
+ if self.get_usb_state() == 1:
+ charge_state = '1'
+ else:
+ charge_state = '0'
+
+ #temp = Power.getVbatt()
+ temp = EventMesh.publish("get_curr_battery_level")
+ vbat = EventMesh.publish("get_battery",temp)
+ if vbat == None:
+ vbat = 100
+ # print("vbat",vbat)
+ # if temp != None :
+ # if temp <= 3505:
+ # vbat = 0
+ # elif temp <= 3699:
+ # vbat = 20 #"E:/vbat_20.jpg"
+ # elif temp <= 3772:
+ # vbat = 40 #"E:/vbat_40.jpg"
+ # elif temp <= 3882:
+ # vbat = 60 #"E:/vbat_60.jpg"
+ # elif temp <= 4070:
+ # vbat = 80 #"E:/vbat_80.jpg"
+ # elif temp <= 4200:
+ # vbat = 90 #
+ # else:
+ # vbat = 100 #"E:/vbat_100.jpg"
+ # else:
+ # vbat = 100
+
+ result = [charge_state, vbat]
+
+ return result
+ #Set the current average battery level
+ def set_curr_battery_level(self, event=None, msg=None):
+ self.curr_battery_level = msg
+
+ def get_curr_battery_level(self, event=None, msg=None):
+ return self.curr_battery_level
+
+ def get_device_fw_version(self, *args):
+ '''
+ 获取设备固件版本号
+ '''
+ fw_version = modem.getDevFwVersion()
+ if isinstance(fw_version, str):
+ return fw_version
+ return "--"
+
+ def get_standby_time(self, *args):
+ '''
+ 获取设备单次开机待机时间
+ '''
+ time_msg = utime.time()
+ d = int(
+ time_msg / 86400) # The int call removes the decimals. Conveniently, it always rounds down. int(2.9) returns 2 instead of 3, for example.
+ time_msg -= (
+ d * 86400) # This updates the value of x to show that the already counted seconds won't be double counted or anything.
+ h = int(time_msg / 3600)
+ time_msg -= (h * 3600)
+ m = int(time_msg / 60)
+ time_msg -= (m * 60)
+ s = time_msg
+ result = "{}天{}小时{}分".format(d, h, m)
+ return result
+
+ def set_key(self, topic, msg):
+ self.key = msg["value"]
+ def get_key(self, topic, msg):
+ return self.key
+
+ def get_imei(self, topic, msg):
+ if not self.imei:
+ self.imei = modem.getDevImei()
+ return self.imei
+
+ def get_cid(self, topic, msg):
+ return self.cid
+
+ def set_cid(self, topic, msg):
+ self.cid = msg["value"]
+
+ def get_imsi(self, topic, msg):
+ if not self.imei:
+ self.imei = sim.getImsi()
+ return self.imsi
+
+ def get_password(self, topic, msg):
+ return self.password
+
+ def set_password(self, topic, msg):
+ self.password = msg["value"]
+
+ def set_ping(self, topic, msg):
+ self.PING = msg
+ def get_ping(self, topic, msg):
+ return self.PING
+
+ def set_connect(self, topic, msg):
+ #print("set_connect:{}".format(msg))
+ self.connect = msg
+ def get_connect(self, topic, msg):
+ return self.connect
+
+ def start_blood_oxygen(self, topic, msg):
+ print("start_blood_oxygen!!!")
+ self.hsensor.open_blood_oxygen()
+
+ def start_heart(self, topic, msg):
+ print("start_heart!!!")
+ self.hsensor.open_heart()
+
+ def stop_blood_oxygen(self, topic, msg):
+ print("stop_blood_oxygen!!!")
+ self.hsensor.close()
+
+ def stop_heart(self, topic, msg):
+ print("stop_heart!!!")
+ self.hsensor.close()
+
+ def get_blood_oxygen(self, topic, msg):
+ data = self.hsensor.get_all_data()
+ return data[1]
+
+ def get_heart(self, topic, msg):
+ data = self.hsensor.get_all_data()
+ return data[0]
+
+ def get_wear(self, topic, msg):
+ return self.hsensor.get_wear()
+
+ def get_Hsensor(self, topic, msg):
+ return self.hsensor
+
+ def Hsensor_set_sleep(self, topic, msg):
+ self.hsensor.set_sleep()
+
+ def start_temp(self, topic, msg):
+ WHO_AM_I = bytearray([0x01, 0])
+ I2C_SLAVE_ADDR = 0x49
+ r_data = bytearray(2)
+ data = bytearray([0x61A0, 0]) # 唤醒
+ return self.i2c0.write(I2C_SLAVE_ADDR, WHO_AM_I, 1, data, 2)
+ def stop_temp(self, topic, msg):
+ WHO_AM_I = bytearray([0x01, 0])
+ I2C_SLAVE_ADDR = 0x49
+ r_data = bytearray(2)
+ data = bytearray([0x60A0, 0]) #休眠
+ return self.i2c0.write(I2C_SLAVE_ADDR, WHO_AM_I, 1, data, 2)
+
+ def get_temp(self, topic, msg):
+ WHO_AM_I = bytearray([0x00, 0])
+ I2C_SLAVE_ADDR = 0x49
+ r_data = bytearray(2)
+ self.i2c0.read(I2C_SLAVE_ADDR, WHO_AM_I, 1, r_data, 2, 0)
+ #print("temp_data:{}".format(r_data))
+ temp_s = ((r_data[0]<<8) | (r_data[1]))>>4
+ #print("temp_s:{}".format(temp_s))
+ temp_data = temp_s * 0.0625
+ #print("temp_data:{}".format(temp_data))
+ return temp_data
+
+
+
+ def sim_slot_get(self, topic=None, msg=None):
+ return sim.getCurSimid()
+
+ def sim_slot_switch(self, topic=None, slot=None):
+ """
+ sim 卡槽切换
+ :param topic:
+ :param slot:
+ :return: 切换sim卡卡槽 0 切换成功, 1 无需切换, -1 切换失败
+ """
+ if self.sim_slot_get() == slot:
+ return 1
+ else:
+ return sim.switchCard(slot)
+
+ def usb_event_cb(self, state):
+ status = state
+ if status == 1:#拔出
+ screen_NAME = EventMesh.publish("get_screen_NAME")
+ if screen_NAME != None:
+ if screen_NAME == "poweron" or screen_NAME == "system_init":
+ return
+ bat_tmp = EventMesh.publish("screen_get_battery")
+ if bat_tmp != None:
+ if bat_tmp[0] == "1":
+ EventMesh.publish("load_screen", {"screen": "charge_in"})
+ pass
+ elif status == 0:#插入usb
+ screen_NAME = EventMesh.publish("get_screen_NAME")
+ if screen_NAME != None:
+ if screen_NAME == "poweron" or screen_NAME == "system_init":
+ return
+ bat_tmp = EventMesh.publish("screen_get_battery")
+ if bat_tmp != None:
+ if bat_tmp[0] == "0":
+ EventMesh.publish("load_screen", {"screen": "charge_out"})
+ #EventMesh.publish("battery", self.get_battery())
+
+ def get_usb_state(self):
+ state = self.usb.getStatus()
+ if state == -1:
+ state = 0
+ return state
+
+
+def wifiScan_cb(args):
+ EventMesh.publish(constants.EVENT.WIFIINFO, args)
+ wifiScan.control(0)
+
+class LocationManager(Abstract):
+
+ def __init__(self):
+ self.gps = None
+ #self.match = GPSMatch()
+ self.timer_read_GPS_info = osTimer()
+ self.wifi_data = []
+ self.gps_data = {}
+ self.cell_data = []
+ self.location_timer_count = 0
+ self.location_check_data_timer_count = 0
+ self.GGA_count = 0
+ self.RMC_A_count = 0
+ self.location_type = 0 #定位类型,0:正常定位,有gps数据或60秒关闭;1:测试模式,只有发CLOSE_LOCATION消息才关闭
+ self.location_flag = 0
+ self.start_location_flag = 0
+ self.location_thread_id = 0
+ self.location_queue = Queue(100)
+ self.lpm_fd = None
+ self.start_agps = 0
+ read_data = EventMesh.publish("get_storage_config","isOpenGNSS")#获取是否打开GNSS
+ if read_data != None:
+ self.isOpenGNSS = read_data
+ else:#默认关闭GNSS
+ self.isOpenGNSS = "1"
+ EventMesh.publish("set_storage_config",["isOpenGNSS",self.isOpenGNSS])
+ self.isOpenGNSS = EventMesh.publish("get_storage_config","isOpenGNSS")
+ if self.isOpenGNSS == None:
+ self.isOpenGNSS = "1"
+ print("self.isOpenGNSS",self.isOpenGNSS)
+ if self.isOpenGNSS == "1":
+ quecgnss.init()
+ quecgnss.gnssEnable(0)
+ @staticmethod
+ def get_date():
+ return "{:04d}-{:02d}-{:02d}".format(*utime.localtime()[0:3])
+
+ @staticmethod
+ def get_time():
+ return "{:02d}:{:02d}:{:02d}".format(*utime.localtime()[3:6])
+
+ def post_processor_after_instantiation(self):
+ # _gps_cfg = {
+ # "UARTn": UART.UART1,
+ # "buadrate": 115200,
+ # "databits": 8,
+ # "parity": 0,
+ # "stopbits": 1,
+ # "flowctl": 0,
+ # "PowerPin": Pin.GPIO2,
+ # "StandbyPin": Pin.GPIO3,
+ # "BackupPin": None,
+ # "gps_mode": 0x01,
+ # }
+ # self.gps = GPS(**_gps_cfg)
+ # self.gps.power_switch(0)#关闭GPS
+ EventMesh.subscribe(constants.EVENT.GPSOPEN, self.gps_open)
+ EventMesh.subscribe(constants.EVENT.GPSCLOSE, self.gps_close)
+ EventMesh.subscribe(constants.EVENT.START_LOCATION, self.start_location)
+ EventMesh.subscribe(constants.EVENT.START_LOCATION_TEST, self.start_location_test)
+ EventMesh.subscribe(constants.EVENT.WIFIINFO, self.WIFI_INFO)
+ EventMesh.subscribe(constants.EVENT.WIFISCANOPEN,self.WIFI_scan_open)
+ EventMesh.subscribe(constants.EVENT.CLOSE_LOCATION,self.close_location)
+ EventMesh.subscribe("get_location_flag",self.get_location_flag)
+
+ #EventMesh.subscribe(constants.EVENT.GPSCLOSE, self.gps_close)
+ def get_location_flag(self, event, msg):
+ return self.location_flag
+ def start_location(self, event, msg):
+ self.location_queue.put(msg)#测试类型入队
+ self.gps_data = {}
+ self.wifi_data = []
+ self.cell_data = []
+ self.location_timer_count = 0
+ self.GSV_sig_ok_count = 0
+ print("start_location:{}".format(msg))
+ if( self.location_flag == 1):
+ return
+ self.location_thread_id = _thread.start_new_thread(self.location_thread, ())
+ self.location_flag = 1
+ self.timer_read_GPS_info.start(1000, 1, self.location_timer)
+ #self.gps_open(event, msg)
+
+
+ def start_location_test(self, event, msg):
+ print("start_location_test")
+
+ self.location_type = 1
+ if( self.location_flag == 1):
+ return
+ self.location_thread_id = _thread.start_new_thread(self.location_thread, ())
+ self.location_timer_count = 0
+ self.location_flag = 1
+ #self.gps_open(event, msg)
+ self.location_type = 1
+ self.timer_read_GPS_info.start(1000, 1, self.location_timer)
+
+
+ def close_location(self, event, msg):
+ self.location_flag = 0
+ self.location_type = 0
+ self.timer_read_GPS_info.stop()
+
+
+
+ def WIFI_INFO(self, event, msg):
+ self.wifi_data = msg
+ # print("WIFI_INFO:")
+ # print([msg[0],msg])
+
+ def WIFI_scan_open(self, event, msg):
+ #print("WIFI_scan_open")
+ if wifiScan.getState() == False :
+ self.wifi_data = []
+ wifiScan.control(1)
+ wifiScan.setCfgParam(6, 2, 5, 0) #设置WiFi参数,10秒上层,两轮,最多6个,6秒底层,PS优先
+ wifiScan.setCallback(wifiScan_cb) #注册回调函数
+ wifiScan.asyncStart()
+ #print("wifiScan.asyncStart")
+ else :
+ print("WIFI_scan_open:error1")
+ def gps_open(self, event, msg):
+ if self.isOpenGNSS == "1":
+ #EventMesh.debug_log("publish:gps_open")
+ #quecgnss.init()
+ quecgnss.gnssEnable(2)
+ #self.gps.__gps_nmea_data_clean()
+ def gps_close(self, event, msg):
+ if self.isOpenGNSS == "1":
+ quecgnss.gnssEnable(0)
+ def location_timer(self, *args, **kwargs):
+
+ self.location_timer_count = self.location_timer_count +1
+ self.location_check_data_timer_count = self.location_check_data_timer_count+1
+
+ def Location_send(self, msg) :
+ print("Location_send1")
+ if self.location_queue.empty() == True:
+ return
+ print("Location_send2")
+ while True:
+ if self.location_queue.empty() == False:
+ TYPE = self.location_queue.get()
+ date = "{:04d}{:02d}{:02d},{:02d}{:02d}{:02d}".format(*utime.localtime()[0:6])
+ date = date[2:]
+ #date = "180916,025723"
+ GPS_type = "V"
+ latitude = "0.000000,N"
+ longitude = "0.000000,E"
+ speed = "0.00"
+ direction = "0.0"
+ high = "100.0"
+ number = "0"
+ precision = "24"
+ if msg[0] :#有GPS数据
+ GPS_type = "A"
+ # 纬度
+ latitude = msg[0]["latitude"]
+ # 经度
+ longitude = msg[0]["longitude"]
+ # 速度
+ speed = msg[0]["speed"]
+ # 方向
+ direction = "0"
+ if msg[0]["direction"] :
+ direction = msg[0]["direction"]
+ # 高度
+ high = msg[0]["high"]
+ high_tmp = high.split(".")
+ if len(high_tmp) >= 2 :
+ high = "%s"%(high_tmp[0])
+ # 讯号质量:搜索到的卫星数目
+ number = msg[0]["number"]
+ precision = msg[0]["precision"]
+ #date = msg[0]["date"]
+
+ #gsm 信号强度
+ gsm_sig = str((100//31)*EventMesh.publish("screen_get_sig"))
+ # 电池电量百分比
+ bat_tmp = EventMesh.publish("screen_get_battery")
+ battery_caption = str(bat_tmp[1])
+ #步数
+ old_step = 0
+ step = 0
+ step = EventMesh.publish("get_old_step_value")
+ if step != 0:
+ tmp_data = EventMesh.publish("get_storage_config","old_step_new")
+ if tmp_data != None:
+ old_step = tmp_data
+ if old_step != step:
+ EventMesh.publish("set_storage_config",["old_step",step])
+ EventMesh.publish("set_storage_config",["old_step_new",step])
+
+ old_step = step
+ # step = str(EventMesh.publish(constants.EVENT.GET_STEP)[0])
+ #翻转次数
+ turn_count = "0"
+ #终端状态
+ state = "%08X"%(EventMesh.publish("get_dev_state"))
+ #EventMesh.debug_log("TYPE:{}".format(TYPE))
+ if type(TYPE) == list:#队列里的数据有终端状态,则用队里的终端状态
+ if len(TYPE)>= 2 :
+ state = "%08X"%(TYPE[1])
+
+ print("state:{}".format(state))
+ #基站数据
+ CELL_num = len(msg[2])
+ CELL_data = "1," #时延
+ if msg[2] != []:
+ for CELL in msg[2] :
+ if CELL[0] == 0 :
+ CELL_data += "%X,"%(int(CELL[2])) #MCC
+ CELL_data += str(CELL[3]) +","#MNC
+ CELL_data += str(CELL[5]) +","#tac,区域码
+ CELL_data += str(CELL[1]) +","#基站编号 CID
+ CELL_data += str(int(CELL[7]+140)) +","#信号强度 rssi
+ else :
+ CELL_data += str(CELL[5]) +","#tac,区域码
+ CELL_data += str(CELL[1]) +","#基站编号 CID
+ CELL_data += str(int(CELL[7]+140)) +","#信号强度 rssi
+ CELL_data = CELL_data[:(len(CELL_data)-1)]
+ #WIFI数据
+ WIFI_num = 0
+ WIFI_data = ""
+ if msg[1] :
+ WIFI_num = msg[1][0]
+ i = 0
+ for MAC in msg[1][1] :
+ WIFI_data += "wifi%d,%s,%d,"%(i,str(MAC[0]),MAC[1])
+ i += 1
+ WIFI_data = WIFI_data[:(len(WIFI_data)-1)]
+ WIFI_data = WIFI_data.lower()
+ #send_data = "UD ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%d ,%s ,%d ,%s"\
+ # %(date,GPS_type,latitude,longitude,speed,direction,high,number,gsm_sig,battery_caption,step,turn_count,state,CELL_num,CELL_data,WIFI_num,WIFI_data)
+ #定位数据
+ send_data = "%s,%s,%s"%(date,GPS_type,latitude)
+ send_data += ",%s,%s,%s"%(longitude,speed,direction)
+ send_data += ",%s,%s,%s"%(high,number,gsm_sig,)
+ send_data += ",%s,%s,%s"%(battery_caption,step,turn_count)
+ send_data += ",%s,%d,%s"%(state,CELL_num,CELL_data)
+ send_data += ",%d,%s"%(WIFI_num,WIFI_data)
+ send_data+=",%s"%(precision)
+ #EventMesh.debug_log("Location_send2:{} q_size:{}".format(send_data,self.location_queue.size()))
+
+
+ #EventMesh.debug_log("Location_send3:{}:{}".format(TYPE,send_data))
+ if type(TYPE) == list:
+ EventMesh.publish(TYPE[0],send_data)
+ else:
+ EventMesh.publish(TYPE,send_data)
+ else :
+ break
+
+ def GxGGA_latitude(self, gga_data):
+ """Parse latitude from GGA"""
+ if gga_data:
+ latitude_re = ure.search(r",[0-9]+\.[0-9]+,[NS],", gga_data)
+ if latitude_re:
+ latitude = latitude_re.group(0)[1:-3]
+ return str(float(latitude[:2]) + float(latitude[2:]) / 60)
+ return ""
+ def GxGGA_longitude(self, gga_data):
+ """Parse longitude from GGA"""
+ if gga_data:
+ longitude_re = ure.search(r",[0-9]+\.[0-9]+,[EW],", gga_data)
+ if longitude_re:
+ longitude = longitude_re.group(0)[1:-3]
+ return str(float(longitude[:3]) + float(longitude[3:]) / 60)
+ return ""
+
+ def GxGGA_altitude(self, gga_data):
+ """Parse altitude from GGA"""
+ if gga_data:
+ altitude_re = ure.search(r",-*[0-9]+\.[0-9]+,M,", gga_data)
+ if altitude_re:
+ return altitude_re.group(0)[1:-3]
+ return ""
+ def location_thread(self):
+
+ self.wifi_data = []
+ self.gps_data = {}
+ self.cell_data = []
+ gnss_r_data = []
+ self.GSV_sig_ok_count = 0
+ self.GSV_sig_very_ok_count = 0
+ self.GGA_count = 0
+ self.RMC_A_count = 0
+ # if self.start_agps == 1: #开启agps
+ # self.start_agps = 0
+ # quecgnss.configSet(2,1)
+ if self.lpm_fd == None:
+ self.lpm_fd = pm.create_wakelock("test_lock", len("test_lock"))
+ pm.wakelock_lock(self.lpm_fd)
+ print("location_thread:1")
+ EventMesh.publish(constants.EVENT.GPSOPEN)
+ print("location_thread:2")
+ #self.timer_read_GPS_info.start(1000, 1, self.location_timer)
+ print("location_thread:3")
+ #utime.sleep_ms(1000)
+ self.location_timer_count = 0
+ #quecgnss.read(4096)#去掉第一次错误数据
+ #EventMesh.txt_log("START_LOCATION")
+ # pm.autosleep(0)#唤醒
+ # pm.sclkEx_set(0, 1, 5)
+ GSV_dict= {}
+ while self.location_flag == 1:
+ try :
+
+ match_gga_data = []
+ #match_gsv_data = []
+ gnss_r_data = []
+ # if self.location_check_data_timer_count >= 3:
+ # pm.autosleep(0)#唤醒
+ # pm.sclkEx_set(0, 1, 5)
+ if self.location_check_data_timer_count >= 1 :#3秒查一次基站数据和wifi数据
+ self.location_check_data_timer_count = 0
+ #print(self.location_timer_count)
+ GSV_dict= {}
+ if self.isOpenGNSS == "1":
+ #检查GNSS数据
+ if ( self.gps_data == {} or self.location_type == 1) and quecgnss.get_state() == 2:
+
+ pass
+ tmp_ok_count = 0
+ tmp_very_ok_count = 0
+ gsv_data = quecgnss.get_gsv()
+ rmc_data = quecgnss.get_rmc()
+ gga_data = quecgnss.get_gga()
+ vtg_data = quecgnss.get_vtg()
+ # EventMesh.debug_log("gsv:{}".format(quecgnss.get_gsv()))
+ # EventMesh.debug_log("gga:{}".format(quecgnss.get_gga()))
+ # EventMesh.debug_log("rmc:{}".format(quecgnss.get_rmc()))
+ # EventMesh.debug_log("vtg:{}".format(quecgnss.get_vtg()))
+ for i in range(len(gsv_data)) :
+
+ if i % 2 == 0:
+ if i+1 >= len(gsv_data) :
+ # EventMesh.debug_log("gsv_data num error!!")
+ break
+ GSV_dict[gsv_data[i]] = gsv_data[i+1]
+ #EventMesh.debug_log("type:gsv_data{}".format(type(gsv_data[i+1])))
+ try:
+ #EventMesh.debug_log("gsv_tmp[i+3]:{}".format(gsv_tmp[i+3]))
+ if gsv_data[i+1] :
+ if (gsv_data[i+1])>=20:
+ tmp_ok_count +=1
+ if (gsv_data[i+1])>=30:
+ tmp_very_ok_count +=1
+
+ except Exception as e:
+ usys.print_exception(e)
+
+ if(tmp_ok_count > self.GSV_sig_ok_count ):
+ self.GSV_sig_ok_count = tmp_ok_count
+ if(tmp_very_ok_count > self.GSV_sig_very_ok_count ):
+ self.GSV_sig_very_ok_count = tmp_very_ok_count
+ match_rmc_data = rmc_data.split(",")
+ if len (match_rmc_data)>3: #有rmc数据
+ if match_rmc_data[2] == 'A':
+ match_gga_data = gga_data.split(",")
+ if len(match_gga_data) >4: #数据全
+ match_vtg_data = vtg_data.split(",")
+ gps_date = "%s,%s"%(match_rmc_data[9],match_rmc_data[1][:6])#日期
+ #gps_data_tmp = self.gps.read_coordinates(gnss_r_data[1])
+ latitude = "0,N" #纬度
+ latitude_tmp = str(self.GxGGA_latitude(gga_data)).split(".")
+ if len(latitude_tmp) >= 2 and len(latitude_tmp[1])>=5:
+ latitude = "%s.%s"%(latitude_tmp[0],latitude_tmp[1][:6])
+ latitude = "%s,%s"%(latitude,match_rmc_data[4] )
+
+ longitude = "0,E"#经度
+ longitude_tmp = str(self.GxGGA_longitude(gga_data)).split(".")
+ if len(longitude_tmp) >= 2 and len(longitude_tmp[1])>=5:
+ longitude = "%s.%s"%(longitude_tmp[0],longitude_tmp[1][:6])
+ longitude = "%s,%s"%(longitude,match_rmc_data[6] ) #match_rmc_data[6] + str(gnss_r_data[1])
+
+ high = "0"#高度
+ high = str(self.GxGGA_altitude(gga_data))
+ number = "0"#可用卫星
+ precision = "5.8"#精度
+ if len(match_gga_data)>5 :
+ if match_gga_data[7]:
+ number = match_gga_data[7]
+ if match_gga_data[8]:
+ precision = match_gga_data[8]
+ direction = "249.5" #方向
+ speed = '0.00' #速度
+ if(len(match_vtg_data)>5 ):
+ if match_vtg_data[1]:
+ direction = match_vtg_data[1]
+ if match_vtg_data[7]:
+ speed = match_vtg_data[7]
+ self.gps_data = {
+ "latitude": latitude,
+ "longitude": longitude,
+ "high": high,
+ "direction": direction,
+ "speed": speed,
+ "number": number,
+ "date": gps_date,
+ "precision": precision
+ }
+# ***********************************************************************************
+
+
+ #检查wifi数据
+ if self.wifi_data == [] or (self.wifi_data != [] and self.wifi_data[0] == 0):#and self.wifi_data[0] <= 0:
+ EventMesh.publish(constants.EVENT.WIFISCANOPEN)
+
+ #检查基站数据
+ if self.cell_data == []:
+ data_tmp = net.getCellInfo()
+ if(len(data_tmp)>=2):
+ for cell in data_tmp:
+ if cell and cell[0][0] == 0 and len(cell[0]) > 1:
+ self.cell_data = cell
+ break
+
+ if self.location_type == 1: #测试模式
+ self.location_timer_count = 0
+
+ EventMesh.publish("PUSH_LOCATION_DATA", [[self.gps_data,GSV_dict],self.wifi_data,self.cell_data])
+ if self.gps_data != {} : #发送数据
+ EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位
+ self.location_queue.put(constants.PROTOCOL.UD_SEND)
+ self.Location_send([self.gps_data,self.wifi_data,self.cell_data])
+
+
+ elif self.location_type == 0: #正常模式
+ if self.gps_data != {} or self.location_timer_count > 100: #or( self.wifi_data != [] and self.cell_data != []):
+ if self.location_queue.empty() == False:#有定位队列
+ EventMesh.txt_log("LOCATION timer:{} ok:{} very_ok:{}".format(self.location_timer_count,self.GSV_sig_ok_count,self.GSV_sig_very_ok_count))
+ #EventMesh.txt_log("LOCATION:timer:{} ok_count:{} ".format(self.location_timer_count,self.GSV_sig_ok_count))
+ if self.gps_data == {}: #定位超时,且信噪比多个大于30,下次启动agps
+ if self.GSV_sig_very_ok_count > 3:#3个超30以上
+ self.start_agps = 1
+ EventMesh.txt_log("open agps:{}".format(GSV_dict))
+ #upload_time = EventMesh.publish("get_upload_data")
+ self.Location_send([self.gps_data,self.wifi_data,self.cell_data])
+ #if upload_time > 200 :
+ EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位
+ # else: #定位间隔小于3分钟不关闭gps,不影响无信号判断
+ # self.location_timer_count = 0
+ # self.GSV_sig_ok_count = 0
+
+
+ # if (self.GGA_count < 3 and self.GSV_sig_ok_count < 2) and self.wifi_data and self.cell_data and self.location_timer_count > 30 and self.location_timer_count < 40: #超过20秒且有效卫星个数少于3
+ # EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位
+ # EventMesh.txt_log("GGA_count<3:timer:{} ok_count:{} count:{}".format(self.location_timer_count,self.GSV_sig_ok_count,self.GGA_count))
+ # self.Location_send([self.gps_data,self.wifi_data,self.cell_data])
+
+ if (self.isOpenGNSS != "1" or (self.GSV_sig_ok_count <= 1 and self.location_timer_count > 20)) and self.wifi_data != [] and self.cell_data != [] : #超过40秒且信号大于30的不足3个
+ EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位
+ print("Location_send:CLOSE_LOCATION")
+ #EventMesh.txt_log("GSV_sig_ok_count<3:timer:{} ok_count:{} ".format(self.location_timer_count,self.GSV_sig_ok_count))
+ self.Location_send([self.gps_data,self.wifi_data,self.cell_data])
+ #break
+ # if self.location_type != 1 and self.location_timer_count >= 60*4 : #4分钟关闭
+ # EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位
+ #break
+ #EventMesh.txt_log("self.GSV_sig_ok_count :{}".format(self.GSV_sig_ok_count))
+ #EventMesh.publish("set_old_step_value",self.location_timer_count)
+
+ #print("location_timer_count:{}".format(self.location_timer_count))
+
+ except Exception as e:
+ usys.print_exception(e)
+ EventMesh.txt_log("location_thread:ERROR:".format(e))
+ #print("location_thread:ERROR:{}".format(usys.print_exception(e)))
+ print("self.gps_data{},self.wifi_data{},self.cell_data{}".format(self.gps_data,self.wifi_data,self.cell_data))
+ #self.Location_send([self.gps_data,self.wifi_data,self.cell_data])
+ EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位
+ utime.sleep_ms(500)
+
+ #self.timer_read_GPS_info.stop()
+ #self.gps.power_switch(0)
+ wifiScan.control(0)
+ EventMesh.publish(constants.EVENT.GPSCLOSE)
+ # if EventMesh.publish("get_lcd_state" ) == 0:#休眠的时候,恢复休眠
+ # pm.autosleep(1)
+ # pm.sclkEx_set(1, 1, 5)
+ if self.lpm_fd != None:
+ pm.wakelock_unlock(self.lpm_fd)
+ #pm.delete_wakelock(lpm_fd)
+ print("CLOSE_LOCATION")
+ #EventMesh.txt_log("CLOSE_LOCATION")
+
+
+
+class AddrBookManager(Abstract):
+ # 通讯录
+ def __init__(self):
+ self.read_phonebook = {}
+ self.check_json = 0
+ self.check_json = ql_fs.path_exists("/ext/static/storage_file/phonebook.json")
+
+ if self.check_json == True:
+ with open("/ext/static/storage_file/phonebook.json","r",encoding="utf-8") as fd:
+ self.read_phonebook = ujson.load(fd)
+ print("读取电话本")
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("get_phonebook_list", self.get)
+ EventMesh.subscribe("set_phonebook_list", self.set)
+
+ def get(self, event, msg):
+ self.check_json = ql_fs.path_exists("/ext/static/storage_file/phonebook.json")
+ return [self.check_json,self.read_phonebook]
+
+ def set(self, event, msg):
+ self.check_json = msg[0]
+ self.read_phonebook = msg[1]
+
+import sms
+class MsgManager(Abstract):
+ # 短信
+ def __init__(self):
+ self.msg_nums = 0
+ self.msg_detail = ""
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("get_msg_nums", self.get_msg_nums)
+ # 可通过此push_addr_book_list主动推送
+ EventMesh.subscribe("get_msg_detail", self.get_msg_detail)
+
+ def get_msg_nums(self, event, msg):
+
+ self.msg_nums = sms.getMsgNums()
+ print("self.msg_nums {}:".format(self.msg_nums))
+ return self.msg_nums
+
+ def get_msg_detail(self, event, msg):
+
+ # self.msg_detail = sms.searchTextMsg(self.msg_nums)
+ # print("self.msg_detai {}:".format(self.msg_detai))
+ return{
+ "小明":"有内鬼,停止交易",
+ "小红":"今晚十点一起吃饭"
+ }
+
+class MsgdetailManager(Abstract):
+ def __init__(self):
+ self.level = 0
+ self.msg_name = ""
+ self.msg_content = ""
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("save_msg_name", self.save_msg_name)
+ EventMesh.subscribe("save_msg_content", self.save_msg_content)
+ EventMesh.subscribe("get_msg_name", self.get_msg_name)
+ EventMesh.subscribe("get_msg_content", self.get_msg_content)
+
+ def save_msg_name(self, event, msg):
+ self.msg_name = str(msg)
+ print("save_msg_name:msg".format(msg))
+
+ def save_msg_content(self, event, msg):
+ self.msg_content = str(msg)
+ print("save_msg_content:msg".format(msg))
+
+ def get_msg_content(self, event, msg):
+ return self.msg_content
+
+ def get_msg_name(self, event, msg):
+ return self.msg_name
+
+class CallLogManager(Abstract):
+ # 通话记录
+ def __init__(self):
+ self.read_call_log = {}
+ self.check_json = ql_fs.path_exists("/ext/static/storage_file/Call_log.json")
+
+ if self.check_json == True:
+ with open("/ext/static/storage_file/Call_log.json","r",encoding="utf-8") as fd:
+ self.read_call_log = ujson.load(fd)
+ print("读取通话记录")
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("get_call_log_list", self.get)
+ EventMesh.subscribe("set_call_log_list", self.set)
+
+ def get(self, event, msg):
+ self.check_json = ql_fs.path_exists("/ext/static/storage_file/Call_log.json")
+ return [self.check_json,self.read_call_log]
+
+ def set(self, event, msg):
+ self.check_json = msg[0]
+ self.read_call_log = msg[1]
+ with open("/ext/static/storage_file/Call_log.json","w+",encoding="utf-8") as fd:
+ ujson.dump(self.read_call_log,fd)
+ # def call_usr(self,event,msg):
+ # content = self.log[msg]
+ # # 参数1 姓名 参数2 电话 参数3 1/主动呼叫 0别人呼叫
+ # EventMesh.publish("call_in", [content[2], content[0], 1])
+
+
+
+class PhoneCallingManager(Abstract):
+ def __init__(self):
+ self.phonenum = ""
+ self.phonename = ""
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("save_phonenum", self.save_phonenum)
+ EventMesh.subscribe("get_phonenum", self.get_phonenum)
+ EventMesh.subscribe("get_phonename", self.get_phonename)
+ EventMesh.subscribe("save_phonename", self.save_phonename)
+
+ def get_phonename(self, event, msg):
+ return self.phonename
+
+ def save_phonename(self, event, msg):
+ self.phonename = str(msg)
+
+ def save_phonenum(self, event, msg):
+ self.phonenum = str(msg)
+
+ def get_phonenum(self, event, msg):
+ return self.phonenum
+
+#获取心率 血氧 步数历史数据
+class gethistoryDataManager(Abstract):
+ def __init__(self):
+ self.oldHr = 0
+ self.oldspo2 = 0
+ self.oldstep = 0
+ self.old_step = 0
+ self.read_histroy_hr_data = []
+ self.read_histroy_temp_data = []
+ self.read_histroy_spo2_data = []
+
+ oldHr = EventMesh.publish("get_storage_config","old_hr")
+ if oldHr != None:
+ self.oldHr = oldHr
+ old_spo2 = EventMesh.publish("get_storage_config","old_spo2")
+ if old_spo2 != None:
+ self.oldspo2 = old_spo2
+ old_step = EventMesh.publish("get_storage_config","old_step")
+ if old_step != None:
+ self.oldstep = old_step
+
+
+ check_hr= ql_fs.path_exists("/ext/static/storage_file/history_hr.json")
+ if check_hr == True :
+ with open("/ext/static/storage_file/history_hr.json","r") as fd:#音频文件编号
+ self.read_histroy_hr_data = ujson.load(fd)
+ if self.read_histroy_hr_data == None:
+ self.read_histroy_hr_data = []
+ check_temp= ql_fs.path_exists("/ext/static/storage_file/history_temp.json")
+ if check_temp == True :
+ with open("/ext/static/storage_file/history_temp.json","r") as fd:#音频文件编号
+ self.read_histroy_temp_data = ujson.load(fd)
+ if self.read_histroy_temp_data == None:
+ self.read_histroy_temp_data = []
+ check_spo2= ql_fs.path_exists("/ext/static/storage_file/history_spo2.json")
+ if check_spo2 == True :
+ with open("/ext/static/storage_file/history_spo2.json","r") as fd:#音频文件编号
+ self.read_histroy_spo2_data = ujson.load(fd)
+ if self.read_histroy_spo2_data == None:
+ self.read_histroy_spo2_data = []
+ self.temp_value = 0
+
+ # self.read_histroy_hr_data=[{"timeSec":16789890,"value":90},{"timeSec":16789888,"value":78},{"timeSec":16789688,"value":68},{"timeSec":16789898,"value":58},\
+ # {"timeSec":16789897,"value":88},{"timeSec":16789867,"value":77},{"timeSec":16789895,"value":70}]
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("set_old_hr_data", self.save_hr_value)
+ EventMesh.subscribe("get_old_hr_data", self.get_hr_value)
+ EventMesh.subscribe("set_old_spo2_data", self.save_spo2_value)
+ EventMesh.subscribe("get_old_spo2_data", self.get_spo2_value)
+
+ EventMesh.subscribe("get_old_step_value", self.get_old_step_value)
+ EventMesh.subscribe("set_old_step_value", self.set_old_step_value)
+
+
+ EventMesh.subscribe("get_history_hr_value", self.get_history_hr_value)
+ EventMesh.subscribe("set_history_hr_value", self.set_history_hr_value)
+
+ EventMesh.subscribe("get_history_temp_value", self.get_history_temp_value)
+ EventMesh.subscribe("set_history_temp_value", self.set_history_temp_value)
+
+ EventMesh.subscribe("get_history_spo2_value", self.get_history_spo2_value)
+ EventMesh.subscribe("set_history_spo2_value", self.set_history_spo2_value)
+
+ def get_history_spo2_value(self, event, msg): #近7次血氧历史数据统计显示
+ return self.read_histroy_spo2_data
+
+ def set_history_spo2_value(self, event, msg):
+ pass
+
+
+
+ def get_history_temp_value(self, event, msg): #近7次体温历史数据统计显示
+ return self.read_histroy_temp_data
+
+ def set_history_temp_value(self, event, msg):
+ self.temp_value = msg
+ if self.temp_value > 0:
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ if len(self.read_histroy_temp_data) >= 7:
+ sort_new = {}
+ sort_new = sorted(self.read_histroy_temp_data, key = lambda i: i['timeSec'],reverse = False)#按照时间戳进行排序 去掉最旧的一次数据如果满了五十条
+ print(sort_new)
+ for i in range(len(self.read_histroy_temp_data)-1):
+ sort_new[i] = sort_new[i+1]#0==1 1== 2 2== 3 3==4 4==5 5==6 6==7
+ self.read_histroy_temp_data[i] = sort_new[i]
+ pass
+ self.read_histroy_temp_data[6] = {"timeSec": time_tmp, "temp": self.temp_value}
+ else:
+ self.read_histroy_temp_data.append({"timeSec": time_tmp, "temp": self.temp_value})
+
+ with open("/ext/static/storage_file/history_temp.json","w",encoding="utf-8") as fd:
+ ujson.dump(self.read_histroy_temp_data,fd)
+ #print(self.read_histroy_temp_data)
+ EventMesh.publish("show_history_temp_data")
+
+ def get_history_hr_value(self, event, msg): #近7次心率历史数据统计显示
+ if self.read_histroy_hr_data:
+ return self.read_histroy_hr_data
+ else :
+ return []
+
+ def set_history_hr_value(self, event, msg):
+ pass
+
+
+
+ def save_hr_value(self, event, msg):
+ if msg >= 50:
+ EventMesh.publish("set_storage_config",["old_hr",msg])
+ self.oldHr = msg
+
+
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ if len(self.read_histroy_hr_data) >= 7:
+ sort_new = {}
+ sort_new = sorted(self.read_histroy_hr_data, key = lambda i: i['timeSec'],reverse = False)#按照时间戳进行排序 去掉最旧的一次数据如果满了五十条
+ print(sort_new)
+ for i in range(len(self.read_histroy_hr_data)-1):
+ sort_new[i] = sort_new[i+1]#0==1 1== 2 2== 3 3==4 4==5 5==6 6==7
+ self.read_histroy_hr_data[i] = sort_new[i]
+ pass
+ self.read_histroy_hr_data[6] = {"timeSec": time_tmp, "hr": self.oldHr}
+ else:
+ self.read_histroy_hr_data.append({"timeSec": time_tmp, "hr": self.oldHr})
+
+
+ with open("/ext/static/storage_file/history_hr.json","w",encoding="utf-8") as fd:
+ ujson.dump(self.read_histroy_hr_data,fd)
+ EventMesh.publish("show_history_hr_data")
+ #print(self.read_histroy_hr_data)
+
+
+ def get_hr_value(self, event, msg):
+ return self.oldHr
+
+ def save_spo2_value(self, event, msg):
+ if msg >= 85:
+ EventMesh.publish("set_storage_config",["old_spo2",msg])
+ self.oldspo2 = msg
+
+
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ if len(self.read_histroy_spo2_data) >= 7:
+ sort_new = {}
+ sort_new = sorted(self.read_histroy_spo2_data, key = lambda i: i['timeSec'],reverse = False)#按照时间戳进行排序 去掉最旧的一次数据如果满了五十条
+ print(sort_new)
+ for i in range(len(self.read_histroy_spo2_data)-1):
+ sort_new[i] = sort_new[i+1]#0==1 1== 2 2== 3 3==4 4==5 5==6 6==7
+ self.read_histroy_spo2_data[i] = sort_new[i]
+ pass
+ self.read_histroy_spo2_data[6] = {"timeSec": time_tmp, "spo2": self.oldspo2}
+ else:
+ self.read_histroy_spo2_data.append({"timeSec": time_tmp, "spo2": self.oldspo2})
+
+ with open("/ext/static/storage_file/history_spo2.json","w",encoding="utf-8") as fd:
+ ujson.dump(self.read_histroy_spo2_data,fd)
+ EventMesh.publish("show_history_spo2_data")
+ #print(self.read_histroy_spo2_data)
+
+ def get_spo2_value(self, event, msg):
+ return self.oldspo2
+
+ def set_old_step_value(self, event, msg):
+ self.oldstep = msg
+ EventMesh.publish("set_storage_config",["old_step",msg])
+
+
+ def get_old_step_value(self, event, msg):
+ step = EventMesh.publish(constants.EVENT.GET_STEP)
+ self.old_step = self.oldstep + step[0]
+ return self.old_step
+#获取旧的时间戳
+class getOldTimeManager(Abstract):
+ # 获取天气数据
+ def __init__(self):
+ self.time_sec = 0
+ tmp_data = EventMesh.publish("get_storage_config","old_time")
+ if tmp_data !=None :
+ self.time_sec = tmp_data
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("get_old_time_data", self.get_old_time_data)
+ EventMesh.subscribe("set_old_time_data", self.set_old_time_data)
+
+ def get_old_time_data(self, event, msg):
+ return self.time_sec
+
+ def set_old_time_data(self, event, msg):
+ self.time_sec = msg
+ EventMesh.publish("set_storage_config",["old_time",msg])
+
+
+
+
+
+
+
+class getWeatherDataManager(Abstract):
+ # 获取天气数据
+ def __init__(self):
+ self.date = {} #日期23-04-07
+ self.time = {} #14:41:41
+ self.content = {} #天气描述
+ self.type = None #天气类型
+ self.temp = None #当前温度
+ self.min_temp = None #最低温度
+ self.max_temp = None #最高温度
+ self.city = {} #城市
+ self.no_data = 0#0沒有数据 1有数据
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("get_weather_data", self.get)
+ EventMesh.subscribe("set_weather_data", self.set)
+
+ def get(self, event, msg):
+ return [self.date,self.time,self.content,self.type,self.temp,self.min_temp,self.max_temp,self.city,self.no_data]
+
+ def set(self, event, msg):
+ self.date = msg[0]
+ self.time = msg[1]
+ self.content = msg[2]
+ self.type = msg[3]
+ self.temp = msg[4]
+ self.min_temp = msg[5]
+ self.max_temp = msg[6]
+ self.city = msg[7]
+ self.no_data = msg[8]
+
+
+class getHrTimeManager(Abstract):
+ def __init__(self):
+ self.set_time = 0
+ self.set_hr = 0 #0关闭 1手动 2 自动测量按照时间间隔测试心率
+ self.set_spo2 = 0
+ self.open_btn = 0
+ read_data = EventMesh.publish("get_storage_config","measure_time")
+ if read_data != None:
+ self.set_time = read_data
+ read_data = EventMesh.publish("get_storage_config","open_hr_btn")
+
+ if read_data != None:
+ self.open_btn = read_data
+
+
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("set_time_hr_spo2", self.set_time_hr_spo2)
+ EventMesh.subscribe("get_time_hr_spo2", self.get_time_hr_spo2)
+ EventMesh.subscribe("set_hr_state", self.set_hr_state)
+ EventMesh.subscribe("get_hr_state", self.get_hr_state)
+ EventMesh.subscribe("set_spo2_state", self.set_spo2_state)
+ EventMesh.subscribe("get_spo2_state", self.get_spo2_state)
+
+
+ def set_time_hr_spo2(self, event, msg):
+ self.open_btn = msg[0]
+ self.set_time = msg[1]
+ EventMesh.publish("set_storage_config",["measure_time",self.set_time])
+ EventMesh.publish("set_storage_config",["open_hr_btn",self.open_btn])
+
+ def get_time_hr_spo2(self, event, msg):
+ return [self.open_btn,self.set_time]
+
+ def set_hr_state(self, event, msg):
+ self.set_hr = msg
+
+ def get_hr_state(self, event, msg):
+ if self.set_hr:
+ return self.set_hr
+ else:
+ return 0
+
+ def set_spo2_state(self, event, msg):
+ self.set_spo2 = msg
+
+ def get_spo2_state(self, event, msg):
+ if self.set_spo2:
+ return self.set_spo2
+ else:
+ return 0
+
+#体温
+class getTempTimeManager(Abstract):
+ def __init__(self):
+ self.set_time = 0
+ self.get_temp = 0
+ read_data = EventMesh.publish("get_storage_config","temp_time")
+
+ if read_data != None:
+ self.set_time = read_data
+
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("set_temp_time", self.set_temp_time)
+ EventMesh.subscribe("get_temp_time", self.get_temp_time)
+
+ EventMesh.subscribe("set_temp_state", self.set_temp_state)
+ EventMesh.subscribe("get_temp_state", self.get_temp_state)
+
+
+ def set_temp_time(self, event, msg):
+ self.set_time = msg
+ EventMesh.publish("set_storage_config",["temp_time",self.set_time])
+
+ def get_temp_time(self, event, msg):
+ if self.set_time:
+ return self.set_time
+ else :
+ return 0
+
+ def set_temp_state(self, event, msg):
+ self.get_temp = msg
+
+ def get_temp_state(self, event, msg):
+ if self.get_temp:
+ return self.get_temp
+ else :
+ return 0
+
+class getBrightnessManager(Abstract):#获取亮度级别
+ def __init__(self):
+ self.level = 6#默认值6
+ # self.read_data = {}
+ self.time = 5
+ self.PWM_backlight = None
+
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("get_brightness_level", self.get_brightness_level)
+ EventMesh.subscribe("push_add_brightness_level", self.add)
+ EventMesh.subscribe("push_reduce_brightness_level", self.reduce)
+ EventMesh.subscribe("set_brightness_level", self.set_brightness_level)
+
+ EventMesh.subscribe("set_brightness_time", self.set_brightness_time)
+ EventMesh.subscribe("get_brightness_time", self.get_brightness_time)
+
+ def set_brightness_level(self, event, msg):
+ self.level = msg
+ EventMesh.publish("set_storage_config", ["brightness_level",self.level])
+
+ def get_brightness_level(self, event, msg):
+ tmp = EventMesh.publish("get_storage_config","brightness_level")
+ if tmp != None:
+ self.level = tmp
+ return self.level
+
+ def set_brightness_time(self, event, msg):
+ self.time = msg
+ EventMesh.publish("set_storage_config", ["brightness_time",self.time])
+
+ def get_brightness_time(self, event, msg):
+ tmp = EventMesh.publish("get_storage_config","brightness_time")
+ if tmp != None:
+ self.time = tmp
+ return self.time
+
+
+
+ def add(self, event, msg):
+ if self.level < 10:
+ self.level = self.level + 2
+ self.PWM_backlight = PWM(PWM.PWM1, PWM.ABOVE_MS, self.level, 10)
+ self.PWM_backlight.open()
+ EventMesh.publish("set_storage_config", ["brightness_level",self.level])
+
+
+ def reduce(self, event, msg):
+ if self.level > 0:
+ self.level = self.level - 2
+ if self.level <= 0:
+ self.PWM_backlight = PWM(PWM.PWM1, PWM.ABOVE_MS, 1, 10)
+ else:
+ self.PWM_backlight = PWM(PWM.PWM1, PWM.ABOVE_MS,self.level, 10)
+
+ self.PWM_backlight.open()
+ EventMesh.publish("set_storage_config", ["brightness_level",self.level])
+
+
+class getStorageDataManager(Abstract):#获取内存数据
+ def __init__(self):
+ self.config_data = {}
+ check = ql_fs.path_exists("/ext/static/storage_file/config.json")
+ if check == True:
+ with open("/ext/static/storage_file/config.json","r") as fd:
+ self.config_data = ujson.load(fd)
+ else :
+ self.config_data = {'old_time': 0, 'flip_sw': 0}
+ pass
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("set_storage_config", self.set_storage_config)
+ EventMesh.subscribe("get_storage_config", self.get_storage_config)
+
+ def set_storage_data(self, event, msg):
+ # print("set_storage_data:{}".format(msg))
+ if msg != None:
+ self.config_data = msg
+ with open("/ext/static/storage_file/config.json",'w+',encoding="utf-8") as fd:
+ ujson.dump(self.config_data,fd)
+
+
+ def set_storage_config(self,event,msg):
+ # print("set_storage_key_data1:{}".format(msg))
+ if len(msg) >= 2:
+ self.config_data[msg[0]]=msg[1]
+ # print("set_storage_key_data2:{}".format(self.config_data[msg[0]]))
+ EventMesh.publish("publish_message_event_ui",{"func":self.set_storage_save,"data":0})
+ def set_storage_save(self, data):
+ with open("/ext/static/storage_file/config.json",'w+',encoding="utf-8") as fd:
+ ujson.dump(self.config_data,fd)
+ def get_storage_data(self, event, msg):
+ # print("get_storage_data:{}".format(self.config_data))
+ return self.config_data
+ def get_storage_config(self,event,msg):
+ # print("get_storage_key_data1:{}".format(msg))
+ b = msg in self.config_data.keys()
+ if b == True:
+ # print("get_storage_key_data2:{}".format(self.config_data[msg]))
+ return self.config_data[msg]
+ else :
+ return None
+ # try:
+ # return self.config_data[msg]
+ # except:
+ # print("get_storage_key_data:none key:{}",msg)
+ # return None
+#定位频率
+class getUpLoadDataManager(Abstract):#
+ def __init__(self):
+ self.upload_time = 1800
+ read_data = EventMesh.publish("get_storage_config","upload_time")
+ if read_data != None:
+ self.upload_time = read_data
+
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("set_upload_data", self.set_upload_data)
+ EventMesh.subscribe("get_upload_data", self.get_upload_data)
+
+ def set_upload_data(self, event, msg):
+ self.upload_time = msg
+
+ def get_upload_data(self, event, msg):
+ return self.upload_time
+
+class getplayAudiodStateManager(Abstract):#获取设置播放音频状态
+ def __init__(self):
+ self.play = 0
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("set_audio_state", self.set_audio_state)
+ EventMesh.subscribe("get_audio_state", self.get_audio_state)
+
+ def set_audio_state(self, event, msg):
+ self.play = msg
+
+ def get_audio_state(self, event, msg):
+ return self.play
+
+class getVolumSizeManager(Abstract):#设置或获取音量大小数据
+ def __init__(self):
+ self.volume_size = 8
+ read_data = EventMesh.publish("get_storage_config","volum")
+ if read_data != None:
+ self.volume_size = read_data
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("set_volum_size", self.set_volum_size)
+ EventMesh.subscribe("get_volum_size", self.get_volum_size)
+
+ def set_volum_size(self, event, msg):
+ self.volume_size = msg
+ EventMesh.publish("set_storage_config", ["volum",self.volume_size])
+
+ def get_volum_size(self, event, msg):
+ return self.volume_size
+
+class getSosFlagManager(Abstract):#设置sos
+ def __init__(self):
+ self.sos_flag = 0
+ self.sos_num = 0
+ self.hangup_mode = 0
+ self.call_timer = osTimer()
+ self.sos_numer1 = []
+ self.callnumer =""
+ SOS_NUMBER1 = EventMesh.publish("get_storage_config","SOS_NUMBER1")
+ if SOS_NUMBER1 != None:
+ self.sos_numer1 = SOS_NUMBER1
+ SOS_NUMBER2 = EventMesh.publish("get_storage_config","SOS_NUMBER2")
+ if SOS_NUMBER2 != None:
+ self.sos_numer1 = [SOS_NUMBER1, SOS_NUMBER2]
+
+ SOS_NUMBER3 = EventMesh.publish("get_storage_config","SOS_NUMBER3")
+ if SOS_NUMBER3 != None:
+ self.sos_numer1 = [SOS_NUMBER1, SOS_NUMBER2,SOS_NUMBER3]
+
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("set_sos_flag", self.set_sos_flag)#设置sos拨打标识
+ EventMesh.subscribe("get_sos_flag", self.get_sos_flag)
+
+ EventMesh.subscribe("set_sos_num", self.set_sos_num)#设置拨打循环次数
+ EventMesh.subscribe("get_sos_num", self.get_sos_num)
+
+ EventMesh.subscribe("set_dial_sos_number", self.set_dial_sos_number)
+ EventMesh.subscribe("get_dial_sos_number", self.get_dial_sos_number)#设置家庭号码三个
+
+ EventMesh.subscribe("set_callnumer_cb", self.set_callnumer_cb)#延时回调
+
+ EventMesh.subscribe("set_hangup_mode", self.set_hangup_mode)
+ EventMesh.subscribe("get_hangup_mode", self.get_hangup_mode)#获取挂断方式 是对方挂断 还是手表按键主动挂断
+
+ EventMesh.subscribe("close_sos_timer",self.close_sos_timer)
+
+ def get_hangup_mode(self, event, msg): # 1是设备端手表主动挂断 0是手机端
+ return self.hangup_mode
+
+ def set_hangup_mode(self, event, msg):
+ self.hangup_mode = msg
+
+ def set_sos_flag(self, event, msg):
+ self.sos_flag = msg
+
+ if self.sos_flag == 1:
+ number = EventMesh.publish("get_dial_sos_number")
+
+ if number != None:
+ if len(number) > 0:
+ sos_state = EventMesh.publish("get_dev_state")
+ tmp = 1 << 16
+ sos_state = sos_state|tmp #第16位=1
+ EventMesh.publish("set_dev_state",sos_state)
+
+ EventMesh.publish(constants.EVENT.START_LOCATION,[constants.PROTOCOL.AL_SEND,sos_state]) #开始AL定位
+
+ EventMesh.publish("save_phonename",number[0])
+ EventMesh.publish("save_phonenum",number[0])
+ EventMesh.publish("set_sos_num",0)
+ EventMesh.publish("load_screen", {"screen": "dialing_noplay_popup"})
+ #voiceCall.callStart(str(number[0]))
+
+ def set_callnumer_cb(self, event, msg):
+ if self.sos_flag == 1:
+ self.callnumer = msg
+ self.call_timer.start(10000, 0, self.call_timer_cb)#延迟10S 继续拨打
+
+ def call_timer_cb(self, *args, **kwargs):
+ sos_state = EventMesh.publish("get_dev_state")
+ tmp = 1 << 16
+ sos_state = sos_state|tmp #第16位=1
+ EventMesh.publish("set_dev_state",sos_state)
+
+ EventMesh.publish(constants.EVENT.START_LOCATION,[constants.PROTOCOL.AL_SEND,sos_state]) #开始AL定位
+ # print("call_timer_cb:{}".format(self.callnumer))
+ EventMesh.publish("save_phonename",str(self.callnumer))
+ EventMesh.publish("save_phonenum",str(self.callnumer))
+ EventMesh.publish("load_screen", {"screen": "dialing_noplay_popup"})
+
+ def close_sos_timer(self,event,msg):
+ self.call_timer.stop()
+ pass
+
+ def get_sos_flag(self, event, msg):
+ return self.sos_flag
+
+ def set_sos_num(self, event, msg):
+ self.sos_num = msg
+
+ def get_sos_num(self, event, msg):
+ return self.sos_num
+
+ def set_dial_sos_number(self, event, msg):
+ self.sos_numer1 = msg
+
+
+ def get_dial_sos_number(self, event, msg):
+ return self.sos_numer1
+class getLowBatManager(Abstract):#低电提醒
+ def __init__(self):
+
+ self.low_btn = 0
+ read_data = EventMesh.publish("get_storage_config","low_on")
+ if read_data != None:
+ self.low_btn = read_data
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("set_low_bat_btn", self.set_low_bat_btn)#
+ EventMesh.subscribe("get_low_bat_btn", self.get_low_bat_btn)
+
+ def set_low_bat_btn(self, event, msg):
+ self.low_btn = msg
+ EventMesh.publish("set_storage_config",["low_on",self.low_btn])
+
+ def get_low_bat_btn(self, event, msg):
+ return self.low_btn
+
+
+
+class playPowerAudioManager(Abstract):#播放开关机音频文件
+ def __init__(self):
+ self.aud = audio.Audio(0)
+
+ def post_processor_after_instantiation(self):
+
+ EventMesh.subscribe("play_poewr_on_event", self.play_poewr_on_event)#
+ EventMesh.subscribe("play_poewr_off_event", self.play_poewr_off_event)
+
+ def play_poewr_on_event(self, event, msg):
+ self.aud.play(1, 1, 'E:/static/R_POWER_1.mp3') #播放播放开机铃声
+
+ def play_poewr_off_event(self, event, msg):
+ self.aud.setVolume(11)
+ self.aud.play(1, 1, 'E:/static/R_POWER_OFF_1.mp3') #播放关机铃声
+
+class getBootOffManager(Abstract):#开关机时间
+ def __init__(self):
+ self.off_msg = {}
+ self.off_flag = 0
+ self.rtc = RTC()
+
+ read_data = EventMesh.publish("get_storage_config","off_on")
+ if read_data != None:
+ self.off_on = read_data
+ read_data = EventMesh.publish("get_storage_config","off_start")
+ if read_data != None:
+ self.off_start= read_data
+ read_data = EventMesh.publish("get_storage_config","off_end")
+ if read_data != None:
+ self.off_end = read_data
+
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("set_boot_off_time", self.set_boot_off_time)#设置关机时间
+ EventMesh.subscribe("get_boot_off_time", self.get_boot_off_time)
+
+ def set_boot_off_time(self, event, msg):
+ EventMesh.publish("get_storage_config",["off_on",msg[0]])
+ EventMesh.publish("get_storage_config",["off_start",msg[1]])
+ EventMesh.publish("get_storage_config",["off_end",msg[2]])
+ self.off_msg = msg
+
+
+ def get_boot_off_time(self, event, msg):
+ flag = 0
+ msg_tmp = EventMesh.publish("get_check_alarm_list")
+ # print("len(msg_tmp):{} len(self.off_msg):{}".format(msg_tmp,len(self.off_msg)))
+ if len(self.off_msg) > 0:
+ if msg_tmp > len(self.off_msg)-1:#判断闹钟是否有数据 总的数据大于开关机的时间 说明有闹钟列表
+ flag = 1
+ else:
+ flag = 0
+ else:
+ if msg_tmp > 0:
+ flag = 1
+
+ return [self.off_msg,flag]
+class setSmsIndexManager(Abstract):#
+ def __init__(self):
+ self.index = -1
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("set_sms_index", self.set_sms_index)#设置关机时间
+ EventMesh.subscribe("get_sms_index", self.get_sms_index)
+
+ def set_sms_index(self, event, msg):
+ self.index = msg
+
+
+ def get_sms_index(self, event, msg):
+
+ return self.index
+
+class testSmsSetIPManager(Abstract):#
+ def __init__(self):
+ self.timer = osTimer()
+ self.newip = "api.xcloudtech.com"#默认防走丢协议
+ self.newcom = 9000
+ self.newmd5 = "bZld0ALsZTt15tKEZhOlLPgbsO75BLTP"
+ tmp_data = EventMesh.publish("get_storage_config","set_new_ip_addr")
+ if tmp_data != None:
+ self.newip = tmp_data
+ tmp_data = EventMesh.publish("get_storage_config","set_new_com")
+ if tmp_data != None:
+ self.newcom = tmp_data
+ tmp_data = EventMesh.publish("get_storage_config","set_new_md5")
+ if tmp_data != None:
+ self.newmd5 = tmp_data
+
+
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("set_new_ip", self.set_new_ip)#设置关机时间
+ EventMesh.subscribe("get_new_ip", self.get_new_ip)
+
+ def set_new_ip(self, event, msg):
+ self.newip = str(msg[0])
+ self.newcom = int(msg[1])
+ # self.newmd5 = str(msg[2])
+ #短信格式:SETIP:api.xcloudtech.com:9000:bZld0ALsZTt15tKEZhOlLPgbsO75BLTP 以冒号分隔 SETIP:ip地址:ip端口号:ip密钥key
+
+ # self.read_data["set_new_md5"] = self.newmd5 #通过短信设置ip的key密钥
+ EventMesh.publish("set_storage_config",["set_new_ip_addr",self.newip])
+ EventMesh.publish("set_storage_config",["set_new_com",self.newcom])
+
+ number = str(msg[2])
+ sms.sendPduMsg(number, 'set ok', 'UCS2')
+ self.timer.start(10*1000,0,self.fun)
+
+ def fun(self,*argc):
+ Power.powerRestart()
+
+ def get_new_ip(self, event, msg):
+ tmp_data = EventMesh.publish("get_storage_config","set_new_ip_addr")
+ # return [self.newip,self.newcom,self.newmd5]
+ if(tmp_data != None):
+ return [self.newip,self.newcom]
+
+
+class setCallStateManager(Abstract):#设置电话通话状态
+ def __init__(self):
+ self.call_state = 0
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("set_call_state", self.set_call_state)#设置关机时间
+ EventMesh.subscribe("get_call_state", self.get_call_state)
+
+ def set_call_state(self, event, msg):
+ self.call_state = msg
+
+
+ def get_call_state(self, event, msg):
+
+ return self.call_state
+
+class setclassTimeManager(Abstract):#设置上课禁用时间
+ def __init__(self):
+ self.class_buf = {}
+ self.class_state = 0
+ check_json = ql_fs.path_exists("/ext/static/storage_file/class_msg.json")
+
+ if check_json == True:
+ with open("/ext/static/storage_file/class_msg.json","r",encoding="utf-8") as fd:
+ self.class_buf = ujson.load(fd)
+ print("读取上课禁用时间段")
+ # print("self.class_buf:",self.class_buf)
+
+
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("set_class_time", self.set_class_time)#设置上课禁用时间段
+ EventMesh.subscribe("get_class_time", self.get_class_time)
+ EventMesh.subscribe("get_cur_class_time_state", self.get_cur_class_time_state)
+ EventMesh.subscribe("get_class_in_time_page",self.get_class_in_time_page)
+
+ def set_class_time(self, event, msg):
+ self.class_buf = msg
+ # print("self.class_buf",self.class_buf)
+
+
+ def get_class_time(self, event, msg):
+
+ return self.class_buf
+
+ def get_cur_class_time_state(self, event, msg):
+ data = RTC().datetime()
+ hour = data[4]#当前小时
+ min = data[5]#当前分钟
+
+ cur_week = data[3]#星期几
+
+
+
+ cur_hour = hour
+ cur_min = min
+ cur_total_min = cur_hour*60+cur_min
+ #print("cur_total_min",cur_total_min)
+
+ start_time1 = 0
+ end_time1 = 0
+ week1 = []
+ enable1 = 0
+
+ start_time2 = 0
+ end_time2 = 0
+ week2 = []
+ enable2 = 0
+
+ start_time3 = 0
+ end_time3 = 0
+ week3 = []
+ enable3 = 0
+
+ start_time4 = 0
+ end_time4 = 0
+ week4 = []
+ enable4 = 0
+
+ self.class_state = 0
+ # {'1': {'enabled': 1, 'end_hour': '17:00', 'start_hour': '10:00', 'week': [1, 2, 3, 4, 5]},
+ # '0': {'enabled': 1, 'end_hour': '17:00', 'start_hour': '08:00', 'week': [1, 2, 3, 4, 5]},
+ # '3': {'enabled': 1, 'end_hour': '17:00', 'start_hour': '08:00', 'week': [1, 2, 3, 4, 5]},
+ # '2': {'enabled': 1, 'end_hour': '17:00', 'start_hour': '08:00', 'week': [1, 2, 3, 4, 5]}}
+ # print("self.class_buf time:",self.class_buf)
+ if len(self.class_buf) != 0:
+ #19:56; 9:16
+ data1 = self.class_buf["0"]
+ start_time1 = int(data1["start_time"].split(":")[0])*60+int(data1["start_time"].split(":")[1])
+ end_time1 = int(data1["end_time"].split(":")[0])*60 + int(data1["end_time"].split(":")[1])
+
+ week1 = data1["week"]
+ enable1 = data1["enable"]
+
+ data2 = self.class_buf["1"]
+ start_time2 = int(data2["start_time"].split(":")[0])*60 + int(data2["start_time"].split(":")[1])
+ end_time2 = int(data2["end_time"].split(":")[0])*60 + int(data2["end_time"].split(":")[1])
+
+ week2 = data2["week"]
+ enable2 = data2["enable"]
+
+ data3 = self.class_buf["2"]
+ start_time3 = int(data3["start_time"].split(":")[0])*60 + int(data3["start_time"].split(":")[1])
+ end_time3= int(data3["end_time"].split(":")[0])*60 + int(data3["end_time"].split(":")[1])
+
+ week3 = data3["week"]
+ enable3 = data3["enable"]
+
+ data4 = self.class_buf["3"]
+ start_time4= int(data4["start_time"].split(":")[0])*60 + int(data4["start_time"].split(":")[1])
+ end_time4 = int(data4["end_time"].split(":")[0])*60 + int(data4["end_time"].split(":")[1])
+
+ week4 = data4["week"]
+ enable4 = data4["enable"]
+ week1_state = 0
+ week2_state = 0
+ week3_state = 0
+ week4_state = 0
+ # print("end_time1 ",start_time1,end_time1,start_time2,end_time2,start_time3,end_time3,start_time4,end_time4)
+ for i in range(0,7):
+ if ((cur_week in week1) and enable1 == 1):
+ week1_state = 1
+ if ((cur_week in week2) and enable2 == 1):
+ week2_state = 1
+
+ if ((cur_week in week3) and enable3 == 1):
+ week3_state = 1
+
+ if ((cur_week in week4) and enable4 == 1):
+ week4_state = 1
+
+ if ((cur_week in week1) and enable1 == 1) or ((cur_week in week2) and enable2 == 1) or\
+ ((cur_week in week3) and enable3 == 1) or ((cur_week in week4) and enable4 == 1):
+ if enable1 == 1 or enable2 == 1 or enable3 == 1 or enable4 == 1:
+ if week1 != [] or week2 != [] or week3 != [] or week4 != []:
+ if (end_time1 > start_time1 and enable1 == 1 and week1_state == 1) or (end_time2 > start_time2 and enable2 == 1 and week2_state == 1) or\
+ (end_time3 > start_time3 and enable3 == 1 and week3_state == 1) or (end_time4 > start_time4 and enable4 == 1 and week4_state == 1):
+ if (cur_total_min <= end_time1 and cur_total_min >= start_time1 and enable1 == 1) or (cur_total_min <= end_time2 and cur_total_min >= start_time2 and enable2 == 1) or\
+ (cur_total_min <= end_time3 and cur_total_min >= start_time3 and enable3 == 1) or (cur_total_min <= end_time4 and cur_total_min >= start_time4 and enable3 == 1):
+ self.class_state = 1
+ print("class_in1")
+ break
+ else:#开始时间小于结束时间属于垮天 9:00 -7:00 7*60 6:00
+
+ # print("end_time1!!!!!!!!!",start_time1,end_time1,start_time2,end_time2,start_time3,end_time3,start_time4,end_time4)
+ if (((end_time1 >= cur_total_min or cur_total_min >= start_time1) and enable1 == 1 and week1_state == 1)or \
+ ((end_time2 >= cur_total_min or cur_total_min >= start_time2) and enable2 == 1 and week2_state == 1) or\
+ ((end_time3 >= cur_total_min or cur_total_min >= start_time3) and enable3 == 1 and week3_state == 1) or \
+ ((end_time4 >= cur_total_min or cur_total_min >= start_time4) and enable4 == 1 and week4_state == 1)):
+ self.class_state = 1
+ print("class_in2")
+ break
+
+
+ return self.class_state
+
+ def get_class_in_time_page(self, event, msg):
+ EventMesh.publish("get_cur_class_time_state")
+ phone_call = EventMesh.publish("get_UI_high_priority")
+
+ screen_NAME = EventMesh.publish("get_screen_NAME")
+ if self.class_state == 1:
+ if screen_NAME != None:
+ if screen_NAME != "system_init" or screen_NAME != "poweron":
+ if screen_NAME != "class_time" and phone_call == 0:
+ EventMesh.publish("load_screen", {"screen": "class_time"})
+ else:
+ if screen_NAME != None:
+ if screen_NAME == "class_time":
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ pass
+
\ No newline at end of file
--- /dev/null
+# -*- coding: UTF-8 -*-
+import audio
+from machine import Pin
+import utime
+import uos
+
+def audio_cb(event):
+ if event == 0:
+ print('audio-play start.')
+ elif event == 7:
+ print('audio-play finish.')
+
+aud = audio.Audio(0)
+aud.setCallback(audio_cb)
+
+# 音频流播放
+size = 4*1024 # 保证一次填充的音频数据足够大以便底层连续播放
+format = 1
+
+def play_from_fs():
+ file_size = uos.stat("/usr/audio_incoming_call.wav")[6] # 获取文件总字节数
+ print(file_size)
+ with open("/usr/audio_incoming_call.wav", "rb")as f:
+ b = f.read(44)
+ while 1:
+ b = f.read(size) # read
+ print("play_from_fs:len:{}".format(len(b)))
+ if not b:
+ break
+ aud.playStream(format, b)
+ #utime.sleep_ms(20)
+
+
+play_from_fs()
+# 等待播放完成
+utime.sleep_ms(5000)
+# 停止本次播放以便不影响下次播放
+aud.stopPlayStream()
--- /dev/null
+import ujson
+import utime
+import EventMesh
+import constants
+from common import Abstract
+import uhashlib
+import ubinascii
+from misc import Power
+import audio
+from machine import Pin
+import ujson
+import ql_fs
+import dataCall
+import checkNet
+import net
+import usocket
+import osTimer
+
+import machine
+import urandom
+import _thread
+import usys
+import request
+import umqtt
+import modem
+SHA256 = uhashlib.sha256
+import SecureData
+def server_init(server_type = None):
+ #服务器选择1,防走丢,2大锤,3三基同创,4童信,5云米,6荣为 8:ds未知 dey.hinwatch. com:9968 9:183.62.239.121:31869 10:183.62.239.121:33461
+ if server_type == None:
+ server_type = 2
+ #EventMesh.debug_log("server_init:server_type:{}".format(server_type))
+
+ d_server_addr = "api.xcloudtech.com"
+ d_server_port = 9000
+ d_md5_key = "bZld0ALsZTt15tKEZhOlLPgbsO75BLTP"
+ d_PID = "SZKW"
+ if server_type == 1:
+ pass
+
+ elif server_type == 2:
+ # test.iot.socket.thisiot.com:9999
+ # iot.socket .thisiot.com:9999
+ # d_server_addr = "test.iot.socket.thisiot.com"
+ # d_server_port = 9999
+ # d_md5_key = "3JyCjsw4ryXKzjzudayY"
+ # d_PID = "qAELPTKmFanR4RHe"
+
+ d_server_addr = "iot.socket.thisiot.com"
+ d_server_port = 9999
+ d_md5_key = "SZYhyGhroQ3xFKFWZq1g"
+ d_PID = "oxLwDqcwJCtiPSRu"
+
+ elif server_type == 3:
+ d_server_addr = "tcp.zhihuixuexiao.com"
+ d_server_port = 2346
+ d_md5_key = ""
+ d_PID = "3G"
+ elif server_type == 4:
+ d_server_addr = "tcp.tx.kidxin.com"
+ d_server_port = 20500
+ elif server_type == 5:
+ d_server_addr = "device.miwitracker.com"
+ d_server_port = 8505
+ d_md5_key = ""
+ d_PID = "3G"
+ elif server_type == 6:
+ d_server_addr = "120.26.104.21"
+ d_server_port = 9968
+ d_md5_key = "bZld0ALsZTt15tKEZhOlLPgbsO75BLTP"
+ d_PID = "SZKW"
+ elif server_type == 7:
+ d_server_addr = "8.134.68.15"
+ d_server_port = 30346
+ d_PID="KnHnj1Cd5VxcO3Ft"
+ d_md5_key = "evxThVhMBmRNiQ1Twigw"
+ elif server_type == 99:
+ d_server_addr = "lab.xcloudtech.com"
+ d_server_port = 9000
+ elif server_type == 8:
+ d_server_addr = "dev.hxinwatch.com"
+ d_server_port = 9968
+ elif server_type == 9:
+ d_server_addr = "183.62.239.121"
+ d_server_port = 31869
+ elif server_type == 10:
+ d_server_addr = "183.62.239.121"
+ d_server_port = 33461
+
+ return [d_server_addr,d_server_port,d_md5_key,d_PID]
+from queue import Queue
+def unicode_to_utf8(src):
+ ref = 0xe08080
+ result = ref
+
+ #取最后六位
+ a = src & 0x3f
+
+ #将最后六位放在ref最后六位的空位置
+ result = result | a
+ src = src >> 6
+
+ #取接下来的六位
+ a = src & 0x3f
+
+ #放在ref对应的六个位置
+ result = result | (a << 8)
+
+ #保留最后四位
+ src = src >> 6
+
+ #放在ref对应的四个位置
+ result = result | (src << 16)
+ return result
+
+def UnicodeHexStr_To_Utf8Str(str):
+ odata = 0
+
+ result = bytes()
+ su =str.upper()
+
+ i = 0
+ for c in su:
+ tmp=ord(c)
+ if tmp <= ord('9') :
+ odata = odata << 4
+ odata += tmp - ord('0')
+
+ elif ord('A') <= tmp <= ord('F'):
+ odata = odata << 4
+ odata += tmp - ord('A') + 10
+ if(i%4==3): #每2字节获取一个int,拿到转换后的unicode int
+ #print(odata.to_bytes(2, 'big'))
+ #result.append(odata)
+ if odata > 255:
+ tmp = unicode_to_utf8(odata)#拿到转换后的utf8 int
+ tmp2 = tmp.to_bytes(3, 'big') #转bytes
+ else :
+ tmp2 = odata.to_bytes(1, 'big')
+ #print("tmp2:{}".format(tmp2))
+ result = result + tmp2
+ odata = 0
+ i+=1
+ return result.decode('utf-8') #返回utf8的str
+
+def gewu_init():
+ productKey = "cu1shld45y4hjr1L"
+ return productKey
+mqtt_state = 0
+def mqttsub_cb(topic, msg):
+ global mqtt_state
+ print("Subscribe Recv: Topic={},Msg={}".format(topic.decode(), msg.decode()))
+ jsload_data = ujson.loads(msg.decode())
+ print("jsload_data-{} type:{}".format(jsload_data,type(msg.decode())))
+ # jsload_data = {'data':'111','protocolType':'', 'host':'device.miwitracker.com', 'secretKey': 'bZld0ALsZTt15tKEZhOlLPgbsO75BLTP', 'port':8505, 'bid': '3G', 'extJsonStr': ''}
+ # ujson.loads(c)
+ # $sys/cu1shld45y4hjr1L/866610001011658/ext/regist
+ #data = {"messageId":"25","params":{"deviceSecret":"C1D75A63C0338978438E9197372FC698""}}
+ if "params" in jsload_data:
+ params_str = jsload_data["params"]
+ if "deviceSecret" in params_str:
+ str_tmp = params_str["deviceSecret"]
+ print(str_tmp)
+ EventMesh.publish("set_deviceSecret",str_tmp)
+ mqtt_state = 1
+def mqtterr_cb(error):
+ '''
+ 接收umqtt线程内异常的回调函数
+ '''
+ print("error!!!!!!!!!!!".format(error))
+
+def HMAC(k, m):
+ SHA1_BLOCK_SIZE = 64
+ KEY_BLOCK = k + (b'\0' * (SHA1_BLOCK_SIZE - len(k)))
+ KEY_INNER = bytes((x ^ 0x36) for x in KEY_BLOCK)
+ KEY_OUTER = bytes((x ^ 0x5C) for x in KEY_BLOCK)
+ inner_message = KEY_INNER + m
+ outer_message = KEY_OUTER + SHA256(inner_message).digest()
+ return SHA256(outer_message)
+
+
+def get_hmac_sha256(k, m):
+ data = HMAC(k, m).digest()
+ # print("HMAC(k, m).digest():", data)
+ # print("HMAC(k, m).digest():", ubinascii.hexlify(data))
+ hex_data = ubinascii.hexlify(data)
+ hex_data = hex_data.decode('ascii')
+ return hex_data
+
+def mqtt_client_pro_init():#一型一密
+ client = 0
+
+ # 创建一个mqtt实例
+#
+ # {"productKey":"cu1r1rjjrjdhz0lx","deviceKey":"DD86000000001","deviceSecret":"93FEEC6D16D30E2B90FE0DBC2FFCDB14"} 设备基本信息
+ # hmac_sha256(deviceIddeviceKeyproductKey,deviceSecret) mqttclientId
+ deviceId = ""#"bOOSGN5FlXEjt15"
+ deviceKey = ''#"bOOSGN5FlXEjt15"
+ imei = EventMesh.publish(constants.EVENT.GET_IMEI)
+ deviceId = str(imei)
+ deviceKey = str(imei)
+ productKey = gewu_init()
+
+ EventMesh.publish("set_product_key",productKey)
+ data = "{}{}{}".format(deviceId,deviceKey,productKey)#需要用户定义产品是提供数据
+ # data = b"The data to encrypt"
+ # 密钥
+ productSecret = b"765fc66242616852209d1c57e51b0744" #765fc66242616852209d1c57e51b0744 ,productSecret
+
+ # {"productKey":"cu1shld45y4hjr1L","deviceKey":"bOOSGN5FlXEjt15","deviceSecret":"9234577490038E0949B800C243BF4321"}
+ checkpassword = get_hmac_sha256(productSecret,data)
+ # print(checkpassword)
+ # {deviceId}|{productKey}|{signMethod}|{authType}|{operator};连接id格式
+
+ Client_id = "{}|{}|0|1|0".format(deviceId,productKey) #
+ # print(Client_id)
+ server = "dmp-mqtts.cuiot.cn"#"dmp-mqtt.cuiot.cn"
+ port = 8883
+ # {deviceKey}|{productKey} mqttUsername
+ userName = "{}|{}".format(deviceKey,productKey)
+ userpassword = checkpassword
+ # print(userName)
+ # print(userpassword)
+ # client = umqtt.MQTTClient("866610001011658|cu1shld45y4hjr1L|0|1|0","dmp-mqtt.cuiot.cn", 1883, "866610001011658|cu1shld45y4hjr1L","675f6fbfb15a729bbc280273632ce3a96f8b38d4736fbaf888fe8a48fd7aee09")
+ # client = umqtt.MQTTClient("lxRXQayZ4poQz8G|cujg06l29iav591b|0|0|0","dmp-mqtt.cuiot.cn", 1883, "lxRXQayZ4poQz8G|cujg06l29iav591b","1f8c69d29afca0505d967066b39d84a5eb1e54302b87e337b405f99d029a9242")
+ client = umqtt.MQTTClient(Client_id,server, port, userName,"{}".format(userpassword),reconn=False,ssl=True)
+ # client = MqttClient(Client_id, server, port, userName,"{}".format(userpassword))
+ # 设置消息回调
+ client.set_callback(mqttsub_cb)
+ # 设置异常回调
+ client.error_register_cb(mqtterr_cb)
+ return client
+
+def mqtt_client_dev_init():#一机一密
+ client = 0
+
+ # 创建一个mqtt实例
+#
+ # {"productKey":"cu1r1rjjrjdhz0lx","deviceKey":"DD86000000001","deviceSecret":"93FEEC6D16D30E2B90FE0DBC2FFCDB14"} 设备基本信息
+ # hmac_sha256(deviceIddeviceKeyproductKey,deviceSecret) mqttclientId
+ deviceId = '' #"bOOSGN5FlXEjt15"
+ deviceKey = ''#"bOOSGN5FlXEjt15"
+ imei = EventMesh.publish(constants.EVENT.GET_IMEI)
+ deviceId = str(imei)
+ deviceKey = str(imei)
+ productKey = gewu_init()
+ data = "{}{}{}".format(deviceId,deviceKey,productKey)#需要用户定义产品是提供数据
+ # data = b"The data to encrypt"
+ # 密钥
+ deviceSecret_tmp = EventMesh.publish("get_deviceSecret")
+ subscribe_msg = deviceSecret_tmp.encode('ascii')
+ deviceSecret = subscribe_msg #765fc66242616852209d1c57e51b0744 ,productSecret
+ print(deviceSecret)
+
+ checkpassword = get_hmac_sha256(deviceSecret,data)
+ print(checkpassword)
+ # {deviceId}|{productKey}|{signMethod}|{authType}|{operator};连接id格式
+ Client_id = "{}|{}|0|0|0".format(deviceId,productKey) # 860132060346475|cu1shld45y4hjr1L|0|0|0
+ server = "dmp-mqtts.cuiot.cn"#"dmp-mqtt.cuiot.cn"
+ port = 8883
+ # {deviceKey}|{productKey} mqttUsername
+ userName = "{}|{}".format(deviceKey,productKey)
+ userpassword = checkpassword
+
+ client = umqtt.MQTTClient(Client_id,server, port, userName,"{}".format(userpassword),reconn=False,ssl=True)
+ # client = MqttClient(Client_id, server, port, userName,"{}".format(userpassword))
+ # 设置消息回调
+ client.set_callback(mqttsub_cb)
+ # 设置异常回调
+ client.error_register_cb(mqtterr_cb)
+ return client
+
+
+
+class SockManager(Abstract):
+ def __init__(self):
+ self.sock = None
+ self.resolver = None
+ self.run_flag = False
+ self.lost_conn_check_time = 5 * 60 * 30
+ self.monitor_timer = osTimer()
+ self.publish_timer = osTimer()
+ self.reconnect_timer = osTimer()
+ self.mqtt_recv_timer = osTimer()
+ self.reconnect_time = 1000
+ self.reconnect_flag = 0
+ self.connect_tmp = 0
+ server_data = server_init()
+ # EventMesh.debug_log("SockManager:server_data:{}".format(server_data))
+ # self.server_addr = server_data[0]
+ # self.server_port = server_data[1]
+ self.server_addr = ""
+ self.server_port = ""
+ self.device_id = ""
+ self.device_key = ""
+ self.product_key = gewu_init()
+ self.deviceSecret = ""
+ self.client = 0
+ self.client_dev = 0
+ self.client_state = 0
+ self.mqtt_client_count = 0
+ ip_infor = {}
+ ip_infor = EventMesh.publish("get_new_ip_com")
+ EventMesh.debug_log("ip_infor1:{} \n\n\n".format(ip_infor))
+
+ if ip_infor != None: #已经改过服务器
+ self.server_addr = ip_infor[0]
+ self.server_port = ip_infor[1]
+ else:
+ self.server_addr = server_data[0]
+ self.server_port = server_data[1]
+
+ EventMesh.debug_log("server_addr:{} server_port:{}".format(self.server_addr,self.server_port))
+ _thread.stack_size((9+3)*1024)
+ _thread.start_new_thread(self.connect, ())
+ _thread.stack_size(8*1024)
+
+
+ self.socket_send_queue = Queue()
+ _thread.stack_size((9+2)*1024)
+ _thread.start_new_thread(self.socket_send_queue_thread, ())
+ _thread.stack_size(8*1024)
+ EventMesh.subscribe("set_device_id",self.set_device_id)
+ EventMesh.subscribe("set_device_key",self.set_device_key)
+ EventMesh.subscribe("set_product_key",self.set_product_key)
+
+ EventMesh.subscribe("get_device_id",self.get_device_id)
+ EventMesh.subscribe("get_device_key",self.get_device_key)
+ EventMesh.subscribe("get_product_key",self.get_product_key)
+
+ EventMesh.subscribe("set_deviceSecret",self.set_deviceSecret)
+
+ EventMesh.subscribe("get_deviceSecret",self.get_deviceSecret)
+ if EventMesh.platform == "gewu":
+ str = "deviceSecret:"
+ buf = bytearray(32+len(str))
+ length = SecureData.Read(2, buf, 32+len(str))
+ deviceSecret = buf.decode()
+ print(type(deviceSecret))
+ if deviceSecret != "":
+ if "deviceSecret" in deviceSecret:
+ self.deviceSecret = deviceSecret.split(":")[1]
+ else:
+ self.deviceSecret = " "
+ if EventMesh.platform == "gewu":
+ self.client = mqtt_client_pro_init()
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("get_mqtt_pro_connect_state",self.get_mqtt_pro_connect_state)
+ EventMesh.subscribe("get_mqtt_dev_connect_state",self.get_mqtt_dev_connect_state)
+ EventMesh.subscribe(constants.EVENT.CHANNEL_SOCKET_SEND, self.send)
+ self.monitor_timer.start(7 * 60 * 1000, 1, self.check)
+
+ def add_support_resolver(self, resolver):
+ self.resolver = resolver
+
+ def initialization(self, *args, **kwargs):
+ _thread.stack_size(16*1024)
+ _thread.start_new_thread(self.recv, ())
+ _thread.stack_size(8*1024)
+
+ def set_device_id(self,event,msg):
+ self.device_id = str(msg)
+
+ def get_device_id(self,event,msg):
+
+ return self.device_id
+ def set_device_key(self,event,msg):
+ self.device_key = str(msg)
+ return
+ def get_device_key(self,event,msg):
+
+ return self.device_key
+
+ def set_product_key(self,event,msg):
+ self.product_key = str(msg)
+
+ def get_product_key(self,event,msg):
+
+ return self.product_key
+
+ def set_deviceSecret(self,event,msg):
+ if EventMesh.platform == "gewu":
+ self.deviceSecret = str(msg)
+ deviceSecret_tmp = "deviceSecret:{}".format(msg)
+ SecureData.Store(2, deviceSecret_tmp, len(deviceSecret_tmp))
+
+ def get_deviceSecret(self,event,msg):
+ return self.deviceSecret
+
+ def connect(self):
+ EventMesh.debug_log("connect1{}:{}".format(self.server_addr, self.server_port))
+ if EventMesh.publish("get_sim_Status") != 1: #没sim
+ return
+ try:
+ if(self.sock != None) :
+ self.sock.close()
+ self.sock = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM)
+ #self.sock.setblocking(False) &self.sock.settimeout(0)不阻塞
+ self.sock.connect((self.server_addr, self.server_port))
+
+ self.publish_timer.start(2000, 1, self.publish_timer_cb)
+ if EventMesh.platform == "gewu":
+ self.mqtt_client_count = 0
+ self.mqtt_recv_timer.start(5000, 1, self.mqtt_recv_timer_cb)
+
+ utime.sleep_ms(500)
+ EventMesh.publish(constants.PROTOCOL.LK_SEND)
+ # 发送数据
+
+
+ except Exception as e:
+ usys.print_exception(e)
+ self.run_flag = False
+ else:
+ self.run_flag = True
+ EventMesh.debug_log("connect2{}:{}".format(self.server_addr, self.server_port))
+ self.reconnect_flag = 0
+ def publish_timer_cb(self, *args):
+ self.authen_set()
+
+ def authen_set(self):
+ sever_state = EventMesh.publish("get_server_state")#获取修改服务器状态
+ # print("sever_state{}".format(sever_state))
+ if sever_state != None:
+ if sever_state == 0:
+ imei = EventMesh.publish(constants.EVENT.GET_IMEI)
+ server_data = EventMesh.publish("get_new_key_pid")#获取pid和key
+ key_data = ""
+ pid_data = ""
+ if server_data != None:
+ key_data = server_data[0]
+ pid_data = server_data[1]
+ else:
+ server_data = server_init()
+ key_data = server_data[2]
+ pid_data = server_data[3]
+
+ # server_data = server_init()
+ # key_data = server_data[2]
+ # pid_data = server_data[3]
+
+ sonce_data = str(urandom.getrandbits(32))#随机生成32位的随机数
+ md5_data = "{}*{}*{}*{}".format(imei,pid_data,sonce_data,key_data)#md5签名
+ sign_data = ""
+ hash_obj = uhashlib.md5(md5_data)
+ res = hash_obj.digest()
+
+ # 转成十六进制表示
+ sign_data = ubinascii.hexlify(res)
+ sign_data = sign_data.decode('ascii')
+ # print("sign_data:{} sonce_data:{}".format(md5_data,sign_data))
+ # sign_data = MD5_head
+ # http://8.134.110.49:31379/dev/device/check?imei=&bid=sonce=sign=
+ # ip_addr = "test.iot.api.thisiot.com"
+ # ip_addr = "app.api.thisiot.com"
+ # http://app.api.thisiot.com/
+ url = "http://app.api.thisiot.com/dev/device/check?imei={}&bid={}&sonce={}&sign={}".format(imei,pid_data,sonce_data,sign_data)
+
+ # print("url:{}".format(url))
+ response = request.get(url)
+ data_tmp ={}
+ # d_server_addr = "device.miwitracker.com"
+ # d_server_port = 8505
+ # d_md5_key = ""
+ # d_PID = "3G"
+ # response.content = {'protocolType': '', 'host': 'device.miwitracker.com', 'secretKey': '', 'port': 8505, 'bid': '3G', 'extJsonStr': ''}
+ # response.status_code=200
+ print("test-{}".format(response.status_code))
+ if response.status_code == 200:
+ content = response.content
+ c = next(content)
+ # "api.xcloudtech.com"
+ # d_server_port = 9000
+ jsload_data = ujson.loads(c)
+ print("jsload_data-{}".format(jsload_data))
+ # jsload_data = {'data':'111','protocolType':'', 'host':'device.miwitracker.com', 'secretKey': 'bZld0ALsZTt15tKEZhOlLPgbsO75BLTP', 'port':8505, 'bid': '3G', 'extJsonStr': ''}
+ # ujson.loads(c)
+
+ if "success" in jsload_data:
+ success = jsload_data["success"]
+ if success == True:#合法设备
+ if "data" in jsload_data:
+ data_tmp = jsload_data["data"]#返回的数据
+ print("data_tmp:{}".format(data_tmp))
+ code = jsload_data["code"]
+ if code == 20000:#合法的设备
+ protocloType = data_tmp["protocolType"]#协议类型
+ host = data_tmp["host"]#服务骑地址
+ secretKey = data_tmp["secretKey"]#
+ pid = data_tmp["bid"]#产品型号
+ port = data_tmp["port"]#端口号
+
+
+
+ if host != '' and (port != '' and port != -1):
+ if host != '':
+ self.server_addr = host
+ EventMesh.publish("set_ip",str(self.server_addr))
+
+ if port != '' and port != -1:
+ self.server_port = port
+ EventMesh.publish("set_com",self.server_port)
+ EventMesh.publish("set_new_key", str(secretKey))#获取pid和key
+ EventMesh.publish("set_new_pid",str(pid))#获取pid和key
+ # self.reconnect_timer_cb()#重连设备
+ print("self.reconnect_flag",self.reconnect_flag)
+ self.reconnect_flag = 0
+ self.reconnect()#重连设备
+ self.publish_timer.stop()
+ EventMesh.publish("set_server_state",1)#获取修改服务器状态
+ else:
+ self.publish_timer.stop()
+
+
+
+ def mqtt_recv_timer_cb(self, *args):
+ self.mqtt_clien_cb()
+
+
+
+ def mqtt_clien_cb(self):
+ if EventMesh.platform != "gewu":
+ return
+ # 需要加密的数据
+ get_deviceSecret = EventMesh.publish("get_deviceSecret")
+ if get_deviceSecret != None:
+ if self.mqtt_client_count == 0:
+ self.mqtt_client_count = 1
+ self.mqtt_recv_timer.stop()
+ get_deviceSecret = EventMesh.publish("get_deviceSecret")#获取设备的秘钥 只获取一次
+ print("get_deviceSecret{}".format(get_deviceSecret))
+ if get_deviceSecret == '':#如果为空就获取一次
+ # print("self.client:{}".format(self.client))
+ mqtt_connect = -1
+ try:
+ mqtt_connect = self.client.connect()
+ except Exception as e:
+ print(e)
+ mqtt_connect = -1
+ print("mqtt_connect:{}".format(mqtt_connect))
+ if mqtt_connect == 0 :
+ # 订阅主题
+ get_device_id = EventMesh.publish(constants.EVENT.GET_IMEI)
+ get_deviceKey = EventMesh.publish(constants.EVENT.GET_IMEI)
+ get_productKey = gewu_init()
+ #$sys/{productKey}/{deviceKey}/ext/regist
+ client_msg = "$sys/{}/{}/ext/regist".format(get_productKey,get_deviceKey)
+ # client_msg = "$sys/cu1shld45y4hjr1L/866610001011658/ext/regist"
+ subscribe_msg = client_msg.encode('ascii')
+ print(subscribe_msg)
+
+ self.client.subscribe(subscribe_msg,0)#订阅消息主题
+
+
+ self.client.wait_msg() # 阻塞函数,监听消息
+ utime.sleep(5)
+ get_deviceSecret = EventMesh.publish("get_deviceSecret")
+ if get_deviceSecret != '':
+ self.client.disconnect()
+ self.client_dev = mqtt_client_dev_init()
+ print(self.client_dev)
+ # mqtt_connect = self.client_dev.connect()
+ try:
+ mqtt_connect = self.client_dev.connect()
+ except Exception as e:
+ print(e)
+ mqtt_connect = -1
+ if mqtt_connect == 0:
+ # $sys/cu1shld45y4hjr1L/bOOSGN5FlXEjt15/property/batch_reply
+ msg_reply = "$sys/{}/{}/property/batch_reply".format(get_productKey,get_deviceKey)
+ sub_msg = msg_reply.encode('ascii')
+ self.client_dev.subscribe(sub_msg,0)#订阅消息主题
+ print("Connected to dmp-mqtt.cuiot.cn, subscribed to /public/TEST/quecpython topic")
+ # 发布消息
+ # UnicodeHexStr_To_Utf8Str(str_data)
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)#需要转换成毫秒级别
+ updataTime = "{}".format(time_tmp*1000)
+ # imei_tmp= modem.getDevImei()
+ imei_tmp = EventMesh.publish(constants.EVENT.GET_IMEI)
+ bat_tmp = EventMesh.publish("screen_get_battery")
+ imei = "{}".format(imei_tmp)
+ power = 0
+ power = int(bat_tmp[1])
+ hr = 0
+ hr = EventMesh.publish("get_old_hr_data")
+ if hr == None:
+ hr = 0
+ deviceTime = "{}".format(time_tmp)
+ manufactury = "fengda"
+ DeviceState = "online"
+
+ data_info = {
+ "messageId":"0",
+ "params": {
+ "data": [
+ {
+ "key":"deviceOffOn",
+ "value": {
+ "deviceStatus":"Poweron",
+ "updateTime":updataTime,
+ "Imei":imei
+ }
+
+ },
+ {
+ "key":"HeartRate",
+ "value":{
+ "heartRate":hr,
+ "updateTme":updataTime,
+ "Imei":imei
+ }
+ },
+ {
+ "key":"powerSavingMode",
+ "value":0
+ },
+ {
+ "key":"IMEI",
+ "value":imei
+ },
+ {
+ "key":"DEVICE_TIME",
+ "value":deviceTime
+ },
+ {
+ "key":"MANUFACTURER",
+ "value":manufactury
+ },
+ {
+ "key":"REMAINING_POWER",
+ "value":power
+ },
+ {
+ "key":"DeviceState",
+ "value":DeviceState
+ }
+ ]
+ }
+ }
+
+ data_json = ujson.dumps(data_info)
+ # print("data_json:{}",data_json)
+ # $sys/cu1shld45y4hjr1L/{deviceKey}/property/batch
+ msg_pub = "$sys/{}/{}/property/batch".format(get_productKey,get_deviceKey)
+ pub_msg = msg_pub.encode('ascii')
+ self.client_dev.publish(pub_msg,data_json,0)#publis主题内容
+
+ print("Publish topic: /public/TEST/quecpython758, msg: my name is Quecpython")
+ pass
+
+ else:
+ mqtt_dev_connect = -1
+ mqtt_ret_connect = -1
+ mqtt_pro_connect = -1
+ if self.client_dev == 0:
+ self.client_dev = mqtt_client_dev_init()
+ try:
+ mqtt_dev_connect = self.client_dev.connect()
+ except Exception as e:
+ print("erro!{}".format(e))
+ mqtt_dev_connect = -2
+ # Server Actively FIN Disconnected.Need Check Connection parameters
+ err_dis = "FIN Disconnected" in str(e)
+ err_parm1 = "107" in str(e)
+ err_parm2 = "4" in str(e)
+ # print("err_parm1!{} {} {} {}".format(err_parm1,err_parm2,err_info,err_dis))
+ # Connect Error='4' MQTT Connect error=
+ if err_dis == True or err_parm1 == True or err_parm2 == True:
+ mqtt_dev_connect = -1
+
+
+ if mqtt_dev_connect != 0:#连接参数错误可能是deviceScrete出错重新获取
+
+ try:
+ mqtt_ret_connect = self.client.connect()#重新获取deviceScrete
+ except Exception as e:
+ print(e)
+ mqtt_ret_connect = -1
+ # mqtt_connect = self.client.connect()
+ print("mqtt_ret_connect:{}".format(mqtt_ret_connect))
+ if mqtt_ret_connect == 0:
+ # 订阅主题
+ get_device_id = EventMesh.publish(constants.EVENT.GET_IMEI)
+ get_deviceKey = EventMesh.publish(constants.EVENT.GET_IMEI)
+ get_productKey = gewu_init()
+ #$sys/{productKey}/{deviceKey}/ext/regist
+ client_msg = "$sys/{}/{}/ext/regist".format(get_productKey,get_deviceKey)
+ # client_msg = "$sys/cu1shld45y4hjr1L/866610001011658/ext/regist"
+ subscribe_msg = client_msg.encode('ascii')
+ print(subscribe_msg)
+
+ self.client.subscribe(subscribe_msg,0)#订阅消息主题
+
+ self.client.wait_msg() # 阻塞函数,监听消息
+ utime.sleep(5)
+
+ self.client.disconnect()
+ self.client_dev = mqtt_client_dev_init()
+ # print(self.client_dev)
+ try:
+ mqtt_pro_connect = self.client_dev.connect()
+ except Exception as e:
+ print(e)
+ mqtt_pro_connect = -1
+ # print("no deviceScret!!!!!!!{}".format(self.client_dev))
+ # 设备秘钥不为空 重连获取设备失败不连接 第一次连接失败不连接不发送数据
+ if EventMesh.publish("get_deviceSecret") != "" and (mqtt_pro_connect == 0 or mqtt_dev_connect == 0):
+ get_device_id = EventMesh.publish(constants.EVENT.GET_IMEI)
+ get_deviceKey = EventMesh.publish(constants.EVENT.GET_IMEI)
+ get_productKey = gewu_init()
+ # $sys/cu1shld45y4hjr1L/bOOSGN5FlXEjt15/property/batch_reply
+ msg_reply = "$sys/{}/{}/property/batch_reply".format(get_productKey,get_deviceKey)
+ sub_msg = msg_reply.encode('ascii')
+ # print(" deviceScret!!!!!!!{} msg_reply:{} sub_msg:{}".format(self.client_dev,msg_reply,sub_msg))
+ self.client_dev.subscribe(sub_msg,0)#订阅消息主题
+ print("Connected to dmp-mqtt.cuiot.cn, subscribed to /public/TEST/quecpython topic")
+ # 发布消息
+ # UnicodeHexStr_To_Utf8Str(str_data)
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)#需要转换成毫秒级别
+ updataTime = "{}".format(time_tmp*1000)
+ imei_tmp = EventMesh.publish(constants.EVENT.GET_IMEI)
+ imei = "{}".format(imei_tmp)
+ bat_tmp = EventMesh.publish("screen_get_battery")
+ power = 0
+ power = int(bat_tmp[1])
+ hr = 0
+ hr = EventMesh.publish("get_old_hr_data")
+ if hr == None:
+ hr = 0
+ deviceTime = "{}".format(time_tmp)
+ manufactury = "fengda"
+ DeviceState = "online"
+
+ data_info = {
+ "messageId":"0",
+ "params": {
+ "data": [
+ {
+ "key":"deviceOffOn",
+ "value": {
+ "deviceStatus":"Poweron",
+ "updateTime":updataTime,
+ "Imei":imei
+ }
+
+ },
+ {
+ "key":"HeartRate",
+ "value":{
+ "heartRate":hr,
+ "updateTme":updataTime,
+ "Imei":imei
+ }
+ },
+ {
+ "key":"powerSavingMode",
+ "value":0
+ },
+ {
+ "key":"IMEI",
+ "value":imei
+ },
+ {
+ "key":"DEVICE_TIME",
+ "value":deviceTime
+ },
+ {
+ "key":"MANUFACTURER",
+ "value":manufactury
+ },
+ {
+ "key":"REMAINING_POWER",
+ "value":power
+ },
+ {
+ "key":"DeviceState",
+ "value":DeviceState
+ }
+ ]
+ }
+ }
+
+ data_json = ujson.dumps(data_info)
+ # print("data_json:{}",data_json)
+ # $sys/cu1shld45y4hjr1L/{deviceKey}/property/batch
+ msg_pub = "$sys/{}/{}/property/batch".format(get_productKey,get_deviceKey)
+ pub_msg = msg_pub.encode('ascii')
+ self.client_dev.publish(pub_msg,data_json,0)#publis主题内容
+
+ print("Publish topic: /public/TEST/quecpython758, msg: my name is Quecpython")
+
+ def get_mqtt_pro_connect_state(self,event,msg):
+ return self.client
+ def get_mqtt_dev_connect_state(self,event,msg):
+ return self.client_dev
+
+ def check(self, *args):
+ if (not self.run_flag) or (self.connect_tmp == 0) : #7分钟无数据读取,则认为是掉线了
+ EventMesh.debug_log("tcp reconnect!!!!!!!!!!!!!!!!!!")
+ EventMesh.publish(constants.EVENT.SET_CONNECT,0) #标记断网
+ self.reconnect()
+ self.connect_tmp = 0
+ def reconnect(self):
+ if(self.reconnect_flag == 1):
+ return
+ self.reconnect_flag = 1
+ self.reconnect_timer.start(self.reconnect_time, 0, self.reconnect_timer_cb)
+ if self.reconnect_time < 600*1000:
+ self.reconnect_time += 30*1000
+
+ def reconnect_timer_cb(self, *args):
+ _thread.stack_size((9+1)*1024)
+ _thread.start_new_thread(self.connect, ())
+ _thread.stack_size(8*1024)
+
+ def socket_send_queue_thread(self):
+ while True:
+ data = self.socket_send_queue.get()
+ EventMesh.debug_log("TCP:send data1 len:{}".format(len(data)))
+
+ #EventMesh.debug_log("ui_queue_thread:data = {}".format(data))
+ socketsta = self.sock.getsocketsta()
+ if(socketsta == -1): #给释放了或者出错了
+ continue
+ if(socketsta == 4):#正常连击
+ if data != None:
+ try:
+ self.sock.send(data)
+ EventMesh.debug_log("TCP:send data2 len:{}".format(len(data)))
+ except Exception as e:
+ self.reconnect()
+ self.socket_send_queue.put(data)#重新把数据加回队列
+ #EventMesh.debug_log("socket_send_queue_thread1:ERROR:")
+ #usys.print_exception(e)
+ elif socketsta < 4:#正在连接,等待连接成功重新发送
+ count = 0
+ while True:
+ if count > 15 :
+ break
+ utime.sleep(1)
+ if(self.sock.getsocketsta() == 4):#
+ try:
+ self.sock.send(data)
+ EventMesh.debug_log("TCP:send data3 len:{}".format(len(data)))
+ except Exception as e:
+ self.reconnect()
+ self.socket_send_queue.put(data)#重新把数据加回队列
+ #EventMesh.debug_log("socket_send_queue_thread2:ERROR:")
+ #usys.print_exception(e)
+ break
+ else :#连接错误
+ EventMesh.debug_log("socket_send_queue_thread:ERROR:reconnect")
+ self.reconnect()
+ utime.sleep(1)
+
+ def send(self, topic, msg):
+ # EventMesh.debug_log("TCP:send data:{}".format(msg))
+ if EventMesh.publish("get_sim_Status") != 1: #没sim,则不发送
+ EventMesh.publish(constants.EVENT.SET_CONNECT, 0)#标记断网
+ EventMesh.debug_log("dataCall not connect")
+ return
+ else :
+ try:
+ self.socket_send_queue.put(msg)
+ except Exception as e:
+ EventMesh.debug_log("self.socket_send_queue.put:ERROR:")
+ usys.print_exception(e)
+ # self.run_flag = False
+
+ def recv(self):
+ data = b''
+ while True:
+ try:
+ r = b''
+ r = self.sock.recv(1024*5)
+
+ if not r:
+ self.run_flag = False
+ self.reconnect()
+
+ data = data + r
+ EventMesh.debug_log("TCP recv: data:len:{}".format(len(data)))
+ # EventMesh.debug_log("TCP recv: data:{}".format(data))
+ if data[-1] != 0x5d and len(data)<20*1024: #']':
+ continue
+ self.connect_tmp = 1 #有数据,就认为是连接状态
+ self.reconnect_time = 1000
+ EventMesh.publish(constants.EVENT.SET_CONNECT, 1)
+ data_str = data.decode('ascii')
+ data_str = data_str.split(']')
+ if len(data_str) < 3 :
+ self.resolver.handler(data)
+ else :
+ for i in range(len(data_str)-1):
+ self.resolver.handler(data_str[i])
+
+ data = b''
+ except Exception as e:
+ #EventMesh.debug_log("TCP:ERROR:recv:")
+ #usys.print_exception(e)
+ self.run_flag = False
+ self.reconnect()
+
+ data = b''
+ utime.sleep(2)
+
+
+
+class NetManager(Abstract):
+ THRESHOLD = 10
+
+ def __init__(self):
+ self.__data_call = dataCall
+ self.__net = net
+ self.check_net = checkNet.CheckNetwork("QuecPython_Helios_Framework", "this latest version")
+ EventMesh.subscribe("get_network_state", self.get_network_state)
+ self.network_state = 0
+
+ def post_processor_after_instantiation(self, *args, **kwargs):
+ count = 0
+ while True:
+ count += 1
+ if count > 5 :
+ return
+ data = dataCall.getInfo(1, 0)
+ EventMesh.debug_log("data call INFO {}".format(data))
+ if data[2][0]:
+ self.network_state = 1
+ break
+ utime.sleep(1)
+ self.__data_call.start(2, 0, "", "", "", 0)
+ self.__data_call.setCallback(self.__datacall_cb)
+
+ def __datacall_cb(self, args):
+ pdp = args[0]
+ nw_sta = args[1]
+ if nw_sta == 1:
+ self.network_state = 1
+ EventMesh.debug_log("*** network %d connected! ***" % pdp)
+
+ else:
+ self.network_state = 0
+ EventMesh.debug_log("*** network %d not connected! ***" % pdp)
+
+ def get_network_state(self, topic, msg):
+ return self.network_state
+
+
+class ProtoCol(Abstract):
+ TYPE = ""
+ HEADER = "#@{}@#;"
+ SEPARATOR = ";"
+ END = ";" + chr(0x01)
+ #PID = "SZKW"
+ #PID = "qAELPTKmFanR4RHe"
+ md5_key = ''
+ PID = ''
+
+ def __init__(self):
+ self.content = None
+ self.check_sum = None
+ self.password = EventMesh.publish(constants.EVENT.GET_PASSWORD)
+ self.imei = EventMesh.publish(constants.EVENT.GET_IMEI)
+ self.cid = EventMesh.publish(constants.EVENT.GET_CID)
+ self.imsi = EventMesh.publish(constants.EVENT.GET_IMSI)
+ self.key = EventMesh.publish(constants.EVENT.GET_KEY)
+ self.HEADER = self.HEADER.format(self.TYPE)
+
+ self.md5_key = ''
+ self.PID = ''
+ server_data = EventMesh.publish("get_new_key_pid")#获取pid和key
+ if server_data == None:
+ server_data = server_init()#如果获取的数据是None,就用默认的大锤key和pid
+ self.md5_key = server_data[2]
+ self.PID = server_data[3]
+ else:
+ self.md5_key = server_data[0]
+ self.PID = server_data[1]
+
+ # EventMesh.debug_log("md5_key:--",self.md5_key,self.PID)
+ # ip_infor = {}
+ # ip_infor = EventMesh.publish("get_new_ip_com")
+ # if ip_infor != None:
+ # self.md5_key = ip_infor[2]
+ # EventMesh.debug_log("md5_key",self.md5_key)
+
+ def initialization(self, *args, **kwargs):
+ EventMesh.subscribe(self.TYPE + "_SEND", self.handler)
+ EventMesh.subscribe(self.TYPE + "_RECV", self.handler)
+ #EventMesh.debug_log("ProtoCol:{}".format(self.TYPE + "_SEND"))
+
+ def handler(self, event, msg):
+ #EventMesh.debug_log("ProtoCol:handler:{}".format(event))
+ self.password = EventMesh.publish(constants.EVENT.GET_PASSWORD)
+ self.imei = EventMesh.publish(constants.EVENT.GET_IMEI)#"867387060319166"#EventMesh.publish(constants.EVENT.GET_IMEI)#"867387060319166" #EventMesh.publish(constants.EVENT.GET_IMEI)#"867387060319166"#EventMesh.publish(constants.EVENT.GET_IMEI) #"867387060319166"#EventMesh.publish(constants.EVENT.GET_IMEI) #"867387060319166"#"867387060319188"#"867387060319177"#"867387060319166"#"860132060004322"#"867387060319166"#"860132060004322"#EventMesh.publish(constants.EVENT.GET_IMEI)
+ self.cid = EventMesh.publish(constants.EVENT.GET_CID)
+ self.imsi = EventMesh.publish(constants.EVENT.GET_IMSI)
+ self.key = EventMesh.publish(constants.EVENT.GET_KEY)
+ if event.endswith("_SEND"):
+ self.send(event, msg)
+ else:
+ self.recv(event, msg)
+
+ def send(self, event, msg):
+ pass
+
+ def recv(self, event, msg):
+ pass
+
+ @staticmethod
+ def get_date():
+ return "{:04d}-{:02d}-{:02d}".format(*utime.localtime()[0:3])
+
+ @staticmethod
+ def get_time():
+ return "{:02d}:{:02d}:{:02d}".format(*utime.localtime()[3:6])
+
+ def calc_crc(self):
+ data = self.content
+ if not isinstance(data, bytes):
+ data = data.encode()
+ count = 0
+ for x in data:
+ count += x
+ self.check_sum = 100 - count % 100
+
+ def pack(self):
+ self.calc_crc()
+ return self.HEADER.encode() + self.content.encode() + self.SEPARATOR.encode() + int(self.check_sum).to_bytes(1,'little') + self.END.encode()
+
+ def pack_MD5_head(self,data):
+ #key = "bZld0ALsZTt15tKEZhOlLPgbsO75BLTP"
+ self.md5_key=EventMesh.publish("get_new_key")
+ if self.md5_key == None:
+ self.md5_key = server_init[2]
+
+ if(self.md5_key == ""):
+ return ""
+ MD5_head = ""
+ hash_obj = uhashlib.md5(data+self.md5_key)
+ res = hash_obj.digest()
+
+ # 转成十六进制表示
+ MD5_head = ubinascii.hexlify(res)
+ MD5_head = MD5_head.decode('ascii')
+ #EventMesh.debug_log("data+self.md5_key:{}".format(data+self.md5_key))
+ #EventMesh.debug_log(res)
+ #EventMesh.debug_log(MD5_head)
+ return MD5_head
+
+class LK_ProtoCol(ProtoCol):
+ """链路保持"""
+ TYPE = "LK"
+
+ def send(self, event, msg):
+ #[SZKW*334588000000156*0002*LK]
+ #EventMesh.debug_log('self.imei:%s'%(self.imei))
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0002*LK"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ # EventMesh.debug_log("LK_ProtoCol:send:%s"%(data))
+
+
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+ """
+
+ @param event: LK成功
+ @param msg: 接收到的下行数据
+ """
+ EventMesh.debug_log("LK_ProtoCol:recv:%s"%(msg))
+ EventMesh.publish(constants.PROTOCOL.PING_SEND)
+ EventMesh.publish(constants.PROTOCOL.KA_SEND)
+ EventMesh.publish(constants.PROTOCOL.TIME_SEND)
+
+ EventMesh.publish(constants.EVENT.START_LOCATION,constants.PROTOCOL.UD_SEND) #开始UD定位
+ EventMesh.publish(constants.EVENT.START_LOCATION,constants.PROTOCOL.WT_SEND) #开始WT定位
+ if EventMesh.model == 'D15':
+ EventMesh.publish(constants.PROTOCOL.MEMBERS_SEND)
+
+class PING_ProtoCol(ProtoCol):
+ """获取绑定状态"""
+ TYPE = "PING"
+
+ def send(self, event, msg):
+ #[SZKWT*YYYYYYYYYYYYYYY*LEN*PING]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0004*PING"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ #EventMesh.debug_log("PING_ProtoCol:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+ """
+
+ @param event: PING
+ @param msg: 接收到的下行数据
+ """
+ #EventMesh.debug_log("PING_ProtoCol:recv:%s"%(msg))
+ data_tmp = msg.decode('ascii')
+ data_tmp = data_tmp.split(']')[0] #去掉]
+ EventMesh.publish(constants.EVENT.SET_PING, data_tmp.split(',')[1])
+ if EventMesh.model == 'D15':
+ EventMesh.publish(constants.PROTOCOL.JPREG_SEND)
+ EventMesh.publish(constants.PROTOCOL.MEMBERS_SEND)
+
+class KA_ProtoCol(ProtoCol):
+ """心跳"""
+ TYPE = "KA"
+ count = 0
+ roll_count = 0
+ def send(self, event, msg):
+ #"{:04d}-{:02d}-{:02d}".format(*utime.localtime()[0:3])
+ #[XT*YYYYYYYYYYYYYYY*LEN*KA,日期,步数,翻滚次数,电量百分数,车载里程数(km)] 实例:[XT*334588000000156*0014*KA,120414,50,100,100,100.12]
+ date = "{:04d}{:02d}{:02d}".format(*utime.localtime()[0:3])
+ date = date[2:]
+ #EventMesh.debug_log("date:",date)
+ #步数
+ old_step = 0
+ step = 0
+ step = EventMesh.publish("get_old_step_value")
+ if step != None:
+ if step != 0:
+ read_data = EventMesh.publish("get_storage_config","old_step_new")
+ if read_data != None:
+ old_step = read_data
+
+ if old_step != step:
+ # EventMesh.debug_log("old_step:send:%d %d"%(old_step,step))
+ EventMesh.publish("set_storage_config",["old_step_new",step+10])
+ EventMesh.publish("set_storage_config",["old_step_new",step])
+
+ old_step = step
+ # step = EventMesh.publish(constants.EVENT.GET_STEP)[0]
+ # 电池电量百分比
+
+ bat_tmp = EventMesh.publish("screen_get_battery")
+ sleep_time = EventMesh.publish("get_storage_config","sleep_time")
+ if sleep_time != None:
+ if len(sleep_time) != 0:
+ hour = utime.localtime()[3]
+ min = utime.localtime()[4]
+ cur_time = hour*60+min
+ start_hour = int(sleep_time["start_hour"])
+ start_min = int(sleep_time["start_min"])
+ start_total = start_hour*60+start_min
+
+ end_hour = int(sleep_time["end_hour"])
+ end_min = int(sleep_time["end_min"])
+ end_total = end_hour*60+end_min
+ # EventMesh.debug_log("ka roll_:",hour,min,cur_time,start_total,end_total)
+ if cur_time >= start_total and cur_time <= end_total:
+ self.roll_count = int(hour)
+ if self.roll_count == 0:
+ self.roll_count+=1
+ else:
+ self.roll_count = 0
+ else:
+ self.roll_count = 0
+ else:
+ self.roll_count = 0
+ hour = utime.localtime()[3]
+ min = utime.localtime()[4]
+ EventMesh.txt_log("ka step:{} hour:{} min:{}".format(step,hour,min))
+
+ battery_caption = bat_tmp[1]
+ send_data = "KA,%s,%d,%d,%d"%(date,step,self.roll_count,battery_caption)
+ send_len = len(send_data)
+
+ send_data = EventMesh.publish("get_new_pid")+"*%s*%04X*%s"%(self.imei,send_len,send_data)
+ MD5_head_data = EventMesh.publish("get_new_pid")+"*%s*%04X*%s"%(self.imei,send_len,"KA")
+
+ MD5_SIGN = self.pack_MD5_head(MD5_head_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ #EventMesh.debug_log("KA_ProtoCol:send:%s"%(data))
+
+
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+ """
+
+ @param event: PING
+ @param msg: 接收到的下行数据
+ """
+ #EventMesh.debug_log("KA_ProtoCol:recv:%s"%(msg))
+
+class UD_ProtoCol(ProtoCol):
+ """位置信息"""
+ TYPE = "UD"
+ UD_count = 0#每6次定位获取一次天气数据
+ def send(self, event, msg):
+ #EventMesh.debug_log("UD:send:%s"%(msg))
+ #"{:04d}-{:02d}-{:02d}".format(*utime.localtime()[0:3])
+ #[6f62cfc40fc50173f9a7b21e87be3424IS*861217001020120*00f6*UD,220726,211210,A,22.649529,N,114.119165,E,0.28,137.4,100.0,8,24,63,119,0,00000000,2,1,460,11,30472,125667122,24,30472,218944048,19,4,
+ # wifi0,34:93:44:01:28:b9,-74,wifi1,34:20:03:96:35:ad,-78,wifi2,ea:b5:7b:e8:56:54,-80,wifi3,c4:49:bb:d4:d9:78,-88]
+
+
+ self.UD_count+=1
+ #每6次定位获取一次天气数据
+ if self.UD_count>=6:
+ self.UD_count = 0
+ EventMesh.publish(constants.PROTOCOL.WT_SEND,msg)
+
+ send_data ="UD,"+msg
+ send_len = len(send_data)
+ #wt_data = "%s"%(send_data)
+ send_data = EventMesh.publish("get_new_pid")+"*%s*%04X*%s"%(self.imei,send_len,send_data)
+ MD5_head_data = EventMesh.publish("get_new_pid")+"*%s*%04X*%s"%(self.imei,send_len,"UD")
+
+ MD5_SIGN = self.pack_MD5_head(MD5_head_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ # EventMesh.debug_log("{}".format(data))
+ # wt_data = EventMesh.publish("get_weather_data")
+ # # #如果没有天气数据,则获取天气数据
+ # if wt_data != None or wt_data[0] == None :
+ #
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+ if EventMesh.platform == "gewu":
+ if(msg != ""):
+ client = EventMesh.publish("get_mqtt_dev_connect_state")
+ if client != 0:
+ mqtt_connect = -1
+ try:
+ mqtt_connect = client.connect()
+ except Exception as e:
+ print(e)
+ mqtt_connect = -1
+ print("mqtt_connect:{}".format(mqtt_connect))
+ if mqtt_connect == 0:
+ # 订阅主题
+ get_device_id = EventMesh.publish(constants.EVENT.GET_IMEI)
+ get_deviceKey = EventMesh.publish(constants.EVENT.GET_IMEI)
+ get_productKey = gewu_init()
+ #$sys/{productKey}/{deviceKey}/ext/regist
+ event_msg = "$sys/{}/{}/event/pub_reply".format(get_productKey,get_deviceKey)
+ # client_msg = "$sys/cu1shld45y4hjr1L/866610001011658/ext/regist"
+ subscribe_msg = event_msg.encode('ascii')
+
+ client.subscribe(subscribe_msg,0)#订阅事件消息消息主题
+ print("Connected to dmp-mqtt.cuiot.cn, subscribed to /public/TEST/quecpython topic")
+ msg_tmp = msg.decode('ascii')
+ msg_tmp = msg_tmp.split(',')
+ longitude = float(msg_tmp[3])
+ latitude = float(msg_tmp[5])
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)#需要转换成毫秒级别
+ updataTime = "{}".format(time_tmp*1000)
+ data_info = {
+ "messageId":"0",
+ "params": {
+ "key":"location",
+ "info": [
+ {
+ "key":"longitude",
+ "value":longitude
+ },
+ {
+ "key":"latitude",
+ "value":latitude
+ },
+ {
+ "key":"UpdateTime",
+ "value":updataTime
+ }
+ ]
+ }
+ }
+ data_json = ujson.dumps(data_info)
+ event_pub_msg = "$sys/{}/{}/event/pub".format(get_productKey,get_deviceKey)
+ pub_msg = event_pub_msg.encode('ascii')
+ client.publish(pub_msg,data_json,0)#publis主题内容
+
+ print("Publish topic: /public/TEST/quecpython758, msg: my name is Quecpython")
+
+
+
+ def recv(self, event, msg):
+ pass
+ # EventMesh.debug_log("UD_ProtoCol:recv:%s"%(msg))
+
+class CR_ProtoCol(ProtoCol):
+ """立即定位"""
+ TYPE = "CR"
+
+ def send(self, event, msg):
+ #[SZKWT*YYYYYYYYYYYYYYY*LEN*PING]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0002*CR"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ #EventMesh.debug_log("CR_ProtoCol:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+ """
+
+ @param event: PING
+ @param msg: 接收到的下行数据
+ """
+ EventMesh.publish(constants.PROTOCOL.CR_SEND)
+ EventMesh.publish(constants.EVENT.START_LOCATION,constants.PROTOCOL.UD_SEND) #开始ud定位
+ #EventMesh.debug_log("CR_ProtoCol:recv:%s"%(msg))
+
+class AL_ProtoCol(ProtoCol):
+ """报警数据上报"""
+ TYPE = "AL"
+ timer_repetition_send = None
+ repetition_queue = None
+
+ def send(self, event, msg):
+ if EventMesh.platform != "gewu":
+ if self.timer_repetition_send == None:
+ self.timer_repetition_send = osTimer()
+ if self.repetition_queue == None:
+ self.repetition_queue = Queue(100)
+
+
+ send_data ="AL,"+msg
+ send_len = len(send_data)
+ #wt_data = "%s"%(send_data)
+ send_data = EventMesh.publish("get_new_pid")+"*%s*%04X*%s"%(self.imei,send_len,send_data)
+ MD5_head_data = EventMesh.publish("get_new_pid")+"*%s*%04X*%s"%(self.imei,send_len,"AL")
+
+ MD5_SIGN = self.pack_MD5_head(MD5_head_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ # EventMesh.debug_log("AL_ProtoCol:send:{}".format(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+ if EventMesh.platform != "gewu":
+ self.repetition_queue.put(data)#发送入队
+ self.timer_repetition_send.start(10000, 1, self.repetition_timer_cb)
+ EventMesh.publish("set_dev_state",0)
+ def recv(self, event, msg):
+ """
+
+ @param event: PING
+ @param msg: 接收到的下行数据
+ """
+ #EventMesh.publish(constants.PROTOCOL.CR_SEND)
+ #EventMesh.publish(constants.EVENT.START_LOCATION,constants.PROTOCOL.UD_SEND) #开始ud定位
+ # print("报警数据上报:recv:%s"%(msg))
+ EventMesh.debug_log("报警数据上报:recv:{}".format(msg))
+ #
+ if EventMesh.platform != "gewu":
+ if self.repetition_queue.empty() == False:
+ self.repetition_queue.get()#出队
+ else:
+ self.timer_repetition_send.stop()
+
+ def repetition_timer_cb(self, *args, **kwargs):#每隔10秒发送一次
+ if self.repetition_queue.empty() == False:
+ data = self.repetition_queue.get()#出队
+ self.repetition_queue.put(data)#发送入队
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+ else:
+ self.timer_repetition_send.stop()
+
+class FIND_ProtoCol(ProtoCol):
+ """查找设备"""
+ TYPE = "FIND"
+
+ def send(self, event, msg):
+ #[SZKWT*YYYYYYYYYYYYYYY*LEN*PING]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0004*FIND"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ #EventMesh.debug_log("FIND_ProtoCol:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+ """
+
+ @param event: FIND,播放铃声
+ @param msg: 接收到的下行数据
+ """
+ EventMesh.publish(constants.PROTOCOL.FIND_SEND)
+ # a = audio.Audio(0)
+ # a.set_pa(Pin.GPIO29)
+ # a.setVolume(10)
+ # a.play(1, 1, 'E:/audio_find_haixiu.mp3') #文件名前面要加上路径
+
+ # EventMesh.publish("load_screen", {"screen": "FIND"})
+ EventMesh.publish("OPEN_FIND_WATCH")#
+ #EventMesh.debug_log("FIND_ProtoCol:recv:%s"%(msg))
+
+class POWEROFF_ProtoCol(ProtoCol):
+ """关机"""
+ TYPE = "POWEROFF"
+
+ def send(self, event, msg):
+ # [SZKW*867387060319491*0008*POWEROFF]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0008*POWEROFF"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ #EventMesh.debug_log("POWEROFF_ProtoCol:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+ """
+
+ @param event: POWEROFF关机
+ @param msg: 接收到的下行数据
+ """
+ EventMesh.publish(constants.PROTOCOL.POWEROFF_SEND)
+ #EventMesh.debug_log("POWEROFF_ProtoCol:recv:%s"%(msg))
+ battery = EventMesh.publish("screen_get_battery")
+ if battery != None:
+ if battery[0] != "1":
+ EventMesh.publish("open_power_on", 2)# #远程关机
+
+class PHL_ProtoCol(ProtoCol):
+ """电话本同步"""
+ TYPE = "PHL"
+
+
+ def send(self, event, msg):
+ # [SZKW*867387060319491*0008*PHL]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0003*PHL"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ #EventMesh.debug_log("POWEROFF_ProtoCol:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+ """
+
+ @param event: 电话本同步
+ @param msg: 接收到的下行数据
+ """
+ msg = msg[1:-1]
+ # EventMesh.debug_log("phonebook:msg:%s\r\n"%msg)
+ msg_tmp = msg.decode('ascii')
+ msg_tmp = msg_tmp.split(',')
+ # EventMesh.debug_log("phonebook:len:{}\r\n data:{}".format(len(msg_tmp),msg_tmp))
+
+ phonebook = {}
+ msg_tmp = msg_tmp[1:]
+
+ j = 0
+ i = 0
+ phonebook_oldtmp = {}
+ # 0 1 2 3
+ for phonebook_tmp in msg_tmp:
+ j+=1
+ # EventMesh.debug_log("phonebook_tmp:{} len:{}".format(phonebook_tmp,len(phonebook_tmp)))
+
+ if (j%2) == 0:
+ i+=1
+ if len(phonebook_tmp) != 0:
+ phonebook_name = UnicodeHexStr_To_Utf8Str(phonebook_tmp)
+ phonebook_name = "{}:{}".format("%03d"%i,phonebook_name)
+ phonebook[phonebook_name] = phonebook_oldtmp
+
+ phonebook_oldtmp = phonebook_tmp
+ # EventMesh.debug_log("phonebook_oldtmp!!!:{}".format(str(phonebook_oldtmp)))
+ # EventMesh.debug_log("phonebook!!!:{}".format(str(phonebook)))
+ with open("/usr/static/storage_file/phonebook.json","w",encoding="utf-8") as fd:
+ ujson.dump(phonebook,fd)
+ EventMesh.debug_log("创建电话簿")
+
+ EventMesh.publish(constants.PROTOCOL.PHL_SEND)
+ EventMesh.publish("set_phonebook_list",[1,phonebook])
+ EventMesh.publish("contact_updata_list_show")
+
+
+class WT_ProtoCol(ProtoCol):
+ """天气数据"""
+ TYPE = "WT"
+ WT_T = 0
+
+ def send(self, event, msg):
+ # [SZKW*867387060319491*0008*WT]
+ # if self.WT_T != 0:
+ # tmp_WT =
+ if(msg != ""):
+ msg_tmp = "WT," + msg
+ data_len = len(msg_tmp)
+ MD5_head_data = EventMesh.publish("get_new_pid")+"*%s*%04X*WT"%(self.imei,data_len)
+ MD5_SIGN = self.pack_MD5_head(MD5_head_data)
+ send_data = EventMesh.publish("get_new_pid")+"*%s*%04X*%s"%(self.imei,data_len,msg_tmp)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ EventMesh.debug_log("WT_ProtoCol:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+ """
+
+ @param event: T天气温度数据下发
+ @param msg: 接收到的下行数据
+ """
+ # b'SZKW*860132060004322*0035*WT,23-04-06,14:41:06,b6e0d4c6,1,27,-1,40,6DF157335E02'
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_tmp = msg_tmp.split('WT,')
+ # EventMesh.debug_log("phonebook:len:{}\r\n data:{}".format(len(msg_tmp),msg_tmp))
+ msg_tmp = str(msg_tmp[1])
+
+ # EventMesh.debug_log("msg_tmp :%s"%(msg_tmp))
+
+ msg_date = msg_tmp.split(',')[0]
+
+ msg_time = msg_tmp.split(',')[1]
+ msg_weather_content = msg_tmp.split(',')[2]
+ msg_type = msg_tmp.split(',')[3]
+ msg_temp = msg_tmp.split(',')[4]
+ msg_min_temp = msg_tmp.split(',')[5]
+ msg_max_temp = msg_tmp.split(',')[6]
+ msg_city = msg_tmp.split(',')[7]
+
+ msg_city = UnicodeHexStr_To_Utf8Str(msg_city)
+ msg_weather_content = UnicodeHexStr_To_Utf8Str(msg_weather_content)
+ # EventMesh.debug_log("msg_date:{} msg_time:{} msg_weather_content:{} msg_type:{} msg_temp:{} msg_min_temp:{} msg_max_temp:{} msg_city:{}".format(msg_date,msg_time,\
+ # msg_weather_content,msg_type,msg_temp,msg_min_temp,msg_max_temp,msg_city))
+ EventMesh.debug_log("WT_ProtoCol RECV msg:%s"%(msg))
+
+ EventMesh.publish("set_weather_data",[msg_date,msg_time,msg_weather_content,msg_type,msg_temp,msg_min_temp,msg_max_temp,msg_city,1])
+ EventMesh.publish("updata_weather_show")
+class REMIND_ProtoCol(ProtoCol):#普通闹钟
+ """
+
+ 平台发送:
+ [XT*YYYYYYYYYYYYYYY*LEN*REMIND,,时间1-开关,时间2-开关,周几]
+ 实例:[XT*334588000000156*0008*REMIND,,时间1-开关,时间2-开关,周几]
+ 终端回复:
+ [XT*YYYYYYYYYYYYYYY*LEN*REMIND]
+ """
+ TYPE = "REMIND"
+
+ def send(self, event, msg):
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0006*REMIND"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ #Wechat_log("POWEROFF_ProtoCol:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+ # SZKW*860132060346475*0013*REMIND_CH_MEDICINE2,4-1
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_tmp_new = str(msg_tmp.split('REMIND,')[1])
+ msg_tmp_data = str(msg_tmp.split('REMIND')[1])
+ count = 0
+ for i in str(msg_tmp_data):
+ # print("i",i)
+ if i == ",":
+ count+=1
+
+ normal_alarm_save = []
+ # # ("handler -> b'[SZKW*860132060346475*001C*REMIND,08:00-1-1,,]'",)
+ # b'[SZKW*860132060346475*001B*REMIND,08:00-1-1,,]'",)
+ # medicine_alarmday = str(msg_data[4])
+ # alarmday=[]
+ alarm_day = []
+ alarm_switch = 0
+
+ print("count",count,msg_tmp_new)
+ if count >= 3:
+ count = 3
+ for i in range(0,count):#默认是三个时间多了也不保存
+ alarm_day = []
+ alarm_data = str(msg_tmp_new.split(',')[i])
+ # print("i",i,sleep_data)
+ if len(alarm_data) != 0:
+ b = alarm_data.find('-')
+ if b != -1:
+ alarm_time = alarm_data.split('-')[0]#-作为分隔符
+ alarm_switch = int(alarm_data.split('-')[1])#开关
+ alarm_repeat = int(alarm_data.split('-')[2])#是单次还是每天 还是自定义
+
+ alarm_hour = int(alarm_time.split(":")[0])#时间
+ alarm_min = int(alarm_time.split(":")[1])#冒号分隔时间 时 分
+
+
+ if alarm_repeat == 2:#每一天
+ alarm_day = [0,1,2,3,4,5,6]
+ elif alarm_repeat == 3:#自定义
+ alarm_day_tmp = alarm_data.split('-')[3]#-作为分隔符
+ if len(str(alarm_day_tmp)) != 0:
+ for i in range(0,7):
+ if alarm_day_tmp[i] != '0':
+ alarm_day.append(i)
+ else:#单次 1
+ alarm_day=[]
+ if alarm_switch != 0:
+ normal_alarm_save.append({"hour":alarm_hour,"min":alarm_min,"day":alarm_day,"enable":alarm_switch})
+
+ EventMesh.publish("set_storage_config",["normal_alarm",normal_alarm_save])
+ # normal_alarm = EventMesh.publish("get_storage_config","normal_alarm")
+
+ # EventMesh.debug_log("recv REMIND_SEND:{} normal_alarm ;{}".format(msg,normal_alarm))
+
+ EventMesh.publish(constants.PROTOCOL.REMIND_SEND)
+ EventMesh.publish("clear_normal_alarm")
+
+
+
+
+
+
+
+class HRSTART_ProtoCol(ProtoCol):
+ """心率频率数据"""
+ TYPE = "hrtstart"
+
+
+ def send(self, event, msg):
+ # [SZKW*867387060319491*0008*hrtstart]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0008*hrtstart"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ # EventMesh.debug_log("HRSTART_ProtoCol:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event: 心率数据下发
+ @param msg: 接收到的下行数据
+ """
+ # b'SZKW*860132060004322*0035*REMIND,23-04-06,14:41:06,b6e0d4c6,1,27,-1,40,6DF157335E02'
+ # EventMesh.debug_log("REMIND_ProtoCol RECV msg:%s"%(msg))
+ # HRSTART_ProtoCol RECV msg:b'SZKW*860132060004322*000D*hrtstart,7200' msg_:7200
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_tmp = msg_tmp.split(',')
+ msg_tmp = msg_tmp[1]
+ EventMesh.debug_log("HRSTART_ProtoCol RECV msg:{} msg_:{}".format(msg,msg_tmp))
+ hrTotal = int(msg_tmp)
+ if hrTotal == 1:#单次测量
+ EventMesh.debug_log("HRSTART_ 2".format(hrTotal))
+ get_hr_state = EventMesh.publish("get_hr_state")
+ get_spo2_state = EventMesh.publish("get_spo2_state")
+ get_bp_state = EventMesh.publish("get_bp_state")
+ get_bg_state = EventMesh.publish("get_bg_state")
+ # if (get_hr_state == 3 ) or (get_spo2_state == 0 and get_hr_state == 0):#只要两个不在测量 单次优先级最低
+ if (get_spo2_state == 0 and get_hr_state == 0 and get_bg_state == 0 and get_bp_state == 0):
+ battery = EventMesh.publish("screen_get_battery")
+ if battery != None:
+ if battery[0] != "1":
+ EventMesh.publish("set_hr_state",3)#3代表单次测量
+ pass
+ else:
+ if hrTotal > 0 and hrTotal <= 300:
+ hrTotal = 300
+ elif hrTotal >= 65536:
+ hrTotal = 65536
+ EventMesh.debug_log("HRSTART_ 3".format(hrTotal))
+ on = 0
+ if hrTotal != 0:
+ on = 1
+ EventMesh.publish("set_time_hr",[on,hrTotal])
+
+
+ EventMesh.publish(constants.PROTOCOL.HRTSTART_SEND)
+
+class HEART_ProtoCol(ProtoCol):
+ """心率数据"""
+ TYPE = "heart"
+
+
+ def send(self, event, msg):
+ # [SZKW*334588000000156*len*heart,x]
+ # EventMesh.debug_log("HEART:send:{}".format(msg))
+ len_size = len(str(msg))+len("heart,")
+ send_data = EventMesh.publish("get_new_pid")+"*%s*%04X*heart"%(self.imei,len_size)
+ MD5_head_data = EventMesh.publish("get_new_pid")+"*%s*%04X*%s"%(self.imei,len_size,"heart")
+ MD5_SIGN = self.pack_MD5_head(MD5_head_data)
+ data = "[%s%s,%d]"%(str(MD5_SIGN),send_data,msg)
+ # EventMesh.debug_log("HEART_ProtoCol:data:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event: 心率数据下发
+ @param msg: 接收到的下行数据
+ """
+ # EventMesh.debug_log("HRSTART_ProtoCol RECV msg:")
+ #EventMesh.publish(constants.PROTOCOL.HEART_SEND)
+class OXYGEN_ProtoCol(ProtoCol):
+ """上传血氧测试数据"""
+ TYPE = "oxygen"
+ def send(self, event, msg):
+ # [SZKW*334588000000156*len*heart,x]
+ # EventMesh.debug_log("oxstart:send:{}".format(msg))
+ len_size = len(str(msg))+len("oxygen,")
+ send_data = EventMesh.publish("get_new_pid")+"*%s*%04X*oxygen"%(self.imei,len_size)
+ MD5_head_data = EventMesh.publish("get_new_pid")+"*%s*%04X*%s"%(self.imei,len_size,"oxygen")
+ MD5_SIGN = self.pack_MD5_head(MD5_head_data)
+ data = "[%s%s,%d]"%(str(MD5_SIGN),send_data,msg)
+ # EventMesh.debug_log("HEART_ProtoCol:data:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event: 心率数据下发
+ @param msg: 接收到的下行数据
+ """
+ # EventMesh.debug_log("HRSTART_ProtoCol RECV msg:")
+ #EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND)
+
+class OXYGEN_One_ProtoCol(ProtoCol):#单次测量
+ """上传单次测量测试数据"""
+ TYPE = "oxstart"
+
+# 终端发送[XT*YYYYYYYYYYYYYYY*LEN*oxygen,x]
+# x 表示血氧饱和度
+# 示例[XT*334588000000156*0009*oxygen,15]
+# 平台回复:handler -> b'[SZKW*860132060004322*0009*oxstart,1]'
+# [XT*334588000000156*0006*oxygen]
+ def send(self, event, msg):
+ # [SZKW*334588000000156*len*heart,x]
+ EventMesh.debug_log("oxstart:")
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0007*oxstart"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ # EventMesh.debug_log("HEART_ProtoCol:data:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event: 血氧单次测量下发
+ @param msg: 接收到的下行数据
+ """
+ EventMesh.debug_log("oxstart:{}".format(msg))
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_tmp = msg_tmp.split(',')
+ msg_tmp = msg_tmp[1]
+
+ oxstartTotal = int(msg_tmp)
+ # oxstartTotal = 300
+ print("oxstartTotal:{}".format(oxstartTotal))
+ if oxstartTotal == 1:#单次测量
+ get_bp_state = EventMesh.publish("get_bp_state")
+ get_hr_state = EventMesh.publish("get_hr_state")
+ get_spo2_state = EventMesh.publish("get_spo2_state")
+ get_bg_state = EventMesh.publish("get_bp_state")
+ print("get_bp_state:{}".format(get_bp_state))
+ if get_bp_state == 0 and get_hr_state == 0 and get_spo2_state == 0 and get_bg_state == 0:#只要两个不在测量 单次优先级最低
+ battery = EventMesh.publish("screen_get_battery")
+ if battery != None:
+ if battery[0] != "1":
+ EventMesh.publish("set_spo2_state",3)#3代表单次测量
+ else:
+ if oxstartTotal > 0 and oxstartTotal <= 300:
+ oxstartTotal = 300
+ elif oxstartTotal >= 65536:
+ oxstartTotal = 65536
+
+ # if oxstartTotal == 0:#关闭自动测量
+ # EventMesh.debug_log("bpSTART_ 1")
+ # EventMesh.publish("set_spo2_time",[0,0])
+ # else:
+ on = 0
+ if oxstartTotal != 0:
+ on = 1
+ EventMesh.publish("set_spo2_time",[on,oxstartTotal])
+
+ EventMesh.publish(constants.PROTOCOL.OXSTART_SEND)
+
+class TEMP_ProtoCol(ProtoCol):
+ """上传体温测试数据"""
+ TYPE = "temp"
+ def send(self, event, msg):
+ # [SZKW*334588000000156*len*heart,x]
+ # EventMesh.debug_log("temp:send:{}".format(msg))
+ len_size = len(str(msg[0]))+len("temp,")+1+len(str(msg[1]))
+ EventMesh.debug_log("temp:send:{} len:{}".format(msg,len_size))
+ # 实例:[XT*334588000000156*0009*temp,36.2]
+ # 代表终端的温度为:36.2
+ # 平台回复:
+ # [XT*334588000000156*0004*temp]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*%04X*temp"%(self.imei,len_size)
+ MD5_head_data = EventMesh.publish("get_new_pid")+"*%s*%04X*%s"%(self.imei,len_size,"temp")
+ MD5_SIGN = self.pack_MD5_head(MD5_head_data)
+ data = "[%s%s,%d.%d]"%(str(MD5_SIGN),send_data,msg[0],msg[1])
+ # EventMesh.debug_log("temp:data:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event:
+ @param msg: 接收到的下行数据
+ """
+ # EventMesh.debug_log("HRSTART_ProtoCol RECV msg:")
+ #EventMesh.publish(constants.PROTOCOL.TEMP_SEND)
+
+class WDSTART_ProtoCol(ProtoCol):
+ """上传体温频率"""
+ TYPE = "wdstart"
+ def send(self, event, msg):
+ #[XT*334588000000156*len*wdstart,300]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0007*wdstart"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ # EventMesh.debug_log("temp:data:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event: 体温下发频率数据
+ @param msg: 接收到的下行数据
+ """
+ # EventMesh.debug_log("WDSTART_ProtoCol RECV msg:")
+ EventMesh.debug_log("wdstart:{}".format(msg))
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_tmp = msg_tmp.split(',')
+ msg_tmp = msg_tmp[1]
+
+ tempTotal = int(msg_tmp)
+ EventMesh.debug_log("tempTotal:{}".format(tempTotal))
+ if tempTotal == 1:#单次测量
+ get_temp_state = EventMesh.publish("get_temp_state")
+ EventMesh.debug_log("get_temp_state:{}".format(get_temp_state))
+ if get_temp_state == 0:#只要两个不在测量 单次优先级最低
+ battery = EventMesh.publish("screen_get_battery")
+ if battery != None:
+ if battery[0] != "1":
+ EventMesh.publish("set_temp_state",3)#3代表单次测量
+ else:
+ if tempTotal > 0 and tempTotal <= 300:
+ tempTotal = 300
+ elif tempTotal >= 65536:
+ tempTotal = 65536
+
+ EventMesh.publish("set_temp_time",tempTotal)
+
+
+
+ EventMesh.publish(constants.PROTOCOL.WDSTART_SEND)
+#解绑
+# 设置血压上传频率
+# 平台发送[XT*YYYYYYYYYYYYYYY*LEN*bldstart,x]
+# x为上传间隔时间,单位秒,连续上传时最小时间不小于300秒,最大不超过65535.
+# 示例[XT*334588000000156*0008*bldstart,300]
+# 终端回复:
+# [XT*334588000000156*0005*bldstart]
+# x为1则代表终端单次上传。
+# x为0则代表终端上传关闭。
+class bldstart_ProtoCol(ProtoCol):
+ """app下发血压测试频率"""
+ TYPE = "bldstart"
+ def send(self, event, msg):
+ #[XT*334588000000156*len*wdstart,300]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0008*bldstart"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ # print("temp:data:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event: 体温下发频率数据
+ @param msg: 接收到的下行数据
+ """
+ # print("WDSTART_ProtoCol RECV msg:")
+ print("bldstart:{}".format(msg))
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_tmp = msg_tmp.split(',')
+ msg_tmp = msg_tmp[1]
+
+ bldstartTotal = int(msg_tmp)
+ # bldstartTotal = 300
+ print("bldstartTotal:{}".format(bldstartTotal))
+ if bldstartTotal == 1:#单次测量
+ get_bp_state = EventMesh.publish("get_bp_state")
+ get_hr_state = EventMesh.publish("get_hr_state")
+ get_spo2_state = EventMesh.publish("get_spo2_state")
+ get_bg_state = EventMesh.publish("get_bg_state")
+ print("get_bp_state:{}".format(get_bp_state))
+ if get_bp_state == 0 and get_hr_state == 0 and get_spo2_state == 0 and get_bg_state == 0:#只要两个不在测量 单次优先级最低
+ battery = EventMesh.publish("screen_get_battery")
+ if battery != None:
+ if battery[0] != "1":
+ EventMesh.publish("set_bp_state",3)#3代表单次测量
+ else:
+ if bldstartTotal > 0 and bldstartTotal <= 300:
+ bldstartTotal = 300
+ elif bldstartTotal >= 65536:
+ bldstartTotal = 65536
+
+ on = 0
+ if bldstartTotal != 0:#关闭自动测量
+ on = 1
+ print("on:{} bldstartTotal:{} ".format(on,bldstartTotal))
+ EventMesh.publish("set_bp_time",[on,bldstartTotal])
+
+ EventMesh.publish(constants.PROTOCOL.BLDSTART_SEND)
+
+
+# 注:回复完后开始测量血压并上传(一般测一次90秒,app端会提醒用户两分钟后刷新页面查看)
+# 上传血压数据
+# 终端发送[XT*YYYYYYYYYYYYYYY*LEN*blood,x,y]
+# x 是收缩压(高压)
+# y 是舒张压(低压)
+# 示例[XT*334588000000156*000C*blood,150,70]
+# 平台回复:
+# [XT*334588000000156*0005*blood]
+class blood_ProtoCol(ProtoCol):
+ """上传血压测试数据"""
+ TYPE = "blood"
+ def send(self, event, msg):
+ len_size = len(str(msg[0]))+len("blood,")+1+len(str(msg[1]))
+ print("blood:send:{} len:{}".format(msg,len_size))
+ # 实例:[XT*334588000000156*0009*blood,36,2]
+ # 代表终端的
+ # 平台回复:
+ # [XT*334588000000156*0004*blood]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*%04X*blood"%(self.imei,len_size)
+ MD5_head_data = EventMesh.publish("get_new_pid")+"*%s*%04X*%s"%(self.imei,len_size,"blood")
+ MD5_SIGN = self.pack_MD5_head(MD5_head_data)
+ data = "[%s%s,%d,%d]"%(str(MD5_SIGN),send_data,msg[0],msg[1])
+ print("blood:data:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event:
+ @param msg: 接收到的下行数据
+ """
+ # print("HRSTART_ProtoCol RECV msg:")
+ #EventMesh.publish(constants.PROTOCOL.TEMP_SEND)
+
+
+
+
+# 设置血糖上传频率
+# 平台发送:
+# [XT*334588000000156*len*bgstart,x]
+# x为上传间隔时间,单位秒,连续上传时最小时间不小于300秒,最大不超过65535.
+# 实例:[XT*334588000000156*len*bgstart,300]
+# 终端会每隔300秒检测一次
+
+# x为1则代表终端单次上传。
+# x为0则代表终端上传关闭。
+class bgstart_ProtoCol(ProtoCol):
+ """app下发血糖测试频率"""
+ TYPE = "bgstart"
+ def send(self, event, msg):
+ #[XT*334588000000156*len*wdstart,300]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0007*bgstart"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ # print("temp:data:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event: 体温下发频率数据
+ @param msg: 接收到的下行数据
+ """
+ # print("WDSTART_ProtoCol RECV msg:")
+ print("bgstart:{}".format(msg))
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_tmp = msg_tmp.split(',')
+ msg_tmp = msg_tmp[1]
+
+ bgstartTotal = int(msg_tmp)
+ print("bgstartTotal:{}".format(bgstartTotal))
+ if bgstartTotal == 1:#单次测量
+ get_bp_state = EventMesh.publish("get_bp_state")
+ get_hr_state = EventMesh.publish("get_hr_state")
+ get_spo2_state = EventMesh.publish("get_spo2_state")
+ get_bg_state = EventMesh.publish("get_bg_state")
+ print("get_bg_state:{}".format(get_bg_state))
+ if get_bp_state == 0 and get_hr_state == 0 and get_spo2_state == 0 and get_bg_state == 0:#只要两个不在测量 单次优先级最低
+ battery = EventMesh.publish("screen_get_battery")
+ if battery != None:
+ if battery[0] != "1":
+ EventMesh.publish("set_bg_state",3)#3代表单次测量
+ else:
+ if bgstartTotal > 0 and bgstartTotal <= 300:
+ bgstartTotal = 300
+ elif bgstartTotal >= 65536:
+ bgstartTotal = 65536
+
+ # if bgstartTotal == 0:#关闭自动测量
+ # EventMesh.debug_log("bgSTART_ 1")
+ # EventMesh.publish("set_bgauto_time",[0,0])
+ # else:
+ on = 0
+ if bgstartTotal != 0:
+ on = 1
+ EventMesh.publish("set_bgauto_time",[on,bgstartTotal])
+
+ EventMesh.publish(constants.PROTOCOL.BGSTART_SEND)
+
+# 上传血糖数据
+# 终端发送[XT*YYYYYYYYYYYYYYY*LEN*bloodglucose,x]
+# x 表示血糖,单位mmol/L
+# 示例[XT*334588000000156*0010*bloodglucose,6.1]
+# 平台回复:
+# [XT*334588000000156*000B*bloodglucose]
+class bloodglucose_ProtoCol(ProtoCol):
+ """上传血糖测试数据"""
+ TYPE = "bloodglucose"
+ def send(self, event, msg):
+ len_size = len("bloodglucose,")+1+len(str(msg))
+ print("bloodglucose:send:{} len:{}".format(msg,len_size))
+ # 实例:[XT*334588000000156*0009*blood,36,2]
+ # 代表终端的
+ # 平台回复:
+ # [XT*334588000000156*0004*blood]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*%04X*bloodglucose"%(self.imei,len_size)
+ MD5_head_data = EventMesh.publish("get_new_pid")+"*%s*%04X*%s"%(self.imei,len_size,"bloodglucose")
+ MD5_SIGN = self.pack_MD5_head(MD5_head_data)
+ data = "[%s%s,%s]"%(str(MD5_SIGN),send_data,msg)
+ print("bloodglucose:data:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event:
+ @param msg: 接收到的下行数据
+ """
+ # print("HRSTART_ProtoCol RECV msg:")
+ #EventMesh.publish(constants.PROTOCOL.TEMP_SEND)
+
+# [XT*334588000000156*0003*DLT]
+def reset_factory(msg):
+ if msg == 1:
+ Power.powerRestart()
+class DLT_ProtoCol(ProtoCol):
+ """解绑数据"""
+ TYPE = "DLT"
+ def send(self, event, msg):
+ # [XT*334588000000156*0004*temp]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0003*DLT"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ EventMesh.debug_log("temp:data:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event:
+ @param msg: 接收到的下行数据
+ """
+ # EventMesh.debug_log("DLT_ProtoCol RECV msg:")
+
+
+#定位频率
+class UPLOAD_ProtoCol(ProtoCol):
+ """定位频率数据"""
+ TYPE = "UPLOAD"
+ def send(self, event, msg):
+ # [XT*334588000000156*0004*temp]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0006*UPLOAD"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event:
+ @param msg: 接收到的下行数据
+ """
+ # b'[SZKW*867387060319166*000A*UPLOAD,600]'
+ # EventMesh.debug_log("DLT_ProtoCol RECV msg:".format(msg))
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_tmp = msg_tmp.split(',')
+ msg_tmp = msg_tmp[1]
+ upload_time = int(msg_tmp)
+ EventMesh.publish("set_storage_config",["upload_time",upload_time])
+
+ EventMesh.publish("set_upload_data", upload_time)
+ EventMesh.publish(constants.PROTOCOL.UPLOAD_SEND)
+
+#设置快捷号码
+class CENTER_ProtoCol(ProtoCol):
+ """设置快捷号码"""
+ TYPE = "CENTER"
+ def send(self, event, msg):
+ # [XT*334588000000156*0004*temp]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0006*CENTER"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ EventMesh.debug_log("UPLOAD:data:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event:
+ @param msg: 接收到的下行数据
+ """
+ # b'[SZKW*867387060319166*000A*UPLOAD,600]'
+ # EventMesh.debug_log("DLT_ProtoCol RECV msg:".format(msg))
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_tmp = msg_tmp.split(',')
+ msg_tmp = msg_tmp[1]
+ EventMesh.debug_log("CENTER_ProtoCol RECV msg:{} msg_:{}".format(msg,msg_tmp))
+ center_dial = str(msg_tmp)
+ EventMesh.publish("set_storage_config",["center_dial",center_dial])
+ EventMesh.publish(constants.PROTOCOL.CENTER_SEND)
+
+#呼叫快捷电话号码
+import voiceCall
+class MONITOR_ProtoCol(ProtoCol):
+ """呼叫快捷号码"""
+ TYPE = "MONITOR"
+ def send(self, event, msg):
+ # [XT*334588000000156*0004*MONITOR]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0007*MONITOR"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ EventMesh.debug_log("MONITOR:data:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event:
+ @param msg: 接收到的下行数据
+ """
+ # b'[SZKW*867387060319166*000A*MONITOR]'
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_tmp = msg_tmp.split('MONITOR')
+ msg_tmp = msg_tmp[1]
+ EventMesh.debug_log("MONITOR_ProtoCol RECV msg:{} msg_:{}".format(msg,len(msg_tmp)))
+ if len(msg_tmp) != 0:
+ EventMesh.publish("save_phonename", contact)
+ EventMesh.publish("save_phonenum", contact)
+ EventMesh.publish("dial_out_call_center_cb",contact)#电话拨出去
+ else:
+ read_data = EventMesh.publish("get_storage_config","center_dial")
+ EventMesh.debug_log("MONITOR:data:%s"%(read_data))
+ if read_data != None:
+ contact = read_data
+ if len(contact) > 0:
+ EventMesh.debug_log("MONITOR RECV msg:{} {}".format(contact,type(contact)))
+ EventMesh.publish("save_phonename", contact)
+ EventMesh.publish("save_phonenum", contact)
+ EventMesh.publish("dial_out_call_center_cb",contact)#电话拨出去
+ EventMesh.publish(constants.PROTOCOL.MONITOR_SEND)
+
+#定时开关机
+class bootoff_ProtoCol(ProtoCol):
+ """定时开关机"""
+ TYPE = "BOOTOFF"
+ def send(self, event, msg):
+ # [XT*334588000000156*0004*MONITOR]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0007*BOOTOFF"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ EventMesh.debug_log("BOOTOFF:data:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+ def recv(self, event, msg):
+ """
+ @param event:
+ @param msg: 接收到的下行数据
+ """
+ # b'[SZKW*867387060319166*000A*SOS_SEND]'
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_tmp = msg_tmp.split(',')
+ on_bt = int(msg_tmp[1])
+ start_hour = int(str(msg_tmp[2]).split(":")[0])
+ start_min = int(str(msg_tmp[2]).split(":")[1])
+
+ end_hour = int(str(msg_tmp[3]).split(":")[0])
+ end_min = int(str(msg_tmp[3]).split(":")[1])
+
+ EventMesh.debug_log("BOOTOFF:send data:",on_bt,start_hour,start_min,end_hour,end_min)
+ poweroff = []
+ poweroff.append({"poweroff_on":on_bt,"start_hour":start_hour,"start_min":start_min,"end_hour":end_hour,"end_min":end_min})
+ #b'[SZKW*860132060006970*0015*BOOTOFF,1,06:00,23:59]'
+ EventMesh.publish("set_boot_off_time",poweroff)#设置关机时间
+
+ EventMesh.publish(constants.PROTOCOL.BOOTOFF_SEND)
+
+
+#sos家庭号码
+class sosHome_dial_ProtoCol(ProtoCol):
+ """sos家庭号码"""
+ TYPE = "SOS"
+ def send(self, event, msg):
+ # [XT*334588000000156*0004*MONITOR]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0003*SOS"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ print("sosHome_dial_ProtoCol:data:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event:
+ @param msg: 接收到的下行数据
+ """
+
+ # b'[SZKW*867387060319166*000A*SOS_SEND]'
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_tmp = msg_tmp.split(',')
+
+ # print("sosHome_dial_ProtoCol:send data :{} {}".format(len(msg_tmp),msg_tmp))
+ #b'[SZKW*860132060006970*0015*sosHome_dial_ProtoCol,15521469561,10086,15521469561]'
+ i = 0
+ num = 0
+ count = 0
+ print("sos msg_tmp",msg_tmp)
+ if len(msg_tmp) > 4:
+ num = 3
+ else:
+ num = len(msg_tmp)-1
+ data = []
+ for i in range(num):
+ # print("sos:send data :{}".format(msg_tmp[i+1]))
+ if len(msg_tmp[i+1]) != 0:
+ EventMesh.publish("set_storage_config",["SOS_NUMBER{}".format(i+1),msg_tmp[i+1]])
+ data.append(str(msg_tmp[i+1]))
+ count+=1
+ print("data:{}".format(data))
+ EventMesh.publish("set_dial_sos_number",data)
+
+ EventMesh.publish(constants.PROTOCOL.SOS_SEND)
+
+
+# 低电提醒
+#[XT*334588000000156*0008*LOWBAT,1]
+class LOWBAT_ProtoCol(ProtoCol):
+ """低电提醒"""
+ TYPE = "LOWBAT"
+ def send(self, event, msg):
+ # [XT*334588000000156*0006*LOWBAT]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0006*LOWBAT"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ EventMesh.debug_log("LOWBAT:data:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event:
+ @param msg: 接收到的下行数据
+ """
+ # b'[SZKW*867387060319166*000A*LOWBAT]'
+
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_tmp = msg_tmp.split(',')
+ on_bt = msg_tmp[1]
+ EventMesh.debug_log("LOWBAT:send data:{}".format(on_bt))
+ #b'[SZKW*860132060006970*0015*LOWBAT,1,06:00,23:59]'
+ EventMesh.publish("set_low_bat_btn",on_bt)
+ EventMesh.publish(constants.PROTOCOL.LOWBAT_SEND)
+
+# 设置系统时间
+#
+class Time_ProtoCol(ProtoCol):
+ """设置系统时间"""
+ TYPE = "Time"
+ def send(self, event, msg):
+ #
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0004*Time"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ EventMesh.debug_log("Time:data:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event:
+ @param msg: 接收到的下行数据
+ """
+ # rtc = RTC()
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_data = msg_tmp.split(',')
+
+ timeSecond = int(msg_data[1])
+ #EventMesh.debug_log("type {} timeSecond {}".format((msg_data[1]),timeSecond))
+ # timeSecond = 1703001360
+ next_alarm_time = utime.localtime(timeSecond)
+ #EventMesh.debug_log("next_alarm_time",next_alarm_time)
+ #EventMesh.debug_log("local time",msg)
+ # machine.RTC().datetime((tm[0], tm[1], tm[2], tm[6], tm[3], tm[4], tm[5], 0))
+
+ machine.RTC().datetime((next_alarm_time[0],next_alarm_time[1],next_alarm_time[2],next_alarm_time[6],next_alarm_time[3],next_alarm_time[4],next_alarm_time[5],0))
+ #next_alarm_time = utime.localtime(old_Timesec)#年月日时分秒星期365中的第几天
+ EventMesh.publish("set_rtc_alarm")
+ #EventMesh.publish(constants.PROTOCOL.TIME_SEND)
+
+
+
+
+#免打扰
+class SILENCETIME2_ProtoCol(ProtoCol):
+ """免打扰"""
+ TYPE = "SILENCETIME2"
+ def send(self, event, msg):
+ # [XT*334588000000156*0006*SILENCETIME2]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*000C*SILENCETIME2"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ # EventMesh.debug_log("KEYBRD:data:%s"%(data))
+ # EventMesh.debug_log("SILENCETIME2!!!!!!!!!!!!!",msg)
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event:
+ @param msg: 接收到的下行数据
+ """
+ # b'[SZKW*867387060319166*000A*KEYBRD]'
+ # EventMesh.debug_log("SILENCETIME2!!!!!!!!!!!!!",msg)
+ EventMesh.publish(constants.PROTOCOL.SILENCETIME2_SEND)
+
+#键盘开关
+class KEYBRD_ProtoCol(ProtoCol):
+ """免打扰"""
+ TYPE = "KEYBRD"
+ def send(self, event, msg):
+ # [XT*334588000000156*0006*SILENCETIME2]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0006*KEYBRD"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ # EventMesh.debug_log("KEYBRD:data:%s"%(data))
+ # EventMesh.debug_log("KEYBRD!!!!!!!!!!!!!",msg)
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event:
+ @param msg: 接收到的下行数据
+ """
+ # b'[SZKW*867387060319166*000A*KEYBRD]'
+ # EventMesh.debug_log("KEYBRD!!!!!!!!!!!!!",msg)
+ EventMesh.publish(constants.PROTOCOL.KEYBRD_SEND)
+
+class TK_ProtoCol(ProtoCol):
+ """微聊"""
+ TYPE = "TK"
+
+
+ def send(self, event, msg):
+ EventMesh.debug_log("TK send:")
+ if len(str(msg)) == 1:
+
+ len_size = len(str(msg))+len("TK,")
+ # 实例:[XT*334588000000156*0009*TK,1]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*%04X*TK"%(self.imei,len_size)
+ MD5_head_data = EventMesh.publish("get_new_pid")+"*%s*%04X*%s"%(self.imei,len_size,"TK")
+ MD5_SIGN = self.pack_MD5_head(MD5_head_data)
+ data = "[%s%s,%d]"%(str(MD5_SIGN),send_data,msg)
+ EventMesh.debug_log("TK:data:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+ else:
+ # [SZKW*YYYYYYYYYYYYYYY*LEN*TK,AMR 格式音频数据]
+ #[XT*YYYYYYYYYYYYYYY*LEN*TKS,秒数(十进制),AMR 格式音频数据]
+ arm_data = msg
+ # arm_sec = msg[0]
+ # EventMesh.debug_log("TK_ProtoCol:msgtype:{} arm_sec:{}".format(len(msg[1]),arm_sec))
+
+ arm = bytearray()
+ for i in range(len(arm_data)):
+ if arm_data[i] == 0x7d:
+ arm.extend(b'\x7d\x01')
+ elif arm_data[i] == 0x5b :
+ arm.extend(b'\x7d\x02')
+ elif arm_data[i] == 0x5d :
+ arm.extend(b'\x7d\x03')
+ elif arm_data[i] == 0x2c :
+ arm.extend(b'\x7d\x04')
+ elif arm_data[i] == 0x2a :
+ arm.extend(b'\x7d\x05')
+ else :
+ arm.append(arm_data[i])
+
+ datalen = len(arm) + len("TK,")+1
+ #Wechat_log("len(str(arm_sec)):{}".format(len(str(arm_sec))+1))
+ send_data = bytearray(EventMesh.publish("get_new_pid")+"*%s*%04X*TK,"%(self.imei,datalen))
+ send_data.extend(arm)
+ MD5_head_data = EventMesh.publish("get_new_pid")+"*%s*%04X*%s"%(self.imei,datalen,"TK")
+ MD5_SIGN = self.pack_MD5_head(MD5_head_data)
+ data = bytearray('[')
+ data.extend(MD5_SIGN)
+ data.extend(send_data)
+ data.extend(']')
+ # EventMesh.debug_log("TK:send data:%s MD5_head_data:%s"%(data,MD5_head_data))
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+
+ def recv(self, event, msg):
+ """
+
+ ("TK_ProtoCol:datalen:{} {} {}".format(wechat_num,MXA_MSG,wechat_recode_list))
+ @param event: 微聊
+ @param msg: 接收到的下行数据
+ [SZKW*860132060004322*20BD*TK,#!AMR...]
+ """
+ #Wechat_log("K_ProtoCol:recv:data:{}".format(msg))
+
+ msg_tmp = msg.decode('ascii')
+ str = msg_tmp.split('TK,')
+ # Wechat_log("TK_ProtoCol:recv:len:{} {} {}".format(len(msg),len(str),msg_tmp.find("#!AMR")))
+
+ read_AMR_flag = msg_tmp.find("#!AMR")
+ #EventMesh.debug_log("TK recv:read_AMR_flag:{} ,{}".format(read_AMR_flag,EventMesh.publish("get_wechat_record_flag")))
+ # if EventMesh.publish("get_wechat_record_flag") != 1 and read_AMR_flag != -1: #是否是服务器下发音频数据
+ if read_AMR_flag != -1: #是否是服务器下发音频数据
+ # Wechat_log("TK_ProtoCol:recv:datalen{}".format(len(msg)))
+ arm_data = bytearray(str[1])#获取amr输出
+ get_wechat_data = EventMesh.publish("get_wechat_data")
+ MXA_MSG = get_wechat_data[0]
+ wechat_recode_list = get_wechat_data[1]
+ wechat_num = int(wechat_recode_list["num"])
+ # Wechat_log("TK_ProtoCol:datalen:{} {} {}".format(wechat_num,MXA_MSG,wechat_recode_list))
+
+ if wechat_num >= MXA_MSG:
+ wechat_num = 0
+ if wechat_num == 0:
+ wechat_num += 1
+ elif wechat_num > 0:
+ wechat_num += 1
+
+
+ EventMesh.debug_log("num_total:datalen:{} {}".format(MXA_MSG,wechat_recode_list))
+ wechat_recode_list["%02d"%(wechat_num)] = "read:1"
+ wechat_recode_list['num'] = wechat_num
+ EventMesh.publish("set_wechat_data",[MXA_MSG,wechat_recode_list])
+ #写语音文件数据
+
+ # path = "/usr/static/storage_file/wechat.amr"
+ path = "/usr/static/storage_file/{}.amr".format(wechat_num)
+ with open(path,"w") as fd:
+ arm = bytearray()
+ j = 0
+ for i in range(len(arm_data)):
+ if arm_data[j] == 0x7d and arm_data[j+1] == 0x01:
+ arm.extend(b'\x7d')
+ j+=1
+ elif arm_data[j] == 0x7d and arm_data[j+1] == 0x02:
+ arm.extend(b'\x5b')
+ j+=1
+ elif arm_data[j] == 0x7d and arm_data[j+1] == 0x03:
+ arm.extend(b'\x5d')
+ j+=1
+ elif arm_data[j] == 0x7d and arm_data[j+1] == 0x04:
+ arm.extend(b'\x2c')
+ j+=1
+ elif arm_data[j] == 0x7d and arm_data[j+1] == 0x05:
+ arm.extend(b'\x2a')
+ j+=1
+ else :
+ arm.append(arm_data[j])
+ j+=1
+ if j >= len(arm_data):
+ break
+ fd.write(arm)
+ EventMesh.publish("recv_wechat_audio")#
+ EventMesh.publish(constants.PROTOCOL.TK_SEND,1)
+ EventMesh.debug_log("constants.PROTOCOL.TK_SEND1!!!")
+ else :
+ if read_AMR_flag != -1:
+ EventMesh.publish(constants.PROTOCOL.TK_SEND,0)
+
+class TKS_ProtoCol(ProtoCol):
+ """微聊"""
+ TYPE = "TKS"
+
+
+ def send(self, event, msg):
+ EventMesh.debug_log("TKS send:")
+ if len(str(msg)) == 1:
+ len_size = len(str(msg))+len("TKS,")
+ # 实例:[XT*334588000000156*0009*TK,1]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*%04X*TKS"%(self.imei,len_size)
+ MD5_head_data = EventMesh.publish("get_new_pid")+"*%s*%04X*%s"%(self.imei,len_size,"TKS")
+ MD5_SIGN = self.pack_MD5_head(MD5_head_data)
+ data = "[%s%s,%d]"%(str(MD5_SIGN),send_data,msg)
+ EventMesh.debug_log("TKS:data:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+ else:
+ # [SZKW*YYYYYYYYYYYYYYY*LEN*TK,AMR 格式音频数据]
+ #[XT*YYYYYYYYYYYYYYY*LEN*TKS,秒数(十进制),AMR 格式音频数据]
+ arm_data = msg[1]
+ arm_sec = msg[0]
+ EventMesh.debug_log("TK_ProtoCol:msgtype:{} arm_sec:{}".format(len(msg[1]),arm_sec))
+
+ arm = bytearray()
+ for i in range(len(arm_data)):
+ if arm_data[i] == 0x7d:
+ arm.extend(b'\x7d\x01')
+ elif arm_data[i] == 0x5b :
+ arm.extend(b'\x7d\x02')
+ elif arm_data[i] == 0x5d :
+ arm.extend(b'\x7d\x03')
+ elif arm_data[i] == 0x2c :
+ arm.extend(b'\x7d\x04')
+ elif arm_data[i] == 0x2a :
+ arm.extend(b'\x7d\x05')
+ else :
+ arm.append(arm_data[i])
+
+ datalen = len(arm) + len("TKS,")+len(str(arm_sec))+1
+ #Wechat_log("len(str(arm_sec)):{}".format(len(str(arm_sec))+1))
+ send_data = bytearray(EventMesh.publish("get_new_pid")+"*%s*%04X*TKS,%d,"%(self.imei,datalen,arm_sec))
+ send_data.extend(arm)
+ MD5_head_data = EventMesh.publish("get_new_pid")+"*%s*%04X*%s"%(self.imei,datalen,"TKS")
+ MD5_SIGN = self.pack_MD5_head(MD5_head_data)
+ data = bytearray('[')
+ data.extend(MD5_SIGN)
+ data.extend(send_data)
+ data.extend(']')
+ # EventMesh.debug_log("TK:send data:%s MD5_head_data:%s"%(data,MD5_head_data))
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+
+ def recv(self, event, msg):
+ """
+
+ ("TK_ProtoCol:datalen:{} {} {}".format(wechat_num,MXA_MSG,wechat_recode_list))
+ @param event: 微聊
+ @param msg: 接收到的下行数据
+ [SZKW*860132060004322*20BD*TK,#!AMR...]
+ """
+ #Wechat_log("K_ProtoCol:recv:data:{}".format(msg))
+ # EventMesh.debug_log("TK recv:{}".format(msg))
+ msg_tmp = msg.decode('ascii')
+ str = msg_tmp.split('TKS,')
+ # Wechat_log("TK_ProtoCol:recv:len:{} {} {}".format(len(msg),len(str),msg_tmp.find("#!AMR")))
+ read_AMR_flag = msg_tmp.find("#!AMR")
+ # if EventMesh.publish("get_wechat_record_flag") != 1 and read_AMR_flag != -1: #是否是服务器下发音频数据
+ if read_AMR_flag != -1: #是否是服务器下发音频数据
+ # Wechat_log("TK_ProtoCol:recv:datalen{}".format(len(msg)))
+ arm_data = bytearray(str[1])#获取amr输出
+ get_wechat_data = EventMesh.publish("get_wechat_data")
+ MXA_MSG = get_wechat_data[0]
+ wechat_recode_list = get_wechat_data[1]
+ wechat_num = int(wechat_recode_list["num"])
+ # Wechat_log("TK_ProtoCol:datalen:{} {} {}".format(wechat_num,MXA_MSG,wechat_recode_list))
+
+ if wechat_num >= MXA_MSG:
+ wechat_num = 0
+ if wechat_num == 0:
+ wechat_num += 1
+ elif wechat_num > 0:
+ wechat_num += 1
+
+
+ EventMesh.debug_log("num_total:datalen:{} {}".format(MXA_MSG,wechat_recode_list))
+ wechat_recode_list["%02d"%(wechat_num)] = "read:1"
+ wechat_recode_list['num'] = wechat_num
+ EventMesh.publish("set_wechat_data",[MXA_MSG,wechat_recode_list])
+ #写语音文件数据
+
+ # path = "/usr/static/storage_file/wechat.amr"
+ path = "/usr/static/storage_file/{}.amr".format(wechat_num)
+ with open(path,"w") as fd:
+ arm = bytearray()
+ j = 0
+ for i in range(len(arm_data)):
+ if arm_data[j] == 0x7d and arm_data[j+1] == 0x01:
+ arm.extend(b'\x7d')
+ j+=1
+ elif arm_data[j] == 0x7d and arm_data[j+1] == 0x02:
+ arm.extend(b'\x5b')
+ j+=1
+ elif arm_data[j] == 0x7d and arm_data[j+1] == 0x03:
+ arm.extend(b'\x5d')
+ j+=1
+ elif arm_data[j] == 0x7d and arm_data[j+1] == 0x04:
+ arm.extend(b'\x2c')
+ j+=1
+ elif arm_data[j] == 0x7d and arm_data[j+1] == 0x05:
+ arm.extend(b'\x2a')
+ j+=1
+ else :
+ arm.append(arm_data[j])
+ j+=1
+ if j >= len(arm_data):
+ break
+ fd.write(arm)
+ EventMesh.publish("recv_wechat_audio")#
+ EventMesh.publish(constants.PROTOCOL.TKS_SEND,1)#返回接收成功
+ else :
+ if read_AMR_flag != -1 :
+ EventMesh.publish(constants.PROTOCOL.TKS_SEND,0)#返回接收失败
+
+
+
+
+
+
+
+class MESSAGE_ProtoCol(ProtoCol):
+ """微聊"""
+ TYPE = "MESSAGE"
+
+
+ def send(self, event, msg):
+ #[XT*334588000000156*0007*MESSAGE]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0007*MESSAGE"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ #Wechat_log("POWEROFF_ProtoCol:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+ """
+
+ @param event: 微聊文字
+ @param msg: 接收到的下行数据
+ """
+ # msg = msg[1:-1]
+
+ # msg_s = msg.decode('ascii')
+ # msg_s = msg_s.split(',')
+ # msg_s = msg_s[1]
+ # # Wechat_log("msg_tmp:len:{}\r\n data:{}".format(len(msg_s),msg_s))
+
+
+ # get_wechat_data = EventMesh.publish("get_wechat_data")
+
+ # MXA_MSG = get_wechat_data[0]
+ # wechat_recode_list = get_wechat_data[1]
+ # wechat_num = wechat_recode_list["num"]
+ # # Wechat_log("TK_ProtoCol:datalen:{} {} {}".format(wechat_num,MXA_MSG,wechat_recode_list))
+
+ # if wechat_num >= MXA_MSG:
+ # wechat_num = 0
+ # if wechat_num == 0:
+ # wechat_num += 1
+ # elif wechat_num > 0:
+ # wechat_num += 1
+ # msg_txt = {}
+ # # 0 1 2 3
+ # Wechat_log("wechat_num:init {}".format(wechat_num))
+ # msg_txt = UnicodeHexStr_To_Utf8Str(msg_s)
+ # # Wechat_log("msg_txt:{}".format(msg_txt))
+ # wechat_recode_list["%02d"%(wechat_num)] = "T:{}".format(msg_txt)
+ # wechat_recode_list['num'] = wechat_num
+ # EventMesh.publish("set_wechat_data",[MXA_MSG,wechat_recode_list])
+ # # Wechat_log("wechat_recode_list:len data:{}".format(wechat_recode_list))
+
+ # screen_NAME = EventMesh.publish("get_screen_NAME")
+ # get_lcd_state = EventMesh.publish("get_lcd_state")
+ # if screen_NAME != "wechat" or get_lcd_state == 0:
+ # EventMesh.publish("load_screen", {"screen": "wechat_popup"})
+ # else:
+ # EventMesh.publish("wechat_updata_list_show")
+ EventMesh.publish(constants.PROTOCOL.MESSAGE_SEND)
+ # EventMesh.publish("recv_wechat_audio")#
+
+class FALLDOWN_ProtoCol(ProtoCol):
+ """
+ 跌倒提醒开关
+ 服务器下发跌倒报警设置命令
+ [XT*334588000000156*LEN*FALLDOWN,ONOFF]
+ ONOFF: 1:开启,0:关闭。
+ 终端回复
+ [XT*334588000000156*LEN*FALLDOWN]
+ """
+ TYPE = "FALLDOWN"
+
+ def send(self, event, msg):
+
+ #[XT*334588000000156*LEN*FALLDOWN]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0008*FALLDOWN"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ #Wechat_log("POWEROFF_ProtoCol:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+ """
+ [SZKW*860132060341484*000A*FALLDOWN,1]
+ """
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_data = msg_tmp.split(',')
+
+ Falldowm = msg_data[1]
+ EventMesh.debug_log("FALLDOWN:{}".format(Falldowm))
+ EventMesh.publish("set_storage_config",["fall_sw",Falldowm])
+
+ EventMesh.publish(constants.PROTOCOL.FALLDOWN_SEND)
+
+class REMOVE_ProtoCol(ProtoCol):
+ """
+ 取下手环报警开关
+ 平台发送:
+ [XT*YYYYYYYYYYYYYYY*LEN*REMOVE,0或者1]
+ 实例:[XT*334588000000156*0008*REMOVE,1]
+ 终端回复:
+ [XT*YYYYYYYYYYYYYYY*LEN*REMOVE]
+ """
+ TYPE = "REMOVE"
+
+ def send(self, event, msg):
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0006*REMOVE"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ #Wechat_log("POWEROFF_ProtoCol:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_data = msg_tmp.split(',')
+ Falldowm = msg_data[1]
+ EventMesh.debug_log("REMOVE:{}".format(Falldowm))
+ EventMesh.publish("set_storage_config",["remove_sw",Falldowm])
+ EventMesh.publish(constants.PROTOCOL.REMOVE_SEND)
+
+class HELP_ProtoCol(ProtoCol):
+ """
+一键报警
+ [XT*YYYYYYYYYYYYYYY*LEN*HELP,状态]
+ 状态值为整数:60或不带默认是普通报警,61光电式感烟火灾报警,62检测环境温度(高温报警,温度变化报警),
+ 63人体活动检测报警,64电池欠压提醒功能,65设备脱落提醒功能,66离线报警,67测试报警,123气感报警,
+ 124烟感报警,125水浸报警
+ 实例:
+ [XT*334588000000156*0004*HELP,60]
+ """
+ TYPE = "HELP"
+
+ def send(self, event, msg):
+ #[XT*334588000000156*LEN*FALLDOWN]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0008*HELP,%d"%(self.imei,msg)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ #Wechat_log("POWEROFF_ProtoCol:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+ """
+ [XT*334588000000156*0004*HELP,60]
+ """
+
+ pass
+
+
+#喝水闹钟提示
+# 喝水闹钟设置指令
+# 平台发送:
+# [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_DRINK,时间间隔(小时),开关(0为关,1为开)]
+# 实例:
+# [XT*334588000000156*0026*REMIND_CH_DRINK,4,0]
+# 终端回复:
+# [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_DRINK]
+# 实例:[XT*334588000000156*000E*REMIND_CH_DRINK]
+class REMIND_CHDRINK_ProtoCol(ProtoCol):
+ """
+
+ 平台发送:
+ [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_DRINK,时间间隔(小时),开关(0为关,1为开)]
+ 实例:[XT*334588000000156*0008*REMIND_CH_DRINK,时间间隔(小时),开关(0为关,1为开)]
+ 终端回复:
+ [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_DRINK]
+ """
+ TYPE = "REMIND_CH_DRINK"
+
+ def send(self, event, msg):
+ send_data = EventMesh.publish("get_new_pid")+"*%s*000F*REMIND_CH_DRINK"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ #Wechat_log("POWEROFF_ProtoCol:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+ # SZKW*860132060346475*0013*REMIND_CH_DRINK,4-1
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_data = msg_tmp.split(',')
+ data = str(msg_data[1])
+ hour = int(data.split('-')[0])
+ btn_on = int(data.split('-')[1])
+
+ EventMesh.debug_log("recv REMIND_CH_DRINK:{}-{}-{}".format(hour,btn_on,msg))
+ EventMesh.publish("set_storage_config",["drink_on",btn_on])
+ EventMesh.publish("set_storage_config",["drink_time",hour])
+ EventMesh.publish(constants.PROTOCOL.REMIND_CH_DRINK_SEND)
+
+# 自定义服药闹钟设置指令
+# 平台发送:
+# [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_MEDICINE2,时间1-开关,时间2-开关,周几]
+# 实例:
+# [XT*334588000000156*0026*REMIND_CH_MEDICINE2,08:10-0,09:10-0,1000001]
+# 终端回复:
+# [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_MEDICINE2]
+# 实例:[XT*334588000000156*000E*REMIND_CH_MEDICINE2]
+# 说明:闹铃格式为:时间-开关(0/1),周几(周六到周日)
+
+#REMIND_CH_MEDICINE2,09:00-1,14:00-0,18:00-0,1111111]'",)
+class REMIND_CHMEDICINE2_ProtoCol(ProtoCol):#吃药提醒
+ """
+
+ 平台发送:
+ [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_MEDICINE2,,时间1-开关,时间2-开关,周几]
+ 实例:[XT*334588000000156*0008*REMIND_CH_MEDICINE2,,时间1-开关,时间2-开关,周几]
+ 终端回复:
+ [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_MEDICINE2]
+ """
+ TYPE = "REMIND_CH_MEDICINE2"
+
+ def send(self, event, msg):
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0013*REMIND_CH_MEDICINE2"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ #Wechat_log("POWEROFF_ProtoCol:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+ # SZKW*860132060346475*0013*REMIND_CH_MEDICINE2,4-1
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+
+ msg_data = str(msg_tmp.split('REMIND_CH_MEDICINE2,')[1])
+ msg_data_tmp = str(msg_tmp.split('REMIND_CH_MEDICINE2')[1])
+
+ medicin_data = []
+ alarmday=[]
+ count = 0
+ for i in str(msg_data_tmp):
+ # print("i",i)
+ if i == ",":
+ count+=1
+
+ if count >= 3:
+ count = 3
+ medicine_alarmday = []
+ for i in range(0,count):#默认是三个时间多了也不保存
+ medicine_alarmday = str(msg_data.split(",")[count])
+ # print("i",i)
+ medicine_alarm = str(msg_data.split(",")[i])
+ if str(medicine_alarm).find("-") != -1:
+ on = int(medicine_alarm.split('-')[1])
+ if on != 0:
+ alarmday = []
+ data = str(medicine_alarm.split('-')[0])
+ hour = int(data.split(":")[0])
+ min = int(data.split(":")[1])
+ for i in range(0,7):
+ # print("medicine_alarmday",medicine_alarmday,medicine_alarmday[i])
+ if medicine_alarmday[i] != '0':
+ alarmday.append(i)
+ enable = 1
+ medicin_data.append({"hour":hour,"min":min,"day":alarmday,"enable":enable})
+
+ EventMesh.publish("set_storage_config",["medicine",medicin_data])
+ EventMesh.debug_log("recv REMIND_CH_MEDICINE2:{} medicin_data ;{}".format(msg,medicin_data))
+
+ EventMesh.publish(constants.PROTOCOL.REMIND_CH_MEDICINE2_SEND)
+ EventMesh.publish("clear_medicine_alarm")
+
+# 回家闹钟设置指令
+# 可设置闹钟的提醒文字
+# 平台发送:
+# [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_HOME,闹钟1,闹钟2,闹钟3]
+# 实例:
+# [XT*334588000000156*0018*REMIND_CH_HOME,08:10,12:10]
+# 终端回复:
+# [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_HOME]
+# 实例:[XT*334588000000156*0006*REMIND_CH_HOME]
+# 说明:闹钟为时间点;
+class REMIND_CH_HOME_ProtoCol(ProtoCol):#回家提醒
+ """
+
+ 平台发送:
+ [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_HOME,,时间1-开关,时间2-开关,周几]
+ 实例:[XT*334588000000156*0008*REMIND_CH_HOME,,时间1-开关,时间2-开关,周几]
+ 终端回复:
+ [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_HOME]
+ """
+ TYPE = "REMIND_CH_HOME"
+
+ def send(self, event, msg):
+ send_data = EventMesh.publish("get_new_pid")+"*%s*000E*REMIND_CH_HOME"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ #Wechat_log("POWEROFF_ProtoCol:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+ # SZKW*860132060346475*0013*REMIND_CH_MEDICINE2,4-1
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_data = msg_tmp.split(',')
+
+ # [SZKW*860132060346475*0014*REMIND_CH_HOME,00:00',)
+ home_data = str(msg_data[1])
+
+ EventMesh.debug_log("recv REMIND_CH_HOME:{} medicin_data ;{}".format(msg,home_data))
+ if len(home_data) != 0:
+ EventMesh.publish("set_storage_config",["home_alarm",home_data])
+ EventMesh.publish("clear_home_alarm")
+ EventMesh.publish(constants.PROTOCOL.REMIND_CH_HOME_SEND)
+# 起床闹钟设置指令
+# 平台发送:
+# [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_WAKEUP,闹钟1,闹钟2]
+# 实例:
+# [XT*334588000000156*0026*REMIND_CH_WAKEUP,08:10-0-3-1000001,09:10-0-3-1000001]
+# 闹钟格式为:时间-开关-频率(1:一次;2:每天;3:自定义)
+# 08:10-1-1:闹钟时间8:10,打开,响铃一次
+# 08:10-1-2:闹钟时间8:10,打开,每天响铃
+# 08:10-1-3-0111110:闹钟时间8:10,打开,自定义周一至周五打开
+# 最左边是周日,最右边是周六,即0111110的顺序是:周日,周一,周二,周三,周四,周五,周六(1为打开,0为关闭),其中周一至周五打开闹钟
+# 终端回复:
+# [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_WAKEUP]
+# 实例:[XT*334588000000156*000E*REMIND_CH_WAKEUP]
+# 说明:闹铃格式为:时间-开关-周几(周六到周日)
+class REMIND_CH_WAKEUP_ProtoCol(ProtoCol):#该起床了
+ """
+
+ 平台发送:
+ [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_WAKEUP,,时间1-开关,时间2-开关,周几]
+ 实例:[XT*334588000000156*0008*REMIND_CH_WAKEUP,,时间1-开关,时间2-开关,周几]
+ 终端回复:
+ [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_WAKEUP]
+ """
+ TYPE = "REMIND_CH_WAKEUP"
+
+ def send(self, event, msg):
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0011*REMIND_CH_WAKEUP"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ #Wechat_log("POWEROFF_ProtoCol:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+ # SZKW*860132060346475*0013*REMIND_CH_MEDICINE2,4-1
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_tmp_new = str(msg_tmp.split('REMIND_CH_WAKEUP,')[1])
+ msg_tmp_data = str(msg_tmp.split('REMIND_CH_WAKEUP')[1])
+ count = 0
+ for i in str(msg_tmp_data):
+ # print("i",i)
+ if i == ",":
+ count+=1
+ wakeup_data_save = []
+ # # ("handler -> b'[SZKW*860132060346475*001C*REMIND_CH_WAKEUP,08:00-1-1,,]'",)
+ # medicine_alarmday = str(msg_data[4])
+ # alarmday=[]
+ wakeup_day = []
+ wakeup_switch = 0
+
+ print("count",count)
+ if count >= 3:
+ count = 3
+ for i in range(0,count):#默认是三个时间多了也不保存
+ wakeup_day = []
+ wakeup_data = str(msg_tmp_new.split(',')[i])
+ # print("i",i,wakeup_data)
+ if len(wakeup_data) != 0:
+ b = wakeup_data.find('-')
+ if b != -1:
+ wakeup_time = wakeup_data.split('-')[0]#-作为分隔符
+ wakeup_switch = int(wakeup_data.split('-')[1])#开关
+ wakeup_repeat = int(wakeup_data.split('-')[2])#是单次还是每天 还是自定义
+
+ wakeup_hour = int(wakeup_time.split(":")[0])#时间
+ wakeup_min = int(wakeup_time.split(":")[1])#冒号分隔时间 时 分
+
+
+ if wakeup_repeat == 2:#每一天
+ wakeup_day = [0,1,2,3,4,5,6]
+ elif wakeup_repeat == 3:#自定义
+ wakeup_day_tmp = wakeup_data.split('-')[3]#-作为分隔符
+ for i in range(0,7):
+ if wakeup_day_tmp[i] != '0':
+ wakeup_day.append(i)
+ else:#单次 1
+ wakeup_day=[]
+ if wakeup_switch != 0:
+ wakeup_data_save.append({"hour":wakeup_hour,"min":wakeup_min,"day":wakeup_day,"enable":wakeup_switch})
+
+ EventMesh.publish("set_storage_config",["wakeup_alarm",wakeup_data_save])
+ wakeup = EventMesh.publish("get_storage_config","wakeup_alarm")
+
+ EventMesh.debug_log("recv REMIND_CH_WAKEUP:{} wakeup ;{}".format(msg,wakeup))
+
+ EventMesh.publish(constants.PROTOCOL.REMIND_CH_WAKEUP_SEND)
+
+ EventMesh.publish("clear_wakeup_alarm")
+
+
+
+# 睡觉闹钟设置指令
+# 平台发送:
+# [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_SLEEP,闹钟1,闹钟2]
+# 实例:
+# [XT*334588000000156*0026*REMIND_CH_SLEEP,08:10-0-3-1000001,09:10-0-3-1000001]
+# 闹钟格式为:时间-开关-频率(1:一次;2:每天;3:自定义)
+# 08:10-1-1:闹钟时间8:10,打开,响铃一次
+# 08:10-1-2:闹钟时间8:10,打开,每天响铃
+# 08:10-1-3-0111110:闹钟时间8:10,打开,自定义周一至周五打开
+# 最左边是周日,最右边是周六,即0111110的顺序是:周日,周一,周二,周三,周四,周五,周六(1为打开,0为关闭),其中周一至周五打开闹钟
+# 终端回复:
+# [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_SLEEP]
+# 实例:[XT*334588000000156*000E*REMIND_CH_SLEEP]
+# 说明:闹铃格式为:时间-开关-周几(周六到周日)
+class REMIND_CH_SLEEP_ProtoCol(ProtoCol):#该睡觉了
+ """
+
+ 平台发送:
+ [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_SLEEP,,时间1-开关,时间2-开关,周几]
+ 实例:[XT*334588000000156*0008*REMIND_CH_SLEEP,,时间1-开关,时间2-开关,周几]
+ 终端回复:
+ [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_SLEEP]
+ """
+ TYPE = "REMIND_CH_SLEEP"
+
+ def send(self, event, msg):
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0011*REMIND_CH_SLEEP"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ #Wechat_log("POWEROFF_ProtoCol:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+ # SZKW*860132060346475*0013*REMIND_CH_MEDICINE2,4-1
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_tmp_new = str(msg_tmp.split('REMIND_CH_SLEEP,')[1])
+ msg_tmp_data = str(msg_tmp.split('REMIND_CH_SLEEP')[1])
+ count = 0
+ for i in str(msg_tmp_data):
+ # print("i",i)
+ if i == ",":
+ count+=1
+
+ sleep_data_save = []
+ # # ("handler -> b'[SZKW*860132060346475*001C*REMIND_CH_SLEEP,08:00-1-1,,]'",)
+ # b'[SZKW*860132060346475*001B*REMIND_CH_SLEEP,08:00-1-1,,]'",)
+ # medicine_alarmday = str(msg_data[4])
+ # alarmday=[]
+ sleep_day = []
+ sleep_switch = 0
+
+ print("count",count)
+ if count >= 3:
+ count = 3
+ for i in range(0,count):#默认是三个时间多了也不保存
+ sleep_day = []
+ sleep_data = str(msg_tmp_new.split(',')[i])
+ # print("i",i,sleep_data)
+ if len(sleep_data) != 0:
+ b = sleep_data.find('-')
+ if b != -1:
+ sleep_time = sleep_data.split('-')[0]#-作为分隔符
+ sleep_switch = int(sleep_data.split('-')[1])#开关
+ sleep_repeat = int(sleep_data.split('-')[2])#是单次还是每天 还是自定义
+
+ sleep_hour = int(sleep_time.split(":")[0])#时间
+ sleep_min = int(sleep_time.split(":")[1])#冒号分隔时间 时 分
+
+
+ if sleep_repeat == 2:#每一天
+ sleep_day = [0,1,2,3,4,5,6]
+ elif sleep_repeat == 3:#自定义
+ sleep_day_tmp = sleep_data.split('-')[3]#-作为分隔符
+ for i in range(0,7):
+ if sleep_day_tmp[i] != '0':
+ sleep_day.append(i)
+ else:#单次 1
+ sleep_day=[]
+ if sleep_switch != 0:
+ sleep_data_save.append({"hour":sleep_hour,"min":sleep_min,"day":sleep_day,"enable":sleep_switch})
+
+ EventMesh.publish("set_storage_config",["sleep_alarm",sleep_data_save])
+ # sleep = EventMesh.publish("get_storage_config","sleep_alarm")
+
+ # EventMesh.debug_log("recv REMIND_CH_SLEEP_SEND:{} sleep ;{}".format(msg,sleep))
+
+ EventMesh.publish(constants.PROTOCOL.REMIND_CH_SLEEP_SEND)
+ EventMesh.publish("clear_sleep_alarm")
+
+
+# 可设置闹钟的提醒文字
+# 平台发送:
+# [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_REST,时间间隔1,时间间隔2,时间间隔3]
+# 实例:
+# [XT*334588000000156*0026*REMIND_CH_REST,08:10-10:00,12:10-15:00]
+# 终端回复:
+# [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_REST]
+# 实例:[XT*334588000000156*000E*REMIND_CH_REST]
+# 说明:时间间隔 【起始-结束】,起始为开始休息,结束为休息结束
+
+class REMIND_CH_REST_ProtoCol(ProtoCol):#该休息了
+ """
+
+ 平台发送:
+ [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_REST,,时间1-开关,时间2-开关,周几]
+ 实例:[XT*334588000000156*0008*REMIND_CH_REST,,时间1-开关,时间2-开关,周几]
+ 终端回复:
+ [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_REST]
+ """
+ TYPE = "REMIND_CH_REST"
+
+ def send(self, event, msg):
+ send_data = EventMesh.publish("get_new_pid")+"*%s*000E*REMIND_CH_REST"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ #Wechat_log("POWEROFF_ProtoCol:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+ # SZKW*860132060346475*0013*REMIND_CH_REST,4-1
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_data = str(msg_tmp.split('REMIND_CH_REST,')[1])
+ msg_data_new = str(msg_tmp.split('REMIND_CH_REST')[1])
+ print("REMIND_CH_REST",len(msg_data),msg_data)
+
+ reset_data_save = []
+ count = 0
+ for i in str(msg_data_new):
+ # print("i",i)
+ if i == ",":
+ count+=1
+
+ if count >= 2:
+ count = 2
+
+ for i in range(0,count):#默认是三个时间多了也不保存
+ reset_data = str(msg_data.split(',')[i])
+ print("i",i,reset_data)
+ if len(reset_data) != 0:
+ b = reset_data.find('-')
+ if b != -1:
+ start_time = reset_data.split('-')[0]#-作为分隔符
+ end_time = reset_data.split('-')[1]#-作为分隔符
+
+ start_hour = int(start_time.split(":")[0])
+ start_min = int(start_time.split(":")[1])
+
+ end_hour = int(end_time.split(":")[0])
+ end_min = int(end_time.split(":")[1])
+
+ reset_data_save.append({"start_hour":start_hour,"start_min":start_min,"end_hour":end_hour,"end_min":end_min})
+
+ EventMesh.publish("set_storage_config",["reset_alarm",reset_data_save])
+ # reset = EventMesh.publish("get_storage_config","reset_alarm")
+
+ # EventMesh.debug_log("recv REMIND_CH_REST:{} reset ;{}".format(msg,reset))
+
+ EventMesh.publish(constants.PROTOCOL.REMIND_CH_REST_SEND)
+ EventMesh.publish("clear_reset_alarm")
+
+
+
+class WLKEY_ProtoCol(ProtoCol):#白名单开关
+ """
+ 白名单开关
+ [XT*YYYYYYYYYYYYYYY*LEN*WLKEY,ONOFF] ONOFF: 1:开启,0:关闭,2:30秒后自动接听。
+ 实例:[XT*334588000000156*0008*WLKEY,1]
+ 终端回复
+ [XT*YYYYYYYYYYYYYYY*LEN*WLKEY]
+ 实例:[XT*334588000000156*0006*WLKEY]
+ """
+ TYPE = "WLKEY"
+
+ def send(self, event, msg):
+ send_data = EventMesh.publish("get_new_pid")+"*%s*00006*WLKEY"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ #Wechat_log("POWEROFF_ProtoCol:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_data = msg_tmp.split(',')
+ EventMesh.debug_log("WLKEY_ProtoCol".format(msg_data[1]))
+ EventMesh.publish("set_storage_config",["WLKEY",msg_data[1]])
+
+
+ EventMesh.publish(constants.PROTOCOL.WLKEY_SEND)
+# 终端发送:
+# [XT*YYYYYYYYYYYYYYY*LEN*SLEEP_DATA,清醒时间(分钟),浅睡时间(分钟),深睡时间(分钟),日期(年月日)]
+# 实例: [XT*334588000000156*0004*SLEEP_DATA,120,240,360,20221008]
+# 实例表示:上传睡眠数据
+#[XT*334588000000156*0010*SleepReport,2022-02-09,80,2,532,164,164,25,25,25,25,21:45-0-164-155-3,22:00-1-162-155-0,22:15-2-162-155-0]
+class SLEEP_DATA_ProtoCol(ProtoCol):#睡眠时间
+ """
+ 白名单开关
+ [XT*YYYYYYYYYYYYYYY*LEN*WLKEY,ONOFF] ONOFF: 1:开启,0:关闭,2:30秒后自动接听。
+ 实例:[XT*334588000000156*0008*WLKEY,1]
+ 终端回复
+ [XT*YYYYYYYYYYYYYYY*LEN*WLKEY]
+ 实例:[XT*334588000000156*0006*WLKEY]
+ """
+ TYPE = "SleepReport"
+
+ def send(self, event, msg):
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0000b*SleepReport"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s,%s]"%(str(MD5_SIGN),send_data,msg)
+ EventMesh.debug_log("SLEEP_DATA:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+
+ EventMesh.debug_log("SLEEP_DATA!!!!!!!!!")
+ # msg = msg[1:-1]
+ # msg_tmp = msg.decode('ascii')
+ # msg_data = msg_tmp.split(',')
+ # EventMesh.debug_log("WLKEY_ProtoCol".format(msg_data[1]))
+ # EventMesh.publish("set_storage_config",["WLKEY",msg_data[1]])
+
+
+ # EventMesh.publish(constants.PROTOCOL.WLKEY_SEND)
+
+class SLEEPTIME_ProtoCol(ProtoCol):#睡眠时间
+ """
+ """
+ TYPE = "SLEEPTIME"
+
+ def send(self, event, msg):
+ send_data = EventMesh.publish("get_new_pid")+"*%s*00009*SLEEPTIME"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ EventMesh.debug_log("SLEEPTIME:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+ # 实例:[XT*5678901234*0014*SLEEPTIME,23:30-7:30]
+ EventMesh.debug_log("SLEEPTIME!!!!!!!!!")
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_data = str(msg_tmp.split(',')[1])
+ data = {}
+ if len(msg_data) == 0:
+ EventMesh.publish("set_storage_config",["sleep_time",data])
+ pass
+ else:
+ sleep_start = msg_data.split("-")[0]
+ sleep_end = msg_data.split("-")[1]
+ start_hour = int(sleep_start.split(":")[0])
+ start_min = int(sleep_start.split(":")[1])
+
+ end_hour = int(sleep_end.split(":")[0])
+ end_min = int(sleep_end.split(":")[1])
+
+ data = {"start_hour":start_hour,"start_min":start_min,"end_hour":end_hour,"end_min":end_min}
+ # EventMesh.debug_log("SLEEPTIME".format(data))
+ EventMesh.publish("set_storage_config",["sleep_time",data])
+ # sleep_time = EventMesh.publish("get_storage_config","sleep_time")
+ # EventMesh.debug_log("sleep_time:{}".format(sleep_time))
+
+ EventMesh.publish(constants.PROTOCOL.SLEEPTIME_SEND)
+
+# 平台发送:
+# [XT*YYYYYYYYYYYYYYY*LEN*FACTORY]
+# 实例:[XT*334588000000156*0007*FACTORY]
+# 终端回复:
+# [XT*YYYYYYYYYYYYYYY*LEN*FACTORY]
+# 实例:[XT*334588000000156*0007*FACTORY]
+# 说明:终端恢复出厂设置,里面设置的号码都将清空
+class FACTORY_ProtoCol(ProtoCol):#睡眠时间
+ """
+ 实例:[XT*334588000000156*0008*FACTORY]
+ 终端回复
+ [XT*YYYYYYYYYYYYYYY*LEN*WLKEY]
+ 实例:[XT*334588000000156*0006*FACTORY]
+ """
+ TYPE = "FACTORY"
+
+ def send(self, event, msg):
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0007*FACTORY"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ EventMesh.debug_log("FACTORY:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+
+ EventMesh.debug_log("FACTORY!!!!!!!!!")
+ # msg = msg[1:-1]
+ # msg_tmp = msg.decode('ascii')
+ # msg_data = msg_tmp.split(',')
+ # EventMesh.debug_log("WLKEY_ProtoCol".format(msg_data[1]))
+ # EventMesh.publish("set_storage_config",["WLKEY",msg_data[1]])
+
+ EventMesh.publish(constants.PROTOCOL.FACTORY_SEND)
+ EventMesh.publish("app_factory",None)#app恢复出厂
+
+# 平台发送:
+# [3G*YYYYYYYYYY*LEN*RESET]
+# 实例:[3g*5678901234*0005*RESET]
+# 终端回复:
+# [3G*YYYYYYYYYY*LEN*RESET]
+class RESET_ProtoCol(ProtoCol):#重启
+ """
+ 实例:[XT*334588000000156*0008*RESET]
+ 终端回复
+ [XT*YYYYYYYYYYYYYYY*LEN*RESET]
+ 实例:[XT*334588000000156*0006*RESET]
+ """
+ TYPE = "RESET"
+
+ def send(self, event, msg):
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0005*RESET"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ EventMesh.debug_log("RESET:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+
+ EventMesh.debug_log("RESET!!!!!!!!!")
+ # msg = msg[1:-1]
+ # msg_tmp = msg.decode('ascii')
+ # msg_data = msg_tmp.split(',')
+ # EventMesh.debug_log("WLKEY_ProtoCol".format(msg_data[1]))
+ # EventMesh.publish("set_storage_config",["WLKEY",msg_data[1]])
+
+ EventMesh.publish(constants.PROTOCOL.RESET_SEND)
+ Power.powerRestart()
+
+# 平台发送:
+# [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_SIT,时间间隔(分钟),总开关(0为关,1为开),午间休息时段,晚间休息时段]
+# 午间/晚间休息时段格式为:开始时间(hh:mm)-结束时间(hh:mm)-开关(0为关,1为开),例如 12:00-15:00-1。
+# 久坐默认值为20分钟。
+# 午间和晚间默认值,午间12:00-14:00,晚上20:00-07:00。
+# 实例:
+# [XT*334588000000156*0026*REMIND_CH_SIT,20,0,12:00-15:00-1,20:00-07:00-1]
+# 终端回复:
+# [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_SIT]
+# 实例:[XT*334588000000156*000E*REMIND_CH_SIT]
+class REMIND_CH_SIT_ProtoCol(ProtoCol):#久坐提醒
+ """
+ 实例:[XT*334588000000156*0008*REMIND_CH_SIT]
+ 终端回复
+ [XT*YYYYYYYYYYYYYYY*LEN*REMIND_CH_SIT]
+ 实例:[XT*334588000000156*0006*REMIND_CH_SIT]
+ """
+ TYPE = "REMIND_CH_SIT"
+
+ def send(self, event, msg):
+ send_data = EventMesh.publish("get_new_pid")+"*%s*000d*REMIND_CH_SIT"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ EventMesh.debug_log("REMIND_CH_SIT:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+
+ EventMesh.debug_log("REMIND_CH_SIT!!!!!!!!!")
+ # msg = msg[1:-1]
+ # msg_tmp = msg.decode('ascii')
+ # msg_data = msg_tmp.split(',')
+ # EventMesh.debug_log("WLKEY_ProtoCol".format(msg_data[1]))
+ # EventMesh.publish("set_storage_config",["WLKEY",msg_data[1]])
+
+ EventMesh.publish(constants.PROTOCOL.REMIND_CH_SIT_SEND)
+
+# 平台发送:
+# [XT*YYYYYYYYYYYYYYY*LEN*SCREEN_SHOW,参数内容]
+# 实例:[XT*334588000000156*0016*SCREEN_SHOW,00000000000]
+# 参数内容用 unicode 编码呈现,设备收到后需解码。
+# 解码后的参数内容可能有多个参数,不同参数用逗号分隔,设备自己决定如何在屏幕中显示这些参数。比如 "SCREEN_SHOW,深圳第一中学,三年1班、张三"
+# 终端回复:
+# [XT*YYYYYYYYYYYYYYY*LEN*SCREEN_SHOW]
+# 实例:[XT*334588000000156*000B*SCREEN_SHOW]
+
+class SCREEN_SHOWProtoCol(ProtoCol):
+ """开屏显示"""
+ TYPE = "SCREEN_SHOW"
+ def send(self, event, msg):
+ # [XT*334588000000156*0006*SILENCETIME2]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*000B*SCREEN_SHOW"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ # print("KEYBRD:data:%s"%(data))
+ # print("KEYBRD!!!!!!!!!!!!!",msg)
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event:
+ @param msg: 接收到的下行数据
+ """
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_tmp = msg_tmp.split(',')
+ msg_tmp = msg_tmp[1:]
+ msg_tmp = msg_tmp[0]
+ print("screen_school_data msg",msg)
+
+ j = 0
+ i = 0
+ videobook_old = {}
+ videobook_name_tmp = UnicodeHexStr_To_Utf8Str(msg_tmp)
+ lst = videobook_name_tmp.split(",")
+ print("lst data",lst)
+
+ # 0 1 2 3
+ screen_school_data = ""#学校
+ screen_class_data = ""#班级
+ screen_fullname_data = ""#姓名
+ if len(lst) != 0:
+ count = len(lst)
+ if count > 3:
+ count = 3
+ for i in range(count):
+ if i == 0:
+ screen_school_data = lst[0]
+ EventMesh.publish("set_schoolname", screen_school_data)#
+ elif i == 1:
+ screen_class_data = lst[1]
+ EventMesh.publish("set_classname", screen_class_data)#
+ else:
+ screen_fullname_data= lst[2]
+ EventMesh.publish("set_fullname", screen_fullname_data)#
+
+ # EventMesh.publish("update_screen_show")#更新开屏显示
+
+ print("screen_school_data!!!:",screen_school_data,screen_class_data,screen_fullname_data)
+
+ EventMesh.publish(constants.PROTOCOL.SCREEN_SHOW_SEND)
+
+# #小见平台视频通话
+# # [XT*YYYYYYYYYYYYYYY*LEN*JPREG]
+# # 实例:
+# # [XT*334588000000156*0004*JPREG]
+# # 平台回复:
+# # [XT*设备ID*LEN*JPREG,账号(整型)]
+# # 实例:[XT*334588000000156*0010*JPREG,1087654321]
+class JPREG_ProtoCol(ProtoCol):#登入注册
+ """"""
+ TYPE = "JPREG"
+ def send(self, event, msg):
+
+ # [XT*334588000000156*0005*WLKEY]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0005*JPREG"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ # print("WLKEY:data:%s"%(data))
+ # print("WLKEY!!!!!!!!!!!!!")
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event:
+ @param msg: 接收到的下行数据
+ """
+ # b'[SZKW*867387060319166*000A*KEYBRD]'
+ print("JPREG!!!!!!!!!!!!!",msg,EventMesh.publish("get_new_pid"))
+ # EventMesh.publish(constants.PROTOCOL.JPREG_SEND)
+
+# # (声网,佰锐的账号是整型)
+# # [XT*YYYYYYYYYYYYYYY*LEN*MEMBERS]
+# # 实例:[XT*334588000000156*0007*MEMBERS]
+# # 平台回复:[XT*设备ID*LEN*MEMBERS,账号1,昵称1,电话1,账号2,昵称2,电话2.....]
+# # 实例:
+# # [XT*334588000000156*003F*MEMBERS,d3e2f759f9d5af3858f3530,爸爸,13662313580,妈妈,555]
+# # 以上数据部分使用Unicode编码,最终上面示例传到服务端将是:
+
+class MEMBERS_ProtoCol(ProtoCol):#获取账号列表
+ """"""
+ TYPE = "MEMBERS"
+ def send(self, event, msg):
+
+ # [XT*334588000000156*0005*WLKEY]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0007*MEMBERS"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ print("MEMBERS SEND:data:%s"%(data))
+ # print("WLKEY!!!!!!!!!!!!!")
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event:
+ @param msg: 接收到的下行数据
+ """
+ # b'[SZKW*876226002021444*0048*MEMBERS,0036003900350031003800330032002C563F563FD83CDF410020D83CDF42002C]'
+ print("MEMBERS!!!!!!!!!!!!!",msg,EventMesh.publish("get_new_pid"))
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_tmp = msg_tmp.split(',')
+
+ videobook = {}
+ msg_tmp = msg_tmp[1:]
+ msg_tmp = msg_tmp[0]
+
+ j = 0
+ i = 0
+ videobook_old = {}
+ videobook_name_tmp = UnicodeHexStr_To_Utf8Str(msg_tmp)
+ lst = videobook_name_tmp.split(",")
+
+ print("msg_tmp:{} phonebook_oldtmp:{} type:{}".format(msg_tmp,videobook_name_tmp,lst))
+ # 0 1 2 3
+ for vediobook_tmp in lst:
+
+ if (j % 3) == 0:#账号
+ videobook_old = vediobook_tmp
+ elif (j % 3) == 1:#名称
+ i+=1
+ videobook_name_cont= "{}:{}".format("%03d"%(i),videobook_old)
+ videobook[videobook_name_cont] = vediobook_tmp
+ j+=1
+ print("videobook!!!:{}".format(str(videobook)))
+ # print("phonebook!!!:{}".format(str(phonebook)))
+ with open("/usr/static/storage_file/videobook.json","w",encoding="utf-8") as fd:
+ ujson.dump(videobook,fd)
+ print("创建视频通话账号")
+
+ EventMesh.publish("set_videobook_list",[1,videobook])
+ # EventMesh.publish("video_updata_list_show")
+ # EventMesh.publish(constants.PROTOCOL.MEMBERS_SEND)
+
+# # [X*Y*LEN*CALLING,呼叫者id,会议id,通话类型,Token]
+
+# # 设备回复
+# # [X*Y*LEN*CALLING,音视频状态]
+# # 音视频状态:为0表示正常可通讯状态,否则填上用音视频返回的状态码,比如200,如果未获取到返回状态码,则填1
+class CALLING_ProtoCol(ProtoCol):#app发起视频通话
+ """"""
+ TYPE = "CALLING"
+ def send(self, event, msg):
+
+ # [XT*334588000000156*0005*WLKEY]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0007*CALLING"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s,%d]"%(str(MD5_SIGN),send_data,msg)
+ # print("CALLING:send data:%s"%(data))
+ # print("WLKEY!!!!!!!!!!!!!")
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event:
+ @param msg: 接收到的下行数据
+ """
+ # b'[SZKW*867387060319166*000A*CALLING]'
+ print("CALLING!!!!!!!!!!!!!",msg)
+ if EventMesh.model == "D10":#D10没有视频通话
+ EventMesh.publish(constants.PROTOCOL.CALLING_SEND,1)
+ return
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_tmp_d = msg_tmp.split(',')
+ call_id = msg_tmp_d[1]#id
+ meet_id = msg_tmp_d[2]#会议id
+ call_type = int(msg_tmp_d[3])#会议id# 0音频 1视频
+ tokens_data = msg_tmp_d[4]#tokens
+ EventMesh.publish("set_vedio_call_id", call_id)#
+ EventMesh.publish("set_vedio_meet_id", meet_id)#
+ EventMesh.publish("set_vedio_call_type", call_type)#
+ EventMesh.publish("set_vedio_tokens_data", tokens_data)#
+
+ flag = EventMesh.publish("get_call_state")
+ fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
+ usb_state = EventMesh.publish("get_usb")#
+ video_state = EventMesh.publish("get_video_state")
+ sos_dialing = EventMesh.publish("get_sos_state_out")#正在拨打sos电话
+ if flag != 0 or fall_down != 0 or video_state != 0 or sos_dialing != 0: #电话在打入或者 在充电不允许视频通话
+ EventMesh.publish(constants.PROTOCOL.CALLING_SEND,1)
+ else:
+ EventMesh.publish(constants.PROTOCOL.CALLING_SEND,0)
+ EventMesh.publish("set_video_state", 6)
+ EventMesh.publish("set_dev_app_mode", 2)#
+ EventMesh.publish("close_hr_sop2")#
+ EventMesh.publish("video_call_in_event",call_type)
+
+# # [XT*YYYYYYYYYYYYYYY*LEN*RCALLING,呼叫者id,会议id/声网频道名(没有则留空,但位置保留),音频还是视频(0为音频,1为视频)]
+# # 实例:
+# # [XT*334588000000156*0007*RCALLING,d3e2f759f9d5af3858f3530b,,0]
+# # 终端回复:
+# # [XT*设备ID*LEN*RCALLING]
+# # 实例:[XT*334588000000156*0009*RCALLING]
+# #
+class RCALLING_ProtoCol(ProtoCol):#设备拒接接听
+ """"""
+ TYPE = "RCALLING"
+ def send(self, event, msg):
+
+ # [XT*334588000000156*0005*WLKEY]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0008*RCALLING"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s,%s,%s,%d]"%(str(MD5_SIGN),send_data,msg[0],msg[1],msg[2])
+ # print("RCALLING:send data:%s"%(data))
+ # print("WLKEY!!!!!!!!!!!!!")
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+ # print("RCALLING:send data end:%s"%(data))
+
+ def recv(self, event, msg):
+ """
+ @param event:
+ @param msg: 接收到的下行数据
+ """
+ # b'[SZKW*867387060319166*000A*RCALLING]'
+ print("RCALLING!!!!!!!!!!!!!")
+
+class AGTALK_ProtoCol(ProtoCol):#设备发起视频通话与app接听视频通话
+ """"""
+ TYPE = "AGTALK"
+ def send(self, event, msg):
+
+ # [XT*334588000000156*0005*WLKEY]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0006*AGTALK"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s,%d,%s]"%(str(MD5_SIGN),send_data,msg[0],msg[1])
+ print("AGTALK:send data:%s"%(data))
+ # print("WLKEY!!!!!!!!!!!!!")
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event:
+ @param msg: 接收到的下行数据
+ """
+ # b'[SZKW*876226002021444*007B*AGTALK,0,01lqlyqzzQHpfwv5g7jFVC2H6Ha2tHFpMlfSm5sd2uo7o55JEcc=OVxewje6MjP0NgEODwsLDwkJCwkLCA0NDQ==,8762260020214441701226895]'
+ # print("AGTALK!!!!!!!!!!!!!")
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_tmp_d = msg_tmp.split(',')
+ call_state = int(msg_tmp_d[1])#返回是否可以视频通话
+ if call_state == 0:#可正常通话
+ if EventMesh.publish("get_video_state") != 0:
+ # print("AGTALK!!!!!!!!!!!!!answer")
+ tokens_data = msg_tmp_d[2]#会议id
+ meet_id = msg_tmp_d[3]#会议id
+ EventMesh.publish("set_vedio_meet_id", meet_id)#
+ EventMesh.publish("set_vedio_tokens_data", tokens_data)#
+ EventMesh.publish("open_vedio_infor")
+
+ else:
+ #不能视频通话
+ tokens_data = msg_tmp_d[2]#token数据
+ meet_id = msg_tmp_d[3]#会议id
+ EventMesh.publish("set_vedio_meet_id", meet_id)#
+ EventMesh.publish("set_vedio_tokens_data", tokens_data)#
+ EventMesh.publish("video_newwork_reject_cb",None)#挂断视频通话
+ # print("AGTALK no!!!!!!!!!!!!!")
+
+ print("AGTALK!!!!!!!!!!!!!")
+
+
+class RTALK_ProtoCol(ProtoCol):#app拒接视频通话
+ """"""
+ TYPE = "RTALK"
+ def send(self, event, msg):
+
+ # [XT*334588000000156*0005*WLKEY]
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0005*RTALK"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s,%d,%s]"%(str(MD5_SIGN),send_data,msg[0],msg[1])
+ # print("AGTALK:send data:%s"%(data))
+ # print("WLKEY!!!!!!!!!!!!!")
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+ def recv(self, event, msg):
+ """
+ @param event:
+ @param msg: 接收到的下行数据
+ """
+ # b'[SZKW*867387060319166*000A*RTALK]'
+ print("RTALK!!!!!!!!!!!!!")
+ # [SZKW*876226002021444*003A*RTALK,3ef20e64f3abb84b27f7d764,8762260020214441701226522,1]'
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_tmp_d = msg_tmp.split(',')
+ EventMesh.publish("app_rtalk_cb",1)
+
+
+
+
+class ProtoColResolver(object):
+ def __init__(self):
+ self.protocol_list = []
+
+ def add_support(self, prot):
+ self.protocol_list.append(prot)
+ prot.initialization()
+
+ def handler(self, data):
+ # 这里接收数据
+
+ EventMesh.debug_log("handler -> {}".format(data))
+ # if data.startswith('Init;'):
+ # data = data[5:]
+ # EventMesh.publish(constants.EVENT.SET_KEY, {"value": ujson.loads(data)['KEY']})
+
+ # elif data.startswith("Update;"):
+ # data = data[7:]
+ # EventMesh.publish(constants.PROTOCOL.H04_RECV, data)
+ try:
+ if len(data) > 0:
+ #EventMesh.debug_log("handler:{}".format(len(data)))
+ data_tmp = data.decode('ascii')
+ data_tmp = data_tmp.split(']')[0] #去掉]
+ ProtoCol_type = data_tmp.split('*')[3] #拿到协议标识
+ ProtoCol_type = ProtoCol_type.split(',')[0]
+ ProtoCol_type = "%s_RECV"%(ProtoCol_type)
+ # EventMesh.debug_log("ProtoColResolver:ProtoCol_type:%s\r\ndata:%s"%(ProtoCol_type,data))
+ EventMesh.publish(ProtoCol_type, data) #返回协议read
+ except Exception as e:
+ EventMesh.debug_log("handler:ERROR:")
+ usys.print_exception(e)
+ EventMesh.debug_log("handler:error data:{}".format(len(data)))
--- /dev/null
+import ql_fs
+import uos
+from ucryptolib import aes
+import hashlib
+import utime
+import base64
+import uhashlib
+import ubinascii
+BLOCK_SIZE = 16
+def sha256_encode(key,data):#对数据进行AES256加密 key 需要加密的产品key data需要加密的数据
+ h = hashlib.sha256()
+ h.update(key)
+ crypto_key = h.digest()
+ #IV是偏移量 默认16个十六进制00
+ IV = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+
+ crypto = aes(crypto_key, 2, IV)
+
+ #进行PKCS7Padding填充。
+ block_num = len(data) // BLOCK_SIZE+1
+ k = len(data) % BLOCK_SIZE
+ j = len(data) // BLOCK_SIZE
+ padding = BLOCK_SIZE - k
+ i = 0
+ szDataIn = bytearray(data)
+ # print(szDataIn)
+ szDataIn = szDataIn+bytearray(block_num * BLOCK_SIZE -len(data))
+ # print(szDataIn)
+
+ for i in range(padding):
+ szDataIn[j * BLOCK_SIZE + k + i] = padding
+ # print("szDataIn:{} {} {}\r\n".format(szDataIn,j * BLOCK_SIZE + k + i,padding))
+
+ indata = bytes(szDataIn)
+ enc = crypto.encrypt(indata)
+ #最后将加密AES256的数据转换成base64的编码格式
+ msg_tmp = base64.b64encode(enc)
+ data_encode = msg_tmp.decode('ascii')#转换成字符串
+ return data_encode
+
+
+
+# 设备ID:1234567890
+# PID:Amg1HJ3dJkX3kLiLPNFg
+# 时间戳:1717752535000
+# 秘钥
+# 签名内容:1234567890Amg1HJ3dJkX3kLiLPNFg1717752535000
+# 签名结果:772f56b549e5c36dbc18cd7c2c68565a7acd8979
+# data = "1234567890Amg1HJ3dJkX3kLiLPNFg1717752535000"
+# key = ""
+# data_encode_t = sha256_encode(key,data)
+# print("data_encode_t:{}".format(data_encode_t))
+
+import request
+# 签名内容: = deviceId+pid+timeStamp
+SHA256 = uhashlib.sha256
+date_tmp = utime.localtime()
+timeStamp = (utime.mktime(date_tmp))*1000#获取时间戳
+# timeStamp = 1726130835
+print("timeStamp:{}\r\n".format(timeStamp))
+SHA1_BLOCK_SIZE = 64
+def HMAC(k, m):
+
+ KEY_BLOCK = k + (b'\0' * (SHA1_BLOCK_SIZE - len(k)))
+ KEY_INNER = bytes((x ^ 0x36) for x in KEY_BLOCK)
+ KEY_OUTER = bytes((x ^ 0x5C) for x in KEY_BLOCK)
+ inner_message = KEY_INNER + m
+ outer_message = KEY_OUTER + SHA256(inner_message).digest()
+ return SHA256(outer_message)
+
+
+def get_hmac_sha256(k, m):
+ data = HMAC(k, m).digest()
+ # print("HMAC(k, m).digest():", data)
+ # print("HMAC(k, m).digest():", ubinascii.hexlify(data))
+ hex_data = ubinascii.hexlify(data)
+ hex_data = hex_data.decode('ascii')
+ return hex_data
+deviceId = "876226002022574"
+pid = "qAtdDOGXgXYjT2HGFr3a"
+key = b"MWrMZjdtcPhj41jWuoqFAhTmqyFluqj1"
+en_data = "{}{}{}".format(deviceId,pid,timeStamp)
+print("en_data:{}\r\n".format(en_data))
+en_hex = get_hmac_sha256(key,en_data)
+print("en_hex:{}\r\n".format(en_hex))
+
+#MD5
+# Md5(deviceSecret+deviceId+pid+timeStamp)
+deviceSecret = "MWrMZjdtcPhj41jWuoqFAhTmqyFluqj1"
+md5_data = "{}{}{}{}".format(deviceSecret,deviceId,pid,timeStamp)
+hash_obj = uhashlib.md5(md5_data)
+res = hash_obj.digest()
+sign_data = ubinascii.hexlify(res)
+sign_data = sign_data.decode('ascii')
+data = {
+ "deviceId":"{}".format(deviceId),
+ "pid":"qAtdDOGXgXYjT2HGFr3a",
+ "sign":"{}".format(en_hex),
+ "timeStamp":timeStamp,
+ "signMethod":"HMACSHA256"
+}
+print(ujson.dumps(data))
+headers_T ={"Content-Type":"application/json"}
+url = "http://dmp.raisound.com/bz-api/dev/auth/active"
+import ujson
+data =ujson.dumps(data)
+response = request.put(url,data=data,headers = headers_T)
+
+print(response.json())
+print(response.headers)
+for i in response.text:
+ print(i)
+# if response.status_code == 200:
+# content = response.content
+# c = next(content)
+# # "api.xcloudtech.com"
+# # d_server_port = 9000
+# jsload_data = ujson.loads(c)
+# print("jsload_data-{}".format(jsload_data))
+
+
+# 2024-09-12 17:39:42.123 [MixSdk-043]: text = 28110687C456Y1DxRdBfnzVZQrXHdrNl1726133982000
+# 2024-09-12 17:39:42.185 [MixSdk-044]: productKey = D11EBDD976A824E61846C80523095DCB0FE3F1DD
+# 2024-09-12 17:39:42.185 [MixSdk-045]: signValue = D11EBDD976A824E61846C80523095DCB0FE3F1DD
+# 2024-09-12 17:39:42.185 [MixSdk-046]: http://dmp.raisound.com/bz-api/dev/auth/active ["signMethod": "HMACSHA1", "sign": "D11EBDD976A824E61846C80523095DCB0FE3F1DD", "pid": "Y1DxRdBfnzVZQrXHdrNl", "timeStamp": "1726133982000", "deviceId": "28110687C456"]
+# 2024-09-12 17:39:42.898 [MixSdk-017]: {"success":true,"msg":"激活成功.","code":20000,"data":{"password":"PT+ATeLgL/T1atezfRvUHos5mKi7IYuz5n5Hs/kWePE=","deviceId":"28110687C456","nonce":"gEzghPxPt5cJv2yK"}}
+# svgpSQQRUE4YbJwYNPhLkNSRyGMWJw
\ No newline at end of file
--- /dev/null
+
+import utime
+import audio
+from machine import Pin
+import osTimer
+import _thread
+from queue import Queue
+import uwebsocket
+import usys
+import EventMesh
+import constants
+import ujson
+
+
+import gc
+AI_audio_queue = Queue(100)
+aud = audio.Audio(0)
+aud.set_pa(Pin.GPIO29)
+aud.setVolume(11)
+AI_TTS_str = ""
+AI_client_tts = None
+AI_client_tts_1 = None
+_4S_timer = None
+def AI_client_tts_recv(cli,fd):
+ global AI_TTS_str,AI_client_tts,_4S_timer,AI_client_tts_1
+ while True:
+ try:
+ # 死循环接收数据
+
+ recv_data = cli.recv()
+ if not recv_data:
+ # 服务器关闭连接或客户端关闭连接
+ print("AI_client_tts_recv close!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n")
+ print("AI_client_tts_recv close!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n")
+ break
+ try:
+ # print("AI_client_tts_recv :{}".format(len(recv_data)))
+ #结束标志{"header":{"event":"EndSynthesis","msg":"success","status":20000000,"task_id":"ffd727e620000803280c5a6498d0e321"}}
+ if isinstance(recv_data, str):
+ #print("AI_client_tts_recv:str recv_data:{}".format(recv_data))
+ if recv_data.find('\"state\":\"Listening\"') != -1:
+ AI_client_VC_RequestToRespond()
+ if recv_data.find('\"event\":\"RespondingEnded\"') != -1:
+
+ print("EndSynthesis!!!!!!!!!!!!!!!!!\r\n")
+ print("EndSynthesis!!!!!!!!!!!!!!!!!!\r\n")
+ #cli.close()
+ fd.close()
+ _4S_timer.stop()
+ # AI_client_tts.close()
+ # try:
+ # AI_client_tts_1._close()
+ # except Exception as e:
+ # usys.print_exception(e)
+ break
+ else:
+ fd.write(recv_data)
+ AI_audio_queue.put([recv_data,""])
+ #utime.sleep_ms(1000)
+ except Exception as e:
+ usys.print_exception(e)
+
+ except Exception as e:
+ usys.print_exception(e)
+ break
+def _4S_timer_cb(self,*argc):
+ print("_4S_timer_cb!!!!!!!!!!!!!!!!!!!!!")
+ global AI_TTS_str,AI_client_tts,_4S_timer,AI_client_tts_1
+ try:
+ AI_client_VC_ping()
+ except Exception as e:
+ usys.print_exception(e)
+ _4S_timer.stop()
+def websocket_connect_tts(fd_neme,tts_str):
+ global AI_TTS_str,AI_client_tts,_4S_timer,AI_client_tts_1
+ _4S_timer = osTimer()
+ _4S_timer.start(4000,1,_4S_timer_cb)
+
+ print("websocket_connect_tts {},{}!!!!!!!!!".format(fd_neme,tts_str))
+ fd=open(fd_neme,'w')
+ req_str = ""
+ AI_TTS_str = tts_str
+ lang = "&lang=zh-cn"#普通话测试环境
+
+ platform = "&platform=huoshan&is_bot=1"
+
+ req_str = "is_auth=0{}{}".format(platform,lang)
+ try:
+
+ AI_client_tts = uwebsocket.Client.connect('ws://118.145.158.207:22082/voice-chat/ws?{}'.format(req_str), debug=False)
+ AI_client_tts_1 = uwebsocket.Client.connect('ws://118.145.158.207:22082/voice-chat/ws?{}'.format(req_str), debug=False)
+ except Exception as e: #网络连接异常
+ usys.print_exception(e)
+ print("websocket_connect_tts ERROR:{}\r\n".format(e))
+
+ print("websocket_connect_tts:AI_client_tts {}\r\n".format(AI_client_tts))
+ # 线程接收数据
+
+ #_thread.stack_size(20*1024)
+ AI_client_tts_recv_id = _thread.start_new_thread(AI_client_tts_recv, (AI_client_tts,fd))
+ AI_audio_queue_thread_id = _thread.start_new_thread(AI_audio_queue_thread, ())
+ #_thread.stack_size(8*1024)
+ #开始会话
+ json_data = \
+ {
+ "header": {
+ "trace_id": "0a75ac012af172eb808782150509ee67",
+ "event": "Start"
+ },
+ "payload": {
+ "simple_response": True,
+ "out_format": "mp3",
+ "custom_variables": {
+ "bot_name": "柒妹妹"
+ },
+ "in_format": "pcm",
+ "space_time": 0,
+ "dialog_id": "",
+ "in_sample_rate": 16000,
+ "device_id": "860132060359338",
+ "volume": "100",
+ "sample_rate": 16000,
+ "user_agent": "python",
+ "voice": "ICL_zh_female_huoponvhai_tob",
+ "voice_detection": "enabled"
+ }
+ }
+ AI_client_tts.send(ujson.dumps(json_data))
+ AI_client_tts_1.send(ujson.dumps(json_data))
+ # print("AI_client_tts.send:{}".format(ujson.dumps(json_data)))
+def AI_client_VC_ping():
+ global AI_TTS_str,AI_client_tts,_4S_timer
+ #AI_client_tts.send("ping")
+ AI_client_tts.send("aaa")
+ print("AI_client_VC_ping")
+
+def AI_client_VC_RequestToRespond():
+ global AI_TTS_str,AI_client_tts
+ json_data = \
+ {
+ "header":{
+ "trace_id":"123456",
+ "event":"RequestToRespond"
+ },
+ "payload":{
+ "dialog_id":"123456",
+ "type":"transcript",#prompt是跳过asr,transcript是跳过asr和大模型
+ "text":""
+ }
+ }
+
+ print("AI_client_VC_RequestToRespond!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
+ # if VC_state == VC_State_RequestToRespond:
+ # print("AI_client_VC_RequestToRespond 重复 tts_str:{}\nasr_str:{}".format(AI_TTS_str,AI_ASR_str))
+
+ if AI_TTS_str != "":
+ json_data["payload"]["text"] = AI_TTS_str
+ json_data["payload"]["type"] = "transcript"
+ AI_TTS_str = ""
+ AI_client_tts.send(ujson.dumps(json_data))
+ #AI_ASR_str = ""
+ # utime.sleep_ms(1)
+# 音频队列
+def AI_audio_queue_thread():
+ while True:
+ try:
+ if AI_audio_queue.empty() :
+ # if count_t%200 == 0:
+ # print("AI_send_data_queue.empty")
+ utime.sleep_ms(5)
+ else:
+ #print("AI_audio_queue_thread")
+
+ data = AI_audio_queue.get()
+
+ #AI_client_tts_data_len=len(data)
+ print("audio_queue:len:{} \r\n".format(len(data[0]),data[1]))
+ if len(data[0]) > 1:
+ try:
+
+ tmp= aud.playStream(3, data[0])#播放音频流
+
+ print("出:{}!!!".format(len(data[0])))
+ mem = gc.mem_free()
+ print('1剩余内存RAM:{} KB'.format(mem / 1024))
+ except Exception as e:
+ print("AI_audio_queue_thread:ERROR:")
+ usys.print_exception(e)
+
+ utime.sleep_ms(2)
+ except Exception as e:
+ print("AI_audio_queue_thread:ERROR:")
+ usys.print_exception(e)
+
+websocket_connect_tts("/usr/didianguanji.mp3","当前使用人数较多,请稍候重试。")
+# for i in range(10):
+# websocket_connect_tts("/usr/R_READ_TIME_{}.mp3".format(i),"{}。".format(i))
+# utime.sleep_ms(4000)
+
+# data = "OPQRSTUVWXYZ"
+# #data = "AB"
+# for i in data:
+# websocket_connect_tts("/usr/R_READ_TIME_{}.mp3".format(i),"-{}。".format(i))
+# utime.sleep_ms(4000)
+
+# try:
+# att = None
+# att.connect()
+# except Exception as e:
+# str_tmp = str(e)
+# print("str_tmp:{}".format(str_tmp))
+# if str_tmp.find("connect") != -1:
+# print("find connect!!!!")
+# print("AI_audio_queue_thread:ERROR:{}".format(e))
+# usys.print_exception(e)
\ No newline at end of file
--- /dev/null
+import utime
+import osTimer
+import lvgl as lv
+import EventMesh
+from machine import Timer
+import voiceCall
+import osTimer
+import constants
+from misc import Power
+import pm
+import ujson
+import audio
+import ql_fs
+import audio
+import sms
+from machine import Pin
+from lcd import lcd
+from misc import PWM
+import uos
+import gc
+import _thread
+from queue import Queue
+from machine import RTC
+import usys
+def audio_cb(event):
+ if event == 0:
+ EventMesh.publish("set_audio_state", 1)
+ print('audio-play start.')
+ elif event == 7:
+ EventMesh.publish("set_audio_state", 0)
+ print('audio-play finish.')
+CALL_LOG_MAX = 50
+aud = audio.Audio(0)
+aud.setCallback(audio_cb)
+# -----------------------------------------style create--------------------------------------
+style_screen = lv.style_t()
+style_screen.init()
+style_screen.set_radius(0)
+style_screen.set_bg_color(lv.color_make(0x00, 0x00, 0x00))
+style_screen.set_bg_opa(255)
+style_screen.set_border_width(0)
+style_screen.set_pad_left(0)
+style_screen.set_pad_right(0)
+style_screen.set_pad_top(0)
+style_screen.set_pad_bottom(0)
+
+style_white_screen = lv.style_t()
+style_white_screen.init()
+style_white_screen.set_radius(0)
+style_white_screen.set_bg_color(lv.color_make(0xff, 0xff, 0xff))
+style_white_screen.set_bg_opa(255)
+style_white_screen.set_border_width(0)
+style_white_screen.set_pad_left(0)
+style_white_screen.set_pad_right(0)
+style_white_screen.set_pad_top(0)
+style_white_screen.set_pad_bottom(0)
+
+style_gray_bg = lv.style_t()
+style_gray_bg.init()
+style_gray_bg.set_bg_color(lv.color_make(0x00, 0xff, 0x2a))
+style_gray_bg.set_border_width(0)
+style_gray_bg.set_shadow_opa(0)
+style_gray_bg.set_pad_left(0)
+style_gray_bg.set_pad_right(0)
+style_gray_bg.set_pad_top(0)
+style_gray_bg.set_pad_bottom(0)
+
+style_bar = lv.style_t()
+style_bar.init()
+style_bar.set_radius(10)
+style_bar.set_bg_color(lv.color_make(0xA0, 0xA0, 0xA0))
+style_bar.set_bg_grad_color(lv.color_make(0xA0, 0xA0, 0xA0))
+style_bar.set_bg_grad_dir(lv.GRAD_DIR.VER)
+style_bar.set_bg_opa(60)
+style_bar.set_pad_left(0)
+style_bar.set_pad_right(0)
+style_bar.set_pad_top(0)
+style_bar.set_pad_bottom(0)
+
+
+style_bar_indic = lv.style_t()
+style_bar_indic.init()
+style_bar_indic.set_radius(10)
+style_bar_indic.set_bg_color(lv.color_make(0xff, 0x61, 0x3a))
+style_bar_indic.set_bg_grad_color(lv.color_make(0xff, 0x61, 0x3a))
+style_bar_indic.set_bg_grad_dir(lv.GRAD_DIR.VER)
+style_bar_indic.set_bg_opa(255)
+# 默认白色
+
+style_font_youyuan_20 = lv.style_t()
+style_font_youyuan_20.init()
+style_font_youyuan_20.set_text_color(lv.color_make(0xff, 0xff, 0xff))
+style_font_youyuan_20.set_text_font_v2("font_28.bin",28,0)
+
+
+style_font_youyuan_20_gray = lv.style_t()
+style_font_youyuan_20_gray.init()
+style_font_youyuan_20_gray.set_text_color(lv.color_make(128, 128, 128))
+style_font_youyuan_20_gray.set_text_font_v2("font_28.bin",28,0)
+
+style_font_youyuan_40 = lv.style_t()
+style_font_youyuan_40.init()
+style_font_youyuan_40.set_text_color(lv.color_make(0xff, 0xff, 0xff))
+style_font_youyuan_40.set_text_font_v2("font_40.bin",40,0)
+#黑色
+style_font_youyuan_20_black = lv.style_t()
+style_font_youyuan_20_black.init()
+style_font_youyuan_20_black.set_text_color(lv.color_make(0x00, 0x00, 0x00))
+style_font_youyuan_20_black.set_text_font_v2("font_28.bin",28,0)
+
+#灰色背景黑色字
+style_font_28_black_bg_gray = lv.style_t()
+style_font_28_black_bg_gray.init()
+style_font_28_black_bg_gray.set_text_color(lv.color_make(0x00, 0x00, 0x00))
+style_font_28_black_bg_gray.set_text_font_v2("font_28.bin",28,0)
+style_font_28_black_bg_gray.set_bg_color(lv.color_make(0xe1,0xdb,0xdb))
+
+#黑色
+style_black = lv.style_t()
+style_black.init()
+style_black.set_text_color(lv.color_make(0x00, 0x00, 0x00))
+
+
+style_font_youyuan_20_red = lv.style_t()
+style_font_youyuan_20_red.init()
+style_font_youyuan_20_red.set_text_color(lv.color_make(0xff, 0x00, 0x00))
+style_font_youyuan_20_red.set_text_font_v2("font_28.bin",28,0)
+
+style_img = lv.style_t()
+style_img.init()
+style_img.set_img_opa(255)
+
+style_line = lv.style_t()
+style_line.init()
+style_line.set_line_width(2)
+style_line.set_line_color(lv.color_make(0xff, 0xff, 0xff))
+
+
+style_list = lv.style_t()
+style_list.init()
+style_list.set_bg_color(lv.color_make(0x00, 0x00, 0x00))
+style_list.set_radius(0)
+style_list.set_bg_opa(255)
+style_list.set_border_width(0)
+style_list.set_pad_left(0)
+style_list.set_pad_right(0)
+style_list.set_pad_top(0)
+
+style_list_scro = lv.style_t()
+style_list_scro.init()
+style_list_scro.set_bg_opa(0)
+
+# create style style_btn
+style_btn = lv.style_t()
+style_btn.init()
+style_btn.set_bg_opa(0)
+style_btn.set_shadow_opa(0)
+style_btn.set_border_width(0)
+
+style_wechat_btn = lv.style_t()
+style_wechat_btn.init()
+style_wechat_btn.set_bg_color(lv.color_make(0x1E, 0x26, 0xff))
+style_wechat_btn.set_border_width(0)
+style_wechat_btn.set_shadow_opa(0)
+
+style_contact_btn = lv.style_t()
+style_contact_btn.init()
+style_contact_btn.set_bg_color(lv.color_make(0xff, 0xff, 0xff))
+style_contact_btn.set_border_width(0)
+style_contact_btn.set_shadow_opa(0)
+
+style_common_bg_rect_btn_pressed = lv.style_t()
+style_common_bg_rect_btn_pressed.init()
+style_common_bg_rect_btn_pressed.set_bg_color(lv.color_make(0x1E, 0x26, 0xff))
+style_common_bg_rect_btn_pressed.set_bg_opa(100)
+style_common_bg_rect_btn_pressed.set_border_width(0)
+style_common_bg_rect_btn_pressed.set_shadow_opa(0)
+
+style_contact_btn_pressed = lv.style_t()
+style_contact_btn_pressed.init()
+style_contact_btn_pressed.set_radius(5)
+style_contact_btn_pressed.set_bg_color(lv.color_make(0xff,0xff,0xff))
+style_contact_btn_pressed.set_bg_grad_color(lv.color_make(0x21,0x95,0xf6))
+style_contact_btn_pressed.set_bg_grad_dir(lv.GRAD_DIR.HOR)
+style_contact_btn_pressed.set_bg_opa(217)
+style_contact_btn_pressed.set_border_color(lv.color_make(0x21,0x95,0xf6))
+style_contact_btn_pressed.set_border_width(0)
+style_contact_btn_pressed.set_border_opa(255)
+style_contact_btn_pressed.set_text_color(lv.color_make(0x00,0x00,0x00))
+
+
+style_alipay_btn = lv.style_t()
+style_alipay_btn.init()
+style_alipay_btn.set_bg_color(lv.color_make(0xFF, 0xFF, 0xff))
+style_alipay_btn.set_bg_opa(20)
+style_alipay_btn.set_border_width(0)
+style_alipay_btn.set_shadow_opa(0)
+
+
+
+style_circle = lv.style_t()
+style_circle.init()
+style_circle.set_bg_color(lv.color_make(0xff, 0xff, 0xff))
+style_circle.set_radius(0x7FFF)
+
+
+
+from common import Abstract
+
+class Screen(Abstract):
+ meta_type = "UI"
+ def __init__(self):
+ self.meta = None
+ self.meta_info = None
+
+ # self.bg_img = None
+
+ # def set_bg_img(self, _fp):
+ # print("bg _fp = {} NAME = {} bg_img = {}".format(_fp, self.NAME, self.bg_img))
+ # if self.bg_img:
+ # self.bg_img.set_src(_fp)
+
+ def load_screen(self, e, msg):
+ print("msg = {}".format(msg))
+ EventMesh.publish("load_screen", msg)
+
+
+
+ def load(self):
+ pass
+
+ def get_meta(self):
+ return self.meta
+
+ def Close(self):
+ pass
+ def lcd_on(self):
+ pass
+ def lcd_off(self):
+ pass
+ def done_left_to_right(self):
+ pass
+
+ def done_right_to_left(self):
+ pass
+
+ def done_bottom_to_top(self):
+ pass
+
+ def done_top_to_bottom(self):
+ pass
+
+ def done_return(self):
+ pass
+
+ def done_click(self):
+ pass
+
+ def done_error(self):
+ pass
+ def handle_message_event(self,data):
+ pass
+ def publish_message_event(self,data):
+ EventMesh.publish("publish_message_event_ui", data)
+
+PHONE_CALL_MAX_DATA = 22
+
+phone_line_points = [{"x":0,"y":0},{"x":0,"y":40}]
+phone_screen = None
+phone_line = None
+phone_label = None
+phone_one = None
+phone_two = None
+phone_three = None
+phone_four = None
+phone_five = None
+phone_six = None
+phone_seven = None
+phone_eight = None
+phone_nine = None
+phone_start = None
+phone_zero = None
+phone_hash = None
+phone_call = None
+phone_call_btn = None
+phone_contact = None
+phone_contact_btn = None
+phone_delete = None
+phone_delete_btn = None
+
+class PhoneScreen(Screen):
+ NAME = "Phone"
+
+ def __init__(self):
+
+ super().__init__()
+ self.meta = None
+ self.phone_num = ''
+ self.phone_list = []
+ self.button = 0
+ self.timer = osTimer()
+ self.timer_cb = 0
+ self.count = 0
+
+
+
+ def initialization(self):
+ self.phone_num=''
+ self.phone_list = []
+ global phone_screen ,phone_line,phone_label,phone_one,phone_two,phone_three,phone_four,phone_five,phone_six,phone_seven,phone_eight,phone_nine,phone_start,\
+ phone_zero,phone_hash,phone_call,phone_call_btn,phone_contact,phone_contact_btn,phone_delete,phone_delete_btn
+
+
+ if phone_screen == None:
+ phone_screen = lv.obj()
+ print("phone_screen")
+ phone_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ phone_line = lv.line(phone_screen)
+ phone_line.set_points(phone_line_points,2)
+ phone_line.set_pos(235,8)
+ phone_line.set_size(2,40)
+ phone_line.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ phone_line.add_style(style_line,0)
+
+ phone_label = lv.label(phone_screen)
+ phone_label.set_pos(0, 14)
+ phone_label.set_size(0, 48)
+ phone_label.set_text(" ")
+ phone_label.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
+ phone_label.set_long_mode(lv.label.LONG.CLIP)
+ phone_label.set_style_text_align(lv.TEXT_ALIGN.RIGHT, 0)
+
+ phone_one = lv.img(phone_screen)
+ phone_one.set_src("E:/static/IMAGE_NUMBER_KEY1_ICON.png")
+ phone_one.add_flag(lv.obj.FLAG.CLICKABLE)
+ phone_one.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ phone_one.set_pos(3, 60)
+ phone_one.set_size(76, 50)
+
+ phone_two = lv.img(phone_screen)
+ phone_two.set_size(76, 50)
+ phone_two.set_src("E:/static/IMAGE_NUMBER_KEY2_ICON.png")
+ phone_two.add_flag(lv.obj.FLAG.CLICKABLE)
+ phone_two.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ phone_two.set_pos(82, 60)
+
+ phone_three = lv.img(phone_screen)
+ phone_three.set_size(76, 50)
+ phone_three.set_src("E:/static/IMAGE_NUMBER_KEY3_ICON.png")
+ phone_three.add_flag(lv.obj.FLAG.CLICKABLE)
+ phone_three.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ phone_three.set_pos(161, 60)
+
+ phone_four = lv.img(phone_screen)
+ phone_four.set_size(76, 50)
+ phone_four.set_src("E:/static/IMAGE_NUMBER_KEY4_ICON.png")
+ phone_four.add_flag(lv.obj.FLAG.CLICKABLE)
+ phone_four.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ phone_four.set_pos(3, 112)
+
+ phone_five = lv.img(phone_screen)
+ phone_five.set_size(76, 50)
+ phone_five.set_src("E:/static/IMAGE_NUMBER_KEY5_ICON.png")
+ phone_five.add_flag(lv.obj.FLAG.CLICKABLE)
+ phone_five.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ phone_five.set_pos(82, 112)
+
+ phone_six = lv.img(phone_screen)
+ phone_six.set_size(76, 50)
+ phone_six.set_src("E:/static/IMAGE_NUMBER_KEY6_ICON.png")
+ phone_six.add_flag(lv.obj.FLAG.CLICKABLE)
+ phone_six.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ phone_six.set_pos(161, 112)
+
+ phone_seven = lv.img(phone_screen)
+ phone_seven.set_size(76, 50)
+ phone_seven.set_src("E:/static/IMAGE_NUMBER_KEY7_ICON.png")
+ phone_seven.add_flag(lv.obj.FLAG.CLICKABLE)
+ phone_seven.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ phone_seven.set_pos(3, 164)
+
+ phone_eight = lv.img(phone_screen)
+ phone_eight.set_size(76, 50)
+ phone_eight.set_src("E:/static/IMAGE_NUMBER_KEY8_ICON.png")
+ phone_eight.add_flag(lv.obj.FLAG.CLICKABLE)
+ phone_eight.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ phone_eight.set_pos(82, 164)
+
+ phone_nine = lv.img(phone_screen)
+ phone_nine.set_size(76, 50)
+ phone_nine.set_src("E:/static/IMAGE_NUMBER_KEY9_ICON.png")
+ phone_nine.add_flag(lv.obj.FLAG.CLICKABLE)
+ phone_nine.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ phone_nine.set_pos(161, 164)
+
+ phone_start = lv.img(phone_screen)
+ phone_start.set_size(76, 50)
+ phone_start.set_src("E:/static/IMAGE_NUMBER_KEYSTAR_ICON.png")
+ phone_start.add_flag(lv.obj.FLAG.CLICKABLE)
+ phone_start.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ phone_start.set_pos(3, 216)
+
+ phone_zero = lv.img(phone_screen)
+ phone_zero.set_size(76, 50)
+ phone_zero.set_src("E:/static/IMAGE_NUMBER_KEY0_ICON.png")
+ phone_zero.add_flag(lv.obj.FLAG.CLICKABLE)
+ phone_zero.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ phone_zero.set_pos(82, 216)
+
+ phone_hash = lv.img(phone_screen)
+ phone_hash.set_size(76, 50)
+ phone_hash.set_src("E:/static/IMAGE_NUMBER_KEYHASH_ICON.png")
+ phone_hash.add_flag(lv.obj.FLAG.CLICKABLE)
+ phone_hash.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ phone_hash.set_pos(161, 216)
+
+ phone_call = lv.img(phone_screen)
+ phone_call.set_size(76, 50)
+ phone_call.set_src("E:/static/IMAGE_BUTTON_DIAL.png")
+ phone_call.add_flag(lv.obj.FLAG.CLICKABLE)
+ phone_call.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ phone_call.set_pos(3, 270)
+
+ phone_call_btn = lv.img(phone_screen)
+ phone_call_btn.set_size(76, 52)
+ phone_call_btn.add_flag(lv.obj.FLAG.CLICKABLE)
+ phone_call_btn.set_pos(3, 268)
+
+ phone_contact = lv.img(phone_screen)
+ phone_contact.set_size(64, 50)
+ phone_contact.set_src("E:/static/IMAGE_BUTTON_DIAL_CONTACT.png")
+ phone_contact.add_flag(lv.obj.FLAG.CLICKABLE)
+ phone_contact.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ phone_contact.set_pos(87, 270)
+
+ phone_contact_btn = lv.img(phone_screen)
+ phone_contact_btn.set_size(76, 52)
+ phone_contact_btn.add_flag(lv.obj.FLAG.CLICKABLE)
+ phone_contact_btn.set_pos(87, 268)
+
+ phone_delete = lv.img(phone_screen)
+ phone_delete.set_size(76, 50)
+ phone_delete.set_src("E:/static/IMAGE_BUTTON_DELKEY.png")
+ phone_delete.add_flag(lv.obj.FLAG.CLICKABLE)
+ phone_delete.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ phone_delete.set_pos(161, 270)
+
+ phone_delete_btn = lv.img(phone_screen)
+ phone_delete_btn.set_size(76, 52)
+ phone_delete_btn.add_flag(lv.obj.FLAG.CLICKABLE)
+ phone_delete_btn.set_pos(161, 268)
+
+ self.meta = phone_screen
+
+ phone_one.add_event_cb(lambda e: EventMesh.callback_wrapper(self.one(e)),
+ lv.EVENT.CLICKED, None)
+ phone_two.add_event_cb(lambda e: EventMesh.callback_wrapper(self.two(e)),
+ lv.EVENT.CLICKED, None)
+ phone_three.add_event_cb(lambda e: EventMesh.callback_wrapper(self.three(e)),
+ lv.EVENT.CLICKED, None)
+ phone_four.add_event_cb(lambda e: EventMesh.callback_wrapper(self.four(e)),
+ lv.EVENT.CLICKED, None)
+ phone_five.add_event_cb(lambda e: EventMesh.callback_wrapper(self.five(e)),
+ lv.EVENT.CLICKED, None)
+ phone_six.add_event_cb(lambda e: EventMesh.callback_wrapper(self.six(e)),
+ lv.EVENT.CLICKED, None)
+ phone_seven.add_event_cb(lambda e: EventMesh.callback_wrapper(self.seven(e)),
+ lv.EVENT.CLICKED, None)
+ phone_eight.add_event_cb(lambda e: EventMesh.callback_wrapper(self.eight(e)),
+ lv.EVENT.CLICKED, None)
+ phone_nine.add_event_cb(lambda e: EventMesh.callback_wrapper(self.nine(e)),
+ lv.EVENT.CLICKED, None)
+ phone_zero.add_event_cb(lambda e: EventMesh.callback_wrapper(self.zero(e)),
+ lv.EVENT.CLICKED, None)
+
+ phone_call_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.call(e)),
+ lv.EVENT.CLICKED, None)
+ phone_contact_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.contact(e)),
+ lv.EVENT.CLICKED, None)
+ phone_delete_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.delete(e)),
+ lv.EVENT.CLICKED, None)
+
+ phone_start.add_event_cb(lambda e: EventMesh.callback_wrapper(self.start(e)),
+ lv.EVENT.CLICKED, None)#短按显示*
+
+ phone_start.add_event_cb(lambda e: EventMesh.callback_wrapper(self.pressed_start(e)),
+ lv.EVENT.LONG_PRESSED, None)#长按显示+
+
+ phone_start.add_event_cb(lambda e: EventMesh.callback_wrapper(self.endpressed_start(e)),
+ lv.EVENT.RELEASED, None)#释放按键
+
+
+ phone_hash.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hash(e)),
+ lv.EVENT.CLICKED, None)
+
+
+ self.phone_num=''
+ self.phone_list = []
+ self.count = 0
+ if phone_label != None:
+ phone_label.set_pos(0, 14)
+ phone_label.set_size(0, 0)
+ phone_label.set_text(" ")
+ #phone_label.set_text(" ")
+ # print("self.phone_list :{} self.phone_num:{}".format(self.phone_list,self.phone_num))
+ if self.timer_cb == 0:
+ self.timer_cb = 1
+ self.timer.start(1000,1,self.refresh_line)
+
+
+ def refresh_line(self,e):
+ if self.count > 2 :
+ self.count = 1
+ if self.count%2 == 0:
+ phone_line.clear_flag(lv.obj.FLAG.HIDDEN)
+ else:
+ phone_line.add_flag(lv.obj.FLAG.HIDDEN)
+ self.count+=1
+ def one(self,e):
+ if len(self.phone_list) >= PHONE_CALL_MAX_DATA:
+ #self.phone_list.pop(0)
+ return
+ self.phone_list.append("1")
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+ def two(self,e):
+ if len(self.phone_list) >= PHONE_CALL_MAX_DATA:
+ #self.phone_list.pop(0)
+ return
+ self.phone_list.append("2")
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+ def three(self,e):
+ if len(self.phone_list) >= PHONE_CALL_MAX_DATA:
+ #self.phone_list.pop(0)
+ return
+ self.phone_list.append("3")
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+ def four(self,e):
+ if len(self.phone_list) >= PHONE_CALL_MAX_DATA:
+ #self.phone_list.pop(0)
+ return
+ self.phone_list.append("4")
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+ def five(self,e):
+ if len(self.phone_list) >= PHONE_CALL_MAX_DATA:
+ #self.phone_list.pop(0)
+ return
+ self.phone_list.append("5")
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+ def six(self,e):
+ if len(self.phone_list) >= PHONE_CALL_MAX_DATA:
+ #self.phone_list.pop(0)
+ return
+ self.phone_list.append("6")
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+ def seven(self,e):
+ if len(self.phone_list) >= PHONE_CALL_MAX_DATA:
+ #self.phone_list.pop(0)
+ return
+ self.phone_list.append("7")
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+ def eight(self,e):
+ if len(self.phone_list) >= PHONE_CALL_MAX_DATA:
+ #self.phone_list.pop(0)
+ return
+ self.phone_list.append("8")
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+ def nine(self,e):
+ if len(self.phone_list) >= PHONE_CALL_MAX_DATA:
+ #self.phone_list.pop(0)
+ return
+ self.phone_list.append("9")
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+ def zero(self,e):
+ if len(self.phone_list) >= PHONE_CALL_MAX_DATA:#限制拨号数量20个数字
+ #self.phone_list.pop(0)
+ return
+ self.phone_list.append("0")
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+ def start(self,e):
+ self.button = 0
+
+ def pressed_start(self,e):
+ self.button = 1
+ def Close(self):
+ self.timer_cb = 0
+ self.timer.stop()
+
+ def endpressed_start(self,e):
+ if len(self.phone_list) >= PHONE_CALL_MAX_DATA:#限制拨号数量20个数字
+ #self.phone_list.pop(0)
+ return
+
+ if self.button == 1:#长按
+ self.phone_list.append("+")
+ else:#短按
+ self.phone_list.append("*")
+
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+ def hash(self,e):
+ if len(self.phone_list) >= PHONE_CALL_MAX_DATA:#限制拨号数量20个数字
+ #self.phone_list.pop(0)
+ return
+ self.phone_list.append("#")
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+
+ def delete(self,e):
+ if len(self.phone_list) != 0:
+ self.phone_list.pop()
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+ def contact(self,e):
+ EventMesh.publish("load_screen", {"screen": "contacts"})
+
+ def call(self,e):
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:
+ self.name = None
+ self.phonebook = {}
+ self.number_tmp = {}
+ if len(self.phone_list) != 0:
+ data = EventMesh.publish("get_phonebook_list")
+ if data != None:
+ check = data[0]
+ self.phonebook = data[1]
+ # print("check :{}".format(check))
+ if check == 1:#检查通讯录
+ phonebook_keys = sorted(self.phonebook.keys())
+ b = str(self.phone_num) in self.phonebook.values()#查找key中是否包含content电话号码 True 包含在里面 False不包含在里面
+ j = 0
+ if b == True:
+ for i in range(len(self.phonebook)): #字典 key value
+ #'001:张三':15521469561
+ name = self.phonebook[phonebook_keys[j]]
+ name_value = phonebook_keys[j]
+ number_tmp = str(self.phone_num)
+ # print("name :{} number_tmp:{}".format(name,number_tmp))
+ if name.find(number_tmp) != -1:#查找电话号码是否在通讯录里面
+ number_f= name_value
+ name_s = number_f.split(':')
+ name_s = name_s[1]
+ self.name = name_s
+ break
+ j+=1
+ else:
+ self.name = self.phone_num
+ else:
+ self.name = self.phone_num
+
+ EventMesh.publish("save_phonenum",self.phone_num)
+ EventMesh.publish("save_phonename",self.name)#
+ EventMesh.publish("load_screen", {"screen": "dialing_noplay_popup"})
+ else:
+ EventMesh.publish("load_screen", {"screen": "no_valied_num_screen"})
+ else:#未插卡
+ EventMesh.publish("load_screen", {"screen": "no_sim_popup_screen"})
+
+
+ def show_num(self):
+ #print("self.phone_num ",self.phone_num,self.phone_list)
+ len_t = len(self.phone_list)*40
+ if len_t > 230:
+ len_t = 230
+ phone_label.set_size(len_t,48)
+ phone_label.set_pos(230-len_t,14)
+ phone_label.set_text(self.phone_num)
+
+ def lcd_on(self):
+ if self.timer_cb != 0:
+ self.timer_cb = 0
+ self.timer.start(1000,1,self.refresh_line)
+
+ def lcd_off(self):
+ self.timer_cb = 1
+ self.timer.stop()
+
+
+ def done_return(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn1_release(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
+call_log_screen = None
+contacts_cont_list = None
+call_log_title = None
+none_call_log_title = None
+call_log_cont_list_screen = None
+CALLLOG_FLAG = 0
+class CallLogScreen(Screen):
+ NAME = "call_log"
+
+ def __init__(self):
+ super().__init__()
+ self.CALL_LOG_MAX = CALL_LOG_MAX
+ self.meta = None
+ self.log_list = []
+ self.read_call_log = {}
+ self.check_json = 0
+ self.call_log_detail_list = None
+ self.call_log_detail_list_dict = []
+ self.timer = osTimer()
+ self.is_sliding = 0
+ EventMesh.subscribe("call_log_update_show_list", self.call_log_update_show_list)
+
+ def post_processor_before_initialization(self):
+ read_call_log = EventMesh.publish("get_call_log_list")
+ if read_call_log != None:
+ self.check_json = read_call_log[0]
+ self.read_call_log = read_call_log[1]
+
+
+
+ def call_log_update_show_list(self, event, msg):
+ read_call_log = EventMesh.publish("get_call_log_list")
+ if read_call_log != None:
+ # print("read_call_log:{}".format(read_call_log))
+ self.check_json = read_call_log[0] #文件是否存在
+ self.read_call_log = read_call_log[1]#通话记录数据
+ self.timer.start(500,0,self.reciving)
+
+ def reciving(self,e):
+ self.btn_create()
+
+ def initialization(self):
+ self.is_sliding = 0
+ global call_log_screen,contacts_cont_list ,call_log_title ,none_call_log_title ,call_log_cont_list_screen
+ if call_log_screen == None:
+ call_log_screen = lv.obj()
+ print("call_log_screen")
+ call_log_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ call_log_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ call_log_cont_list_screen = lv.obj(call_log_screen)
+ call_log_cont_list_screen.set_pos(0, 50)
+ call_log_cont_list_screen.set_size(240, 270)
+ call_log_cont_list_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ call_log_cont_list_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+ call_log_title = lv.label(call_log_screen)
+ call_log_title.set_pos(0, 10)
+ call_log_title.set_size(240, 40)
+ call_log_title.set_long_mode(lv.label.LONG.CLIP)
+ call_log_title.set_text("通话记录")
+ call_log_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ call_log_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ none_call_log_title = lv.label(call_log_cont_list_screen)
+ none_call_log_title.set_pos(0, 120)
+ none_call_log_title.set_size(240, 40)
+ none_call_log_title.set_long_mode(lv.label.LONG.WRAP)
+ none_call_log_title.set_text(" ")
+ none_call_log_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ none_call_log_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ #self.call_log_detail_list = lv.obj(call_log_screen)
+ self.call_log_detail_list = lv.obj(call_log_cont_list_screen)
+ self.call_log_detail_list.set_pos(0, 0)
+ self.call_log_detail_list.set_size(240, 271)
+ self.call_log_detail_list.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ self.call_log_detail_list.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+ for i in range(self.CALL_LOG_MAX):
+ _btn = lv.btn(self.call_log_detail_list)
+ _btn.add_flag(lv.obj.FLAG.CLICKABLE)
+ _btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.calling(e)),
+ lv.EVENT.CLICKED, None)
+ _btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.calling(e)),
+ lv.EVENT.PRESSING, None)
+ _btn.add_flag(lv.obj.FLAG.HIDDEN)
+ _btn_label2 = lv.label(_btn)
+ _btn_label3 = lv.label(_btn)
+ _btn_label4 = lv.label(_btn)
+ _btn_label5 = lv.label(_btn)
+ _btn_label6 = lv.label(_btn)
+ _btn.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+ _btn_label4.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+ _btn_label6.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ self.call_log_detail_list_dict.append({"_btn":_btn,"_btn_label2":_btn_label2,"_btn_label3":_btn_label3,
+ "_btn_label4":_btn_label4,"_btn_label5":_btn_label5,"_btn_label6":_btn_label6})
+ self.meta = call_log_screen
+
+
+ read_call_log = EventMesh.publish("get_call_log_list")
+ # print("read_call_log:{}".format(read_call_log))
+ if read_call_log != None:
+ self.check_json = read_call_log[0] #文件是否存在
+ self.read_call_log = read_call_log[1]#通话记录数据
+ if self.check_json == True and self.read_call_log != {}:
+ none_call_log_title.set_text(" ")
+ else:
+ none_call_log_title.set_text("暂无记录")
+ self.btn_create()
+
+ def btn_create(self):
+ EventMesh.publish("publish_message_event_ui",{"func":self.btn_create_screen,"data":0})
+
+ def btn_create_screen(self,data):
+ global call_log_screen,contacts_cont_list ,call_log_title ,none_call_log_title ,call_log_cont_list_screen
+ h = 0
+ if call_log_screen != None:
+ if self.check_json == True and len(self.read_call_log) != 0:
+
+ none_call_log_title.set_text(" ")
+
+ # self.call_log_detail_list.delete()#先删除一次控件
+ # self.call_log_detail_list = lv.obj(call_log_cont_list_screen)
+ # self.call_log_detail_list.set_pos(0, 0)
+ # self.call_log_detail_list.set_size(240, 271)
+ # self.call_log_detail_list.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ # self.call_log_detail_list.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+ sort_tmp = self.read_call_log.values()
+ sort_new = sorted(sort_tmp, key = lambda i: i['timesec'],reverse = True)#按照时间戳进行排序 去掉最旧的一次数据如果满了五十条
+ # print("self.call_log :{} \r\n sort_new:{}\r\n".format(self.read_call_log,sort_new))
+ self.call_log_detail_list.clear_flag(lv.obj.FLAG.HIDDEN)#隐藏空文本
+ for sort_new_tmp in sort_new: #字典 key value
+ num_count = sort_new_tmp["count"]#获取通话次数
+ num_name = sort_new_tmp["name"]#获取名称
+ num_phonnum = sort_new_tmp["number"]#获取电话号码
+ num_time = sort_new_tmp["time"]#获取电话号码
+
+ # print("num_count :{} num_name:{} num_time:{}".format(num_count,num_name,num_time))
+ #_btn = lv.btn(self.call_log_detail_list)
+ self.call_log_detail_list_dict[h]["_btn"].set_size(240,80)
+ self.call_log_detail_list_dict[h]["_btn"].set_pos(0,82*h)
+ #self.call_log_detail_list_dict[h]["_btn"].add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+ self.call_log_detail_list_dict[h]["_btn"].add_event_cb(lambda e: EventMesh.callback_wrapper(self.calling(e)),
+ lv.EVENT.CLICKED, None)
+
+
+ #_btn_label2 = lv.label(_btn)
+ self.call_log_detail_list_dict[h]["_btn_label2"].set_pos(0, 5)
+ self.call_log_detail_list_dict[h]["_btn_label2"].set_size(0, 25)
+ self.call_log_detail_list_dict[h]["_btn_label2"].set_text(num_phonnum)
+ #_btn_label2.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+ #
+ #_btn_label3 = lv.label(_btn)
+ self.call_log_detail_list_dict[h]["_btn_label3"].set_pos(0, 0)
+ self.call_log_detail_list_dict[h]["_btn_label3"].set_size(0, 0)
+ self.call_log_detail_list_dict[h]["_btn_label3"].set_text("(" + str(num_count) + ")")
+ # _btn_label3.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ #_btn_label4 = lv.label(_btn)
+ self.call_log_detail_list_dict[h]["_btn_label4"].set_pos(0, 38)
+ self.call_log_detail_list_dict[h]["_btn_label4"].set_size(230, 30)
+ self.call_log_detail_list_dict[h]["_btn_label4"].set_long_mode(lv.label.LONG.CLIP)
+ self.call_log_detail_list_dict[h]["_btn_label4"].set_text(num_phonnum)
+ #self.call_log_detail_list_dict[h]["_btn_label4"].add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ #_btn_label5 = lv.label(_btn)
+ self.call_log_detail_list_dict[h]["_btn_label5"].set_pos(0, 5)
+ self.call_log_detail_list_dict[h]["_btn_label5"].set_size(0, 0)
+ self.call_log_detail_list_dict[h]["_btn_label5"].set_text(num_name)
+ # _btn_label5.set_long_mode(lv.obj.LONG.DOT)
+ # _btn_label5.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ #_btn_label6 = lv.label(_btn)
+ self.call_log_detail_list_dict[h]["_btn_label6"].set_pos(0, 5)
+ self.call_log_detail_list_dict[h]["_btn_label6"].set_size(230, 28)
+ self.call_log_detail_list_dict[h]["_btn_label6"].set_long_mode(lv.label.LONG.CLIP)
+ self.call_log_detail_list_dict[h]["_btn_label6"].set_text(num_name)
+ #self.call_log_detail_list_dict[h]["_btn_label6"].add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ self.call_log_detail_list_dict[h]["_btn"].clear_flag(lv.obj.FLAG.HIDDEN)
+ #self.call_log_detail_list_dict[h]["_btn"].scroll_to_view(lv.ANIM.OFF)
+ h = h + 1
+ for i in range(self.CALL_LOG_MAX):
+ if i >= h :
+ self.call_log_detail_list_dict[i]["_btn"].add_flag(lv.obj.FLAG.HIDDEN)#隐藏多余
+ else:
+ if call_log_cont_list_screen != None:
+ none_call_log_title.set_text("暂无记录")
+ self.call_log_detail_list.add_flag(lv.obj.FLAG.HIDDEN)#隐藏空文本
+
+ def calling(self,e):
+ code = e.get_code()
+ if code == lv.EVENT.PRESSING:
+ #print("PRESSING")
+ self.is_sliding += 1
+
+ elif code == lv.EVENT.CLICKED:
+ #utime.sleep_ms(10)
+ print("1self.is_sliding",self.is_sliding)
+ if self.is_sliding <= 5 and self.is_sliding != 0:#如果是在滑动中则不需要点击事件
+ self.is_sliding = 0
+
+ global call_log_screen,contacts_cont_list ,call_log_title ,none_call_log_title
+ # print("e.get_text():{} {}".format(e.get_target().get_child(0).get_text(),e.get_target().get_child(3).get_text()))
+ phonnum = str(e.get_target().get_child(0).get_text())
+ phnoname = e.get_target().get_child(3).get_text()
+ # print("phonnum :{} _msg:{}".format(phonnum,phnoname))
+
+
+ self.name = None
+ self.phonebook = {}
+
+ self.call_log = {}
+ self.call_log_value = {}
+ self.read_call_log = {}
+ self.number_tmp = {}
+
+ data = EventMesh.publish("get_phonebook_list")
+ if data != None:
+ check = data[0]
+ self.phonebook = data[1]
+ # print("check :{}".format(check))
+ if check == 1:#检查通讯录
+ phonebook_keys = sorted(self.phonebook.keys())
+ b = str(phonnum) in self.phonebook.values()#查找key中是否包含content电话号码 True 包含在里面 False不包含在里面
+ j = 0
+ if b == True:
+ for i in range(len(self.phonebook)): #字典 key value
+ #'001:':15521469561
+ name = self.phonebook[phonebook_keys[j]]
+ name_value = phonebook_keys[j]
+ number_tmp = str(phonnum)
+ # print("name :{} number_tmp:{}".format(name,number_tmp))
+ if name.find(number_tmp) != -1:#查找电话号码是否在通讯录里面
+ number_f= name_value
+ name_s = number_f.split(':')
+ name_s = name_s[1]
+ self.name = name_s
+ break
+ j+=1
+ else:
+ self.name = phnoname
+ else:
+ self.name = phnoname
+
+ if self.name == None:
+ self.name = phnoname
+ if len(phonnum) > 0:
+ EventMesh.publish("save_phonename",self.name)#
+ EventMesh.publish("save_phonenum",phonnum)#保存电话号码用于界面显示获取
+ #voiceCall.callStart(str(phonnum))
+ EventMesh.publish("load_screen", {"screen": "dialing_noplay_popup"})
+ else:
+ EventMesh.publish("load_screen", {"screen": "no_valied_num_screen"})#无效的号码 请重新输入
+ self.is_sliding = 0
+
+ def done_return(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn1_release(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn8_press(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
+# ------------------------------拨打电话-------------dialing screen----------------------------------------------------------
+
+dialing_screen = None
+dialing_img = None
+dialing_name = None
+dialing_call_label = None
+hangup_imgbtn = None
+class DialingScreen(Screen):
+ NAME = "dialing"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.timer = osTimer()
+ self.call_log = {}
+ self.call_log_value = {}
+ self.read_call_log = {}
+ self.number_tmp = {}
+ self.CALL_LOG_MAX = CALL_LOG_MAX
+ self.meta_type = "popup"
+
+
+ def initialization(self):
+ EventMesh.publish("set_UI_high_priority", 1)
+ global dialing_screen,dialing_img,dialing_name ,hangup_imgbtn
+ if dialing_screen == None:
+ dialing_screen = lv.obj()
+ print("dialing_screen")
+ dialing_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ dialing_img = lv.img(dialing_screen)
+ dialing_img.set_pos(80, 20)
+ dialing_img.set_size(64, 64)
+ dialing_img.set_src("E:/static/IMAGE_NOTICE_CALL.png")
+ dialing_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ dialing_name = lv.label(dialing_screen)
+ dialing_name.set_pos(0, 120)
+ dialing_name.set_size(240, 50)
+ dialing_name.set_text(" ")
+ dialing_name.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ dialing_name.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ dialing_call_label = lv.label(dialing_screen)
+ dialing_call_label.set_pos(0, 174)
+ dialing_call_label.set_size(240, 50)
+ dialing_call_label.set_text("正在等待对方接\n听电话")
+ dialing_call_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ dialing_call_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ hangup_imgbtn = lv.img(dialing_screen)
+ hangup_imgbtn.set_size(64, 64)
+ hangup_imgbtn.set_src("E:/static/hang_up.png")
+ hangup_imgbtn.set_pos(80, 240)
+ hangup_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
+ hangup_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+ hangup_label_imgbtn = lv.label(dialing_screen)
+ hangup_label_imgbtn.set_pos(40, 200)
+ hangup_label_imgbtn.set_size(160, 120)
+ hangup_label_imgbtn.set_text(" ")
+ hangup_label_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
+
+ hangup_label_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hangup(e)),
+ lv.EVENT.SHORT_CLICKED, None)
+
+ hangup_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hangup(e)),
+ lv.EVENT.SHORT_CLICKED, None)
+ self.meta = dialing_screen
+ if dialing_name != None:
+ name = EventMesh.publish("get_phonename")#获取拨打电话名称
+ dialing_name.set_text(name)#名称
+ def post_processor_after_initialization(self):
+ # print("创建通话记录 post_processor_before_initialization\n")
+ utime.sleep_ms(200)#不加延时会切屏
+
+
+ def hangup(self,e):
+ EventMesh.publish("set_UI_high_priority", 0)
+ EventMesh.publish("set_hangup_mode", 1)
+ EventMesh.publish("close_sos_timer")
+ voiceCall.callEnd()
+ EventMesh.publish("set_interrup_incall",0)
+ EventMesh.publish("set_UI_high_priority",0)
+ EventMesh.publish("return_prev_screen")
+
+ def Close(self):
+ self.timer.stop()
+
+ def call_end(self,*argc):
+ call_state = EventMesh.publish("get_call_state")#设置关机时间
+ if call_state != None:
+ if call_state == 0:#未打通
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
+ def done_return(self):
+ pass
+ #EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn1_release(self):
+ pass
+ #EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn8_press(self):
+ flag = EventMesh.publish("get_lcd_state")
+ if flag == 1:
+ EventMesh.publish(constants.EVENT.SYSTEM_SLEEP)
+ else:
+ EventMesh.publish(constants.EVENT.SYSTEM_UP)
+
+
+
+no_sim_popup_screen = None
+no_sim_popup_screen_title1 = None
+no_sim_popup_screen_title2 = None
+#未插卡
+class NoSimScreen(Screen):#
+ NAME = "no_sim_popup_screen"
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.meta_type = "popup"
+
+ def initialization(self):
+ global no_sim_popup_screen,no_sim_popup_screen_title1,no_sim_popup_screen_title2
+ if no_sim_popup_screen == None :
+ no_sim_popup_screen = lv.obj()
+ print("no_sim_popup_screen")
+ no_sim_popup_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ no_sim_popup_screen_title1 = lv.label(no_sim_popup_screen)
+ no_sim_popup_screen_title1.set_pos(0, 140)
+ no_sim_popup_screen_title1.set_size(240, 40)
+ no_sim_popup_screen_title1.set_text("无SIM卡或")
+ no_sim_popup_screen_title1.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ no_sim_popup_screen_title1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ no_sim_popup_screen_title2 = lv.label(no_sim_popup_screen)
+ no_sim_popup_screen_title2.set_pos(0, 190)
+ no_sim_popup_screen_title2.set_size(240, 40)
+ no_sim_popup_screen_title2.set_text("无网络")
+ no_sim_popup_screen_title2.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ no_sim_popup_screen_title2.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ self.meta = no_sim_popup_screen
+
+ def done_left_to_right(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_right_to_left(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_bottom_to_top(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_top_to_bottom(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("return_prev_screen")
+
+
+no_valied_num_screen = None
+no_valied_num_screen_title1 = None
+no_valied_num_screen_title2 = None
+#=无效的号码 请重新输入
+class NovaliedNumScreen(Screen):#
+ NAME = "no_valied_num_screen"
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.meta_type = "popup"
+ self.timer_count = 0
+ self.timer=osTimer()
+
+ def initialization(self):
+ global no_valied_num_screen,no_valied_num_screen_title1,no_valied_num_screen_title2
+ if no_valied_num_screen == None :
+ no_valied_num_screen = lv.obj()
+ print("no_valied_num_screen")
+ no_valied_num_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ no_valied_num_screen_title1 = lv.label(no_valied_num_screen)
+ no_valied_num_screen_title1.set_pos(0, 140)
+ no_valied_num_screen_title1.set_size(240, 40)
+ no_valied_num_screen_title1.set_text("无效的号码,")
+ no_valied_num_screen_title1.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ no_valied_num_screen_title1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+ no_valied_num_screen_title2 = lv.label(no_valied_num_screen)
+ no_valied_num_screen_title2.set_pos(0, 190)
+ no_valied_num_screen_title2.set_size(240, 40)
+ no_valied_num_screen_title2.set_text("请重新输入")
+ no_valied_num_screen_title2.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ no_valied_num_screen_title2.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ self.meta = no_valied_num_screen
+ def post_processor_after_initialization(self):
+ self.timer_count = 0
+ self.timer.start(5000,1,self.timeout_exit)
+
+ def timeout_exit(self,e):
+ self.timer_count+=1
+ if self.timer_count >= 2:
+ self.timer_count = 0
+ EventMesh.publish("return_prev_screen")
+
+ def Close(self):
+ self.timer.stop()
+
+ def done_left_to_right(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_right_to_left(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_bottom_to_top(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_top_to_bottom(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("return_prev_screen")
+
+
+
+no_sim_power_screen = None
+no_sim_power_screen_title = None
+no_sim_power_screen_label =None
+no_sim_power_screen_comfirm =None
+no_sim_power_screen_cancel = None
+no_sim_power_screen_img = None
+
+#未插卡,长按关机
+class NoSimPowerScreen(Screen):#
+ NAME = "no_sim_power_screen"
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.meta_type = "popup"
+
+ def initialization(self):
+ global no_sim_power_screen,no_sim_power_screen_img,no_sim_power_screen_title,no_sim_power_screen_comfirm,no_sim_power_screen_cancel,no_sim_power_screen_label
+ if no_sim_power_screen == None :
+ no_sim_power_screen = lv.obj()
+ print("no_sim_power_screen")
+ no_sim_power_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ no_sim_power_screen_title = lv.label(no_sim_power_screen)
+ no_sim_power_screen_title.set_pos(0, 20)
+ no_sim_power_screen_title.set_size(240, 40)
+ no_sim_power_screen_title.set_text("无SIM卡,无法拨打")
+ no_sim_power_screen_title.set_long_mode(lv.label.LONG.WRAP)
+ no_sim_power_screen_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ no_sim_power_screen_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ no_sim_power_screen_img = lv.img(no_sim_power_screen)
+ no_sim_power_screen_img.set_pos(100, 70)
+ no_sim_power_screen_img.set_size(61, 61)
+ no_sim_power_screen_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ no_sim_power_screen_img.set_src("E:/static/poweroff_icon.png")
+
+
+ no_sim_power_screen_label = lv.label(no_sim_power_screen)
+ no_sim_power_screen_label.set_pos(0, 150)
+ no_sim_power_screen_label.set_size(240, 40)
+ no_sim_power_screen_label.set_text("是否关机?")
+ no_sim_power_screen_label.set_long_mode(lv.label.LONG.WRAP)
+ no_sim_power_screen_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ no_sim_power_screen_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+ no_sim_power_screen_comfirm = lv.img(no_sim_power_screen)
+ no_sim_power_screen_comfirm.set_size(176, 46)
+ no_sim_power_screen_comfirm.set_pos(32, 190)
+ no_sim_power_screen_comfirm.set_src("E:/static/off_icon.png")
+ no_sim_power_screen_comfirm.add_flag(lv.obj.FLAG.CLICKABLE)
+ no_sim_power_screen_comfirm.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ poweroff_confirm_label = lv.label(no_sim_power_screen_comfirm)
+ poweroff_confirm_label.set_text("确定")
+ poweroff_confirm_label.align(lv.ALIGN.CENTER, 0, 5)
+ poweroff_confirm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ no_sim_power_screen_cancel = lv.img(no_sim_power_screen)
+ no_sim_power_screen_cancel.set_size(176, 46)
+ no_sim_power_screen_cancel.set_pos(32, 265)
+ no_sim_power_screen_cancel.set_src("E:/static/cancel_icon.png")
+ no_sim_power_screen_cancel.add_flag(lv.obj.FLAG.CLICKABLE)
+ no_sim_power_screen_cancel.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ poweroff_return_label = lv.label(no_sim_power_screen_cancel)
+ poweroff_return_label.set_text("取消")
+ poweroff_return_label.align(lv.ALIGN.CENTER, 0, 5)
+ poweroff_return_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ no_sim_power_screen_cancel.set_ext_click_area(20)
+
+ self.meta = no_sim_power_screen
+ no_sim_power_screen_comfirm.add_event_cb(lambda e: EventMesh.callback_wrapper(self.confirm(e)),
+ lv.EVENT.CLICKED, None)
+
+ no_sim_power_screen_cancel.add_event_cb(lambda e: EventMesh.callback_wrapper(self.cancel(e)),
+ lv.EVENT.CLICKED, None)
+
+ def confirm(self,e):
+ EventMesh.publish("load_screen", {"screen": "poweroff_comfirm"})
+
+ def cancel(self,e):
+ EventMesh.publish("return_prev_screen")
+
+ def done_left_to_right(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_right_to_left(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_bottom_to_top(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_top_to_bottom(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ # EventMesh.publish("return_prev_screen")
+
+ def btn1_press(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("return_prev_screen")
+
+no_sim_auto_screen = None
+no_sim_auto_screen_title = None
+no_sim_auto_screen_label =None
+no_sim_auto_screen_comfirm =None
+no_sim_autor_screen_cancel = None
+no_sim_auto_screen_img = None
+no_sim_confirm_label = None
+
+#未插卡,长按关机
+class NoSimAutoScreen(Screen):#无sim卡是否关机
+ NAME = "no_sim_auto_screen"
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.meta_type = "popup"
+ self.timer = osTimer()
+ self.count = 0
+
+ def initialization(self):
+ global no_sim_auto_screen,no_sim_confirm_label,no_sim_cancel_label,no_sim_auto_screen_img,no_sim_auto_screen_title,no_sim_auto_screen_comfirm,no_sim_auto_screen_cancel,no_sim_auto_screen_label
+ if no_sim_auto_screen == None :
+ no_sim_auto_screen = lv.obj()
+ print("no_sim_power_screen")
+ no_sim_auto_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ no_sim_auto_screen_title = lv.label(no_sim_auto_screen)
+ no_sim_auto_screen_title.set_pos(0, 10)
+ no_sim_auto_screen_title.set_size(240, 50)
+ no_sim_auto_screen_title.set_text("无SIM卡,无操作30s\n后自动关机")
+ no_sim_auto_screen_title.set_long_mode(lv.label.LONG.WRAP)
+ no_sim_auto_screen_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ no_sim_auto_screen_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ no_sim_auto_screen_img = lv.img(no_sim_auto_screen)
+ no_sim_auto_screen_img.set_pos(100, 70)
+ no_sim_auto_screen_img.set_size(61, 61)
+ no_sim_auto_screen_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ no_sim_auto_screen_img.set_src("E:/static/poweroff_icon.png")
+
+
+ no_sim_auto_screen_label = lv.label(no_sim_auto_screen)
+ no_sim_auto_screen_label.set_pos(0, 150)
+ no_sim_auto_screen_label.set_size(240, 40)
+ no_sim_auto_screen_label.set_text("是否关机?")
+ no_sim_auto_screen_label.set_long_mode(lv.label.LONG.WRAP)
+ no_sim_auto_screen_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ no_sim_auto_screen_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+ no_sim_auto_screen_comfirm = lv.img(no_sim_auto_screen)
+ no_sim_auto_screen_comfirm.set_size(176, 46)
+ no_sim_auto_screen_comfirm.set_pos(32, 190)
+ no_sim_auto_screen_comfirm.set_src("E:/static/off_icon.png")
+ no_sim_auto_screen_comfirm.add_flag(lv.obj.FLAG.CLICKABLE)
+ no_sim_auto_screen_comfirm.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ no_sim_confirm_label = lv.label(no_sim_auto_screen_comfirm)
+ no_sim_confirm_label.set_text("确定")
+ no_sim_confirm_label.align(lv.ALIGN.CENTER, 0, 5)
+ no_sim_confirm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ no_sim_auto_screen_cancel = lv.img(no_sim_auto_screen)
+ no_sim_auto_screen_cancel.set_size(176, 46)
+ no_sim_auto_screen_cancel.set_pos(32, 265)
+ no_sim_auto_screen_cancel.set_src("E:/static/cancel_icon.png")
+ no_sim_auto_screen_cancel.add_flag(lv.obj.FLAG.CLICKABLE)
+ no_sim_auto_screen_cancel.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ no_sim_cancel_label = lv.label(no_sim_auto_screen_cancel)
+ no_sim_cancel_label.set_text("取消")
+ no_sim_cancel_label.align(lv.ALIGN.CENTER, 0, 5)
+ no_sim_cancel_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ no_sim_auto_screen_cancel.set_ext_click_area(20)
+
+ self.meta = no_sim_auto_screen
+ no_sim_auto_screen_comfirm.add_event_cb(lambda e: EventMesh.callback_wrapper(self.confirm(e)),
+ lv.EVENT.CLICKED, None)
+
+ no_sim_auto_screen_cancel.add_event_cb(lambda e: EventMesh.callback_wrapper(self.cancel(e)),
+ lv.EVENT.CLICKED, None)
+ self.timer.start(1*1000,1,self.fun)
+ self.count = 0
+ def fun(self,*argc):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ self.count+=1
+ if self.count > 30:
+ self.count = 0
+ self.timer.stop()
+ EventMesh.publish("load_screen", {"screen": "poweroff_comfirm"})
+
+
+ def Close(self):
+ self.count = 0
+ self.timer.stop()
+
+ def confirm(self,e):
+ EventMesh.publish("load_screen", {"screen": "poweroff_comfirm"})
+
+ def cancel(self,e):
+ EventMesh.publish("return_prev_screen")
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("return_prev_screen")
+
+
+
+
+dialing_popup_screen = None
+dialing_popup_img = None
+dialing_popup_name = None
+dialing_popup_hangup_imgbtn = None
+class DialingNoPlayPopupScreen(Screen):#正在拨号中...未打出
+ NAME = "dialing_noplay_popup"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.meta_type = "popup"
+ self.timer1 = osTimer()
+ self.time_count = 0
+ self.timer2 = osTimer()
+ self.call_log = {}
+ self.call_log_value = {}
+ self.read_call_log = {}
+ self.number_tmp = {}
+ self.CALL_LOG_MAX = CALL_LOG_MAX
+ EventMesh.subscribe("voice_call_end",self.voice_call_end)
+
+
+ def initialization(self):
+ EventMesh.publish("set_UI_high_priority", 1)
+ global dialing_popup_screen,dialing_popup_img,dialing_popup_name ,dialing_popup_call,dialing_popup_hangup_imgbtn
+ if dialing_popup_screen == None:
+ dialing_popup_screen = lv.obj()
+ print("dialing_popup_screen")
+ dialing_popup_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ dialing_popup_img = lv.img(dialing_popup_screen)
+ dialing_popup_img.set_pos(80, 20)
+ dialing_popup_img.set_size(64, 64)
+ dialing_popup_img.set_src("E:/static/IMAGE_NOTICE_CALL.png")
+ dialing_popup_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ dialing_popup_name = lv.label(dialing_popup_screen)
+ dialing_popup_name.set_pos(0, 120)
+ dialing_popup_name.set_size(240, 50)
+ dialing_popup_name.set_text(" ")
+ dialing_popup_name.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ dialing_popup_name.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ dialing_popup_call = lv.label(dialing_popup_screen)
+ dialing_popup_call.set_pos(0, 180)
+ dialing_popup_call.set_size(240, 50)
+ dialing_popup_call.set_text("正在拨号中")
+ dialing_popup_call.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ dialing_popup_call.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ dialing_popup_hangup_imgbtn = lv.img(dialing_popup_screen)
+ dialing_popup_hangup_imgbtn.set_size(64, 64)
+ dialing_popup_hangup_imgbtn.set_src("E:/static/hang_up.png")
+ dialing_popup_hangup_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
+ dialing_popup_hangup_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ dialing_popup_hangup_imgbtn.set_pos(80, 230)
+
+ dialing_popup_hangup_label_imgbtn = lv.label(dialing_popup_screen)
+ dialing_popup_hangup_label_imgbtn.set_pos(40, 200)
+ dialing_popup_hangup_label_imgbtn.set_size(160, 120)
+ dialing_popup_hangup_label_imgbtn.set_text(" ")
+ dialing_popup_hangup_label_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
+
+ dialing_popup_hangup_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hangup(e)),
+ lv.EVENT.CLICKED, None)
+ dialing_popup_hangup_label_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hangup(e)),
+ lv.EVENT.CLICKED, None)
+ self.meta = dialing_popup_screen
+ if dialing_popup_name != None:
+ name = EventMesh.publish("get_phonename")#获取拨打电话名称
+ dialing_popup_name.set_text(name)#名称
+
+ def post_processor_after_initialization(self):
+ self.time_count = 0
+ #获取字符串
+ name = EventMesh.publish("get_phonename")#获取拨打电话名称
+ content = EventMesh.publish("get_phonenum")#获取电话号码
+ time = EventMesh.publish("screen_get_time")#获取系统时间
+
+ # ["15692025051","2","12:59","哥gdh符合双方和开发商开发好看的思考"],
+ # 格式:{"电话号码":{"timesec":'时间戳',"number":'电话号码',"name":'名字',"time":'时间',"count":'通话次数'}}
+ # dialing_content.set_text(content)#电话号码
+ num = 0
+
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ # print("time_tmp:{}".format(time_tmp))
+ read_call_log_tmp = EventMesh.publish("get_call_log_list")
+ check_json = read_call_log_tmp[0]
+
+ if check_json == True:
+ self.read_call_log = read_call_log_tmp[1]
+ b = content in self.read_call_log.keys()#查找key中是否包含content电话号码 True 包含在里面 False不包含在里面
+ if b == True:#查找是否有相同的电话号码 有就直接读出来的次数上加一 没有则从1开始加起
+ number_tmp = {}
+ number_tmp = self.read_call_log[content] #通话次数加一
+ num_tmp_t = number_tmp["count"]
+ # print("number_tmp:{} self.read_call_log.value:{}".format(number_tmp,self.read_call_log.values()))
+ else :
+ num_tmp_t = 0
+ num = num_tmp_t
+ else:
+ num = 0 #通话次数
+
+ sort_tmp = {}
+ sort_tmp = self.read_call_log.values()
+ sort_new = {}
+ sort_new = sorted(sort_tmp, key = lambda i: i['timesec'],reverse = True)#按照时间戳进行排序 去掉最旧的一次数据如果满了五十条
+
+ i = 0
+ # 49 50
+ if len(self.read_call_log) >= self.CALL_LOG_MAX:
+ for sort_new_tmp in sort_new: #字典 key value
+ i+=1 # 1
+ if i >= self.CALL_LOG_MAX:#大于50条把最后一条删除掉只保留前面50调最新的数据
+ key_tmp = sort_new_tmp["number"]
+ del self.read_call_log[key_tmp]
+ tmp = {}
+ tmp["count"]= num+1 #通话次数
+ tmp["time"]= "{}:{}".format("%02d"%(time[0][0]),"%02d"%(time[0][1]))#通湖时间
+ tmp["name"]= name #名称
+ tmp["timesec"]= time_tmp #时间戳
+ tmp["number"] = content
+
+ self.read_call_log[content] = tmp
+ with open("/ext/static/storage_file/Call_log.json","w",encoding="utf-8") as fd:
+ ujson.dump(self.read_call_log,fd)
+ print("创建通话记录")
+ EventMesh.publish("set_call_log_list", [1,self.read_call_log])
+ EventMesh.publish("call_log_update_show_list")
+ self.timer1.start(1000, 1, self.timeout_hangup)
+ self.timer2.start(2000, 0, self.timeout_call)
+
+ def timeout_call(self,e):
+ phone_num = EventMesh.publish("get_phonenum")
+ voiceCall.callStart(phone_num)
+
+ def timeout_hangup(self,e):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ self.time_count+=1
+ if self.time_count >= 5:#5s内没有打通则不在继续拨打关闭
+ self.time_count = 0
+ EventMesh.publish("set_UI_high_priority", 0)
+ EventMesh.publish("set_sos_info_call")
+ EventMesh.publish("load_screen", {"screen": "dial_no_connect_popup"})
+ voiceCall.callEnd()
+
+ def hangup(self,e):
+ print("hangup_end")
+ EventMesh.publish("set_UI_high_priority", 0)
+
+ sos_flag = EventMesh.publish("get_sos_flag")
+ if sos_flag == 1:
+ EventMesh.publish("close_sos_timer")
+ EventMesh.publish("set_sos_flag",0)
+ EventMesh.publish("set_sos_num",0)
+ EventMesh.publish("set_hangup_mode",0)
+ EventMesh.publish("set_interrup_incall",0)
+ EventMesh.publish("return_prev_screen")
+ voiceCall.callEnd()
+
+ def voice_call_end(self,event,msg):
+ voiceCall.callEnd()
+ pass
+
+ def Close(self):
+ self.timer1.stop()
+ self.timer2.stop()
+
+ def done_return(self):
+ pass
+ #EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn1_release(self):
+ pass
+ #EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn8_press(self):
+ flag = EventMesh.publish("get_lcd_state")
+ if flag == 1:
+ EventMesh.publish(constants.EVENT.SYSTEM_SLEEP)
+ else:
+ EventMesh.publish(constants.EVENT.SYSTEM_UP)
+
+dial_no_connect_popup = None
+dialing_connect_call = None
+class DialNoconnectPopupScreen(Screen):#你所拨打的电话暂时无法接通
+ NAME = "dial_no_connect_popup"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.meta_type = "popup"
+ self.timer = osTimer()
+ self.time_count = 0
+
+ def initialization(self):
+ global dial_no_connect_popup,dialing_connect_call
+ if dial_no_connect_popup == None:
+ dial_no_connect_popup = lv.obj()
+ print("dial_no_connect_popup")
+ dial_no_connect_popup.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ dialing_connect_call = lv.label(dial_no_connect_popup)
+ dialing_connect_call.set_pos(0, 110)
+ dialing_connect_call.set_size(240, 150)
+ dialing_connect_call.set_text("你好,你所拨打的\n电话暂时无法接\n通,请稍后再拨")
+ dialing_connect_call.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ dialing_connect_call.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ self.meta = dial_no_connect_popup
+
+ def post_processor_after_initialization(self):
+ self.time_count = 0
+ self.timer.start(1000, 1, self.timeout_hangup)
+
+ def timeout_hangup(self,e):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ self.time_count+=1
+ if self.time_count >= 5:
+ self.time_count = 0
+ EventMesh.publish("return_prev_screen")
+
+ def Close(self):
+ # EventMesh.publish("set_sos_info_call")
+ self.timer.stop()
+
+ def done_left_to_right(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_right_to_left(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_bottom_to_top(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_top_to_bottom(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("return_prev_screen")
+
+charge_full_screen = None
+charge_full_screen_title = None
+class chargefullScreen(Screen):#充电已满弹窗提示
+ NAME = "charge_full"
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.meta_type = "popup"
+ self.timer = osTimer()
+ self.count = 0
+ def initialization(self):
+ global charge_full_screen,charge_full_screen_title
+ if charge_full_screen == None :
+ charge_full_screen = lv.obj()
+ print("charge_full_screen")
+ charge_full_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+ charge_full_screen_title = lv.label(charge_full_screen)
+ charge_full_screen_title.set_pos(0, 150)
+ charge_full_screen_title.set_size(240, 40)
+ charge_full_screen_title.set_text("充电已满")
+ charge_full_screen_title.set_long_mode(lv.label.LONG.WRAP)
+ charge_full_screen_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ charge_full_screen_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ self.meta = charge_full_screen
+ self.count = 0
+ self.timer.start(1*1000,1,self.fun)
+
+ def Close(self):
+ self.count = 0
+ self.timer.stop()
+ pass
+
+ def fun(self,*argc):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ self.count+=1
+ if self.count > 2*60:
+ self.count = 0
+ self.timer.stop()
+ #EventMesh.publish("return_prev_screen")
+
+ def done_click(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("return_prev_screen")
+
+
+
+
+message_popup_screen = None
+message_popup_title = None
+#信息弹窗
+class NewMessageScreen(Screen):
+ NAME = "message_popup"
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.meta_type = "popup"
+
+ def initialization(self):
+ global message_popup_screen,message_popup_title
+ if message_popup_screen == None :
+ message_popup_screen = lv.obj()
+ print("message_popup_screen")
+ message_popup_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ message_popup_title = lv.label(message_popup_screen)
+ message_popup_title.set_pos(0, 150)
+ message_popup_title.set_size(240, 40)
+ message_popup_title.set_text("你有新的信息")
+ message_popup_title.set_long_mode(lv.label.LONG.WRAP)
+ message_popup_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ message_popup_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ self.meta = message_popup_screen
+ EventMesh.publish("set_sms_clear_all_data",10)
+
+
+
+
+ def done_left_to_right(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_right_to_left(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_bottom_to_top(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_top_to_bottom(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+ def done_click(self):
+ EventMesh.publish("load_screen", {"screen": "popup"})
+
+ def btn1_release(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn8_press(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+remove_message_popup_screen = None
+remove_message_popup_title = None
+#信息弹窗
+class RemoveMessageScreen(Screen):#删除短信弹窗框
+ NAME = "remove_message_popup"
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.meta_type = "popup"
+ self.timer = osTimer()
+
+ def initialization(self):
+ global remove_message_popup_screen,remove_message_popup_title
+ if remove_message_popup_screen == None :
+ remove_message_popup_screen = lv.obj()
+ print("message_popup_screen")
+ remove_message_popup_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ message_popup_title = lv.label(remove_message_popup_screen)
+ message_popup_title.set_pos(0, 150)
+ message_popup_title.set_size(240, 50)
+ message_popup_title.set_text("正在删除中...\n请稍候")
+ message_popup_title.set_long_mode(lv.label.LONG.WRAP)
+ message_popup_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ message_popup_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ self.meta = remove_message_popup_screen
+ self.timer.start(1000,1,self.timer_cb)
+ def timer_cb(self,*argc):
+ msg_nums = sms.getMsgNums()
+ # print("timer_cb remove!!!!!!!!!",msg_nums)
+ if msg_nums == 0:
+ self.timer.stop()
+ EventMesh.publish("load_screen", {"screen": "popup"})
+
+ def Close(self):
+ self.timer.stop()
+
+ def done_left_to_right(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_right_to_left(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_bottom_to_top(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_top_to_bottom(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+ def done_click(self):
+ EventMesh.publish("load_screen", {"screen": "popup"})
+
+ def btn1_release(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn8_press(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+message_full_screen = None
+message_full_label = None
+message_full_confirm = None
+message_full_cancel = None
+#信息弹窗
+class MessageFullScreen(Screen):
+ NAME = "message_full"
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.meta_type = "popup"
+ EventMesh.subscribe("remove_all_sms_cb",self.remove_all_sms_cb)
+ def initialization(self):
+ global message_full_screen,message_full_label,message_full_confirm,message_full_cancel
+ if message_full_screen == None :
+ message_full_screen = lv.obj()
+ print("message_full_screen")
+ message_full_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ message_full_label = lv.label(message_full_screen)
+ message_full_label.set_pos(0, 100)
+ message_full_label.set_size(240, 50)
+ message_full_label.set_text("信息已满,是否清除所有?")
+ message_full_label.set_long_mode(lv.label.LONG.WRAP)
+ message_full_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ message_full_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ message_full_confirm = lv.label(message_full_screen)
+ message_full_confirm.set_text("确认")
+ message_full_confirm.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ message_full_confirm.set_size(120, 60)
+ message_full_confirm.set_pos(0,180)
+ message_full_confirm.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ message_full_confirm.add_flag(lv.obj.FLAG.CLICKABLE)
+ message_full_confirm.set_ext_click_area(20)
+
+ message_full_cancel = lv.label(message_full_screen)
+ message_full_cancel.set_text("取消")
+ message_full_cancel.set_size(120, 60)
+ message_full_cancel.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ message_full_cancel.set_pos(120,180)
+ message_full_cancel.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ message_full_cancel.add_flag(lv.obj.FLAG.CLICKABLE)
+ message_full_cancel.set_ext_click_area(20)
+ self.meta = message_full_screen
+
+ message_full_confirm.add_event_cb(lambda e: EventMesh.callback_wrapper(self.confirm(e)),lv.EVENT.CLICKED, None)
+ message_full_cancel.add_event_cb(lambda e: EventMesh.callback_wrapper(self.concel(e)),lv.EVENT.CLICKED, None)
+
+ def remove_all_sms_cb(self, event, msg):
+ sms.deleteMsg(1,4)
+
+ def confirm(self, e):
+ print("sms confirm!!!!!!!!")
+ # self.timer.start(2*1000,0,self.clear_data)
+ EventMesh.publish("load_screen", {"screen": "remove_message_popup"})
+ EventMesh.publish_async("remove_all_sms_cb","",1*1024)
+
+
+ def concel(self, e):
+ EventMesh.publish("return_prev_screen")
+
+ def done_left_to_right(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_right_to_left(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_bottom_to_top(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_top_to_bottom(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+############短信###############################
+MSG_FLAG = 0
+MSG_MAX = 5 #最大显示短信内容条数
+def msg_cb(args):
+ index = args[1]
+ storage = args[2]
+ print("index:{}".format(index))
+ sms_data = sms.getSaveLoc()
+ sms_max = sms_data[0][2]
+ if index != -1:
+ tmp = sms.searchTextMsg(index)
+ detail = tmp[1]#内容
+ print("msg_cb:detail {}".format,detail)
+ if detail.find("SETIP:") != -1:#寻找是否有这个字符串
+ tmp_test = detail.split("SETIP:")[1]
+ if tmp_test.find(":") != -1:
+ new_ip = tmp_test.split(':')[0]
+ # print("tmp_test:{} new_ip:{}".format(tmp_test,new_ip))
+ new_com = tmp_test.split(':')[1]
+ # new_md5 = detail.split(':')[3]
+ if len(new_ip) > 0 and len(new_com) > 0:
+ EventMesh.publish("set_new_ip", [new_ip,new_com,tmp[0]])#设置关机时间
+ # EventMesh.publish("set_new_ip", [new_ip,new_com,new_md5])#设置关机时间
+
+ if index >= sms_max-1:
+ EventMesh.publish("load_screen", {"screen": "message_full"})
+ else:
+ EventMesh.publish("load_screen", {"screen": "message_popup"})
+
+sms.setCallback(msg_cb)
+style_sms_bg_btn = lv.style_t()
+style_sms_bg_btn.init()
+style_sms_bg_btn.set_radius(5)
+style_sms_bg_btn.set_bg_color(lv.color_make(0xff, 0xff, 0xff))
+style_sms_bg_btn.set_bg_grad_color(lv.color_make(0xff, 0xff, 0xff))
+style_sms_bg_btn.set_bg_opa(255)
+style_sms_bg_btn.set_border_color(lv.color_make(0xff, 0xff, 0xff))
+style_sms_bg_btn.set_border_opa(255)
+style_sms_bg_btn.set_border_width(0)
+style_sms_bg_btn.set_pad_left(0)
+style_sms_bg_btn.set_pad_right(0)
+style_sms_bg_btn.set_pad_top(0)
+style_sms_bg_btn.set_pad_bottom(0)
+
+
+msg_list_screen = None
+msg_top_title = None
+msg_cont_detail = None
+msg_list_t = None
+msg_list_t_done_img = None
+no_msg_text = None
+msg_cont_list_screen = None
+
+class PopupScreen(Screen):
+ NAME = "popup"
+
+ def __init__(self):
+ super().__init__()
+ # -------------------------------------------popup_menu screen----------------------------------------------------------
+ self.meta = None
+ self.msg_detail = {}
+ self.msg_nums = 0
+ self.msg_nums_old = 0
+ self.sms_detail_list = None
+ self.sms_detail_list_dict = []
+ self.sms_data = [] #最新短信内容
+ self.is_sliding =0
+ def post_processor_before_initialization(self):
+ pass
+ # self.msg_nums = sms.getMsgNums() #获取短信条数
+ # if self.msg_nums_old != self.msg_nums:
+ # self.sms_data = []
+ # self.msg_nums_old = self.msg_nums
+
+ def initialization(self):
+ self.is_sliding = 0
+ global msg_list_screen,msg_top_title,msg_cont_detail,msg_list_t,msg_list_t_done_img,no_msg_text,msg_cont_list_screen
+ print("PopupScreen:initialization1")
+ if msg_list_screen == None :
+ msg_list_screen = lv.obj()
+ print("msg_list_screen")
+ msg_list_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ msg_list_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+
+ msg_top_title = lv.label(msg_list_screen)
+ msg_top_title.set_pos(0, 10)
+ msg_top_title.set_size(240, 40)
+ msg_top_title.set_text("信息")
+ msg_top_title.set_long_mode(lv.label.LONG.WRAP)
+ msg_top_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ msg_top_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+ msg_cont_list_screen = lv.obj(msg_list_screen)
+ msg_cont_list_screen.set_pos(0, 50)
+ msg_cont_list_screen.set_size(240, 270)
+ msg_cont_list_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ msg_cont_list_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+ msg_list_t_done_img = lv.img(msg_cont_list_screen)
+ msg_list_t_done_img.set_pos(53, 20)
+ msg_list_t_done_img.set_size(134, 117)
+ msg_list_t_done_img.set_src("E:/static/IMAGE_NOTICE_NONE.png")
+ msg_list_t_done_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ no_msg_text = lv.label(msg_cont_list_screen)
+ no_msg_text.set_pos(0, 210)
+ no_msg_text.set_size(240, 40)
+ no_msg_text.set_text("暂无信息")
+ no_msg_text.set_long_mode(lv.label.LONG.WRAP)
+ no_msg_text.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ no_msg_text.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ self.sms_detail_list = lv.obj(msg_cont_list_screen)
+ self.sms_detail_list.set_pos(0, 0)
+ self.sms_detail_list.set_size(230, 271)
+ self.sms_detail_list.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ self.sms_detail_list.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+ for i in range(MSG_MAX):
+ msg_btn = lv.btn(self.sms_detail_list)
+ msg_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.sms_cb(e)),
+ lv.EVENT.CLICKED, None)
+ msg_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.sms_cb(e)),
+ lv.EVENT.PRESSING, None)
+ msg_btn.add_flag(lv.obj.FLAG.HIDDEN)
+ _btn_label2 = lv.label(msg_btn)
+ _btn_label3 = lv.label(msg_btn)
+ _btn_label4 = lv.label(msg_btn)
+ _btn_label5 = lv.label(msg_btn)
+ msg_btn.add_style(style_sms_bg_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+ _btn_label4.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+ _btn_label5.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ self.sms_detail_list_dict.append({"msg_btn":msg_btn,"_btn_label2":_btn_label2,"_btn_label3":_btn_label3,
+ "_btn_label4":_btn_label4,"_btn_label5":_btn_label5})
+ self.meta = msg_list_screen
+
+
+ self.msg_nums = sms.getMsgNums()
+ if self.msg_nums_old != self.msg_nums:
+ self.sms_data = []
+ self.msg_nums_old = self.msg_nums
+
+ self.btn_create(1)
+ print("PopupScreen:initialization2")
+
+ # def sms_create_list(self,event,msg):
+ # self.msg_nums = sms.getMsgNums()
+ # self.btn_create(1)
+
+ def sms_deal_phone_number(self,args):
+ data=enumerate(args)
+ data_str1=""
+ data_str2=""
+ data_str3=""
+ for index,value in data:
+ if index % 2 == 0:
+ data_str1=data_str1+value
+ else:
+ data_str2=data_str2+value
+ for i in range(0,len(data_str1)):
+ data_str3=data_str3+data_str2[i]
+ data_str3=data_str3+data_str1[i]
+ return data_str3
+ def sms_get_message_info(self,index):
+ """
+ :param index :短信索引值
+ :tyoe index :整形
+
+ :return :元组类型
+ 元组内容:
+ (message_ref,message_total_num,message_seq,sub_message_data,pdu_tye,sub_message_len)
+
+ :message_ref :短信参考标识,同一个标识表明为同一条短信
+ :message_total_num :此条长短信总条数
+ :message_seq :此条短信在长短信中的序号
+ :sub_message_data :词条短信的内容
+ :pdu_tye :PDU类型,bit 6标记是否包含用户报文头,长短信需要
+ :sub_message_len :此条短信内容长度
+
+ """
+ message0=sms.searchPduMsg(index)
+ #print("sms_get_message_info:message0:{}".format(message0))
+ if message0 == -1:
+ return -1
+
+ sca_num = int(message0[0:2],16) - 1
+ data_len = 2
+ addr_type= message0[data_len:data_len+1*2]
+ data_len = data_len+1*2
+
+ sca = message0[data_len:data_len+sca_num*2]
+ # 电话号码高低位需要转换
+ sca = self.sms_deal_phone_number(sca)
+
+ # if sca_num % 2 == 1:
+ # print("Get SCA phone {}".format(sca[:-1]))
+ # else:
+ # print("Get SCA phone {}".format(sca))
+
+ data_len = data_len+sca_num*2
+
+ pdu_tye = int(message0[data_len:data_len+1*2],16)
+ data_len = data_len+1*2
+
+ oa_num = int(message0[data_len:data_len+1*2],16)
+ data_len = data_len+1*2
+ oa_addr_type = message0[data_len:data_len+1*2]
+ data_len = data_len+1*2
+
+ if oa_num % 2 == 1:
+ oa_num_t = int((oa_num + 1)/2)
+ else:
+ oa_num_t = int((oa_num )/2)
+
+ oa = message0[data_len:data_len+oa_num_t*2]
+ # 电话号码高低位需要转换
+ oa = self.sms_deal_phone_number(oa)
+
+ # if oa_num % 2 == 1:
+ # print("Get OA phone {}".format(oa[:-1]))
+ # else:
+ # print("get OA phone {}".format(oa))
+
+ data_len = data_len+oa_num_t*2
+ pid = message0[data_len:data_len+1*2]
+
+ data_len = data_len+1*2
+ dcs = message0[data_len:data_len+1*2]
+ data_len = data_len+1*2
+ scts = message0[data_len:data_len+7*2]
+ data_len = data_len+7*2
+ sub_message_len = int(message0[data_len:data_len+1*2],16)
+ data_len = data_len+1*2
+ sub_message_head = message0[data_len:data_len+6*2]
+ data_len = data_len+6*2
+
+ # 或短信用户数据
+ sub_message_data = message0[data_len:data_len+sub_message_len*2]
+
+ #长短信
+ if ((pdu_tye & 0x40 ) >> 6) == 1:
+ #长短信,处理长短信用户报文头
+ message_ref = int(sub_message_head[6:8],16)
+ message_total_num = int(sub_message_head[8:10],16)
+ message_seq = int(sub_message_head[10:12],16)
+ return [message_ref,message_total_num,message_seq,pdu_tye,sub_message_len,message0]
+ else:
+ # 短短信
+ return [0,1,1,pdu_tye,sub_message_len,message0]
+
+ def btn_create(self,msg):
+ EventMesh.publish("publish_message_event_ui",{"func":self.btn_create_screen,"data":msg})
+
+ def btn_create_screen(self,msg):
+ global msg_list_screen,msg_top_title,msg_cont_detail,msg_list_t,msg_list_t_done_img,no_msg_text,msg_cont_list_screen
+ count = 0
+ j = 0
+ print("self.msg_nums:{}".format(self.msg_nums))
+ if self.msg_nums > 0 :
+
+
+ #隐藏短信控件,加提示信息
+ if msg_cont_list_screen != None:
+ msg_list_t_done_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ no_msg_text.clear_flag(lv.obj.FLAG.HIDDEN)
+ no_msg_text.set_text("正在加载···")
+ if self.sms_detail_list != None:
+ self.sms_detail_list.add_flag(lv.obj.FLAG.HIDDEN)
+ SMS_lis={}
+ SMS_lis_count = 0
+ #self.sms_data = [] #短信数组
+ if self.sms_data == [] :
+ for i in range(self.msg_nums):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ message=self.sms_get_message_info(self.msg_nums-i-1)
+ if message == -1:
+ break
+ #print("self.msg_nums:{} message:{} {} {}".format(self.msg_nums-i-1,message[0],message[1],message[2]))
+ #message:[253, 3, 1, 100, 140, '751F4EA776EE524D6D4']
+ if message[1]>1 :#长短信
+ if message[0] in SMS_lis:#存在列表
+ SMS_lis[message[0]].append(message)
+
+ else :#列表是新的
+ SMS_lis[message[0]] = [message]#新增列表
+ #print("SMS_lis:{}".format(SMS_lis))
+ #SMS_lis[message[0]].append(message)#新增列表数据
+ if len(SMS_lis[message[0]]) == message[1]:#存满一条
+ SMS_lis_tmp = SMS_lis[message[0]]
+ data = ""
+ message_pdu = []
+ for k in range(len(SMS_lis_tmp)):
+ for j in range(len(SMS_lis_tmp)): #排序
+ if SMS_lis_tmp[j][2] == k+1:
+ message_pdu = sms.decodePdu(SMS_lis_tmp[j][5],20)
+ if(message_pdu!=-1):
+ data += message_pdu[1]
+ break
+ #print("data:{}".format(data))
+ data_tmp = []
+ data_tmp.append(message_pdu[0])
+ data_tmp.append(data)
+ self.sms_data.append(data_tmp)
+ SMS_lis_count += 1
+ if(SMS_lis_count >= MSG_MAX):
+ break
+ else :
+ SMS_lis_count += 1
+ message_pdu = sms.decodePdu(message[5],20)
+ data = message_pdu[1]
+ data_tmp = []
+ data_tmp.append(message_pdu[0])
+ data_tmp.append(data)
+ self.sms_data.append(data_tmp)
+ print("data:{}".format(data))
+ if(SMS_lis_count >= MSG_MAX):
+ break
+ MSG_nums = len (self.sms_data)
+ for i in range(MSG_MAX):
+ if i >= MSG_nums :
+ self.sms_detail_list_dict[i]["msg_btn"].add_flag(lv.obj.FLAG.HIDDEN)
+ continue
+ tmp = self.sms_data[i]
+ if tmp != -1:
+ #msg_btn = lv.btn(self.sms_detail_list)
+ self.sms_detail_list_dict[i]["msg_btn"].set_size(230,65)
+ self.sms_detail_list_dict[i]["msg_btn"].set_pos(0,67*count)
+ #self.sms_detail_list_dict[i]["msg_btn"].add_style(style_sms_bg_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+ # self.sms_detail_list_dict[i]["msg_btn"].add_event_cb(lambda e: EventMesh.callback_wrapper(self.sms_cb(e)),
+ # lv.EVENT.CLICKED, None)
+
+ title = tmp[0]
+ # print("title:{}".format(title))
+ #_btn_label2 = lv.label(msg_btn)
+ self.sms_detail_list_dict[i]["_btn_label2"].set_pos(0, 0)
+ self.sms_detail_list_dict[i]["_btn_label2"].set_size(0, 0)
+ self.sms_detail_list_dict[i]["_btn_label2"].set_text(title)
+ # _btn_label2.set_long_mode(lv.label.LONG.DOT)
+ # _btn_label2.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+ #
+ detail = tmp[1]
+ #_btn_label3 = lv.label(msg_btn)
+ self.sms_detail_list_dict[i]["_btn_label3"].set_pos(0, 0)
+ self.sms_detail_list_dict[i]["_btn_label3"].set_size(0, 0)
+ self.sms_detail_list_dict[i]["_btn_label3"].set_text(detail)
+ # _btn_label3.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ detail1 = tmp[1]
+ #_btn_label4 = lv.label(msg_btn)
+ self.sms_detail_list_dict[i]["_btn_label4"].set_pos(0, 34)
+ self.sms_detail_list_dict[i]["_btn_label4"].set_size(230, 28)
+ self.sms_detail_list_dict[i]["_btn_label4"].set_text(detail1)
+ self.sms_detail_list_dict[i]["_btn_label4"].set_long_mode(lv.label.LONG.DOT)
+ #self.sms_detail_list_dict[i]["_btn_label4"].add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ title1 = tmp[0]
+ #_btn_label5 = lv.label(msg_btn)
+ self.sms_detail_list_dict[i]["_btn_label5"].set_pos(0, 5)
+ self.sms_detail_list_dict[i]["_btn_label5"].set_size(230, 28)
+ self.sms_detail_list_dict[i]["_btn_label5"].set_text(title1)
+ self.sms_detail_list_dict[i]["_btn_label5"].set_long_mode(lv.label.LONG.DOT)
+ #self.sms_detail_list_dict[i]["_btn_label5"].add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ self.sms_detail_list_dict[i]["msg_btn"].clear_flag(lv.obj.FLAG.HIDDEN)
+ #if msg == 1:
+ #self.sms_detail_list_dict[i]["msg_btn"].scroll_to_view(lv.ANIM.OFF)
+
+ count = count + 1
+ else :
+ self.sms_detail_list_dict[i]["msg_btn"].add_flag(lv.obj.FLAG.HIDDEN)
+ #显示控件
+ if msg_list_t_done_img != None:
+ msg_list_t_done_img.add_flag(lv.obj.FLAG.HIDDEN)
+ no_msg_text.add_flag(lv.obj.FLAG.HIDDEN)
+ self.sms_detail_list.clear_flag(lv.obj.FLAG.HIDDEN)
+ else:
+ if msg_cont_list_screen != None:
+ msg_list_t_done_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ no_msg_text.clear_flag(lv.obj.FLAG.HIDDEN)
+ no_msg_text.set_text("暂无信息")
+ if self.sms_detail_list != None:
+ self.sms_detail_list.add_flag(lv.obj.FLAG.HIDDEN)
+
+ def sms_cb(self,e):
+ code = e.get_code()
+ if code == lv.EVENT.PRESSING:
+ #print("PRESSING")
+ self.is_sliding += 1
+
+ elif code == lv.EVENT.CLICKED:
+ #utime.sleep_ms(10)
+ print("1self.is_sliding",self.is_sliding)
+ if self.is_sliding <= 5 and self.is_sliding != 0:#如果是在滑动中则不需要点击事件
+ print("tp test!!!!!!!!!!!!!!")
+ #上传标题和内容
+ _name = e.get_target().get_child(0).get_text()
+ EventMesh.publish("save_msg_name", _name)
+ content = e.get_target().get_child(1).get_text()
+ EventMesh.publish("save_msg_content", content)
+ #显示详细页面
+ EventMesh.publish("load_screen", {"screen": "msg_detail"})
+
+ self.is_sliding =0
+
+ def done_return(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+ def btn1_release(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+ def btn8_press(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
+
+msg_detail_screen = None
+msg_detail_title = None
+msg_detail_cont = None
+msg_detail_cont_obj = None
+class MsgDetailScreen(Screen):
+ NAME = "msg_detail"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+
+ self.name = ""
+ self.contetn = ""
+
+
+ def initialization(self):
+ global msg_detail_screen,msg_detail_title,msg_detail_cont,msg_detail_cont_obj
+ if msg_detail_screen == None:
+ msg_detail_screen = lv.obj()
+ print("msg_detail_screen")
+ msg_detail_screen.add_style(style_white_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ msg_detail_title = lv.label(msg_detail_screen)
+ msg_detail_title.set_pos(0, 10)
+ msg_detail_title.set_size(240, 35)
+ msg_detail_title.set_long_mode(lv.label.LONG.WRAP)
+ msg_detail_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ msg_detail_title.add_style(style_font_28_black_bg_gray, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ msg_detail_cont_obj = lv.obj(msg_detail_screen)
+ msg_detail_cont_obj.set_pos(0, 45)
+ msg_detail_cont_obj.set_size(240, 270)
+ msg_detail_cont_obj.add_style(style_white_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+ msg_detail_cont = lv.label(msg_detail_cont_obj)
+ msg_detail_cont.set_pos(0, 5)
+ msg_detail_cont.set_size(240, lv.SIZE.CONTENT)
+ msg_detail_cont.set_long_mode(lv.label.LONG.WRAP)
+ msg_detail_cont.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+ msg_detail_cont.add_style(style_font_28_black_bg_gray, lv.PART.MAIN | lv.STATE.DEFAULT)
+ self.meta = msg_detail_screen
+ #获取字符串
+
+
+ msg_detail_cont_obj.scroll_to(0, 0, lv.ANIM.OFF)
+
+ self.name = EventMesh.publish("get_msg_name")
+ self.content = EventMesh.publish("get_msg_content")
+ msg_detail_title.set_text(self.name)
+ # tmp_y=(len(self.content)//15+1)*28
+ # msg_detail_cont.set_size(240, tmp_y)
+ msg_detail_cont.set_text(self.content)
+
+
+ def post_processor_after_initialization(self):
+ size = msg_detail_cont.get_height()
+ print("size:",size)
+
+ def done_return(self):
+ EventMesh.publish("load_screen", {"screen": "popup"})
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("load_screen", {"screen": "popup"})
+
+
+
+# -------------------------------------------heartrate screen----------------------------------------------------------
+heartrate_screen = None
+heartrate_label = None
+heartrate_done_img = None
+heartrate_start_label = None
+heartrate_bpm_label = None
+heartrate_done_label = None
+heartrate_line_bg_img = None
+hr_line1 = None
+hr_line2 = None
+hr_line3 = None
+hr_line4 = None
+hr_line5 = None
+hr_line6 = None
+hr_line7 = None
+heartrate_reset_btn_img = None
+
+style_line_red = lv.style_t()
+style_line_red.init()
+style_line_red.set_line_width(10)
+style_line_red.set_line_color(lv.color_make(0xff, 0x00, 0x00))
+
+hr_line_points = [{"x":0,"y":0},{"x":0,"y":0}]
+
+class HeartrateScreen(Screen):
+ NAME = "heartrate"
+
+
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.timer = osTimer()
+ self.point = 0
+ self.heart_value = 0
+ EventMesh.subscribe("show_history_hr_data",self.show_history_hr_data)
+
+ def initialization(self):
+ global heartrate_screen,heartrate_label,heartrate_reset_btn_img,hr_line1,hr_line2,hr_line3,hr_line4,hr_line5,hr_line6,hr_line7,heartrate_line_bg_img,heartrate_done_img ,heartrate_start_label,heartrate_bpm_label ,heartrate_done_label
+ if heartrate_screen == None:
+ heartrate_screen = lv.obj()
+ print("heartrate_screen")
+ heartrate_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ heartrate_label = lv.label(heartrate_screen)
+ heartrate_label.set_pos(0, 20)
+ heartrate_label.set_size(240, 40)
+ heartrate_label.set_text("心率")
+ heartrate_label.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
+ heartrate_label.set_long_mode(lv.label.LONG.WRAP)
+ heartrate_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ heartrate_line_bg_img = lv.img(heartrate_screen)
+ heartrate_line_bg_img.set_pos(5, 60)
+ heartrate_line_bg_img.set_size(230, 120)
+ heartrate_line_bg_img.set_src("E:/static/hr_line_bg.png")
+
+
+ heartrate_done_img = lv.img(heartrate_screen)
+ heartrate_done_img.set_pos(20, 249)
+ heartrate_done_img.set_src("E:/static/hr_gif_03.png")
+
+ heartrate_reset_btn_img = lv.img(heartrate_screen)
+ heartrate_reset_btn_img.set_pos(0, 192)
+ heartrate_reset_btn_img.set_src("E:/static/reset_hr_btn.png")
+ heartrate_reset_btn_img.add_flag(lv.obj.FLAG.HIDDEN)
+ heartrate_reset_btn_img.add_flag(lv.obj.FLAG.CLICKABLE)
+
+ heartrate_start_label = lv.label(heartrate_screen)
+ heartrate_start_label.set_size(240,40)
+ heartrate_start_label.set_pos(0,200)
+ heartrate_start_label.set_text("正在测量中.")
+ heartrate_start_label.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
+ heartrate_start_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ heartrate_start_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+
+
+ hr_line1 = lv.line(heartrate_screen)
+ hr_line1.set_points(hr_line_points,2)
+ hr_line1.set_pos(25,60)
+ hr_line1.set_size(10,0)
+ hr_line1.add_style(style_line_red,0)
+
+ hr_line2 = lv.line(heartrate_screen)
+ hr_line2.set_points(hr_line_points,2)
+ hr_line2.set_pos(53,60)
+ hr_line2.set_size(10,0)
+ hr_line2.add_style(style_line_red,0)
+
+ hr_line3 = lv.line(heartrate_screen)
+ hr_line3.set_points(hr_line_points,2)
+ hr_line3.set_pos(80,60)
+ hr_line3.set_size(10,0)
+ hr_line3.add_style(style_line_red,0)
+
+ hr_line4 = lv.line(heartrate_screen)
+ hr_line4.set_points(hr_line_points,2)
+ hr_line4.set_pos(109,60)
+ hr_line4.set_size(10,0)
+ hr_line4.add_style(style_line_red,0)
+
+ hr_line5 = lv.line(heartrate_screen)
+ hr_line5.set_points(hr_line_points,2)
+ hr_line5.set_pos(136,60)
+ hr_line5.set_size(10,0)
+ hr_line5.add_style(style_line_red,0)
+
+ hr_line6 = lv.line(heartrate_screen)
+ hr_line6.set_points(hr_line_points,2)
+ hr_line6.set_pos(164,60)
+ hr_line6.set_size(10,0)
+ hr_line6.add_style(style_line_red,0)
+
+ hr_line7 = lv.line(heartrate_screen)
+ hr_line7.set_points(hr_line_points,2)
+ hr_line7.set_pos(192,60)
+ hr_line7.set_size(10,0)
+ hr_line7.add_style(style_line_red,0)
+
+ heartrate_bpm_label = lv.label(heartrate_screen)
+ heartrate_bpm_label.set_size(120, 40)
+ heartrate_bpm_label.set_pos(120, 270)
+ heartrate_bpm_label.set_text("-- bpm")
+ heartrate_bpm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ heartrate_bpm_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+
+ heartrate_done_label = lv.label(heartrate_screen)
+ heartrate_done_label.set_size(240, 40)
+ heartrate_done_label.set_pos(0, 270)
+ heartrate_done_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ heartrate_done_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ heartrate_done_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+
+ self.meta = heartrate_screen
+ heartrate_reset_btn_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.restart_up(e)),
+ lv.EVENT.CLICKED, None)
+ heartrate_done_label.set_text(" ")
+ heartrate_bpm_label.set_text("-- bpm")
+ heartrate_start_label.set_text("正在测量中.")
+ EventMesh.publish("set_hr_state",1)#1代表手动进入测试界面
+
+ EventMesh.publish(constants.EVENT.START_HEART)
+
+ def post_processor_after_initialization(self):
+ self.point = 0
+ self.heart_value = 0
+ # self.show_history_data()
+ EventMesh.publish("show_history_hr_data")
+ self.restart_up(0)
+
+ def restart_up(self,e):
+ global heartrate_done_label,heartrate_bpm_label,heartrate_start_label,heartrate_reset_btn_img
+ self.timer.start(1*500, 1, self.start_measure)
+ heartrate_bpm_label.set_text("-- bpm")
+ if heartrate_reset_btn_img != None:
+ heartrate_reset_btn_img.add_flag(lv.obj.FLAG.HIDDEN)
+ self.point = 0
+ self.heart_value = 0
+
+ heartrate_done_label.set_text(" ")
+ heartrate_bpm_label.set_text("-- bpm")
+ heartrate_start_label.set_text("正在测量中.")
+ EventMesh.publish("set_hr_state",1)#1代表手动进入测试界面
+
+ EventMesh.publish(constants.EVENT.START_HEART)
+
+ def show_history_hr_data(self,event,msg):
+ global hr_line1,hr_line2,hr_line3,hr_line4,hr_line5,hr_line6,hr_line7
+ if heartrate_screen == None:
+ return
+
+ read_data = {}
+ read_data = EventMesh.publish("get_history_hr_value")
+ if len(read_data) != 0:
+ sort_new = {}
+ sort_new = sorted(read_data, key = lambda i: i['timeSec'],reverse = False)#按照时间戳进行排序 去掉最旧的一次数据如果满了五十条
+ # print("hr history sort_new",sort_new)
+ if sort_new != []:
+ for i in range(len(sort_new)):
+ print(int(sort_new[i]["hr"]))
+ # print("hr history read_data",read_data)
+ value = int(sort_new[i]["hr"])
+ if value < 30:
+ value = 30
+ if value >= 210:
+ value = 210
+ line_value = value - 30 #180-80 = 100 160-100 = 60
+ line_value = int(line_value*0.58)+1
+ if line_value >= 100:
+ line_value = 100
+ #print("hr hist",line_value)
+ hr_line_points = [{"x":0,"y":0},{"x":0,"y":line_value}]
+ if i == 0:
+ hr_line1.set_points(hr_line_points,2)
+ hr_line1.set_pos(25,160-line_value)
+ hr_line1.set_size(10,line_value)
+ if i == 1:
+ hr_line2.set_points(hr_line_points,2)
+ hr_line2.set_pos(53,160-line_value)
+ hr_line2.set_size(10,line_value)
+
+ if i == 2:
+ hr_line3.set_points(hr_line_points,2)
+ hr_line3.set_pos(80,160-line_value)
+ hr_line3.set_size(10,line_value)
+
+ if i == 3:
+ hr_line4.set_points(hr_line_points,2)
+ hr_line4.set_pos(109,160-line_value)
+ hr_line4.set_size(10,line_value)
+
+ if i == 4:
+ hr_line5.set_points(hr_line_points,2)
+ hr_line5.set_pos(136,160-line_value)
+ hr_line5.set_size(10,line_value)
+
+ if i == 5:
+ hr_line6.set_points(hr_line_points,2)
+ hr_line6.set_pos(164,160-line_value)
+ hr_line6.set_size(10,line_value)
+
+ if i == 6:
+ hr_line7.set_points(hr_line_points,2)
+ hr_line7.set_pos(192,160-line_value)
+ hr_line7.set_size(10,line_value)
+ def start_measure(self,*args):
+ EventMesh.publish("publish_message_event_ui",{"func":self.start_measure_do,"data":0})
+ def start_measure_do(self,data):
+ global heartrate_screen,heartrate_label,heartrate_done_img ,heartrate_reset_btn_img,heartrate_start_label,heartrate_bpm_label ,heartrate_done_label
+ self.point = self.point + 1
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ self.heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
+ WEAR = EventMesh.publish(constants.EVENT.GET_WEAR)#佩戴数据
+ #print("heart WEAR:{}".format(WEAR))
+ # print("self.heart_value:{}".format(self.heart_value))
+ if self.point >= 2:
+ if self.heart_value < 50:
+ self.heart_value = 0
+ if self.heart_value != 0:
+ heartrate_bpm_label.set_text("{} bpm".format(self.heart_value))
+ else:
+ heartrate_bpm_label.set_text("-- bpm")
+
+ if self.point%4 == 0 :
+ heartrate_start_label.set_text("正在测量中..")
+ heartrate_done_img.set_src("E:/static/hr_gif_02.png")
+ if self.point%4 == 1 :
+ heartrate_start_label.set_text("正在测量中...")
+ heartrate_done_img.set_src("E:/static/hr_gif_01.png")
+ if self.point%4 == 2 :
+ heartrate_start_label.set_text("正在测量中.")
+ heartrate_done_img.set_src("E:/static/hr_gif_02.png")
+
+ if self.point%4 == 3 :
+ heartrate_start_label.set_text("正在测量中.")
+ heartrate_done_img.set_src("E:/static/hr_gif_03.png")
+
+
+
+ if self.point > 120 or (WEAR == 0 and self.point > 10): #测60s或没佩戴
+ self.timer.stop()
+ heartrate_done_img.set_src("E:/static/hr_gif_03.png")
+
+ self.heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
+ if WEAR == 0:
+ self.heart_value = 0
+ heartrate_start_label.set_text("佩戴异常,点击重测")
+ else :
+ heartrate_start_label.set_text("测量结束,点击重测")
+
+ if self.heart_value >= 50:
+ EventMesh.publish("set_old_hr_data",self.heart_value)
+ EventMesh.publish("set_history_hr_value",self.heart_value)
+ EventMesh.publish(constants.PROTOCOL.HEART_SEND,self.heart_value)
+ heartrate_reset_btn_img.clear_flag(lv.obj.FLAG.HIDDEN)
+
+
+ if self.heart_value >= 50:
+ heartrate_bpm_label.set_text("{} bpm".format(self.heart_value))
+ # heartrate_done_label.set_text("测量完成")
+ else:
+ heartrate_bpm_label.set_text("-- bpm")
+ # self.show_history_data()
+ self.point = 0
+ EventMesh.publish("set_hr_state",0)#0代表关闭测试
+ print("stop debug9")
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+
+ def Close(self):
+ self.timer.stop()
+ get_hr_state = EventMesh.publish("get_hr_state")
+ get_spo2_state = EventMesh.publish("get_spo2_state")
+ if get_hr_state == 1 or get_spo2_state == 1:
+ EventMesh.publish("set_hr_state",0)#0代表关闭测试
+ print("stop debug10")
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
+# -------------------------------------------toolbox screen----------------------------------------------------------
+
+toolbox_screen = None
+toolbox_text_img = None
+toolbox_cont = None
+toolbox_step_img = None
+toolbox_weather_img = None
+toolbox_alarm_img = None
+# toolbox_sms_img = None
+toolbox_countdown_img = None
+toolbox_stopwatch_img = None
+
+toolbox_cont_style = lv.style_t()
+toolbox_cont_style.init()
+toolbox_cont_style.set_radius(0)
+toolbox_cont_style.set_bg_color(lv.color_make(0x00, 0x00, 0x00))
+toolbox_cont_style.set_bg_grad_color(lv.color_make(0x00, 0x00, 0x00))
+toolbox_cont_style.set_bg_grad_dir(lv.GRAD_DIR.VER)
+toolbox_cont_style.set_bg_opa(255)
+toolbox_cont_style.set_border_width(0)
+toolbox_cont_style.set_pad_left(0)
+toolbox_cont_style.set_pad_right(0)
+toolbox_cont_style.set_pad_top(0)
+toolbox_cont_style.set_pad_bottom(0)
+
+class ToolboxScreen(Screen):
+ NAME = "toolbox"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.is_sliding = 0
+
+ def initialization(self):
+ self.is_sliding = 0
+ global toolbox_screen,toolbox_text_img,toolbox_cont,toolbox_step_img,toolbox_weather_img ,toolbox_alarm_img ,\
+ toolbox_countdown_img,toolbox_stopwatch_img
+ if toolbox_screen == None:
+ tool_set_y = 0
+ toolbox_screen = lv.obj()
+ print("toolbox_screen")
+ toolbox_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+ toolbox_screen.set_scrollbar_mode(0)
+
+ toolbox_text_img = lv.img(toolbox_screen)
+ toolbox_text_img.set_pos(75, 10)
+ toolbox_text_img.set_size(90, 30)
+ toolbox_text_img.set_src("E:/static/tool/tool_text.png")
+ toolbox_text_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ toolbox_cont = lv.obj(toolbox_screen)
+ toolbox_cont.set_pos(0, 50)
+ toolbox_cont.set_size(240, 270)
+ toolbox_cont.add_style(toolbox_cont_style,lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+ toolbox_step_img = lv.img(toolbox_cont)
+ toolbox_step_img.set_pos(4, tool_set_y)
+ toolbox_step_img.set_size(232, 80)
+ toolbox_step_img.add_flag(lv.obj.FLAG.CLICKABLE)
+ toolbox_step_img.set_src("E:/static/tool/IMAGE_SECMENU_STEP.png")
+ toolbox_step_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ tool_set_y+=90
+
+ toolbox_weather_img = lv.img(toolbox_cont)
+ toolbox_weather_img.set_pos(4, tool_set_y)
+ toolbox_weather_img.set_size(232, 80)
+ toolbox_weather_img.add_flag(lv.obj.FLAG.CLICKABLE)
+ toolbox_weather_img.set_src("E:/static/tool/IMAGE_SECMENU_WEATHER.png")
+ toolbox_weather_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ tool_set_y+=90
+ toolbox_alarm_img = lv.img(toolbox_cont)
+ toolbox_alarm_img.set_pos(4, tool_set_y)
+ toolbox_alarm_img.set_size(232, 80)
+ toolbox_alarm_img.add_flag(lv.obj.FLAG.CLICKABLE)
+ toolbox_alarm_img.set_src("E:/static/tool/IMAGE_SECMENU_ALARM.png")
+ toolbox_alarm_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+ # tool_set_y+=90
+ # toolbox_sms_img = lv.img(toolbox_cont)
+ # toolbox_sms_img.set_pos(4, tool_set_y)
+ # toolbox_sms_img.set_size(232, 80)
+ # toolbox_sms_img.add_flag(lv.obj.FLAG.CLICKABLE)
+ # toolbox_sms_img.set_src("E:/static/tool/sms_setting.png")
+ # toolbox_sms_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ tool_set_y+=90
+ toolbox_countdown_img = lv.img(toolbox_cont)
+ toolbox_countdown_img.set_pos(4, tool_set_y)
+ toolbox_countdown_img.set_size(232, 80)
+ toolbox_countdown_img.add_flag(lv.obj.FLAG.CLICKABLE)
+ toolbox_countdown_img.set_src("E:/static/tool/IMAGE_SECMENU_COUNTDOWN.png")
+ toolbox_countdown_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ tool_set_y+=90
+ toolbox_stopwatch_img = lv.img(toolbox_cont)
+ toolbox_stopwatch_img.set_pos(4, tool_set_y)
+ toolbox_stopwatch_img.set_size(232, 80)
+ toolbox_stopwatch_img.add_flag(lv.obj.FLAG.CLICKABLE)
+ toolbox_stopwatch_img.set_src("E:/static/tool/IMAGE_SECMENU_STOPWATCH.png")
+ toolbox_stopwatch_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ toolbox_step_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.toolbox_cb(e, "step")), lv.EVENT.CLICKED, None)
+ toolbox_weather_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.toolbox_cb(e, "weather")), lv.EVENT.CLICKED, None)
+ toolbox_alarm_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.toolbox_cb(e, "clk_list")), lv.EVENT.CLICKED, None)
+ # toolbox_sms_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.load_screen(e, {"screen": "popup"})), lv.EVENT.CLICKED, None)
+ toolbox_countdown_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.toolbox_cb(e, "countdown")), lv.EVENT.CLICKED, None)
+ toolbox_stopwatch_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.toolbox_cb(e, "stopwatch")), lv.EVENT.CLICKED, None)
+
+ toolbox_step_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.toolbox_cb(e, "step")), lv.EVENT.PRESSING, None)
+ toolbox_weather_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.toolbox_cb(e,"weather")), lv.EVENT.PRESSING, None)
+ toolbox_alarm_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.toolbox_cb(e, "clk_list")), lv.EVENT.PRESSING, None)
+ # toolbox_sms_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.load_screen(e, {"screen": "popup"})), lv.EVENT.PRESSING, None)
+ toolbox_countdown_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.toolbox_cb(e,"countdown")), lv.EVENT.PRESSING, None)
+ toolbox_stopwatch_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.toolbox_cb(e, "stopwatch")), lv.EVENT.PRESSING, None)
+ self.meta = toolbox_screen
+ def toolbox_cb(self,e,msg):
+ code = e.get_code()
+ if code == lv.EVENT.PRESSING:
+ #print("PRESSING")
+ self.is_sliding += 1
+
+ elif code == lv.EVENT.CLICKED:
+ #utime.sleep_ms(10)
+ print("1self.is_sliding",self.is_sliding)
+ if self.is_sliding <= 5 and self.is_sliding != 0:#如果是在滑动中则不需要点击事件
+ self.is_sliding = 0
+ EventMesh.publish("load_screen", {"screen":"{}".format(msg)})
+
+ self.is_sliding =0
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
+incoming_call_screen = None
+incoming_call_img = None
+incoming_call_name_label = None
+incoming_call_answer = None
+incoming_call_hangup = None
+# CALL_LOG_MAX = 50
+class IncomingCallScreen(Screen):
+ NAME = "incoming_call"
+
+ def __init__(self):
+ super().__init__()
+ self.CALL_LOG_MAX = CALL_LOG_MAX
+
+ self.aud = audio.Audio(0)
+
+ self.call_timer = osTimer()
+ self.name = None
+ self.phonebook = {}
+ self.pro_state = 0
+ self.meta = None
+
+ self.meta_type = "popup"
+ self.call_log = {}
+ self.call_log_value = {}
+ self.read_call_log = {}
+ self.number_tmp = {}
+ EventMesh.subscribe("answer_auto_event",self.answer_auto_event)
+
+ def initialization(self):
+ global incoming_call_screen,incoming_call_img,incoming_call_name_label,incoming_call_answer ,incoming_call_hangup
+ if incoming_call_screen == None :
+ # -------------------------------------------incoming_call screen----------------------------------------------------------
+ incoming_call_screen = lv.obj()
+ print("incoming_call_screen")
+ incoming_call_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ incoming_call_img = lv.img(incoming_call_screen)
+ incoming_call_img.set_pos(80, 20)
+ incoming_call_img.set_size(64, 64)
+ incoming_call_img.set_src("E:/static/IMAGE_NOTICE_CALL.png")
+ incoming_call_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ incoming_call_name_label = lv.label(incoming_call_screen)
+ incoming_call_name_label.set_pos(0, 140)
+ incoming_call_name_label.set_text(" ")
+ incoming_call_name_label.set_size(240, 50)
+ incoming_call_name_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ incoming_call_name_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ incoming_call_answer = lv.img(incoming_call_screen)
+ incoming_call_answer.set_size(64, 64)
+ incoming_call_answer.add_flag(lv.obj.FLAG.CLICKABLE)
+ incoming_call_answer.set_pos(150, 220)
+ incoming_call_answer.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ incoming_call_answer.set_src("E:/static/answer.png")
+
+ incoming_call_hangup = lv.img(incoming_call_screen)
+ incoming_call_hangup.set_size(64, 64)
+ incoming_call_hangup.add_flag(lv.obj.FLAG.CLICKABLE)
+ incoming_call_hangup.set_pos(30, 220)
+ incoming_call_hangup.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ incoming_call_hangup.set_src("E:/static/hang_up.png")
+
+ incoming_call_answer.add_event_cb(lambda e: EventMesh.callback_wrapper(self.answer(e)),
+ lv.EVENT.CLICKED, None)
+ incoming_call_hangup.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hangup(e)),
+ lv.EVENT.CLICKED, None)
+ self.meta = incoming_call_screen
+ EventMesh.publish("set_UI_high_priority", 1)
+
+
+ def post_processor_after_initialization(self):
+ global incoming_call_screen,incoming_call_img,incoming_call_name_label,incoming_call_answer ,incoming_call_hangup
+ utime.sleep_ms(200)#不加延时会切屏
+ data = EventMesh.publish("get_phonebook_list")
+ if data != None:
+ check = data[0]
+ self.phonebook = data[1]
+ if check == 1:#先检查通讯录
+ phonebook_keys = sorted(self.phonebook.keys())
+ b = self.meta_info in self.phonebook.values()#查找key中是否包含content电话号码 True 包含在里面 False不包含在里面
+ j = 0
+ if b == True:
+ for i in range(len(self.phonebook)): #字典 key value
+ #'001:邓雪英':15521469561
+ name = self.phonebook[phonebook_keys[j]]
+ name_value = phonebook_keys[j]
+ number_tmp = str(self.meta_info)
+ # print("name :{} number_tmp:{}".format(name,number_tmp))
+ if name.find(number_tmp) != -1:#查找电话号码是否在通讯录里面
+ number_f= name_value
+ name_s = number_f.split(':')
+ name_s = name_s[1]
+ self.name = name_s
+ self.pro_state = 1
+ break
+ j+=1
+ else:
+ self.name = str(self.meta_info)
+ self.pro_state = 0
+ else:
+ self.name = str(self.meta_info)
+ self.pro_state = 0
+
+ read_call_log = EventMesh.publish("get_call_log_list")
+ check_call_log_json = read_call_log[0]
+ self.read_call_log = read_call_log[1]
+ if self.pro_state == 0 and check_call_log_json == 1:#电话本没有就在通话记录查找电话号码并且文件存在是查找
+
+ sort_tmp = self.read_call_log.values()
+ for sort_new_tmp in sort_tmp: #字典 key value
+ number = sort_new_tmp["number"]
+ find_ok = self.meta_info in number
+ # print("find_ok:{} sort_tmp :{} self.meta_info:{}\r\n".format(find_ok,number,self.meta_info))
+ if find_ok == True:
+ name_value = sort_new_tmp["name"]#查找到相同的电话号码就退出break
+ self.name = name_value
+ break
+
+ if self.name == None:
+ self.name = str(self.meta_info)
+
+ # incoming_call_label.set_text(str(self.meta_info))
+ incoming_call_name_label.set_text(self.name)
+ EventMesh.publish("save_phonename",self.name)
+ time = EventMesh.publish("screen_get_time")#获取系统时间
+
+ # ["15692025051","2","12:59","哥gdh符合双方和开发商开发好看的思考"],
+ # 格式:{"电话号码":{"timesec":'时间戳',"number":'电话号码',"name":'名字',"time":'时间',"count":'通话次数'}}
+ self.num = 0
+
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ # print("time_tmp:{}".format(time_tmp))
+ read_call_log = EventMesh.publish("get_call_log_list")
+ check_json = read_call_log[0]
+
+ if check_json == True:
+ self.read_call_log = read_call_log[1]
+ print("读取通话记录")
+ b = str(self.meta_info) in self.read_call_log.keys()#查找key中是否包含content电话号码 True 包含在里面 False不包含在里面
+
+ if b == True:#查找是否有相同的电话号码 有就直接读出来的次数上加一 没有则从1开始加起
+ number_tmp = {}
+ number_tmp = self.read_call_log[str(self.meta_info)] #通话次数加一
+ num_tmp_t = number_tmp["count"]#读取本地保存的通话次数
+ else :
+ num_tmp_t = 0
+ self.num = num_tmp_t
+ else:
+ self.num = 0 #通话次数
+
+ sort_tmp = {}
+ sort_tmp = self.read_call_log.values()
+ sort_new = {}
+ sort_new = sorted(sort_tmp, key = lambda i: i['timesec'],reverse = True)#按照时间戳进行排序 去掉最旧的一次数据如果满了五十条
+ i = 0
+ if len(self.read_call_log) >= self.CALL_LOG_MAX:
+ for sort_new_tmp in sort_new: #字典 key value
+ i+=1 # 1
+ if i >= self.CALL_LOG_MAX:#大于50条把最后一条删除掉只保留前面50调最新的数据
+ key_tmp = sort_new_tmp["number"]
+ del self.read_call_log[key_tmp]
+
+ tmp = {}
+ self.num = self.num +1
+ if self.num > 99:
+ self.num = 99
+ tmp["count"]= self.num #通话次数
+ tmp["time"]= "{}:{}".format("%02d"%(time[0][0]),"%02d"%(time[0][1]))#通话时间
+ tmp["name"]= self.name #名称
+ tmp["timesec"]= time_tmp #时间戳
+ tmp["number"] = self.meta_info
+
+ self.read_call_log[self.meta_info] = tmp
+ with open("/ext/static/storage_file/Call_log.json","w",encoding="utf-8") as fd:
+ ujson.dump(self.read_call_log,fd)
+ print("创建通话记录")
+ EventMesh.publish("set_call_log_list", [1,self.read_call_log])
+ EventMesh.publish("call_log_update_show_list")
+
+ self.call_timer.start(6000, 1, self.call_timer_cb)
+ self.aud.play(1, 1, 'U:/static/R_CALL_mp3.mp3') #播放来电铃声
+
+ def call_timer_cb(self,e):
+ self.aud.play(1, 1, 'U:/static/R_CALL_mp3.mp3') #播放来电铃声
+
+ def answer(self,e):
+ self.call_timer.stop()
+ self.aud.stop()
+ EventMesh.publish("set_UI_high_priority", 0)
+ voiceCall.callAnswer()
+
+ def Close(self):
+ self.call_timer.stop()
+ self.aud.stop()
+
+ def hangup(self,e):
+ EventMesh.publish("set_UI_high_priority", 0)
+ self.aud.stop()
+ self.call_timer.stop()
+ voiceCall.callEnd()
+ EventMesh.publish("set_interrup_incall",0)
+ EventMesh.publish("set_UI_high_priority",0)
+ EventMesh.publish("return_prev_screen")
+
+ def answer_auto_event(self,event,msg):
+ self.call_timer.stop()
+ self.aud.stop()
+ EventMesh.publish("set_UI_high_priority", 0)
+ voiceCall.callAnswer()
+ name = EventMesh.publish("get_phonename")
+ EventMesh.publish("load_screen", {"screen": "on_call","meta":str(name)})
+
+ def btn1_release(self):
+ pass
+
+ def btn8_press(self):
+ flag = EventMesh.publish("get_lcd_state")
+ if flag == 1:
+ EventMesh.publish(constants.EVENT.SYSTEM_SLEEP)
+ else:
+ EventMesh.publish(constants.EVENT.SYSTEM_UP)
+ pass
+
+ def done_left_to_right(self):
+ pass
+
+ def done_right_to_left(self):
+ pass
+
+ def done_bottom_to_top(self):
+ pass
+
+ def done_top_to_bottom(self):
+ pass
+
+ def done_return(self):
+ pass
+
+
+on_call_screen = None
+on_call_obj =None
+on_call_label_name = None
+on_call_second_label = None
+on_call_volum_label = None
+on_call_tab_label = None
+on_call_hangup = None
+on_call_bar = None
+on_call_volum_reduce = None
+on_call_volum_add = None
+on_call_phone_one = None
+on_call_phone_two = None
+on_call_phone_three = None
+on_call_phone_four = None
+on_call_phone_five = None
+on_call_phone_six = None
+on_call_phone_seven = None
+on_call_phone_eight = None
+on_call_phone_nine = None
+on_call_phone_start = None
+on_call_phone_zero = None
+on_call_screen_tab = None
+on_call_phone_hash = None
+on_call_phone_return =None
+on_call_screen_tab_label =None
+on_call_phone_return_btn = None
+ON_CALL_MAX_DATA = 9
+class OnCallScreen(Screen):
+ NAME = "on_call"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.count_sec = 0
+ self.timer = osTimer()
+ self.aud = audio.Audio(0)
+ self.volum_size = 8
+ self.open_volum = 0
+ self.phone_num = ''
+ self.phone_list = []
+ self.button = 0
+ self.mute_btn = 0
+ self.meta_type = "popup"
+
+ def initialization(self):
+ EventMesh.publish("set_UI_high_priority", 1)
+ global on_call_screen,on_call_label_name,on_call_second_label ,on_call_hangup ,on_call_volum_label,on_call_tab_label,on_call_bar,on_call_obj,\
+ on_call_volum_reduce,on_call_volum_add,on_call_phone_one ,on_call_phone_two ,on_call_phone_three,on_call_phone_four,on_call_phone_five,\
+ on_call_phone_six,on_call_phone_seven,on_call_screen_tab_label ,on_call_phone_return,on_call_phone_eight ,on_call_phone_nine ,on_call_phone_start ,\
+ on_call_phone_zero ,on_call_phone_hash,on_call_phone_return_btn,\
+ on_call_screen_tab
+ if on_call_screen ==None :
+ on_call_screen = lv.obj()
+ on_call_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+ on_call_obj = lv.obj(on_call_screen)
+ on_call_obj.set_size(240,320)
+ on_call_obj.set_pos(0,0)
+ on_call_obj.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+ print("on_call_screen")
+
+ on_call_label_name = lv.label(on_call_obj)
+ on_call_label_name.set_pos(0, 80)
+ on_call_label_name.set_size(240, 50)
+ on_call_label_name.set_text(" ")
+ on_call_label_name.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ on_call_label_name.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ on_call_second_label = lv.label(on_call_obj)
+ on_call_second_label.set_pos(0, 140)
+ on_call_second_label.set_size(240, 30)
+ on_call_second_label.set_text("00:00")
+ on_call_second_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ on_call_second_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ on_call_bar = lv.bar(on_call_obj)
+ on_call_bar.set_pos(49, 183)
+ on_call_bar.set_size(140, 25)
+ on_call_bar.set_style_anim_time(1000, lv.PART.INDICATOR | lv.STATE.DEFAULT)
+ on_call_bar.set_mode(lv.bar.MODE.NORMAL)
+ on_call_bar.set_value(50, lv.ANIM.OFF)
+ on_call_bar.add_style(style_bar, lv.PART.MAIN | lv.STATE.DEFAULT)
+ on_call_bar.add_style(style_bar_indic, lv.PART.INDICATOR | lv.STATE.DEFAULT)
+
+ on_call_volum_reduce = lv.img(on_call_obj)
+ on_call_volum_reduce.set_size(36, 36)
+ on_call_volum_reduce.set_pos(4, 178)
+ on_call_volum_reduce.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ on_call_volum_reduce.set_src("E:/static/REDUCE_VOLUM_ICON.png")
+
+
+ on_call_volum_reduce_btn = lv.label(on_call_obj)
+ on_call_volum_reduce_btn.set_pos(0, 170)
+ on_call_volum_reduce_btn.add_flag(lv.obj.FLAG.CLICKABLE)
+ on_call_volum_reduce_btn.set_size(60, 50)
+ on_call_volum_reduce_btn.set_text(" ")
+ on_call_volum_reduce_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.reduce_volum_size(e)),
+ lv.EVENT.CLICKED, None)
+
+ on_call_volum_add = lv.img(on_call_obj)
+ on_call_volum_add.set_size(36, 36)
+ on_call_volum_add.set_pos(194, 178)
+ on_call_volum_add.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ on_call_volum_add.set_src("E:/static/VOLUM_ADD_ICON.png")
+
+
+ on_call_volum_add_btn = lv.label(on_call_obj)
+ on_call_volum_add_btn.set_pos(180, 170)
+ on_call_volum_add_btn.add_flag(lv.obj.FLAG.CLICKABLE)
+ on_call_volum_add_btn.set_size(60, 50)
+ on_call_volum_add_btn.set_text(" ")
+ on_call_volum_add_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.add_volum_size(e)),
+ lv.EVENT.CLICKED, None)
+
+
+ on_call_volum_label = lv.label(on_call_obj)
+ on_call_volum_label.set_pos(0, 270)
+ on_call_volum_label.add_flag(lv.obj.FLAG.CLICKABLE)
+ on_call_volum_label.set_size(85, 50)
+ on_call_volum_label.set_text("静音")
+ on_call_volum_label.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
+ on_call_volum_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ on_call_volum_label.add_event_cb(lambda e: EventMesh.callback_wrapper(self.open_volum_show(e)),
+ lv.EVENT.CLICKED, None)
+
+ on_call_hangup = lv.img(on_call_obj)
+ on_call_hangup.set_size(64, 64)
+ on_call_hangup.add_flag(lv.obj.FLAG.CLICKABLE)
+ on_call_hangup.set_pos(85, 245)
+ on_call_hangup.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ on_call_hangup.set_src("E:/static/hang_up.png")
+ on_call_hangup.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hangup(e)),
+ lv.EVENT.CLICKED, None)
+
+ on_call_tab_label = lv.label(on_call_obj)
+ on_call_tab_label.set_pos(150, 270)
+ on_call_tab_label.add_flag(lv.obj.FLAG.CLICKABLE)
+ on_call_tab_label.set_size(90, 50)
+ on_call_tab_label.set_text("键盘")
+ on_call_tab_label.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
+ on_call_tab_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ on_call_tab_label.add_event_cb(lambda e: EventMesh.callback_wrapper(self.on_call_tab_show(e)),
+ lv.EVENT.CLICKED, None)
+
+ on_call_screen_tab = lv.obj(on_call_screen)
+ on_call_screen_tab.set_size(240,320)
+ on_call_screen_tab.set_pos(0,0)
+ on_call_screen_tab.add_flag(lv.obj.FLAG.HIDDEN)
+ on_call_screen_tab.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ on_call_screen_tab_label = lv.label(on_call_screen_tab)
+ on_call_screen_tab_label.set_pos(40, 34)
+ on_call_screen_tab_label.set_size(0, 30)
+ on_call_screen_tab_label.set_text(" ")
+ on_call_screen_tab_label.set_long_mode(lv.label.LONG.CLIP)
+ on_call_screen_tab_label.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
+ on_call_screen_tab_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+
+ on_call_phone_return = lv.img(on_call_screen_tab)
+ on_call_phone_return.set_src("E:/static/RED_RETURN_PNG.png")
+ on_call_phone_return.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ on_call_phone_return.set_pos(0, 30)
+ on_call_phone_return.set_size(36, 36)
+
+ on_call_phone_return_btn = lv.img(on_call_screen_tab)
+ on_call_phone_return_btn.add_flag(lv.obj.FLAG.CLICKABLE)
+ on_call_phone_return_btn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ on_call_phone_return_btn.set_pos(0, 0)
+ on_call_phone_return_btn.set_size(50, 100)
+ on_call_phone_return_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.on_return_show(e)),
+ lv.EVENT.CLICKED, None)
+
+
+ on_call_phone_one = lv.img(on_call_screen_tab)
+ on_call_phone_one.set_src("E:/static/IMAGE_NUMBER_KEY1_ICON.png")
+ on_call_phone_one.add_flag(lv.obj.FLAG.CLICKABLE)
+ on_call_phone_one.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ on_call_phone_one.set_pos(3, 110)
+ on_call_phone_one.set_size(76, 50)
+
+ on_call_phone_two = lv.img(on_call_screen_tab)
+ on_call_phone_two.set_size(76, 50)
+ on_call_phone_two.set_src("E:/static/IMAGE_NUMBER_KEY2_ICON.png")
+ on_call_phone_two.add_flag(lv.obj.FLAG.CLICKABLE)
+ on_call_phone_two.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ on_call_phone_two.set_pos(82, 110)
+
+ on_call_phone_three = lv.img(on_call_screen_tab)
+ on_call_phone_three.set_size(76, 50)
+ on_call_phone_three.set_src("E:/static/IMAGE_NUMBER_KEY3_ICON.png")
+ on_call_phone_three.add_flag(lv.obj.FLAG.CLICKABLE)
+ on_call_phone_three.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ on_call_phone_three.set_pos(161, 110)#1
+
+ on_call_phone_four = lv.img(on_call_screen_tab)
+ on_call_phone_four.set_size(76, 50)
+ on_call_phone_four.set_src("E:/static/IMAGE_NUMBER_KEY4_ICON.png")
+ on_call_phone_four.add_flag(lv.obj.FLAG.CLICKABLE)
+ on_call_phone_four.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ on_call_phone_four.set_pos(3, 162)
+
+ on_call_phone_five = lv.img(on_call_screen_tab)
+ on_call_phone_five.set_size(76, 50)
+ on_call_phone_five.set_src("E:/static/IMAGE_NUMBER_KEY5_ICON.png")
+ on_call_phone_five.add_flag(lv.obj.FLAG.CLICKABLE)
+ on_call_phone_five.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ on_call_phone_five.set_pos(82, 162)
+
+ on_call_phone_six = lv.img(on_call_screen_tab)
+ on_call_phone_six.set_size(76, 50)
+ on_call_phone_six.set_src("E:/static/IMAGE_NUMBER_KEY6_ICON.png")
+ on_call_phone_six.add_flag(lv.obj.FLAG.CLICKABLE)
+ on_call_phone_six.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ on_call_phone_six.set_pos(161, 162)#2
+
+ on_call_phone_seven = lv.img(on_call_screen_tab)
+ on_call_phone_seven.set_size(76, 50)
+ on_call_phone_seven.set_src("E:/static/IMAGE_NUMBER_KEY7_ICON.png")
+ on_call_phone_seven.add_flag(lv.obj.FLAG.CLICKABLE)
+ on_call_phone_seven.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ on_call_phone_seven.set_pos(3, 214)
+
+ on_call_phone_eight = lv.img(on_call_screen_tab)
+ on_call_phone_eight.set_size(76, 50)
+ on_call_phone_eight.set_src("E:/static/IMAGE_NUMBER_KEY8_ICON.png")
+ on_call_phone_eight.add_flag(lv.obj.FLAG.CLICKABLE)
+ on_call_phone_eight.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ on_call_phone_eight.set_pos(82, 214)
+
+ on_call_phone_nine = lv.img(on_call_screen_tab)
+ on_call_phone_nine.set_size(76, 50)
+ on_call_phone_nine.set_src("E:/static/IMAGE_NUMBER_KEY9_ICON.png")
+ on_call_phone_nine.add_flag(lv.obj.FLAG.CLICKABLE)
+ on_call_phone_nine.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ on_call_phone_nine.set_pos(161, 214)
+
+ on_call_phone_start = lv.img(on_call_screen_tab)
+ on_call_phone_start.set_size(76, 50)
+ on_call_phone_start.set_src("E:/static/IMAGE_NUMBER_KEYSTAR_ICON.png")
+ on_call_phone_start.add_flag(lv.obj.FLAG.CLICKABLE)
+ on_call_phone_start.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ on_call_phone_start.set_pos(3, 266)
+
+ on_call_phone_zero = lv.img(on_call_screen_tab)
+ on_call_phone_zero.set_size(76, 50)
+ on_call_phone_zero.set_src("E:/static/IMAGE_NUMBER_KEY0_ICON.png")
+ on_call_phone_zero.add_flag(lv.obj.FLAG.CLICKABLE)
+ on_call_phone_zero.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ on_call_phone_zero.set_pos(82, 266)
+
+ on_call_phone_hash = lv.img(on_call_screen_tab)
+ on_call_phone_hash.set_size(76, 50)
+ on_call_phone_hash.set_src("E:/static/IMAGE_NUMBER_KEYHASH_ICON.png")
+ on_call_phone_hash.add_flag(lv.obj.FLAG.CLICKABLE)
+ on_call_phone_hash.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ on_call_phone_hash.set_pos(161, 266)
+
+ self.meta = on_call_screen
+
+
+ on_call_phone_one.add_event_cb(lambda e: EventMesh.callback_wrapper(self.one(e)),
+ lv.EVENT.CLICKED, None)
+ on_call_phone_two.add_event_cb(lambda e: EventMesh.callback_wrapper(self.two(e)),
+ lv.EVENT.CLICKED, None)
+ on_call_phone_three.add_event_cb(lambda e: EventMesh.callback_wrapper(self.three(e)),
+ lv.EVENT.CLICKED, None)
+ on_call_phone_four.add_event_cb(lambda e: EventMesh.callback_wrapper(self.four(e)),
+ lv.EVENT.CLICKED, None)
+ on_call_phone_five.add_event_cb(lambda e: EventMesh.callback_wrapper(self.five(e)),
+ lv.EVENT.CLICKED, None)
+ on_call_phone_six.add_event_cb(lambda e: EventMesh.callback_wrapper(self.six(e)),
+ lv.EVENT.CLICKED, None)
+ on_call_phone_seven.add_event_cb(lambda e: EventMesh.callback_wrapper(self.seven(e)),
+ lv.EVENT.CLICKED, None)
+ on_call_phone_eight.add_event_cb(lambda e: EventMesh.callback_wrapper(self.eight(e)),
+ lv.EVENT.CLICKED, None)
+ on_call_phone_nine.add_event_cb(lambda e: EventMesh.callback_wrapper(self.nine(e)),
+ lv.EVENT.CLICKED, None)
+ on_call_phone_zero.add_event_cb(lambda e: EventMesh.callback_wrapper(self.zero(e)),
+ lv.EVENT.CLICKED, None)
+
+ on_call_phone_start.add_event_cb(lambda e: EventMesh.callback_wrapper(self.start(e)),
+ lv.EVENT.CLICKED, None)#短按显示*
+
+ on_call_phone_start.add_event_cb(lambda e: EventMesh.callback_wrapper(self.pressed_start(e)),
+ lv.EVENT.LONG_PRESSED, None)#长按显示+
+
+ on_call_phone_start.add_event_cb(lambda e: EventMesh.callback_wrapper(self.endpressed_start(e)),
+ lv.EVENT.RELEASED, None)#释放按键
+
+ on_call_phone_hash.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hash(e)),
+ lv.EVENT.CLICKED, None)
+ name = EventMesh.publish("get_phonename")
+ on_call_label_name.set_text(name)
+ # on_call_label.set_text(str(self.meta_info))
+ on_call_second_label.set_text("00:00")
+ on_call_volum_label.set_style_text_color(lv.color_make(255,255,255), lv.STATE.DEFAULT)
+ self.phone_num = ''
+ self.phone_list = []
+ self.button = 0
+ self.mute_btn = 0
+ voiceCall.mute(2,0,0)
+
+ def show_num(self):
+ global on_call_screen_tab_label
+ print("phone self.phone_num ",self.phone_num,self.phone_list)
+ on_call_screen_tab_label.set_size(200, 30)
+ on_call_screen_tab_label.set_text(self.phone_num)
+ def one(self,e):
+ if len(self.phone_list) >= ON_CALL_MAX_DATA:
+ self.phone_list.pop(0)
+ #return
+
+ voiceCall.startDtmf("1",100)
+ self.phone_list.append("1")
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+ def two(self,e):
+ if len(self.phone_list) >= ON_CALL_MAX_DATA:
+ self.phone_list.pop(0)
+ #return
+ voiceCall.startDtmf("2",100)
+ self.phone_list.append("2")
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+ def three(self,e):
+ if len(self.phone_list) >= ON_CALL_MAX_DATA:
+ self.phone_list.pop(0)
+ voiceCall.startDtmf("3",100)
+ self.phone_list.append("3")
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+ def four(self,e):
+ if len(self.phone_list) >= ON_CALL_MAX_DATA:
+ self.phone_list.pop(0)
+ voiceCall.startDtmf("4",100)
+ self.phone_list.append("4")
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+ def five(self,e):
+ if len(self.phone_list) >= ON_CALL_MAX_DATA:
+ self.phone_list.pop(0)
+ #return
+ voiceCall.startDtmf("5",100)
+ self.phone_list.append("5")
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+ def six(self,e):
+ if len(self.phone_list) >= ON_CALL_MAX_DATA:
+ self.phone_list.pop(0)
+ #return
+ voiceCall.startDtmf("6",100)
+ self.phone_list.append("6")
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+ def seven(self,e):
+ if len(self.phone_list) >= ON_CALL_MAX_DATA:
+ self.phone_list.pop(0)
+ #return
+ voiceCall.startDtmf("7",100)
+ self.phone_list.append("7")
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+ def eight(self,e):
+ if len(self.phone_list) >= ON_CALL_MAX_DATA:
+ self.phone_list.pop(0)
+ #return
+ voiceCall.startDtmf("8",100)
+ self.phone_list.append("8")
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+ def nine(self,e):
+ if len(self.phone_list) >= ON_CALL_MAX_DATA:
+ self.phone_list.pop(0)
+ #return
+ voiceCall.startDtmf("9",100)
+ self.phone_list.append("9")
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+ def zero(self,e):
+ if len(self.phone_list) >= ON_CALL_MAX_DATA:#限制拨号数量20个数字
+ self.phone_list.pop(0)
+ #return
+ voiceCall.startDtmf("0",100)
+ self.phone_list.append("0")
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+ def start(self,e):
+ self.button = 0
+
+ def pressed_start(self,e):
+ self.button = 1
+ def Close(self):
+ self.timer_cb = 0
+ self.timer.stop()
+
+ def endpressed_start(self,e):
+ if len(self.phone_list) >= ON_CALL_MAX_DATA:#限制拨号数量20个数字
+ self.phone_list.pop(0)
+ #return
+
+ # if self.button == 1:#长按
+ # voiceCall.startDtmf("+",100)
+ # self.phone_list.append("+")
+ # else:#短按
+ voiceCall.startDtmf("*",100)
+ self.phone_list.append("*")
+
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+ def hash(self,e):
+ if len(self.phone_list) >= ON_CALL_MAX_DATA:#限制拨号数量20个数字
+ self.phone_list.pop(0)
+ #return
+ voiceCall.startDtmf("#",100)
+ self.phone_list.append("#")
+ self.phone_num = ''.join(self.phone_list)
+ self.show_num()
+
+ def add_show_hidden(self):
+ on_call_volum_add.add_flag(lv.obj.FLAG.HIDDEN)
+ on_call_volum_reduce.add_flag(lv.obj.FLAG.HIDDEN)
+ on_call_bar.add_flag(lv.obj.FLAG.HIDDEN)
+
+ def clear_show_hidden(self):
+ on_call_volum_add.clear_flag(lv.obj.FLAG.HIDDEN)
+ on_call_volum_reduce.clear_flag(lv.obj.FLAG.HIDDEN)
+ on_call_bar.clear_flag(lv.obj.FLAG.HIDDEN)
+
+ def open_volum_show(self, e):
+ global on_call_screen_tab,on_call_screen,on_call_obj
+ if self.mute_btn == 0:#默认是开启
+ self.mute_btn = 1
+ voiceCall.mute(2,1,0)
+ on_call_volum_label.set_style_text_color(lv.color_make(0, 169, 242), lv.STATE.DEFAULT)
+ else:
+
+ on_call_volum_label.set_style_text_color(lv.color_make(255, 255, 255), lv.STATE.DEFAULT)
+ self.mute_btn = 0
+ voiceCall.mute(2,0,0)
+ # self.aud.setVolume(0)
+ # if self.open_volum_state == 1:
+ # self.open_volum_state = 0
+ # else:
+ # self.open_volum_state = 1
+ # if self.open_volum_state == 1:
+ # self.add_show_hidden()
+ # else:
+ # self.clear_show_hidden()
+
+
+ def on_call_tab_show(self, e):
+ global on_call_screen_tab,on_call_screen,on_call_obj
+ if on_call_screen_tab != None:
+ self.phone_num = ''
+ self.phone_list = []
+ self.show_num()
+ on_call_screen_tab.clear_flag(lv.obj.FLAG.HIDDEN)
+ on_call_obj.add_flag(lv.obj.FLAG.HIDDEN)
+
+
+ def on_return_show(self, e):
+ global on_call_screen_tab,on_call_screen,on_call_obj
+ if on_call_screen_tab != None:
+ on_call_screen_tab.add_flag(lv.obj.FLAG.HIDDEN)
+ on_call_obj.clear_flag(lv.obj.FLAG.HIDDEN)
+
+ def add_volum_size(self, e):
+ self.volum_size+=2
+ if self.volum_size >= 11:
+ self.volum_size = 11
+ self.show_bar(1)
+
+ def reduce_volum_size(self, e):
+
+ self.volum_size -= 2
+ if self.volum_size < 0:
+ self.volum_size = 0
+ self.show_bar(1)
+
+ def show_bar(self,msg):
+ on_call_bar.set_value((100 // 11) * self.volum_size, lv.ANIM.OFF)
+ if msg == 1:
+ self.aud.setVolume(self.volum_size)
+ EventMesh.publish("set_volum_size",self.volum_size)
+
+
+ def post_processor_after_initialization(self):
+ global on_call_screen_tab,on_call_obj
+ self.count_sec = 0
+ self.timer.start(1000,1,self.refresh)
+
+ num = EventMesh.publish("get_volum_size")
+ if num == None:
+ self.volum_size = 8
+ else:
+ self.volum_size = num
+ self.show_bar(0)
+ self.open_volum = 0
+ self.phone_num = ''
+ self.phone_list = []
+ self.button = 0
+ if on_call_obj != None:
+ on_call_obj.clear_flag(lv.obj.FLAG.HIDDEN)
+ if on_call_screen_tab != None:
+ on_call_screen_tab.add_flag(lv.obj.FLAG.HIDDEN)
+ self.show_num()
+ def refresh(self,e):
+ EventMesh.publish("publish_message_event_ui",{"func":self.refresh_do,"data":0})
+
+ def refresh_do(self,data):
+ # print("call_in")
+ global on_call_screen,on_call_label_name,on_call_second_label ,on_call_hangup
+ min = self.count_sec/60
+ sec = self.count_sec%60
+ if min > 99:
+ total = "%03d:%02d"%(min,sec)
+ else:
+ total = "%02d:%02d"%(min,sec)
+ on_call_second_label.set_text(str(total))
+ self.count_sec+=1
+
+ def hangup(self,e):
+ EventMesh.publish("set_UI_high_priority", 0)
+ self.timer.stop()
+ voiceCall.callEnd()
+ EventMesh.publish("set_interrup_incall",0)
+ EventMesh.publish("set_UI_high_priority",0)
+ EventMesh.publish("return_prev_screen")
+
+ def Close(self):
+ self.timer.stop()
+
+ def btn1_release(self):
+ pass
+ #EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn8_press(self):
+ flag = EventMesh.publish("get_lcd_state")
+ if flag == 1:
+ EventMesh.publish(constants.EVENT.SYSTEM_SLEEP)
+ else:
+ EventMesh.publish(constants.EVENT.SYSTEM_UP)
+ #EventMesh.publish("load_screen", {"screen": "main_menu"})
+# -------------------------------------------step screen----------------------------------------------------------#
+
+step_screen = None
+step_label = None
+step_label_01 = None
+step_img = None
+class StepScreen(Screen):
+ NAME = "step"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.timer = osTimer()
+
+ def initialization(self):
+ global step_screen,step_label ,step_label_01 ,step_img
+ if step_screen == None:
+ step_screen = lv.obj()
+ print("step_screen")
+ step_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ step_label = lv.label(step_screen)
+ step_label.set_pos(10, 30)
+ step_label.set_size(230, 50)
+ step_label.set_text("今日步数")
+ step_label.set_long_mode(lv.label.LONG.WRAP)
+ step_label.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+ step_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ step_label_01 = lv.label(step_screen)
+ step_label_01.set_pos(0, 100)
+ step_label_01.set_size(240, 50)
+ step_label_01.set_text("0步")
+ step_label_01.set_long_mode(lv.label.LONG.WRAP)
+ step_label_01.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ step_label_01.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ step_img = lv.img(step_screen)
+ step_img.set_pos(100, 150)
+ step_img.set_size(40, 65)
+ step_img.set_src("E:/static/IMAGE_STEP.png")
+ step_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ self.meta = step_screen
+
+ step = EventMesh.publish("get_old_step_value")
+ step_label_01.set_text("{} 步".format(step))
+ self.timer.start(1000, 1, self.revcing)
+
+ def revcing(self, *args, **kwargs):
+ global step_screen,step_label ,step_label_01 ,step_img
+ step = EventMesh.publish("get_old_step_value")
+ step_label_01.set_text("{} 步".format(step))
+
+ def Close(self):
+ self.timer.stop()
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+# -------------------------------------------weather screen----------------------------------------------------------
+
+weather_screen = None
+weather_img = None
+no_weather_img = None
+weather_tem_label = None
+no_weather_degree = None
+weather_detail_label = None
+weather_location_label = None
+no_connect_label = None
+no_connect_label1 = None
+class WeatherScreen(Screen):
+ NAME = "weather"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.weather_data = {}
+ EventMesh.subscribe("updata_weather_show", self.update_weather_data)
+
+ def initialization(self):
+ global weather_screen,weather_img,no_weather_img,weather_tem_label,no_weather_degree,\
+ weather_detail_label,weather_location_label,no_connect_label ,no_connect_label1
+ if weather_screen == None :
+ weather_screen = lv.obj()
+ print("weather_screen")
+ weather_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ weather_img = lv.img(weather_screen)
+ weather_img.set_pos(10, 10)
+ weather_img.set_size(135, 120)
+
+ weather_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ no_weather_img = lv.img(weather_screen)
+ no_weather_img.set_pos(5, 10)
+ no_weather_img.set_size(135, 120)
+ no_weather_img.set_src("E:/static/update.png")
+ no_weather_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ weather_tem_label = lv.label(weather_screen)
+ weather_tem_label.set_pos(145, 44)
+ weather_tem_label.set_size(240-145, 50)
+ weather_tem_label.set_text("_ _ ℃")
+ weather_tem_label.set_long_mode(lv.label.LONG.WRAP)
+ weather_tem_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ weather_tem_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ # no_weather_degree = lv.img(weather_screen)
+ # no_weather_degree.set_pos(200, 40)
+ # no_weather_degree.set_size(22, 22)
+ # # no_weather_degree.set_src("U:/static/degree.png")
+ # no_weather_degree.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ weather_detail_label = lv.label(weather_screen)
+ weather_detail_label.set_pos(155, 80)
+ weather_detail_label.set_size(85, 50)
+ weather_detail_label.set_text("-/-")
+ weather_detail_label.set_long_mode(lv.label.LONG.WRAP)
+ weather_detail_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ weather_detail_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ weather_location_label = lv.label(weather_screen)
+ weather_location_label.set_pos(0, 200)
+ weather_location_label.set_size(240, 50)
+ weather_location_label.set_text("--")
+ weather_location_label.set_long_mode(lv.label.LONG.WRAP)
+ weather_location_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ weather_location_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ no_connect_label = lv.label(weather_screen)
+ no_connect_label.set_pos(0, 200)
+ no_connect_label.set_size(240, 40)
+ no_connect_label.set_text("找不到服务器")
+ no_connect_label.set_long_mode(lv.label.LONG.WRAP)
+ no_connect_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ no_connect_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ no_connect_label1 = lv.label(weather_screen)
+ no_connect_label1.set_pos(0, 250)
+ no_connect_label1.set_size(240, 70)
+ no_connect_label1.set_text("请联网后重试")
+ no_connect_label1.set_long_mode(lv.label.LONG.WRAP)
+ no_connect_label1.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ no_connect_label1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ self.meta = weather_screen
+
+ #EventMesh.publish(constants.PROTOCOL.WT_SEND)
+ EventMesh.publish(constants.EVENT.START_LOCATION,constants.PROTOCOL.WT_SEND) #开始WT定位
+ def post_processor_after_initialization(self):
+ EventMesh.publish("updata_weather_show")
+
+
+ def update_weather_data(self, event, msg):
+ global weather_screen,weather_img,no_weather_img,weather_tem_label,\
+ weather_detail_label,weather_location_label,no_connect_label ,no_connect_label1
+ connect = EventMesh.publish(constants.EVENT.GET_CONNECT) #获取网络状态
+ self.weather_data = EventMesh.publish("get_weather_data")
+ if weather_screen != None:
+ if connect != 0 and self.weather_data != None:
+ no_data = self.weather_data[8]
+ if no_data != 0 :
+ no_weather_img.add_flag(lv.obj.FLAG.HIDDEN)
+ weather_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ no_connect_label.set_text(" ")
+ no_connect_label1.set_text(" ")
+ # print("self.weather_data:{}".format(self.weather_data))
+ type = self.weather_data[3]
+ if type == None:
+ weather_img.set_src("E:/static/update.png")#天气类型
+ else:
+ weather_img.set_src("E:/static/{}_weather.png".format(type))#天气类型
+
+ temp = self.weather_data[4]
+ if temp == None:
+ weather_tem_label.set_text("_ _℃")
+ else:
+ weather_tem_label.set_text("{} ℃".format(temp))
+
+ date = self.weather_data[0]
+ if date != '{}':
+ date_month = date.split('-')[1]
+ date_day = date.split('-')[2]
+ weather_detail_label.set_text("{}/{}".format(date_month,date_day))#天气更新时间
+ else:
+ weather_detail_label.set_text("-/-")
+
+ city = self.weather_data[7]
+ if city != '{}':
+ weather_location_label.set_text("{}".format(city))#城市
+ else:
+ weather_location_label.set_text("--")
+ else:#已联网未获取到天气数据
+
+ weather_location_label.set_text(" ")
+ weather_detail_label.set_text("-/-")
+ weather_tem_label.set_text("_ _℃")
+
+ no_connect_label.set_text("未获取网络数据")
+ no_connect_label1.set_text("请稍候重试")
+
+ else:
+
+ weather_location_label.set_text(" ")
+ weather_detail_label.set_text("-/-")
+ weather_tem_label.set_text("_ _℃")
+
+ no_weather_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ weather_img.add_flag(lv.obj.FLAG.HIDDEN)
+ no_connect_label.set_text("找不到服务器")
+ no_connect_label1.set_text("请联网后重试")
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+import audio
+from machine import Pin
+
+
+
+
+# -----------------------------联系人--------------contacts screen----------------------------------------------------------
+
+CONTACT_FLAG = 0
+contacts_screen = None
+contacts_cont = None
+contacts_top_title = None
+contact_none_label = None
+contacts_screen_list_screen = None
+class ContactsScreen(Screen):
+ NAME = "contacts"
+
+ def __init__(self):
+ super().__init__()
+ # -------------------------------------------popup_menu screen----------------------------------------------------------
+ self.meta = None
+ self.phonebook = {}
+ self.count = 0
+ self.phone_num_count = 0
+ self.phone_num = {}
+ self.name = []
+ self.check_json = 0
+ self.timer = osTimer()
+ self.contact_detail_list = None
+ EventMesh.subscribe("contact_updata_list_show", self.btn_create_list)
+ self.MXA_phone_num = 50 #最大显示号码个数
+ self.contact_detail_listt_dict = []
+ self.calling_btn = []
+ self.is_sliding = 0
+
+ def post_processor_before_initialization(self):
+ data = EventMesh.publish("get_phonebook_list")
+ if data != None:
+ self.check_json = data[0]
+ self.phonebook = data[1]
+ self.count = 0
+
+ def initialization(self):
+ self.is_sliding = 0
+ global contacts_screen,contacts_cont,contacts_top_title,contact_none_label,contacts_screen_list_screen
+ if contacts_screen == None:
+ contacts_screen = lv.obj()
+ print("contacts_screen")
+ contacts_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ contacts_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ contacts_screen_list_screen = lv.obj(contacts_screen)
+ contacts_screen_list_screen.set_pos(0, 50)
+ contacts_screen_list_screen.set_size(240, 270)
+ contacts_screen_list_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ contacts_screen_list_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ contacts_top_title = lv.label(contacts_screen)
+ contacts_top_title.set_pos(0, 10)
+ contacts_top_title.set_size(240, 40)
+ contacts_top_title.set_text("联系人")
+ contacts_top_title.set_long_mode(lv.label.LONG.WRAP)
+ contacts_top_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ contacts_top_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+ contact_none_label = lv.label(contacts_screen_list_screen)
+ contact_none_label.set_pos(0, 80)
+ contact_none_label.set_size(240, 50)
+ contact_none_label.set_text("无联系人,请在手机\nAPP上添加")
+ contact_none_label.set_long_mode(lv.label.LONG.WRAP)
+ contact_none_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ contact_none_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ self.contact_detail_list = lv.obj(contacts_screen_list_screen)
+ self.contact_detail_list.set_pos(0, 0)
+ self.contact_detail_list.set_size(240, 271)
+ self.contact_detail_list.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ self.contact_detail_list.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+ for i in range(self.MXA_phone_num):
+ contact_btn = lv.btn(self.contact_detail_list)
+ contact_btn.add_flag(lv.obj.FLAG.CLICKABLE)
+ contact_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.calling_cb(e)),
+ lv.EVENT.CLICKED, None)
+ contact_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.calling_cb(e)),
+ lv.EVENT.PRESSING, None)
+ contact_btn.add_flag(lv.obj.FLAG.HIDDEN)
+
+ contact_btn_label_1 = lv.label(contact_btn)
+ contact_btn_label_2 = lv.label(contact_btn)
+ contact_btn_label_3 = lv.label(contact_btn)
+ contact_btn.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+ contact_btn_label_1.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+ contact_btn_label_3.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ self.contact_detail_listt_dict.append({"contact_btn":contact_btn,"contact_btn_label_1":contact_btn_label_1,"contact_btn_label_2":contact_btn_label_2,"contact_btn_label_3":contact_btn_label_3})
+ self.meta = contacts_screen
+ self.count = 0
+ self.btn_create_list_show(0)
+
+ def btn_create_list(self,event,msg):
+ self.post_processor_before_initialization()
+ self.timer.start(1 * 1000, 0, self.OutTime_s)
+
+ def OutTime_s(self,e):
+ self.btn_create_list_show(1)
+
+ def btn_create_list_show(self,state):
+ EventMesh.publish("publish_message_event_ui",{"func":self.btn_create_list_show_screen,"data":state})
+
+ def btn_create_list_show_screen(self,state):
+ global contacts_screen,contacts_cont,contacts_top_title,contact_none_label,contacts_screen_list_screen
+ print("btn_create_list_show_screen!!!!!!!!!!!")
+ if contacts_screen == None:
+ return
+ #读取json文件中的键作为label文本;
+ if self.check_json == True and len(self.phonebook) != 0:
+ self.contact_detail_list.clear_flag(lv.obj.FLAG.HIDDEN)
+ contact_none_label.add_flag(lv.obj.FLAG.HIDDEN)#隐藏空文本
+ j =0
+ # print("self.phonebook sorted :{} len(self.phonebook) :{}".format(sorted(self.phonebook.keys()),len(self.phonebook)))
+ phonebook_keys = sorted(self.phonebook.keys())
+
+ # self.contact_detail_list.delete()#先删除一次控件
+ # self.contact_detail_list = lv.obj(contacts_screen_list_screen)
+ # self.contact_detail_list.set_pos(0, 0)
+ # self.contact_detail_list.set_size(240, 271)
+ # self.contact_detail_list.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ # self.contact_detail_list.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+ # print("self.phonebook sorted :{}".format(len(self.phonebook)))
+ if len(self.phonebook) > self.MXA_phone_num:
+ j = len(self.phonebook) - self.MXA_phone_num
+ for i in range(self.MXA_phone_num): #字典 key value
+ if(j >= len(self.phonebook)):
+ self.contact_detail_listt_dict[i]["contact_btn"].add_flag(lv.obj.FLAG.HIDDEN)
+ continue
+ name = self.phonebook[phonebook_keys[j]]
+ key_tmp = phonebook_keys[j]
+
+ # print("name :{} key_tmp:{}".format(name,key_tmp))
+
+ #contact_btn = lv.btn(self.contact_detail_list)
+ self.contact_detail_listt_dict[i]["contact_btn"].set_size(230,80)
+ self.contact_detail_listt_dict[i]["contact_btn"].set_pos(0,82*i )
+ #self.contact_detail_listt_dict[i]["contact_btn"].add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+ # contact_btn.add_style(style_contact_btn_pressed, lv.PART.MAIN | lv.STATE.PRESSED)
+ # self.contact_detail_listt_dict[i]["contact_btn"].add_event_cb(lambda e: EventMesh.callback_wrapper(self.calling(e)),
+ # lv.EVENT.CLICKED, None)
+
+ #contact_btn_label_1 = lv.label(contact_btn)
+ self.contact_detail_listt_dict[i]["contact_btn_label_1"].set_pos(0, 0)
+ self.contact_detail_listt_dict[i]["contact_btn_label_1"].set_size(180, 30)
+ self.contact_detail_listt_dict[i]["contact_btn_label_1"].set_text(key_tmp[4:])
+ self.contact_detail_listt_dict[i]["contact_btn_label_1"].set_long_mode(lv.label.LONG.DOT)
+ #self.contact_detail_listt_dict[i]["contact_btn_label_1"].add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ #contact_btn_label_2 = lv.label(contact_btn)
+ self.contact_detail_listt_dict[i]["contact_btn_label_2"].set_pos(0, 5)
+ self.contact_detail_listt_dict[i]["contact_btn_label_2"].set_size(0, 0)
+ self.contact_detail_listt_dict[i]["contact_btn_label_2"].set_text(key_tmp)
+
+
+ #contact_btn_label_3 = lv.label(contact_btn)
+ self.contact_detail_listt_dict[i]["contact_btn_label_3"].set_pos(0, 35)
+ self.contact_detail_listt_dict[i]["contact_btn_label_3"].set_size(220, 35)
+ self.contact_detail_listt_dict[i]["contact_btn_label_3"].set_text(name)
+ #self.contact_detail_listt_dict[i]["contact_btn_label_3"].add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+ self.contact_detail_listt_dict[i]["contact_btn"].clear_flag(lv.obj.FLAG.HIDDEN)
+ #self.contact_detail_listt_dict[i]["contact_btn"].scroll_to_view(lv.ANIM.OFF)
+ j+=1
+
+ if state == 1:
+ self.contact_detail_listt_dict[i]["contact_btn"].scroll_to_view(lv.ANIM.OFF)
+
+ else:
+ if contacts_screen_list_screen != None:
+ contact_none_label.clear_flag(lv.obj.FLAG.HIDDEN) #显示空文本
+ if self.contact_detail_list != None:
+ self.contact_detail_list.add_flag(lv.obj.FLAG.HIDDEN)#隐藏空文本
+
+ def calling_cb(self,e):
+ code = e.get_code()
+ if code == lv.EVENT.PRESSING:
+ #print("PRESSING")
+ self.is_sliding += 1
+
+ elif code == lv.EVENT.CLICKED:
+ #utime.sleep_ms(10)
+ print("1self.is_sliding",self.is_sliding)
+ if self.is_sliding <= 5 and self.is_sliding != 0:#如果是在滑动中则不需要点击事件
+ self.is_sliding = 0
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#有卡时触发sos报警 无卡时自动关机
+ msg_text = e.get_target().get_child(1).get_text()
+ EventMesh.publish("publish_message_event_ui",{"func":self.calling,"data":msg_text})
+ else:
+ EventMesh.publish("load_screen", {"screen": "no_sim_popup_screen"})
+ self.is_sliding =0
+
+ def calling(self,msg_text):
+ _msg = msg_text
+ print("contacts:calling_cb1:{}".format(_msg))
+ # print("_msg:{}".format(_msg))
+ msg_tmp = _msg.split(':')
+ msg_tmp = msg_tmp[1]
+ EventMesh.publish("save_phonename", msg_tmp)
+
+ phone_num = self.phonebook[_msg]
+ EventMesh.publish("save_phonenum", phone_num)
+
+ # phone_num_tmp = int(phone_num)
+
+ EventMesh.publish("load_screen", {"screen": "dialing_noplay_popup"})
+
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+ # EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+# -------------------------------------------temperature screen----------------------------------------------------------
+
+temperature_screen = None
+temperature_bg_img = None
+temperature_body_label = None
+temperature_degree_img = None
+temperature_value_label = None
+temperature_wrist_label = None
+temperature_wrist_degree_img = None
+temperature_wrist_value_label = None
+temperature_measure_end_label = None
+temperature_measure_countdown_label = None
+temp_reset_btn_img = None
+temp_line1 = None
+temp_line2 = None
+temp_line3 = None
+temp_line4 = None
+temp_line5 = None
+temp_line6 = None
+temp_line7 = None
+temperature_label = None
+temperature_line_bg_img = None
+temperature_done_img = None
+temperature_start_label=None
+temperature_bpm_label = None
+temperature_done_label = None
+temperature_keep_label = None
+
+style_line_blue = lv.style_t()
+style_line_blue.init()
+style_line_blue.set_line_width(10)
+style_line_blue.set_line_color(lv.color_make(35, 141, 255))
+
+class TemperatureScreen(Screen):
+ NAME = "temperature"
+
+
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.timer = osTimer()
+ self.point = 0
+ self.temp_value = 0
+ self.temp_data_old = 0
+ EventMesh.subscribe("show_history_temp_data",self.show_history_temp_data)
+
+ def initialization(self):
+ global temperature_screen,temperature_keep_label,temperature_label,temp_reset_btn_img,temp_line1,temp_line2,temp_line3,temp_line4,temp_line5,\
+ temp_line6,temp_line7,temperature_line_bg_img,temperature_done_img ,temperature_start_label,temperature_bpm_label ,temperature_done_label
+ if temperature_screen == None:
+ temperature_screen = lv.obj()
+ print("temp_screen")
+ temperature_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ temperature_label = lv.label(temperature_screen)
+ temperature_label.set_pos(0, 10)
+ temperature_label.set_size(240, 40)
+ temperature_label.set_text("体温")
+ temperature_label.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
+ temperature_label.set_long_mode(lv.label.LONG.WRAP)
+ temperature_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ temperature_line_bg_img = lv.img(temperature_screen)
+ temperature_line_bg_img.set_pos(5, 50)
+ temperature_line_bg_img.set_size(230, 120)
+ temperature_line_bg_img.set_src("E:/static/temp_line_bg.png")
+
+
+ temperature_done_img = lv.img(temperature_screen)
+ temperature_done_img.set_pos(20, 226)
+ temperature_done_img.set_src("E:/static/temp_gif03.png")
+
+ temp_reset_btn_img = lv.img(temperature_screen)
+ temp_reset_btn_img.set_pos(0, 182)
+ temp_reset_btn_img.set_src("E:/static/reset_hr_btn.png")
+ temp_reset_btn_img.add_flag(lv.obj.FLAG.HIDDEN)
+ temp_reset_btn_img.add_flag(lv.obj.FLAG.CLICKABLE)
+
+ temperature_start_label = lv.label(temperature_screen)
+ temperature_start_label.set_size(240,40)
+ temperature_start_label.set_pos(0,190)
+ temperature_start_label.set_text("正在测量中.")
+ temperature_start_label.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
+ temperature_start_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ temperature_start_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+
+ # hr_line_points1 = [{"x":0,"y":0},{"x":0,"y":30}]
+ # hr_line_points2 = [{"x":0,"y":0},{"x":0,"y":47}]
+ # hr_line_points3 = [{"x":0,"y":0},{"x":0,"y":67}]
+ # hr_line_points4 = [{"x":0,"y":0},{"x":0,"y":85}]
+ # hr_line_points5 = [{"x":0,"y":0},{"x":0,"y":100}]
+ # hr_line_points6 = [{"x":0,"y":0},{"x":0,"y":100}]
+ # hr_line_points7 = [{"x":0,"y":0},{"x":0,"y":100}]
+
+ temp_line1 = lv.line(temperature_screen)
+ temp_line1.set_points(hr_line_points,2)
+ temp_line1.set_pos(29,120)
+ temp_line1.set_size(10,0)
+ temp_line1.add_style(style_line_blue,0)
+
+ temp_line2 = lv.line(temperature_screen)
+ temp_line2.set_points(hr_line_points,2)
+ temp_line2.set_pos(57,103)
+ temp_line2.set_size(10,0)
+ temp_line2.add_style(style_line_blue,0)
+
+ temp_line3 = lv.line(temperature_screen)
+ temp_line3.set_points(hr_line_points,2)
+ temp_line3.set_pos(84,82)
+ temp_line3.set_size(10,0)
+ temp_line3.add_style(style_line_blue,0)
+
+ temp_line4 = lv.line(temperature_screen)
+ temp_line4.set_points(hr_line_points,2)
+ temp_line4.set_pos(110,66)
+ temp_line4.set_size(10,0)
+ temp_line4.add_style(style_line_blue,0)
+
+ temp_line5 = lv.line(temperature_screen)
+ temp_line5.set_points(hr_line_points,2)
+ temp_line5.set_pos(140,50)
+ temp_line5.set_size(10,0)
+ temp_line5.add_style(style_line_blue,0)
+
+ temp_line6 = lv.line(temperature_screen)
+ temp_line6.set_points(hr_line_points,2)
+ temp_line6.set_pos(167,50)
+ temp_line6.set_size(10,0)
+ temp_line6.add_style(style_line_blue,0)
+
+ temp_line7 = lv.line(temperature_screen)
+ temp_line7.set_points(hr_line_points,2)
+ temp_line7.set_pos(195,50)
+ temp_line7.set_size(10,0)
+ temp_line7.add_style(style_line_blue,0)
+
+ temperature_bpm_label = lv.label(temperature_screen)
+ temperature_bpm_label.set_size(240-100, 40)
+ temperature_bpm_label.set_pos(100, 249)
+ temperature_bpm_label.set_text("- -℃")
+ temperature_bpm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ temperature_bpm_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+
+ temperature_keep_label = lv.label(temperature_screen)
+ temperature_keep_label.set_size(140, 35)
+ temperature_keep_label.set_pos(100, 285)
+ temperature_keep_label.set_text("未出值")
+ temperature_keep_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ temperature_keep_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+
+ #35 246 42
+ # temperature_degree_img = lv.img(temperature_screen)
+ # temperature_degree_img.set_pos(156, 242)
+ # temperature_degree_img.set_size(22, 22)
+ # temperature_degree_img.set_src("U:/static/degree.png")
+ # temperature_degree_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+ self.meta = temperature_screen
+ temp_reset_btn_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.restart_up(e)),
+ lv.EVENT.CLICKED, None)
+
+ temperature_bpm_label.set_text("- -℃")
+ temperature_start_label.set_text("正在测量中.")
+ self.temp_data_old = 0
+
+
+ def post_processor_after_initialization(self):
+ self.restart_up(0)
+
+ def restart_up(self,e):
+ global temperature_done_label,temperature_keep_label,temperature_bpm_label,temperature_start_label,temp_reset_btn_img
+ temperature_bpm_label.set_text("- -℃")
+ temperature_keep_label.set_text("未出值")
+ temp_reset_btn_img.add_flag(lv.obj.FLAG.HIDDEN)
+ self.point = 0
+ temperature_bpm_label.set_text("- -℃")
+ temperature_start_label.set_text("正在测量中.")
+ EventMesh.publish("set_temp_state",1)
+ EventMesh.publish(constants.EVENT.START_TEMP)
+ EventMesh.publish("show_history_temp_data")
+ self.temp_data_old = 0
+ self.timer.start(1*500, 1, self.start_measure)
+
+ def show_history_temp_data(self,event,msg):
+ global temp_line1,temp_line2,temp_line3,temp_line4,temp_line5,temp_line6,temp_line7,temperature_screen
+ if temperature_screen == None:
+ return
+ read_data = {}
+ read_data = EventMesh.publish("get_history_temp_value")
+ # print("hr get_history_temp_value",read_data)
+ if len(read_data) != 0:
+ sort_new = {}
+ sort_new = sorted(read_data, key = lambda i: i['timeSec'],reverse = False)#按照时间戳进行排序 去掉最旧的一次数据如果满了五
+ count = len(sort_new)
+ if count != 0:
+ for i in range(count):
+ # print(int(sort_new[i]["temp"]))
+ # print("hr history read_data",read_data)
+ value = int(sort_new[i]["temp"])
+ value_temp = int(value)
+ if value <= 30:
+ line_value = int(value_temp)
+ elif value <= 34:
+ line_value = int((value_temp-30)*4.25)+30
+ elif value <= 38:
+ line_value = int((value_temp-34)*5)+47
+ elif value <= 42:
+ line_value = int((value_temp-38)*4)+67
+ elif value < 46:
+ line_value = int((value_temp-42)*3.75)+85
+ else:
+ value = 46
+ line_value = 100
+
+ if line_value >= 100:
+ line_value = 100
+ #print("hr hist",line_value)
+ temp_line_points = [{"x":0,"y":0},{"x":0,"y":line_value}]
+ if i == 0:
+ temp_line1.set_points(temp_line_points,2)
+ temp_line1.set_pos(29,150-line_value)
+ temp_line1.set_size(10,line_value)
+ if value >= 37.3:
+ temp_line1.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
+ else:
+ temp_line1.set_style_line_color(lv.color_make(35,141,255),0)
+ if i == 1:
+ temp_line2.set_points(temp_line_points,2)
+ temp_line2.set_pos(57,150-line_value)
+ temp_line2.set_size(10,line_value)
+ if value >= 37.3:
+ temp_line2.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
+ else:
+ temp_line2.set_style_line_color(lv.color_make(35,141,255),0)
+
+ if i == 2:
+ temp_line3.set_points(temp_line_points,2)
+ temp_line3.set_pos(84,150-line_value)
+ temp_line3.set_size(10,line_value)
+ if value >= 37.3:
+ temp_line3.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
+ else:
+ temp_line3.set_style_line_color(lv.color_make(35,141,255),0)
+ if i == 3:
+ temp_line4.set_points(temp_line_points,2)
+ temp_line4.set_pos(112,150-line_value)
+ temp_line4.set_size(10,line_value)
+ if value >= 37.3:
+ temp_line4.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
+ else:
+ temp_line4.set_style_line_color(lv.color_make(35,141,255),0)
+ if i == 4:
+ temp_line5.set_points(temp_line_points,2)
+ temp_line5.set_pos(140,150-line_value)
+ temp_line5.set_size(10,line_value)
+ if value >= 37.3:
+ temp_line5.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
+ else:
+ temp_line5.set_style_line_color(lv.color_make(35,141,255),0)
+
+ if i == 5:
+ temp_line6.set_points(temp_line_points,2)
+ temp_line6.set_pos(167,150-line_value)
+ temp_line6.set_size(10,line_value)
+ if value >= 37.3:
+ temp_line6.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
+ else:
+ temp_line6.set_style_line_color(lv.color_make(35,141,255),0)
+
+ if i == 6:
+ temp_line7.set_points(temp_line_points,2)
+ temp_line7.set_pos(195,150-line_value)
+ temp_line7.set_size(10,line_value)
+ if value >= 37.3:
+ temp_line7.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
+ else:
+ temp_line7.set_style_line_color(lv.color_make(35,141,255),0)
+
+ def start_measure(self,*args):
+ EventMesh.publish("publish_message_event_ui",{"func":self.start_measure_do,"data":0})
+ def start_measure_do(self,data):
+ global temperature_label,temperature_keep_label,temperature_done_img ,temp_reset_btn_img,temperature_start_label,temperature_bpm_label ,temperature_done_label
+ self.point = self.point + 1
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ WEAR = EventMesh.publish(constants.EVENT.GET_WEAR)#佩戴数据
+ temp_data = EventMesh.publish("optimize_temp")
+ if temp_data == None:
+ temp_data = 0
+
+
+ # print("self.temp:{}".format(temp))
+ if self.point >= 10 and self.point % 10 == 0:
+ self.temp_data_old = temp_data
+ tmp = temp_data
+ if WEAR == 0:
+ tmp = 0
+ self.temp_data_old = 0
+ if tmp != 0 and WEAR == 1:
+ tmp_data = tmp
+ if str(tmp).find(".") != -1:
+ tmp_data = str(tmp).split('.')[0] + '.' + str(tmp).split('.')[1][:1]#获取小数点后一位 舍去小数点最后一位
+ temperature_bpm_label.set_text("{} ℃".format(tmp_data))
+ else:
+ temperature_bpm_label.set_text("- -℃")
+ if self.temp_data_old >= 37.3:
+ temperature_keep_label.set_text("体温偏高")
+ temperature_keep_label.set_style_text_color(lv.color_make(0xff, 0x00, 0x00), lv.STATE.DEFAULT)
+ elif self.temp_data_old == 0:
+ temperature_keep_label.set_text(" ")
+ temperature_keep_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+ else:
+ temperature_keep_label.set_text("体温正常")
+ temperature_keep_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+ temp = self.temp_data_old
+
+ if self.point%4 == 0 :
+ temperature_start_label.set_text("正在测量中..")
+ temperature_done_img.set_src("E:/static/temp_gif02.png")
+ if self.point%4 == 1 :
+ temperature_start_label.set_text("正在测量中...")
+ temperature_done_img.set_src("E:/static/temp_gif01.png")
+ if self.point%4 == 2 :
+ temperature_start_label.set_text("正在测量中.")
+ temperature_done_img.set_src("E:/static/temp_gif02.png")
+
+ if self.point%4 == 3 :
+ temperature_start_label.set_text("正在测量中.")
+ temperature_done_img.set_src("E:/static/temp_gif03.png")
+
+ tmp_f_tmp = 0
+ tmp_d_tmp = 0
+ if str(temp).find(".") != -1:
+ tmp_f = str(temp).split('.')[0]
+ tmp_f_tmp = int(tmp_f)
+
+ tmp_d = str(temp).split('.')[1][:1]
+ tmp_d_tmp = int(tmp_d)
+ else:
+ tmp_f_tmp = temp
+
+ if self.point > 120 or (WEAR == 0 and self.point > 10): #测2min
+ self.timer.stop()
+ if WEAR == 0:
+ temp = 0
+ temperature_start_label.set_text("佩戴异常,点击重测")
+ temperature_bpm_label.set_text("- -℃")
+ temperature_keep_label.set_text(" ")
+ temperature_keep_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+ else :
+ temperature_start_label.set_text("测量结束,点击重测")
+ EventMesh.publish("set_history_temp_value",temp)
+ EventMesh.publish(constants.PROTOCOL.TEMP_SEND,[tmp_f_tmp,tmp_d_tmp])
+ num = str(tmp_f_tmp)+"."+ str(tmp_d_tmp)
+ EventMesh.publish(constants.PROTOCOL.BTEMP2_SEND,[1,num])
+ if temp >= 37.3:
+ temperature_done_img.set_src("E:/static/temp_high.png")
+ else:
+ temperature_done_img.set_src("E:/static/temp_gif03.png")
+ temp_reset_btn_img.clear_flag(lv.obj.FLAG.HIDDEN)
+
+ # self.show_history_data()
+
+ self.point = 0
+ EventMesh.publish("set_temp_state",0)
+
+ EventMesh.publish(constants.EVENT.STOP_TEMP)
+
+
+ print("stop debug9")
+
+ def Close(self):
+ self.timer.stop()
+ EventMesh.publish("set_temp_state",0)
+ EventMesh.publish(constants.EVENT.STOP_TEMP)
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
+
+line_points = [{"x":0,"y":0},{"x":240,"y":0}]
+spo2_screen = None
+spo2_label_0 = None
+spo2_done_img = None
+spo2_label = None
+spo2_label_1 = None
+spo2_line = None
+spo2_last_time = None
+spo2_last_value = None
+spo2_line1 = None
+spo2_line2 = None
+spo2_line3 = None
+spo2_line4 = None
+spo2_line5 = None
+spo2_line6 = None
+spo2_line7 = None
+spo2_reset_btn_img = None
+spo2_label = None
+spo2_line_bg_img = None
+spo2_done_img = None
+spo2_done_label = None
+spo2_value_label = None
+spo2_start_label = None
+
+style_line_red = lv.style_t()
+style_line_red.init()
+style_line_red.set_line_width(10)
+style_line_red.set_line_color(lv.color_make(0xff, 0x00, 0x00))
+
+spo2_line_points = [{"x":0,"y":0},{"x":0,"y":0}]
+
+class Spo2Screen(Screen):
+ NAME = "spo2"
+
+
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.timer = osTimer()
+ self.point = 0
+ self.spo2_value = 0
+ #self.Hsensor = None
+ EventMesh.subscribe("show_history_spo2_data",self.show_history_spo2_data)
+
+ def initialization(self):
+ global spo2_screen,spo2_label,spo2_value_label,spo2_reset_btn_img,spo2_done_img,spo2_line_bg_img,spo2_line1,spo2_line2,\
+ spo2_line3,spo2_line4,spo2_line5,spo2_line6,spo2_line7,spo2_line_bg_img ,spo2_start_label ,spo2_done_label
+ if spo2_screen == None:
+ spo2_screen = lv.obj()
+ print("spo2_screen")
+ spo2_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ spo2_label = lv.label(spo2_screen)
+ spo2_label.set_pos(0, 20)
+ spo2_label.set_size(240, 40)
+ spo2_label.set_text("血氧")
+ spo2_label.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
+ spo2_label.set_long_mode(lv.label.LONG.WRAP)
+ spo2_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ spo2_line_bg_img = lv.img(spo2_screen)
+ spo2_line_bg_img.set_pos(5, 60)
+ spo2_line_bg_img.set_size(230, 120)
+ spo2_line_bg_img.set_src("E:/static/spo2_line_bg.png")
+
+
+ spo2_done_img = lv.img(spo2_screen)
+ spo2_done_img.set_pos(20, 240)
+ spo2_done_img.set_src("E:/static/spo2_gif04.png")
+
+ spo2_reset_btn_img = lv.img(spo2_screen)
+ spo2_reset_btn_img.set_pos(0, 192)
+ spo2_reset_btn_img.set_src("E:/static/reset_hr_btn.png")
+ spo2_reset_btn_img.add_flag(lv.obj.FLAG.HIDDEN)
+ spo2_reset_btn_img.add_flag(lv.obj.FLAG.CLICKABLE)
+
+ spo2_start_label = lv.label(spo2_screen)
+ spo2_start_label.set_size(240,40)
+ spo2_start_label.set_pos(0,200)
+ spo2_start_label.set_text("正在测量中.")
+ spo2_start_label.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
+ spo2_start_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ spo2_start_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+
+
+ spo2_line1 = lv.line(spo2_screen)
+ spo2_line1.set_points(spo2_line_points,2)
+ spo2_line1.set_pos(25,60)
+ spo2_line1.set_size(10,0)
+ spo2_line1.add_style(style_line_red,0)
+
+ spo2_line2 = lv.line(spo2_screen)
+ spo2_line2.set_points(spo2_line_points,2)
+ spo2_line2.set_pos(53,60)
+ spo2_line2.set_size(10,0)
+ spo2_line2.add_style(style_line_red,0)
+
+ spo2_line3 = lv.line(spo2_screen)
+ spo2_line3.set_points(spo2_line_points,2)
+ spo2_line3.set_pos(80,60)
+ spo2_line3.set_size(10,0)
+ spo2_line3.add_style(style_line_red,0)
+
+ spo2_line4 = lv.line(spo2_screen)
+ spo2_line4.set_points(spo2_line_points,2)
+ spo2_line4.set_pos(109,60)
+ spo2_line4.set_size(10,0)
+ spo2_line4.add_style(style_line_red,0)
+
+ spo2_line5 = lv.line(spo2_screen)
+ spo2_line5.set_points(spo2_line_points,2)
+ spo2_line5.set_pos(136,60)
+ spo2_line5.set_size(10,0)
+ spo2_line5.add_style(style_line_red,0)
+
+ spo2_line6 = lv.line(spo2_screen)
+ spo2_line6.set_points(spo2_line_points,2)
+ spo2_line6.set_pos(164,60)
+ spo2_line6.set_size(10,0)
+ spo2_line6.add_style(style_line_red,0)
+
+ spo2_line7 = lv.line(spo2_screen)
+ spo2_line7.set_points(spo2_line_points,2)
+ spo2_line7.set_pos(192,60)
+ spo2_line7.set_size(10,0)
+ spo2_line7.add_style(style_line_red,0)
+
+ spo2_value_label = lv.label(spo2_screen)
+ spo2_value_label.set_size(110, 40)
+ spo2_value_label.set_pos(130, 270)
+ spo2_value_label.set_text("- -%")
+ spo2_value_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ spo2_value_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+
+
+ self.meta = spo2_screen
+ spo2_reset_btn_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.restart_up(e)),
+ lv.EVENT.CLICKED, None)
+
+ def post_processor_after_initialization(self):
+ self.point = 0
+ self.spo2_value = 0
+ EventMesh.publish("show_history_spo2_data")
+ self.restart_up(0)
+
+ def restart_up(self,e):
+ global spo2_value_label,heartrate_bpm_label,spo2_start_label,spo2_reset_btn_img
+ self.point = 0
+ self.timer.start(1*500, 1, self.start_measure)
+ if spo2_reset_btn_img != None:
+ spo2_reset_btn_img.add_flag(lv.obj.FLAG.HIDDEN)
+
+
+ spo2_value_label.set_text("- -%")
+ spo2_start_label.set_text("正在测量中.")
+ EventMesh.publish("set_spo2_state",1)#2代表后台进入血氧测试
+ EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)
+
+ def show_history_spo2_data(self,event,msg):
+ global spo2_line1,spo2_line2,spo2_line3,spo2_line4,spo2_line5,spo2_line6,spo2_line7
+ if spo2_screen == None:
+ return
+ read_data = {}
+ read_data = EventMesh.publish("get_history_spo2_value")
+ # print("hr get_history_spo2_value",read_data)
+ if len(read_data) != 0:
+ sort_new = {}
+ sort_new = sorted(read_data, key = lambda i: i['timeSec'],reverse = False)#按照时间戳进行排序 去掉最旧的一次数据如果满了五
+ count = len(sort_new)
+ if count != 0:
+ for i in range(count):
+ print(int(sort_new[i]["spo2"]))
+ # print("hr history read_data",read_data)
+ value = int(sort_new[i]["spo2"])
+ if value < 80:
+ value = 80
+ if value >= 100:
+ value = 100
+ if value <= 85:
+ value = value - 80
+ line_value = int(value*6)
+ elif value <= 90:
+ value = value-85
+ line_value = int((17/5)*value)+30
+ elif value <= 95:
+ value = value-90
+ line_value = int((21/5)*value)+47
+ elif value <= 100:
+ value = value-95
+ line_value = int((16/5)*value)+68
+
+
+ if line_value >= 100:
+ line_value = 100
+ #print("hr hist",line_value)
+ hr_line_points = [{"x":0,"y":0},{"x":0,"y":line_value}]
+ if i == 0:
+ spo2_line1.set_points(hr_line_points,2)
+ spo2_line1.set_pos(25,160-line_value)
+ spo2_line1.set_size(10,line_value)
+ if i == 1:
+ spo2_line2.set_points(hr_line_points,2)
+ spo2_line2.set_pos(53,160-line_value)
+ spo2_line2.set_size(10,line_value)
+
+ if i == 2:
+ spo2_line3.set_points(hr_line_points,2)
+ spo2_line3.set_pos(80,160-line_value)
+ spo2_line3.set_size(10,line_value)
+
+ if i == 3:
+ spo2_line4.set_points(hr_line_points,2)
+ spo2_line4.set_pos(109,160-line_value)
+ spo2_line4.set_size(10,line_value)
+
+ if i == 4:
+ spo2_line5.set_points(hr_line_points,2)
+ spo2_line5.set_pos(136,160-line_value)
+ spo2_line5.set_size(10,line_value)
+
+ if i == 5:
+ spo2_line6.set_points(hr_line_points,2)
+ spo2_line6.set_pos(164,160-line_value)
+ spo2_line6.set_size(10,line_value)
+
+ if i == 6:
+ spo2_line7.set_points(hr_line_points,2)
+ spo2_line7.set_pos(192,160-line_value)
+ spo2_line7.set_size(10,line_value)
+
+ def start_measure(self,*args):
+ EventMesh.publish("publish_message_event_ui",{"func":self.start_measure_do,"data":0})
+ def start_measure_do(self,data):
+ global spo2_screen,spo2_label,spo2_start_label,spo2_value_label,spo2_done_img ,spo2_reset_btn_img
+ self.point = self.point + 1
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ WEAR = EventMesh.publish(constants.EVENT.GET_WEAR)#佩戴数据
+ # if self.Hsensor == None:
+ # self.Hsensor = EventMesh.publish("get_Hsensor")
+ # c_data = self.Hsensor.get_test_data()#校准数据和工厂数据
+ # print(" 佩戴状态\n红外:{}活体:{}佩戴:{}\n{},{} \n{},{} \n{},{}\n校准数据:{},{},{},{}\n漏光数据:{},{},{}"
+ # .format(c_data[3],c_data[4],WEAR,c_data[5],c_data[6],c_data[7],c_data[8],c_data[9],c_data[10],
+ # c_data[11],c_data[12],c_data[13],c_data[14],c_data[0],c_data[1],c_data[2],))
+ # print("sop2:start_measure:point{}".format(self.point))
+ self.spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
+ if self.point >= 2:
+ if self.spo2_value != 0:
+ spo2_value_label.set_text("{}%".format(self.spo2_value))
+ else:
+ spo2_value_label.set_text("- - %")
+
+ if self.point%4 == 0 :
+ spo2_start_label.set_text("正在测量中..")
+ spo2_done_img.set_src("E:/static/spo2_gif03.png")
+
+ if self.point%4 == 1 :
+ spo2_start_label.set_text("正在测量中...")
+ spo2_done_img.set_src("E:/static/spo2_gif02.png")
+
+ if self.point%4 == 2 :
+ spo2_start_label.set_text("正在测量中.")
+ spo2_done_img.set_src("E:/static/spo2_gif01.png")
+
+ if self.point%4 == 3 :
+ spo2_start_label.set_text("正在测量中.")
+ spo2_done_img.set_src("E:/static/spo2_gif04.png")
+
+
+
+ if self.point > 120 or (WEAR == 0 and self.point > 10): #测60s
+ self.timer.stop()
+ spo2_done_img.set_src("E:/static/spo2_gif04.png")
+ self.spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
+ if WEAR == 0:
+ self.spo2_value = 0
+ spo2_start_label.set_text("佩戴异常,点击重测")
+ else :
+ spo2_start_label.set_text("测量结束,点击重测")
+
+ if self.spo2_value >= 85:
+ EventMesh.publish("set_old_spo2_data",self.spo2_value)
+ EventMesh.publish("set_history_spo2_value",self.spo2_value)
+ EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,self.spo2_value)
+ spo2_reset_btn_img.clear_flag(lv.obj.FLAG.HIDDEN)
+
+
+
+ if self.spo2_value != 0:
+ spo2_value_label.set_text("{}%".format(self.spo2_value))
+ # heartrate_done_label.set_text("测量完成")
+ else:
+ spo2_value_label.set_text("- - %")
+
+
+ # self.show_history_data()
+
+ self.point = 0
+ EventMesh.publish("set_spo2_state",0)#0代表关闭测试
+ print("stop debug9")
+ EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
+
+ def Close(self):
+ self.timer.stop()
+ get_hr_state = EventMesh.publish("get_hr_state")
+ get_spo2_state = EventMesh.publish("get_spo2_state")
+ if get_hr_state == 1 or get_spo2_state == 1:
+ EventMesh.publish("set_spo2_state",0)#0代表关闭测试
+ EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
+
+
+
+
+
+
+# -------------------------------------------countdown screen----------------------------------------------------------
+countdown_screen = None
+countdown_title = None
+countdown_hour = None
+countdown_mao = None
+countdown_mao = None
+countdown_mao1 = None
+countdown_sec = None
+countdown_hour_up = None
+countdown_hour_up_btn = None
+countdown_hour_down = None
+countdown_hour_down_btn = None
+countdown_min_up = None
+countdown_min_up_btn = None
+countdown_min_down = None
+countdown_min_down_btn = None
+countdown_sec_up = None
+countdown_sec_up_btn = None
+countdown_sec_down = None
+countdown_sec_down_btn = None
+countdown_reset_img = None
+countdown_reset_imgbtn = None
+countdown_start_img = None
+countdown_start_imgbtn = None
+countdown_stop_img = None
+countdown_min = None
+class CountdownScreen(Screen):
+ NAME = "countdown"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.timer = osTimer()
+ self.sec = 0
+ self.min = 0
+ self.hour = 0
+ self.total = 0
+ self.flag = 1
+ self.g_state = 0
+ self.g_end = 0
+ self.total = 0
+ self.time_tmp = 0
+ self.timer_cb = 0
+ EventMesh.subscribe("close_count_show_info", self.close_count_show_info)
+
+ def initialization(self):
+ global countdown_screen ,countdown_title,countdown_hour ,countdown_mao ,countdown_mao ,countdown_mao1 ,\
+ countdown_sec ,countdown_hour_up ,countdown_hour_up_btn ,countdown_hour_down ,countdown_hour_down_btn ,\
+ countdown_min_up,countdown_min_up_btn ,countdown_min_down,countdown_min_down_btn,countdown_sec_up ,\
+ countdown_sec_up_btn,countdown_sec_down ,countdown_sec_down_btn ,countdown_reset_img ,countdown_reset_imgbtn ,\
+ countdown_start_img,countdown_start_imgbtn,countdown_stop_img ,countdown_min
+ if countdown_screen == None :
+ countdown_screen = lv.obj()
+ print("countdown_screen")
+ countdown_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ countdown_title = lv.label(countdown_screen)
+ countdown_title.set_pos(0, 20)
+ countdown_title.set_size(240, 20)
+ countdown_title.set_text("倒计时")
+ countdown_title.set_long_mode(lv.label.LONG.WRAP)
+ countdown_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ countdown_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ countdown_hour = lv.label(countdown_screen)
+ countdown_hour.set_pos(30, 140)
+ countdown_hour.set_size(60, 30)
+ countdown_hour.set_text("00")
+ countdown_hour.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
+ countdown_hour.set_long_mode(lv.label.LONG.WRAP)
+ countdown_hour.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+
+ countdown_mao = lv.label(countdown_screen)
+ countdown_mao.set_pos(82, 138)
+ countdown_mao.set_size(30, 30)
+ countdown_mao.set_text(":")
+ countdown_mao.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
+ countdown_mao.set_long_mode(lv.label.LONG.WRAP)
+ countdown_mao.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+
+
+ countdown_min = lv.label(countdown_screen)
+ countdown_min.set_pos(95, 140)
+ countdown_min.set_size(60, 30)
+ countdown_min.set_text("00")
+ countdown_min.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
+ countdown_min.set_long_mode(lv.label.LONG.WRAP)
+ countdown_min.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+
+ countdown_mao1 = lv.label(countdown_screen)
+ countdown_mao1.set_pos(146, 138)
+ countdown_mao1.set_size(30, 30)
+ countdown_mao1.set_text(":")
+ countdown_mao1.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
+ countdown_mao1.set_long_mode(lv.label.LONG.WRAP)
+ countdown_mao1.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+
+
+ countdown_sec = lv.label(countdown_screen)
+ countdown_sec.set_pos(160, 140)
+ countdown_sec.set_size(60, 30)
+ countdown_sec.set_text("00")
+ countdown_sec.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
+ countdown_sec.set_long_mode(lv.label.LONG.WRAP)
+ countdown_sec.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+
+ countdown_hour_up = lv.img(countdown_screen)
+ countdown_hour_up.set_size(34, 30)
+ countdown_hour_up.set_pos(36, 100)
+ countdown_hour_up.set_src("E:/static/time_up.png")
+ countdown_hour_up.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ countdown_hour_up_btn= lv.img(countdown_screen)
+ countdown_hour_up_btn.set_size(62, 70)
+ countdown_hour_up_btn.set_pos(20, 80)
+ countdown_hour_up_btn.add_flag(lv.obj.FLAG.CLICKABLE)
+
+
+ countdown_hour_down = lv.img(countdown_screen)
+ countdown_hour_down.set_size(34, 30)
+ countdown_hour_down.set_pos(36, 180)
+ countdown_hour_down.set_src("E:/static/time_down.png")
+ countdown_hour_down.add_flag(lv.obj.FLAG.CLICKABLE)
+ countdown_hour_down.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ countdown_hour_down_btn= lv.img(countdown_screen)
+ countdown_hour_down_btn.set_size(62, 80)
+ countdown_hour_down_btn.set_pos(20, 150)
+ countdown_hour_down_btn.add_flag(lv.obj.FLAG.CLICKABLE)
+
+
+ countdown_min_up = lv.img(countdown_screen)
+ countdown_min_up.set_size(34, 30)
+ countdown_min_up.set_pos(99, 100)
+ countdown_min_up.set_src("E:/static/time_up.png")
+ countdown_min_up.add_flag(lv.obj.FLAG.CLICKABLE)
+ countdown_min_up.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ countdown_min_up_btn= lv.img(countdown_screen)
+ countdown_min_up_btn.set_size(64, 70)
+ countdown_min_up_btn.set_pos(82, 80)
+ countdown_min_up_btn.add_flag(lv.obj.FLAG.CLICKABLE)
+
+
+
+ countdown_min_down = lv.img(countdown_screen)
+ countdown_min_down.set_size(34, 30)
+ countdown_min_down.set_pos(99, 180)
+ countdown_min_down.set_src("E:/static/time_down.png")
+ countdown_min_down.add_flag(lv.obj.FLAG.CLICKABLE)
+ countdown_min_down.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ countdown_min_down_btn= lv.img(countdown_screen)
+ countdown_min_down_btn.set_size(64, 80)
+ countdown_min_down_btn.set_pos(82, 150)
+ countdown_min_down_btn.add_flag(lv.obj.FLAG.CLICKABLE)
+
+
+ countdown_sec_up = lv.img(countdown_screen)
+ countdown_sec_up.set_size(34, 30)
+ countdown_sec_up.set_pos(165, 100)
+ countdown_sec_up.set_src("E:/static/time_up.png")
+ countdown_sec_up.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ countdown_sec_up_btn = lv.img(countdown_screen)
+ countdown_sec_up_btn.set_size(64, 70)
+ countdown_sec_up_btn.set_pos(146, 80)
+ countdown_sec_up_btn.add_flag(lv.obj.FLAG.CLICKABLE)
+
+ countdown_sec_down = lv.img(countdown_screen)
+ countdown_sec_down.set_size(34, 30)
+ countdown_sec_down.set_pos(165, 180)
+ countdown_sec_down.set_src("E:/static/time_down.png")
+ countdown_sec_down.add_flag(lv.obj.FLAG.CLICKABLE)
+ countdown_sec_down.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ countdown_sec_down_btn = lv.img(countdown_screen)
+ countdown_sec_down_btn.set_size(64, 80)
+ countdown_sec_down_btn.set_pos(146, 150)
+ countdown_sec_down_btn.add_flag(lv.obj.FLAG.CLICKABLE)
+
+ countdown_reset_img = lv.img(countdown_screen)
+ countdown_reset_img.set_size(99, 36)
+ countdown_reset_img.set_src("E:/static/stopwatch_reset.png")
+ countdown_reset_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ countdown_reset_img.set_pos(10, 260)
+
+ countdown_reset_imgbtn = lv.img(countdown_screen)
+ countdown_reset_imgbtn.set_size(99, 70)
+ countdown_reset_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
+ countdown_reset_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ countdown_reset_imgbtn.set_pos(10, 240)
+
+
+
+ countdown_start_img = lv.img(countdown_screen)
+ countdown_start_img.set_size(99, 36)
+ countdown_start_img.set_src("E:/static/stopwatch_play.png")
+ countdown_start_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ countdown_start_img.set_pos(120, 260)
+
+ countdown_start_imgbtn = lv.img(countdown_screen)
+ countdown_start_imgbtn.set_size(99, 70)
+ countdown_start_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
+ countdown_start_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ countdown_start_imgbtn.set_pos(120, 240)
+
+
+
+ countdown_stop_img = lv.img(countdown_screen)
+ countdown_stop_img.set_size(99, 36)
+ countdown_stop_img.set_src("E:/static/stopwatch_stop.png")
+ countdown_stop_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ countdown_stop_img.set_pos(120, 260)
+ countdown_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
+ countdown_start_img.clear_flag(lv.obj.FLAG.HIDDEN)
+
+ countdown_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
+ countdown_reset_img.clear_flag(lv.obj.FLAG.HIDDEN)
+
+ self.meta = countdown_screen
+
+ countdown_sec_up_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.sec_up(e)),
+ lv.EVENT.CLICKED, None)
+ countdown_sec_down_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.sec_down(e)),
+ lv.EVENT.CLICKED, None)
+ countdown_min_up_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.min_up(e)),
+ lv.EVENT.CLICKED, None)
+ countdown_min_down_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.min_down(e)),
+ lv.EVENT.CLICKED, None)
+ countdown_hour_up_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hour_up(e)),
+ lv.EVENT.CLICKED, None)
+ countdown_hour_down_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hour_down(e)),
+ lv.EVENT.CLICKED, None)
+ countdown_start_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.start(e)),
+ lv.EVENT.CLICKED, None)
+ countdown_reset_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.reset(e)),
+ lv.EVENT.CLICKED, None)
+ # countdown_stop_imgbtn.add_event_cb(lambda e: self.stop(e),
+ # lv.EVENT.CLICKED, None)
+ date_tmp = utime.localtime()
+ self.time_tmp = utime.mktime(date_tmp)
+
+ if self.g_state == 1:
+ if self.timer_cb == 1:
+ EventMesh.publish("set_countdown_off_state", [0,self.g_state])
+ self.timer.start(1000,1,self.fun)
+ def post_processor_after_initialization(self):
+ global countdown_screen ,countdown_title,countdown_hour ,countdown_mao ,countdown_mao ,countdown_mao1 ,\
+ countdown_sec ,countdown_hour_up ,countdown_hour_up_btn ,countdown_hour_down ,countdown_hour_down_btn ,\
+ countdown_min_up,countdown_min_up_btn ,countdown_min_down,countdown_min_down_btn,countdown_sec_up ,\
+ countdown_sec_up_btn,countdown_sec_down ,countdown_sec_down_btn ,countdown_reset_img ,countdown_reset_imgbtn ,\
+ countdown_start_img,countdown_start_imgbtn,countdown_stop_img ,countdown_min
+ if self.g_state == 0:
+ countdown_start_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ countdown_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
+ countdown_reset_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ countdown_hour_up.clear_flag(lv.obj.FLAG.HIDDEN)
+ countdown_hour_down.clear_flag(lv.obj.FLAG.HIDDEN)
+ countdown_min_up.clear_flag(lv.obj.FLAG.HIDDEN)
+ countdown_min_down.clear_flag(lv.obj.FLAG.HIDDEN)
+ countdown_sec_up.clear_flag(lv.obj.FLAG.HIDDEN)
+ countdown_sec_down.clear_flag(lv.obj.FLAG.HIDDEN)
+ countdown_sec.clear_flag(lv.obj.FLAG.HIDDEN)
+ countdown_min.clear_flag(lv.obj.FLAG.HIDDEN)
+ countdown_hour.clear_flag(lv.obj.FLAG.HIDDEN)
+ countdown_title.clear_flag(lv.obj.FLAG.HIDDEN)
+ self.g_end = 0
+ self.total = 0
+ self.hour = 0
+ self.min = 0
+ self.sec = 0
+ EventMesh.publish("reset_time_countdown")
+ self.show_value()
+
+ def sec_up(self,e):
+ EventMesh.publish("add_countdown_sec")
+ self.sec = EventMesh.publish("get_countdown_sec")
+ print("sec_up:",self.sec)
+ self.show_value()
+
+ def sec_down(self,e):
+ EventMesh.publish("reduce_countdown_sec")
+ self.sec = EventMesh.publish("get_countdown_sec")
+ print("sec_down:",self.sec)
+ self.show_value()
+
+ def min_up(self,e):
+ EventMesh.publish("add_countdown_min")
+ self.min = EventMesh.publish("get_countdown_min")
+ print("min_up:",self.min)
+ self.show_value()
+
+ def min_down(self,e):
+ EventMesh.publish("reduce_countdown_min")
+ self.min = EventMesh.publish("get_countdown_min")
+ print("min_down:",self.min)
+ self.show_value()
+
+ def hour_up(self,e):
+ EventMesh.publish("add_countdown_hour")
+ self.hour = EventMesh.publish("get_countdown_hour")
+
+ print("hour_up:",self.hour)
+ self.show_value()
+
+ def hour_down(self,e):
+ EventMesh.publish("reduce_countdown_hour")
+ self.hour = EventMesh.publish("get_countdown_hour")
+ print("hour_down:",self.hour)
+ self.show_value()
+
+ def start(self,e):
+ global countdown_screen ,countdown_title,countdown_hour ,countdown_mao ,countdown_mao ,countdown_mao1 ,\
+ countdown_sec ,countdown_hour_up ,countdown_hour_up_btn ,countdown_hour_down ,countdown_hour_down_btn ,\
+ countdown_min_up,countdown_min_up_btn ,countdown_min_down,countdown_min_down_btn,countdown_sec_up ,\
+ countdown_sec_up_btn,countdown_sec_down ,countdown_sec_down_btn ,countdown_reset_img ,countdown_reset_imgbtn ,\
+ countdown_start_img,countdown_start_imgbtn,countdown_stop_img ,countdown_min
+ self.total = self.hour*60*60 + self.min*60 + self.sec
+ print("--00:",self.total,self.hour,self.min,self.sec,self.g_state)
+ if self.g_state == 1:
+ self.g_state = 2
+ self.stop()
+ elif self.g_state == 2:
+ self.g_state = 1
+ if self.total > 0:
+ date_tmp = utime.localtime()
+ timeSecond = utime.mktime(date_tmp)
+ print("start self.timeSecond:{}".format(timeSecond))
+ EventMesh.publish("set_countdown_all_time", [self.total,timeSecond])
+ if self.g_state != 2:
+ self.g_state = 1
+ self.g_end = 0
+ date_tmp = utime.localtime()
+ self.timeSecond = utime.mktime(date_tmp)
+ self.show_value()
+ self.timer.start(1000,1,self.fun)
+ countdown_hour_up.add_flag(lv.obj.FLAG.HIDDEN)
+ countdown_hour_down.add_flag(lv.obj.FLAG.HIDDEN)
+ countdown_hour_up.add_flag(lv.obj.FLAG.HIDDEN)
+ countdown_hour_down.add_flag(lv.obj.FLAG.HIDDEN)
+ countdown_min_up.add_flag(lv.obj.FLAG.HIDDEN)
+ countdown_min_down.add_flag(lv.obj.FLAG.HIDDEN)
+ countdown_sec_up.add_flag(lv.obj.FLAG.HIDDEN)
+ countdown_sec_down.add_flag(lv.obj.FLAG.HIDDEN)
+ countdown_start_img.add_flag(lv.obj.FLAG.HIDDEN)
+ countdown_stop_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ countdown_reset_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ EventMesh.publish("set_countdown_off_state", [0,self.g_state])
+
+ def stop(self):
+ global countdown_screen ,countdown_title,countdown_hour ,countdown_mao ,countdown_mao ,countdown_mao1 ,\
+ countdown_sec ,countdown_hour_up ,countdown_hour_up_btn ,countdown_hour_down ,countdown_hour_down_btn ,\
+ countdown_min_up,countdown_min_up_btn ,countdown_min_down,countdown_min_down_btn,countdown_sec_up ,\
+ countdown_sec_up_btn,countdown_sec_down ,countdown_sec_down_btn ,countdown_reset_img ,countdown_reset_imgbtn ,\
+ countdown_start_img,countdown_start_imgbtn,countdown_stop_img ,countdown_min
+ print("in stop")
+ countdown_hour_up.add_flag(lv.obj.FLAG.HIDDEN)
+ countdown_hour_down.add_flag(lv.obj.FLAG.HIDDEN)
+ countdown_hour_up.add_flag(lv.obj.FLAG.HIDDEN)
+ countdown_hour_down.add_flag(lv.obj.FLAG.HIDDEN)
+ countdown_min_up.add_flag(lv.obj.FLAG.HIDDEN)
+ countdown_min_down.add_flag(lv.obj.FLAG.HIDDEN)
+ countdown_sec_up.add_flag(lv.obj.FLAG.HIDDEN)
+ countdown_sec_down.add_flag(lv.obj.FLAG.HIDDEN)
+ countdown_start_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ countdown_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
+ countdown_reset_img.clear_flag(lv.obj.FLAG.HIDDEN)
+
+ self.g_end = 0
+ self.timer.stop()
+ # self.show_value()
+ # EventMesh.publish("load_screen", {"screen": "countdown"})
+
+ def fun(self,e):
+ if self.g_state == 1:
+ date_tmp = utime.localtime()
+ self.time_tmp = utime.mktime(date_tmp)
+ total_sec = self.time_tmp - self.timeSecond
+ # print("total_sec:{} self.time_tmp:{} self.timeSecond:{} self.total:{}".format(total_sec,self.time_tmp,self.timeSecond,self.total))
+ if self.total > 0:
+ self.total = self.total - total_sec
+ self.timeSecond = self.time_tmp
+
+
+ self.hour = self.total//3600
+ self.min = self.total%3600//60
+ self.sec = self.total%60
+
+
+ # print("self.total:{} self.time_tmp:{} self.timeSecond:{} test_hour:{} test_min:{} test_sec:{}".format(self.total,self.time_tmp,self.timeSecond,test_hour,test_min,test_sec))
+ self.show_value()
+ # print("Close self.timeSecond:22")
+ EventMesh.publish("set_countdown_all_time", [self.total,self.timeSecond])
+ if self.total <= 0:
+ self.g_state = 0
+ self.g_end = 1
+ self.hour = 0
+ self.min = 0
+ self.sec = 0
+ EventMesh.publish("set_countdown_off_state", [0,self.g_state])
+ self.timer.stop()
+ self.show_value()
+ EventMesh.publish("load_screen", {"screen": "countdown_end"})
+
+ # self.total = self.total - 1
+
+ # self.sec = self.sec - 1
+ # if self.sec < 0:
+ # self.sec = 59
+
+ def Close(self):
+ time = EventMesh.publish("get_countdown_all_time")
+ if time > 0 and self.g_state == 1:
+ self.timer_cb = 1
+ date_tmp = utime.localtime()
+ self.timeSecond = utime.mktime(date_tmp)
+ EventMesh.publish("set_countdown_off_state", [1,self.g_state])
+ # print("Close self.timeSecond:{}".format(self.timeSecond))
+ EventMesh.publish("set_countdown_all_time", [self.total,self.timeSecond])
+ self.timer.stop()
+ else:
+ msg_tmp = EventMesh.publish("get_countdown_off_state")
+ self.g_state = msg_tmp[1]
+ EventMesh.publish("set_countdown_off_state", [0,self.g_state])
+ def close_count_show_info(self, event, msg):
+ self.reset(0)
+
+ def reset(self,e):
+ global countdown_screen ,countdown_title,countdown_hour ,countdown_mao ,countdown_mao ,countdown_mao1 ,\
+ countdown_sec ,countdown_hour_up ,countdown_hour_up_btn ,countdown_hour_down ,countdown_hour_down_btn ,\
+ countdown_min_up,countdown_min_up_btn ,countdown_min_down,countdown_min_down_btn,countdown_sec_up ,\
+ countdown_sec_up_btn,countdown_sec_down ,countdown_sec_down_btn ,countdown_reset_img ,countdown_reset_imgbtn ,\
+ countdown_start_img,countdown_start_imgbtn,countdown_stop_img ,countdown_min
+ # print("in reset")
+ self.timer.stop()
+ self.hour = 0
+ self.min = 0
+ self.sec = 0
+ self.g_state = 0
+ self.g_end = 0
+ self.total = 0
+ EventMesh.publish("set_countdown_off_state", [0,self.g_state])
+ EventMesh.publish("reset_time_countdown")
+ countdown_start_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ countdown_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
+ countdown_reset_img.clear_flag(lv.obj.FLAG.HIDDEN)
+
+ countdown_hour_up.clear_flag(lv.obj.FLAG.HIDDEN)
+ countdown_hour_down.clear_flag(lv.obj.FLAG.HIDDEN)
+ countdown_min_up.clear_flag(lv.obj.FLAG.HIDDEN)
+ countdown_min_down.clear_flag(lv.obj.FLAG.HIDDEN)
+ countdown_sec_up.clear_flag(lv.obj.FLAG.HIDDEN)
+ countdown_sec_down.clear_flag(lv.obj.FLAG.HIDDEN)
+ self.show_value()
+
+
+
+
+ def show_value(self):
+ global countdown_screen ,countdown_title,countdown_hour ,countdown_mao ,countdown_mao ,countdown_mao1 ,\
+ countdown_sec ,countdown_hour_up ,countdown_hour_up_btn ,countdown_hour_down ,countdown_hour_down_btn ,\
+ countdown_min_up,countdown_min_up_btn ,countdown_min_down,countdown_min_down_btn,countdown_sec_up ,\
+ countdown_sec_up_btn,countdown_sec_down ,countdown_sec_down_btn ,countdown_reset_img ,countdown_reset_imgbtn ,\
+ countdown_start_img,countdown_start_imgbtn,countdown_stop_img ,countdown_min
+
+ countdown_sec.set_text(str("%02d"%(self.sec)))
+ countdown_min.set_text(str("%02d"%(self.min)))
+ countdown_hour.set_text(str("%02d"%(self.hour)))
+
+ def lcd_on(self):
+ print("lcd_on self.timer_cb:{}".format(self.timer_cb))
+ time = EventMesh.publish("get_countdown_all_time")
+
+ if time > 0 and self.g_state != 0:
+ if self.g_state == 1:
+ if self.timer_cb != 0:
+ self.timer_cb = 0
+ EventMesh.publish("set_countdown_off_state", [0,self.g_state])
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ total_sec = time_tmp - self.timeSecond
+ # print("total_sec:{} self.time_tmp:{} self.timeSecond:{} self.total:{}".format(total_sec,self.time_tmp,self.timeSecond,self.total))
+ if self.total > 0:
+ self.total = self.total - total_sec
+ self.timeSecond = self.time_tmp
+ self.hour = self.total//3600
+ self.min = self.total%3600//60
+ self.sec = self.total%60
+ self.show_value()
+ self.timer.start(1000,1,self.fun)
+ else:
+ msg_tmp = EventMesh.publish("get_countdown_off_state")
+ self.g_state = msg_tmp[1]
+ EventMesh.publish("set_countdown_off_state", [0,self.g_state])
+
+ else:
+ self.reset(0)
+ msg_tmp = EventMesh.publish("get_countdown_off_state")
+ self.g_state = msg_tmp[1]
+ EventMesh.publish("set_countdown_off_state", [0,self.g_state])
+
+ def lcd_off(self):
+ time = EventMesh.publish("get_countdown_all_time")
+ if time > 0 and self.g_state == 1:
+ self.timer_cb = 1
+ date_tmp = utime.localtime()
+ self.timeSecond = utime.mktime(date_tmp)
+ EventMesh.publish("set_countdown_off_state", [1,self.g_state])
+ EventMesh.publish("set_countdown_all_time", [self.total,self.timeSecond])
+ self.timer.stop()
+ else:
+ EventMesh.publish("set_countdown_off_state", [0,self.g_state])
+
+ def stop_count_down(self,*argc,a):
+ if self.g_state == 0:
+ self.timer.stop()
+
+ def done_return(self):
+ if self.g_state == 0:
+ self.timer.stop()
+ if self.g_end == 1:
+ EventMesh.publish("load_screen", {"screen": "countdown"})
+ else:
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ if self.g_state == 0:
+ self.timer.stop()
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ if self.g_state == 0:
+ self.timer.stop()
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+#结束倒计时显示图标
+countdown_end_screen = None
+countdown_end_img = None
+countdown_end_label = None
+class CountdownEndScreen(Screen):
+ NAME = "countdown_end"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.FIND_timer=osTimer()
+ self.aud = audio.Audio(0)
+ self.FIND_timer_count = 0
+ self.meta_type = "popup"
+
+ def initialization(self):
+ global countdown_end_screen ,countdown_end_img ,countdown_end_label
+ if countdown_end_screen == None:
+ countdown_end_screen = lv.obj()
+ print("countdown_end_screen")
+ countdown_end_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+ countdown_end_img = lv.img(countdown_end_screen)
+ countdown_end_img.set_size(140, 140)
+ countdown_end_img.set_pos(50, 60)
+ countdown_end_img.set_src("E:/static/time_finish.png")
+ countdown_end_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ countdown_end_label = lv.label(countdown_end_screen)
+ countdown_end_label.set_pos(0, 240)
+ countdown_end_label.set_size(240, 40)
+ countdown_end_label.set_text("时间到")
+ countdown_end_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ countdown_end_label.set_long_mode(lv.label.LONG.WRAP)
+ countdown_end_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ self.meta = countdown_end_screen
+ self.FIND_timer_count = 0
+ self.FIND_timer.start(3000, 1, self.FIND_timer_cb)
+ EventMesh.publish("close_count_show_info")
+ self.aud.play(1, 1, 'E:/static/audio_audio_haixiu.mp3') #播放声音
+
+ def FIND_timer_cb(self, *args):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ self.FIND_timer_count += 1
+ if self.FIND_timer_count >= 4: #120秒
+ self.stop_FIND()
+ EventMesh.publish("return_prev_screen")
+ return
+ self.aud.play(1, 1, 'E:/static/audio_audio_haixiu.mp3')
+
+ def stop_FIND(self) :
+
+ self.FIND_timer.stop()
+ self.aud.stopAll()
+
+ def Close(self):
+ self.stop_FIND()
+
+ def done_left_to_right(self):
+ self.stop_FIND()
+ EventMesh.publish("return_prev_screen")
+
+ def done_right_to_left(self):
+ self.stop_FIND()
+ EventMesh.publish("return_prev_screen")
+
+ def done_bottom_to_top(self):
+ self.stop_FIND()
+ EventMesh.publish("return_prev_screen")
+
+ def done_top_to_bottom(self):
+ self.stop_FIND()
+ EventMesh.publish("return_prev_screen")
+
+ def done_return(self):
+ self.stop_FIND()
+ EventMesh.publish("return_prev_screen")
+
+ def done_click(self):
+ print("count down !!!!!!!!!!")
+ self.stop_FIND()
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ self.stop_FIND()
+ EventMesh.publish("return_prev_screen")
+ def btn8_press(self):
+ self.stop_FIND()
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+# -------------------------------------------stopwatch screen----------------------------------------------------------
+
+
+stopwatch_screen = None
+stopwatch_title = None
+stopwatch_label_min = None
+stopwatch_mao = None
+stopwatch_label_sec = None
+stopwatch_mao1 = None
+stopwatch_label_ms = None
+stopwatch_reset_img = None
+stopwatch_reset_imgbtn = None
+stopwatch_start_img = None
+stopwatch_start_imgbtn = None
+stopwatch_stop_img = None
+class StopwatchScreen(Screen):
+ NAME = "stopwatch"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.ms_value = 0
+ self.sec_value = 0
+ self.min_value = 0
+ self.s_state = 0
+ self.total_time = 0
+ self.TimeSecond = 0
+ self.timer = osTimer()
+
+ def initialization(self):
+ global stopwatch_screen,stopwatch_title,stopwatch_label_min,stopwatch_mao,stopwatch_label_sec ,\
+ stopwatch_mao1 ,stopwatch_label_ms,stopwatch_reset_img ,topwatch_reset_imgbtn ,stopwatch_start_img ,\
+ stopwatch_start_imgbtn, stopwatch_stop_img
+ if stopwatch_screen == None :
+ stopwatch_screen = lv.obj()
+ print("stopwatch_screen")
+ stopwatch_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ stopwatch_title = lv.label(stopwatch_screen)
+ stopwatch_title.set_pos(0, 20)
+ stopwatch_title.set_size(240, 20)
+ stopwatch_title.set_text("秒表")
+ stopwatch_title.set_long_mode(lv.label.LONG.WRAP)
+ stopwatch_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ stopwatch_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ stopwatch_label_min = lv.label(stopwatch_screen)
+ stopwatch_label_min.set_pos(30, 140)
+ stopwatch_label_min.set_size(60, 30)
+ stopwatch_label_min.set_text("00")
+ stopwatch_label_min.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
+ stopwatch_label_min.set_long_mode(lv.label.LONG.WRAP)
+ stopwatch_label_min.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+
+ stopwatch_mao = lv.label(stopwatch_screen)
+ stopwatch_mao.set_pos(82, 138)
+ stopwatch_mao.set_size(30, 30)
+ stopwatch_mao.set_text(":")
+ stopwatch_mao.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
+ stopwatch_mao.set_long_mode(lv.label.LONG.WRAP)
+ stopwatch_mao.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+
+
+ stopwatch_label_sec = lv.label(stopwatch_screen)
+ stopwatch_label_sec.set_pos(95, 140)
+ stopwatch_label_sec.set_size(60, 30)
+ stopwatch_label_sec.set_text("00")
+ stopwatch_label_sec.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
+ stopwatch_label_sec.set_long_mode(lv.label.LONG.WRAP)
+ stopwatch_label_sec.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+
+ stopwatch_mao1 = lv.label(stopwatch_screen)
+ stopwatch_mao1.set_pos(146, 138)
+ stopwatch_mao1.set_size(30, 30)
+ stopwatch_mao1.set_text(".")
+ stopwatch_mao1.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
+ stopwatch_mao1.set_long_mode(lv.label.LONG.WRAP)
+ stopwatch_mao1.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+
+
+ stopwatch_label_ms = lv.label(stopwatch_screen)
+ stopwatch_label_ms.set_pos(160, 140)
+ stopwatch_label_ms.set_size(60, 30)
+ stopwatch_label_ms.set_text("0")
+ stopwatch_label_ms.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
+ stopwatch_label_ms.set_long_mode(lv.label.LONG.WRAP)
+ stopwatch_label_ms.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+
+
+
+
+ stopwatch_reset_img = lv.img(stopwatch_screen)
+ stopwatch_reset_img.set_size(99, 36)
+ stopwatch_reset_img.set_src("E:/static/stopwatch_reset.png")
+ stopwatch_reset_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ stopwatch_reset_img.set_pos(10, 210)
+
+ stopwatch_reset_imgbtn = lv.img(stopwatch_screen)
+ stopwatch_reset_imgbtn.set_size(99, 76)
+ stopwatch_reset_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
+ stopwatch_reset_imgbtn.set_pos(10, 190)
+
+
+ stopwatch_start_img = lv.img(stopwatch_screen)
+ stopwatch_start_img.set_size(99, 36)
+ stopwatch_start_img.set_src("E:/static/stopwatch_play.png")
+ stopwatch_start_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ stopwatch_start_img.set_pos(115, 210)
+
+
+ stopwatch_start_imgbtn = lv.img(stopwatch_screen)
+ stopwatch_start_imgbtn.set_size(99, 76)
+ stopwatch_start_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
+ stopwatch_start_imgbtn.set_pos(115, 190)
+
+
+ stopwatch_stop_img = lv.img(stopwatch_screen)
+ stopwatch_stop_img.set_size(99, 36)
+ stopwatch_stop_img.set_src("E:/static/stopwatch_stop.png")
+ stopwatch_stop_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ stopwatch_stop_img.set_pos(115, 210)
+ stopwatch_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
+ stopwatch_start_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.start(e)),
+ lv.EVENT.CLICKED, None)
+
+ stopwatch_reset_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.reset(e)),
+ lv.EVENT.CLICKED, None)
+ self.meta = stopwatch_screen
+
+ if self.s_state == 0:
+ self.reset(0)
+ if self.s_state == 1:
+ date_tmp = utime.localtime()
+ timeSecond = utime.mktime(date_tmp)
+ reduce = timeSecond - self.TimeSecond
+ self.total_time = self.total_time+reduce
+ if self.total_time >= 99*60:
+ self.total_time = 99*60
+ self.ms_value = 0
+ stopwatch_start_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ stopwatch_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
+ self.show_value()
+ else:
+ self.timer.start(100,1,self._fun)
+
+
+ def start(self, e):
+ global stopwatch_screen,stopwatch_title,stopwatch_label_min,stopwatch_mao,stopwatch_label_sec ,\
+ stopwatch_mao1 ,stopwatch_label_ms,stopwatch_reset_img ,topwatch_reset_imgbtn ,stopwatch_start_img ,\
+ stopwatch_start_imgbtn, stopwatch_stop_img
+ print("stopwatch start:{}".format(self.s_state))
+ #self.timer.start(100, 1, self._fun)
+
+ if self.s_state == 1:
+ self.s_state = 2
+ self.paused()
+ elif self.s_state == 2:
+ self.s_state = 1
+ if self.s_state != 2:
+ self.s_state = 1
+ if self.total_time >= 99*60:
+ self.ms_value = 0
+ self.sec_value = 0
+ self.min_value = 0
+ self.total_time = 0
+ self.show_value()
+ self.timer.start(100,1,self._fun)
+ stopwatch_stop_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ stopwatch_start_img.add_flag(lv.obj.FLAG.HIDDEN)
+ # print("ms_value start:{} {} {}".format(self.ms_value,self.sec_value,self.min_value))
+
+
+
+ def paused(self):
+ global stopwatch_screen,stopwatch_title,stopwatch_label_min,stopwatch_mao,stopwatch_label_sec ,\
+ stopwatch_mao1 ,stopwatch_label_ms,stopwatch_reset_img ,topwatch_reset_imgbtn ,stopwatch_start_img ,\
+ stopwatch_start_imgbtn, stopwatch_stop_img
+ print("stopwatch pause")
+ stopwatch_start_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ stopwatch_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
+ self.timer.stop()
+ self.show_value()
+
+ def reset(self,e):
+ global stopwatch_screen,stopwatch_title,stopwatch_label_min,stopwatch_mao,stopwatch_label_sec ,\
+ stopwatch_mao1 ,stopwatch_label_ms,stopwatch_reset_img ,topwatch_reset_imgbtn ,stopwatch_start_img ,\
+ stopwatch_start_imgbtn, stopwatch_stop_img
+ print("stopwatch reset")
+
+ self.sec_value = 0
+ self.min_value = 0
+ self.ms_value = 0
+ self.s_state = 0
+ self.total_time = 0
+ stopwatch_start_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ stopwatch_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
+ self.timer.stop()
+ self.show_value()
+
+ def _fun(self,e):
+ self.ms_value += 1
+ if self.ms_value > 9:
+ self.ms_value = 0
+ self.sec_value += 1
+ self.total_time+=1
+ if self.sec_value > 59:
+ self.sec_value = 0
+ if self.total_time > 99*60:
+ self.total_time = 99*60
+ self.timer.stop()
+ stopwatch_start_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ stopwatch_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
+
+ self.show_value()
+
+ def show_value(self):
+ global stopwatch_screen,stopwatch_title,stopwatch_label_min,stopwatch_mao,stopwatch_label_sec ,\
+ stopwatch_mao1 ,stopwatch_label_ms,stopwatch_reset_img ,topwatch_reset_imgbtn ,stopwatch_start_img ,\
+ stopwatch_start_imgbtn, stopwatch_stop_img
+ if self.total_time >= 99*60:
+ self.total_time = 99*60
+ test_s = self.total_time % 60
+ test_m = self.total_time//60
+ # print("test_s:{} test_m:{} self.total_time:{}".format(test_s,test_m,self.total_time))
+
+ stopwatch_label_ms.set_text(str("%d"%(self.ms_value)))
+ stopwatch_label_sec.set_text(str("%02d"%(test_s)))
+ stopwatch_label_min.set_text(str("%02d"%(test_m)))
+
+ def Close(self):
+ if self.s_state == 1:
+ self.timer.stop()
+ date_tmp = utime.localtime()
+ self.TimeSecond = utime.mktime(date_tmp)
+
+ def lcd_on(self):
+ if self.s_state == 1:
+ date_tmp = utime.localtime()
+ timeSecond = utime.mktime(date_tmp)
+ reduce = timeSecond - self.TimeSecond
+ self.total_time = self.total_time+reduce
+ total = self.total_time // 60
+ if total >= 99:
+ self.total_time = 99*60
+ self.timer.stop()
+ self.s_state = 0
+ self.ms_value = 0
+ stopwatch_start_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ stopwatch_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
+ self.show_value()
+ else:
+
+ print("stopwatch reset start:{}".format(self.s_state))
+ #self.timer.start(100, 1, self._fun)
+ self.show_value()
+ self.timer.start(100,1,self._fun)
+ stopwatch_stop_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ stopwatch_start_img.add_flag(lv.obj.FLAG.HIDDEN)
+ # print("ms_value start:{} {} {}".format(self.ms_value,self.sec_value,self.min_value))
+
+ pass
+
+ def lcd_off(self):
+ if self.s_state == 1:
+ date_tmp = utime.localtime()
+ timeSecond = utime.mktime(date_tmp)
+ self.TimeSecond = timeSecond
+ self.timer.stop()
+ pass
+
+ def done_return(self):
+ if self.s_state == 0:
+ self.timer.stop()
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ if self.s_state == 0:
+ self.timer.stop()
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ if self.s_state == 0:
+ self.timer.stop()
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+FIND_screen = None
+watchface_mpsignal_img = None
+class UIFINDScreen(Screen):
+ NAME = "FIND"
+ def __init__(self):
+ super().__init__()
+ self.aud = audio.Audio(0)
+ # self.aud.setVolume(self.volum_size)
+ self.FIND_timer = osTimer()
+ self.FIND_timer_count = 0
+ self.meta_type = "popup"
+ self.meta = None
+
+ def initialization(self):
+ global FIND_screen ,watchface_mpsignal_img
+
+ if FIND_screen ==None:
+ FIND_screen = lv.obj()
+ print("FIND_screen")
+ FIND_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ # add style for watchface
+ FIND_screen.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT)
+ #进入图片
+ watchface_mpsignal_img = lv.img(FIND_screen)
+ watchface_mpsignal_img.set_pos(int(40),int(45))
+ watchface_mpsignal_img.set_size(160,230)
+ watchface_mpsignal_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ watchface_mpsignal_img.add_flag(lv.obj.FLAG.CLICKABLE)
+ watchface_mpsignal_img.set_src("E:/static/find_phone.png")
+ watchface_mpsignal_img.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT)
+ self.meta = FIND_screen
+
+
+ def post_processor_after_initialization(self):
+ utime.sleep_ms(200)#不加延时会切屏
+ self.FIND_timer_count = 0
+ print("self.FIND_timer_count:{}".format(self.FIND_timer_count))
+ self.FIND_timer.start(3000, 1, self.FIND_timer_cb)
+ self.aud.play(1, 1, 'E:/static/audio_audio_haixiu.mp3') #播放声音
+
+ def FIND_timer_cb(self, *args):
+ EventMesh.publish("system_sleep_rest")
+ self.aud.play(1, 1, 'E:/static/audio_audio_haixiu.mp3')
+ self.FIND_timer_count += 1
+ if self.FIND_timer_count > 20: #120秒
+ self.stop_FIND()
+
+ def stop_FIND(self) :
+ self.FIND_timer.stop()
+ self.aud.stop() #播放声音
+ EventMesh.publish("return_prev_screen")
+
+ def Close(self):
+ print("self.FIND_timer_Close")
+ self.FIND_timer.stop()
+ self.aud.stop() #播放声音
+
+ def done_left_to_right(self):
+ self.stop_FIND()
+
+ def done_right_to_left(self):
+ self.stop_FIND()
+ def done_bottom_to_top(self):
+ self.stop_FIND()
+
+ def done_top_to_bottom(self):
+ self.stop_FIND()
+
+ def done_return(self):
+ self.stop_FIND()
+
+ def done_click(self):
+ self.stop_FIND()
+
+
+ def btn1_release(self):
+ self.stop_FIND()
+
+
+ def btn8_press(self):
+ self.stop_FIND()
+
+Lowpower_screen = None
+Lowpower_screen_img = None
+class LowPowerScreen(Screen):
+ NAME = "LOW_POWER"
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.meta_type = "popup"
+
+ def initialization(self):
+ global Lowpower_screen ,Lowpower_screen_img
+ if Lowpower_screen == None :
+ Lowpower_screen = lv.obj()
+ print("Lowpower_screen")
+ Lowpower_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ # add style for watchface
+ Lowpower_screen.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT)
+ #进入图片
+ Lowpower_screen_img = lv.img(Lowpower_screen)
+ Lowpower_screen_img.set_pos(int(40),int(45))
+ Lowpower_screen_img.set_size(160,230)
+ Lowpower_screen_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ Lowpower_screen_img.add_flag(lv.obj.FLAG.CLICKABLE)
+ Lowpower_screen_img.set_src("E:/static/low_power.png")
+ Lowpower_screen_img.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT)
+ self.meta = Lowpower_screen
+
+ def done_left_to_right(self):
+ EventMesh.publish("return_prev_screen")
+ def done_right_to_left(self):
+ EventMesh.publish("return_prev_screen")
+ def done_bottom_to_top(self):
+ EventMesh.publish("return_prev_screen")
+ def done_top_to_bottom(self):
+ EventMesh.publish("return_prev_screen")
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+ def done_click(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+LowOnePower_screen = None
+LowOnePower_screen_img = None
+LowOnePower_screen_label2 = None
+LowOnePower_screen_label1 = None
+class LowOnePowerScreen(Screen): #0%的电池电量
+ NAME = "LOW_ONE_POWER"
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.timer = osTimer()
+ self.meta_type = "popup"
+
+ def initialization(self):
+ global LowOnePower_screen ,LowOnePower_screen_img ,LowOnePower_screen_label2,LowOnePower_screen_label1
+ if LowOnePower_screen == None :
+ LowOnePower_screen = lv.obj()
+ print("LowOnePower_screen")
+ LowOnePower_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ # add style for watchface
+ LowOnePower_screen.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT)
+ #进入图片
+ LowOnePower_screen_img = lv.img(LowOnePower_screen)
+ LowOnePower_screen_img.set_pos(int(86),int(30))
+ LowOnePower_screen_img.set_size(68,110)
+ LowOnePower_screen_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ LowOnePower_screen_img.add_flag(lv.obj.FLAG.CLICKABLE)
+ LowOnePower_screen_img.set_src("E:/static/0_BAT.png")
+ LowOnePower_screen_img.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+ LowOnePower_screen_label1 = lv.label(LowOnePower_screen)
+ LowOnePower_screen_label1.set_pos(0, 180)
+ LowOnePower_screen_label1.set_size(240, 60)
+ LowOnePower_screen_label1.set_text("电池电量过低,请及时充电")
+ LowOnePower_screen_label1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ LowOnePower_screen_label1.set_long_mode(lv.label.LONG.WRAP)
+ LowOnePower_screen_label1.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+
+ LowOnePower_screen_label2 = lv.label(LowOnePower_screen)
+ LowOnePower_screen_label2.set_pos(0, 250)
+ LowOnePower_screen_label2.set_size(240, 60)
+ LowOnePower_screen_label2.set_text("继续使用,5s过后强制关机")
+ LowOnePower_screen_label2.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ LowOnePower_screen_label2.set_long_mode(lv.label.LONG.WRAP)
+ LowOnePower_screen_label2.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+
+ self.meta = LowOnePower_screen
+
+ def post_processor_after_initialization(self):
+ self.timer.start(5000,0,self.fun)
+
+ def fun(self,e):
+ EventMesh.publish("load_screen", {"screen": "poweroff_comfirm"})
+
+ def done_left_to_right(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_right_to_left(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_bottom_to_top(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_top_to_bottom(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_click(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
+
+sos_screen = None
+sos_screen_label = None
+sos_screen_label_p = None
+sos_screen_confirm_label_S = None
+sos_screen_confirm_label = None
+sos_screen_confirm_img = None
+#sos求组提示界面
+
+class sosScreen(Screen):
+ NAME = "SOS_POPUP"
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.timer = osTimer()
+ self.meta_type = "popup"
+ self.count = 0
+
+ def initialization(self):
+ global sos_screen ,sos_screen_label ,sos_screen_confirm_label_S
+ if sos_screen == None :
+ sos_screen = lv.obj()
+ print("SOS_POPUP")
+ sos_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ # add style for watchface
+ sos_screen.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT)
+ #进入图片
+
+ # sos_screen_label = lv.label(sos_screen)
+ # sos_screen_label.set_pos(0, 20)
+ # sos_screen_label.set_size(240, 30)
+ # sos_screen_label.set_text("SOS")
+ # sos_screen_label.add_style(style_font_youyuan_20_red, lv.PART.MAIN | lv.STATE.DEFAULT)
+ # sos_screen_label.set_long_mode(lv.label.LONG.WRAP)
+ # sos_screen_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+
+
+ # sos_screen_label = lv.label(sos_screen)
+ # sos_screen_label.set_text("是否拨打紧急\n求助电话?")
+ # sos_screen_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ # sos_screen_label.set_size(240, 50)
+ # sos_screen_label.set_pos(0,20)
+ # sos_screen_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+
+ # sos_screen_confirm_img = lv.btn(sos_screen)
+ # sos_screen_confirm_img.set_pos(int(20),int(50))
+ # sos_screen_confirm_img.set_size(200,85)
+ # sos_screen_confirm_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ # sos_screen_confirm_img.set_style_pad_all(0, lv.STATE.DEFAULT)
+ # sos_screen_confirm_img.add_flag(lv.obj.FLAG.CLICKABLE)
+
+ # sos_screen_confirm_img.add_style(style_screen_btn_1_main_main_red, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+ # sos_screen_confirm_label = lv.label(sos_screen)
+ # sos_screen_confirm_label.set_pos(int(0),int(66))
+ # sos_screen_confirm_label.set_size(240,30)
+ # sos_screen_confirm_label.set_text("确定")
+ # sos_screen_confirm_label.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
+ # sos_screen_confirm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ # sos_screen_confirm_label_S = lv.label(sos_screen)
+ # sos_screen_confirm_label_S.set_pos(int(0),int(101))
+ # sos_screen_confirm_label_S.set_size(240,30)
+ # sos_screen_confirm_label_S.set_text("10S")
+ # sos_screen_confirm_label_S.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
+ # sos_screen_confirm_label_S.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ # screen_btn_1_label = lv.label(sos_screen_confirm_img)
+ # screen_btn_1_label.set_text("确定")
+ # screen_btn_1_label.align(lv.ALIGN.CENTER,0,5)
+ # style_screen_btn_1_main_main_default.set_bg_color(lv.color_make(249,47,104))
+ # # add style for screen_btn_1
+ # sos_screen_confirm_img.add_style(style_screen_btn_1_main_main_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+
+ sos_screen_confirm_img = lv.img(sos_screen)
+ sos_screen_confirm_img.set_size(200, 85)
+ sos_screen_confirm_img.set_pos(20, 50)
+ sos_screen_confirm_img.set_src("E:/static/off_icon_01.png")
+ sos_screen_confirm_img.add_flag(lv.obj.FLAG.CLICKABLE)
+ sos_screen_confirm_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ sos_screen_confirm_label = lv.label(sos_screen)
+ sos_screen_confirm_label.set_pos(int(0),int(66))
+ sos_screen_confirm_label.set_size(240,30)
+ sos_screen_confirm_label.set_text("确定")
+ sos_screen_confirm_label.add_flag(lv.obj.FLAG.CLICKABLE)
+ sos_screen_confirm_label.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
+ sos_screen_confirm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ sos_screen_confirm_label_S = lv.label(sos_screen)
+ sos_screen_confirm_label_S.set_pos(int(0),int(101))
+ sos_screen_confirm_label_S.set_size(240,30)
+ sos_screen_confirm_label_S.set_text("10S")
+ sos_screen_confirm_label_S.add_flag(lv.obj.FLAG.CLICKABLE)
+ sos_screen_confirm_label_S.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
+ sos_screen_confirm_label_S.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ # sos_screen_confirm_label = lv.label(sos_screen_confirm_img)
+ # sos_screen_confirm_label.set_text("确定")
+ # sos_screen_confirm_label.align(lv.ALIGN.CENTER, 0, 5)
+ # sos_screen_confirm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ # sos_screen_label = lv.label(sos_screen)
+ # sos_screen_label.set_text("无操作10s后\n自动拨打")
+ # sos_screen_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ # sos_screen_label.set_size(240, 50)
+ # sos_screen_label.set_pos(0,170)
+ # sos_screen_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+ # sos_screen_return = lv.btn(sos_screen)
+ # sos_screen_return.set_pos(int(20),int(200))
+ # sos_screen_return.set_size(200,66)
+ # sos_screen_return.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ # sos_screen_return.set_style_pad_all(0, lv.STATE.DEFAULT)
+ # sos_screen_return.add_flag(lv.obj.FLAG.CLICKABLE)
+
+
+ # screen_btn_2_label = lv.label(sos_screen_return)
+ # screen_btn_2_label.set_text("取消")
+ # screen_btn_2_label.align(lv.ALIGN.CENTER,0,5)
+ # sos_screen_return.add_style(style_screen_btn_1_main_main_yellow, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+
+ sos_screen_return = lv.img(sos_screen)
+ sos_screen_return.set_size(200, 66)
+ sos_screen_return.set_pos(20, 200)
+ sos_screen_return.set_src("E:/static/off_icon_02.png")
+ sos_screen_return.add_flag(lv.obj.FLAG.CLICKABLE)
+ sos_screen_return.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ sos_screen_return_label = lv.label(sos_screen_return)
+ sos_screen_return_label.set_text("取消")
+ sos_screen_return_label.align(lv.ALIGN.CENTER, 0, 5)
+ sos_screen_return_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ sos_screen_return_label.set_ext_click_area(20)
+
+ self.meta = sos_screen
+ sos_screen_confirm_label.add_event_cb(lambda e: EventMesh.callback_wrapper(self.timer_comfirm_cb(e)),
+ lv.EVENT.CLICKED, None)
+ sos_screen_confirm_label_S.add_event_cb(lambda e: EventMesh.callback_wrapper(self.timer_comfirm_cb(e)),
+ lv.EVENT.CLICKED, None)
+
+ sos_screen_confirm_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.timer_comfirm_cb(e)),
+ lv.EVENT.CLICKED, None)
+
+ sos_screen_return.add_event_cb(lambda e: EventMesh.callback_wrapper(self.timer_cancel_cb(e)),
+ lv.EVENT.CLICKED, None)
+
+ self.count = 10
+ if sos_screen_confirm_label_S != None:
+ sos_screen_confirm_label_S.set_text("{}S".format(self.count))
+ self.timer.start(1000,1,self.timer_cb_onescond)
+
+ def timer_comfirm_cb(self,e):
+ self.timer.stop()
+ EventMesh.publish("set_sos_flag", 1)
+
+ def timer_cancel_cb(self,e):
+ EventMesh.publish("return_prev_screen")
+
+ def timer_cb_onescond(self,e):
+ global sos_screen_confirm_label_S
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ if self.count > 0:
+ self.count-=1
+ if self.count == 0:
+ self.timer.stop()
+ EventMesh.publish("set_sos_flag", 1)
+ sos_screen_confirm_label_S.set_text("{}S".format(self.count))
+
+ def Close(self):
+ self.timer.stop()
+
+ def done_left_to_right(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def done_right_to_left(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def done_bottom_to_top(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def done_top_to_bottom(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def done_click(self):
+ #EventMesh.publish("return_prev_screen")
+ pass
+
+ def btn8_press(self):
+
+ pass
+ def btn1_press(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+
+
+no_sos_screen = None
+no_sos_screen_label = None
+
+#没有设置紧急联系人的号码
+class noSosDataScreen(Screen):
+ NAME = "NO_SOS_POPUP"
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.meta_type = "popup"
+ self.count = 0
+ self.timer = osTimer()
+
+ def initialization(self):
+ global no_sos_screen ,no_sos_screen_label
+ if no_sos_screen == None :
+ no_sos_screen = lv.obj()
+ print("NO_SOS_POPUP")
+ no_sos_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ # add style for watchface
+ no_sos_screen.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT)
+ #进入图片
+
+ no_sos_screen_label = lv.label(no_sos_screen)
+ no_sos_screen_label.set_pos(0, 110)
+ no_sos_screen_label.set_size(240, 80)
+ no_sos_screen_label.set_text("请在手机app上设置\n紧急联系人号码")
+ no_sos_screen_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ no_sos_screen_label.set_long_mode(lv.label.LONG.WRAP)
+ no_sos_screen_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+
+
+ self.meta = no_sos_screen
+ def post_processor_before_initialization(self):
+ self.count = 0
+ self.timer.start(1000,1,self.timer_cb_onescond)
+
+ def Close(self):
+ self.timer.stop()
+
+ def timer_cb_onescond(self,e):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ self.count+=1
+ if self.count >= 5:
+ self.count = 0
+ self.timer.stop()
+ EventMesh.publish("return_prev_screen")
+
+
+ def done_left_to_right(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def done_right_to_left(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def done_bottom_to_top(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def done_top_to_bottom(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def done_click(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+
+ def btn8_press(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def btn1_press(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+
+
+
+
+system_init_screen = None
+system_init_label = None
+class SystemInitScreen(Screen):
+ #系统初始化中...
+ NAME = "system_init"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.system_init_timer=osTimer()
+ self.system_init_timer_count = 0
+ self.meta_type = "popup"
+
+ def initialization(self):
+ global system_init_screen ,system_init_label
+ if system_init_screen == None:
+ system_init_screen = lv.obj()
+ print("Lowpower_screen")
+ system_init_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ system_init_label = lv.label(system_init_screen)
+ system_init_label.set_pos(0, 150)
+ system_init_label.set_size(240, 40)
+ system_init_label.set_text("系统初始化中")
+ system_init_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ system_init_label.set_long_mode(lv.label.LONG.WRAP)
+ system_init_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ self.meta = system_init_screen
+ self.system_init_timer_count = 0
+ self.system_init_timer.start(1000, 1, self.system_init_timer_cb)
+
+ def system_init_timer_cb(self, *args):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ self.system_init_timer_count += 1
+ if self.system_init_timer_count > 4:
+ self.system_init_timer_count = 1
+ if system_init_screen != None:
+
+ system_init_label_str = "系统初始化中"
+ if self.system_init_timer_count == 1:
+ system_init_label.set_text("系统初始化中.")
+ elif self.system_init_timer_count == 2:
+ system_init_label.set_text("系统初始化中..")
+ elif self.system_init_timer_count == 3:
+ system_init_label.set_text("系统初始化中...")
+ else:
+ system_init_label.set_text("系统初始化中....")
+
+ def Close(self):
+ self.system_init_timer.stop()
+
+
+poweron_screen = lv.obj()
+print("poweron_screen")
+poweron_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+poweron_label = lv.label(poweron_screen)
+poweron_label.set_text("WELCOME")
+poweron_label.align(lv.ALIGN.CENTER, 0, 0)
+poweron_label.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
+class PowerOnScreen(Screen):
+ NAME = "poweron"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = poweron_screen
+ self.timer = osTimer()
+ self.aud = audio.Audio(0)
+ self.aud.set_pa(Pin.GPIO29)
+ self.meta_type = "popup"
+ self.volum_size = 8
+ check_volum = EventMesh.publish("get_storage_config","volum")
+ if check_volum != None:
+ self.volum_size = check_volum
+
+
+ self.aud.setVolume(self.volum_size)
+ self.count = 0
+
+ def initialization(self):
+ EventMesh.publish("set_UI_high_priority",1)
+ self.count = 0
+ self.aud.setVolume(11)
+ self.timer.start(1000,1,self.fun)
+ pass
+
+ def fun(self,*argc):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ if self.count == 0:
+ #self.aud.play(1, 1, 'E:/static/R_POWER_1.mp3') #播放来电铃声
+ pass
+ else:
+ if self.count >= 6:#在上一个界面在播放音频时切换界面则关闭 以免一直播放
+ self.count = 0
+ self.timer.stop()
+ EventMesh.publish("set_UI_high_priority",0)
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+ return
+ self.count+=1
+
+ def Close(self):
+ EventMesh.publish("set_UI_high_priority",0)
+ self.timer.stop()
+ self.aud.setVolume(self.volum_size)
+ pass
+ def done_return(self):
+ pass
+
+ def btn1_release(self):
+ pass
+
+ def btn8_press(self):
+ pass
+
+
+charge_in_screen = None
+charge_in_screen_label = None
+
+#正在充电
+class chargeInScreen(Screen):
+ NAME = "charge_in"
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.meta_type = "popup"
+ self.count = 0
+ self.timer = osTimer()
+
+ def initialization(self):
+ global charge_in_screen ,charge_in_screen_label
+ if charge_in_screen == None :
+ charge_in_screen = lv.obj()
+ print("charge_in_screen")
+ charge_in_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ # add style for watchface
+ charge_in_screen.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT)
+ #进入图片
+
+ charge_in_screen_label = lv.label(charge_in_screen)
+ charge_in_screen_label.set_pos(0, 170)
+ charge_in_screen_label.set_size(240, 20)
+ charge_in_screen_label.set_text(" ")
+ charge_in_screen_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ charge_in_screen_label.set_long_mode(lv.label.LONG.WRAP)
+ charge_in_screen_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+
+
+ self.meta = charge_in_screen
+
+
+ def post_processor_after_initialization(self):
+ global charge_in_screen_label
+ self.count = 0
+ self.timer.start(1000,1,self.timer_cb_onescond)
+ charge_in_screen_label.set_text("正在充电")
+
+ def Close(self):
+ self.timer.stop()
+
+ def timer_cb_onescond(self,e):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ self.count+=1
+ if self.count >= 5:
+ self.count = 0
+ EventMesh.publish("return_prev_screen")
+
+
+ def done_left_to_right(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def done_right_to_left(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def done_bottom_to_top(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def done_top_to_bottom(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def done_click(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+
+ def btn8_press(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def btn1_press(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+
+
+charge_out_screen = None
+charge_out_screen_label = None
+
+#充电已移出
+class chargeOutScreen(Screen):
+ NAME = "charge_out"
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.meta_type = "popup"
+ self.count = 0
+ self.timer = osTimer()
+
+
+ def initialization(self):
+ global charge_out_screen ,charge_out_screen_label
+ if charge_out_screen == None :
+ charge_out_screen = lv.obj()
+ print("charge_out_screen")
+ charge_out_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ # add style for watchface
+ charge_out_screen.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT)
+ #进入图片
+
+ charge_out_screen_label = lv.label(charge_out_screen)
+ charge_out_screen_label.set_pos(0, 170)
+ charge_out_screen_label.set_size(240, 20)
+ charge_out_screen_label.set_text(" ")
+ charge_out_screen_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ charge_out_screen_label.set_long_mode(lv.label.LONG.WRAP)
+ charge_out_screen_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+
+
+ self.meta = charge_out_screen
+
+
+
+ def post_processor_after_initialization(self):
+ global charge_out_screen_label
+ self.count = 0
+ self.timer.start(1000,1,self.timer_cb_onescond)
+ charge_out_screen_label.set_text("充电已移出")
+
+ def Close(self):
+ self.timer.stop()
+
+ def timer_cb_onescond(self,e):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ self.count+=1
+ if self.count >= 5:
+ self.count = 0
+ EventMesh.publish("return_prev_screen")
+
+
+ def done_left_to_right(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def done_right_to_left(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def done_bottom_to_top(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def done_top_to_bottom(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def done_click(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+
+ def btn8_press(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def btn1_press(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+rrestor_confirm_n_screen = None
+rrestor_confirm_n_screen_label = None
+
+#
+class restore_confirmScreen(Screen):
+ NAME = "restore_confirm"
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.meta_type = "popup"
+ self.count = 0
+ self.timer1 = osTimer()
+ self.timer2 = osTimer()
+ self.timer3 = osTimer()
+
+ EventMesh.subscribe("app_factory_cb",self.app_factory_cb)
+
+ def initialization(self):
+ global rrestor_confirm_n_screen ,rrestor_confirm_n_screen_label
+ if rrestor_confirm_n_screen == None :
+ rrestor_confirm_n_screen = lv.obj()
+ print("rrestor_confirm_n_screen")
+ rrestor_confirm_n_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ # add style for watchface
+ rrestor_confirm_n_screen.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT)
+ #进入图片
+
+ rrestor_confirm_n_screen_label = lv.label(rrestor_confirm_n_screen)
+ rrestor_confirm_n_screen_label.set_pos(0, 150)
+ rrestor_confirm_n_screen_label.set_size(240, 60)
+ rrestor_confirm_n_screen_label.set_text("正在恢复出厂中\n请稍等...")
+ rrestor_confirm_n_screen_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ rrestor_confirm_n_screen_label.set_long_mode(lv.label.LONG.WRAP)
+ rrestor_confirm_n_screen_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+
+
+ self.meta = rrestor_confirm_n_screen
+ self.timer1.start(1000,1,self.timer_cb_onescond)
+
+ ret = 0
+ ret = ql_fs.path_exists("/ext/static/storage_file")#电话本
+ if ret == True:
+ ql_fs.rmdirs("/ext/static/storage_file")
+ ql_fs.mkdirs("/ext/static/storage_file")
+ EventMesh.publish("alipay_unbind")
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#已连接服务器发指令恢复出厂
+ EventMesh.publish(constants.PROTOCOL.DLT_SEND)
+ self.timer2.start(4000,0,self.timer_cb_threescond)
+
+
+ def Close(self):
+ self.timer1.stop()
+ self.timer2.stop()
+
+ def app_factory_cb(self,event,msg):
+ ret = 0
+ ret = ql_fs.path_exists("/ext/static/storage_file")#电话本
+ if ret == True:
+ ql_fs.rmdirs("/ext/static/storage_file")
+ ql_fs.mkdirs("/ext/static/storage_file")
+ EventMesh.publish("alipay_unbind")
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#已连接服务器发指令恢复出厂
+ EventMesh.publish(constants.PROTOCOL.DLT_SEND)
+ self.timer3.start(4000,0,self.timer_cb_threescond)
+ pass
+ def timer_cb_threescond(self,e):
+
+ Power.powerRestart()
+
+ def timer_cb_onescond(self,e):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+
+
+ def done_left_to_right(self):
+ pass
+ def done_right_to_left(self):
+ pass
+ def done_bottom_to_top(self):
+ pass
+ def done_top_to_bottom(self):
+ pass
+ def done_return(self):
+ pass
+ def done_click(self):
+ pass
+
+ def btn8_press(self):
+ pass
+ def btn1_press(self):
+ pass
+ def btn1_release(self):
+ pass
+
+style_font_youyuan_70_red = lv.style_t()
+style_font_youyuan_70_red.init()
+style_font_youyuan_70_red.set_text_color(lv.color_make(0xff, 0xff, 0xff))
+style_font_youyuan_70_red.set_text_font(lv.font_70_bold)
+
+class_mgr_popup_screen = None
+class_mgr_popup_label = None
+class_mgr_popup_time1_text = None
+class classMgrPopupScreen(Screen):#上课禁用时间界面
+ #上课禁用
+ NAME = "class_time"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = None
+ self.timer = osTimer()
+ self.meta_type = "popup"
+ def initialization(self):
+ global class_mgr_popup_screen ,class_mgr_popup_label ,class_mgr_popup_time1_text
+ if class_mgr_popup_screen == None:
+ class_mgr_popup_screen = lv.obj()
+ print("Lowpower_screen")
+ class_mgr_popup_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ class_mgr_popup_time1_text = lv.label(class_mgr_popup_screen)
+ class_mgr_popup_time1_text.set_pos(0, 10)
+ class_mgr_popup_time1_text.set_size(240, 80)
+ class_mgr_popup_time1_text.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ class_mgr_popup_time1_text.set_text(" ")
+ class_mgr_popup_time1_text.add_style(style_font_youyuan_70_red, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+ class_mgr_popup_label = lv.label(class_mgr_popup_screen)
+ class_mgr_popup_label.set_pos(0, 120)
+ class_mgr_popup_label.set_size(240, 50)
+ class_mgr_popup_label.set_text("现在是上课时间点,禁用手表功能")
+ class_mgr_popup_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ class_mgr_popup_label.set_long_mode(lv.label.LONG.WRAP)
+ class_mgr_popup_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ self.meta = class_mgr_popup_screen
+
+ sos_flag = EventMesh.publish("get_sos_flag")
+ if sos_flag == 1:
+ EventMesh.publish("set_sos_flag",0)
+ EventMesh.publish("set_sos_num",0)
+ EventMesh.publish("close_sos_timer")
+ EventMesh.publish("set_hangup_mode",0)
+ data = RTC().datetime()
+ hour = data[4]
+ min = data[5]
+ class_mgr_popup_time1_text.set_text("{}:{}".format("%02d"%(hour),"%02d"%(min)))
+ self.timer.start(1*1000,1,self.fun)
+
+ def lcd_on(self):
+ self.timer.start(1*1000,1,self.fun)
+
+ def lcd_off(self):
+ self.timer.stop()
+
+ def fun(self,*argc):
+ global class_mgr_popup_time1_text
+ data = RTC().datetime()
+ hour = data[4]
+ min = data[5]
+ class_mgr_popup_time1_text.set_text("{}:{}".format("%02d"%(hour),"%02d"%(min)))
+
+
+ def btn1_release(self):
+ state = EventMesh.publish("get_cur_class_time_state")
+ print("state:{}".format(state))
+ if state != None:
+ if state == 0:
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+ return
+ flag = EventMesh.publish("get_lcd_state")
+ if flag == 1:
+ EventMesh.publish(constants.EVENT.SYSTEM_SLEEP)
+ else:
+ EventMesh.publish(constants.EVENT.SYSTEM_UP)
+
+ def btn8_press(self):
+ state = EventMesh.publish("get_cur_class_time_state")
+ print("state:{}".format(state))
+ if state != None:
+ if state == 0:
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+ return
+ flag = EventMesh.publish("get_lcd_state")
+ if flag == 1:
+ EventMesh.publish(constants.EVENT.SYSTEM_SLEEP)
+ else:
+ EventMesh.publish(constants.EVENT.SYSTEM_UP)
+
+#from usr.ui_WatchFaceScreen import WatchFaceScreen
+class UI(object):
+ def __init__(self):
+ #self.screen = WatchFaceScreen()
+ #self.screen_old = self.screen
+ self.ui_queue = Queue()
+ _thread.stack_size(13*1024)
+ _thread.start_new_thread(self.ui_queue_thread, ())
+ _thread.stack_size(8*1024)
+ self.screen = None
+ self.screen_old = None
+ self.screen_prev = None
+ self.screen_prev_new = None
+ self.screen_last = None
+ self.screen_list = []
+ self.lv = lv
+ self.system_sleep_timer = osTimer()
+ self.system_sleep_timer_count = 0
+ self.sleep_flag = 1
+ self.level = 6
+ self.aud = audio.Audio(0)
+
+ self.main_flag = 0
+ self.main_id = 0
+ self.set_interrup_flag = 0
+ self.UI_high_priority_flag = 0 #如果=1,则当前ui不被打断
+ self.page_id = ["main_menu"]
+ self.page_count = 0
+
+ self.level = EventMesh.publish("get_storage_config","brightness_level")
+
+
+ if self.level == None:
+ self.level = 6
+ self.PWM_backlight = PWM(PWM.PWM1, PWM.ABOVE_MS, self.level, 10)
+ self.PWM_backlight.open()
+ self.sleep_lock = 0
+
+ def post_processor_after_instantiation(self):
+ EventMesh.subscribe("load_screen", self.load_screen_cb)
+
+ EventMesh.subscribe("btn1_press", self.btn_press)
+ EventMesh.subscribe("btn8_press", self.btn_press)
+ EventMesh.subscribe("btn8_long_press", self.btn_press)
+
+ EventMesh.subscribe("btn1_release", self.btn_release)
+ EventMesh.subscribe("btn8_release", self.btn_release)
+
+ EventMesh.subscribe("done_left_to_right", self.ui_press)
+ EventMesh.subscribe("done_right_to_left", self.ui_press)
+ EventMesh.subscribe("done_bottom_to_top", self.ui_press)
+ EventMesh.subscribe("done_top_to_bottom", self.ui_press)
+ EventMesh.subscribe("done_return", self.ui_press)
+ EventMesh.subscribe("done_click", self.ui_press)
+ EventMesh.subscribe("done_error", self.ui_press)
+ EventMesh.subscribe("done_press", self.ui_press)
+ EventMesh.subscribe("call_in", self.publish_call_in)
+
+ EventMesh.subscribe("get_lcd_state", self.get_lcd_state)
+ EventMesh.subscribe("set_lcd_state", self.set_lcd_state)
+
+ #EventMesh.subscribe("call_in", self.publish_call_in)
+ #EventMesh.subscribe("set_bg_img", self.set_bg_img)
+
+ EventMesh.subscribe(constants.EVENT.SYSTEM_SLEEP, self.system_sleep)
+ EventMesh.subscribe(constants.EVENT.SYSTEM_UP, self.system_up)
+ EventMesh.subscribe("system_sleep_rest", self.system_sleep_rest)
+ EventMesh.subscribe("set_UI_high_priority", self.set_UI_high_priority)
+ EventMesh.subscribe("get_UI_high_priority", self.get_UI_high_priority)
+
+ EventMesh.subscribe("set_interrup_incall", self.set_interrup_incall)
+ EventMesh.subscribe("get_interrup_incall", self.get_interrup_incall)
+ EventMesh.subscribe("get_screen_NAME",self.get_screen_NAME)
+ EventMesh.subscribe("publish_message_event_ui",self.publish_message_event_ui)
+ EventMesh.subscribe("return_prev_screen",self.return_prev_screen)
+
+ EventMesh.subscribe("del_prev_screen",self.del_prev_screen)#退出当前界面就删除当前界面 进去需要保存当前界面
+ EventMesh.subscribe("add_new_screen",self.add_new_screen)#保存新的界面用作返回上一级
+
+ EventMesh.subscribe("get_old_screen",self.get_old_screen)#保存新的界面用作返回上一级
+
+
+ self.system_sleep_timer.start(1000, 1, self.system_sleep_timer_cb)
+
+ def publish_message_event_ui(self,event,msg):
+ self.ui_queue.put(msg)
+
+ #ui的消息队列处理,防止内存越界 格式:{函数名,数据}
+ def ui_queue_thread(self):
+ while True:
+ data = self.ui_queue.get()
+ #print("ui_queue_thread:data = {}".format(data))
+ if data != None:
+ try:
+ data["func"](data["data"])
+ except Exception as e:
+ usys.print_exception(e)
+ print("ui_queue_thread:ERROR:{}".format(e))
+ # for scr in self.screen_list:
+ # if scr.handle_message_event(data) == 1 :
+ # break
+ def add_new_screen(self, event, msg):
+ if msg == "main_menu":
+ if self.page_count > 0:
+ self.page_id.clear()#清空所有
+ self.page_count = 0
+ self.page_id = ["main_menu"]
+ print("add_new_screen ",self.page_id,self.page_count)
+ else:
+ if self.page_count == None:
+ self.page_count = 0
+ self.page_id.clear()#清空所有
+ self.page_id = ["main_menu"]
+ last_screen = self.page_id[int(self.page_count)]
+ print("self.page_id",last_screen,msg,self.page_id,self.page_count)
+ if last_screen != msg and (msg in last_screen) == False:
+ self.page_count+=1
+ page_pre = "{}".format(msg)
+ self.page_id.append(page_pre)
+
+ def del_prev_screen(self, event, msg):
+ if self.page_count > 0:
+ # print("del_prev_screen self.page_id",self.page_id,self.page_count)
+ if self.screen.meta_type != "popup":
+ del self.page_id[int(self.page_count)]
+ self.page_count-=1
+
+ if self.page_count == 0:
+ self.page_id.clear()#清空所有
+ self.page_id = ["main_menu"]
+
+ if self.page_count == None:
+ self.page_count = 0
+ self.page_id.clear()#清空所有
+ self.page_id = ["main_menu"]
+ def return_prev_screen(self, event, msg):
+ EventMesh.publish("del_prev_screen")#退出当前界面就删除当前界面 进去需要保存当前界面
+
+ pre_page = self.page_id[int(self.page_count)]
+ # print("pre_page:data = {} self.page_count:{}".format(pre_page,self.page_count))
+ if len(pre_page) == 0:#预防是空的界面
+ self.page_count = 0
+ pre_page = "main_menu"
+
+ if self.page_count == None:
+ self.page_count = 0
+
+ if self.page_count == 0:
+ pre_page = "main_menu"
+ if pre_page != None:
+ EventMesh.publish("load_screen", {"screen": pre_page})
+ # if self.screen_prev != None:
+ # print("self.screen_prev.NAME",self.screen_prev.NAME)
+ # EventMesh.publish("load_screen", {"screen": self.screen_prev.NAME})
+
+ def get_old_screen(self, event, msg):
+ # print("self.screen_old.NAME",self.screen_old.NAME)
+ if self.screen_old == None:
+ old_screen = "main_menu"
+ return old_screen
+ else:
+ return self.screen_old.NAME
+
+
+
+
+ def set_interrup_incall(self, event, msg):
+ self.set_interrup_flag = msg
+
+ def get_interrup_incall(self, event, msg):
+ return self.set_interrup_flag
+
+ def set_UI_high_priority(self, event, msg):
+ self.UI_high_priority_flag = msg
+
+ def get_UI_high_priority(self, event, msg):
+ return self.UI_high_priority_flag
+
+ def get_lcd_state(self, event, key):
+ return self.sleep_flag
+
+ def set_lcd_state(self, event, key):
+ print("key_:{}".format(key))
+ self.sleep_flag = key
+
+ def system_sleep_rest(self, event, key):
+ #print("system_sleep_rest!!!!!")
+ self.system_sleep_timeout_rest()
+
+ def ui_press(self, event, key):
+ screen_NAME = EventMesh.publish("get_screen_NAME")
+ if screen_NAME == "system_init":
+ return
+ self.system_sleep_timeout_rest()
+ #print("ui press {}".format(event))
+ if event == "done_left_to_right":
+ self.screen.done_left_to_right()
+ if event == "done_right_to_left":
+ self.screen.done_right_to_left()
+ if event == "done_bottom_to_top":
+ self.screen.done_bottom_to_top()
+ if event == "done_top_to_bottom":
+ self.screen.done_top_to_bottom()
+ if event == "done_return":
+ self.screen.done_return()
+ if event == "done_click":
+ self.screen.done_click()
+ # if event == "done_press":
+ # self.system_sleep_timeout_rest()
+ def btn_press(self, event, key):
+ screen_NAME = EventMesh.publish("get_screen_NAME")
+ if screen_NAME == "system_init" or screen_NAME == "poweron":
+ return
+ print("btn_press: {} self.main_flag:{} self.sleep_flag:{}".format(event,self.main_flag,self.sleep_flag))
+ #主表盘按电源键,息屏
+
+ #息屏状态按按钮都亮屏
+
+
+ if self.main_flag != 1 and self.sleep_flag == 0:
+ if event == "btn8_long_press":
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#有卡时触发sos报警 无卡时自动关机
+ sos_number = EventMesh.publish("get_dial_sos_number")
+ if sos_number != None:
+ if len(sos_number) != 0:
+ screen_NAME = EventMesh.publish("get_screen_NAME")
+ if screen_NAME != None:
+ if screen_NAME != "SOS_POPUP":
+ EventMesh.publish("load_screen", {"screen": "SOS_POPUP"})
+ else:
+ EventMesh.publish("load_screen", {"screen": "NO_SOS_POPUP"})
+ else:
+ EventMesh.publish("load_screen", {"screen": "no_sim_power_screen"})
+ else:
+ self.__lcd_on()
+ return
+ # if event == "btn1_press":
+ # self.screen.btn1_press()
+ # self.__lcd_on()
+ if event == "btn8_press":
+ self.screen.btn8_press()
+ if event == "btn8_long_press":
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#有卡时触发sos报警 无卡时自动关机
+ sos_number = EventMesh.publish("get_dial_sos_number")
+ if sos_number != None:
+ if len(sos_number) != 0:
+ screen_NAME = EventMesh.publish("get_screen_NAME")
+ if screen_NAME != None:
+ if screen_NAME != "SOS_POPUP":
+ EventMesh.publish("load_screen", {"screen": "SOS_POPUP"})
+ else:
+ EventMesh.publish("load_screen", {"screen": "NO_SOS_POPUP"})
+ else:
+ EventMesh.publish("load_screen", {"screen": "no_sim_power_screen"})
+
+ if event == "btn1_press":
+ self.screen.btn1_release()
+
+
+ def btn_release(self, event, msg):
+ screen_NAME = EventMesh.publish("get_screen_NAME")
+ if screen_NAME == "system_init" or screen_NAME == "poweron":
+ return
+ print("btn_release: {}".format(event))
+ # if self.main_flag != 1 and self.sleep_flag == 0:
+ # self.__lcd_on()
+ # return
+ # if event == "btn1_release":
+
+ # self.screen.btn1_release()
+
+ def __lcd_on(self):
+ self.system_sleep_timeout_rest()
+ if self.sleep_flag == 0 :
+ print("__lcd_on")
+ if self.sleep_lock == 1:
+ print("__lcd_on:sleep_lock:error!")
+ utime.sleep_ms(200)
+ self.sleep_lock = 1
+ self.sleep_flag = 1
+
+
+ #lcd_ctrl.write(1)
+ #utime.sleep(10)
+ self.screen.lcd_on()
+ self.system_sleep_timer.start(1000, 1, self.system_sleep_timer_cb)
+ EventMesh.publish("set_lcd_state",self.sleep_flag)
+ #tp_cst816.resume()
+ lcd.lcd_display_on()
+ utime.sleep_ms(2)
+ lv.autoSleep(0)
+ pm.autosleep(0)
+ pm.sclkEx_set(0, 1, 5)
+ utime.sleep_ms(60)
+ self.level = EventMesh.publish("get_brightness_level")
+ if self.level == None:
+ self.level = 6
+ elif self.level > 10:
+ self.level = 10
+ elif self.level <= 0:
+ self.level = 1
+ self.PWM_backlight = PWM(PWM.PWM1, PWM.ABOVE_MS, self.level, 10)
+ self.PWM_backlight.open()
+ self.sleep_lock = 0
+
+
+ def publish_call_in(self, event, msg):
+ EventMesh.publish("load_screen", {"screen": "dialing", "meta": msg})
+
+ def __lcd_off(self):
+
+ if self.sleep_flag == 1 :
+ print("__lcd_off")
+ if self.sleep_lock == 1:
+ print("__lcd_on:sleep_lock:error!")
+ utime.sleep_ms(200)
+ self.sleep_lock = 1
+ self.sleep_flag = 0
+ self.PWM_backlight = PWM(PWM.PWM1, PWM.ABOVE_MS, 0, 1)
+ self.PWM_backlight.open()
+ #lcd_ctrl.write(0)
+ #
+ lv.autoSleep(1)
+ pm.autosleep(1)
+ pm.sclkEx_set(1, 1, 5)
+ utime.sleep_ms(2)
+ #tp_cst816.suspend()
+ lcd.lcd_display_off()
+ #utime.sleep_ms(80)
+ EventMesh.publish("set_lcd_state",self.sleep_flag)
+ self.sleep_lock = 0
+ self.screen.lcd_off()
+ self.system_sleep_timer.stop()
+ EventMesh.publish("Hsensor_set_sleep") #让系统更快休眠
+
+ def system_sleep(self, event, msg) :
+ self.__lcd_off()
+
+ def system_up(self, event, msg):
+ self.__lcd_on()
+
+ def system_sleep_timer_cb(self, *args):
+ #print("system_sleep_timer_count:{}".format(self.system_sleep_timer_count))
+ time = EventMesh.publish("get_brightness_time")
+ if time == None:
+ time = 10
+ self.system_sleep_timer_count += 1
+ if self.system_sleep_timer_count >= time :
+ self.system_sleep_timer_count = 0
+ self.__lcd_off()
+
+ def system_sleep_timeout_rest(self) :
+ #print("system_sleep_timeout_rest")
+ self.system_sleep_timer_count = 0
+
+ def start(self):
+ #self.post_processor_after_instantiation()
+ pass
+
+ def add_screen(self, screen):
+ try:
+ self.screen_list.append(screen)
+ except Exception as e:
+ usys.print_exception(e)
+ return self
+
+ def get_screen_NAME(self, event, msg):
+ return self.screen.NAME
+
+ def load_screen_cb(self, topic, msg):
+ EventMesh.publish("publish_message_event_ui",{"func":self.load_screen,"data":msg})
+
+ def load_screen(self, msg):
+ print("msg1={} self.UI_high_priority_flag:{}".format(msg,self.UI_high_priority_flag))
+ if self.UI_high_priority_flag == 1:#电话界面屏蔽其他界面
+ return
+ state = EventMesh.publish("get_cur_class_time_state")
+ print("state:{}".format(state))
+ if state != None:
+ if state == 1:
+ screen_NAME = EventMesh.publish("get_screen_NAME")
+ if screen_NAME != None:
+ if msg["screen"] == "charge_out" or msg["screen"] == "charge_in":
+ pass
+ else:
+ if screen_NAME == "class_time" :#在上课禁用界面打断其他操作界面
+ print("class_time UI")
+ if msg["screen"] == "countdown_end":
+ # print("countdown_end UI")
+ EventMesh.publish("close_count_show_info")
+ return
+ else:
+ if screen_NAME != "dialing_noplay_popup" or screen_NAME != "dial_no_connect_popup" or \
+ screen_NAME != "on_call" or screen_NAME != "dialing" or screen_NAME != "incoming_call" or \
+ screen_NAME != "charge_in" or screen_NAME != "charge_out":
+ EventMesh.publish("load_screen", {"screen": "class_time"})
+ if self.screen :
+ if self.screen.NAME == msg["screen"]:
+ return
+ for scr in self.screen_list:
+ if scr.NAME == msg["screen"]:
+ # 每次屏幕切换开始息屏倒计时
+
+ if scr.NAME == 'main_menu':
+ self.main_flag = 1
+ else :
+ self.main_flag = 0
+ mem = gc.mem_free()
+ print('1剩余内存RAM:{} KB'.format(mem / 1024))
+
+ self.screen = scr
+ play_state = EventMesh.publish("get_audio_state")#音频播放状态
+ if play_state != None:
+ if play_state != 0:#在上一个界面在播放音频时切换界面则关闭 以免一直播放
+ self.aud.stop()
+
+ if self.screen_old != None :
+ self.screen_old.Close() #先关闭上一次界面
+ self.lv.img.cache_invalidate_src(None) #清img cache
+ self.lv.img.cache_set_size(16) #开img cache
+ if self.screen.meta_type != "popup": #只要当前界面不是弹窗界面都要保存当前界面
+ if self.screen_old.meta_type != "popup":#上个界面也不为弹窗界面
+ self.screen_prev = self.screen_old #第二种方式
+ screen_new = msg["screen"]
+ # print('self.screen_prev.NAME:{} self.screen_old:{}'.format(self.screen_prev.NAME,self.screen.NAME))
+ if self.screen_prev.NAME != self.screen.NAME:
+ EventMesh.publish("add_new_screen",screen_new)#保存新的界面用作返回上一级
+
+ if msg.get("meta"):
+ self.screen.meta_info = msg.get("meta")
+ print("load_screen:post_processor_before_initialization")
+ self.screen.post_processor_before_initialization()
+ self.screen_old = self.screen
+ print("load_screen:initialization")
+ self.screen.initialization()
+
+ print("load_screen.load()1")
+ self.screen.load()
+ # print("load_screen.load()2")
+ self.lv.scr_load(self.screen.get_meta())
+ # print("load_screen.load()3")
+
+ self.screen.post_processor_after_initialization()
+ # print("load_screen.load()4")
+ if self.screen_prev == None:
+ if self.screen.meta_type != "popup":
+ self.screen_prev = self.screen
+ self.__lcd_on()
+ # print("load_screen.load()5")
+ mem = gc.mem_free()
+ print('2剩余内存RAM:{} KB'.format(mem / 1024))
+
+
+
+
+
--- /dev/null
+#表盘
+import osTimer
+import lvgl as lv
+import EventMesh
+import osTimer
+import constants
+from ui import Screen,style_screen
+import ql_fs
+import ujson
+from machine import RTC
+
+
+
+# style_font_youyuan_20 = lv.style_t()
+# style_font_youyuan_20.init()
+# style_font_youyuan_20.set_text_color(lv.color_make(0xff, 0xff, 0xff))
+# style_font_youyuan_20.set_text_font_v2("font_22.bin",22,0)
+
+watchface_style_default = lv.style_t()
+watchface_style_default.init()
+watchface_style_default.set_text_color(lv.color_make(0xff, 0xff, 0xff))
+watchface_style_default.set_text_font_v2("font_28.bin",28,0)
+
+
+style_font_youyuan_28 = lv.style_t()
+style_font_youyuan_28.init()
+style_font_youyuan_28.set_text_color(lv.color_make(0xFF, 0xFF, 0xFF))
+style_font_youyuan_28.set_text_font(lv.font_28_dial)
+
+power_line_points = [{"x":0,"y":0},{"x":0,"y":16}]
+power_line_red = lv.style_t()
+power_line_red.init()
+power_line_red.set_line_width(0)#23 宽度
+power_line_red.set_line_color(lv.color_make(0xff, 0xff, 0xff))
+
+Watchface = lv.obj()
+print("Watchface")
+Watchface1 = lv.obj(Watchface)
+
+Watchface1.set_size(240,320)
+#Watchface1.set_pos(0,0)
+Watchface1.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+Watchface1.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+# create style style_watchface_img_default
+style_watchface_img_default = lv.style_t()
+style_watchface_img_default.init()
+style_watchface_img_default.set_img_recolor(lv.color_make(0xff,0xff,0xff))
+style_watchface_img_default.set_img_recolor_opa(0)
+style_watchface_img_default.set_img_opa(255)
+
+
+#表盘
+
+#状态栏
+
+watchface1_mpsignal_img = lv.img(Watchface1)
+watchface1_mpsignal_img.set_pos(int(20),int(5))
+watchface1_mpsignal_img.set_size(30,22)
+watchface1_mpsignal_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+watchface1_mpsignal_img.add_flag(lv.obj.FLAG.CLICKABLE)
+watchface1_mpsignal_img.set_src("E:/static/mpsignal5.png")
+watchface1_mpsignal_img.add_style(style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+watchface1_res_stat_battery_img = lv.img(Watchface1)
+watchface1_res_stat_battery_img.set_pos(int(196),int(5))
+watchface1_res_stat_battery_img.set_size(40,22)
+watchface1_res_stat_battery_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+watchface1_res_stat_battery_img.add_flag(lv.obj.FLAG.CLICKABLE)
+watchface1_res_stat_battery_img.set_src("E:/static/vbat_0.png")
+watchface1_res_stat_battery_img.add_style(style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+
+
+
+watchface1_res_stat_battery_line = lv.line(Watchface1)
+watchface1_res_stat_battery_line.set_points(power_line_points,2)
+watchface1_res_stat_battery_line.set_pos(int(203),int(3))
+watchface1_res_stat_battery_line.set_size(0,16)#高度12
+watchface1_res_stat_battery_line.add_style(power_line_red,0)
+
+watchface1_res_stat_charge_in_img = lv.img(Watchface1)
+watchface1_res_stat_charge_in_img.set_pos(int(180),int(0))
+watchface1_res_stat_charge_in_img.set_size(10,18)
+watchface1_res_stat_charge_in_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+watchface1_res_stat_charge_in_img.add_flag(lv.obj.FLAG.CLICKABLE)
+# watchface1_res_stat_charge_in_img.set_src("E:/static/charge_in.png")
+# add style for watchface1_res_stat_charge_in_img
+watchface1_res_stat_charge_in_img.add_style(style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+#主图片
+watchface1_bg_img = lv.img(Watchface1)
+watchface1_bg_img.set_pos(int(9),int(65))
+watchface1_bg_img.set_size(222,222)
+watchface1_bg_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+watchface1_bg_img.add_flag(lv.obj.FLAG.CLICKABLE)
+watchface1_bg_img.set_src("U:/static/bg.png")
+watchface1_bg_img.add_style(style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+#时间
+
+
+style_font_youyuan_70_black = lv.style_t()
+style_font_youyuan_70_black.init()
+style_font_youyuan_70_black.set_text_color(lv.color_make(0x32, 0xc8, 0xdb))
+style_font_youyuan_70_black.set_text_font(lv.font_70_bold)
+#init3:(2106, 2, 7, 6, 29, 38, 6, 38)
+data = RTC().datetime()
+hour = data[4]
+min = data[5]
+
+week = data[3]
+
+date1 = data[1]
+date2 = data[2]
+print("hour:{} min:{} week:{} date1:{} date2:{} data:{}".format(hour,min,week,date1,date2,data))
+
+def get_week(msg):
+ if msg == 1:
+ return '一'
+ elif msg == 2:
+ return '二'
+ elif msg == 3:
+ return '三'
+ elif msg == 4:
+ return '四'
+ elif msg == 5:
+ return '五'
+ elif msg == 6:
+ return '六'
+ elif msg == 7 or msg == 0:
+ return '日'
+
+
+watchface1_time1_text = lv.label(Watchface1)
+watchface1_time1_text.set_pos(20, 50)
+watchface1_time1_text.set_size(190, 71)
+watchface1_time1_text.set_align(lv.TEXT_ALIGN.LEFT)
+watchface1_time1_text.set_text("{}:{}".format("%02d"%(hour),"%02d"%(min)))
+# watchface1_time1_text.set_text("%02d:%02d"%(hour,min))
+watchface1_time1_text.add_style(style_font_youyuan_70_black, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+#日期
+watchface1_date_span = lv.label(Watchface1)
+watchface1_date_span.set_pos(8, 122)
+watchface1_date_span.set_size(140, 30)
+watchface1_date_span.set_align(lv.TEXT_ALIGN.LEFT)
+watchface1_date_span.set_text("%d月%d日"%(date1,date2))
+watchface1_date_span.add_style(style_font_youyuan_28, lv.PART.MAIN|lv.STATE.DEFAULT)
+#星期
+watchface1_week_span = lv.label(Watchface1)
+watchface1_week_span.set_pos(8, 160)
+watchface1_week_span.set_size(100, 30)
+watchface1_week_span.set_align(lv.TEXT_ALIGN.LEFT)
+watchface1_week_span.set_text("星期%s"%(get_week(week)))
+watchface1_week_span.add_style(style_font_youyuan_28, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+
+
+watchface1_step_span = lv.label(Watchface1)
+watchface1_step_span.set_pos(142, 159)
+watchface1_step_span.set_size(240-142, 30)
+watchface1_step_span.set_align(lv.TEXT_ALIGN.LEFT)
+watchface1_step_span.set_text("0")
+watchface1_step_span.add_style(style_font_youyuan_28, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+
+
+# watchface1_HB_span = lv.label(Watchface1)
+# watchface1_HB_span.set_pos(52, 235)
+# watchface1_HB_span.set_size(80, 30)
+# watchface1_HB_span.set_align(lv.TEXT_ALIGN.LEFT)
+# watchface1_HB_span.set_text("0")
+# watchface1_HB_span.add_style(style_font_youyuan_28, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+watchface1_HB_span = lv.label(Watchface1)
+watchface1_HB_span.set_pos(5, 235)
+watchface1_HB_span.set_size(115, 30)
+watchface1_HB_span.set_text("0")
+watchface1_HB_span.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+watchface1_HB_span.add_style(style_font_youyuan_28, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+watchface1_SPO2_span = lv.label(Watchface1)
+watchface1_SPO2_span.set_pos(110, 235)
+watchface1_SPO2_span.set_size(120, 30)
+watchface1_SPO2_span.set_text("0")
+watchface1_SPO2_span.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+watchface1_SPO2_span.add_style(style_font_youyuan_28, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+
+class WatchFace1():
+ NAME = "Watchface1"
+ # # #表盘1
+ def __init__(self,main_menu):
+ print("Watchface1:__init__")
+ self.meta = Watchface1
+ Watchface1.set_parent(main_menu)#设置父控件
+
+ def initialization(self,main_menu):
+ print("Watchface1:initialization")
+
+ #获取信号
+ signal = EventMesh.publish("screen_get_sig")
+ if signal:
+ self.__signal(None, signal)
+ # 获取电池电量
+ battery = EventMesh.publish("screen_get_battery")
+ if battery:
+ self.__battery(None, battery)
+ time = EventMesh.publish("screen_get_time")
+ #print("publish_time:"+time)
+ if time:
+ self.__time(None, time)
+ hrValue = EventMesh.publish("get_old_hr_data")
+ if hrValue:
+ self.__oldHrValue(None, hrValue)
+
+ spo2Value = EventMesh.publish("get_old_spo2_data")
+ if spo2Value :
+ self.__oldSpo2Value(None, spo2Value)
+ # print("main get_step msg:{}".format(msg))
+
+ # step = EventMesh.publish(constants.EVENT.GET_STEP)
+ step = EventMesh.publish("get_old_step_value")
+ self.__stepValue(None, step)
+
+
+ def timerout_update(self):
+ #获取信号
+ signal = EventMesh.publish("screen_get_sig")
+ if signal:
+ self.__signal(None, signal)
+ # 获取电池电量
+ battery = EventMesh.publish("screen_get_battery")
+ if battery:
+ self.__battery(None, battery)
+
+ time = EventMesh.publish("screen_get_time")
+ #print("publish_time:"+time)
+ if time:
+ self.__time(None, time)
+
+ hrValue = EventMesh.publish("get_old_hr_data")
+ if hrValue:
+ self.__oldHrValue(None, hrValue)
+
+ spo2Value = EventMesh.publish("get_old_spo2_data")
+ if spo2Value :
+ self.__oldSpo2Value(None, spo2Value)
+ # print("main get_step msg:{}".format(msg))
+ # step = EventMesh.publish(constants.EVENT.GET_STEP)
+ step = EventMesh.publish("get_old_step_value")
+ self.__stepValue(None, step)
+
+ def __time(self, event, msg):
+ #时间
+ watchface1_time1_text.set_text("{}:{}".format("%02d"%(msg[0][0]),"%02d"%(msg[0][1])))
+
+ watchface1_date_span.set_text(msg[2])#日期
+ watchface1_week_span.set_text(msg[3]) #星期
+
+ def __signal(self, event, msg):
+ #print("__signal_cb:",str(msg))
+ # 信号强度值范围0 ~ 31,值越大表示信号强度越好
+ #print("__signal_cb:{}".format(msg//8))
+ if msg:
+ if msg >= 0 and msg<=31 :
+ watchface1_mpsignal_img.set_src("E:/static/mpsignal{}.png".format(msg//8+1))
+ else :
+ watchface1_mpsignal_img.set_src("E:/static/mpsignal5.png")
+
+ def __battery(self, event, msg):
+ #print("__battery_cb:",str(msg))
+ #print(msg)
+ if msg[0] == '1':
+
+ watchface1_res_stat_battery_line.set_pos(int(0),int(8))
+ watchface1_res_stat_battery_line.set_size(0,0)
+ watchface1_res_stat_battery_line.set_style_line_width(0,lv.PART.MAIN)
+ watchface1_res_stat_battery_img.set_src("E:/static/charge_ing.png")
+ else:
+ watchface1_res_stat_battery_img.set_src("E:/static/vbat_0.png")
+ level = msg[1]
+ if level >= 100:
+ level = 100
+ line_len = int(level*(30/100))
+ # print("__battery_cb:",level,line_len,30/100)
+ if line_len >= 30:
+ line_len = 30
+ if line_len <= 6:
+ line_len = 6
+ set_x = int(199+line_len//2)
+ watchface1_res_stat_battery_line.set_pos(int(set_x),int(8))
+ watchface1_res_stat_battery_line.set_size(line_len,15)
+ watchface1_res_stat_battery_line.set_style_line_width(line_len,lv.PART.MAIN)
+ if line_len <= 6:
+ watchface1_res_stat_battery_line.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
+ else:
+ watchface1_res_stat_battery_line.set_style_line_color(lv.color_make(0x00,0xff,0x00),0)
+ # watchface2_res_stat_battery_img.set_src("E:/static/vbat_%d.png"%(msg[1]))#"E:/vbat_60.png"
+ pass
+
+ def __oldHrValue(self, event, msg):
+ watchface1_HB_span.set_text(str(msg))
+
+ def __oldSpo2Value(self, event, msg):
+ watchface1_SPO2_span.set_text(str(msg))
+
+ def __stepValue(self, event, msg):
+ if msg == None:
+ watchface1_step_span.set_text("0")
+ else:
+ watchface1_step_span.set_text(str(msg))
+
+ def Close(self):
+ pass
+
+ def done_left_to_right(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def done_right_to_left(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def done_top_to_bottom(self):
+ EventMesh.publish("load_screen", {"screen": "popup"})
+
+ def done_bottom_to_top(self):
+ EventMesh.publish("load_screen", {"screen": "call_log"})
+
+# create style style_watchface_img_default
+style_watchface_img_default = lv.style_t()
+style_watchface_img_default.init()
+style_watchface_img_default.set_img_recolor(lv.color_make(0xff,0xff,0xff))
+style_watchface_img_default.set_img_recolor_opa(0)
+style_watchface_img_default.set_img_opa(255)
+
+Watchface2 = lv.obj(Watchface)
+Watchface2.set_size(240,320)
+#Watchface2.set_pos(0,0)
+Watchface2.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+Watchface2.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+#表盘
+
+#状态栏
+
+watchface2_mpsignal_img = lv.img(Watchface2)
+watchface2_mpsignal_img.set_pos(int(20),int(5))
+watchface2_mpsignal_img.set_size(30,22)
+watchface2_mpsignal_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+watchface2_mpsignal_img.add_flag(lv.obj.FLAG.CLICKABLE)
+watchface2_mpsignal_img.set_src("E:/static/mpsignal5.png")
+watchface2_mpsignal_img.add_style(style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+watchface2_res_stat_battery_img = lv.img(Watchface2)
+watchface2_res_stat_battery_img.set_pos(int(196),int(5))
+watchface2_res_stat_battery_img.set_size(40,22)
+watchface2_res_stat_battery_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+watchface2_res_stat_battery_img.add_flag(lv.obj.FLAG.CLICKABLE)
+watchface2_res_stat_battery_img.set_src("E:/static/vbat_0.png")
+watchface2_res_stat_battery_img.add_style(style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+
+watchface2_res_stat_battery_line = lv.line(Watchface2)
+watchface2_res_stat_battery_line.set_points(power_line_points,2)
+watchface2_res_stat_battery_line.set_pos(int(203),int(3))
+watchface2_res_stat_battery_line.set_size(0,16)#高度12
+watchface2_res_stat_battery_line.add_style(power_line_red,0)
+
+
+# watchface2_res_stat_charge_in_img = lv.img(Watchface2)
+# watchface2_res_stat_charge_in_img.set_pos(int(180),int(0))
+# watchface2_res_stat_charge_in_img.set_size(10,18)
+# watchface2_res_stat_charge_in_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+# watchface2_res_stat_charge_in_img.add_flag(lv.obj.FLAG.CLICKABLE)
+# watchface2_res_stat_charge_in_img.set_src("E:/static/charge_ing.png")
+# # add style for watchface_res_stat_charge_in_img
+# watchface2_res_stat_charge_in_img.add_style(style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+style_font_youyuan_70_red = lv.style_t()
+style_font_youyuan_70_red.init()
+style_font_youyuan_70_red.set_text_color(lv.color_make(0xff, 0xff, 0xff))
+style_font_youyuan_70_red.set_text_font(lv.font_70_bold)
+#时间
+x = 30
+y = 80
+watchface2_time1_hour_text = lv.label(Watchface2)
+watchface2_time1_hour_text.set_pos(20, 80)
+watchface2_time1_hour_text.set_size(88, 70)
+watchface2_time1_hour_text.set_align(lv.TEXT_ALIGN.LEFT)
+watchface2_time1_hour_text.set_text("{}".format("%02d"%(hour)))
+watchface2_time1_hour_text.add_style(style_font_youyuan_70_red, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+watchface2_time1_mao_text = lv.label(Watchface2)
+watchface2_time1_mao_text.set_pos(108, 76)
+watchface2_time1_mao_text.set_size(44, 70)
+watchface2_time1_mao_text.set_align(lv.TEXT_ALIGN.LEFT)
+watchface2_time1_mao_text.set_text(":")
+watchface2_time1_mao_text.add_style(style_font_youyuan_70_red, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+watchface2_time1_hour1_text = lv.label(Watchface2)
+watchface2_time1_hour1_text.set_pos(152, 80)
+watchface2_time1_hour1_text.set_size(88, 70)
+watchface2_time1_hour1_text.set_align(lv.TEXT_ALIGN.LEFT)
+watchface2_time1_hour1_text.set_text("{}".format("%02d"%(min)))
+watchface2_time1_hour1_text.add_style(style_font_youyuan_70_red, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+
+
+
+#日期
+watchface2_date_span = lv.label(Watchface2)
+watchface2_date_span.set_pos(18, 170)
+watchface2_date_span.set_size(120, 35)
+watchface2_date_span.set_align(lv.TEXT_ALIGN.LEFT)
+watchface2_date_span.set_text("%d月%d日"%(date1,date2))
+watchface2_date_span.add_style(style_font_youyuan_28, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+#日期
+watchface2_week = lv.label(Watchface2)
+watchface2_week.set_pos(146, 170)
+watchface2_week.set_size(110, 35)
+watchface2_week.set_align(lv.TEXT_ALIGN.LEFT)
+watchface2_week.set_text("星期%s"%(get_week(week)))
+watchface2_week.add_style(style_font_youyuan_28, lv.PART.MAIN|lv.STATE.DEFAULT)
+#星期
+
+
+# watchface2_week = lv.img(Watchface2)
+# watchface2_week.set_pos(int(30+56+20+25),int(y+56+30))
+# watchface2_week.set_size(90,30)
+# watchface2_week.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+# watchface2_week.set_src("E:/static/watch_plate/style_2/week/0_week.png")
+# watchface2_week.add_style(style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+
+
+watchface2_step_img = lv.img(Watchface2)
+watchface2_step_img.set_pos(int(95),int(260))
+watchface2_step_img.set_size(26,21)
+watchface2_step_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+watchface2_step_img.set_src("U:/static/step.png")
+watchface2_step_img.add_style(style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+watchface2_step_txt = lv.label(Watchface2)
+watchface2_step_txt.set_pos(125, 260)
+watchface2_step_txt.set_size(240-125, 35)
+watchface2_step_txt.set_align(lv.TEXT_ALIGN.LEFT)
+watchface2_step_txt.set_text("0")
+watchface2_step_txt.add_style(style_font_youyuan_28, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+class WatchFace2():
+ NAME = "Watchface2"
+ # # #表盘2
+ def __init__(self,main_menu):
+ print("Watchface2:__init__")
+ self.meta = Watchface2
+ Watchface2.set_parent(main_menu)#设置父控件
+
+ def initialization(self,main_menu):
+ print("Watchface2:initialization")
+
+ #获取信号
+ signal = EventMesh.publish("screen_get_sig")
+ if signal:
+ self.__signal(None, signal)
+ # 获取电池电量
+ battery = EventMesh.publish("screen_get_battery")
+ if battery:
+ self.__battery(None, battery)
+ time = EventMesh.publish("screen_get_time")
+ #print("publish_time:"+time)
+ if time:
+ self.__time(None, time)
+
+ step = EventMesh.publish("get_old_step_value")
+ self.__stepValue(None, step)
+
+
+ def timerout_update(self):
+ #获取信号
+ signal = EventMesh.publish("screen_get_sig")
+ if signal:
+ self.__signal(None, signal)
+ # 获取电池电量
+ battery = EventMesh.publish("screen_get_battery")
+ if battery:
+ self.__battery(None, battery)
+
+ time = EventMesh.publish("screen_get_time")
+ #print("publish_time:"+time)
+ if time:
+ self.__time(None, time)
+
+ step = EventMesh.publish("get_old_step_value")
+ self.__stepValue(None, step)
+
+ def __time(self, event, msg):
+ #时间
+ hour1_chose = (msg[0][0])//10%10
+ hour2_chose = (msg[0][0])%10
+ min1_chose = (msg[0][1])//10%10
+ min2_chose = (msg[0][1])%10
+ watchface2_time1_hour_text.set_text("{}".format("%02d"%(msg[0][0])))
+ watchface2_time1_hour1_text.set_text("{}".format("%02d"%(msg[0][1])))
+ # watchface2_time1_hour_text.set_text("{}".format("%d"%(hour1_chose)))
+ # watchface2_time1_hour2_text.set_text("{}".format("%d"%(hour2_chose)))
+ # watchface2_time2_min1_text.set_text("{}".format("%d"%(min1_chose)))
+ # watchface2_time2_min2_text.set_text("{}".format("%d"%(min2_chose)))
+ watchface2_date_span.set_text(msg[2])#日期
+ watchface2_week.set_text(msg[3])#星期
+ # watchface2_week.set_src("E:/static/watch_plate/style_2/week/%d_week.png"%(msg[5])) #星期
+
+ def __signal(self, event, msg):
+ #print("__signal_cb:",str(msg))
+ # 信号强度值范围0 ~ 31,值越大表示信号强度越好
+ #print("__signal_cb:{}".format(msg//8))
+ if msg:
+ if msg >= 0 and msg<=31 :
+ watchface2_mpsignal_img.set_src("E:/static/mpsignal{}.png".format(msg//8+1))
+ else :
+ watchface2_mpsignal_img.set_src("E:/static/mpsignal5.png")
+
+ def __battery(self, event, msg):
+ #print("__battery_cb:",str(msg))
+ #print(msg)
+ if msg[0] == '1':
+
+ watchface2_res_stat_battery_line.set_pos(int(0),int(0))
+ watchface2_res_stat_battery_line.set_size(0,0)
+ watchface2_res_stat_battery_line.set_style_line_width(0,lv.PART.MAIN)
+ watchface2_res_stat_battery_img.set_src("E:/static/charge_ing.png")
+ else:
+ watchface2_res_stat_battery_img.set_src("E:/static/vbat_0.png")
+ level = msg[1]
+ if level >= 100:
+ level = 100
+ line_len = int(level*(30/100))
+ # print("__battery_cb:",level,line_len,30/100)
+ if line_len >= 30:
+ line_len = 30
+ if line_len <= 6:
+ line_len = 6
+ set_x = int(199+line_len//2)
+ watchface2_res_stat_battery_line.set_pos(int(set_x),int(8))
+ watchface2_res_stat_battery_line.set_size(line_len,16)
+ watchface2_res_stat_battery_line.set_style_line_width(line_len,lv.PART.MAIN)
+ if line_len <= 6:
+ watchface2_res_stat_battery_line.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
+ else:
+ watchface2_res_stat_battery_line.set_style_line_color(lv.color_make(0x00,0xff,0x00),0)
+ # watchface2_res_stat_battery_img.set_src("E:/static/vbat_%d.png"%(msg[1]))#"E:/vbat_60.png"
+ pass
+ def __stepValue(self, event, msg):
+ if msg == None:
+ watchface2_step_txt.set_text("0")
+ else:
+ watchface2_step_txt.set_text(str(msg))
+
+
+ # def __weather_type(self, event, msg):
+ # if msg == None:
+ # watchface2_temp_img.add_flag(lv.obj.FLAG.HIDDEN)
+ # watchface2_no_temp_txt.clear_flag(lv.obj.FLAG.HIDDEN)
+ # else:
+ # type = int(msg)
+ # watchface2_no_temp_txt.add_flag(lv.obj.FLAG.HIDDEN)
+ # watchface2_temp_img.clear_flag(lv.obj.FLAG.HIDDEN)
+ # watchface2_temp_img.set_src("E:/static/watch_plate/style_2/%d_main2_weather.png"%(type))
+
+ # def __weather_value(self, event, msg):
+ # if msg == None:
+ # watchface2_temp_degree.add_flag(lv.obj.FLAG.HIDDEN)
+ # watchface2_no_temp_txt.clear_flag(lv.obj.FLAG.HIDDEN)
+ # watchface2_temp_txt.add_flag(lv.obj.FLAG.HIDDEN)
+ # else:
+ # watchface2_no_temp_txt.add_flag(lv.obj.FLAG.HIDDEN)
+ # watchface2_temp_txt.clear_flag(lv.obj.FLAG.HIDDEN)
+ # watchface2_temp_degree.clear_flag(lv.obj.FLAG.HIDDEN)
+ # watchface2_temp_txt.set_text(str(msg))
+
+ def Close(self):
+ pass
+
+ def done_left_to_right(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def done_right_to_left(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+ def done_top_to_bottom(self):
+ EventMesh.publish("load_screen", {"screen": "popup"})
+
+ def done_bottom_to_top(self):
+ EventMesh.publish("load_screen", {"screen": "call_log"})
+
+class WatchFace():
+ #NAME = "Watchface"
+
+ def __init__(self):
+ #表盘
+ self.meta = None
+ self.watchface_style_num = "Watchface1"
+ self.watchface_list = []
+ self.timer_update = osTimer()
+ EventMesh.subscribe("set_change_face", self.change_face)
+ self.PWM_backlight = None
+ read_data = EventMesh.publish("get_storage_config","watchface")
+ if read_data != None:
+ self.watchface_style_num = read_data
+
+
+
+ def initialization(self,main_menu):
+ if self.watchface_list == [] : #第一次初始化
+ self.watchface_list.append( WatchFace1(main_menu))
+ self.watchface_list.append( WatchFace2(main_menu))
+ print("watchface INIT !!!!!!!!:",self.watchface_style_num)
+ for wat in self.watchface_list:
+ if wat.NAME == self.watchface_style_num :
+ self.watchface_style = wat
+ wat.meta.add_flag(lv.obj.FLAG.HIDDEN) #隐藏
+ self.watchface_style.initialization(main_menu)
+ self.meta = self.watchface_style.meta
+ self.watchface_style.meta.clear_flag(lv.obj.FLAG.HIDDEN)#显示
+ self.watchface_style.timerout_update()
+ self.timer_update.start(10000, 1, self.timerout_update)
+
+ def timerout_update(self, *args, **kwargs):
+ self.watchface_style.timerout_update()
+
+ def change_face(self, event=None, msg=None):
+ print("change_face :",msg)
+ self.watchface_style_num = str(msg)
+
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
+ # def done_left_to_right(self):
+ # EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ # def done_right_to_left(self):
+ # EventMesh.publish("load_screen", {"screen": "main_menu"})
+ # def done_top_to_bottom(self):
+ # EventMesh.publish("load_screen", {"screen": "popup"})
+
+ # def done_bottom_to_top(self):
+ # EventMesh.publish("load_screen", {"screen": "call_log"})
+ # def done_return(self):
+ # EventMesh.publish("load_screen", {"screen": "Watchface"})
+
+ # def btn1_release(self):
+ # EventMesh.publish("load_screen", {"screen": "Watchface"})
+
+ # def btn8_press(self):
+ # EventMesh.publish("load_screen", {"screen": "Watchface"})
+
+ def Close(self):
+ print("watchface Close !!!!!!!!")
+ self.timer_update.stop()
+ self.watchface_style.Close()
+ return
+
+
+
+
--- /dev/null
+
+import lvgl as lv
+import ql_fs
+import EventMesh
+from misc import Power
+from ui import style_screen,style_font_youyuan_20,style_btn,style_img,Screen,style_contact_btn
+import constants
+import osTimer
+import audio
+from machine import Pin
+import ujson
+from lcd import style_font_youyuan_40
+# -------------------------------------------setting screen----------------------------------------------------------
+
+style_bar = lv.style_t()
+style_bar.init()
+style_bar.set_radius(10)
+style_bar.set_bg_color(lv.color_make(0xA0, 0xA0, 0xA0))
+style_bar.set_bg_grad_color(lv.color_make(0xA0, 0xA0, 0xA0))
+style_bar.set_bg_grad_dir(lv.GRAD_DIR.VER)
+style_bar.set_bg_opa(60)
+style_bar.set_pad_left(0)
+style_bar.set_pad_right(0)
+style_bar.set_pad_top(0)
+style_bar.set_pad_bottom(0)
+
+style_volume_btn = lv.style_t()
+style_volume_btn.init()
+style_volume_btn.set_shadow_opa(0)
+style_volume_btn.set_border_width(0)
+style_volume_btn.set_bg_color(lv.color_make(0x80, 0x80, 0x80))
+
+style_bar_indic = lv.style_t()
+style_bar_indic.init()
+style_bar_indic.set_radius(10)
+style_bar_indic.set_bg_color(lv.color_make(0xff, 0x61, 0x3a))
+style_bar_indic.set_bg_grad_color(lv.color_make(0xff, 0x61, 0x3a))
+style_bar_indic.set_bg_grad_dir(lv.GRAD_DIR.VER)
+style_bar_indic.set_bg_opa(255)
+
+health_cont_y = 0
+health_screen = lv.obj()
+print("health_screen")
+health_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+health_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+health_title_img = lv.img(health_screen)
+health_title_img.set_pos(58, 10)
+health_title_img.set_size(124, 30)
+health_title_img.set_src("E:/static/health/health_text.png")
+health_title_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+
+setting_cont_style = lv.style_t()
+setting_cont_style.init()
+setting_cont_style.set_radius(0)
+setting_cont_style.set_bg_color(lv.color_make(0x00, 0x00, 0x00))
+setting_cont_style.set_bg_grad_color(lv.color_make(0x00, 0x00, 0x00))
+setting_cont_style.set_bg_grad_dir(lv.GRAD_DIR.VER)
+setting_cont_style.set_bg_opa(255)
+setting_cont_style.set_border_width(0)
+setting_cont_style.set_pad_left(0)
+setting_cont_style.set_pad_right(0)
+setting_cont_style.set_pad_top(0)
+setting_cont_style.set_pad_bottom(0)
+
+health_list_screen = lv.obj(health_screen)
+health_list_screen.set_pos(0, 50)
+health_list_screen.set_size(240, 270)
+health_list_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+health_list_screen.add_style(setting_cont_style,lv.PART.MAIN | lv.STATE.DEFAULT)
+
+setting_cont = lv.obj(health_list_screen)
+setting_cont.set_pos(0, 0)
+setting_cont.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+setting_cont.set_size(240, 271)
+setting_cont.add_style(setting_cont_style,lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+health_hr = lv.btn(setting_cont)
+health_hr.set_pos(0, health_cont_y)
+health_hr.set_size(0, 0)
+health_hr_label = lv.label(health_hr)
+health_hr_label.set_text("心率")
+health_hr.set_style_pad_all(0, lv.STATE.DEFAULT)
+health_hr_label.align(lv.ALIGN.LEFT_MID, 70, 0)
+health_hr_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+health_hr_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+health_hr.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+health_hr_img = lv.img(setting_cont)
+health_hr_img.set_pos(0, health_cont_y)
+health_hr_img.set_size(232, 80)
+health_hr_img.add_flag(lv.obj.FLAG.CLICKABLE)
+health_hr_img.set_src("E:/static/health/health_hr.png")
+health_hr_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+health_cont_y+=90
+
+
+
+health_spo2 = lv.btn(setting_cont)
+health_spo2.set_pos(0, health_cont_y)
+health_spo2.set_size(0, 0)
+health_spo2_label = lv.label(health_spo2)
+health_spo2_label.set_text("血氧")
+health_spo2.set_style_pad_all(0, lv.STATE.DEFAULT)
+health_spo2_label.align(lv.ALIGN.LEFT_MID, 70, 0)
+health_spo2_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+health_spo2_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+health_spo2.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+health_spo2_img = lv.img(setting_cont)
+health_spo2_img.set_pos(0, health_cont_y)
+health_spo2_img.set_size(232, 80)
+health_spo2_img.add_flag(lv.obj.FLAG.CLICKABLE)
+health_spo2_img.set_src("E:/static/health/health_spo2.png")
+health_spo2_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+health_cont_y+=90
+
+health_temp = lv.btn(setting_cont)
+health_temp.set_pos(0, health_cont_y)
+health_temp.set_size(0, 0)
+health_temp_label = lv.label(health_temp)
+health_temp_label.set_text("体温")
+health_temp.set_style_pad_all(0, lv.STATE.DEFAULT)
+health_temp_label.align(lv.ALIGN.LEFT_MID, 70, 0)
+health_temp_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+health_temp_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+health_temp.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+health_temp_img = lv.img(setting_cont)
+health_temp_img.set_pos(0, health_cont_y)
+health_temp_img.set_size(232, 80)
+health_temp_img.add_flag(lv.obj.FLAG.CLICKABLE)
+health_temp_img.set_src("E:/static/health/health_temp.png")
+health_temp_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+health_cont_y+=90
+
+
+
+
+class HealthScreen(Screen):#健康测量
+ NAME = "health"
+
+ def __init__(self):
+ super().__init__()
+ self.is_sliding = 0
+ self.meta = health_screen
+ # setting_language.add_event_cb(lambda e: self.load_screen(e, {"screen": "language"}), lv.EVENT.SHORT_CLICKED, None)
+ health_hr_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.health_cb(e, "heartrate")), lv.EVENT.SHORT_CLICKED, None)
+ # setting_themeswitch.add_event_cb(lambda e: self.load_screen(e, {"screen": "themeswitch"}), lv.EVENT.SHORT_CLICKED, None)
+ health_spo2_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.health_cb(e, "spo2")), lv.EVENT.SHORT_CLICKED, None)
+ health_temp_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.health_cb(e, "temperature")), lv.EVENT.SHORT_CLICKED, None)
+
+
+ health_hr_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.health_cb(e,"heartrate")), lv.EVENT.PRESSING, None)
+ # setting_themeswitch.add_event_cb(lambda e: self.load_screen(e, {"screen": "themeswitch"}), lv.EVENT.PRESSING, None)
+ health_spo2_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.health_cb(e, "spo2")), lv.EVENT.PRESSING, None)
+ health_temp_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.health_cb(e, "temperature")), lv.EVENT.PRESSING, None)
+
+ def health_cb(self,e,msg):
+ code = e.get_code()
+ if code == lv.EVENT.PRESSING:
+ #print("PRESSING")
+ self.is_sliding += 1
+
+ elif code == lv.EVENT.SHORT_CLICKED:
+ #utime.sleep_ms(10)
+ print("1self.is_sliding",self.is_sliding)
+ if self.is_sliding <= 5 and self.is_sliding != 0:#如果是在滑动中则不需要点击事件
+ self.is_sliding = 0
+ EventMesh.publish("load_screen", {"screen":"{}".format(msg)})
+
+ self.is_sliding =0
+
+ def done_return(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn1_release(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+##################################################################
+# -------------------------------------------language screen----------------------------------------------------------
--- /dev/null
+#主菜单
+import utime
+import osTimer
+import lvgl as lv
+import EventMesh
+from machine import Timer
+import voiceCall
+import osTimer
+import constants
+from misc import Power
+import pm
+from ui import Screen,style_font_youyuan_20_gray,style_font_youyuan_40
+from ui_WatchFaceScreen import WatchFace
+style_MainMenu_screen_default = lv.style_t()
+style_MainMenu_screen_default.init()
+style_MainMenu_screen_default.set_radius(0)
+style_MainMenu_screen_default.set_bg_color(lv.color_make(0x00, 0x00, 0x00))
+style_MainMenu_screen_default.set_bg_opa(255)
+style_MainMenu_screen_default.set_border_width(0)
+style_MainMenu_screen_default.set_pad_left(0)
+style_MainMenu_screen_default.set_pad_right(0)
+style_MainMenu_screen_default.set_pad_top(0)
+style_MainMenu_screen_default.set_pad_bottom(0)
+
+style_MainMenu_img_default = lv.style_t()
+style_MainMenu_img_default.init()
+style_MainMenu_img_default.set_img_recolor(lv.color_make(0xff,0xff,0xff))
+style_MainMenu_img_default.set_img_recolor_opa(0)
+style_MainMenu_img_default.set_img_opa(255)
+
+style_font_youyuan_20 = lv.style_t()
+style_font_youyuan_20.init()
+style_font_youyuan_20.set_text_color(lv.color_make(0xff, 0xff, 0xff))
+style_font_youyuan_20.set_text_font_v2("font_28.bin",28,0)
+
+style_font_youyuan_25 = lv.style_t()
+style_font_youyuan_25.init()
+style_font_youyuan_25.set_text_color(lv.color_make(0xff, 0xff, 0xff))
+style_font_youyuan_25.set_text_font_v2("font_28.bin",28,0)
+
+
+
+style_btn = lv.style_t()
+style_btn.init()
+style_btn.set_bg_opa(lv.OPA.TRANSP)
+style_btn.set_shadow_opa(0)
+style_btn.set_border_width(0)
+
+
+# MainMenu = lv.obj()
+# class MainMenuScreen(Screen):
+# NAME = "main_menu"
+
+# def __init__(self):
+# super().__init__()
+# #主菜单
+# self.meta = MainMenu
+# self.main_menu_style_num = "MainMenu2"
+
+# def initialization(self):
+# print("main_menu INIT !!!!!!!!")
+# EventMesh.publish("load_screen", {"screen": self.main_menu_style_num})
+
+
+# def post_processor_after_instantiation(self):
+# EventMesh.subscribe("change_style", self.change_style)
+
+
+# def change_style(self, event=None, msg=None): #换风格
+# self.main_menu_style_num = msg
+# EventMesh.publish("load_screen", {"screen": self.main_menu_style_num})
+
+# def Close(self):
+# return
+
+
+# def done_return(self):
+# EventMesh.publish("load_screen", {"screen": "Watchface"})
+
+# def btn1_release(self):
+# EventMesh.publish("load_screen", {"screen": "Watchface"})
+
+# def btn8_press(self):
+# EventMesh.publish("load_screen", {"screen": "Watchface"})
+
+
+
+
+
+style_font_youyuan_font_60 = lv.style_t()
+style_font_youyuan_font_60.init()
+style_font_youyuan_font_60.set_text_color(lv.color_make(0xFF, 0xFF, 0xFF))
+style_font_youyuan_font_60.set_text_font(lv.font_60_main_menu)
+MainMenu2x = 0
+MainMenu2_num = 0
+MainMenu2 = lv.obj()
+print("MainMenu2")
+MainMenu2_til = lv.tileview(MainMenu2)
+MainMenu2_til.set_scrollbar_mode(0)
+MainMenu2_til.add_style(style_MainMenu_screen_default, lv.PART.MAIN | lv.STATE.DEFAULT)
+#MainMenu2_til.add_flag(lv.obj.FLAG.SCROLL_ELASTIC)
+#LV_OBJ_FLAG_SCROLL_MOMENTUM
+#表盘
+MainMenu2_Watchface = MainMenu2_til.add_tile(0, 1, lv.DIR.LEFT | lv.DIR.RIGHT)
+
+label_text = lv.label(MainMenu2_Watchface)
+label_text.set_pos(0, 240)
+label_text.set_size(0, 0)
+label_text.set_text("0")
+MainMenu2_num+=1
+# #支付宝
+# MainMenu2_alipay = MainMenu2_til.add_tile(MainMenu2x, 0, lv.DIR.LEFT | lv.DIR.RIGHT)
+# #MainMenu2_alipay.set_tile_act(7,0,lv.ANIM.ON)#设置拼接
+# label_text = lv.label(MainMenu2_alipay)
+# label_text.set_pos(0, 240)
+# label_text.set_size(0, 0)
+# label_text.set_text("{}".format(MainMenu2_num))
+# MainMenu2_img_alipay_text = lv.label(MainMenu2_alipay)
+# MainMenu2_img_alipay_text.set_pos(int(0),int(220))
+# MainMenu2_img_alipay_text.set_size(240,100)
+# MainMenu2_img_alipay_text.add_flag(lv.obj.FLAG.CLICKABLE)
+# MainMenu2_img_alipay_text.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+# MainMenu2_img_alipay_text.set_text("支付宝")
+# MainMenu2_img_alipay_text.add_style(style_font_youyuan_font_60, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+# MainMenu2_img_alipay = lv.img(MainMenu2_alipay)
+# MainMenu2_img_alipay.set_size(160,160)
+# MainMenu2_img_alipay.set_pos(40,20)
+# MainMenu2_img_alipay.set_src("U:/static/alipay_.png")
+# MainMenu2_img_alipay.add_flag(lv.obj.FLAG.CLICKABLE)
+# MainMenu2_img_alipay.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT)
+# MainMenu2_num+=1
+# MainMenu2x+=1
+
+# label_alipay.set_long_mode(lv.label.LONG.WRAP)
+# label_alipay.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+# label_alipay.add_style(style_font_youyuan_25, lv.PART.MAIN | lv.STATE.DEFAULT)
+#拨号盘
+MainMenu2_phone = MainMenu2_til.add_tile(MainMenu2x, 0, lv.DIR.LEFT | lv.DIR.RIGHT)
+label_text = lv.label(MainMenu2_phone)
+label_text.set_pos(0, 240)
+label_text.set_size(0, 0)
+label_text.set_text("{}".format(MainMenu2_num))
+MainMenu2_img_phone = lv.img(MainMenu2_phone)
+MainMenu2_img_phone.set_size(160,160)
+MainMenu2_img_phone.set_pos(40,20)
+MainMenu2_img_phone.set_src("U:/static/IMAGE_ONE_PAGE_CALL.png")
+MainMenu2_img_phone.add_flag(lv.obj.FLAG.CLICKABLE)
+MainMenu2_img_phone.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+MainMenu2_img_phone_text = lv.label(MainMenu2_phone)
+MainMenu2_img_phone_text.set_pos(int(0),int(220))
+MainMenu2_img_phone_text.set_size(240,100)
+MainMenu2_img_phone_text.add_flag(lv.obj.FLAG.CLICKABLE)
+MainMenu2_img_phone_text.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+MainMenu2_img_phone_text.set_text("拨号盘")
+MainMenu2_img_phone_text.add_style(style_font_youyuan_font_60, lv.PART.MAIN|lv.STATE.DEFAULT)
+MainMenu2_num+=1
+MainMenu2x+=1
+
+#通讯录
+MainMenu2_contacts = MainMenu2_til.add_tile(MainMenu2x, 0, lv.DIR.LEFT | lv.DIR.RIGHT)
+label_text = lv.label(MainMenu2_contacts)
+label_text.set_pos(0, 240)
+label_text.set_size(0, 0)
+label_text.set_text("{}".format(MainMenu2_num))
+MainMenu2_img_contacts = lv.img(MainMenu2_contacts)
+MainMenu2_img_contacts.set_size(160,160)
+MainMenu2_img_contacts.set_pos(40,20)
+MainMenu2_img_contacts.set_src("U:/static/IMAGE_ONE_PAGE_CONTACTS.png")
+MainMenu2_img_contacts.add_flag(lv.obj.FLAG.CLICKABLE)
+MainMenu2_img_contacts.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+MainMenu2_img_contacts_txt = lv.label(MainMenu2_contacts)
+MainMenu2_img_contacts_txt.set_pos(int(0),int(220))
+MainMenu2_img_contacts_txt.set_size(240,100)
+MainMenu2_img_contacts_txt.add_flag(lv.obj.FLAG.CLICKABLE)
+MainMenu2_img_contacts_txt.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+MainMenu2_img_contacts_txt.set_text("联系人")
+MainMenu2_img_contacts_txt.add_style(style_font_youyuan_font_60, lv.PART.MAIN|lv.STATE.DEFAULT)
+MainMenu2_num+=1
+MainMenu2x+=1
+
+#短信
+MainMenu2_SMS = MainMenu2_til.add_tile(MainMenu2x, 0, lv.DIR.LEFT | lv.DIR.RIGHT)
+label_text = lv.label(MainMenu2_SMS)
+label_text.set_pos(0, 240)
+label_text.set_size(0, 0)
+label_text.set_text("{}".format(MainMenu2_num))
+MainMenu2_img_sms = lv.img(MainMenu2_SMS)
+MainMenu2_img_sms.set_size(160,160)
+MainMenu2_img_sms.set_pos(40,20)
+MainMenu2_img_sms.set_src("U:/static/IMAGE_ONE_PAGE_SMS.png")
+MainMenu2_img_sms.add_flag(lv.obj.FLAG.CLICKABLE)
+MainMenu2_img_sms.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+MainMenu2_img_sms_txt = lv.label(MainMenu2_SMS)
+MainMenu2_img_sms_txt.set_pos(int(0),int(220))
+MainMenu2_img_sms_txt.set_size(240,100)
+MainMenu2_img_sms_txt.add_flag(lv.obj.FLAG.CLICKABLE)
+MainMenu2_img_sms_txt.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+MainMenu2_img_sms_txt.set_text("短信")
+MainMenu2_img_sms_txt.add_style(style_font_youyuan_font_60, lv.PART.MAIN|lv.STATE.DEFAULT)
+MainMenu2_num+=1
+MainMenu2x+=1
+
+#微聊
+MainMenu2_wechat = MainMenu2_til.add_tile(MainMenu2x, 0, lv.DIR.LEFT | lv.DIR.RIGHT)
+label_text = lv.label(MainMenu2_wechat)
+label_text.set_pos(0, 240)
+label_text.set_size(0, 0)
+label_text.set_text("{}".format(MainMenu2_num))
+MainMenu2_img_wechat = lv.img(MainMenu2_wechat)
+MainMenu2_img_wechat.set_size(160,160)
+MainMenu2_img_wechat.set_pos(40,20)
+MainMenu2_img_wechat.set_src("U:/static/IMAGE_ONE_PAGE_WECHAT.png")
+MainMenu2_img_wechat.add_flag(lv.obj.FLAG.CLICKABLE)
+MainMenu2_img_wechat.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+MainMenu2_img_wechat_txt = lv.label(MainMenu2_wechat)
+MainMenu2_img_wechat_txt.set_pos(int(0),int(220))
+MainMenu2_img_wechat_txt.set_size(240,100)
+MainMenu2_img_wechat_txt.add_flag(lv.obj.FLAG.CLICKABLE)
+MainMenu2_img_wechat_txt.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+MainMenu2_img_wechat_txt.set_text("微聊")
+MainMenu2_img_wechat_txt.add_style(style_font_youyuan_font_60, lv.PART.MAIN|lv.STATE.DEFAULT)
+MainMenu2_num+=1
+MainMenu2x+=1
+
+#健康测量
+MainMenu2_heartrate = MainMenu2_til.add_tile(MainMenu2x, 0, lv.DIR.LEFT | lv.DIR.RIGHT)
+label_text = lv.label(MainMenu2_heartrate)
+label_text.set_pos(0, 240)
+label_text.set_size(0, 0)
+label_text.set_text("{}".format(MainMenu2_num))
+MainMenu2_img_health = lv.img(MainMenu2_heartrate)
+MainMenu2_img_health.set_size(160,160)
+MainMenu2_img_health.set_pos(40,20)
+MainMenu2_img_health.set_src("U:/static/IMAGE_ONE_PAGE_HEALTH.png")
+MainMenu2_img_health.add_flag(lv.obj.FLAG.CLICKABLE)
+MainMenu2_img_health.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+MainMenu2_img_health_txt = lv.label(MainMenu2_heartrate)
+MainMenu2_img_health_txt.set_pos(int(0),int(220))
+MainMenu2_img_health_txt.set_size(240,100)
+MainMenu2_img_health_txt.add_flag(lv.obj.FLAG.CLICKABLE)
+MainMenu2_img_health_txt.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+MainMenu2_img_health_txt.set_text("健康测量")
+MainMenu2_img_health_txt.add_style(style_font_youyuan_font_60, lv.PART.MAIN|lv.STATE.DEFAULT)
+MainMenu2_num+=1
+MainMenu2x+=1
+#血样检测
+# MainMenu2_spo2 = MainMenu2_til.add_tile(4, 0, lv.DIR.LEFT | lv.DIR.RIGHT)
+# label_text = lv.label(MainMenu2_spo2)
+# label_text.set_pos(0, 240)
+# label_text.set_size(0, 0)
+# label_text.set_text("5")
+# MainMenu2_img_spo2 = lv.img(MainMenu2_spo2)
+# MainMenu2_img_spo2.set_size(160,160)
+# MainMenu2_img_spo2.set_pos(40,20)
+# MainMenu2_img_spo2.set_src("U:/static/IMAGE_ONE_PAGE_SPO2_DETECT.png")
+# MainMenu2_img_spo2.add_flag(lv.obj.FLAG.CLICKABLE)
+# MainMenu2_img_spo2.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+# MainMenu2_img_spo2_txt = lv.label(MainMenu2_spo2)
+# MainMenu2_img_spo2_txt.set_pos(int(0),int(220))
+# MainMenu2_img_spo2_txt.set_size(240,100)
+# MainMenu2_img_spo2_txt.add_flag(lv.obj.FLAG.CLICKABLE)
+# MainMenu2_img_spo2_txt.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+# MainMenu2_img_spo2_txt.set_text("血氧检测")
+# MainMenu2_img_spo2_txt.add_style(style_font_youyuan_font_60, lv.PART.MAIN|lv.STATE.DEFAULT)
+#MainMenu2_num+=1
+#MainMenu2x+=1
+
+# #sos
+# MainMenu2_setting = MainMenu2_til.add_tile(MainMenu2x, 0, lv.DIR.LEFT | lv.DIR.RIGHT)
+# #MainMenu2_setting.set_tile_act(0,0,lv.ANIM.ON)
+# label_text = lv.label(MainMenu2_setting)
+# label_text.set_pos(0, 240)
+# label_text.set_size(0, 0)
+# label_text.set_text("{}".format(MainMenu2_num))
+# MainMenu2_img_sos = lv.img(MainMenu2_setting)
+# MainMenu2_img_sos.set_size(160,160)
+# MainMenu2_img_sos.set_pos(40,20)
+# MainMenu2_img_sos.set_src("U:/static/IMAGE_ONE_PAGE_SOS.png")
+# MainMenu2_img_sos.add_flag(lv.obj.FLAG.CLICKABLE)
+# MainMenu2_img_sos.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+# MainMenu2_img_sos_txt = lv.label(MainMenu2_setting)
+# MainMenu2_img_sos_txt.set_pos(int(0),int(210))
+# MainMenu2_img_sos_txt.set_size(240,100)
+# MainMenu2_img_sos_txt.add_flag(lv.obj.FLAG.CLICKABLE)
+# MainMenu2_img_sos_txt.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+# MainMenu2_img_sos_txt.set_text("SOS")
+# MainMenu2_img_sos_txt.add_style(style_font_youyuan_40, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+# MainMenu2_img_sos_txt1 = lv.label(MainMenu2_setting)
+# MainMenu2_img_sos_txt1.set_pos(int(0),int(260))
+# MainMenu2_img_sos_txt1.set_size(240,60)
+# MainMenu2_img_sos_txt1.add_flag(lv.obj.FLAG.CLICKABLE)
+# MainMenu2_img_sos_txt1.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+# MainMenu2_img_sos_txt1.set_text("或长按【SOS键】3秒快速呼叫")
+# MainMenu2_img_sos_txt1.add_style(style_font_youyuan_20_gray, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+# MainMenu2_num+=1
+# MainMenu2x+=1
+
+#工具箱
+MainMenu2_toolbox = MainMenu2_til.add_tile(MainMenu2x, 0, lv.DIR.LEFT | lv.DIR.RIGHT)
+label_text = lv.label(MainMenu2_toolbox)
+label_text.set_pos(0, 240)
+label_text.set_size(0, 0)
+label_text.set_text("{}".format(MainMenu2_num))
+MainMenu2_img_toolbox = lv.img(MainMenu2_toolbox)
+MainMenu2_img_toolbox.set_size(160,160)
+MainMenu2_img_toolbox.set_pos(40,20)
+MainMenu2_img_toolbox.set_src("U:/static/IMAGE_ONE_PAGE_TOOLS.png")
+MainMenu2_img_toolbox.add_flag(lv.obj.FLAG.CLICKABLE)
+MainMenu2_img_toolbox.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+MainMenu2_img_toolbox_txt = lv.label(MainMenu2_toolbox)
+MainMenu2_img_toolbox_txt.set_pos(int(0),int(220))
+MainMenu2_img_toolbox_txt.set_size(240,100)
+MainMenu2_img_toolbox_txt.add_flag(lv.obj.FLAG.CLICKABLE)
+MainMenu2_img_toolbox_txt.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+MainMenu2_img_toolbox_txt.set_text("工具箱")
+MainMenu2_img_toolbox_txt.add_style(style_font_youyuan_font_60, lv.PART.MAIN|lv.STATE.DEFAULT)
+MainMenu2_num+=1
+MainMenu2x+=1
+
+
+
+#设置
+MainMenu2_setting = MainMenu2_til.add_tile(MainMenu2x, 0, lv.DIR.LEFT | lv.DIR.RIGHT)
+#MainMenu2_setting.set_tile_act(0,0,lv.ANIM.ON)
+label_text = lv.label(MainMenu2_setting)
+label_text.set_pos(0, 240)
+label_text.set_size(0, 0)
+label_text.set_text("{}".format(MainMenu2_num))
+MainMenu2_img_setting = lv.img(MainMenu2_setting)
+MainMenu2_img_setting.set_size(160,160)
+MainMenu2_img_setting.set_pos(40,20)
+MainMenu2_img_setting.set_src("U:/static/IMAGE_ONE_PAGE_SETTINGS.png")
+MainMenu2_img_setting.add_flag(lv.obj.FLAG.CLICKABLE)
+MainMenu2_img_setting.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+MainMenu2_img_setting_txt = lv.label(MainMenu2_setting)
+MainMenu2_img_setting_txt.set_pos(int(0),int(220))
+MainMenu2_img_setting_txt.set_size(240,100)
+MainMenu2_img_setting_txt.add_flag(lv.obj.FLAG.CLICKABLE)
+MainMenu2_img_setting_txt.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+MainMenu2_img_setting_txt.set_text("设置")
+MainMenu2_img_setting_txt.add_style(style_font_youyuan_font_60, lv.PART.MAIN|lv.STATE.DEFAULT)
+MainMenu2_num+=1
+MainMenu2x+=1
+
+
+
+
+
+
+#主菜单风格2,单页
+class MainMenuScreen(Screen):
+ NAME = "main_menu"
+ def __init__(self):
+ self.meta = MainMenu2
+ self.watchface = WatchFace()
+ self.menu_id = "0"
+ self.menu_new_id = "255"
+ self.menu_old_id = "255"
+ self.is_sliding = 0
+ self.scroll_begin_event_count = 0
+ self.menu_action = 0 # =1左滑 =2右划
+ print("MainMenu1:__init__")
+ MainMenu2_til.add_event_cb(lambda e: EventMesh.callback_wrapper(self.scroll_begin_event_cb(e)),lv.EVENT.SCROLL_END,None)
+ #lv_obj_add_event_cb(lv_tabview_get_content(tabview), scroll_begin_event, LV_EVENT_SCROLL_END, NULL);
+ MainMenu2_img_phone.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "Phone")), lv.EVENT.SHORT_CLICKED, None)
+ MainMenu2_img_toolbox.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "AI_success")), lv.EVENT.SHORT_CLICKED, None)
+ MainMenu2_img_setting.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "setting")), lv.EVENT.SHORT_CLICKED, None)
+ MainMenu2_img_health.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "health")), lv.EVENT.SHORT_CLICKED, None)
+ MainMenu2_img_contacts.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "contacts")), lv.EVENT.SHORT_CLICKED, None)
+ MainMenu2_img_wechat.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "wechat")), lv.EVENT.SHORT_CLICKED, None)
+ # MainMenu2_img_sos.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "sos")), lv.EVENT.SHORT_CLICKED, None)
+ MainMenu2_img_sms.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "popup")), lv.EVENT.SHORT_CLICKED, None)
+ # MainMenu2_img_sos.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "popup")), lv.EVENT.SHORT_CLICKED, None)
+ #MainMenu2_img_alipay.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "alipay_open")), lv.EVENT.SHORT_CLICKED, None)
+
+
+ MainMenu2_img_phone.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "Phone")), lv.EVENT.PRESSING, None)
+ MainMenu2_img_toolbox.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "AI_success")), lv.EVENT.PRESSING, None)
+ MainMenu2_img_setting.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "setting")), lv.EVENT.PRESSING, None)
+ MainMenu2_img_health.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "health")), lv.EVENT.PRESSING, None)
+ MainMenu2_img_contacts.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "contacts")), lv.EVENT.PRESSING, None)
+ MainMenu2_img_wechat.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "wechat")), lv.EVENT.PRESSING, None)
+ # MainMenu2_img_sos.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "sos")), lv.EVENT.PRESSING, None)
+ MainMenu2_img_sms.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "popup")), lv.EVENT.PRESSING, None)
+ # MainMenu2_img_sos.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "popup")), lv.EVENT.PRESSING, None)
+ #MainMenu2_img_alipay.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "alipay_open")), lv.EVENT.PRESSING, None)
+
+ EventMesh.subscribe("watch_top_show", self.watch_top_show)
+ EventMesh.subscribe("return_alipay", self.return_alipay)
+ EventMesh.subscribe("return_setiing", self.return_setiing)
+ #MainMenu2_img_alipay.add_event_cb(lambda e: img_cb(e, "Watchface_set"), lv.EVENT.CLICKED, None)
+
+ def initialization(self):
+ self.is_sliding=0
+ self.watchface.initialization(MainMenu2_Watchface)
+
+ if self.menu_id =="0":
+ MainMenu2_til.set_tile_id(0,1,lv.ANIM.OFF)
+ # if self.meta_info in globals() :
+ # MainMenu2_til.set_tile_id(self.meta_info[0],self.meta_info[1],lv.ANIM.OFF)
+ pass#
+
+ def scroll_begin_event_cb(self, e):
+ pass
+ # EventMesh.publish("publish_message_event_ui",{"func":self.scroll_begin_event,"data":0})
+ # def scroll_begin_event(self, data):
+ #处理轻微滑动不跳页面问题
+ # self.scroll_begin_event_count+=1
+
+ # if self.scroll_begin_event_count == 1:
+ # self.menu_new_id = MainMenu2_til.get_tile_act().get_child(0).get_text()
+ # #print("scroll_begin_event scroll_begin_event {} old_id {} new_id{}".format(self.scroll_begin_event_count,self.menu_old_id,self.menu_new_id))
+ # elif self.scroll_begin_event_count == 2:
+ # self.menu_old_id = MainMenu2_til.get_tile_act().get_child(0).get_text()
+ # print("scroll_begin_event menu_action {} old_id {} new_id {}".format(self.menu_action,self.menu_old_id,self.menu_new_id))
+ # self.scroll_begin_event_count = 0
+ # if self.menu_old_id == self.menu_new_id and self.menu_action == 1:
+ # MainMenu2_til.set_tile_id(int(self.menu_old_id)-2,0,lv.ANIM.ON)
+ # print("scroll_begin_event menu_action == 1")
+ # elif self.menu_old_id == self.menu_new_id and self.menu_action == 2:
+ # print("scroll_begin_event menu_action == 2")
+ # MainMenu2_til.set_tile_id(int(self.menu_old_id),0,lv.ANIM.ON)
+ # self.menu_action = 0
+ # else :
+ # self.scroll_begin_event_count = 0
+
+ # MainMenu = e.get_target()
+ # code = e.get_code()
+ # print("MainMenu2:scroll_begin_event code {}!!!!!".format(code))
+ # if code == lv.EVENT.SCROLL_END:
+ # pass
+ def watch_top_show(self, event, msg): #
+ MainMenu2_til.set_tile_id(0,1,lv.ANIM.OFF)
+
+ def img_cb(self, e, msg):
+ code = e.get_code()
+
+ #print("code!!!!!!!!",code,msg)
+ if code == lv.EVENT.PRESSING:
+ #print("PRESSING")
+ self.is_sliding += 1
+
+ elif code == lv.EVENT.SHORT_CLICKED:
+ #utime.sleep_ms(10)
+ # print("1self.is_sliding",self.is_sliding)
+ if self.is_sliding <= 5 and self.is_sliding != 0:#如果是在滑动中则不需要点击事件
+ self.is_sliding =0
+ print("MainMenu2:img_cb:{}".format(msg))
+ if msg == "sos":
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#有卡时触发sos报警 无卡时自动关机
+ sos_number = EventMesh.publish("get_dial_sos_number")
+ if sos_number != None:
+ if len(sos_number) != 0:
+ screen_NAME = EventMesh.publish("get_screen_NAME")
+ if screen_NAME != None:
+ if screen_NAME != "SOS_POPUP":
+ EventMesh.publish("load_screen", {"screen": "SOS_POPUP"})
+ else:
+ EventMesh.publish("load_screen", {"screen": "NO_SOS_POPUP"})
+ else:
+ EventMesh.publish("load_screen", {"screen": "no_sim_power_screen"})
+ return
+ EventMesh.publish("load_screen", {"screen": "{}".format(msg)})
+ self.is_sliding =0
+
+ def lcd_on(self):
+ self.watchface.watchface_style.timerout_update()
+ self.watchface.timer_update.start(10000, 1, self.watchface.timerout_update)
+
+ def lcd_off(self):
+ self.watchface.timer_update.stop()
+
+ def done_return(self):
+ MainMenu2_til.set_tile_id(0,1,lv.ANIM.OFF)
+
+ def btn1_release(self):
+ flag = EventMesh.publish("get_lcd_state")
+ if flag == 0:
+ EventMesh.publish(constants.EVENT.SYSTEM_UP)
+ else:
+ if MainMenu2_til.get_tile_act() != None:
+ id = MainMenu2_til.get_tile_act().get_child(0).get_text()
+ if id != "0":
+ MainMenu2_til.set_tile_id(0,1,lv.ANIM.OFF)
+ else:
+ EventMesh.publish("load_screen", {"screen": "alipay_open"})
+
+ def return_alipay(self, event, msg):
+ MainMenu2_til.set_tile_id(0,0,lv.ANIM.OFF)
+
+ def return_setiing(self, event, msg):
+ MainMenu2_til.set_tile_id(7,0,lv.ANIM.OFF)
+
+
+
+ def btn8_press(self):
+ flag = EventMesh.publish("get_lcd_state")
+ if MainMenu2_til.get_tile_act() != None:
+ id = MainMenu2_til.get_tile_act().get_child(0).get_text()
+ if id == "0":
+ if flag == 1:
+ EventMesh.publish(constants.EVENT.SYSTEM_SLEEP)
+ else:
+ EventMesh.publish(constants.EVENT.SYSTEM_UP)
+ else:
+ if flag == 1:
+ MainMenu2_til.set_tile_id(0,1,lv.ANIM.OFF)
+ else:
+ EventMesh.publish(constants.EVENT.SYSTEM_UP)
+ else:
+ if flag == 1:
+ MainMenu2_til.set_tile_id(0,1,lv.ANIM.OFF)
+ else:
+ EventMesh.publish(constants.EVENT.SYSTEM_UP)
+
+ def done_bottom_to_top(self):
+ id = MainMenu2_til.get_tile_act().get_child(0).get_text()
+ if id == "0":
+ EventMesh.publish("load_screen", {"screen": "call_log"})
+ self.menu_id = id
+
+ def done_top_to_bottom(self):
+ id = MainMenu2_til.get_tile_act().get_child(0).get_text()
+ if id == "0":
+ EventMesh.publish("load_screen", {"screen": "popup"})
+ self.menu_id = id
+ def done_left_to_right(self):
+ id = MainMenu2_til.get_tile_act().get_child(0).get_text()
+ # print("done_left_to_right:ID{} menu_id{}".format(id,self.menu_id))
+ if id == "0":
+ MainMenu2_til.set_tile_id(MainMenu2_num-2,0,lv.ANIM.OFF)
+ elif self.menu_id != '2' and id == '1':
+ MainMenu2_til.set_tile_id(MainMenu2_num-2,0,lv.ANIM.OFF)
+ elif self.menu_id == id :
+ self.menu_action = 1
+ self.menu_id = id
+ def done_right_to_left(self):
+ id = MainMenu2_til.get_tile_act().get_child(0).get_text()
+ # print("done_right_to_left:ID{} menu_id{}".format(id,self.menu_id))
+ if id == "0":
+ MainMenu2_til.set_tile_id(0,0,lv.ANIM.OFF)
+ elif (self.menu_id != str(MainMenu2_num-2) ) and id == str(MainMenu2_num-1) :
+ MainMenu2_til.set_tile_id(0,0,lv.ANIM.OFF)
+ else :
+ self.menu_action = 2
+ self.menu_id = id
+
+ def Close(self):
+ self.watchface.Close()
+ print("main_menu Close !!!!!!!!")
+ self.menu_id = '1'
+ return
+
--- /dev/null
+
+import lvgl as lv
+import ql_fs
+import EventMesh
+from misc import Power
+from ui import style_screen,style_font_youyuan_20_gray,style_font_youyuan_20,style_btn,style_img,Screen,style_contact_btn,style_bar,style_bar_indic
+import constants
+import osTimer
+import audio
+from machine import Pin
+import ujson
+from lcd import style_font_youyuan_40
+# -------------------------------------------setting screen----------------------------------------------------------
+
+
+
+style_volume_btn = lv.style_t()
+style_volume_btn.init()
+style_volume_btn.set_shadow_opa(0)
+style_volume_btn.set_border_width(0)
+style_volume_btn.set_bg_color(lv.color_make(0x80, 0x80, 0x80))
+
+
+
+setting_cont_y = 0
+setting_screen = lv.obj()
+print("setting_screen")
+setting_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+setting_imei_img = lv.img(setting_screen)
+setting_imei_img.set_pos(75, 10)
+setting_imei_img.set_size(90, 30)
+setting_imei_img.set_src("E:/static/setting/setting_text.png")
+setting_imei_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+# setting_title = lv.label(setting)
+# setting_title.set_pos(0, 10)
+# setting_title.set_size(240, 40)
+# setting_title.set_text("设置")
+# setting_title.set_long_mode(lv.label.LONG.WRAP)
+# setting_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+# setting_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_cont_style = lv.style_t()
+setting_cont_style.init()
+setting_cont_style.set_radius(0)
+setting_cont_style.set_bg_color(lv.color_make(0x00, 0x00, 0x00))
+setting_cont_style.set_bg_grad_color(lv.color_make(0x00, 0x00, 0x00))
+setting_cont_style.set_bg_grad_dir(lv.GRAD_DIR.VER)
+setting_cont_style.set_bg_opa(255)
+setting_cont_style.set_border_width(0)
+setting_cont_style.set_pad_left(0)
+setting_cont_style.set_pad_right(0)
+setting_cont_style.set_pad_top(0)
+setting_cont_style.set_pad_bottom(0)
+
+
+setting_cont = lv.obj(setting_screen)
+setting_cont.set_pos(0, 50)
+setting_cont.set_size(240, 270)
+setting_cont.add_style(setting_cont_style,lv.PART.MAIN | lv.STATE.DEFAULT)
+
+# setting_language = lv.btn(setting_cont)
+# setting_language.set_pos(0, setting_cont_y)
+# setting_language.set_size(240, 54)
+# setting_language_label = lv.label(setting_language)
+# setting_language_label.set_text("语言设置")
+# setting_language.set_style_pad_all(0, lv.STATE.DEFAULT)
+# setting_language_label.align(lv.ALIGN.LEFT_MID, 70, 0)
+# setting_language_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+# setting_language_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+# setting_language.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+# setting_language_img = lv.img(setting_cont)
+# setting_language_img.set_pos(10, setting_cont_y)set_size(47, 47)
+# setting_language_img.set_size(232, 80)
+# setting_language_img.add_flag(lv.obj.FLAG.CLICKABLE)
+# setting_language_img.set_src("E:/static/menu_language.png")
+# setting_language_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+#setting_cont_y += 60
+
+setting_dialswitch = lv.btn(setting_cont)
+setting_dialswitch.set_pos(0, setting_cont_y)
+setting_dialswitch.set_size(0, 0)
+setting_dialswitch_label = lv.label(setting_dialswitch)
+setting_dialswitch_label.set_text("表盘切换")
+setting_dialswitch.set_style_pad_all(0, lv.STATE.DEFAULT)
+setting_dialswitch_label.align(lv.ALIGN.LEFT_MID, 70, 0)
+setting_dialswitch_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+setting_dialswitch_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_dialswitch.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_dialswitch_img = lv.img(setting_cont)
+setting_dialswitch_img.set_pos(0, setting_cont_y)
+setting_dialswitch_img.set_size(232, 80)
+setting_dialswitch_img.add_flag(lv.obj.FLAG.CLICKABLE)
+setting_dialswitch_img.set_src("E:/static/setting/menu_watch_switch.png")
+setting_dialswitch_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_cont_y+=90
+
+
+# setting_themeswitch = lv.btn(setting_cont)
+# setting_themeswitch.set_pos(0, 120)
+# setting_themeswitch.set_size(240, 54)
+# setting_themeswitch_label = lv.label(setting_themeswitch)
+# setting_themeswitch_label.set_text("主题切换")
+# setting_themeswitch.set_style_pad_all(0, lv.STATE.DEFAULT)
+# setting_themeswitch_label.align(lv.ALIGN.LEFT_MID, 70, 0)
+# setting_themeswitch_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+# setting_themeswitch_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+# setting_themeswitch.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+# setting_themeswitch_img = lv.img(setting_cont)
+# setting_themeswitch_img.set_pos(10, 120)
+# setting_themeswitch_img.set_size(232, 80)
+# setting_themeswitch_img.add_flag(lv.obj.FLAG.CLICKABLE)
+# setting_themeswitch_img.set_src("E:/static/menu_theme_switch.png")
+# setting_themeswitch_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+#setting_cont_y+=60
+
+setting_imei = lv.btn(setting_cont)
+setting_imei.set_pos(0, setting_cont_y)
+setting_imei.set_size(0, 0)
+setting_imei_label = lv.label(setting_imei)
+setting_imei_label.set_text("设备IMEI号")
+setting_imei.set_style_pad_all(0, lv.STATE.DEFAULT)
+setting_imei_label.align(lv.ALIGN.LEFT_MID, 70, 0)
+setting_imei_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+setting_imei_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_imei.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_imei_img = lv.img(setting_cont)
+setting_imei_img.set_pos(0, setting_cont_y)
+setting_imei_img.set_size(232, 80)
+setting_imei_img.add_flag(lv.obj.FLAG.CLICKABLE)
+setting_imei_img.set_src("E:/static/setting/menu_imei_qrcode.png")
+setting_imei_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_cont_y+=90
+
+setting_app = lv.btn(setting_cont)
+setting_app.set_pos(0, setting_cont_y)
+setting_app.set_size(0, 0)
+setting_app_label = lv.label(setting_app)
+setting_app_label.set_text("手机安装APP")
+setting_app.set_style_pad_all(0, lv.STATE.DEFAULT)
+setting_app_label.align(lv.ALIGN.LEFT_MID, 70, 0)
+setting_app_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+setting_app_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_app.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_app_img = lv.img(setting_cont)
+setting_app_img.set_pos(0, setting_cont_y)
+setting_app_img.set_size(232, 80)
+setting_app_img.add_flag(lv.obj.FLAG.CLICKABLE)
+setting_app_img.set_src("E:/static/setting/menu_app_qrcode.png")
+setting_app_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_cont_y+=90
+
+setting_bright = lv.btn(setting_cont)
+setting_bright.set_pos(0, setting_cont_y)
+setting_bright.set_size(0, 0)
+setting_bright_label = lv.label(setting_bright)
+setting_bright_label.set_text("屏幕调节")
+setting_bright.set_style_pad_all(0, lv.STATE.DEFAULT)
+setting_bright_label.align(lv.ALIGN.LEFT_MID, 70, 0)
+setting_bright_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+setting_bright_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_bright.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_bright_img = lv.img(setting_cont)
+setting_bright_img.set_pos(0, setting_cont_y)
+setting_bright_img.set_size(232, 80)
+setting_bright_img.add_flag(lv.obj.FLAG.CLICKABLE)
+setting_bright_img.set_src("E:/static/setting/menu_bright.png")
+setting_bright_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_cont_y+=90
+
+setting_volume = lv.btn(setting_cont)
+setting_volume.set_pos(0, setting_cont_y)
+setting_volume.set_size(0, 0)
+setting_volume_label = lv.label(setting_volume)
+setting_volume_label.set_text("铃声")
+setting_volume.set_style_pad_all(0, lv.STATE.DEFAULT)
+setting_volume_label.align(lv.ALIGN.LEFT_MID, 70, 0)
+setting_volume_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+setting_volume_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_volume.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_volume_img = lv.img(setting_cont)
+setting_volume_img.set_pos(0, setting_cont_y)
+setting_volume_img.set_size(232, 80)
+setting_volume_img.add_flag(lv.obj.FLAG.CLICKABLE)
+setting_volume_img.set_src("E:/static/setting/menu_volume.png")
+setting_volume_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_cont_y+=90
+
+setting_restore = lv.btn(setting_cont)
+setting_restore.set_pos(0, setting_cont_y)
+setting_restore.set_size(0, 0)
+setting_restore_label = lv.label(setting_restore)
+setting_restore_label.set_text("恢复出厂设置")
+setting_restore.set_style_pad_all(0, lv.STATE.DEFAULT)
+setting_restore_label.align(lv.ALIGN.LEFT_MID, 70, 0)
+setting_restore_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+setting_restore_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_restore.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_restore_img = lv.img(setting_cont)
+setting_restore_img.set_pos(0, setting_cont_y)
+setting_restore_img.set_size(232, 80)
+setting_restore_img.add_flag(lv.obj.FLAG.CLICKABLE)
+setting_restore_img.set_src("E:/static/setting/menu_restore.png")
+setting_restore_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_cont_y+=90
+
+setting_poweroff = lv.btn(setting_cont)
+setting_poweroff.set_pos(0, setting_cont_y)
+setting_poweroff.set_size(0, 0)
+setting_poweroff_label = lv.label(setting_poweroff)
+setting_poweroff_label.set_text("关机")
+setting_poweroff.set_style_pad_all(0, lv.STATE.DEFAULT)
+setting_poweroff_label.align(lv.ALIGN.LEFT_MID, 70, 0)
+setting_poweroff_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+setting_poweroff_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_poweroff.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_poweroff_img = lv.img(setting_cont)
+setting_poweroff_img.set_pos(0, setting_cont_y)
+setting_poweroff_img.set_size(232, 80)
+setting_poweroff_img.add_flag(lv.obj.FLAG.CLICKABLE)
+setting_poweroff_img.set_src("E:/static/setting/menu_poweroff.png")
+setting_poweroff_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_cont_y+=90
+
+setting_version = lv.btn(setting_cont)
+setting_version.set_pos(0, setting_cont_y)
+setting_version.set_size(0, 0)
+setting_version_label = lv.label(setting_version)
+setting_version_label.set_text("关于设备")
+setting_version.set_style_pad_all(0, lv.STATE.DEFAULT)
+setting_version_label.align(lv.ALIGN.LEFT_MID, 70, 0)
+setting_version_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+setting_version_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_version.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_version_img = lv.img(setting_cont)
+setting_version_img.set_pos(0, setting_cont_y)
+setting_version_img.set_size(232, 80)
+setting_version_img.add_flag(lv.obj.FLAG.CLICKABLE)
+setting_version_img.set_src("E:/static/setting/menu_version.png")
+setting_version_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+setting_cont_y+=90
+
+# setting_update = lv.btn(setting_cont)
+# setting_update.set_pos(0, setting_cont_y)
+# setting_update.set_size(0, 0)
+# setting_update_label = lv.label(setting_update)
+# setting_update_label.set_text("系统升级")
+# setting_update.set_style_pad_all(0, lv.STATE.DEFAULT)
+# setting_update_label.align(lv.ALIGN.LEFT_MID, 70, 0)
+# setting_update_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+# setting_update_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+# setting_update.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+# setting_update_img = lv.img(setting_cont)
+# setting_update_img.set_pos(0, setting_cont_y)
+# setting_update_img.set_size(232, 80)
+# setting_update_img.add_flag(lv.obj.FLAG.CLICKABLE)
+# setting_update_img.set_src("E:/static/setting/menu_upgrade.png")
+# setting_update_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+class SettingScreen(Screen):
+ NAME = "setting"
+
+ def __init__(self):
+ super().__init__()
+ self.is_sliding = 0
+ self.meta = setting_screen
+ # setting_language.add_event_cb(lambda e: self.load_screen(e, {"screen": "language"}), lv.EVENT.CLICKED, None)
+ setting_dialswitch.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e, "dialswitch")), lv.EVENT.CLICKED, None)
+ # setting_themeswitch.add_event_cb(lambda e: self.load_screen(e, {"screen": "themeswitch"}), lv.EVENT.CLICKED, None)
+ setting_imei.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e, "imei")), lv.EVENT.CLICKED, None)
+ setting_app.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e, "app")), lv.EVENT.CLICKED, None)
+ setting_bright.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e,"brightness")), lv.EVENT.CLICKED, None)
+ setting_volume.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e,"totalvolume")), lv.EVENT.CLICKED, None)
+ setting_restore.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e, "restore")), lv.EVENT.CLICKED, None)
+ setting_poweroff.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e, "poweroff")), lv.EVENT.CLICKED, None)
+ # setting_update.add_event_cb(lambda e: EventMesh.callback_wrapper(self.load_screen(e, {"screen": "update"})), lv.EVENT.CLICKED, None)
+ setting_version.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e, "version")), lv.EVENT.CLICKED, None)
+
+ # img regist btton
+ # setting_language.add_event_cb(lambda e: self.load_screen(e, {"screen": "language"}), lv.EVENT.CLICKED, None)
+ setting_dialswitch_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e, "dialswitch")), lv.EVENT.CLICKED, None)
+ # setting_themeswitch.add_event_cb(lambda e: self.load_screen(e, {"screen": "themeswitch"}), lv.EVENT.CLICKED, None)
+ setting_imei_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e, "imei")), lv.EVENT.CLICKED, None)
+ setting_app_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e, "app")), lv.EVENT.CLICKED, None)
+ setting_bright_img.add_event_cb(lambda e:EventMesh.callback_wrapper( self.setting_cb(e, "brightness")), lv.EVENT.CLICKED, None)
+ setting_volume_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e, "totalvolume")), lv.EVENT.CLICKED, None)
+ setting_restore_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e,"restore")), lv.EVENT.CLICKED, None)
+ setting_poweroff_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e, "poweroff")), lv.EVENT.CLICKED, None)
+ # setting_update_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.load_screen(e, {"screen": "update"})), lv.EVENT.CLICKED, None)
+ setting_version_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e, "version")), lv.EVENT.CLICKED, None)
+
+
+ setting_dialswitch_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e, "dialswitch")), lv.EVENT.PRESSING, None)
+ # setting_themeswitch.add_event_cb(lambda e: self.load_screen(e, {"screen": "themeswitch"}), lv.EVENT.CLICKED, None)
+ setting_imei_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e, "imei")), lv.EVENT.PRESSING, None)
+ setting_app_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e, "app")), lv.EVENT.PRESSING, None)
+ setting_bright_img.add_event_cb(lambda e:EventMesh.callback_wrapper( self.setting_cb(e,"brightness")), lv.EVENT.PRESSING, None)
+ setting_volume_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e, "totalvolume")), lv.EVENT.PRESSING, None)
+ setting_restore_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e, "restore")), lv.EVENT.PRESSING, None)
+ setting_poweroff_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e,"poweroff")), lv.EVENT.PRESSING, None)
+ # setting_update_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.load_screen(e, {"screen": "update"})), lv.EVENT.CLICKED, None)
+ setting_version_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e, "version")), lv.EVENT.PRESSING, None)
+
+
+ def setting_cb(self,e,msg):
+ code = e.get_code()
+ if code == lv.EVENT.PRESSING:
+ #print("PRESSING")
+ self.is_sliding += 1
+
+ elif code == lv.EVENT.CLICKED:
+ #utime.sleep_ms(10)
+ print("1self.is_sliding",self.is_sliding)
+ if self.is_sliding <= 5 and self.is_sliding != 0:#如果是在滑动中则不需要点击事件
+ self.is_sliding = 0
+ EventMesh.publish("load_screen", {"screen":"{}".format(msg)})
+
+ self.is_sliding =0
+
+ def done_return(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn1_release(self):
+ EventMesh.publish("return_setiing")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+##################################################################
+# -------------------------------------------language screen----------------------------------------------------------
+language_screen = lv.obj()
+print("language_screen")
+language_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+language_title = lv.label(language_screen)
+language_title.set_pos(0, 10)
+language_title.set_size(240, 40)
+language_title.set_text("语言设置")
+language_title.set_long_mode(lv.label.LONG.WRAP)
+language_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+language_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+language_english_btn = lv.btn(language_screen)
+language_english_btn.set_size(240,50)
+language_english_btn.set_pos(0, 60)
+language_english_btn.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.PRESSED)
+language_english_btn.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+language_english_btn_label = lv.label(language_english_btn)
+language_english_btn_label.set_text("English")
+language_english_btn_label.align(lv.ALIGN.LEFT_MID, 10, 0)
+language_english_btn_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+language_chinese_btn = lv.btn(language_screen)
+language_chinese_btn.set_size(240,50)
+language_chinese_btn.set_pos(0, 120)
+language_chinese_btn.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.PRESSED)
+language_chinese_btn.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+language_chinese_btn_label = lv.label(language_chinese_btn)
+language_chinese_btn_label.set_text("简体中文")
+language_chinese_btn_label.align(lv.ALIGN.LEFT_MID, 10, 0)
+language_chinese_btn_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+# -------------------------------------------dialswitch screen----------------------------------------------------------
+dialswitch_screen = lv.obj()
+dialswitch_screen.set_pos(0,0)
+dialswitch_screen.set_size(240,320)
+print("dialswitch_screen")
+dialswitch_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+dialswitch_title = lv.label(dialswitch_screen)
+dialswitch_title.set_pos(0, 10)
+dialswitch_title.set_size(240, 40)
+dialswitch_title.set_text("表盘切换")
+dialswitch_title.set_long_mode(lv.label.LONG.WRAP)
+dialswitch_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+dialswitch_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+dialswitch_img1 = lv.img(dialswitch_screen)#表盘预览图
+dialswitch_img1.set_pos(50, 60)
+dialswitch_img1.set_size(140, 172)
+dialswitch_img1.set_src("U:/static/DIAL_PREV01.png")
+dialswitch_img1.add_flag(lv.obj.FLAG.CLICKABLE)
+dialswitch_img1.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+
+dialswitch_btn1_label = lv.label(dialswitch_screen)#显示表盘1 表盘2
+dialswitch_btn1_label.set_text(" ")
+dialswitch_btn1_label.align(lv.ALIGN.TOP_MID, 0, 260)
+dialswitch_btn1_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+dialswitch_butoom_crcile1 = lv.img(dialswitch_screen)#底部显示圆点
+dialswitch_butoom_crcile1.set_pos(95, 300)
+dialswitch_butoom_crcile1.set_size(10, 10)
+dialswitch_butoom_crcile1.set_src("E:/static/point_white.png")
+dialswitch_butoom_crcile1.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+dialswitch_butoom_crcile2 = lv.img(dialswitch_screen)#底部显示圆点
+dialswitch_butoom_crcile2.set_pos(140, 300)
+dialswitch_butoom_crcile2.set_size(10, 10)
+dialswitch_butoom_crcile2.set_src("E:/static/point_black.png")
+dialswitch_butoom_crcile2.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+# dialswitch_btn2 = lv.btn(dialswitch_screen)
+# dialswitch_btn2.set_size(240,54)
+# dialswitch_btn2.set_pos(0, 104)
+# dialswitch_btn2.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.PRESSED)
+# dialswitch_btn2.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+# dialswitch_btn2_label = lv.label(dialswitch_btn2)
+# dialswitch_btn2_label.set_text("表盘2")
+# dialswitch_btn2_label.align(lv.ALIGN.LEFT_MID, 10, 0)
+# dialswitch_btn2_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+# btn1_switch = lv.switch(dialswitch_btn1)
+# btn1_switch.set_pos(185, 3)
+# btn1_switch.set_size(10, 10)
+# btn1_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.MAIN | lv.PART.INDICATOR)
+# btn1_switch.set_style_bg_color(lv.color_make(0xff, 0x00, 0x00),lv.PART.KNOB | lv.STATE.CHECKED)
+# btn1_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.KNOB)
+
+# btn2_switch = lv.switch(dialswitch_btn2)
+# btn2_switch.set_pos(185, 3)
+# btn2_switch.set_size(10, 10)
+# btn2_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.MAIN | lv.PART.INDICATOR)
+# btn2_switch.set_style_bg_color(lv.color_make(0xff, 0x00, 0x00),lv.PART.KNOB | lv.STATE.CHECKED)
+# btn2_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.KNOB)
+
+# -------------------------------------------menustyle screen----------------------------------------------------------
+menustyle_screen = lv.obj()
+print("menustyle_screen")
+menustyle_screen.center()
+menustyle_screen.set_size(240, 320)
+menustyle_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+menustyle_title = lv.label(menustyle_screen)
+menustyle_title.set_pos(0, 10)
+menustyle_title.set_size(240, 40)
+menustyle_title.set_text("主菜单风格")
+menustyle_title.set_long_mode(lv.label.LONG.WRAP)
+menustyle_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+menustyle_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+menustyle_btn1 = lv.btn(menustyle_screen)
+menustyle_btn1.set_size(240,54)
+menustyle_btn1.set_pos(0, 50)
+menustyle_btn1.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.PRESSED)
+menustyle_btn1.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+menustyle_btn1_label = lv.label(menustyle_btn1)
+menustyle_btn1_label.set_text("四宫格")
+menustyle_btn1_label.align(lv.ALIGN.LEFT_MID, 10, 0)
+menustyle_btn1_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+menu_btn1_switch = lv.switch(menustyle_btn1)
+menu_btn1_switch.set_pos(185, 3)
+menu_btn1_switch.set_size(10, 10)
+menu_btn1_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.MAIN | lv.PART.INDICATOR)
+menu_btn1_switch.set_style_bg_color(lv.color_make(0xff, 0x00, 0x00),lv.PART.KNOB | lv.STATE.CHECKED)
+menu_btn1_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.KNOB)
+
+menustyle_btn2 = lv.btn(menustyle_screen)
+menustyle_btn2.set_size(240,54)
+menustyle_btn2.set_pos(0, 104)
+menustyle_btn2.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.PRESSED)
+menustyle_btn2.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+menustyle_btn2_label = lv.label(menustyle_btn2)
+menustyle_btn2_label.set_text("单页")
+menustyle_btn2_label.align(lv.ALIGN.LEFT_MID, 10, 0)
+menustyle_btn2_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+menu_btn2_switch = lv.switch(menustyle_btn2)
+menu_btn2_switch.set_pos(185, 3)
+menu_btn2_switch.set_size(10, 10)
+menu_btn2_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.MAIN | lv.PART.INDICATOR)
+menu_btn2_switch.set_style_bg_color(lv.color_make(0xff, 0x00, 0x00),lv.PART.KNOB | lv.STATE.CHECKED)
+menu_btn2_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.KNOB)
+
+
+
+
+
+# -------------------------------------------app screen----------------------------------------------------------
+#app_screen = lv.obj()
+app_screen = lv.obj()
+print("app_screen")
+app_screen.center()
+app_screen.set_size(240, 320)
+app_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+app_img = lv.img(app_screen)
+app_img.set_pos(int(20),int(40))
+app_img.set_size(200,200)
+app_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+app_img.add_flag(lv.obj.FLAG.CLICKABLE)
+app_img.set_src("E:/static/IMAGE_APP_QR_CODE.png")
+app_img.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT)
+# app_qr = lv.qrcode(imei, 150, fg_color, bg_color)
+# app_qr.center()
+# Add a border with bg_color
+# app_qr.set_style_border_color(bg_color, 0)
+# app_qr.set_style_border_width(5, 0)
+# app_qr_data = str("https://fangzoudiu.xcloudtech.com/xiao_jian")
+# app_qr.update(app_qr_data,len(app_qr_data))
+
+app_label = lv.label(app_screen)
+app_label.set_pos(0, 280)
+app_label.set_size(240, 20)
+app_label.set_text(" ")
+app_label.set_long_mode(lv.label.LONG.WRAP)
+app_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+app_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+# -------------------------------------------restore screen----------------------------------------------------------
+restore_screen = lv.obj()
+print("restore_screen")
+restore_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+restore_label = lv.label(restore_screen)
+restore_label.set_pos(0, 90)
+restore_label.set_size(240, 70)
+restore_label.set_text("设备所有的数据将被清除,确定继续?")
+restore_label.set_long_mode(lv.label.LONG.WRAP)
+restore_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+restore_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+restore_confirm_label = lv.label(restore_screen)
+restore_confirm_label.set_text("确认")
+restore_confirm_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+restore_confirm_label.set_size(120, 60)
+restore_confirm_label.set_pos(0,180)
+restore_confirm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+restore_confirm = lv.label(restore_screen)
+restore_confirm.set_text(" ")
+restore_confirm.set_size(120, 80)
+restore_confirm.set_pos(0,160)
+restore_confirm.add_flag(lv.obj.FLAG.CLICKABLE)
+
+restore_cancel_label = lv.label(restore_screen)
+restore_cancel_label.set_text("返回")
+restore_cancel_label.set_size(120, 60)
+restore_cancel_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+restore_cancel_label.set_pos(120,180)
+restore_cancel_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+restore_cancel = lv.label(restore_screen)
+restore_cancel.set_text(" ")
+restore_cancel.set_size(120, 80)
+restore_cancel.set_pos(120,160)
+restore_cancel.add_flag(lv.obj.FLAG.CLICKABLE)
+
+
+
+
+
+# -------------------------------------------version screen----------------------------------------------------------
+version_screen = lv.obj()
+print("version_screen")
+version_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+version_msg = "Software Version:\n\
+MMI\n\
+Version:UIX8910_C55_V\n\
+1.0_Release\n\
+Build Time:\n\
+2-17-2023\n\
+9:32:5\n\
+IMEI:\n\
+"
+import versions
+
+version_label1 = lv.label(version_screen)
+version_label1.set_pos(10, 30)
+version_label1.set_size(230, 30)
+version_label1.set_long_mode(lv.label.LONG.WRAP)
+version_label1.set_text("产品名称:")
+version_label1.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+version_label1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+# version_label2 = lv.label(version_screen)
+# version_label2.set_pos(0, 60)
+# version_label2.set_size(240, 30)
+# version_label2.set_long_mode(lv.label.LONG.WRAP)
+# version_label2.set_text("Python Lvgl")
+# version_label2.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+# version_label2.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+# version_label3 = lv.label(version_screen)
+# version_label3.set_pos(0, 90)
+# version_label3.set_size(240, 30)
+# version_label3.set_long_mode(lv.label.LONG.WRAP)
+# version_label3.set_text("Version:")
+# version_label3.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+# version_label3.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+version_label3 = lv.label(version_screen)
+version_label3.set_pos(10, 70)
+version_label3.set_size(230, 30)
+version_label3.set_long_mode(lv.label.LONG.WRAP)
+version_label3.set_text(EventMesh.version)
+version_label3.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+version_label3.add_style(style_font_youyuan_20_gray, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+# version_label4 = lv.label(version_screen)
+# version_label4.set_pos(0, version_label_y)
+# version_label4.set_size(240, 30)
+# version_label4.set_long_mode(lv.label.LONG.WRAP)
+# version_label4.set_text("")
+# version_label4.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+# version_label4.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+version_label5 = lv.label(version_screen)
+version_label5.set_pos(10, 120)
+version_label5.set_size(230, 30)
+version_label5.set_long_mode(lv.label.LONG.WRAP)
+version_label5.set_text("软件版本:")
+version_label5.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+version_label5.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+version_label6 = lv.label(version_screen)
+version_label6.set_pos(10, 160)
+version_label6.set_size(230, 60)
+version_label6.set_long_mode(lv.label.LONG.WRAP)
+version_label6.set_text(EventMesh.builTime)
+version_label6.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+version_label6.add_style(style_font_youyuan_20_gray, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+# version_label7 = lv.label(version_screen)
+# version_label7.set_pos(0, 210)
+# version_label7.set_size(240, 30)
+# version_label7.set_long_mode(lv.label.LONG.WRAP)
+# version_label7.set_text(versions.Build_Time.split(" ")[1])
+# version_label7.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+# version_label7.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+# version_label8 = lv.label(version_screen)
+# version_label8.set_pos(0, 210)
+# version_label8.set_size(240, 30)
+# version_label8.set_long_mode(lv.label.LONG.WRAP)
+# version_label8.set_text("IMEI:")
+# version_label8.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+# version_label8.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+# version_label9 = lv.label(version_screen)
+# version_label9.set_pos(0, 240)
+# version_label9.set_size(240, 30)
+# version_label9.set_long_mode(lv.label.LONG.WRAP)
+# version_label9.set_text(" ")
+# version_label9.set_style_text_align(lv.TEXT_ALIGN.LEF, 0)
+# version_label9.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+
+# -------------------------------------------update screen----------------------------------------------------------
+update_screen = lv.obj()
+print("update_screen")
+update_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+update_title = lv.label(update_screen)
+update_title.set_pos(0, 10)
+update_title.set_size(240, 40)
+update_title.set_text("系统更新")
+update_title.set_long_mode(lv.label.LONG.WRAP)
+update_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+update_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+update_label = lv.label(update_screen)
+update_label.set_text(" 已经是最新版本")
+update_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+update_label.set_size(240, 50)
+update_label.set_pos(0,50)
+update_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+update_return = lv.label(update_screen)
+update_return.set_text("返回")
+update_return.set_size(240, 40)
+update_return.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+update_return.set_pos(0,240)
+update_return.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+update_return.add_flag(lv.obj.FLAG.CLICKABLE)
+
+class RestoreScreen(Screen):
+ NAME = "restore"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = restore_screen
+ restore_confirm.add_event_cb(lambda e: EventMesh.callback_wrapper(self.confirm(e)),lv.EVENT.CLICKED, None)
+ restore_cancel.add_event_cb(lambda e: EventMesh.callback_wrapper(self.concel(e)),lv.EVENT.CLICKED, None)
+
+
+ def confirm(self, e):
+ EventMesh.publish("load_screen", {"screen": "restore_confirm"})
+
+
+ def concel(self, e):
+ EventMesh.publish("return_prev_screen")
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
+class UpdateScreen(Screen):
+ NAME = "update"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = update_screen
+ update_return.add_event_cb(lambda e: EventMesh.callback_wrapper(self.back(e)),lv.EVENT.CLICKED, None)
+
+ def back(self,e):
+ EventMesh.publish("return_prev_screen")
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
+class VersionScreen(Screen):
+ NAME = "version"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = version_screen
+ self.btn_count = 0
+ def initialization(self):
+ imei = EventMesh.publish(constants.EVENT.GET_IMEI)
+ # version_label9.set_text(imei)
+
+ def Close(self):
+ self.btn_count = 0
+
+ def done_click(self):
+ self.btn_count += 1
+ if self.btn_count >= 5 :
+ EventMesh.publish("load_screen", {"screen": "factorymode"})
+
+ def done_bottom_to_top(self):
+ self.btn_count += 1
+ if self.btn_count >= 5 :
+ EventMesh.publish("load_screen", {"screen": "factorymode"})
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+# -------------------------------------------poweroff screen----------------------------------------------------------
+poweroff_screen = lv.obj()
+print("poweroff_screen")
+poweroff_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+poweroff_img = lv.img(poweroff_screen)
+poweroff_img.set_pos(100, 30)
+poweroff_img.set_size(61, 61)
+poweroff_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+poweroff_img.set_src("E:/static/poweroff_icon.png")
+
+poweroff_label = lv.label(poweroff_screen)
+poweroff_label.set_text("是否关机?")
+poweroff_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+poweroff_label.set_size(240, 20)
+poweroff_label.set_pos(0,120)
+poweroff_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+poweroff_confirm_img = lv.img(poweroff_screen)
+poweroff_confirm_img.set_size(176, 46)
+poweroff_confirm_img.set_pos(32, 160)
+poweroff_confirm_img.set_src("E:/static/off_icon.png")
+poweroff_confirm_img.add_flag(lv.obj.FLAG.CLICKABLE)
+poweroff_confirm_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+poweroff_confirm_label = lv.label(poweroff_confirm_img)
+poweroff_confirm_label.set_text("关机")
+poweroff_confirm_label.align(lv.ALIGN.CENTER, 0, 5)
+poweroff_confirm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+poweroff_return = lv.img(poweroff_screen)
+poweroff_return.set_size(176, 46)
+poweroff_return.set_pos(32, 240)
+poweroff_return.set_src("E:/static/cancel_icon.png")
+
+poweroff_return.add_flag(lv.obj.FLAG.CLICKABLE)
+poweroff_return.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+poweroff_return_label = lv.label(poweroff_return)
+poweroff_return_label.set_text("返回")
+poweroff_return_label.align(lv.ALIGN.CENTER, 0, 5)
+poweroff_return_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+poweroff_return.set_ext_click_area(20)
+
+
+
+
+
+
+class PoweroffScreen(Screen):
+ NAME = "poweroff"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = poweroff_screen
+ poweroff_confirm_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.confirm(e)),lv.EVENT.CLICKED, None)
+ poweroff_return.add_event_cb(lambda e: EventMesh.callback_wrapper(self.concel(e)),lv.EVENT.CLICKED, None)
+
+ def initialization(self):
+ pass
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def confirm(self, e):
+ EventMesh.publish("load_screen", {"screen": "poweroff_comfirm"})
+ #EventMesh.publish("load_screen", {"screen": "no_sim_power_screen"})
+
+
+ def concel(self, e):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+poweron_screen = lv.obj()
+print("poweron_screen")
+poweron_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+poweron_label = lv.label(poweron_screen)
+poweron_label.set_text("WELCOME")
+poweron_label.align(lv.ALIGN.CENTER, 0, 0)
+poweron_label.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
+class PowerOnScreen(Screen):
+ NAME = "poweron"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = poweron_screen
+ self.timer = osTimer()
+ self.aud = audio.Audio(0)
+ self.aud.set_pa(Pin.GPIO29)
+ self.meta_type = "popup"
+ self.volum_size = 8
+ check_volum = EventMesh.publish("get_storage_config","volum")
+ if check_volum != None:
+ self.volum_size = check_volum
+
+
+ self.aud.setVolume(self.volum_size)
+ self.count = 0
+
+ def initialization(self):
+ EventMesh.publish("set_UI_high_priority",1)
+ self.count = 0
+ self.aud.setVolume(11)
+ self.timer.start(1000,1,self.fun)
+ pass
+
+ def fun(self,*argc):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ if self.count == 0:
+ self.aud.play(1, 1, 'E:/static/R_POWER_1.mp3') #播放来电铃声
+ else:
+ play_state = EventMesh.publish("get_audio_state")#音频播放状态
+ if play_state != None:
+ if self.count >= 9:#在上一个界面在播放音频时切换界面则关闭 以免一直播放
+ self.count = 0
+ self.timer.stop()
+ EventMesh.publish("set_UI_high_priority",0)
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+ return
+ self.count+=1
+
+ def Close(self):
+ EventMesh.publish("set_UI_high_priority",0)
+ self.timer.stop()
+ self.aud.setVolume(self.volum_size)
+ pass
+ def done_return(self):
+ pass
+
+ def btn1_release(self):
+ pass
+
+ def btn8_press(self):
+ pass
+
+poweroff_confirm_screen = lv.obj()
+print("poweroff_confirm_screen")
+poweroff_confirm_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+poweroff_confirm_label = lv.label(poweroff_confirm_screen)
+poweroff_confirm_label.set_text("Goodbye")
+poweroff_confirm_label.align(lv.ALIGN.CENTER, 0, 0)
+poweroff_confirm_label.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+import utime
+class PoweroffConfirmScreen(Screen):
+ NAME = "poweroff_comfirm"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = poweroff_confirm_screen
+ self.timer = osTimer()
+ self.count = 0
+ self.meta_type = "popup"
+
+ def initialization(self):
+ step = EventMesh.publish("get_old_step_value")
+ if step != 0:
+ EventMesh.publish("set_storage_config",["old_step",step])
+
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ EventMesh.publish("set_storage_config",["old_time",time_tmp])#关机保存一个是时间
+
+ #print("self.read_data:{}".format(self.read_data))
+ EventMesh.publish("play_poewr_off_event")#
+ self.count = 0
+ self.timer.start(1*1000,1,self.power_off)
+
+ def power_off(self,*args):
+ self.count+=1
+ EventMesh.publish("system_sleep_rest")#防止黑屏
+ play_state = EventMesh.publish("get_audio_state")#音频播放状态
+ if play_state != None:
+ # print("power off!!!!!!!",self.count)
+ if self.count > 5:#在上一个界面在播放音频时切换界面则关闭 以免一直播放
+ self.count = 0
+ self.timer.stop()
+ Power.powerDown()
+
+ def done_return(self):
+ pass
+
+ def btn1_release(self):
+ pass
+
+ def btn8_press(self):
+ pass
+from common import Abstract
+class TimePoweroffScreen(Abstract):
+
+
+ def __init__(self):
+ super().__init__()
+ self.power_off_flag = 0
+
+ EventMesh.subscribe("get_time_power_off", self.get_time_power_off)
+ EventMesh.subscribe("power_off_callback", self.power_off_callback)
+ EventMesh.subscribe("set_time_power_off", self.set_time_power_off)
+
+
+ def power_off_callback(self,event,msg):
+ if self.power_off_flag == 0:
+ self.power_off_flag = 1
+ EventMesh.publish("set_time_power_off")
+ Power.powerDown()
+
+ elif self.power_off_flag == 1:
+ self.power_off_flag = 0
+ EventMesh.publish("set_time_power_off")
+ Power.powerRestart()
+
+
+ def get_time_power_off(self,event,msg):
+ if self.power_off_flag == 0:
+ self.power_off_flag = 1
+ elif self.power_off_flag == 1:
+ self.power_off_flag = 0
+
+ def set_time_power_off(self,event,msg):
+
+ pass
+
+
+
+
+ def done_return(self):
+ pass
+
+ def btn1_release(self):
+ pass
+
+ def btn8_press(self):
+ pass
+
+class LanguageScreen(Screen):
+ NAME = "language"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = language_screen
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
+class DialswitchScreen(Screen):
+ NAME = "dialswitch"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = dialswitch_screen
+ self.watchface_style_num = "Watchface1"
+ dialswitch_img1.add_event_cb(lambda e: EventMesh.callback_wrapper(self.watchface01(e)),
+ lv.EVENT.CLICKED, None)
+ self.dial_num = 1
+ self.move = 0
+ self.timer= osTimer()
+
+ def initialization(self):
+ self.dial_num = 1
+ self.move = 0
+ read_data = EventMesh.publish("get_storage_config","watchface")
+
+ if read_data != None:
+ self.watchface_style_num = read_data
+ if self.watchface_style_num == "Watchface1":
+ self.dial_num = 1
+ else:
+ self.dial_num = 2
+ self.show_info()
+
+
+
+ def watchface01(self,e):
+ code = e.get_code()
+ if code == lv.EVENT.CLICKED:
+ self.timer.start(50,0,self.enter_main_show)
+
+ def enter_main_show(self,e):
+ EventMesh.publish("set_storage_config",["watchface","Watchface{}".format(self.dial_num)])
+ EventMesh.publish("set_change_face", "Watchface{}".format(self.dial_num))
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def done_left_to_right(self):#右滑
+ #print("done_left_to_right!!!!!!!!!")
+ self.move = 1
+ if self.dial_num > 1:
+ self.dial_num-=1
+ else:
+ self.dial_num = 2
+ self.timer.stop()
+ self.show_info()
+
+ def done_right_to_left(self):#左滑
+ #print("done_right_to_left!!!!!!!!!")
+ self.move = 2
+ self.dial_num+=1
+ if self.dial_num > 2:
+ self.dial_num = 1
+ self.show_info()
+ self.timer.stop()
+
+ def done_bottom_to_top(self):
+ self.move = 3
+ self.timer.stop()
+
+ def done_top_to_bottom(self):
+ self.move = 4
+ self.timer.stop()
+
+ def show_info(self):
+ dialswitch_img1.set_src("U:/static/DIAL_PREV0{}.png".format(self.dial_num))
+ dialswitch_btn1_label.set_text("表盘{}".format(self.dial_num))
+ if(self.dial_num == 1):
+ dialswitch_butoom_crcile1.set_src("E:/static/point_white.png")
+ dialswitch_butoom_crcile2.set_src("E:/static/point_black.png")
+ else:
+ dialswitch_butoom_crcile1.set_src("E:/static/point_black.png")
+ dialswitch_butoom_crcile2.set_src("E:/static/point_white.png")
+ def Close(self):
+ self.timer.stop()
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
+class ThemeswitchScreen(Screen):
+ NAME = "themeswitch"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = menustyle_screen
+ menustyle_btn1.add_event_cb(lambda e: EventMesh.callback_wrapper(self.fun1(e)),
+ lv.EVENT.PRESSED, None)
+
+ menustyle_btn2.add_event_cb(lambda e: EventMesh.callback_wrapper(self.fun2(e)),
+ lv.EVENT.PRESSED, None)
+
+ def fun1(self,e):
+ menu_btn1_switch.add_state(lv.STATE.CHECKED)
+ menu_btn2_switch.clear_state(lv.STATE.CHECKED)
+ EventMesh.publish("change_style", "MainMenu1")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def fun2(self,e):
+ menu_btn1_switch.clear_state(lv.STATE.CHECKED)
+ menu_btn2_switch.add_state(lv.STATE.CHECKED)
+ EventMesh.publish("change_style", "MainMenu2")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def done_return(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn1_release(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+ def btn8_press(self):
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+# -------------------------------------------imei screen----------------------------------------------------------
+imei_screen = lv.obj()
+print("imei_screen")
+imei_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+bg_color = lv.palette_lighten(lv.PALETTE.LIGHT_BLUE, 5)
+fg_color = lv.palette_darken(lv.PALETTE.BLUE, 4)
+
+imei_qr = lv.qrcode(imei_screen, 150, fg_color, bg_color)
+imei_qr.center()
+# Add a border with bg_color
+imei_qr.set_style_border_color(bg_color, 0)
+imei_qr.set_style_border_width(5, 0)
+
+
+imei_label = lv.label(imei_screen)
+imei_label.set_pos(0, 280)
+imei_label.set_size(240, 20)
+imei_label.set_text(" ")
+imei_label.set_long_mode(lv.label.LONG.WRAP)
+imei_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+imei_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+class ImeiScreen(Screen):
+ NAME = "imei"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = imei_screen
+
+ def initialization(self):
+
+ imei = EventMesh.publish(constants.EVENT.GET_IMEI)
+ imei_qr_data = str(imei)
+ imei_qr.update(imei_qr_data,len(imei_qr_data))
+ imei_label.set_text(imei)
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
+class AppScreen(Screen):
+ NAME = "app"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = app_screen
+ def initialization(self):
+ imei = EventMesh.publish(constants.EVENT.GET_IMEI)
+ app_label.set_text(imei)
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+# -------------------------------------------brightness screen----------------------------------------------------------
+brightness_screen = lv.obj()
+print("brightness_screen")
+brightness_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+brightness_title = lv.label(brightness_screen)
+brightness_title.set_pos(0, 10)
+brightness_title.set_size(240, 40)
+brightness_title.set_text("屏幕调节")
+brightness_title.set_long_mode(lv.label.LONG.WRAP)
+brightness_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+brightness_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+brightness_label1 = lv.label(brightness_screen)
+brightness_label1.set_pos(10, 70)
+brightness_label1.set_size(230, 40)
+brightness_label1.set_text("亮度:")
+brightness_label1.set_long_mode(lv.label.LONG.WRAP)
+brightness_label1.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+brightness_label1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+brightness_bar = lv.bar(brightness_screen)
+brightness_bar.set_pos(20, 100)
+brightness_bar.set_size(200, 25)
+brightness_bar.set_style_anim_time(1000, lv.PART.INDICATOR | lv.STATE.DEFAULT)
+brightness_bar.set_mode(lv.bar.MODE.NORMAL)
+brightness_bar.set_value(50, lv.ANIM.OFF)
+brightness_bar.add_style(style_bar, lv.PART.MAIN | lv.STATE.DEFAULT)
+brightness_bar.add_style(style_bar_indic, lv.PART.INDICATOR | lv.STATE.DEFAULT)
+
+brightness_reduce_imgbtn = lv.img(brightness_screen)
+brightness_reduce_imgbtn.set_pos(5, 195)
+brightness_reduce_imgbtn.set_size(110, 46)
+brightness_reduce_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
+brightness_reduce_imgbtn.set_src("E:/static/reduce_btn.png")
+brightness_reduce_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+brightness_add_imgbtn = lv.img(brightness_screen)
+brightness_add_imgbtn.set_pos(125, 195)
+brightness_add_imgbtn.set_size(110, 46)
+brightness_add_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
+brightness_add_imgbtn.set_src("E:/static/add_btn.png")
+brightness_add_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+brightness_label_time = lv.label(brightness_screen)
+brightness_label_time.set_pos(10, 150)
+brightness_label_time.set_size(80, 30)
+brightness_label_time.set_text("时间:")
+brightness_label_time.set_long_mode(lv.label.LONG.WRAP)
+brightness_label_time.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+brightness_label_time.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+brightness_time_reduce_img = lv.img(brightness_screen)
+brightness_time_reduce_img.set_pos(90, 145)
+brightness_time_reduce_img.set_size(30, 34)
+brightness_time_reduce_img.set_src("E:/static/time_up2.png")
+brightness_time_reduce_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+brightness_time_reduce_imgbtn= lv.img(brightness_screen)
+brightness_time_reduce_imgbtn.set_size(80, 45)
+brightness_time_reduce_imgbtn.set_pos(90, 140)
+brightness_time_reduce_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
+
+
+brightness_label_time_text = lv.label(brightness_screen)
+brightness_label_time_text.set_pos(130, 152)
+brightness_label_time_text.set_size(60, 30)
+brightness_label_time_text.set_text("5秒")
+brightness_label_time_text.set_long_mode(lv.label.LONG.WRAP)
+brightness_label_time_text.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+brightness_label_time_text.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+brightness_time_add_img = lv.img(brightness_screen)
+brightness_time_add_img.set_pos(190, 145)
+brightness_time_add_img.set_size(30, 34)
+brightness_time_add_img.set_src("E:/static/time_up1.png")
+brightness_time_add_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+brightness_time_add_imgbtn= lv.img(brightness_screen)
+brightness_time_add_imgbtn.set_size(70, 45)
+brightness_time_add_imgbtn.set_pos(170, 140)
+brightness_time_add_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
+
+brightness_flip_label = lv.label(brightness_screen)
+brightness_flip_label.set_pos(0, 270)
+brightness_flip_label.set_size(140, 40)
+brightness_flip_label.set_text("翻腕亮屏")
+#brightness_flip_label.set_long_mode(lv.label.LONG.WRAP)
+brightness_flip_label.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+brightness_flip_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+brightness_flip_sw = lv.switch(brightness_screen)
+brightness_flip_sw.set_pos(140, 260)
+brightness_flip_sw.set_size(80, 40)
+
+brightness_flip_label_btn = lv.label(brightness_screen)
+brightness_flip_label_btn.set_pos(135, 255)
+brightness_flip_label_btn.set_size(105, 65)
+brightness_flip_label_btn.set_text(" ")
+brightness_flip_label_btn.add_flag(lv.obj.FLAG.CLICKABLE)
+
+
+
+class BrightnessScreen(Screen):
+ NAME = "brightness"
+
+ def __init__(self):
+ super().__init__()
+ self.level = 6
+ self.time = 10
+ self.flip_sw =0
+ self.meta = brightness_screen
+ brightness_add_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.add_level(e)),
+ lv.EVENT.CLICKED, None)
+ brightness_reduce_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.reduce_level(e)),
+ lv.EVENT.CLICKED, None)
+
+ brightness_time_reduce_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.reduce_time_level(e)),
+ lv.EVENT.CLICKED, None)
+
+ brightness_time_add_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.add_time_level(e)),
+ lv.EVENT.CLICKED, None)
+ brightness_flip_label_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.flip_sw_cb(e)),lv.EVENT.CLICKED, None)
+ def initialization(self):
+ self.level = EventMesh.publish("get_brightness_level")
+ self.time = EventMesh.publish("get_brightness_time")
+ print("self.time:{}".format(self.time))
+ if self.time == None:
+ self.time = 5
+ brightness_label_time_text.set_text("{}秒".format(self.time))
+ EventMesh.publish("get_storage_config","flip_sw")
+ if self.flip_sw == None:
+ self.flip_sw = 0
+ if self.flip_sw == 0:
+ brightness_flip_sw.clear_state(lv.STATE.CHECKED)
+ else:
+ brightness_flip_sw.add_state(lv.STATE.CHECKED)
+ self.show_bar()
+ def add_level(self, e):
+ EventMesh.publish("push_add_brightness_level")
+ self.level = EventMesh.publish("get_brightness_level")
+ print("self.level:{}".format(self.level))
+ self.show_bar()
+
+ def reduce_level(self, e):
+ EventMesh.publish("push_reduce_brightness_level")
+ self.level = EventMesh.publish("get_brightness_level")
+ self.show_bar()
+
+ def flip_sw_cb(self,e):
+ code = e.get_code()
+ obj = e.get_target()
+ if code == lv.EVENT.CLICKED:
+ if self.flip_sw == 0:
+ self.flip_sw = 1
+ brightness_flip_sw.add_state(lv.STATE.CHECKED)
+ else:
+ self.flip_sw = 0
+ brightness_flip_sw.clear_state(lv.STATE.CHECKED)
+ # print("self.flip_sw:",self.flip_sw)
+ EventMesh.publish("set_storage_config",["flip_sw",self.flip_sw])
+
+ def reduce_time_level(self, e):
+ if self.time > 5:
+ self.time-=5
+ EventMesh.publish("set_brightness_time",self.time)
+ brightness_label_time_text.set_text("{}秒".format(self.time))
+
+
+
+ def add_time_level(self, e):
+ self.time+=5
+ if self.time >= 30:
+ self.time = 30
+ EventMesh.publish("set_brightness_time",self.time)
+ brightness_label_time_text.set_text("{}秒".format(self.time))
+
+
+
+
+ def show_bar(self):
+ if self.level == None:
+ self.level = 6
+ brightness_bar.set_value((100 // 10) * self.level, lv.ANIM.OFF)
+
+
+
+ def done_return(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+
+#-----------------------------------------Total--volum-------------------------------
+
+volume_adjust_screen = lv.obj()
+print("volume_adjust_screen")
+volume_adjust_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+totalvolume_title = lv.label(volume_adjust_screen)
+totalvolume_title.set_pos(0, 10)
+totalvolume_title.set_size(240, 40)
+totalvolume_title.set_text("铃声调节")
+totalvolume_title.set_long_mode(lv.label.LONG.WRAP)
+totalvolume_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+totalvolume_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+totalvolume_label1 = lv.label(volume_adjust_screen)
+totalvolume_label1.set_pos(10, 70)
+totalvolume_label1.set_size(230, 40)
+totalvolume_label1.set_text("铃声:")
+totalvolume_label1.set_long_mode(lv.label.LONG.WRAP)
+totalvolume_label1.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+totalvolume_label1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+totalvolume_bar = lv.bar(volume_adjust_screen)
+totalvolume_bar.set_pos(20, 100)
+totalvolume_bar.set_size(200, 25)
+totalvolume_bar.set_style_anim_time(1000, lv.PART.INDICATOR | lv.STATE.DEFAULT)
+totalvolume_bar.set_mode(lv.bar.MODE.NORMAL)
+totalvolume_bar.set_value(50, lv.ANIM.OFF)
+totalvolume_bar.add_style(style_bar, lv.PART.MAIN | lv.STATE.DEFAULT)
+totalvolume_bar.add_style(style_bar_indic, lv.PART.INDICATOR | lv.STATE.DEFAULT)
+
+totalvolume_reduce_imgbtn = lv.img(volume_adjust_screen)
+totalvolume_reduce_imgbtn.set_pos(5, 145)
+totalvolume_reduce_imgbtn.set_size(110, 46)
+totalvolume_reduce_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
+totalvolume_reduce_imgbtn.set_src("E:/static/reduce_btn.png")
+totalvolume_reduce_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+totalvolume_add_imgbtn = lv.img(volume_adjust_screen)
+totalvolume_add_imgbtn.set_pos(125, 145)
+totalvolume_add_imgbtn.set_size(110, 46)
+totalvolume_add_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
+totalvolume_add_imgbtn.set_src("E:/static/add_btn.png")
+totalvolume_add_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+class totalvolumeScreen(Screen):
+ NAME = "totalvolume"
+
+ def __init__(self):
+ super().__init__()
+ self.meta = volume_adjust_screen
+ totalvolume_add_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.add_volum_size(e)),
+ lv.EVENT.CLICKED, None)
+ totalvolume_reduce_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.reduce_volum_size(e)),
+ lv.EVENT.CLICKED, None)
+ self.volum_size = 8
+ self.aud = audio.Audio(0)
+
+ def initialization(self):
+ num = EventMesh.publish("get_volum_size")
+ if num == None:
+ self.volum_size = 8
+ else:
+ self.volum_size = num
+ self.aud.setVolume(self.volum_size)
+ self.show_bar(0)
+
+ def add_volum_size(self, e):
+ self.volum_size+=2
+ if self.volum_size >= 11:
+ self.volum_size = 11
+ self.show_bar(1)
+
+ def reduce_volum_size(self, e):
+
+ self.volum_size -= 2
+ if self.volum_size < 0:
+ self.volum_size = 0
+ self.show_bar(1)
+
+ def show_bar(self,msg):
+ totalvolume_bar.set_value((100 // 11) * self.volum_size, lv.ANIM.OFF)
+ if msg == 1:
+ self.aud.setVolume(self.volum_size)
+ EventMesh.publish("set_volum_size",self.volum_size)
+ # print("self.read_data:size :{}".format(self.read_data))
+ self.aud.stop()
+ self.aud.play(1, 1, 'E:/static/audio_audio_haixiu.mp3') #播放声音
+
+ def Close(self):
+ self.aud.stop()
+
+ def done_return(self):
+ self.aud.stop()
+ EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+
+ def btn8_press(self):
+ EventMesh.publish("watch_top_show")
+ EventMesh.publish("load_screen", {"screen": "main_menu"})
--- /dev/null
+import log
+import usocket as socket
+import ubinascii as binascii
+import urandom as random
+import log
+import ure as re
+import ustruct as struct
+import urandom as random
+import usocket as socket
+from ucollections import namedtuple
+import websocket_mask
+LOGGER = log.getLogger(__name__)
+
+# Opcodes
+OP_CONT = 0x0
+OP_TEXT = 0x1
+OP_BYTES = 0x2
+OP_CLOSE = 0x8
+OP_PING = 0x9
+OP_PONG = 0xa
+
+# Close codes
+CLOSE_OK = 1000
+CLOSE_GOING_AWAY = 1001
+CLOSE_PROTOCOL_ERROR = 1002
+CLOSE_DATA_NOT_SUPPORTED = 1003
+CLOSE_BAD_DATA = 1007
+CLOSE_POLICY_VIOLATION = 1008
+CLOSE_TOO_BIG = 1009
+CLOSE_MISSING_EXTN = 1010
+CLOSE_BAD_CONDITION = 1011
+
+URL_RE = re.compile(r'(wss|ws)://([A-Za-z0-9-\.]+)(?:\:([0-9]+))?(/.+)?')
+URI = namedtuple('URI', ('protocol', 'hostname', 'port', 'path'))
+
+
+def urlparse(uri):
+ """Parse ws:// URLs"""
+ match = URL_RE.match(uri)
+ if match:
+ protocol = match.group(1)
+ host = match.group(2)
+ port = match.group(3)
+ path = match.group(4)
+
+ if protocol == 'wss':
+ if port is None:
+ port = 443
+ elif protocol == 'ws':
+ if port is None:
+ port = 80
+ else:
+ raise ValueError('Scheme {} is invalid'.format(protocol))
+
+ return URI(protocol, host, int(port), path)
+
+
+class NoDataException(Exception):
+ pass
+
+
+class ConnectionClosed(Exception):
+ pass
+
+
+class Websocket(object):
+ """
+ Basis of the Websocket protocol.
+
+ This can probably be replaced with the C-based websocket module, but
+ this one currently supports more options.
+ """
+ is_client = False
+
+ def __init__(self, sock, debug=False):
+ self.sock = sock
+ self.open = True
+ self.debug = debug
+
+ def __enter__(self):
+ return self
+
+ def __exit__(self, exc_type, exc, tb):
+ self.close()
+
+ def settimeout(self, timeout):
+ self.sock.settimeout(timeout)
+
+ def read_frame(self, max_size=None):
+ """
+ Read a frame from the socket.
+ See https://tools.ietf.org/html/rfc6455#section-5.2 for the details.
+ """
+
+ # Frame header
+ two_bytes = self.sock.read(2)
+
+ if not two_bytes:
+ raise NoDataException
+
+ byte1, byte2 = struct.unpack('!BB', two_bytes)
+
+ # Byte 1: FIN(1) _(1) _(1) _(1) OPCODE(4)
+ fin = bool(byte1 & 0x80)
+ opcode = byte1 & 0x0f
+
+ # Byte 2: MASK(1) LENGTH(7)
+ mask = bool(byte2 & (1 << 7))
+ length = byte2 & 0x7f
+
+ if length == 126: # Magic number, length header is 2 bytes
+ length, = struct.unpack('!H', self.sock.read(2))
+ elif length == 127: # Magic number, length header is 8 bytes
+ length, = struct.unpack('!Q', self.sock.read(8))
+
+ if mask: # Mask is 4 bytes
+ mask_bits = self.sock.read(4)
+
+ try:
+ data = self.sock.read(length)
+ except MemoryError:
+ # We can't receive this many bytes, close the socket
+ if self.debug: LOGGER.info("Frame of length %s too big. Closing", length)
+ self.close(code=CLOSE_TOO_BIG)
+ return True, OP_CLOSE, None
+
+ if mask:
+ data = bytes(b ^ mask_bits[i % 4]
+ for i, b in enumerate(data))
+
+ return fin, opcode, data
+
+ def write_frame(self, opcode, data=b''):
+ """
+ Write a frame to the socket.
+ See https://tools.ietf.org/html/rfc6455#section-5.2 for the details.
+ """
+ fin = True
+ mask = self.is_client # messages sent by client are masked
+
+ length = len(data)
+
+ # Frame header
+ # Byte 1: FIN(1) _(1) _(1) _(1) OPCODE(4)
+ byte1 = 0x80 if fin else 0
+ byte1 |= opcode
+
+ # Byte 2: MASK(1) LENGTH(7)
+ byte2 = 0x80 if mask else 0
+
+ if length < 126: # 126 is magic value to use 2-byte length header
+ byte2 |= length
+ self.sock.write(struct.pack('!BB', byte1, byte2))
+
+ elif length < (1 << 16): # Length fits in 2-bytes
+ byte2 |= 126 # Magic code
+ self.sock.write(struct.pack('!BBH', byte1, byte2, length))
+
+ elif length < (1 << 64):
+ byte2 |= 127 # Magic code
+ self.sock.write(struct.pack('!BBQ', byte1, byte2, length))
+
+ else:
+ raise ValueError()
+ #print("mask start len:{}".format(length))
+ if mask: # Mask is 4 bytes
+ mask_bits = struct.pack('!I', random.getrandbits(32))
+ self.sock.write(mask_bits)
+ #tmp_data = data
+ # data = bytes(b ^ mask_bits[i % 4]
+ # for i, b in enumerate(data))
+ # print("old mask:{}".format(data))
+
+ data_array = bytearray(data)
+ mask_bits_array = bytearray(mask_bits)
+ websocket_mask.MASK(data_array,len(data_array),mask_bits_array)
+ #print("new mask:{}".format(data_array))
+ data=bytes(data_array)
+ #print("mask end")
+ self.sock.write(data)
+ #print("write end")
+
+ def recv(self):
+ """
+ Receive data from the websocket.
+
+ This is slightly different from 'websockets' in that it doesn't
+ fire off a routine to process frames and put the data in a queue.
+ If you don't call recv() sufficiently often you won't process control
+ frames.
+ """
+ assert self.open
+
+ while self.open:
+ try:
+ fin, opcode, data = self.read_frame()
+ except NoDataException:
+ return ''
+ except ValueError:
+ if self.debug: LOGGER.info("Failed to read frame. Socket dead.")
+ self._close()
+ raise ConnectionClosed()
+
+ if not fin:
+ raise NotImplementedError()
+
+ if opcode == OP_TEXT:
+ return data.decode('utf-8')
+ elif opcode == OP_BYTES:
+ return data
+ elif opcode == OP_CLOSE:
+ self._close()
+ return
+ elif opcode == OP_PONG:
+ # Ignore this frame, keep waiting for a data frame
+ continue
+ elif opcode == OP_PING:
+ # We need to send a pong frame
+ if self.debug: LOGGER.info("Sending PONG")
+ self.write_frame(OP_PONG, data)
+ # And then wait to receive
+ continue
+ elif opcode == OP_CONT:
+ # This is a continuation of a previous frame
+ raise NotImplementedError(opcode)
+ else:
+ raise ValueError(opcode)
+
+ def send(self, buf):
+ """Send data to the websocket."""
+
+ assert self.open
+
+ if isinstance(buf, str):
+ opcode = OP_TEXT
+ buf = buf.encode('utf-8')
+ elif isinstance(buf, bytes):
+ opcode = OP_BYTES
+ else:
+ raise TypeError()
+
+ self.write_frame(opcode, buf)
+
+ def ping(self):
+ self.write_frame(OP_PING,b'ping')
+
+ def close(self, code=CLOSE_OK, reason=''):
+ """Close the websocket."""
+ if not self.open:
+ return
+
+ buf = struct.pack('!H', code) + reason.encode('utf-8')
+
+ self.write_frame(OP_CLOSE, buf)
+ self._close()
+
+ def _close(self):
+ if self.debug: LOGGER.info("Connection closed")
+ self.open = False
+ self.sock.close()
+
+
+class WebsocketClient(Websocket):
+ is_client = True
+
+
+class Client(object):
+
+ @staticmethod
+ def connect(uri, headers=None, debug=False):
+ """
+ Connect a websocket.
+ :param uri: example ws://172.16.185.123/
+ :param headers: k, v of header
+ :param debug: allow output log
+ :return:
+ """
+ if not headers:
+ headers = dict()
+ if not isinstance(headers, dict):
+ raise Exception("headers must be dict type but {} you given.".format(type(headers)))
+
+ uri = urlparse(uri)
+ assert uri
+
+ if debug: LOGGER.info("open connection %s:%s",
+ uri.hostname, uri.port)
+
+ sock = socket.socket()
+ addr = socket.getaddrinfo(uri.hostname, uri.port)
+ sock.connect(addr[0][4])
+
+ if uri.protocol == 'wss':
+ import ussl
+ sock = ussl.wrap_socket(sock)
+
+ def send_header(header, *args):
+ if debug: LOGGER.info(str(header), *args)
+ sock.write(header % args + '\r\n')
+
+ # Sec-WebSocket-Key is 16 bytes of random base64 encoded
+ key = binascii.b2a_base64(bytes(random.getrandbits(8) for _ in range(16)))[:-1]
+ send_header(b'GET %s HTTP/1.1', uri.path or '/')
+ send_header(b'Host: %s:%s', uri.hostname, uri.port)
+ send_header(b'Connection: Upgrade')
+ send_header(b'Upgrade: websocket')
+ send_header(b'Sec-WebSocket-Key: %s', key)
+ send_header(b'Sec-WebSocket-Version: 13')
+ send_header(b'Origin: http://{hostname}:{port}'.format(
+ hostname=uri.hostname,
+ port=uri.port)
+ )
+ for k, v in headers.items():
+ send_header('{}:{}'.format(k, v).encode())
+ send_header(b'')
+
+ header = sock.readline()[:-2]
+ assert header.startswith(b'HTTP/1.1 101 '), header
+
+ # We don't (currently) need these headers
+ # FIXME: should we check the return key?
+ while header:
+ if debug: LOGGER.info(str(header))
+ header = sock.readline()[:-2]
+
+ return WebsocketClient(sock, debug)
--- /dev/null
+Version="V1.0"
+Build_Time="2025-06-19 17:15:15"
--- /dev/null
+# Copyright (c) Quectel Wireless Solution, Co., Ltd.All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+NAME := EG810MCN_GA_VOLTE
+
+GLOBAL_INCS = include
+
+$(NAME)_ARCHIVES = \
+ libraries/libHeliosAPI.lib \
+ libraries/ql_common_api.lib
+
--- /dev/null
+/*
+ *
+ * Automatically generated file; DO NOT EDIT.
+ * Helios SDK Configuration
+ *
+ */
+#define PROJECT_NAME_G3_C06S 1 //项目宏定义
+#define CONFIG_LVGL_SPAN 1
+#define CONFIG_LVGL_FS_HELIOS 1
+#define CONFIG_LVGL_GIF_DECODE 1
+#define CONFIG_LVGL_SPINNER 1
+#define CONFIG_LCD 1
+#define CONFIG_LVGL_ANIMIMG 1
+#define CONFIG_LVGL_KEYBOARD 1
+#define CONFIG_LVGL_CALENDAR 1
+#define CONFIG_LVGL_LED 1
+#define CONFIG_VIOCE_CALL 1
+#define CONFIG_LVGL_FS_EXTFLASH_HELIOS 1
+#define CONFIG_LVGL_TABVIEW 1
+#define CONFIG_LVGL_LINE 1
+#define CONFIG_LVGL 1
+#define CONFIG_LVGL_CHART 1
+#define CONFIG_LVGL_LIST 1
+#define CONFIG_LVGL_MSGBOX 1
+#define CONFIG_LVGL_ARC 1
+#define CONFIG_LVGL_METER 1
+#define CONFIG_LVGL_JPG_DECODE 1
+#define CONFIG_LVGL_PNG_DECODE 1
+#define CONFIG_LVGL_IMGBTN 1
+//#define CONFIG_GH301x 1
+//#define CONFIG_HX3918 1
+#define CONFIG_MBEDTLS 1
+#define CONFIG_SC7A20 1
+#define CONFIG_LVGL_WIN 1
+#define CONFIG_LVGL_COLORWHEEL 1
+#define CONFIG_LVGL_CANVAS 1
+#define CONFIG_LVGL_SPINBOX 1
+#define CONFIG_LVGL_QRCODE 1
+#define CONFIG_LVGL_TILEVIEW 1
+#define CONFIG_LVGL_HANDLER_TASK_PRIORITY 80
+//#define CONFIG_CAMERA 1
+#define CONFIG_JPEG 1
+//#define CONFIG_CAMERA_SAVEPHOTOS 1
--- /dev/null
+
+mainmenu "Helios SDK Configuration"
+
+menu "System Configuration"
+source "../system/config.in"
+endmenu
+
+menu "EG810MCN_GA_VOLTE"
+source "../services/microPython/config/config.in"
+source "../components/poc/poc_option.in"
+source "../components/GH301x/GH301x_option.in"
+source "../components/SC7A20/SC7A20_option.in"
+
+endmenu
+
--- /dev/null
+#
+# Automatically generated file; DO NOT EDIT.
+# Helios SDK Configuration
+#
+PROJECT_NAME_G3_C06S=y
+#
+# System Configuration
+#
+CONFIG_MBEDTLS=y
+
+#
+# EG810MCN_GA_VOLTE
+#
+CONFIG_LVGL=y
+
+#
+# lvgl option
+#
+CONFIG_LVGL_PNG_DECODE=y
+# CONFIG_LVGL_GIF_DECODE is not set
+CONFIG_LVGL_JPG_DECODE=y
+CONFIG_LVGL_FS_HELIOS=y
+# CONFIG_LVGL_FS_SD_HELIOS is not set
+CONFIG_LVGL_FS_EXTFLASH_HELIOS=y
+# CONFIG_LVGL_CUSTOMER_FONT_SUPPORT is not set
+CONFIG_LVGL_QRCODE=y
+# CONFIG_LVGL_FONT is not set
+# CONFIG_LVGL_ARC is not set
+CONFIG_LVGL_IMGBTN=y
+CONFIG_LVGL_LINE=y
+CONFIG_LVGL_LIST=y
+# CONFIG_LVGL_CHART is not set
+# CONFIG_LVGL_LED is not set
+CONFIG_LVGL_CANVAS=y
+CONFIG_LVGL_WIN=y
+# CONFIG_LVGL_TABVIEW is not set
+CONFIG_LVGL_TILEVIEW=y
+CONFIG_LVGL_MSGBOX=y
+# CONFIG_LVGL_METER is not set
+# CONFIG_LVGL_CALENDAR is not set
+# CONFIG_LVGL_SPINNER is not set
+# CONFIG_LVGL_SPINBOX is not set
+# CONFIG_LVGL_ANIMIMG is not set
+# CONFIG_LVGL_COLORWHEEL is not set
+CONFIG_LVGL_KEYBOARD=y
+CONFIG_LVGL_SPAN=y
+CONFIG_LVGL_HANDLER_TASK_PRIORITY=80
+# CONFIG_QRCODE is not set
+#CONFIG_CAMERA=y
+# CONFIG_CAMERA_DECODE is not set
+CONFIG_CAMERA_SAVEPHOTOS=y
+# CONFIG_QUECTHING is not set
+# CONFIG_SPINAND is not set
+# CONFIG_RTMP is not set
+CONFIG_JPEG=y
+# CONFIG_SPI_SDCARD is not set
+CONFIG_VIOCE_CALL=y
+# CONFIG_TTS is not set
+CONFIG_LCD=y
+# CONFIG_UART_SLIP is not set
+# CONFIG_POC is not set
+#CONFIG_GH301x=y
+#CONFIG_HX3918=y
+CONFIG_SC7A20=y
+CONFIG_VAD=y
+#CONFIG_juphoon=y
--- /dev/null
+/*
+ * Copyright (c) Quectel Wireless Solution, Co., Ltd.All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __MPCONFIGBOARD_H__
+#define __MPCONFIGBOARD_H__
+
+#define MICROPY_QPY_MODULE_ATCMD (1)
+#define MICROPY_QPY_MODULE_UOS (1)
+#define MICROPY_QPY_MODULE_MACHINE (1)
+#define MICROPY_QPY_MODULE_USOCKET (1)
+#define MICROPY_QPY_MODULE_MISC (1)
+#define MICROPY_QPY_MODULE_OSTIMER (1)
+#define MICROPY_QPY_MODULE_EXAMPLE (1)
+#define MICROPY_QPY_MODULE_DATACALL (1)
+#define MICROPY_QPY_MODULE_MODEM (1)
+#define MICROPY_QPY_MODULE_UTIME (1)
+#define MICROPY_QPY_MODULE_UTILS (1)
+#define MICROPY_QPY_MODULE_HMACSHA1 (1)
+#define MICROPY_QPY_MODULE_SMS (1)
+#define MICROPY_QPY_MODULE_SIM (1)
+#define MICROPY_QPY_MODULE_DUALSIM (1)
+#define MICROPY_QPY_MODULE_LPM (1)
+#define MICROPY_QPY_MODULE_NET (1)
+#define MICROPY_QPY_MODULE_CELLLOCATOR (0)
+#define MICROPY_QPY_MODULE_CELLLOCATOR_QPY (1)
+#define MICROPY_QPY_MODULE_AUDIO (1)
+#define MICROPY_QPY_MODULE_FOTA (1)
+#define MICROPY_QPY_MODULE_WIFISCAN (1)
+#define MICROPY_QPY_MODULE_QUECGNSS (1)
+#define MICROPY_QPY_MODULE_WIFILOCATOR (1)
+#define MICROPY_QPY_MODULE_ETHERNET (0)
+#define MICROPY_QPY_MODULE_SENSOR (1)
+#define MICROPY_QPY_MODULE_SECUREDATA (1)
+#define MICROPY_QPY_MODULE_SLIP (0)
+#define MICROPY_QPY_MODULE_TP (1)
+#define MICROPY_QPY_MODULE_AUDIOCODEC (0)
+#define MICROPY_QPY_MODULE_CSD (0)
+#define MICROPY_QPY_MODULE_LWM2M (0)
+#define MICROPY_QPY_MODULE_NB (0)
+#define MICROPY_QPY_MODULE_UHASHLIB (1)
+#define MICROPY_QPY_MODULE_UCRYPTOLIB (1)
+#define MICROPY_QPY_MODULE_ALIPAY (0)
+#define MICROPY_QPY_MODULE_VFS_THREADSAFE (1)
+#define MICROPY_QPY_MODULE_GPIO_ENCODER (0)
+#if CONFIG_MBEDTLS
+ #define MICROPY_QPY_MODULE_USSL (1)
+ #define MICROPY_QPY_SSL_MBEDTLS (1)
+#endif
+
+#if CONFIG_QUECTHING
+ #define MICROPY_QPY_MODULE_QUECIOT (1)
+#else
+ #define MICROPY_QPY_MODULE_QUECIOT (0)
+#endif
+
+#if CONFIG_LVGL
+ #define MICROPY_QPY_MODULE_LVGL (1)
+#else
+ #define MICROPY_QPY_MODULE_LVGL (0)
+#endif
+
+#if CONFIG_CAMERA
+ #define MICROPY_QPY_MODULE_CAMERA (1)
+#else
+ #define MICROPY_QPY_MODULE_CAMERA (0)
+#endif
+
+#if CONFIG_RTMP
+ #define MICROPY_QPY_MODULE_RTMP (1)
+#else
+ #define MICROPY_QPY_MODULE_RTMP (0)
+#endif
+#if CONFIG_VIOCE_CALL
+ #define MICROPY_QPY_MODULE_VIOCE_CALL (1)
+#else
+ #define MICROPY_QPY_MODULE_VIOCE_CALL (0)
+#endif
+
+#if CONFIG_POC
+ #define MICROPY_QPY_MODULE_POC (1)
+#else
+ #define MICROPY_QPY_MODULE_POC (0)
+#endif
+#if CONFIG_QRCODE
+ #define MICROPY_QPY_MODULE_QRCODE (1)
+#else
+ #define MICROPY_QPY_MODULE_QRCODE (0)
+#endif
+
+#ifdef CONFIG_QUEC_PROJECT_FEATURE_BLE_GATT
+ #define MICROPY_QPY_MODULE_BLE (1)
+#else
+ #define MICROPY_QPY_MODULE_BLE (0)
+#endif
+
+#ifdef CONFIG_QUEC_PROJECT_FEATURE_CLASSIC_BT
+ #define MICROPY_QPY_MODULE_BT (1)
+#else
+ #define MICROPY_QPY_MODULE_BT (0)
+#endif
+#define MICROPY_QPY_CAMERA_LVGL_PREVIEW (1)
+
+//modmachine
+#if MICROPY_QPY_MODULE_MACHINE
+ #define MICROPY_QPY_MACHINE_TIMER (1)
+ #define MICROPY_QPY_MACHINE_RTC (1)
+ #define MICROPY_QPY_MACHINE_WDT (1)
+ #define MICROPY_QPY_MACHINE_PIN (1)
+ #define MICROPY_QPY_MACHINE_EXTINT (1)
+ #define MICROPY_QPY_MACHINE_UART (1)
+ #define MICROPY_QPY_MACHINE_SPI (1)
+ #define MICROPY_QPY_MACHINE_I2C (1)
+ #define MICROPY_QPY_MACHINE_I2C_SOFT (1)
+ #ifdef CONFIG_LCD
+ #define MICROPY_QPY_MACHINE_LCD (1)
+#else
+ #define MICROPY_QPY_MACHINE_LCD (0)
+#endif
+ #define MICROPY_QPY_MACHINE_KEYPAD (1)
+ #ifdef CONFIG_SPINAND
+ #define MICROPY_QPY_MACHINE_NANDFLASH (1)
+ #else
+ #define MICROPY_QPY_MACHINE_NANDFLASH (0)
+ #endif
+
+#if MICROPY_QPY_MACHINE_UART
+ #define MICROPY_QPY_UART4 (1)
+#endif
+
+#endif
+
+#if MICROPY_QPY_MODULE_MISC
+ #define MICROPY_QPY_MISC_POWER (1)
+ #define MICROPY_QPY_MISC_ADC (1)
+ #define MICROPY_QPY_MISC_POWERKEY (1)
+ #define MICROPY_QPY_MISC_TEMPERATURE (0)
+ #define MICROPY_QPY_MISC_PWM (1)
+ #define MICROPY_QPY_MISC_USB (1)
+ #define MICROPY_QPY_MISC_USBNET (1)
+#endif
+
+#if MICROPY_QPY_MODULE_AUDIO
+ #define MICROPY_QPY_AUDIO_AUDIO (1)
+ #if CONFIG_TTS
+ #define MICROPY_QPY_AUDIO_TTS (1)
+ #else
+ #define MICROPY_QPY_AUDIO_TTS (0)
+ #endif
+ #define MICROPY_QPY_AUDIO_RECORD (1)
+#endif
+
+#if MICROPY_QPY_MODULE_ETHERNET
+ #define MICROPY_QPY_ETHERNET_DM9051 (0)
+ #define MICROPY_QPY_ETHERNET_W5500 (0)
+#endif
+
+#if MICROPY_QPY_MODULE_TP
+ #define MICROPY_QPY_TP_XPT2046 (0)
+ #define MICROPY_QPY_TP_GT9XX (0)
+ #define MICROPY_QPY_TP_CST816 (1)
+#endif
+
+#if MICROPY_QPY_MODULE_AUDIOCODEC
+ #define MICROPY_QPY_AUDIOCODEC_RT5616 (0)
+#endif
+
+#if MICROPY_QPY_MODULE_SENSOR
+ #define MICROPY_QPY_SENSOR_SN95500 (0)
+ #define MICROPY_QPY_SENSOR_ICC_KEY (0)
+ #define MICROPY_QPY_SENSOR_GNSS (1)
+#endif
+
+#if MICROPY_QPY_MODULE_CAMERA
+ #define MICROPY_QPY_CAMERA_CAMPREVIEW (1)
+ #if CONFIG_CAMERA_SAVEPHOTOS
+ #define MICROPY_QPY_CAMERA_CAMCAPTURE (1)
+ #else
+ #define MICROPY_QPY_CAMERA_CAMCAPTURE (0)
+ #endif
+ #ifdef CONFIG_CAMERA_DECODE
+ #define MICROPY_QPY_CAMERA_CAMSCANDECODE (1)
+ #else
+ #define MICROPY_QPY_CAMERA_CAMSCANDECODE (0)
+ #endif
+#endif
+
+#define MICROPY_QPY_DEVICE_REPORT (1)
+
+/***********************micropython opts*******************************/
+#define MICROPY_QPY_DEBUG_PRINTERS (0) //flash 4160 Byte
+#define MICROPY_QPY_PY_MATH (1) //flash 14880 Byte
+#define MICROPY_QPY_PY_CMATH (0) //flash 3136 Byte
+#define MICROPY_QPY_PY_USELECT (0) //flash 1792 Byte
+#define MICROPY_QPY_PY_UCTYPES (1) //flash 2816 Byte
+#define MICROPY_QPY_PY_UZLIB (0) //flash 3072 Byte
+#define MICROPY_QPY_PY_UASYNCIO (0) //flash 2048 Byte
+#define MICROPY_QPY_PY_ENABLE_WEBSERVER (0) //flash 3424 Byte
+#define MICROPY_QPY_PERSISTENT_CODE_LOAD (1) //flash 2048 Byte
+#define MICROPY_QPY_EMIT_XTENSAWIN (0) //flash 19776 Byte
+#define MICROPY_QPY_MODULE_VFS_THREADSAFE (1)
+#define MICROPY_QPY_GC_HEAP_SIZE (1000 * 1024)
+#endif
\ No newline at end of file
--- /dev/null
+
+#ifndef __APP_LINK_START_ADDR_H__
+#define __APP_LINK_START_ADDR_H__
+
+#define APP_LINK_START_ADDR 0x80521000
+#define APP_FLASH_MAX_SIZE 0x1F8000
+
+#define APP_RAM_START 0x7E3E0000
+#define APP_RAM_MAX_SIZE 0x180000
+
+#endif
--- /dev/null
+import main_init
+main_init.main_init()
\ No newline at end of file