import _thread
import utime
from ext import EventMesh
-
+from misc import PWM
init_data = (
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
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()
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
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())
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())
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
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())
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())
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")
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)
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
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):
# # 通讯录
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()
-# 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):
#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)
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})
#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()
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) :
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"})
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"})