From: p15692025051 <846603105@qq.com> Date: Tue, 11 Apr 2023 01:48:44 +0000 (+0800) Subject: 1.添加工厂模式 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=12db56b401591ea48e165fa9c35e0143e260c1ee;p=mirrors%2FASR1603_G5.git 1.添加工厂模式 2.修改屏背光 --- diff --git a/3.code/1.watch/2.code/lcd.py b/3.code/1.watch/2.code/lcd.py index 3108cd16..b2df7af4 100644 --- a/3.code/1.watch/2.code/lcd.py +++ b/3.code/1.watch/2.code/lcd.py @@ -4,7 +4,7 @@ from tp import cst816 import _thread import utime from ext import EventMesh - +from misc import PWM init_data = ( @@ -140,8 +140,10 @@ displayon = bytearray(init_data4) 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 = 5) -gpio_backlight = Pin(Pin.GPIO37, Pin.OUT, Pin.PULL_DISABLE, 0) -gpio_backlight.write(0) +# 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 @@ -226,4 +228,5 @@ print("power_on_screen init...") lv.scr_load(power_on_screen) utime.sleep_ms(1000) print("power_on_screen end...") -gpio_backlight.write(1) +PWM_backlight = PWM(PWM.PWM1, PWM.ABOVE_MS, 1, 1) +PWM_backlight.open() diff --git a/3.code/1.watch/2.code/main.py b/3.code/1.watch/2.code/main.py index 6bf13abb..83c43f66 100644 --- a/3.code/1.watch/2.code/main.py +++ b/3.code/1.watch/2.code/main.py @@ -45,7 +45,7 @@ if __name__ == '__main__': from ext import EventMesh from ext.common import Abstract - from ext.lcd import gpio_backlight,tp_cst816 + from ext.lcd import tp_cst816 from ext.btn_device_ec800m import BtnDevice from ext.protocol import LK_ProtoCol,PING_ProtoCol,WT_ProtoCol,UD_ProtoCol,REMIND_ProtoCol, CR_ProtoCol,KA_ProtoCol,FIND_ProtoCol,POWEROFF_ProtoCol,ProtoColResolver,PHL_ProtoCol import ext.mgr as mgr @@ -59,13 +59,14 @@ if __name__ == '__main__': from ext.ui_main_menu import MainMenuScreen from ext.appWechat import WechatScreen,TK_ProtoCol,MESSAGE_ProtoCol import ext.ui_setting as _ui_setting + from ext.appFactoryMode import FactoryModeLocationScreen,FactoryModeScreen from usr.test_sms import hrTimeHandlerManager #from usr.ui_wechat import WechatScreen,TK_ProtoCol btn_device = BtnDevice(tp_cst816) btn_device.start() - ui = _ui.UI(gpio_backlight) + ui = _ui.UI() ui.add_screen(WatchFaceScreen()) ui.add_screen(_ui.PopupScreen()) ui.add_screen(_ui.PhoneScreen()) @@ -118,6 +119,8 @@ if __name__ == '__main__': ui.add_screen(_ui.IncomingCallScreen()) ui.add_screen(_ui.OnCallScreen()) # ui.add_screen(_ui.PowerOnScreen()) + ui.add_screen(FactoryModeLocationScreen()) + ui.add_screen(FactoryModeScreen()) # ui.add_screen(_ui.Setting2Screen()) # ui.add_screen(_ui.Setting3Screen()) diff --git a/3.code/1.watch/2.code/main_1.py b/3.code/1.watch/2.code/main_1.py index d10bc1e9..a550eab6 100644 --- a/3.code/1.watch/2.code/main_1.py +++ b/3.code/1.watch/2.code/main_1.py @@ -45,7 +45,7 @@ if __name__ == '__main__': from ext import EventMesh from ext.common import Abstract - from ext.lcd import gpio_backlight,tp_cst816 + from ext.lcd import tp_cst816 from ext.btn_device_ec800m import BtnDevice from ext.protocol import LK_ProtoCol,PING_ProtoCol,WT_ProtoCol,UD_ProtoCol,REMIND_ProtoCol, CR_ProtoCol,KA_ProtoCol,FIND_ProtoCol,POWEROFF_ProtoCol,ProtoColResolver,PHL_ProtoCol import ext.mgr as mgr @@ -59,13 +59,14 @@ if __name__ == '__main__': from ext.ui_main_menu import MainMenuScreen from ext.appWechat import WechatScreen,TK_ProtoCol,MESSAGE_ProtoCol import ext.ui_setting as _ui_setting - from usr.test_sms import hrTimeHandlerManager,HRSTART_ProtoCol,getHrTimeManager + from ext.appFactoryMode import FactoryModeLocationScreen,FactoryModeScreen + from ext.test_sms import hrTimeHandlerManager,HRSTART_ProtoCol,getHrTimeManager #from usr.ui_wechat import WechatScreen,TK_ProtoCol btn_device = BtnDevice(tp_cst816) btn_device.start() - ui = _ui.UI(gpio_backlight) + ui = _ui.UI() ui.add_screen(WatchFaceScreen()) ui.add_screen(_ui.PopupScreen()) ui.add_screen(_ui.PhoneScreen()) @@ -118,6 +119,8 @@ if __name__ == '__main__': ui.add_screen(_ui.IncomingCallScreen()) ui.add_screen(_ui.OnCallScreen()) # ui.add_screen(_ui.PowerOnScreen()) + ui.add_screen(FactoryModeLocationScreen()) + ui.add_screen(FactoryModeScreen()) # ui.add_screen(_ui.Setting2Screen()) # ui.add_screen(_ui.Setting3Screen()) diff --git a/3.code/1.watch/2.code/mgr.py b/3.code/1.watch/2.code/mgr.py index e0b349da..b056ca9f 100644 --- a/3.code/1.watch/2.code/mgr.py +++ b/3.code/1.watch/2.code/mgr.py @@ -621,7 +621,7 @@ class DeviceInfoManager(Abstract): EventMesh.publish(constants.EVENT.START_LOCATION) #开始定位 EventMesh.publish(constants.EVENT.PUSH_STEP, self.get_step_count()) - hr_time = EventMesh.publish("get_hr_spo2_time")#获取时间是否大于0 + hr_time = EventMesh.publish("get_time_hr_spo2")#获取时间是否大于0 get_hr_state = EventMesh.publish("get_hr_state") @@ -1124,7 +1124,10 @@ class LocationManager(Abstract): self.gps_data = [] self.cell_data = [] EventMesh.publish(constants.EVENT.WIFISCANOPEN) - + if msg != None : + self.location_type = msg + else : + self.location_type = 0 def close_location(self, event, msg): self.gps.power_switch(0) @@ -1162,14 +1165,8 @@ class LocationManager(Abstract): def location_timer(self, *args, **kwargs): + data = "" self.location_timer_count = self.location_timer_count +1 - if self.location_timer_count > 60 : #1分钟定位超时,超时发送数据,停止定时器及关闭定位 - # print("publish:CLOSE_LOCATION") - self.location_timer_count = 0 - EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位 - EventMesh.publish(constants.EVENT.READ_LOCATION, [self.gps_data,self.wifi_data,self.cell_data])#发送数据 - - self.location_check_data_timer_count = self.location_check_data_timer_count+1 if self.location_check_data_timer_count > 5 :#5秒查一次 self.location_check_data_timer_count = 0 @@ -1215,12 +1212,19 @@ class LocationManager(Abstract): if cell and cell[0][0] == 0 : self.cell_data = cell break - - if self.gps_data != [] : #or( self.wifi_data != [] and self.cell_data != []): - #print("publish:READ_LOCATION") - EventMesh.publish(constants.EVENT.READ_LOCATION, [self.gps_data,self.wifi_data,self.cell_data]) - EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位 - + if self.location_type == 1: #测试模式 + EventMesh.publish("PUSH_LOCATION_DATA", [data,self.wifi_data,self.cell_data]) + elif self.location_type == 0: #正常模式 + if self.gps_data != [] or self.location_timer_count > 60: #or( self.wifi_data != [] and self.cell_data != []): + #print("publish:READ_LOCATION") + EventMesh.publish(constants.EVENT.READ_LOCATION, [self.gps_data,self.wifi_data,self.cell_data]) + EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位 + # if self.location_timer_count > 60 : #1分钟定位超时,超时发送数据,停止定时器及关闭定位 + # EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位 + # EventMesh.publish(constants.EVENT.READ_LOCATION, [self.gps_data,self.wifi_data,self.cell_data])#发送数据 + + + # class AddrBookManager(Abstract): # # 通讯录 diff --git a/3.code/1.watch/2.code/ui.py b/3.code/1.watch/2.code/ui.py index 6f02b7aa..995a0a1c 100644 --- a/3.code/1.watch/2.code/ui.py +++ b/3.code/1.watch/2.code/ui.py @@ -14,7 +14,8 @@ import ql_fs import audio import sms from machine import Pin -from ext.lcd import gpio_backlight,lcd,lcd_ctrl,tp_cst816 +from ext.lcd import lcd,lcd_ctrl,tp_cst816 +from misc import PWM import uos # -----------------------------------------style create-------------------------------------- style_screen = lv.style_t() @@ -2911,19 +2912,7 @@ class StopwatchScreen(Screen): -# class PowerOnScreen(Screen): -# NAME = "PowerOn" -# def __init__(self): -# super().__init__() -# self.meta = power_on_screen -# self.timer = osTimer() -# def post_processor_after_initialization(self): -# self.timer.start(2*1000,0,self.update_show) - -# def update_show(self,*agrs): - -# EventMesh.publish("load_screen", {"screen": "watchface"}) class UIFINDScreen(Screen): @@ -2995,18 +2984,19 @@ class UIFINDScreen(Screen): #from usr.ui_WatchFaceScreen import WatchFaceScreen class UI(object): - def __init__(self, lcd_gpio): + def __init__(self): #self.screen = WatchFaceScreen() #self.screen_old = self.screen self.screen = None self.screen_old = None self.screen_list = [] self.lv = lv - self.lcd_gpio = lcd_gpio self.system_sleep_timer = osTimer() self.system_sleep_timer_count = 0 self.main_flag = 0 self.sleep_flag = 1 + self.PWM_backlight = PWM(PWM.PWM1, PWM.ABOVE_MS, 1, 1) + self.PWM_backlight.open() def post_processor_after_instantiation(self): EventMesh.subscribe("load_screen", self.load_screen) @@ -3085,22 +3075,20 @@ class UI(object): if event == "btn1_release": self.screen.btn1_release() - def __lcd_state(self): - return self.lcd_gpio.read() - def __lcd_on(self): print("__lcd_on") if self.sleep_flag == 0 : self.sleep_flag = 1 self.system_sleep_timeout_rest() - gpio_backlight.write(1) + self.PWM_backlight = PWM(PWM.PWM1, PWM.ABOVE_MS, 1, 1) + self.PWM_backlight.open() #lcd_ctrl.write(1) #utime.sleep(10) tp_cst816.resume() lcd.lcd_display_on() lv.autoSleep(0) pm.autosleep(0) - utime.sleep_ms(100) + #utime.sleep_ms(100) def publish_call_in(self, event, msg): EventMesh.publish("load_screen", {"screen": "dialing", "meta": msg}) @@ -3109,14 +3097,15 @@ class UI(object): #print("__lcd_off") if self.sleep_flag == 1 : self.sleep_flag = 0 - gpio_backlight.write(0) + self.PWM_backlight = PWM(PWM.PWM1, PWM.ABOVE_MS, 0, 1) + self.PWM_backlight.open() #lcd_ctrl.write(0) #utime.sleep(10) tp_cst816.suspend() lcd.lcd_display_off() lv.autoSleep(1) pm.autosleep(1) - utime.sleep_ms(300) + #utime.sleep_ms(300) def system_sleep(self, event, msg) : self.__lcd_off() @@ -3128,8 +3117,6 @@ class UI(object): self.system_sleep_timer_count += 1 if self.system_sleep_timer_count > 50 : self.system_sleep_timer_count = 0 - #print("__lcd_state") - #if self.sleep_flag == 1: # 未息屏状态,熄灭屏幕 self.__lcd_off() def system_sleep_timeout_rest(self) : diff --git a/3.code/1.watch/2.code/ui_setting.py b/3.code/1.watch/2.code/ui_setting.py index b7fd608e..c7b63e8d 100644 --- a/3.code/1.watch/2.code/ui_setting.py +++ b/3.code/1.watch/2.code/ui_setting.py @@ -285,9 +285,7 @@ class SettingScreen(Screen): setting_update_img.add_event_cb(lambda e: self.load_screen(e, {"screen": "update"}), lv.EVENT.CLICKED, None) setting_version_img.add_event_cb(lambda e: self.load_screen(e, {"screen": "version"}), lv.EVENT.CLICKED, None) - def done_bottom_to_top(self): - #上滑添加动画切屏:动画类型,时间,延迟,auto_del - EventMesh.publish("load_screen", {"screen": "setting2"}) + def done_return(self): EventMesh.publish("load_screen", {"screen": "main_menu"}) @@ -926,6 +924,20 @@ class VersionScreen(Screen): def __init__(self): super().__init__() self.meta = version_screen + self.btn_count = 0 + + 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("load_screen", {"screen": "setting"})