From: p15692025051 <846603105@qq.com> Date: Mon, 4 Dec 2023 11:24:05 +0000 (+0800) Subject: D10死机问题处理 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=24de559074e3df3756fc1c927e2077ca9dbaa104;p=mirrors%2FASR1603_G5.git D10死机问题处理 D10佩戴、跌落功能实现 --- diff --git a/2.sdk/Helios_SDK/components/HX3918/hx3918.h b/2.sdk/Helios_SDK/components/HX3918/hx3918.h index 79feaf24..39bfd53e 100644 --- a/2.sdk/Helios_SDK/components/HX3918/hx3918.h +++ b/2.sdk/Helios_SDK/components/HX3918/hx3918.h @@ -3,7 +3,7 @@ #include #include #include "helios_debug.h" -#define HX3918_DEBUG 1 +#define HX3918_DEBUG 0 #if HX3918_DEBUG == 1 #define HX3918_LOG(msg, ...) custom_log("HX3918", msg, ##__VA_ARGS__) #else diff --git a/2.sdk/Helios_SDK/components/HX3918/hx3918_prox.h b/2.sdk/Helios_SDK/components/HX3918/hx3918_prox.h index 9882344f..bd398568 100644 --- a/2.sdk/Helios_SDK/components/HX3918/hx3918_prox.h +++ b/2.sdk/Helios_SDK/components/HX3918/hx3918_prox.h @@ -9,7 +9,7 @@ #include #include - +#include "autoconf.h" @@ -68,8 +68,11 @@ //#define FULL125PF //HX3918 full range cap = 1.25pf //#define FULL25PF //HX3918 full range cap = 2.5pf, 一般PAD大小默认这个. //#define FULL375PF //HX3918 full range cap = 3.75 pf +#if PROJECT_NAME_G5_D10 == 1 +#define FULL25PF +#else #define FULL50PF //HX3918 full range cap = 5.0 pf - +#endif //READ_DEVATION ,read offset 的偏差控制, 一个offset = 0.0586pf 按照不同量程, 对应的code, 留10%余量 #ifdef FULL125PF #define READ_DEVATION 1680 diff --git a/2.sdk/Helios_SDK/services/microPython/ports/quectel/core/source/modGsensor_SC7A20.c b/2.sdk/Helios_SDK/services/microPython/ports/quectel/core/source/modGsensor_SC7A20.c index d65ec440..2a119e74 100644 --- a/2.sdk/Helios_SDK/services/microPython/ports/quectel/core/source/modGsensor_SC7A20.c +++ b/2.sdk/Helios_SDK/services/microPython/ports/quectel/core/source/modGsensor_SC7A20.c @@ -48,6 +48,7 @@ #include "helios_timer.h" #include "helios_extint.h" extern Helios_Thread_t sensor_thread_id ; +extern Helios_ThreadAttr HealthSensor; // extern int sensor_timer ; //#define TIMER_TIME_MS 10 //10ms #define IS_CYCLICAL 1 @@ -242,8 +243,8 @@ void Gsensor_CALLBACK_OP(uint8_t state) } } -#define FALL_DETECH_LOW_THRESHOLD 40 -#define FALL_COUNTER_THRESHOLD 8 +#define FALL_DETECH_LOW_THRESHOLD 35 +#define FALL_COUNTER_THRESHOLD 7 static uint16_t fall_counter = 0; uint8_t gsensor_sc7a20_fall_detect(acc_g_data_t * acc) { @@ -430,8 +431,8 @@ unsigned int SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO(void) hx3918_set_gsen_fifo(SC7A20_XYZ_Buf_tmp[0],SC7A20_XYZ_Buf_tmp[1],SC7A20_XYZ_Buf_tmp[2],SC7A20_XYZ_Buf_tmp_len); SC7A20_XYZ_Buf_tmp_len = 0; } - #endif - #if CONFIG_GH301x + + #elif CONFIG_GH301x // s_sc7a20_read_data_counter++; if(SC7A20_XYZ_Buf_tmp_len >= 25) { @@ -457,6 +458,18 @@ unsigned int SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO(void) SC7A20_XYZ_Buf_tmp_len = 0; //SC7A20_LOG("SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO:s_sc7a20_read_data_len:%d\r\n",s_sc7a20_read_data_len); } + #else + if(SC7A20_XYZ_Buf_tmp_len >= 25) + { + for(i = 0; i < SC7A20_XYZ_Buf_tmp_len; i++) + { + SC7A20_XYZ_Buf_tmp[0][i] = SC7A20_XYZ_Buf_tmp[0][i]/2; + SC7A20_XYZ_Buf_tmp[1][i] = SC7A20_XYZ_Buf_tmp[1][i]/2; + SC7A20_XYZ_Buf_tmp[2][i] = SC7A20_XYZ_Buf_tmp[2][i]/2; + } + //hx3918_set_gsen_fifo(SC7A20_XYZ_Buf_tmp[0],SC7A20_XYZ_Buf_tmp[1],SC7A20_XYZ_Buf_tmp[2],SC7A20_XYZ_Buf_tmp_len); + SC7A20_XYZ_Buf_tmp_len = 0; + } #endif //SC7A20_LOG("SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO:SC7A20_FIFO_NUM:%d\r\n",SC7A20_FIFO_NUM); @@ -670,7 +683,7 @@ int SC7A20_init(void) if(sensor_thread_id == 0) - sensor_thread_id = Helios_Thread_Create(&ThreadAttr);//和hsensor一个iic,必须在一个线程读数据 + sensor_thread_id = Helios_Thread_Create(&HealthSensor);//和hsensor一个iic,必须在一个线程读数据 Gsensor_init_flag = 1; return 1; } @@ -742,7 +755,7 @@ STATIC mp_obj_t mp_SC7A20_register_usr_cb(mp_obj_t self_in, mp_obj_t callback) STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_init_SC7A20_obj, mp_SC7A20_init);//初始化 STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_deinit_SC7A20_obj, mp_SC7A20_deinit);// STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_activate_SC7A20_obj, mp_activate_SC7A20);// -//STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_SC7A20_poll_obj, mp_SC7A20_poll);// +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_SC7A20_poll_obj, mp_SC7A20_poll);// STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_SC7A20_get_status_obj, mp_SC7A20_get_status);// STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_SC7A20_clean_status_obj, mp_SC7A20_clean_status);// @@ -754,7 +767,7 @@ STATIC const mp_rom_map_elem_t SC7A20_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&mp_init_SC7A20_obj) }, { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&mp_deinit_SC7A20_obj) }, { MP_ROM_QSTR(MP_QSTR_activate), MP_ROM_PTR(&mp_activate_SC7A20_obj) }, - //{ MP_ROM_QSTR(MP_QSTR_poll), MP_ROM_PTR(&mp_SC7A20_poll_obj) }, + { MP_ROM_QSTR(MP_QSTR_poll), MP_ROM_PTR(&mp_SC7A20_poll_obj) }, { MP_ROM_QSTR(MP_QSTR_get_status), MP_ROM_PTR(&mp_SC7A20_get_status_obj) }, { MP_ROM_QSTR(MP_QSTR_clean_status), MP_ROM_PTR(&mp_SC7A20_clean_status_obj) }, diff --git a/2.sdk/Helios_SDK/services/microPython/ports/quectel/core/source/modHsensor.c b/2.sdk/Helios_SDK/services/microPython/ports/quectel/core/source/modHsensor.c index 41238909..763725ab 100644 --- a/2.sdk/Helios_SDK/services/microPython/ports/quectel/core/source/modHsensor.c +++ b/2.sdk/Helios_SDK/services/microPython/ports/quectel/core/source/modHsensor.c @@ -76,7 +76,7 @@ void sensor_thread_entry(void * argv) } Helios_Thread_t sensor_thread_id = 0; void sensor_thread_entry(void * argv); -Helios_ThreadAttr ThreadAttr = { +Helios_ThreadAttr HealthSensor = { .name = "HealthSensor", .stack_size = 1024*20, .priority = 100, diff --git a/2.sdk/Helios_SDK/services/microPython/ports/quectel/core/source/modHsensor_GH3018.c b/2.sdk/Helios_SDK/services/microPython/ports/quectel/core/source/modHsensor_GH3018.c index a79510cb..1125e6fb 100644 --- a/2.sdk/Helios_SDK/services/microPython/ports/quectel/core/source/modHsensor_GH3018.c +++ b/2.sdk/Helios_SDK/services/microPython/ports/quectel/core/source/modHsensor_GH3018.c @@ -36,7 +36,7 @@ #define GH3018_LOG(msg, ...) custom_log("GH3018", msg, ##__VA_ARGS__) extern void sensor_thread_entry(void * argv); -extern Helios_ThreadAttr ThreadAttr; +extern Helios_ThreadAttr HealthSensor; extern Helios_Thread_t sensor_thread_id ; ////////////////////////////////////////////////////////////////////////////// typedef struct _GH3018_obj_t @@ -298,7 +298,7 @@ mp_obj_t mp_GH3018_init(mp_obj_t self_in) if(sensor_thread_id == 0) { GH3018_LOG("mp_GH3018_open_heart Helios_Thread_Create\r\n"); - sensor_thread_id = Helios_Thread_Create(&ThreadAttr); + sensor_thread_id = Helios_Thread_Create(&HealthSensor); } diff --git a/2.sdk/Helios_SDK/services/microPython/ports/quectel/core/source/modHsensor_HX3918.c b/2.sdk/Helios_SDK/services/microPython/ports/quectel/core/source/modHsensor_HX3918.c index c28ceec4..2ce7d989 100644 --- a/2.sdk/Helios_SDK/services/microPython/ports/quectel/core/source/modHsensor_HX3918.c +++ b/2.sdk/Helios_SDK/services/microPython/ports/quectel/core/source/modHsensor_HX3918.c @@ -37,7 +37,7 @@ #include "hx3918_factory_test.h" #include "autoconf.h" extern void sensor_thread_entry(void * argv); -extern Helios_ThreadAttr ThreadAttr; +extern Helios_ThreadAttr HealthSensor; extern Helios_Thread_t sensor_thread_id ; //#define HX3918_LOG(msg, ...) custom_log("HX3918", msg, ##__VA_ARGS__) ////////////////////////////////////////////////////////////////////////////// @@ -82,7 +82,7 @@ extern signed char SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO(void); extern unsigned char Gsensor_init_flag ; void HX3918_restart(void); #endif -int ir_wear = 0;//红外佩戴状态 +int ir_wear = 1;//红外佩戴状态 int cap_wear = 1;//电容佩戴状态 char is_open_sar = 0;//是否打开sar检测 int wear_time = 0; @@ -169,7 +169,7 @@ void HX3918_thread_do(void) // } #if CONFIG_SC7A20 - if(ir_wear == 1 && cap_wear==1) + //if(ir_wear == 1 && cap_wear==1) { SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO(); @@ -345,7 +345,7 @@ mp_obj_t mp_HX3918_init(mp_obj_t self_in) if(sensor_thread_id == 0) { HX3918_LOG("mp_HX3918_open_heart Helios_Thread_Create\r\n"); - sensor_thread_id = Helios_Thread_Create(&ThreadAttr); + sensor_thread_id = Helios_Thread_Create(&HealthSensor); } diff --git a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/EventMesh.py b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/EventMesh.py index a2c05ddd..4efabf3b 100644 --- a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/EventMesh.py +++ b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/EventMesh.py @@ -93,7 +93,7 @@ def callback_wrapper(callback):#按键回调 import utime import uos -debug_Log = 0 +debug_Log = 1 def debug_log(*data): if debug_Log != 0 : print(data) diff --git a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/alarm.py b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/alarm.py deleted file mode 100644 index ee398af8..00000000 --- a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/alarm.py +++ /dev/null @@ -1,812 +0,0 @@ -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() -EventMesh.debug_log("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("U:/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() -EventMesh.debug_log("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() -EventMesh.debug_log("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() -EventMesh.debug_log("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}] -#用于显示闹钟列表不包含开关机信息 - - -#闹钟弹窗 -popup_alarm_screen = lv.obj() -EventMesh.debug_log("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("U:/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 - - def initialization(self): - self.alarm_count = 0 - self.timer.start(3*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): - self.alarm_count+=1 - if self.alarm_count > 10: - self.alarm_count = 0 - self.aud.stop() - self.timer.stop() - EventMesh.publish("load_screen", {"screen": "main_menu"}) - return - self.aud.play(1, 1, 'U:/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("load_screen", {"screen": "main_menu"}) - - def done_right_to_left(self): - self.close_timer() - EventMesh.publish("load_screen", {"screen": "main_menu"}) - - def done_bottom_to_top(self): - self.close_timer() - EventMesh.publish("load_screen", {"screen": "main_menu"}) - - def done_top_to_bottom(self): - self.close_timer() - EventMesh.publish("load_screen", {"screen": "main_menu"}) - - def done_return(self): - self.close_timer() - EventMesh.publish("load_screen", {"screen": "main_menu"}) - - def done_click(self): - self.close_timer() - EventMesh.publish("load_screen", {"screen": "main_menu"}) - - def btn1_release(self): - self.close_timer() - EventMesh.publish("load_screen", {"screen": "main_menu"}) - - def btn8_press(self): - self.close_timer() - EventMesh.publish("load_screen", {"screen": "main_menu"}) - -#闹钟列表 -class ClkListScreen(Screen): - NAME = "clk_list" - def __init__(self): - super().__init__() - self.meta = clk_list_screen - self.clock_list = [] - # clk_list_add_btn.add_event_cb(lambda e: self.add_alarm_btn(e), - # lv.EVENT.PRESSED, None) - self.weekdays_list = ["日","一","二","三","四","五","六"] - - self.alarm_show_list = lv.obj(clk_list_screen) - self.timer=osTimer() - - - def initialization(self): - EventMesh.publish("read_alarminjson") - EventMesh.publish("set_rtc_alarm") - EventMesh.debug_log("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): - global alarm_list - self.clock_list = alarm_list - IFEXIST = ql_fs.path_exists("/usr/static/storage_file/alarm_msg.json") - if IFEXIST == True: - if self.clock_list: - # EventMesh.debug_log("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) - #EventMesh.debug_log("菜单的孩子个数:",clk_list_screen1.get_child_cnt()) - num = 0 - count = 0 - for i ,each in enumerate(self.clock_list): - num = each["idx"] - if count >= 3: - break - repeart = each["repeart"] - if repeart == 10: - continue - _btn = lv.btn(self.alarm_show_list) - _btn.set_size(230,75) - _btn.set_pos(8,79*count) - _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) - - - # EventMesh.debug_log("------刷新闹钟列表噢:{} num:{}",each,num) - _btn_label1 = lv.label(_btn) - _btn_label1.set_pos(50, 0) - _btn_label1.set_size(0, 0) - _btn_label1.set_text(str(num)) - - _btn_label2 = lv.label(_btn) - _btn_label2.set_pos(8, 10) - _btn_label2.set_size(97, 40) - _btn_label2.set_text("%02d" % each["hour"] + ":"+"%02d" % each["minute"]) - # _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) - _btn_label2.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0) - - _new_list = sorted(each["days"]) - repeart = each["repeart"] - _output = [self.weekdays_list[x] for x in _new_list] - _btn_label3 = lv.label(_btn) - _btn_label3.set_pos(5, 44) - _btn_label3.set_size(200, 40) - EventMesh.debug_log("_new_list:{} repeart:{}".format(_new_list,repeart)) - if repeart == 1: - _btn_label3.set_text("一次") - elif repeart == 2: - _btn_label3.set_text("每天") - else: - _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) - _btn_label3.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0) - - # _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.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()) - EventMesh.debug_log("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 - EventMesh.debug_log("!!!!!!!!!!!!!!!!!------") - 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] - # EventMesh.debug_log("修改闹钟开关:",self.clock_list[idx]) - # clock_info["idx"] = idx - # if obj.has_state(lv.STATE.CHECKED): - # EventMesh.debug_log("ON ~~~") - # clock_info["enabled"] = True - # else: - # EventMesh.debug_log("OFF ~~~") - # clock_info["enabled"] = False - # EventMesh.publish("push_clock_info", clock_info) - # EventMesh.publish("set_rtc_alarm") - - # EventMesh.debug_log("sw_event_cb ~~~") - - def done_return(self): - EventMesh.publish("load_screen", {"screen": "toolbox"}) - - def btn1_release(self): - EventMesh.publish("load_screen", {"screen": "toolbox"}) - - 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): - EventMesh.debug_log("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"}) - -class CLKTimeScreen(Screen): - NAME = "clk_time" - - def __init__(self): - super().__init__() - self.meta = clk_time_screen - # alarm_ok.add_event_cb(lambda e: self.handler(e), lv.EVENT.PRESSED, None) - - def initialization(self): - roll_1_v = self.meta_info["hour"] - roll_2_v = self.meta_info["minute"] - - clk_time_roller_1.set_selected(int(roll_1_v), lv.ANIM.ON) - clk_time_roller_2.set_selected(int(roll_2_v), lv.ANIM.ON) - - def handler(self, e): - option_1 = " " * 10 - option_2 = " " * 10 - clk_time_roller_2.get_selected_str(option_2, len(option_2)) - clk_time_roller_1.get_selected_str(option_1, len(option_1)) - option_1_strip = option_1.strip()[:2] - option_2_strip = option_2.strip()[:2] - EventMesh.debug_log("option_1_strip = {} option_2_strip = {}".format(option_1_strip, option_2_strip)) - self.meta_info["hour"] = int(option_1_strip) - self.meta_info["minute"] = int(option_2_strip) - EventMesh.publish("push_clock_info", self.meta_info) - - EventMesh.publish("load_screen", {"screen": "clk_list"}) - - 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"}) - -class ClkPeriod(Screen): - NAME = "clk_period" - - def __init__(self): - super().__init__() - self.meta = clk_repeat_screen - self.choice_list=[] - self.alarm_info={} - self.clk_switch_list = [ - clk_repeat_switch6, - clk_repeat_switch, - clk_repeat_switch1, - clk_repeat_switch2, - clk_repeat_switch3, - clk_repeat_switch4, - clk_repeat_switch5, - - ] - - clk_repeat_switch.add_event_cb(lambda e: EventMesh.callback_wrapper(self.save_choice(e,1)), lv.EVENT.VALUE_CHANGED, None) - clk_repeat_switch1.add_event_cb(lambda e: EventMesh.callback_wrapper(self.save_choice(e,2)), lv.EVENT.VALUE_CHANGED, None) - clk_repeat_switch2.add_event_cb(lambda e: EventMesh.callback_wrapper(self.save_choice(e,3)), lv.EVENT.VALUE_CHANGED, None) - clk_repeat_switch3.add_event_cb(lambda e: EventMesh.callback_wrapper(self.save_choice(e,4)), lv.EVENT.VALUE_CHANGED, None) - clk_repeat_switch4.add_event_cb(lambda e: EventMesh.callback_wrapper(self.save_choice(e,5)), lv.EVENT.VALUE_CHANGED, None) - clk_repeat_switch5.add_event_cb(lambda e: EventMesh.callback_wrapper(self.save_choice(e,6)), lv.EVENT.VALUE_CHANGED, None) - clk_repeat_switch6.add_event_cb(lambda e: EventMesh.callback_wrapper(self.save_choice(e,0)), lv.EVENT.VALUE_CHANGED, None) - - def initialization(self): - self.choice_list = self.meta_info["days"] - self.alarm_info = self.meta_info - EventMesh.debug_log("初始化:{},{}".format(self.alarm_info,self.choice_list)) - - - for i in range(0,6): - if i in self.choice_list: - self.clk_switch_list[i].add_state(lv.STATE.CHECKED) - - else: - self.clk_switch_list[i].clear_state(lv.STATE.CHECKED) - - - def save_choice(self,e,i): - if i in self.choice_list: - self.clk_switch_list[i].clear_state(lv.STATE.CHECKED) - self.choice_list.remove(i) - EventMesh.debug_log("here1-----",self.choice_list,i) - - else: - self.clk_switch_list[i].add_state(lv.STATE.CHECKED) - self.choice_list.append(i) - EventMesh.debug_log("here2-----",self.choice_list,i) - - EventMesh.debug_log("here-----",self.choice_list) - self.alarm_info["days"] = self.choice_list - - EventMesh.debug_log("编辑星期:{}".format(self.alarm_info)) - if self.alarm_info["days"] == []: - self.alarm_info["repeart"] = 1 - else: - num = self.alarm_info["days"] - if len(num) >= 7: - self.alarm_info["repeart"] = 2 - else: - self.alarm_info["repeart"] = 3 - - EventMesh.publish("push_clock_info", self.alarm_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"}) - diff --git a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/btn_device_ec800m.py b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/btn_device_ec800m.py index 6b4477d2..4da1ffe6 100644 --- a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/btn_device_ec800m.py +++ b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/btn_device_ec800m.py @@ -87,7 +87,7 @@ class intervManager(Abstract): self.record_test = audio.Record() self.record_test.gain(4,12) - self.wechat_record_flag = 0 + self.timeSecond = 0 self.wechat_show = 0 self.sort_new = {} @@ -191,7 +191,7 @@ class intervManager(Abstract): EventMesh.subscribe("sos_short_press", self.sos_short_press)#sos短按事件 - EventMesh.subscribe("get_wechat_record_flag", self.get_wechat_record_flag) #获取是否在录音表示 + def sos_short_press(self,args,msg): EventMesh.publish("interup_call_event")#如果在电话中强制挂断电话 @@ -1458,9 +1458,7 @@ class intervManager(Abstract): def get_wechat_time(self, event, msg): return [self.press_btn,self.timeSecond] - - def get_wechat_record_flag(self, event, msg): - return self.wechat_record_flag + def start_wechat_record(self, event, msg): #开始录音相关配置 if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#未联网不需要录音 @@ -1482,7 +1480,6 @@ class intervManager(Abstract): self.wechat_num = 0 self.wechat_num += 1 self.wechat_show = self.wechat_num - self.wechat_record_flag = 1 self.record_test.start("/usr/static/storage_file/{}.amr".format(self.wechat_show),16) else: self.timeSecond = 0 @@ -1498,6 +1495,7 @@ class intervManager(Abstract): EventMesh.publish("set_led_time_arg",[1,1,0,led_mode.FLASH_LIGHT_GREEN,4,2,led_mode.OTHER_MEASURE_MODE])#測量成功 # EventMesh.publish("set_led_time_arg",[0,1000,1,led_mode.LONG_LIGHT_GREEN,led_mode.OPEN_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#測量成功 self.countdown_old = 0 + date_tmp = utime.localtime() time_tmp = utime.mktime(date_tmp) @@ -1512,9 +1510,12 @@ class intervManager(Abstract): self.wechat_recode_list["num"] = self.wechat_show EventMesh.debug_log("self.wechat_recode_list :{}".format(self.wechat_recode_list)) + + with open("/usr/static/storage_file/wechat_record.json","w+",encoding="utf-8") as fd: ujson.dump(self.wechat_recode_list,fd) - + # EventMesh.debug_log("send wechat data!!!!!!!!!!!!!!!!!!!!!") + check_txt = ql_fs.path_exists("/usr/static/storage_file/{}.amr".format(self.wechat_show)) if check_txt == True : path = "/usr/static/storage_file/{}.amr".format(self.wechat_show) @@ -1522,8 +1523,9 @@ class intervManager(Abstract): buf = bytearray(ql_fs.path_getsize(path)) fd.readinto(buf) senddata = [self.countdown_old,buf] - EventMesh.publish(constants.PROTOCOL.TKS_SEND,senddata) - self.wechat_record_flag = 0 + EventMesh.publish(constants.PROTOCOL.TK_SEND,senddata) + + # check_txt = ql_fs.path_exists("/usr/static/storage_file/{}.amr".format(self.wechat_show)) # if check_txt == True : # path = "/usr/static/storage_file/{}.amr".format(self.wechat_show) @@ -1777,12 +1779,24 @@ class BtnDevice(Abstract): self.pwkey_press = 0 self.pwKey_press_count = 0 self.led_state = 0 + # if EventMesh.publish("get_sim_Status") != 1: + # EventMesh.publish("open_power_on", 2)# + # else: + EventMesh.publish("open_power_on", 3)# + return + + if self.pwkey_count >= 3*10 : if EventMesh.publish("get_sim_Status") != 1: + EventMesh.debug_log("长3秒关机") + EventMesh.publish("stop_led_timer")#设置参数 + self.pwkey_timer.stop() + self.pwkey_count = 0 + self.pwkey_press = 0 + self.pwKey_press_count = 0 + self.led_state = 0 EventMesh.publish("open_power_on", 2)# - else: - EventMesh.publish("open_power_on", 3)# - return - + + if self.GPIO26_status == 1:#松开 if self.pwkey_count >= 1: #防抖100ms # EventMesh.debug_log("self.GPIO26_status == 1") diff --git a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/constants.py b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/constants.py index 7c6828f5..7d1a85ea 100644 --- a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/constants.py +++ b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/constants.py @@ -14,6 +14,9 @@ class PROTOCOL: CR_SEND = "CR_SEND" CR_RECV = "CR_RECV" + AL_SEND = "AL_SEND" + AL_RECV = "AL_RECV" + FIND_SEND = "FIND_SEND" FIND_RECV = "FIND_RECV" @@ -90,6 +93,15 @@ class PROTOCOL: 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" + class EVENT: CHANNEL_SOCKET_SEND = "CHANNEL_SOCKET_SEND" diff --git a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/main_init.py b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/main_init.py index ffc1bade..e6072c42 100644 --- a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/main_init.py +++ b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/main_init.py @@ -73,10 +73,10 @@ def main_init(): EventMesh.debug_log("init6:{}".format(utime.localtime())) - from protocol import MESSAGE_ProtoCol,TK_ProtoCol,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,Time_ProtoCol,TKS_ProtoCol,\ - ProtoColResolver,SILENCETIME2_ProtoCol,PHL_ProtoCol,MONITOR_ProtoCol,bootoff_ProtoCol,WDSTART_ProtoCol,LOWBAT_ProtoCol,sosHome_dial_ProtoCol,SockManager,NetManager - + # from protocol import MESSAGE_ProtoCol,TK_ProtoCol,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,Time_ProtoCol,TKS_ProtoCol,FALLDOWN_ProtoCol,\ + # ProtoColResolver,SILENCETIME2_ProtoCol,PHL_ProtoCol,MONITOR_ProtoCol,bootoff_ProtoCol,WDSTART_ProtoCol,LOWBAT_ProtoCol,sosHome_dial_ProtoCol,SockManager,NetManager + import protocol import mgr as mgr EventMesh.debug_log("init7:{}".format(utime.localtime())) @@ -117,7 +117,7 @@ def main_init(): app.append_manager(ConfigStoreManager()) - app.append_manager(NetManager()) + app.append_manager(protocol.NetManager()) app.append_manager(LocationManager()) app.append_manager(AddrBookManager()) app.append_manager(mgr.MsgManager()) @@ -147,38 +147,42 @@ def main_init(): EventMesh.debug_log("init21:{}".format(utime.localtime())) EventMesh.debug_log("init11:{}".format(utime.localtime())) - pcr = ProtoColResolver() - pcr.add_support(LK_ProtoCol()) - pcr.add_support(PING_ProtoCol()) - pcr.add_support(KA_ProtoCol()) - pcr.add_support(UD_ProtoCol()) - pcr.add_support(CR_ProtoCol()) - pcr.add_support(FIND_ProtoCol()) - pcr.add_support(POWEROFF_ProtoCol()) - pcr.add_support(PHL_ProtoCol()) - pcr.add_support(TK_ProtoCol()) - pcr.add_support(TKS_ProtoCol()) - pcr.add_support(MESSAGE_ProtoCol()) - pcr.add_support(WT_ProtoCol()) - pcr.add_support(REMIND_ProtoCol()) - pcr.add_support(HRSTART_ProtoCol()) - pcr.add_support(HEART_ProtoCol()) - pcr.add_support(OXYGEN_ProtoCol()) - pcr.add_support(OXYGEN_One_ProtoCol()) - pcr.add_support(TEMP_ProtoCol()) - pcr.add_support(DLT_ProtoCol()) - pcr.add_support(UPLOAD_ProtoCol()) - pcr.add_support(MONITOR_ProtoCol()) - # pcr.add_support(CENTER_ProtoCol()) - pcr.add_support(CENTER_ProtoCol()) - pcr.add_support(bootoff_ProtoCol()) - pcr.add_support(WDSTART_ProtoCol()) - pcr.add_support(LOWBAT_ProtoCol()) - pcr.add_support(sosHome_dial_ProtoCol()) - pcr.add_support(Time_ProtoCol()) - pcr.add_support(SILENCETIME2_ProtoCol()) - - sm = SockManager() + 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()) + sm = protocol.SockManager() sm.add_support_resolver(pcr) app.append_manager(sm) EventMesh.debug_log("init11.0:{}".format(utime.localtime())) diff --git a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/mgr.py b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/mgr.py index 43b2390d..92d77d03 100644 --- a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/mgr.py +++ b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/mgr.py @@ -745,7 +745,8 @@ class DeviceInfoManager(Abstract): EventMesh.debug_log("DeviceInfoManager:3") self.i2c0 = I2C(I2C.I2C0, I2C.FAST_MODE) self.stop_temp( None, None) - + self.dev_state = 0 + self.wear = 1 def post_processor_after_instantiation(self): EventMesh.debug_log("post_processor_after_instantiation:1") """订阅此类所有的事件到 EventMesh中""" @@ -793,6 +794,9 @@ class DeviceInfoManager(Abstract): EventMesh.subscribe(constants.EVENT.STOP_TEMP, self.stop_temp) EventMesh.subscribe(constants.EVENT.GET_TEMP, self.get_temp) EventMesh.subscribe("get_boot_time_count", self.get_boot_time_count) + EventMesh.subscribe("get_dev_state", self.get_dev_state) + EventMesh.subscribe("set_dev_state", self.set_dev_state) + EventMesh.debug_log("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) @@ -823,9 +827,18 @@ class DeviceInfoManager(Abstract): def gsensor_cb(self, para): EventMesh.debug_log("gsensor_cb:{}".format(para)) flip_sw = EventMesh.publish("get_storage_config","flip_sw") - + fall_sw = EventMesh.publish("get_storage_config","fall_sw") if para == 0: #跌倒报警 pass + if fall_sw == "1": + EventMesh.publish("OPEN_FIND_WATCH") + dev_state = EventMesh.publish("get_dev_state") + + tmp = 1 << 21 + dev_state = dev_state|tmp #第21位=1 + EventMesh.publish("set_dev_state",dev_state) + EventMesh.publish(constants.EVENT.START_LOCATION,[constants.PROTOCOL.AL_SEND,dev_state]) #开始AL定位 + pass #EventMesh.publish("load_screen", {"screen": "FIND"}) elif para == 1: #抬腕 @@ -838,6 +851,12 @@ class DeviceInfoManager(Abstract): # EventMesh.publish(constants.EVENT.SYSTEM_SLEEP) def get_boot_time_count(self, event, msg): return self.boot_time_count + + def get_dev_state(self, event, msg): + return self.dev_state + def set_dev_state(self, event, msg): + self.dev_state = msg + def publish_event_cb(self, *args, **kwargs): if self.boot_time_count < 50000000: self.boot_time_count += 10 @@ -1039,8 +1058,31 @@ class DeviceInfoManager(Abstract): if msg_nums >= sms_max-1: EventMesh.publish("remove_all_sms_cb")# - """定时测量心率,血氧,体温""" + #佩戴检测 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 + # else : + # pass + + # tmp = 1 << 20 + # dev_state = dev_state|tmp #第20位=1 + # tmp = 1 << 3 + # dev_state = dev_state|tmp #第三位=1 + EventMesh.debug_log("佩戴检测:{}".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") self.get_spo2_state = EventMesh.publish("get_spo2_state") get_temp_time = EventMesh.publish("get_temp_time") @@ -2177,108 +2219,120 @@ class LocationManager(Abstract): self.location_check_data_timer_count = self.location_check_data_timer_count+1 def Location_send(self, msg) : - #EventMesh.debug_log("Location_send1") + EventMesh.debug_log("Location_send1") if self.location_queue.empty() == True: return - 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 = "00000000" - #基站数据 - 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_send2") while True: if self.location_queue.empty() == False: TYPE = self.location_queue.get() - #EventMesh.debug_log("Location_send3:{}".format(TYPE)) - EventMesh.publish(TYPE,send_data) + 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]) + + EventMesh.debug_log("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 @@ -2476,23 +2530,15 @@ class LocationManager(Abstract): # 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.wifi_data != [] and self.cell_data != [] and self.location_timer_count > 20: #超过40秒且信号大于30的不足3个 - EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位 + 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)#关闭定位 + EventMesh.debug_log("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) - - #EventMesh.debug_log("location_timer_count:{}".format(self.location_timer_count)) + + except Exception as e: usys.print_exception(e) @@ -3444,8 +3490,8 @@ class deleteSmsManager(Abstract):#删除信息 sms.deleteMsg(1,4) #闹钟信息 -alarm_list = [{'hour': 6, 'repeart': 10, 'idx': 0, 'enabled': 1, 'days': [0,1,2,3,4,5,6], 'minute': 0}, - {'hour': 23, 'repeart': 10, 'idx': 1, 'enabled': 1, 'days': [0,1,2,3,4,5,6], 'minute': 0}, +alarm_list = [ {'hour': 6, 'repeart': 10, 'idx': 0, 'enabled': 1, 'days': [0,1,2,3,4,5,6], 'minute': 0}, + {'hour': 10, 'repeart': 10, 'idx': 1, 'enabled': 1, 'days': [0,1,2,3,4,5,6], 'minute': 10}, {'hour': 16, 'repeart': 10, 'idx': 2, 'enabled': 0, 'days': [], 'minute': 39}, {'hour': 16, 'repeart': 10, 'idx': 3, 'enabled': 0, 'days': [], 'minute': 39}, {'hour': 16, 'repeart': 10, 'idx': 4, 'enabled': 0, 'days': [], 'minute': 39}] @@ -3643,7 +3689,7 @@ class ClockManager(Abstract): EventMesh.debug_log("关机距离下一次响铃的的分钟数:", interval_minute,next_minute) else:#8:00 9:00 #7*60*24 7天一个周期 7*60*24 - - interval_minute = next_minute + 24*60 + interval_minute = next_minute + (24*60-current_minute) EventMesh.debug_log("关机08888距离下一次响铃的的分钟数:", interval_minute,next_minute) #反向获取时间戳 @@ -3683,7 +3729,8 @@ class ClockManager(Abstract): EventMesh.publish("open_power_on", 5)#静音关机 return else: - EventMesh.debug_log("结束111开机时设置rtc的到期时间失败:", data_e) + EventMesh.debug_log("充电关机失败:", data_e) + #self.rtc.datetime([2023, 12, 1, 5, 5, 59, 30, 0]) return EventMesh.publish("set_rtc_alarm") diff --git a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/protocol.py b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/protocol.py index 412d6d9c..e78fbef7 100644 --- a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/protocol.py +++ b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/protocol.py @@ -34,10 +34,7 @@ def server_init(server_type = None): d_PID = "SZKW" if server_type == 1: pass - # server_addr = "api.xcloudtech.com" - # server_port = 9000 - # md5_key = "bZld0ALsZTt15tKEZhOlLPgbsO75BLTP" - # PID = "SZKW" + elif server_type == 2: d_server_addr = "8.134.110.49" @@ -67,6 +64,10 @@ def server_init(server_type = None): 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 + return [d_server_addr,d_server_port,d_md5_key,d_PID] from queue import Queue def unicode_to_utf8(src): @@ -255,7 +256,7 @@ class SockManager(Abstract): utime.sleep(1) def send(self, topic, msg): - # EventMesh.debug_log("TCP:send data:{}".format(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") @@ -281,7 +282,7 @@ class SockManager(Abstract): data = data + r EventMesh.debug_log("TCP recv: data:len:{}".format(len(data))) - #EventMesh.debug_log("TCP recv: data:{}".format(data)) + EventMesh.debug_log("TCP recv: data:{}".format(data)) if data[-1] != 0x5d and len(data)<20*1024: #']': continue self.connect_tmp = 1 #有数据,就认为是连接状态 @@ -378,8 +379,10 @@ class ProtoCol(Abstract): 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) @@ -543,6 +546,7 @@ 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] @@ -567,7 +571,7 @@ class UD_ProtoCol(ProtoCol): # # #如果没有天气数据,则获取天气数据 # if wt_data != None or wt_data[0] == None : # - + EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data) def recv(self, event, msg): @@ -596,7 +600,57 @@ class CR_ProtoCol(ProtoCol): 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 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 = self.PID+"*%s*%04X*%s"%(self.imei,send_len,send_data) + MD5_head_data = self.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:%s"%(data)) + # 通过socket发送到服务器端 + EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data) + 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定位 + EventMesh.debug_log("报警数据上报:recv:%s"%(msg)) + # + 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" @@ -1331,13 +1385,13 @@ class LOWBAT_ProtoCol(ProtoCol): EventMesh.publish("set_low_bat_btn",on_bt) EventMesh.publish(constants.PROTOCOL.LOWBAT_SEND) -# 低电提醒 -#[XT*334588000000156*0008*LOWBAT,1] +# 设置系统时间 +# class Time_ProtoCol(ProtoCol): """设置系统时间""" TYPE = "Time" def send(self, event, msg): - # [XT*334588000000156*0006*LOWBAT] + # send_data = self.PID+"*%s*0004*Time"%(self.imei) MD5_SIGN = self.pack_MD5_head(send_data) data = "[%s%s]"%(str(MD5_SIGN),send_data) @@ -1364,7 +1418,7 @@ class Time_ProtoCol(ProtoCol): 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) @@ -1436,6 +1490,7 @@ class KEYBRD_ProtoCol(ProtoCol): # b'[SZKW*867387060319166*000A*KEYBRD]' # EventMesh.debug_log("KEYBRD!!!!!!!!!!!!!",msg) EventMesh.publish(constants.PROTOCOL.KEYBRD_SEND) + class TK_ProtoCol(ProtoCol): """微聊""" TYPE = "TK" @@ -1753,6 +1808,96 @@ class MESSAGE_ProtoCol(ProtoCol): 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 = "SZKW*%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 = "SZKW*%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 = "SZKW*%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 class ProtoColResolver(object): def __init__(self): diff --git a/2.sdk/project/D10/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/images/firmware_base_release_pack.zip b/2.sdk/project/D10/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/images/firmware_base_release_pack.zip index fc5cf21f..d97b83d7 100644 Binary files a/2.sdk/project/D10/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/images/firmware_base_release_pack.zip and b/2.sdk/project/D10/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/images/firmware_base_release_pack.zip differ