From: hcj <1224667075@qq.com> Date: Wed, 27 Mar 2024 07:48:15 +0000 (+0800) Subject: gsensortest X-Git-Tag: release_V1.2.70_20241020_135402~1253^2 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=b5ca41b5488f39834609014eab75e8704b839997;p=mirrors%2FFD230.git gsensortest --- diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 15bd4d2e8..9277b459b 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -494,6 +494,8 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testmakephone.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testcat1.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testhrsenson.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testgsenson.cpp + #${CMAKE_CURRENT_SOURCE_DIR} /service/acc_service.c ) if("SUPPORT_ALIPAY_SEC" IN_LIST DEFINES) set(SOURCES diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testPresenter.h index 6f462af64..5c1c01df9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testPresenter.h @@ -33,6 +33,7 @@ namespace OHOS BUTTON, MAKEPHONE, HRSENSON, + GSENSON, TEST_1, MAX_TESTVIEWID, diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testView.h b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testView.h index f1ba437da..112907ae8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testView.h @@ -23,6 +23,7 @@ #include "producttest/include/testmakephone.h" #include "producttest/include/testcat1.h" #include "producttest/include/testhrsenson.h" +#include "producttest/include/testgsenson.h" namespace OHOS { @@ -79,6 +80,7 @@ namespace OHOS bool ChangeMPTESTView(int16_t thisView); bool ChangeHRTESTView(int16_t thisView); bool ChangeCAT1TESTView(int16_t thisView); + bool ChangeGTESTView(int16_t thisView); bool ClickFunc(int16_t interface); void ChangeView(int16_t hideView, int16_t showView); @@ -109,7 +111,9 @@ namespace OHOS testMagicView *test_MG_view{nullptr}; testhrsenson1View *test_hr_view{nullptr}; testmakephoneView *test_MP_view{nullptr}; - + + testgsensonView *test_G_view{nullptr}; + UILabelButtonExt *button[10]={NULL}; bool initViewStatus{false}; }; diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testgsenson.h b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testgsenson.h new file mode 100644 index 000000000..fd5018fcb --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testgsenson.h @@ -0,0 +1,54 @@ +#ifndef TEST_GSONSON_VIEW_H +#define TEST_GSONSON_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "producttest/include/testmagnetic.h" +#include "CompassModel.h" +#include "components/ui_label_button_ext.h" +//#include "cmsis_os.h" +#include + +namespace OHOS +{ + class testgsensonView + { + + public: + + struct LabelConfig + { + int16_t left; + int16_t top; + int16_t width; + int16_t height; + int16_t fontSize; // 字体大小 + int16_t lineHeigh; // 行高 + char *text; // 文本 + uint8_t lineBreakMode; // 断行模式。 + }; + + testgsensonView(); + virtual ~testgsensonView(); + static testgsensonView *GetInstance(void); + + UIScrollView *testGSENSONInitIView(void); + void ClearAll(void); + void set_data(); + private: + bool testGsonsonScrollViewcrollViewinit(void); + UILabel *InitLabel(LabelConfig &labelConfig); + UIScrollView *testGsonsonScrollView{nullptr}; + bool initViewStatus{false}; + UILabel *title{nullptr}; // “关于” + UILabel *x{nullptr}; // “手表名称” + UILabel *y{nullptr}; + UILabel *z{nullptr}; // "固件版本" + + UILabelButtonExt* labelButton_next = nullptr; + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPresenter.cpp index f730e39b1..533e48dd6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPresenter.cpp @@ -47,7 +47,8 @@ namespace OHOS {CAT1,"cat1button", "buttonbutton_next",true}, {BUTTON,"buttonbutton", "makephonebutton_next",true}, {MAKEPHONE,"makephonebutton", "hrsensonbutton_next",true}, - {HRSENSON,"hrsensonbutton", "xxxxxxxxxx",true}, + {HRSENSON,"hrsensonbutton", "gsensonbutton_next",true}, + {GSENSON,"gsensonbutton","xxxx" ,true}, }; // {FACTORYRESETVIEW,"FactoryResetButton",true}, // {SYSTEMLUPGRADE,"systemupgread",true}, diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testView.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testView.cpp index b489a3208..6388cd180 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testView.cpp @@ -30,6 +30,7 @@ namespace OHOS {BUTTON,"buttonbutton","button" ,&testView::ChangKEYTESTView}, {MAKEPHONE,"makephonebutton","makephone" ,&testView::ChangeMPTESTView}, {HRSENSON,"hrsensonbutton","hrsenson" ,&testView::ChangeHRTESTView}, + {GSENSON,"gsensonbutton","gsenson" ,&testView::ChangeGTESTView}, // {FACTORYRESETVIEW,"FactoryResetButton","恢复出厂", &testView::ChangeSystemAboutView}, // {SYSTEMLUPGRADE,"systemupgread","系统升级",&testView::ChangeSystemAboutView}, // {TEST,"testButton","测试模式", &testView::ChangeSystemAboutView}, @@ -450,6 +451,24 @@ namespace OHOS return true; } + + bool testView::ChangeGTESTView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSystemAboutView"); + test_G_view = new testgsensonView(); + if (test_G_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_G_view->testGSENSONInitIView(); + RootView::GetInstance()->Add(SystemScrollView[thisView]); + } + return true; + } + UIScrollView *testView::GetSystemScrollView(int ViewId) { if (SystemScrollView[ViewId] == nullptr) diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testgsenson.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testgsenson.cpp new file mode 100644 index 000000000..9d937409d --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testgsenson.cpp @@ -0,0 +1,229 @@ +#include "wearable_log.h" +#include "custom_utils.h" +#include "producttest/include/testPresenter.h" +#include "producttest/include/testgsenson.h" +#include "mag_service.h" +#include "cmsis_os2.h" +#include "cywee_hal.h" +//#include "acc_service.h" +namespace OHOS +{ + + // static void get_gsonsen_xyz(gsenson_t *t) + // { + // // if(osal_mutex_trylock(&mutex_gsenson_queue)==0) + // // { + // // CWM_OS_dbgPrintf("get_gsonsen_xyz_fail\n"); + // // return; + // // } + // lis2doc_read_data_single(&t->x,&t->y,&t->z); + // //osal_mutex_trylock(&mutex_gsenson_queue); + // // t->x=gxyz_t.x; + // // t->y=gxyz_t.y; + // // t->z=gxyz_t.z; + // //osal_mutex_unlock(&mutex_gsenson_queue); + // // int ret= osal_msg_queue_read_copy(gsenson_queue, t, sizeof(gsenson_t),OSAL_MSGQ_NO_WAIT); + // // if(ret!=0) + // // { + // // CWM_OS_dbgPrintf("get_gsonsen_xyz_fail\n"); + // // } + // } + + static testgsensonView *g_pSystemAboutTheWatchView{nullptr}; + + testgsensonView::testgsensonView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::SystemAboutTheWatchView"); + g_pSystemAboutTheWatchView = this; + } + + testgsensonView::~testgsensonView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::~SystemAboutTheWatchView"); + ClearAll(); + g_pSystemAboutTheWatchView = nullptr; + } + + testgsensonView *testgsensonView::GetInstance() + { + + return g_pSystemAboutTheWatchView; + } + static osTimerId_t Gsenson_TEST_timer=NULL; + void testgsensonView::ClearAll() + { + if(testGsonsonScrollView) + { + testGsonsonScrollView->RemoveAll(); + + if (Gsenson_TEST_timer != NULL) { + osTimerDelete(Gsenson_TEST_timer); + Gsenson_TEST_timer = NULL; + return ; + } + + if(title!=NULL) + { + delete title; + title=nullptr; + } + if(x!=NULL) + { + delete x; + x=nullptr; + } + if(labelButton_next) + { + delete labelButton_next; + labelButton_next=nullptr; + } + delete testGsonsonScrollView; + testGsonsonScrollView=nullptr; + } + } + + static void mgdataTimerCallBack(int data) + { + testgsensonView::GetInstance()->set_data(); + } + static uint8_t MG_TEST_FALG=0; + void testgsensonView ::set_data(void) + { + + MG_TEST_FALG++; + gsenson_t t; + get_gsonsen_xyz(&t); + char buf[124]={0}; + sprintf(buf,"X:%d\nY:%d\nZ:%d",t.x,t.y,t.z); + x->SetText(buf); + RootView::GetInstance()->Invalidate(); + + // if(MG_TEST_FALG>10) + // CompassModel::GetInstance()->CloseCompassSensor(); + } + + UILabel *testgsensonView::InitLabel(LabelConfig &labelConfig) + { + UILabel *label = new UILabel(); + if (label == nullptr) + { + return nullptr; + } + label->SetPosition(labelConfig.left, labelConfig.top, labelConfig.width, labelConfig.height); // 位置大小 + label->SetStyle(STYLE_TEXT_FONT, labelConfig.fontSize); // 字体大小 + label->SetStyle(STYLE_LINE_HEIGHT, labelConfig.lineHeigh); // 字体行高 + label->SetText(labelConfig.text); // 内容 + label->SetLineBreakMode(labelConfig.lineBreakMode); // 断行模式。 + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_TOP); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelConfig.fontSize); + return label; + } + + + + bool testgsensonView::testGsonsonScrollViewcrollViewinit(void) + { + uint32_t tick; + osStatus_t retTimer; + + // CompassModel::GetInstance()->OpenCompassSensor(); + + testGsonsonScrollView = new UIScrollView(); + if (testGsonsonScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::testGsonsonScrollView new fail!"); + return false; + } + testGsonsonScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + testGsonsonScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + testGsonsonScrollView->SetStyle(STYLE_BORDER_RADIUS, 1294); + + testGsonsonScrollView->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + MG_TEST_FALG=0; + + Gsenson_TEST_timer = osTimerNew((osTimerFunc_t)mgdataTimerCallBack, osTimerPeriodic, NULL, NULL); + tick =1000;// osMs2Tick(1000); + retTimer = osTimerStart(Gsenson_TEST_timer, tick); + if (retTimer != osOK && Gsenson_TEST_timer != NULL) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer); + osTimerDelete(Gsenson_TEST_timer); + Gsenson_TEST_timer = NULL; + return false; + } + + testGsonsonScrollView->SetScrollBlankSize(0); + testGsonsonScrollView->SetReboundSize(0); + testGsonsonScrollView->SetDirection(1); + //UIView::OnDragListener *draglistener = static_cast(SystemPresenter::GetInstance()); + // if (draglistener == nullptr) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::draglistener can not be nullptr!"); + // return false; + // } + // testGsonsonScrollView->SetOnDragListener(draglistener); + + LabelConfig Config = { + .left = 203, + .top = 52, + .width = 60, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "GSENSON", + .lineBreakMode = UILabel::LINE_BREAK_ADAPT, + }; + title = InitLabel(Config); + if (title == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemAboutTheWatchTitle new fail!"); + return false; + } + testGsonsonScrollView->Add(title); + /* -------------------------------------------------------------------------- */ + uint16_t angle_value= (int16_t)mag_service_get_fAzimuth(); + gsenson_t t; + //get_gsonsen_xyz(&t); + char buf[124]={0}; + sprintf(buf,"X:%f\nY:%f\nZ:%f",t.x,t.y,t.z); + Config = { + .left = 173, + .top = 160, + .width = 120, + .height = 35, + .fontSize = 40, + .lineHeigh = 35, + .text = buf, + .lineBreakMode = UILabel::LINE_BREAK_ADAPT, + }; + + x = InitLabel(Config); + if (x == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::WatchNameTitle new fail!"); + return false; + } + testGsonsonScrollView->Add(x); + /* -------------------------------------------------------------------------- */ + + labelButton_next= testAboutView::GetInstance()->init_button_next(167,378,"luminanceButton_next"); + testGsonsonScrollView->Add(labelButton_next); + + + testGsonsonScrollView->SetTouchable(true); + testGsonsonScrollView->SetDraggable(false); + + + + + return true; + } + + UIScrollView *testgsensonView::testGSENSONInitIView() + { + if (!testGsonsonScrollViewcrollViewinit()) + { + return nullptr; + } + return testGsonsonScrollView; + } +} \ No newline at end of file diff --git a/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h b/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h index 979346879..c62c3cdc1 100644 --- a/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h +++ b/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h @@ -32,6 +32,7 @@ extern void* CWM_OS_malloc(int size); extern void CWM_OS_free(void *ptr); extern void CWM_OS_saveData(uint8_t* data, uint32_t len); extern void CWM_OS_restoreData(uint8_t* data, uint32_t len); + /********************CYWEE LIB*************************/ #define SPORT_ACTIVE_MODE_NORMAL 1001 // 一般模式(生活模式) normal(base) 1001 @@ -112,6 +113,15 @@ typedef struct int sub_mode_number;// int[2] = sub_mode_number (預設: 0) }set_activity_mode_t; +typedef struct { + uint16_t x; + uint16_t y; + uint16_t z; + // uint16_t x_1; + // uint16_t y_1; + // uint16_t z_1; +} gsenson_t; + #if 1 /** @@ -417,6 +427,9 @@ typedef struct int mag_axis_setting;// int[2] = mag_axis setting (0: default, 1-24: axis_mode) }input_sensor_config_t; + +extern void get_gsonsen_xyz(gsenson_t *t); + #pragma pack() diff --git a/code/sdk/drivers/peripheral/cywee/src/main_dml.c b/code/sdk/drivers/peripheral/cywee/src/main_dml.c index 3804615eb..017442ccb 100644 --- a/code/sdk/drivers/peripheral/cywee/src/main_dml.c +++ b/code/sdk/drivers/peripheral/cywee/src/main_dml.c @@ -8,19 +8,100 @@ #include "power_display_service.h" #include "ppg_service.h" #include "broadcast_feature.h" +#include "cmsis_os2.h" +#include "osal_msgqueue.h" +#include "osal_mutex.h" #define AP_ENABLE_DML_SDO_LISTEN +int16_t gsensor_x[24] = {0}; +int16_t gsensor_y[24] = {0}; +int16_t gsensor_z[24] = {0}; +#define GSENSON_MSG_COUNT 16 +osal_mutex mutex_gsenson_queue; +static unsigned long gsenson_queue; + +void uapi_GSENSON_create_queue(void) +{ + if (osal_msg_queue_create("battery_queue", GSENSON_MSG_COUNT, &gsenson_queue, + 0, sizeof(gsenson_t)) != ERRCODE_SUCC) { + //PRINT("[battery][service] app create mail fail\n"); + } + + osal_mutex_init(&mutex_gsenson_queue); +} + +static gsenson_t gxyz_t; +static uint8_t gsenson_falg=0; +void get_gsonsen_xyz(gsenson_t *t) +{ + if(osal_mutex_trylock(&mutex_gsenson_queue)==0) + { + CWM_OS_dbgPrintf("get_gsonsen_xyz_fail\n"); + return; + } + t->x=gxyz_t.x; + t->y=gxyz_t.y; + t->z=gxyz_t.z; + CWM_OS_dbgPrintf("get_gsonsen_%d,%d,%d\n",t->x, t->y,t->z); + osal_mutex_unlock(&mutex_gsenson_queue); +} void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { switch (sensorEVT->sensorType) { case IDX_ACCEL: - #if 0 - CWM_OS_dbgPrintf("acc: x=%.3f, y=%.3f, z=%.3f\n", - sensorEVT->fData[0], - sensorEVT->fData[1], - sensorEVT->fData[2] - ); + #if 1 + // CWM_OS_dbgPrintf("acc: x=%.3f, y=%.3f, z=%.3f\n", + // sensorEVT->fData[0], + // sensorEVT->fData[1], + // sensorEVT->fData[2] + // ); + if(osal_msg_queue_is_full(gsenson_queue)) + { + + gsenson_t t; + int ret=osal_msg_queue_read_copy(gsenson_queue, &t, sizeof(gsenson_t),OSAL_MSGQ_NO_WAIT); + if(osal_mutex_trylock(&mutex_gsenson_queue)==0) + { + CWM_OS_dbgPrintf("get_gsonsen_xxxxxxxx_fail\n"); + break; + } + gxyz_t.x=t.x; + gxyz_t.y=t.y; + gxyz_t.z=t.z; + osal_mutex_unlock(&mutex_gsenson_queue); + + if(ret!=0) + { + CWM_OS_dbgPrintf("osal_msg_queue_read_copyz_fail\n"); + } + t.x=sensorEVT->fData[0]*1024; + t.y=sensorEVT->fData[1]*1024; + t.z=sensorEVT->fData[2]*1024; + ret=osal_msg_queue_write_copy(gsenson_queue, &t, sizeof(gsenson_t),OSAL_MSGQ_NO_WAIT); + if(ret!=0) + { + CWM_OS_dbgPrintf("osal_msg_queue_write_copy_fail\n"); + } + + + } + else + { + gsenson_t t; + t.x=sensorEVT->fData[0]; + t.y=sensorEVT->fData[1]; + t.z=sensorEVT->fData[2]; + int ret= osal_msg_queue_write_copy(gsenson_queue, &t, sizeof(gsenson_t),OSAL_MSGQ_NO_WAIT); + if(ret!=0) + { + CWM_OS_dbgPrintf("osal_msg_queue_write_copy_fail\n"); + } + + + } + + #endif break;