声音调节关机开机不重置的问题
authord15521469561 <d155214695615@qq.com>
Wed, 10 May 2023 07:40:48 +0000 (15:40 +0800)
committerd15521469561 <d155214695615@qq.com>
Wed, 10 May 2023 07:40:48 +0000 (15:40 +0800)
3.code/1.watch/2.code/appWechat.py
3.code/1.watch/2.code/main.py
3.code/1.watch/2.code/main_1.py

index 365af17..f37e40d 100644 (file)
@@ -84,6 +84,7 @@ class WechatScreen(Screen):
         self.wechat_num = 0
         self.read_data = {}
         self.volum_size = 8 
+        self.msg_tmp = ""
         check_txt = ql_fs.path_exists("/ext/static/storage_file/wechat_num.txt")
         if check_txt == True :
             with open("/ext/static/storage_file/wechat_num.txt","r") as fd:#音频文件编号
@@ -159,7 +160,7 @@ class WechatScreen(Screen):
             #写编号
         with open("/ext/static/storage_file/wechat_num.txt","w") as fd:
                 fd.write("{}".format(self.wechat_num))
-        #print("self.MXA_MSG:{} self.wechat_num:{} self.wechat_recode_list:{}".format(self.MXA_MSG,self.wechat_num,self.wechat_recode_list))
+        print("self.MXA_MSG:{} self.wechat_num:{} self.wechat_recode_list:{}".format(self.MXA_MSG,self.wechat_num,self.wechat_recode_list))
 
     def wechat_updata_list_show(self, event, msg): 
         if (self.wechat_list.has_flag(lv.obj.FLAG.HIDDEN)) == False:
@@ -180,9 +181,7 @@ class WechatScreen(Screen):
                 elif index == 2 or index == 1:
                     #读取json文件中的键作为label文本;
                     #print("self.wechat_list.self.wechat_num:{}".format(self.wechat_num))
-                    self.startWidth = 0
-                    self.startY = 0
-                    i = 0
+                    
                     print("self.wechat_recode_list:{}".format(self.wechat_recode_list))
                     self.wechat_list.delete()#先删除一次控件
                     self.wechat_list = lv.obj(wechat_screen)
@@ -194,52 +193,35 @@ class WechatScreen(Screen):
                     if index == 2:
                         self.wechat_list.add_flag(lv.obj.FLAG.HIDDEN)
                     j = 1
-                    count = 0
                     if len(self.wechat_recode_list) == self.MXA_MSG:
                         j = self.wechat_num+1
+                    print("wechat_num:{} ".format(self.wechat_num))
                     for i in range(self.MXA_MSG):
                         if j > self.MXA_MSG:
                             j = 1
                         key = "%02d"%(j)
                         
-                        # if j > len(self.wechat_recode_list) :
-                        #     break
+                        if j > len(self.wechat_recode_list) :
+                            break
                         j+=1
-                        
-                        # print("self.wechat_recode_list.keys():{}".format(self.wechat_recode_list.keys()))
-                        # if self.wechat_recode_list.keys().find("%02d"%(j)) == -1:
-                        #     continue
-                        # num = "%02d"
-                        if key in self.wechat_recode_list:
-                            
-                            print('键存在于字典中')
-                        else:
-                            if count > 0:
-                                count-=1
-                            print('键不存在于字典中')
-                            continue
-
-                            
                     
                         value = self.wechat_recode_list[key]
-                        # print("value:{}".format(value))
-                        self.startY = 52*count 
+                        print("value:{} key:{}".format(value,key))
+
+                        self.startY = 56*i 
+                        print("self.startY:{}".format(self.startY))
                         if value.find("S:") != -1 or value.find("R:") != -1:
-                            msg_tmp = value[2:] 
-                            msg_tmp = int(msg_tmp)
-                            self.startWidth = 55+msg_tmp*10
+                            self.msg_tmp = value[2:] 
+                            self.msg_tmp = int(self.msg_tmp)
+                            self.startWidth = 55+self.msg_tmp*10
                             
                         elif value.find("T:") != -1:#文字显示
-                            msg_tmp = value[2:] 
-                            size = len(msg_tmp)
-                            self.startWidth = size*20
-                            # print("self.startWidth :{} size:{}".format(self.startWidth,size))
-                            if self.startWidth > 230:
-                                self.startWidth = 230
+                            self.msg_tmp = value[2:] 
+                            self.startWidth = 230
                         
                         wechat_btn = lv.btn(self.wechat_list)
                         # if value.find("R:") != -1:
