From fe91b5b2c91269a2bf0c1ac66695ba0198779022 Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Mon, 17 Jun 2024 16:40:11 +0800 Subject: [PATCH] =?utf8?q?=E6=B7=BB=E5=8A=A0=E5=BC=80=E6=9C=BA=E5=8A=A8?= =?utf8?q?=E7=94=BB=EF=BC=8C=E4=BC=98=E5=8C=96=E8=93=9D=E7=89=99=E4=BA=A7?= =?utf8?q?=E6=B5=8B=EF=BC=8C=E4=BC=98=E5=8C=96=E4=B9=85=E5=9D=90=E6=8F=90?= =?utf8?q?=E9=86=92=E8=AE=BE=E7=BD=AE=EF=BC=8C=E6=B7=BB=E5=8A=A0efuse?= =?utf8?q?=E8=AF=BB=E5=86=99=E6=B5=8B=E8=AF=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../wearable/ohos_startup/ohosfwk_startup.c | 3 + .../factorytest_protocol.c | 194 ++++++------- .../factorytest_protocol.h | 5 +- .../drivers/peripheral/cywee/src/main_dml.c | 10 +- .../drivers/peripheral/ppg/hx3695/hx3695.c | 26 +- .../peripheral/ppg/service/ppg_service.cpp | 2 +- .../drivers/peripheral/utils/custom_utils.c | 37 ++- .../drivers/peripheral/utils/custom_utils.h | 4 +- .../peripheral/utils/custom_utils_at_cmd.c | 63 ++++- .../service/src/graphic_service_wrapper.cpp | 263 ++++++++++++++++-- 10 files changed, 448 insertions(+), 159 deletions(-) diff --git a/code/sdk/application/wearable/ohos_startup/ohosfwk_startup.c b/code/sdk/application/wearable/ohos_startup/ohosfwk_startup.c index f2e077caa..4160dcc13 100755 --- a/code/sdk/application/wearable/ohos_startup/ohosfwk_startup.c +++ b/code/sdk/application/wearable/ohos_startup/ohosfwk_startup.c @@ -61,13 +61,16 @@ void ohos_startup() #if defined(CONFIG_OTA_UPDATE_SUPPORT) && defined(ENABLE_UIKIT) if (upg_check_upgrade_need_upgrade()) { + boot_animation_init(); ShowGraphicOTALogo(); }else{ + boot_animation_init(); ShowGraphicLogo(); } #else #ifdef ENABLE_UIKIT + boot_animation_init(); ShowGraphicLogo(); #endif diff --git a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c index ce293ef40..2d42caf8e 100644 --- a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c +++ b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c @@ -65,18 +65,21 @@ static int factorytest_mode_flag = 0; ble_aging_t aging_t; -static osTimerId_t g_ble_vibrator_timer; +static osTimerId_t g_ble_vibrator_timer = NULL; -static osTimerId_t g_ble_acc_timer; +static osTimerId_t g_ble_acc_timer = NULL; -static osTimerId_t g_ble_hrs_timer; -static osTimerId_t g_ble_spo2_timer; +static osTimerId_t g_ble_hrs_timer = NULL; +static osTimerId_t g_ble_spo2_timer = NULL; -static osTimerId_t g_ble_microhone_timer; -static osTimerId_t g_ble_spk_timer; +static osTimerId_t g_ble_microhone_timer = NULL; +static osTimerId_t g_ble_spk_timer = NULL; static uint32_t aging_time = 0; +static uint8_t pwr_button_result = 0; +static uint8_t func_button_result = 1; + static int CRC16_XMODEM(uint8_t *bytes,uint16_t length) { int crc = 0x0000; // initial value int polynomial = 0x1021; @@ -127,64 +130,28 @@ errcode_t factorytest_protocol_replymsg(uint8_t mode, uint8_t submode,uint8_t te static void pwr_button_callback_press(void) { - uint8_t send_data = 1; - - factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_KEY, - 0x02, - &send_data, - 1); + pwr_button_result = 1; } static void pwr_button_callback_click_2(void) { - uint8_t send_data = 3; - - factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_KEY, - 0x02, - &send_data, - 1); + pwr_button_result = 3; } static void pwr_button_callback_long_press_2s(void) { - uint8_t send_data = 2; - - factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_KEY, - 0x02, - &send_data, - 1); + pwr_button_result = 2; } static void func_button_callback_press(void) { - uint8_t send_data = 1; - - factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_KEY, - 0x03, - &send_data, - 1); + func_button_result = 1; } static void func_button_callback_click_2(void) { - uint8_t send_data = 3; - - factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_KEY, - 0x03, - &send_data, - 1); + func_button_result = 3; } static void func_button_callback_long_press_2s(void) { - uint8_t send_data = 2; - - factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_KEY, - 0x03, - &send_data, - 1); + func_button_result = 2; } void ble_vibrator_check_timer_callback(void) @@ -204,37 +171,37 @@ void ble_acc_check_timer_callback(void) 6); } - void ble_hrs_check_timer_callback(void) { uint8_t databuf[4] = {0}; int32_t ppg_buf; uint8_t i; - if(ble_hrs_flag == 1) + if(ble_hrs_flag != 1) + return; + else { - ble_hrs_flag = 0; osTimerStop(g_ble_hrs_timer); osTimerDelete(g_ble_hrs_timer); + ble_hrs_flag = 0; send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); - return; - } - if(ble_hrs_data > 10000) - { - ppg_buf = ble_hrs_data; + if(ble_hrs_data > 10000) + { + ppg_buf = ble_hrs_data; - databuf[0] = (uint8_t)((ppg_buf & 0xFF000000) >> 24); - databuf[1] = (uint8_t)((ppg_buf & 0x00FF0000) >> 16); - databuf[2] = (uint8_t)((ppg_buf & 0x0000FF00) >> 8); - databuf[3] = (uint8_t)((ppg_buf & 0x000000FF) >> 0); + databuf[0] = (uint8_t)((ppg_buf & 0xFF000000) >> 24); + databuf[1] = (uint8_t)((ppg_buf & 0x00FF0000) >> 16); + databuf[2] = (uint8_t)((ppg_buf & 0x0000FF00) >> 8); + databuf[3] = (uint8_t)((ppg_buf & 0x000000FF) >> 0); - PRINT("%2X %2X %2X %2X \r\n",databuf[0],databuf[1],databuf[2],databuf[3]); + PRINT("%2X %2X %2X %2X \r\n",databuf[0],databuf[1],databuf[2],databuf[3]); - factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_HRS, - 0x03, - databuf, - 4); + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_HRS, + 0x07, + databuf, + 4); + } } } @@ -244,37 +211,40 @@ void ble_spo2_check_timer_callback(void) uint8_t databuf[4] = {0}; int32_t red_buf; - if(ble_spo2_flag == 1) + if(ble_spo2_flag != 1) + return; + else { - ble_spo2_flag = 0; osTimerStop(g_ble_spo2_timer); osTimerDelete(g_ble_spo2_timer); + ble_spo2_flag = 0; send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_SPO2_TEST); - return; - } - if(ble_spo2_data > 10000) - { - red_buf = ble_spo2_data; + if(ble_spo2_data > 10000) + { + red_buf = ble_spo2_data; - databuf[0] = (uint8_t)((red_buf & 0xFF000000) >> 24); - databuf[1] = (uint8_t)((red_buf & 0x00FF0000) >> 16); - databuf[2] = (uint8_t)((red_buf & 0x0000FF00) >> 8); - databuf[3] = (uint8_t)((red_buf & 0x000000FF) >> 0); + databuf[0] = (uint8_t)((red_buf & 0xFF000000) >> 24); + databuf[1] = (uint8_t)((red_buf & 0x00FF0000) >> 16); + databuf[2] = (uint8_t)((red_buf & 0x0000FF00) >> 8); + databuf[3] = (uint8_t)((red_buf & 0x000000FF) >> 0); - PRINT("%2X %2X %2X %2X \r\n",databuf[0],databuf[1],databuf[2],databuf[3]); + PRINT("%2X %2X %2X %2X \r\n",databuf[0],databuf[1],databuf[2],databuf[3]); - factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_HRS, - 0x04, - databuf, - 4); + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_HRS, + 0x08, + databuf, + 4); + } } + } void ble_microhone_check_timer_callback(void) { + PRINT("ble_microhone_check_timer_callback \r\n"); uint8_t send_data= 0; uapi_microhone_switch(0); @@ -291,6 +261,7 @@ void ble_microhone_check_timer_callback(void) void ble_spk_check_timer_callback(void) { + PRINT("ble_spk_check_timer_callback \r\n"); uint8_t send_data= 0; uapi_check_spk(0); @@ -777,7 +748,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint 1); } else if(testitem == 0x02) { - //查询电源键测试结果 + //开启电源键测试 uint8_t send_data = 0; uapi_button_register_event_cb(pwr_button_callback_press, 1); @@ -791,7 +762,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint 1); } else if(testitem == 0x03) { - //查询功能键测试结果 + //开启功能键测试 uint8_t send_data = 0; uapi_button_register_event_cb(func_button_callback_press, 24); @@ -803,6 +774,26 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint 0x03, &send_data, 1); + } else if(testitem == 0x04) + { + //查询电源键测试结果 + uint8_t send_data = pwr_button_result; + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_KEY, + 0x04, + &send_data, + 1); + } else if(testitem == 0x05) + { + //查询功能键测试结果 + uint8_t send_data = func_button_result; + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_KEY, + 0x05, + &send_data, + 1); } break; @@ -1043,7 +1034,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint //LCD显示颜色 uint8_t send_data = 0x00; char *color_buf[5] ={"0Xffff0000","0xff00ff00","0xff0000ff","0xffffffff","0xff000000"}; - ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); + ScreenAlwaysOnCtr(1); switch (*data) { case 1: @@ -1239,14 +1230,14 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint 0x02, &send_data, 1); - } else if(testitem == 0x03) + } else if(testitem == 0x07) { //打开心率检测 g_ble_hrs_timer = osTimerNew((osTimerFunc_t)ble_hrs_check_timer_callback, osTimerPeriodic, NULL, NULL); osTimerStart(g_ble_hrs_timer,400); send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_PPG_TEST); - } else if(testitem == 0x04) + } else if(testitem == 0x08) { //打开血氧检测 g_ble_spo2_timer = osTimerNew((osTimerFunc_t)ble_spo2_check_timer_callback, osTimerPeriodic, NULL, NULL); @@ -1512,9 +1503,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint uint8_t send_data[2] = {0}; uint16_t len = sizeof(send_data); - cat1_getsignal(); - msleep(1000); - send_data[1]=uapi_dev_runtime_get_cat1_simstat(); + send_data[1] = uapi_dev_runtime_get_cat1_simstat(); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CAT1, 0x03, @@ -1525,9 +1514,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint //查看信号强度 uint8_t send_data[2] = {0}; - cat1_getsignal(); - msleep(1000); - send_data[1]=uapi_dev_runtime_get_cat1_signal(); + send_data[1] = uapi_dev_runtime_get_cat1_signal(); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CAT1, @@ -1537,19 +1524,18 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint } else if(testitem == 0x05) { //查看网络类型 - uint8_t send_data = 0x00; + uint8_t send_data[2] = {0}; cat1_getsignal(); msleep(1000); - - PRINT("send_buf : %s \r\n",uapi_dev_runtime_get_cat1_operator()); - + send_data[1] = uapi_dev_runtime_get_cat1_networtype(); + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CAT1, 0x05, - (uint8_t *)uapi_dev_runtime_get_cat1_operator(), - strlen(uapi_dev_runtime_get_cat1_operator())); + send_data, + 2); } else if(testitem == 0x06) { //拨打电话 @@ -1627,16 +1613,16 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint if(testitem == 0x01) { //开始录音 - g_ble_microhone_timer = osTimerNew((osTimerFunc_t)ble_microhone_check_timer_callback, osTimerPeriodic, NULL, NULL); - osTimerStart(g_ble_microhone_timer,5000); uapi_microhone_switch(1); + g_ble_microhone_timer = osTimerNew((osTimerFunc_t)ble_microhone_check_timer_callback, osTimerPeriodic, NULL, NULL); + osStatus_t ret = osTimerStart(g_ble_microhone_timer,5000); } else if(testitem == 0x02) { //播放录音 - g_ble_microhone_timer = osTimerNew((osTimerFunc_t)ble_spk_check_timer_callback, osTimerPeriodic, NULL, NULL); - osTimerStart(g_ble_spk_timer,5000); uapi_check_spk(1); + g_ble_spk_timer = osTimerNew((osTimerFunc_t)ble_spk_check_timer_callback, osTimerPeriodic, NULL, NULL); + osTimerStart(g_ble_spk_timer,5000); } break; diff --git a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.h b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.h index 47cc3f500..ab2474cf7 100644 --- a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.h +++ b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.h @@ -91,12 +91,13 @@ extern "C" { #define BLE_TEST_CMD_SOFT_TEST_SUB_MODE_EXTRAM 0x19 //软件测试 子模式ID CAT1 #define BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CAT1 0x1A +//软件测试 子模式ID SPEAKER +#define BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER 0x1B //软件测试 子模式ID 通讯录 #define BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CONTACTS 0x30 //软件测试 子模式ID 支付宝 #define BLE_TEST_CMD_SOFT_TEST_SUB_MODE_ALIPAY 0x31 -//软件测试 子模式ID SPEAKER -#define BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER 0x32 + /** * * encode cmd msg string and send to ble diff --git a/code/sdk/drivers/peripheral/cywee/src/main_dml.c b/code/sdk/drivers/peripheral/cywee/src/main_dml.c index cdda9ddbf..e2a704a11 100644 --- a/code/sdk/drivers/peripheral/cywee/src/main_dml.c +++ b/code/sdk/drivers/peripheral/cywee/src/main_dml.c @@ -509,9 +509,15 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { { CWM_OS_dbgPrintf("CUSTOM_OFFBODY_DETECT !!! \r\n"); if((int)sensorEVT->fData[2] == 1) - send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_WEAR_MODE_TEST); + { + set_keep_in_wear_det_mode(1); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_WEAR_MODE_TEST); + } else + { send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_WEAR_MODE_TEST); + set_keep_in_wear_det_mode(0); + } } if((int)sensorEVT->fData[1] == CUSTOM_ON_CHARGING) @@ -1001,7 +1007,7 @@ int cywee_main_dml(void) cywee_activity_mode_change(SPORT_ACTIVE_MODE_NORMAL); - cywee_inactivity_mode_change(INACTIVITY_MODE_SEDENTARY); + //cywee_inactivity_mode_change(INACTIVITY_MODE_SEDENTARY); //cywee_inactivity_mode_change(INACTIVITY_MODE_SLEEPING); diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c index 9e5320690..77cf75721 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c @@ -2724,14 +2724,6 @@ void hx3695_hrs_ppg_Int_handle(void) return; } - for(ii = 0; ii < hrs_s_dat.count; ii++) - { - if(PPG_buf[ii] > 10000) - { - ble_hrs_data = PPG_buf[ii]; - } - } - #ifndef GSEN_40MS_TIMMER //readFifoByHrsModule(); #endif @@ -2781,6 +2773,10 @@ void hx3695_hrs_ppg_Int_handle(void) gsen_fifo_y_send[ii] = gsensordata[ii].y * 2048; gsen_fifo_z_send[ii] = gsensordata[ii].z * 2048; } + + if(abs(PPG_buf[ii]) > 10000) + ble_hrs_data = abs(PPG_buf[ii]); + //PRINT("hxdata:%d/%d %d %d %.3f %.3f %.3f %d\r\n" ,1+ii,*count,PPG_buf[ii],ir_buf[0],gsen_fifo_x_send[ii],gsen_fifo_y_send[ii],gsen_fifo_z_send[ii],ppg_s_data.green_cur); PRINT("hxdata:%d/%d %d %d %d %d %d %d\r\n" ,1+ii,*count,PPG_buf[ii],ir_buf[0],gsen_fifo_x_send[ii],gsen_fifo_y_send[ii],gsen_fifo_z_send[ii],ppg_s_data.green_cur); @@ -3210,16 +3206,7 @@ void hx3695_spo2_ppg_Int_handle(void) { return; } - - for(ii = 0; ii < hrs_s_dat.count; ii++) - { - if(red_buf[ii] > 10000) - { - ble_spo2_data = red_buf[ii]; - } - } - - + #ifndef GSEN_40MS_TIMMER // readFifoByHrsModule(); #endif @@ -3246,6 +3233,9 @@ void hx3695_spo2_ppg_Int_handle(void) gsen_fifo_z_send[ii] = gsensordata[ii].z * 2048; } + if(abs(red_buf[ii]) > 10000) + ble_spo2_data = abs(red_buf[ii]) ; + PRINT("hxdata:%d/%d %d %d %d %d %d %d\r\n", 1+ii,*count,red_buf[ii],ir_buf[ii],green_buf[ii],gsen_fifo_x_send[ii],gsen_fifo_y_send[ii],gsen_fifo_z_send[ii]); //printf("FFF==>spo2 red_buf : %d, %d, %d, %d \n", 1+ii, *count, red_buf[ii], ir_buf[0]); diff --git a/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp b/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp index ac3d3cbc5..9aa9e1a74 100644 --- a/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp +++ b/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp @@ -68,7 +68,7 @@ static bool ppg_service_running_stat = false; static bool ppg_sensor_exist = false; static uint8_t wear_mode_state = 0; -static uint8_t keep_in_wear_det_mod = 1; //持续坚持 佩戴检测模式 +static uint8_t keep_in_wear_det_mod = 0; //持续坚持 佩戴检测模式 void set_keep_in_wear_det_mode(uint8_t mod) diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 146fc17e8..dd7c181c6 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -2229,15 +2229,38 @@ void uapi_check_spk(bool isopen) #endif } -void uapi_efuse_test(void) +void uapi_efuse_test_write(uint8_t *data,uint32_t byte_number,uint8_t len) { - uint8_t writedata[8] = {1,2,3,4,5,6,7,8}; - uint8_t readdata[8] = {0}; + uint8_t readdata[10] = {0}; + errcode_t ret = 0; - uapi_efuse_write_buffer(0x170, writedata, 8); + PRINT("byte_number : %d \r\n",byte_number); - uapi_efuse_read_buffer(readdata, 0x170, 8); - for(int i = 0; i < 8; i++) - PRINT("readdata[%d] : %d \r\n",i,readdata[i]); + for(int i = 0; i < len; i++) + PRINT("write_data[%d] : %d \r\n",i,data[i]); + ret = uapi_efuse_write_buffer(byte_number, data, len); + if(ret != ERRCODE_SUCC) + PRINT("uapi_efuse_write_buffer failed \r\n"); + + ret = uapi_efuse_read_buffer(readdata, byte_number, len); + if(ret != ERRCODE_SUCC) + PRINT("uapi_efuse_read_buffer failed \r\n"); + for(int i = 0; i < len; i++) + PRINT("read_data[%d] : %d \r\n",i,readdata[i]); +} + +void uapi_efuse_test_read(uint32_t byte_number,uint8_t len) +{ + uint8_t readdata[10] = {0}; + errcode_t ret = 0; + + PRINT("byte_number : %d \r\n",byte_number); + + ret = uapi_efuse_read_buffer(readdata, byte_number, len); + if(ret != ERRCODE_SUCC) + PRINT("uapi_efuse_read_buffer failed \r\n"); + + for(int i = 0; i < len; i++) + PRINT("read_data[%d] : %d \r\n",i,readdata[i]); } \ No newline at end of file diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.h b/code/sdk/drivers/peripheral/utils/custom_utils.h index 8856f04df..9f3d44e6b 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.h +++ b/code/sdk/drivers/peripheral/utils/custom_utils.h @@ -205,7 +205,9 @@ void uapi_ppg_get_id(uint8_t *chip_id); void uapi_microhone_switch(bool isopen); void uapi_check_spk(bool isopen); -void uapi_efuse_test(void); +void uapi_efuse_test_write(uint8_t *data,uint32_t byte_number,uint8_t len); +void uapi_efuse_test_read(uint32_t byte_number,uint8_t len); + #include "custom_utilscpp.h" diff --git a/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c b/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c index f1c49636e..1f7271e66 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c @@ -592,16 +592,71 @@ static uint32_t custom_test_sntp(uint8_t *para, uint32_t paraLen, char *strCommo return ERRCODE_SUCC; } -static uint32_t custom_uapi_efuse_test(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +static uint32_t custom_uapi_efuse_test_write(uint8_t *para, uint32_t paraLen, char *strCommonCmd) { UNUSED(strCommonCmd); + uint8_t argv[CUSTOM_UTILS_MAX_ARGC][CUSTOM_UTILS_MAX_ARGV_LEN] = { 0 }; + uint32_t argc = 0; + uint8_t send_data[8] = {0}; - uapi_efuse_test(); + + int ret = ConvertCmdToParam(para, paraLen, argv, &argc); + if (ret != CUSTOM_UTILS_SUCCESS) { + PRINT("CUSTOM_UTILSTEST ATCMD Convert Command Failed\n"); + return ERRCODE_FAIL; + } + + if (argc != 3) { + PRINT("CUSTOM_UTILSTEST power_test ATCMD Set Parameter Failed argc %d\r\nPM_DSP_POWER_UP_AND_RUN=2 PM_DSP_POWER_OFF=3\r\n",argc); + return ERRCODE_FAIL; + } + + uint32_t add = atol((char*)argv[1]); + uint8_t len = atol((char*)argv[2]); + + for(int i = 0; i < len; i++) + { + if(argv[0][i] >=65) + argv[0][i] = argv[0][i] - 65 + 10; + else + argv[0][i] = argv[0][i] - 48; + + send_data[i] = argv[0][i]; + } + + uapi_efuse_test_write(send_data,add,len); + //uapi_boot_animotion_test(); return ERRCODE_SUCC; } +static uint32_t custom_uapi_efuse_test_read(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +{ + + UNUSED(strCommonCmd); + + uint8_t argv[CUSTOM_UTILS_MAX_ARGC][CUSTOM_UTILS_MAX_ARGV_LEN] = { 0 }; + uint32_t argc = 0; + + int ret = ConvertCmdToParam(para, paraLen, argv, &argc); + if (ret != CUSTOM_UTILS_SUCCESS) { + PRINT("CUSTOM_UTILSTEST ATCMD Convert Command Failed\n"); + return ERRCODE_FAIL; + } + + if (argc != 2) { + PRINT("CUSTOM_UTILSTEST power_test ATCMD Set Parameter Failed argc %d\r\nPM_DSP_POWER_UP_AND_RUN=2 PM_DSP_POWER_OFF=3\r\n",argc); + return ERRCODE_FAIL; + } + uint32_t add = atol((char*)argv[0]); + uint8_t len = atol((char*)argv[1]); + uapi_efuse_test_read(add,len); + + return ERRCODE_SUCC; +} + + static const at_cmd_table_t g_custom_utils_cmd[] = { { (char *)"AT^CUSTOM_SN", custom_utils_setsn, (char *)"123456789ABCDEF2345678" }, { (char *)"AT^CUSTOM_SN_REQ", custom_utils_getsn, (char *)" " }, @@ -648,10 +703,12 @@ static const at_cmd_table_t g_custom_utils_cmd[] = { { (char *)"AT^TIMESYNC", custom_test_time_synct, (char *)" " }, { (char *)"AT^24HOUR", custom_test_time_showtype, (char *)" " }, - { (char *)"AT^EFUSETEST", custom_uapi_efuse_test, (char *)" " }, + { (char *)"AT^EFUSEREAD", custom_uapi_efuse_test_read, (char *)" " }, + { (char *)"AT^EFUSEWRITE", custom_uapi_efuse_test_write, (char *)" " }, }; + at_cmd_table_t *get_custom_utils_cmd_table(uint32_t *cmd_count) { *cmd_count = ARRAY_COUNT(g_custom_utils_cmd); diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/service/src/graphic_service_wrapper.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/service/src/graphic_service_wrapper.cpp index 0c16ee228..304ce1d52 100755 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/service/src/graphic_service_wrapper.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/service/src/graphic_service_wrapper.cpp @@ -23,6 +23,10 @@ #include "common/screen.h" #include "components/root_view.h" #include "components/ui_image_view.h" +#include "thread_init.h" +#include "custom_utils.h" +#include "components/ui_image_animator.h" +#include "wearable_log.h" #ifdef __cplusplus extern "C" { @@ -42,15 +46,175 @@ static bool g_showOtaLogo = false; static OHOS::UIImageView* g_ota_logo = nullptr; static OHOS::ImageInfo* g_ota_imgInfo = nullptr; +static uint32_t *g_boot_animation_task_handle = NULL; + +static OHOS::UIViewGroup* group=nullptr; +static OHOS::UIViewGroup* boot_group=nullptr; +static OHOS::UIImageAnimatorView* ReBootImageAnimatorView=nullptr; +static constexpr char *ReBootPaths = "/system/ReBoot/"; //开机图片路径 +static constexpr int16_t REBOOT_IMAGE_ANIMATOR_VIEW_NUM_FRAMES = 30; // 图片帧数 +static constexpr int16_t REBOOT_IMAGE_ANIMATOR_TIME = 150; // 图片更新间隔 +static OHOS::ImageAnimatorInfo ReBootImageInfo[REBOOT_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; // 开机图像的信息 +static constexpr int16_t REBOOT_IMAGE_ANIMATOR_VIEW_X = 0; +static constexpr int16_t REBOOT_IMAGE_ANIMATOR_VIEW_Y = 0; +static constexpr int16_t REBOOT_IMAGE_ANIMATOR_VIEW_W = 466; +static constexpr int16_t REBOOT_IMAGE_ANIMATOR_VIEW_H = 466; +const char **ReBootPathsArray{nullptr}; // 开机图片路径数组 +static OHOS::UIImageAnimatorView::AnimatorStopListener *bootStoplistener{nullptr}; +static bool boot_animation_flag = false; +static app_task_definition_t taskcfg={0}; + #ifdef QSPI_DISPLAY #define IMAGE_OPEN_LOGO_PATH "/user/res/OPEN_LOGO_QSPI.bin" #else #define IMAGE_OPEN_LOGO_PATH "/system/KUMI_LOGO.bin" -#define Z1_IMAGE_OPEN_LOGO_PATH "/system/z1bootlogo.bin" #define IMAGE_OTA_LOGO_PATH "/system/OTAUpdata.bin" - #endif +static void FreeImagePathsArray(const char **imagePaths, const int numImages) +{ + for (int i = 0; i < numImages; i++) + { + delete imagePaths[i]; + imagePaths[i] = nullptr; + } +} + +static void ClearAll(void) +{ + if(group!=nullptr) + { + OHOS::RootView::GetInstance()->Remove(group); + group->RemoveAll(); + + if (ReBootImageAnimatorView != nullptr) + { + delete ReBootImageAnimatorView; + ReBootImageAnimatorView = nullptr; + } + + if(bootStoplistener!=nullptr) + { + delete bootStoplistener; + bootStoplistener = nullptr; + } + + FreeImagePathsArray(ReBootPathsArray, REBOOT_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + + delete group; + group = nullptr; + } +} + +class BootAnimatorListener:public OHOS::UIImageAnimatorView::AnimatorStopListener +{ +public: +BootAnimatorListener(){} +~BootAnimatorListener(){} + +private: + void OnAnimatorStop(OHOS::UIView &view) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnAnimatorStop"); + + ClearAll(); + + errcode_t ret = uapi_terminate_thread(taskcfg.task_handle); + + if(ret != ERRCODE_SUCC) + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"kill boot_animation_task failed %d!",ret); + else + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"kill boot_animation_task succed !"); + + //boot_group->SetVisible(false); + OHOS::RootView::GetInstance()->Remove(boot_group); + delete boot_group; + boot_group = nullptr; + boot_animation_flag = true; + } + +}; + + +static const char ** CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages) +{ + const char **imagePaths = new const char *[numImages]; + char buffer[256]; + for (int i = 0; i < numImages; i++) + { + if(i < 10) + snprintf(buffer, sizeof(buffer), "%s6S2400%d.%s", basePath, i , fileExtension); + else + snprintf(buffer, sizeof(buffer), "%s6S240%d.%s", basePath, i , fileExtension); + imagePaths[i] = strdup(buffer); + //WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP," imagePaths[%d] = %s ", i, imagePaths[i]); + } + return imagePaths; +} + +bool ShowReBootAnimatorView() +{ + ReBootPathsArray = CreateImagePathsArray(ReBootPaths, "bin", REBOOT_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + + if (ReBootImageAnimatorView == nullptr) + { + ReBootImageAnimatorView = new OHOS::UIImageAnimatorView(); + if (ReBootImageAnimatorView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new ReBootImageAnimatorView fail"); + return false; + } + for (uint8_t i = 0; i < REBOOT_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++) + { + ReBootImageInfo[i].imagePath = (ReBootPathsArray[i]); + ReBootImageInfo[i].imageType = OHOS::IMG_SRC_FILE_PATH; + ReBootImageInfo[i].pos.x = REBOOT_IMAGE_ANIMATOR_VIEW_X; + ReBootImageInfo[i].pos.y = REBOOT_IMAGE_ANIMATOR_VIEW_Y; + ReBootImageInfo[i].width = REBOOT_IMAGE_ANIMATOR_VIEW_W; + ReBootImageInfo[i].height = REBOOT_IMAGE_ANIMATOR_VIEW_H; + } + ReBootImageAnimatorView->SetPosition(REBOOT_IMAGE_ANIMATOR_VIEW_X, REBOOT_IMAGE_ANIMATOR_VIEW_Y, REBOOT_IMAGE_ANIMATOR_VIEW_W, REBOOT_IMAGE_ANIMATOR_VIEW_H); + ReBootImageAnimatorView->SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xffffffff); + ReBootImageAnimatorView->SetStyle(OHOS::STYLE_BACKGROUND_OPA, 0xff); + ReBootImageAnimatorView->SetImageAnimatorSrc(ReBootImageInfo, REBOOT_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, 100); + ReBootImageAnimatorView->SetRepeat(false); + ReBootImageAnimatorView->SetRepeatTimes(1); + + bootStoplistener = static_cast(new BootAnimatorListener()); + if (bootStoplistener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to Create bootStoplistener!!"); + return false; + } + ReBootImageAnimatorView->SetAnimatorStopListener(bootStoplistener); + } + + + return true; +} + +OHOS::UIViewGroup* ReBootAnimatorViewInit(void) +{ + bool ret; + group = new OHOS::UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP," group new fail"); + return nullptr; + } + group->SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION); + group->SetStyle(OHOS::STYLE_BACKGROUND_OPA, OHOS::OPA_OPAQUE); + ret = ShowReBootAnimatorView(); + + if (ret == false) + { + return nullptr; + } + + group->Add(ReBootImageAnimatorView); + return group; +} + static void UikitRTCCallBack(uintptr_t data) { (void)(data); @@ -151,20 +315,21 @@ void InitGraphicService(void) void HideGraphicLogo() { if (!g_showLogo) { - return; - } - g_showLogo = false; - OHOS::GraphicEventHandler::GetInstance()->PostGraphicEvent( - [] { - if (g_logo != nullptr) { - OHOS::RootView::GetInstance()->Remove(g_logo); - delete g_logo; - g_logo = nullptr; - OHOS::ImageCacheManager::GetInstance().UnloadSingleRes(IMAGE_OPEN_LOGO_PATH); - g_imgInfo = nullptr; - } - }, - false); + return; + } + + g_showLogo = false; + OHOS::GraphicEventHandler::GetInstance()->PostGraphicEvent( + [] { + if (g_logo != nullptr) { + OHOS::RootView::GetInstance()->Remove(g_logo); + delete g_logo; + g_logo = nullptr; + OHOS::ImageCacheManager::GetInstance().UnloadSingleRes(IMAGE_OPEN_LOGO_PATH); + g_imgInfo = nullptr; + } + }, + false); } void HideGraphicOtaLogo() @@ -185,29 +350,64 @@ void HideGraphicOtaLogo() }, false); } + +static void boot_animation_task(void *arg) +{ + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "boot_animation_task start"); + unused(arg); + + boot_group = ReBootAnimatorViewInit(); + if (boot_group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP," boot_group nullptr fail"); + return; + } + + OHOS::GraphicEventHandler::GetInstance()->PostGraphicEvent( + [] { + OHOS::RootView::GetInstance()->Add(boot_group); + ReBootImageAnimatorView->Start(); + }, + false); + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "boot_animation_task end!!"); +} + void ShowGraphicLogo(void) { + while(boot_animation_flag == false) + { + //WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowGraphicLogo : %d ",boot_animation_flag); + LOS_Mdelay(1); + } if (g_showLogo) { - return; + return; } g_showLogo = true; g_logo = new OHOS::UIImageView(); - g_logo->SetPosition(0, 0, OHOS::Screen::GetInstance().GetWidth(), OHOS::Screen::GetInstance().GetHeight()); + g_logo->SetPosition(0, 0, 466, 466); g_logo->SetAutoEnable(false); g_logo->SetResizeMode(OHOS::UIImageView::CENTER); - g_imgInfo = OHOS::ImageCacheManager::GetInstance().LoadSingleRes(Z1_IMAGE_OPEN_LOGO_PATH); - if (g_imgInfo == nullptr) - g_imgInfo = OHOS::ImageCacheManager::GetInstance().LoadSingleRes(IMAGE_OPEN_LOGO_PATH); + + g_imgInfo = OHOS::ImageCacheManager::GetInstance().LoadSingleRes(IMAGE_OPEN_LOGO_PATH); g_logo->SetSrc(g_imgInfo); + OHOS::GraphicEventHandler::GetInstance()->PostGraphicEvent( [] { OHOS::RootView::GetInstance()->Add(g_logo); OHOS::RootView::GetInstance()->Invalidate(); }, false); + } + void ShowGraphicOTALogo(void) { + while(boot_animation_flag == false) + { + //WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowGraphicLogo : %d ",boot_animation_flag); + LOS_Mdelay(1); + } if (g_showOtaLogo) { return; } @@ -225,6 +425,27 @@ void ShowGraphicOTALogo(void) }, false); } + +void boot_animation_init(void) +{ + //ShowGraphicLogo(); + + taskcfg.task_handle = g_boot_animation_task_handle; + taskcfg.attr.name="boot_animation_service"; + taskcfg.attr.priority = TASK_PRIORITY_SDK; + taskcfg.attr.stack_size = 0x1000; + taskcfg.func = boot_animation_task; + taskcfg.use_mem = USE_EXTEND_MEM; + + errcode_t ret=uapi_create_osThread_custom(&taskcfg); + if(ret != ERRCODE_SUCC) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"create boot_animation_task failed %d!",ret); + return ; + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"create boot_animation_task succed"); +} + #ifdef __cplusplus }; #endif -- 2.17.1