From 253e1fb4d061777a89bb3dad19297ccda2d3d15c Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Mon, 18 Aug 2025 18:38:54 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E8=93=9D=E7=89=99=E4=BA=A7?= =?utf8?q?=E6=B5=8B=E5=9C=B0=E7=A3=81=E3=80=81gps=20=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/compass/src/CompassModel.cpp | 27 ++++++---- .../UI/producttest/include/testPresenter.h | 30 ++++++++++- .../zhihui/UI/producttest/src/testgsenson.cpp | 52 ++++++++++++++++--- .../UI/producttest/src/testmagnetic.cpp | 44 ++++++++++++++-- .../zhihui/drivers/mag/mmc5603/mmc5603_hal.h | 6 +-- .../zhihui/drivers/mag/mmc5603/mmc5603_main.c | 16 +++--- code/sdk/zhihui/drivers/mag/service/mag_hal.c | 16 +++--- code/sdk/zhihui/drivers/mag/service/mag_hal.h | 7 +-- .../factorytest_protocol.c | 27 +++++----- .../gnss/sample/pgnss_sample/pgnss_sample.c | 4 +- 10 files changed, 172 insertions(+), 57 deletions(-) diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/compass/src/CompassModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/compass/src/CompassModel.cpp index 64639c409..d45048cc2 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/compass/src/CompassModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/compass/src/CompassModel.cpp @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2025-05-15 11:27:16 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-07-31 17:10:15 + * @LastEditTime: 2025-08-18 17:38:37 * @FilePath: /FD230/code/sdk/application/wearable/fd230/nativeapp/nativeui/compass/src/CompassModel.cpp * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -17,15 +17,16 @@ #include "compass/include/CompassModel.h" #include -#ifdef SUPORT_MAG_SERVICE -#include "mag/service/mag_service.h" -#include "mag/mmc5603/mmc5603_hal.h" -#endif #ifdef __cplusplus extern "C" { #endif +#ifdef SUPORT_MAG_SERVICE +#include "mag_service.h" +#include "mag_hal.h" +#endif + using namespace OHOS; #ifdef __cplusplus @@ -56,7 +57,11 @@ void CompassModel::SetCalibrationStatus(uint8_t status) uint8_t CompassModel::GetCalibrationStatus(void) { #ifdef SUPORT_MAG_SERVICE - if( mag_service_get_iAccuracy() < 3) + + int iAccuracy = 0; + mag_get_iAccuracy(&iAccuracy); + + if(iAccuracy < 3) return 1; else return 0; @@ -70,14 +75,16 @@ uint8_t CompassModel::GetCalibrationStatus(void) */ void CompassModel::SetDisplayAngle(uint16_t angle) { - #ifdef SUPORT_MAG_SERVICE - displayAngle = (int16_t)mag_service_get_fAzimuth(); - #else +#ifdef SUPORT_MAG_SERVICE + float data = 0; + mag_get_fAzimuth(&data); + displayAngle = (int16_t)data; +#else displayAngle += angle; if (displayAngle > 359) { displayAngle = 0; } - #endif +#endif } /* diff --git a/code/sdk/zhihui/UI/producttest/include/testPresenter.h b/code/sdk/zhihui/UI/producttest/include/testPresenter.h index 1d5a595ff..8671d6a3e 100644 --- a/code/sdk/zhihui/UI/producttest/include/testPresenter.h +++ b/code/sdk/zhihui/UI/producttest/include/testPresenter.h @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-08-23 10:50:37 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-08-13 14:38:27 + * @LastEditTime: 2025-08-18 18:37:28 * @FilePath: /FD230/code/sdk/application/wearable/fd230/nativeapp/nativeui/producttest/include/testPresenter.h * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -24,6 +24,30 @@ #include "producttest/include/testhrsenson.h" #include "components/ui_label_button_ext.h" #include "common/key_code.h" + + + +typedef struct { + bool lcd; // LCD测试结果 + bool tp; // 触摸屏测试结果 + bool mag; // 磁力计测试结果 + bool brightness; // 亮度测试结果 + bool bat; // 亮度测试结果 + bool spk; // 喇叭测试结果 + bool mic; // 麦克风测试结果 + bool motor; // 马达测试结果 + bool hr; // 心率漏光测试结果 + bool gsensor; // 重力加速度传感器 + bool cat1; // 4g测试结果 + bool button; // 按键测试结果 + bool bt; // 蓝牙扫描测试结果 + bool aplipay; // 支付宝加密芯片测试结果 + bool gps; // gps测试结果 + bool lowpower; // 低功耗测试结果 +} FactoryTestResult; + +static FactoryTestResult g_factoryTestResult = {false}; + namespace OHOS { typedef enum @@ -65,7 +89,6 @@ namespace OHOS MAX_TESTVIEWID, } TEST_VIEW; - class testView; class testPresenter : public Presenter, public UIView::OnClickListener, @@ -83,6 +106,9 @@ namespace OHOS static testPresenter *GetInstance(); + FactoryTestResult* GetFactoryTestResult() {return &g_factoryTestResult;} + + private: // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; bool OnClick(UIView &view, const ClickEvent &event) override; diff --git a/code/sdk/zhihui/UI/producttest/src/testgsenson.cpp b/code/sdk/zhihui/UI/producttest/src/testgsenson.cpp index c381c37c1..fb7b92a19 100644 --- a/code/sdk/zhihui/UI/producttest/src/testgsenson.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testgsenson.cpp @@ -5,6 +5,7 @@ #include "cmsis_os2.h" #include "cywee_hal.h" #include "producttest/include/testView.h" +#include "math.h" #ifdef __cplusplus #if __cplusplus extern "C" @@ -19,6 +20,11 @@ extern "C" #endif #endif +#ifdef SUPPORT_CYWEE_SERVICE +static gsenson_t last_value = {0}; +static bool isInit = false; +#endif + //#include "acc_service.h" namespace OHOS { @@ -66,6 +72,12 @@ namespace OHOS static osTimerId_t Gsenson_TEST_timer=NULL; void testgsensonView::ClearAll() { +#ifdef SUPPORT_CYWEE_SERVICE + last_value.x = 0; + last_value.y = 0; + last_value.z = 0; + isInit = false; +#endif if(testGsonsonScrollView) { testGsonsonScrollView->RemoveAll(); @@ -112,15 +124,43 @@ namespace OHOS { MG_TEST_FALG++; - gsenson_t t; + char buf[124]={0}; + #ifdef SUPPORT_CYWEE_SERVICE + gsenson_t t; cywee_get_gsensor_data(1,&t); + sprintf(buf,"X:%.2f\nY:%.2f\nZ:%.2f",t.x,t.y,t.z); + + // if (!isInit) + // { + // last_value.x = t.x; + // last_value.y = t.y; + // last_value.z = t.z; + // isInit = true; + // } + // else + // { + // bool xChanged = fabs(t.x - last_value.x) > 0.01f; + // bool yChanged = fabs(t.y - last_value.y) > 0.01f; + // bool zChanged = fabs(t.z - last_value.z) > 0.01f; + + // FactoryTestResult *g_ret = OHOS::testPresenter::GetInstance()->GetFactoryTestResult(); + // if (g_ret) + // { + // if (xChanged || yChanged || zChanged) + // g_ret->gsensor = 1; + // else + // g_ret->gsensor = 2; + // } + // } + + // FactoryTestResult *g_ret = OHOS::testPresenter::GetInstance()->GetFactoryTestResult(); + // if (g_ret) { + // printf("gsensor test result:%d\n", g_ret->gsensor); + // } + #endif - char buf[124]={0}; - float x_t=t.x; - float y_t=t.y; - float z_t=t.z; - sprintf(buf,"X:%.2f\nY:%.2f\nZ:%.2f",x_t,y_t,z_t); + x->SetText(buf); RootView::GetInstance()->Invalidate(); diff --git a/code/sdk/zhihui/UI/producttest/src/testmagnetic.cpp b/code/sdk/zhihui/UI/producttest/src/testmagnetic.cpp index f55d1bb37..395082239 100644 --- a/code/sdk/zhihui/UI/producttest/src/testmagnetic.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testmagnetic.cpp @@ -19,13 +19,17 @@ extern "C" #endif #include "pm_veto.h" #include "pm.h" +#ifdef SUPPORT_MAG_SERVICE + #include "mag_hal.h" +#endif #ifdef __cplusplus #if __cplusplus } #endif -#include "mag/mmc5603/mmc5603_hal.h" #endif +static float last_value = 0; + namespace OHOS { @@ -52,6 +56,8 @@ namespace OHOS osTimerId_t magneyic_TEST_timer=NULL; void testMagicView::ClearAll() { + last_value = 0; + if(testmagicScrollView) { testmagicScrollView->RemoveAll(); @@ -122,7 +128,36 @@ namespace OHOS RootView::GetInstance()->Invalidate(); #else MG_TEST_FALG++; - float angle_value= mag_service_get_fAzimuth(); + float angle_value = 0; + +#ifdef SUPPORT_MAG_SERVICE + mag_get_fAzimuth(&angle_value); +#endif + if(angle_value && !last_value) + { + last_value = angle_value; + } + else if(last_value && angle_value && last_value != angle_value) + { + FactoryTestResult *g_ret = OHOS::testPresenter::GetInstance()->GetFactoryTestResult(); + if(g_ret) + { + g_ret->mag = 1; + } + } + else if(!angle_value) + { + FactoryTestResult *g_ret = OHOS::testPresenter::GetInstance()->GetFactoryTestResult(); + if(g_ret) + { + g_ret->mag = 2; + } + } + + FactoryTestResult *g_ret = OHOS::testPresenter::GetInstance()->GetFactoryTestResult(); + if(g_ret) + printf("mag test result:%d\n",g_ret->mag); + char buf[16]={0}; sprintf(buf,"angle:%.2f",angle_value); x->SetText(buf); @@ -211,7 +246,10 @@ namespace OHOS } testmagicScrollView->Add(title); /* -------------------------------------------------------------------------- */ - uint16_t angle_value= (int16_t)mag_service_get_fAzimuth(); + float angle_value = 0; +#ifdef SUPPORT_MAG_SERVICE + mag_get_fAzimuth(&angle_value); +#endif char buf[16]={0}; sprintf(buf,"angle:%d",angle_value); Config = { diff --git a/code/sdk/zhihui/drivers/mag/mmc5603/mmc5603_hal.h b/code/sdk/zhihui/drivers/mag/mmc5603/mmc5603_hal.h index 4968ca215..779810a0a 100644 --- a/code/sdk/zhihui/drivers/mag/mmc5603/mmc5603_hal.h +++ b/code/sdk/zhihui/drivers/mag/mmc5603/mmc5603_hal.h @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2025-05-15 11:28:07 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-07-29 10:54:34 + * @LastEditTime: 2025-08-18 17:34:06 * @FilePath: /FD230/code/sdk/zhihui/drivers/mag/mmc5603/mmc5603_hal.h * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -36,8 +36,8 @@ int mmc5603_start(void); void mmc5603_poweron(void); void mmc5603_poweroff(void); -float mag_service_get_fAzimuth(void); -int mag_service_get_iAccuracy(void); +void mag_service_get_fAzimuth(float *data); +void mag_service_get_iAccuracy(int *data); #ifdef __cplusplus #if __cplusplus diff --git a/code/sdk/zhihui/drivers/mag/mmc5603/mmc5603_main.c b/code/sdk/zhihui/drivers/mag/mmc5603/mmc5603_main.c index d88f6e933..54a24f95a 100644 --- a/code/sdk/zhihui/drivers/mag/mmc5603/mmc5603_main.c +++ b/code/sdk/zhihui/drivers/mag/mmc5603/mmc5603_main.c @@ -35,13 +35,13 @@ float magnetic_field_z; #define GPIO_PIN_PRG_LED_ON S_AGPIO_R0 /* These variables are used to save the magnetic sensor calibrated data. */ -float calMagX, calMagY, calMagZ; +static float calMagX, calMagY, calMagZ; /* These variables are used to save the calibrated orientation output. */ -float fAzimuth, fPitch, fRoll; +static float fAzimuth, fPitch, fRoll; /* This variable is used to save the calibration accuracy. */ -int iAccuracy; +static int iAccuracy; /* Read saved calibration parameters. These para is saved in somewhere that can not disappear when power-off * ReadPara function should be create by customer.If customer can not implement this function, should comment it out @@ -451,9 +451,10 @@ void mag_coordinate_raw_to_real(int layout, float *in, float *out) break; } } -float mag_service_get_fAzimuth(void) +void mag_service_get_fAzimuth(float *data) { - return fAzimuth; + if(data) + *data = fAzimuth; } float mag_service_get_fPitch(void) @@ -466,9 +467,10 @@ float mag_service_get_fRoll(void) return fRoll; } -int mag_service_get_iAccuracy(void) +void mag_service_get_iAccuracy(int *data) { - return iAccuracy ; + if(data) + *data = iAccuracy; } int mmc5603_stop(void) diff --git a/code/sdk/zhihui/drivers/mag/service/mag_hal.c b/code/sdk/zhihui/drivers/mag/service/mag_hal.c index f2ad86385..a267b35d1 100644 --- a/code/sdk/zhihui/drivers/mag/service/mag_hal.c +++ b/code/sdk/zhihui/drivers/mag/service/mag_hal.c @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2025-05-16 11:36:48 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-07-29 14:17:17 + * @LastEditTime: 2025-08-18 17:33:25 * @FilePath: /FD230/code/sdk/zhihui/drivers/mag/hal/mag_hal.c * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -46,21 +46,19 @@ uint8_t mag_get_chip_id(void) return id; } -int mag_get_iAccuracy(void) +void mag_get_iAccuracy(int *data) { - int iAccuracy = 0; #ifdef MAG_MMC5603 - iAccuracy = mag_service_get_iAccuracy(); + if(data) + mag_service_get_iAccuracy(data); #endif - return iAccuracy; } -float mag_get_fAzimuth(void) +void mag_get_fAzimuth(float *data) { - float fAzimuth = 0; #ifdef MAG_MMC5603 - fAzimuth = (float)mag_service_get_fAzimuth(); + if(data) + mag_service_get_fAzimuth(data); #endif - return fAzimuth; } \ No newline at end of file diff --git a/code/sdk/zhihui/drivers/mag/service/mag_hal.h b/code/sdk/zhihui/drivers/mag/service/mag_hal.h index 6c7b3b53d..d08ed3950 100644 --- a/code/sdk/zhihui/drivers/mag/service/mag_hal.h +++ b/code/sdk/zhihui/drivers/mag/service/mag_hal.h @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-06-07 11:18:26 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-07-31 17:27:56 + * @LastEditTime: 2025-08-18 17:33:40 * @FilePath: /FD230/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.h * @Description: * @@ -28,8 +28,9 @@ void mag_sensor_start(void); void mag_sensor_stop(void); uint8_t mag_get_chip_id(void); -int mag_get_iAccuracy(void); -float mag_get_fAzimuth(void); + +void mag_get_iAccuracy(int *data); +void mag_get_fAzimuth(float *data); #ifdef __cplusplus #if __cplusplus diff --git a/code/sdk/zhihui/services/factorytest_service/factorytest_protocol.c b/code/sdk/zhihui/services/factorytest_service/factorytest_protocol.c index 27d0fbbda..34e90ba41 100644 --- a/code/sdk/zhihui/services/factorytest_service/factorytest_protocol.c +++ b/code/sdk/zhihui/services/factorytest_service/factorytest_protocol.c @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-06-17 14:31:08 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-08-16 18:15:33 + * @LastEditTime: 2025-08-18 18:37:51 * @FilePath: /FD230/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c * @Description: * @@ -487,7 +487,7 @@ void aging_task(void) do_mag_service_check_msg(MAG_SERVICE_CMD_START_CHECK); LOS_Msleep(1000); #ifdef SUPPORT_MAG_SERVICE - fAzimuth = mag_get_fAzimuth(); + mag_get_fAzimuth(&fAzimuth); #endif do_mag_service_check_msg(MAG_SERVICE_CMD_STOP_CHECK); if(fAzimuth < 0) @@ -1692,13 +1692,14 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint { //地磁sensor测试 float fAzimuth,fPitch,fRoll; - +#ifdef SUPPORT_MAG_SERVICE do_mag_service_check_msg(MAG_SERVICE_CMD_START_CHECK); LOS_Msleep(1000); -#ifdef SUPPORT_MAG_SERVICE - fAzimuth = mag_get_fAzimuth(); -#endif + + mag_get_fAzimuth(&fAzimuth); + printf("fAzimuth : %f\n",fAzimuth); do_mag_service_check_msg(MAG_SERVICE_CMD_STOP_CHECK); +#endif #ifdef BOARD_FD230 uint8_t databuf[6] = {0}; @@ -2204,6 +2205,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint &send_data, 1); } + break; case BLE_TEST_CMD_SOFT_TEST_SUB_MODE_GPS: if (testitem == 0x01) @@ -2268,12 +2270,12 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint send_data[5] = (uint8_t)(((uint32_t)send_gps_data.th001_quality & 0x0000FF00) >> 8); send_data[6] = (uint8_t)(((uint32_t)send_gps_data.th001_quality & 0x000000FF) >> 0); - // PRINT("gps_data->num_sats : %d,gps_data->th001_valid_star_count : %d,gps_data->th000_signal_vga : %d,gps_data->th001_quality : %f\n", - // send_gps_data.num_sats,send_gps_data.th001_valid_star_count, - // send_gps_data.th000_signal_vga,send_gps_data.th001_quality - // ); - // PRINT("%2X %2X %2X\r\n",send_data[0],send_data[1],send_data[2]); - // PRINT("%2X %2X %2X %2X \r\n",send_data[3],send_data[4],send_data[5],send_data[6]); + PRINT("gps_data->num_sats : %d,gps_data->th001_valid_star_count : %d,gps_data->th000_signal_vga : %d,gps_data->th001_quality : %f\n", + send_gps_data.num_sats,send_gps_data.th001_valid_star_count, + send_gps_data.th000_signal_vga,send_gps_data.th001_quality + ); + PRINT("%2X %2X %2X\r\n",send_data[0],send_data[1],send_data[2]); + PRINT("%2X %2X %2X %2X \r\n",send_data[3],send_data[4],send_data[5],send_data[6]); } #endif factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, @@ -2284,7 +2286,6 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint } break; - break; default: printf(""); diff --git a/code/sdk/zhihui/services/gnss/sample/pgnss_sample/pgnss_sample.c b/code/sdk/zhihui/services/gnss/sample/pgnss_sample/pgnss_sample.c index aaba6b549..d7130ad3d 100644 --- a/code/sdk/zhihui/services/gnss/sample/pgnss_sample/pgnss_sample.c +++ b/code/sdk/zhihui/services/gnss/sample/pgnss_sample/pgnss_sample.c @@ -290,7 +290,7 @@ void PGnssServerStart(void) #endif g_is_pgnss_poweron = 1; g_pgnss_stopflag = 0; - + sw_debug_uart_deinit(); // Step1: init int32_t ret = tiot_service_init(); if (ret != 0) { @@ -364,5 +364,7 @@ void PGnssServerStart(void) #endif uapi_pm_remove_sleep_veto(PM_ID_SYS); g_is_pgnss_poweron=0; + sw_debug_uart_deinit(); + uart_config_init(); printf("finish gnss samples\r\n"); } -- 2.17.1