-                        wechat_btn.set_size(self.startWidth,50)
+                        wechat_btn.set_size(self.startWidth,54)
                         if value.find("R:") != -1 or value.find("T:") != -1 :#显示文字:
                             wechat_btn.set_pos(10,self.startY )
                             wechat_btn.add_style(style_wechat_s_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
@@ -249,21 +231,22 @@ class WechatScreen(Screen):
                         if value.find("R:") != -1 or value.find("S:") != -1:
                             wechat_btn.add_event_cb(lambda e: self.play_label(e),
                                 lv.EVENT.CLICKED, None)
-
+                        
                         _btn_label1 = lv.label(wechat_btn)
                         if value.find("R:") != -1:
                             _btn_label1.set_size(40, 40)
                             _btn_label1.set_pos(35, 8)
-                            _btn_label1.set_text(str(msg_tmp)+'\"')
+                            _btn_label1.set_text(str(self.msg_tmp)+'\"')
                             
                         elif value.find("S:") != -1:
                             _btn_label1.set_size(40, 40)
-                            _btn_label1.set_pos(self.startWidth-72, 8)
-                            _btn_label1.set_text(str(msg_tmp)+'\"')
+                            _btn_label1.set_pos(self.startWidth-78, 8)
+                            _btn_label1.set_text(str(self.msg_tmp)+'\"')
                         elif value.find("T:") != -1:
-                            _btn_label1.set_size(230, 60)
+                            print("msg_tmp:{}".format(self.msg_tmp))
+                            _btn_label1.set_size(216, 66)
                             _btn_label1.set_pos(0, 0)
-                            _btn_label1.set_text(str(msg_tmp))
+                            _btn_label1.set_text(str(self.msg_tmp))
                             _btn_label1.set_long_mode(lv.label.LONG.DOT)
 
                         _btn_label1.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
@@ -287,7 +270,6 @@ class WechatScreen(Screen):
                                 _btn_img.set_pos(self.startWidth-50, 0)
                                 _btn_img.set_src("E:/static/APP/wechat/S_3.png")
                             _btn_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-                        count+=1
                     bottom_btn1 = self.wechat_list.get_child(-1)
                     bottom_btn1.scroll_to_view(lv.ANIM.OFF)    
 
@@ -319,7 +301,7 @@ class WechatScreen(Screen):
         if self.wechat_num >= self.MXA_MSG:
             self.wechat_num = 0 
         self.wechat_num += 1 
-        print("talking self.wechat_num ...:{}".format(self.wechat_num))
+        print("talking self.wechat_num ...:{} self.MXA_MSG:{}".format(self.wechat_num,self.MXA_MSG))
         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
@@ -354,10 +336,12 @@ class WechatScreen(Screen):
             #读音频amr二进制数据
             
             #修改或添加词典键值
-        
+            self.press_state = 0
+            self.ble_send = 0
+            self.timer.start(2 * 1000, 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)
-                    
+            print("senddata self.wechat_num ...:{}".format(self.wechat_num))
             path = "/ext/static/storage_file/{}.amr".format(self.wechat_num)
             with open(path,"rb") as fd:
                 buf = bytearray(ql_fs.path_getsize(path))
@@ -365,9 +349,9 @@ class WechatScreen(Screen):
                 senddata = [self.countdown_old,buf]
                 EventMesh.publish(constants.PROTOCOL.TK_SEND,senddata)
             #隐藏显示文本 显示列表显示框
-            self.press_state = 0
-            self.ble_send = 0
-            self.timer.start(2 * 1000, 0, self.hide_label)
+            
+           
+            
             self.updata_list_show(2)
             
 
@@ -582,12 +566,14 @@ class TK_ProtoCol(ProtoCol):
             wechat_num = get_wechat_data[1]
             MXA_MSG = get_wechat_data[0]
             wechat_recode_list = get_wechat_data[2]
-            if wechat_num > 0:
-                wechat_num += 1 
+            # print("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 
            
             #写记录列表
             wechat_recode_list["%02d"%(wechat_num)] = "R:{}".format(3)
@@ -661,12 +647,14 @@ class MESSAGE_ProtoCol(ProtoCol):
         wechat_num = get_wechat_data[1]
         MXA_MSG = get_wechat_data[0]
         wechat_recode_list = get_wechat_data[2]
-        if wechat_num > 0:
-            wechat_num += 1 
+        # print("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
         # print("msg_tmp:init {}".format(msg_s))
index d4cd94f..87095de 100644 (file)
@@ -130,8 +130,9 @@ if __name__ == '__main__':
     print("init6:{}".format(utime.localtime()))
     
 
-    from protocol import LK_ProtoCol,PING_ProtoCol,HEART_ProtoCol,OXYGEN_ProtoCol,OXYGEN_One_ProtoCol,HRSTART_ProtoCol,CENTER_ProtoCol,UPLOAD_ProtoCol,TEMP_ProtoCol,DLT_ProtoCol,\
-        WT_ProtoCol,UD_ProtoCol,REMIND_ProtoCol, CR_ProtoCol,KA_ProtoCol,FIND_ProtoCol,POWEROFF_ProtoCol,ProtoColResolver,PHL_ProtoCol,MONITOR_ProtoCol
+    from protocol import LK_ProtoCol,PING_ProtoCol,HEART_ProtoCol,OXYGEN_ProtoCol,OXYGEN_One_ProtoCol,HRSTART_ProtoCol,CENTER_ProtoCol,UPLOAD_ProtoCol,\
+        TEMP_ProtoCol,DLT_ProtoCol,WT_ProtoCol,UD_ProtoCol,REMIND_ProtoCol, CR_ProtoCol,KA_ProtoCol,FIND_ProtoCol,POWEROFF_ProtoCol,\
+            ProtoColResolver,PHL_ProtoCol,MONITOR_ProtoCol,bootoff_ProtoCol
     import mgr as mgr
     print("init7:{}".format(utime.localtime()))
     
@@ -178,6 +179,7 @@ if __name__ == '__main__':
     app.append_manager(getBrightnessManager())
     app.append_manager(getStorageDataManager())
     app.append_manager(getUpLoadDataManager())
+    app.append_manager(getVolumSizeManager())
 
     print("init11:{}".format(utime.localtime()))    
     pcr = ProtoColResolver()
@@ -203,6 +205,7 @@ if __name__ == '__main__':
     pcr.add_support(MONITOR_ProtoCol())
     # pcr.add_support(CENTER_ProtoCol())
     pcr.add_support(CENTER_ProtoCol())
+    pcr.add_support(bootoff_ProtoCol())
     sm = SockManager()
     sm.add_support_resolver(pcr)
     app.append_manager(sm)
index d4cd94f..3c5822e 100644 (file)
@@ -76,7 +76,7 @@ if __name__ == '__main__':
     ui.add_screen(_ui.Spo2Screen()) 
     ui.add_screen(_ui.TemperatureScreen()) 
     ui.add_screen(_ui.ContactsScreen()) 
-    from appWechat import WechatScreen,TK_ProtoCol,MESSAGE_ProtoCol,NewWechatPopupScreen
+    from ext.appWechat import WechatScreen,TK_ProtoCol,MESSAGE_ProtoCol,NewWechatPopupScreen
     ui.add_screen(WechatScreen()) 
     from alarm import ClkListScreen,ClockManager,NewEditClk,CLKTimeScreen,ClkPeriod,PopupAlarmScreen
     ui.add_screen(ClkListScreen()) 
@@ -130,8 +130,9 @@ if __name__ == '__main__':
     print("init6:{}".format(utime.localtime()))
     
 
-    from protocol import LK_ProtoCol,PING_ProtoCol,HEART_ProtoCol,OXYGEN_ProtoCol,OXYGEN_One_ProtoCol,HRSTART_ProtoCol,CENTER_ProtoCol,UPLOAD_ProtoCol,TEMP_ProtoCol,DLT_ProtoCol,\
-        WT_ProtoCol,UD_ProtoCol,REMIND_ProtoCol, CR_ProtoCol,KA_ProtoCol,FIND_ProtoCol,POWEROFF_ProtoCol,ProtoColResolver,PHL_ProtoCol,MONITOR_ProtoCol
+    from protocol import LK_ProtoCol,PING_ProtoCol,HEART_ProtoCol,OXYGEN_ProtoCol,OXYGEN_One_ProtoCol,HRSTART_ProtoCol,CENTER_ProtoCol,UPLOAD_ProtoCol,\
+        TEMP_ProtoCol,DLT_ProtoCol,WT_ProtoCol,UD_ProtoCol,REMIND_ProtoCol, CR_ProtoCol,KA_ProtoCol,FIND_ProtoCol,POWEROFF_ProtoCol,\
+            ProtoColResolver,PHL_ProtoCol,MONITOR_ProtoCol,bootoff_ProtoCol
     import mgr as mgr
     print("init7:{}".format(utime.localtime()))
     
@@ -178,6 +179,7 @@ if __name__ == '__main__':
     app.append_manager(getBrightnessManager())
     app.append_manager(getStorageDataManager())
     app.append_manager(getUpLoadDataManager())
+    app.append_manager(getVolumSizeManager())
 
     print("init11:{}".format(utime.localtime()))    
     pcr = ProtoColResolver()
@@ -203,6 +205,7 @@ if __name__ == '__main__':
     pcr.add_support(MONITOR_ProtoCol())
     # pcr.add_support(CENTER_ProtoCol())
     pcr.add_support(CENTER_ProtoCol())
+    pcr.add_support(bootoff_ProtoCol())
     sm = SockManager()
     sm.add_support_resolver(pcr)
     app.append_manager(sm)