From 789fe4db7e559fa106228ac630d70b17e3a44a70 Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Thu, 25 Sep 2025 14:56:04 +0800 Subject: [PATCH] =?utf8?q?GPS=E4=BA=A7=E6=B5=8B=E7=95=8C=E9=9D=A2=E5=A2=9E?= =?utf8?q?=E5=8A=A0=E7=BA=AF=E5=8C=97=E6=96=97=E5=AE=9A=E4=BD=8D=E6=A8=A1?= =?utf8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/producttest/include/testGPS.h | 43 +- .../nativeui/producttest/include/testView.h | 32 +- .../nativeui/producttest/src/testGPS.cpp | 546 +++++++++++---- .../producttest/src/testPresenter.cpp | 58 +- .../nativeui/producttest/src/testView.cpp | 640 +++++++++--------- .../gnss/sample/pgnss_sample/pgnss_sample.c | 121 +++- .../gnss/sample/pgnss_sample/pgnss_sample.h | 6 +- 7 files changed, 914 insertions(+), 532 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testGPS.h b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testGPS.h index 95ad12d04..c96492dda 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testGPS.h +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testGPS.h @@ -1,16 +1,10 @@ -/* - * @Author: penglei 1624952103@qq.com - * @Date: 2025-06-06 15:56:46 - * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-07-21 14:07:39 - * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testGPS.h - * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE - */ #ifndef TEST_GPS__VIEW_H #define TEST_GPS__VIEW_H -#include "BaseView.h" + #include "View.h" +#include "components/ui_view.h" +#include "components/ui_view_group.h" #include "components/ui_scroll_view.h" #include "components/ui_label.h" #include "components/ui_label_ext.h" @@ -24,6 +18,7 @@ namespace OHOS { #define GPS_CLOSE_CANCEL_BUTTON "gps_close" #define GPS_OPEN_CONFIRM_BUTTON "gps_open" + #define BDS_OPEN_CONFIRM_BUTTON "bds_open" class testGPSView { @@ -42,7 +37,7 @@ namespace OHOS //label int label_x; int label_y; - uint8_t ALIGN; + UITextLanguageAlignment ALIGN; int Fontsize; }; @@ -68,19 +63,41 @@ namespace OHOS virtual ~testGPSView(); static testGPSView *GetInstance(void); - UIScrollView *testGPSInitIView(uint8_t); + UIViewGroup *testGPSInitIView(uint8_t); void gpsdataTimerCallBack(void); void ClearAll(void); + + // 按钮状态管理函数 + void SetGPSButtonActive(bool isActive); + void ToggleGPSState(); // 切换GPS开关状态 + void SetBDSButtonActive(bool isActive); + void ToggleBDSState(); // 切换北斗开关状态 + + // 按钮互斥控制函数 + void SetGPSButtonEnabled(bool enabled); + void SetBDSButtonEnabled(bool enabled); + void UpdateButtonStates(); // 更新按钮状态 private: UILabelButtonExt *SetTheButton_ext(ButtonConfig_ext_t &buttonconfig);//, UIView::OnTouchListener *clickListener); UILabel *InitLabel(LabelConfig &labelConfig); bool testGPSScrollViewcrollViewinit(uint8_t); - UIScrollView *testGPSScrollView{nullptr}; - UIImageView *tempImage{nullptr}; + + // 主容器和固定元素 + UIViewGroup *mainContainer{nullptr}; // 主容器 + UIScrollView *contentScrollView{nullptr}; // 可滚动内容区域 UILabel *label_1_GPS_MSG=NULL; UILabel *label_1_GPS_on_or_off{nullptr}; UILabelButtonExt* GPSbutton[2]{nullptr}; + UILabelButtonExt* BDSButton{nullptr}; // 北斗按钮 + + // GPS状态变量 + bool gpsIsOn{false}; // GPS开关状态 + bool bdsIsOn{false}; // 北斗开关状态 + + // 按钮禁用状态变量 + bool gpsButtonEnabled{true}; // GPS按钮是否可点击 + bool bdsButtonEnabled{true}; // 北斗按钮是否可点击 UILabelButtonExt* labelButton_next = nullptr; bool initViewStatus{false}; 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 2999a25b1..65999088d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testView.h @@ -55,9 +55,7 @@ namespace OHOS static testView *GetInstance(void); void OnStart() override; - void OnSetUpView() override; - void OnTearDownView() override; - void OnStop() override; + struct ButtonConfig { int x; @@ -77,14 +75,13 @@ namespace OHOS const char *ViewId; const char *ImageSrc; - //label + // label int label_x; int label_y; uint8_t ALIGN; - int Fontsize; - + int Fontsize; }; - + bool ChangeSystemView(int16_t thisView); bool ChangeSystemAboutView(int16_t thisView); bool ChangeLCDTESTView(int16_t thisView); @@ -118,15 +115,16 @@ namespace OHOS private: void InitIView(void); - void initView_ext(int x,int y,int w,int h,int interval,const char *imagsrc); + void initView_ext(int x, int y, int w, int h, int interval, const char *imagsrc); void ClearAll(void); bool SetTheSystemScrollView(void); bool SetTheTitle(void); UIButton *SetTheButton(ButtonConfig &buttonconfig, UIView::OnClickListener *clickListener); UILabelButtonExt *SetTheButton_ext(ButtonConfig_ext_t &ButtonConfig_ext, UIView::OnClickListener *clickListener); - + testAboutView *test_about_view; UIScrollView *SystemScrollView[30]{nullptr}; + UIViewGroup *group{nullptr}; UILabel *SystemLabel{nullptr}; // 标题 UILabelButtonExt *SystemUpgradeButtonExt{nullptr}; @@ -160,16 +158,16 @@ namespace OHOS UILabelButtonExt *button[30]={NULL}; bool initViewStatus{false}; }; - struct test_ext + struct test_ext { - const int16_t viewId; - char *viewid_str; - char *Labe_str; - char *viewid_str_next; - bool (testView::*func)(int16_t thisView); - bool enable_falg; + const int16_t viewId; + char *viewid_str; + char *Labe_str; + char *viewid_str_next; + bool (testView::*func)(int16_t thisView); + bool enable_falg; }; - extern test_ext Test_ViewMapper_t[]; + extern test_ext Test_ViewMapper_t[]; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testGPS.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testGPS.cpp index 3813dcede..04dfa7ced 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testGPS.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testGPS.cpp @@ -2,17 +2,20 @@ #include "custom_utils.h" #include "producttest/include/testPresenter.h" // #include "producttest/include/testcat1.h" -#include "AlarmClockModel.h" +#include "alarm/include/AlarmClockModel.h" #include "cmsis_os2.h" #if defined(SUPPORT_GNSS) #include "NMEA0183.h" #include "pgnss_sample.h" +#include "gnss_ctl.h" // code/sdk/zhihui/services/gnss/inc/.h #include "producttest/include/testView.h" #include "producttest/include/testGPS.h" +#include "producttest/include/testModel.h" +#include "uicomponents/UIComponents.h" // #include "gnss_sample.h" #include "graphic_service.h" namespace OHOS @@ -22,7 +25,7 @@ namespace OHOS testGPSView::testGPSView() { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::SystemAboutTheWatchView"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "testGPSView::testGPSView"); g_pSystemAboutTheWatchView = this; } @@ -42,60 +45,91 @@ namespace OHOS void testGPSView::ClearAll() { - if(testGPSScrollView) + if (GPS_TEST_timer != NULL) { + osTimerStop(GPS_TEST_timer); + osTimerDelete(GPS_TEST_timer); + GPS_TEST_timer = NULL; + } + + // 清理固定元素 - 先从父组件中移除,再删除 + if(labelButton_next) { - testGPSScrollView->RemoveAll(); - - if (GPS_TEST_timer != NULL) { - osTimerStop(GPS_TEST_timer); - osTimerDelete(GPS_TEST_timer); - GPS_TEST_timer = NULL; + if(mainContainer && mainContainer->GetChildrenNumber() > 0) { + mainContainer->Remove(labelButton_next); } - if(labelButton_next) - { - delete labelButton_next; - labelButton_next=nullptr; - } - if(label_1_GPS_MSG) - { - delete label_1_GPS_MSG; - label_1_GPS_MSG=nullptr; + delete labelButton_next; + labelButton_next=nullptr; + } + if(label_1_GPS_MSG) + { + if(contentScrollView && contentScrollView->GetChildrenNumber() > 0) { + contentScrollView->Remove(label_1_GPS_MSG); } - - if(label_1_GPS_on_or_off) - { - delete label_1_GPS_on_or_off; - label_1_GPS_on_or_off=nullptr; + delete label_1_GPS_MSG; + label_1_GPS_MSG=nullptr; + } + if(label_1_GPS_on_or_off) + { + if(mainContainer && mainContainer->GetChildrenNumber() > 0) { + mainContainer->Remove(label_1_GPS_on_or_off); } - - if(Title) - { - delete Title; - Title=nullptr; + delete label_1_GPS_on_or_off; + label_1_GPS_on_or_off=nullptr; + } + if(Title) + { + if(mainContainer && mainContainer->GetChildrenNumber() > 0) { + mainContainer->Remove(Title); } - - if(GPSbutton[0]) - { - delete GPSbutton[0]; - GPSbutton[0]=nullptr; + delete Title; + Title=nullptr; + } + if(GPSbutton[0]) + { + if(mainContainer && mainContainer->GetChildrenNumber() > 0) { + mainContainer->Remove(GPSbutton[0]); } - - if(GPSbutton[1]) - { - delete GPSbutton[1]; - GPSbutton[1]=nullptr; + delete GPSbutton[0]; + GPSbutton[0]=nullptr; + } + if(GPSbutton[1]) + { + if(mainContainer && mainContainer->GetChildrenNumber() > 0) { + mainContainer->Remove(GPSbutton[1]); } - - if(tempImage) - { - delete tempImage; - tempImage = nullptr; + delete GPSbutton[1]; + GPSbutton[1]=nullptr; + } + if(BDSButton) + { + if(mainContainer && mainContainer->GetChildrenNumber() > 0) { + mainContainer->Remove(BDSButton); } - + delete BDSButton; + BDSButton=nullptr; + } - delete testGPSScrollView; - testGPSScrollView=nullptr; - } + // 清理滚动内容区域 + if(contentScrollView) + { + contentScrollView->RemoveAll(); + // 如果contentScrollView是mainContainer的子组件,先从mainContainer中移除 + if(mainContainer && mainContainer->GetChildrenNumber() > 0) { + mainContainer->Remove(contentScrollView); + } + delete contentScrollView; + contentScrollView=nullptr; + } + + // 清理主容器 - 最后清理 + if(mainContainer) + { + mainContainer->RemoveAll(); + // 如果mainContainer是RootView的子组件,先从RootView中移除 + RootView::GetInstance()->Remove(mainContainer); + delete mainContainer; + mainContainer=nullptr; + } } UILabelButtonExt *testGPSView::SetTheButton_ext(ButtonConfig_ext_t &buttonconfig) @@ -108,21 +142,222 @@ namespace OHOS } button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h); button->SetViewId(buttonconfig.ViewId); + + // 默认状态:蓝色背景 button->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full); - //button->SetStyle(STYLE_BORDER_RADIUS,0); + button->SetStyle(STYLE_BACKGROUND_OPA, 0x80); + + // 按下状态:深灰色背景 button->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::Black().full, UIButton::PRESSED); - //button->SetStyleForState(STYLE_BORDER_RADIUS,0, UIButton::PRESSED); + button->SetStyleForState(STYLE_BACKGROUND_OPA, 0xff, UIButton::PRESSED); + button->SetTouchable(true); - button->SetStyle(STYLE_BACKGROUND_OPA, 0x80); button->SetText(buttonconfig.str); - button->SetAlign(TEXT_ALIGNMENT_LEFT); - button->SetLabelPosition(buttonconfig.label_x,buttonconfig.label_y ); + button->SetAlign(buttonconfig.ALIGN); // 使用配置的对齐方式 + button->SetLabelPosition(buttonconfig.label_x, buttonconfig.label_y); button->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, buttonconfig.Fontsize); - UIView:: OnClickListener *touchListener = static_cast(testPresenter::GetInstance()); + + UIView::OnClickListener *touchListener = static_cast(testPresenter::GetInstance()); button->SetOnClickListener(touchListener); return button; } + + void testGPSView::SetGPSButtonActive(bool isActive) + { + if (GPSbutton[0] != nullptr) + { + if (isActive) + { + // 激活状态:绿色背景,文字显示"关" + GPSbutton[0]->SetStyle(STYLE_BACKGROUND_COLOR, Color::Green().full); + GPSbutton[0]->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + GPSbutton[0]->SetText("关"); + } + else + { + // 默认状态:蓝色背景,文字显示"开" + GPSbutton[0]->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full); + GPSbutton[0]->SetStyle(STYLE_BACKGROUND_OPA, 0x80); + GPSbutton[0]->SetText("开"); + } + } + + // 强制刷新界面 + RootView::GetInstance()->Invalidate(); + } + + void testGPSView::ToggleGPSState() + { + // 检查按钮是否被禁用 + if (!gpsButtonEnabled) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GPS Toggle: Button is disabled, ignoring click"); + return; + } + + // 切换GPS状态 + gpsIsOn = !gpsIsOn; + + // 更新按钮颜色和文字 + SetGPSButtonActive(gpsIsOn); + + // 更新按钮状态(互斥逻辑) + UpdateButtonStates(); + + // 根据状态执行相应操作 + if (gpsIsOn) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GPS Toggle: Turning ON (Button: Green '关')"); + + // 检查GPS是否已经在运行 + if (getPGnssServerStat() == 1) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GPS Toggle: GPS already running, skipping start"); + return; + } + + gnss_start(); + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GPS Toggle: Turning OFF (Button: Blue '开')"); + + // 检查GPS是否已经停止 + if (getPGnssServerStat() == 0) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GPS Toggle: GPS already stopped, skipping stop"); + return; + } + + gnss_stop(); + } + } + + void testGPSView::SetBDSButtonActive(bool isActive) + { + if (BDSButton != nullptr) + { + if (isActive) + { + // 激活状态:绿色背景,文字显示"关" + BDSButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Green().full); + BDSButton->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + BDSButton->SetText("北斗关"); + } + else + { + // 默认状态:蓝色背景,文字显示"开" + BDSButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full); + BDSButton->SetStyle(STYLE_BACKGROUND_OPA, 0x80); + BDSButton->SetText("北斗开"); + } + } + + // 强制刷新界面 + RootView::GetInstance()->Invalidate(); + } + + void testGPSView::ToggleBDSState() + { + // 检查按钮是否被禁用 + if (!bdsButtonEnabled) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BDS Toggle: Button is disabled, ignoring click"); + return; + } + + // 切换北斗状态 + bdsIsOn = !bdsIsOn; + + // 更新按钮颜色和文字 + SetBDSButtonActive(bdsIsOn); + + // 更新按钮状态(互斥逻辑) + UpdateButtonStates(); + + // 根据状态设置北斗标志位 + if (bdsIsOn) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BDS Toggle: Setting BDS mode flag (Button: Green '关')"); + + // 设置北斗模式标志位 + setBDSModeFlag(1); + gnss_start(); + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BDS Toggle: Setting GPS mode flag (Button: Blue '开')"); + + // 设置GPS模式标志位 + setBDSModeFlag(0); + gnss_stop(); + } + } + + // 按钮启用/禁用控制函数 + void testGPSView::SetGPSButtonEnabled(bool enabled) + { + gpsButtonEnabled = enabled; + if (GPSbutton[0] != nullptr) { + GPSbutton[0]->SetTouchable(enabled); + if (enabled) { + // 启用状态:恢复正常颜色 + if (gpsIsOn) { + GPSbutton[0]->SetStyle(STYLE_BACKGROUND_COLOR, Color::Green().full); + GPSbutton[0]->SetText("关"); + } else { + GPSbutton[0]->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full); + GPSbutton[0]->SetText("开"); + } + } else { + // 禁用状态:灰色,保持原有文字 + GPSbutton[0]->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full); + GPSbutton[0]->SetStyle(STYLE_BACKGROUND_OPA, 0x60); + // 不改变文字内容,保持原有的"开"或"关" + } + } + RootView::GetInstance()->Invalidate(); + } + + void testGPSView::SetBDSButtonEnabled(bool enabled) + { + bdsButtonEnabled = enabled; + if (BDSButton != nullptr) { + BDSButton->SetTouchable(enabled); + if (enabled) { + // 启用状态:恢复正常颜色 + if (bdsIsOn) { + BDSButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Green().full); + BDSButton->SetText("北斗关"); + } else { + BDSButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full); + BDSButton->SetText("北斗开"); + } + } else { + // 禁用状态:灰色,保持原有文字 + BDSButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full); + BDSButton->SetStyle(STYLE_BACKGROUND_OPA, 0x60); + // 不改变文字内容,保持原有的"北斗开"或"北斗关" + } + } + RootView::GetInstance()->Invalidate(); + } + + void testGPSView::UpdateButtonStates() + { + // 互斥逻辑:如果GPS开启,禁用北斗按钮;如果北斗开启,禁用GPS按钮 + if (gpsIsOn) { + // GPS开启,禁用北斗按钮 + SetBDSButtonEnabled(false); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GPS is ON, disabling BDS button"); + } else if (bdsIsOn) { + // 北斗开启,禁用GPS按钮 + SetGPSButtonEnabled(false); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BDS is ON, disabling GPS button"); + } else { + // 两个都关闭,启用所有按钮 + SetGPSButtonEnabled(true); + SetBDSButtonEnabled(true); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Both OFF, enabling all buttons"); + } + } UILabel *testGPSView::InitLabel(LabelConfig &labelConfig) { @@ -147,7 +382,6 @@ namespace OHOS void testGPSView:: gpsdataTimerCallBack(void) { if (label_1_GPS_MSG != nullptr) { - gps_data_t * gpsdata=getPGPSGlobaldata(); gps_data_t gpsd={0}; if (gpsdata->last_gps_time_ms>0) @@ -175,124 +409,145 @@ namespace OHOS bool testGPSView::testGPSScrollViewcrollViewinit(uint8_t id) { - - testGPSScrollView = new UIScrollView(); - if (testGPSScrollView == nullptr) + // 创建主容器(固定布局) + mainContainer = new UIViewGroup(); + if (mainContainer == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::testGPSScrollView new fail!"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "testGPSView::mainContainer new fail!"); return false; } - testGPSScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - testGPSScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - testGPSScrollView->SetStyle(STYLE_BORDER_RADIUS, 0); - testGPSScrollView->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - testGPSScrollView->SetStyle(STYLE_BORDER_COLOR, Color::Yellow().blue); - testGPSScrollView->SetScrollBlankSize(75); - + mainContainer->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + mainContainer->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + mainContainer->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + + // 固定元素:标题(顶部固定) + Title = testAboutView::GetInstance()->init_title(165, 15, "GPS_TEST"); + mainContainer->Add(Title); + + // 固定元素:GPS状态显示(顶部固定,居中) LabelConfig Config = { - .left = 50, - .top = 85, - .width = Screen::GetInstance().GetWidth()-80, + .left = (Screen::GetInstance().GetWidth() - 200) / 2, // 居中显示 + .top = 55, + .width = 200, .height = 35, - .fontSize = 20, - .lineHeigh = 25, + .fontSize = 25, // 增大字体 + .lineHeigh = 35, .text = "", .lineBreakMode = UILabel::LINE_BREAK_WRAP, }; - label_1_GPS_MSG= InitLabel(Config); - if (label_1_GPS_MSG == nullptr) + label_1_GPS_on_or_off = InitLabel(Config); + if (label_1_GPS_on_or_off == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemAboutTheWatchTitle new fail!"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "testGPSView::label_1_GPS_on_or_off new fail!"); return false; } - testGPSScrollView->Add(label_1_GPS_MSG); - + label_1_GPS_on_or_off->SetAlign(TEXT_ALIGNMENT_CENTER); // 设置文字居中对齐 + mainContainer->Add(label_1_GPS_on_or_off); + + // 固定元素:下一页按钮(右上角固定) + labelButton_next = testAboutView::GetInstance()->init_button_next(320, 55, Test_ViewMapper_t[id].viewid_str_next); + mainContainer->Add(labelButton_next); + + // 固定元素:GPS开关按钮(左侧) + ButtonConfig_ext_t buttonconfig; + buttonconfig.x = (Screen::GetInstance().GetWidth() - 300) / 2; // 左侧位置 + buttonconfig.y = 100; + buttonconfig.w = 120; // 调整宽度 + buttonconfig.h = 70; // 保持高度 + buttonconfig.label_x = 0; // 文字居中,不需要偏移 + buttonconfig.label_y = 0; + buttonconfig.Fontsize = 30; // 增大字体大小 + buttonconfig.ViewId = GPS_OPEN_CONFIRM_BUTTON; + buttonconfig.str = "开"; // 改为"开" + buttonconfig.ALIGN = TEXT_ALIGNMENT_CENTER; // 居中对齐 + GPSbutton[0] = SetTheButton_ext(buttonconfig); + mainContainer->Add(GPSbutton[0]); + + // 固定元素:北斗开关按钮(右侧) + buttonconfig.x = (Screen::GetInstance().GetWidth() - 300) / 2 + 150; // 右侧位置 + buttonconfig.y = 100; + buttonconfig.w = 120; // 调整宽度 + buttonconfig.h = 70; // 保持高度 + buttonconfig.label_x = 0; // 文字居中,不需要偏移 + buttonconfig.label_y = 0; + buttonconfig.Fontsize = 30; // 增大字体大小 + buttonconfig.ViewId = BDS_OPEN_CONFIRM_BUTTON; + buttonconfig.str = "北斗开"; // 改为"开" + buttonconfig.ALIGN = TEXT_ALIGNMENT_CENTER; // 居中对齐 + BDSButton = SetTheButton_ext(buttonconfig); + mainContainer->Add(BDSButton); + + // 将第二个按钮设为空,不再使用 + GPSbutton[1] = nullptr; + + // 确保按钮初始状态为蓝色(GPS和北斗关闭状态) + SetGPSButtonActive(false); + SetBDSButtonActive(false); + + // 初始化按钮状态(两个按钮都启用) + UpdateButtonStates(); + + // 创建可滚动内容区域(下半部分) + contentScrollView = new UIScrollView(); + if (contentScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "testGPSView::contentScrollView new fail!"); + return false; + } + int scrollY = 190; // 固定元素下方开始滚动区域 + int scrollHeight = Screen::GetInstance().GetHeight() - scrollY; + contentScrollView->SetPosition(0, scrollY, Screen::GetInstance().GetWidth(), scrollHeight); + contentScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + contentScrollView->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + + // 优化滚动体验参数 - 完全消除惯性 + contentScrollView->SetScrollBlankSize(100); // 增大滚动空白区域,允许底部继续滑动 + contentScrollView->SetReboundSize(0); // 设置为0,消除回弹惯性 + contentScrollView->SetDirection(1); // 垂直滚动 + contentScrollView->SetThrowDrag(false); // 关闭抛掷滚动惯性 + contentScrollView->SetMaxScrollDistance(0); // 设置为0,消除最大滚动距离惯性 + contentScrollView->SetSwipeACCLevel(0); // 关闭滑动加速度补偿 + contentScrollView->SetYScrollBarVisible(true); // 显示滚动条 + + // 在可滚动区域添加GPS详细信息 Config = { - .left = 50, - .top = 50, - .width = 350, - .height = 30, - .fontSize = 25, - .lineHeigh = 35, + .left = 20, + .top = 20, // 相对于滚动视图的位置 + .width = Screen::GetInstance().GetWidth()-40, + .height = 200, // 足够的高度容纳GPS信息 + .fontSize = 20, // 增大GPS信息字体 + .lineHeigh = 25, .text = "", .lineBreakMode = UILabel::LINE_BREAK_WRAP, }; - label_1_GPS_on_or_off= InitLabel(Config); - if (label_1_GPS_on_or_off == nullptr) + label_1_GPS_MSG = InitLabel(Config); + if (label_1_GPS_MSG == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemAboutTheWatchTitle new fail!"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "testGPSView::label_1_GPS_MSG new fail!"); return false; } - testGPSScrollView->Add(label_1_GPS_on_or_off); + contentScrollView->Add(label_1_GPS_MSG); - ButtonConfig_ext_t buttonconfig; - buttonconfig.x = 20; - buttonconfig.y = 400; - buttonconfig.w = 180; - buttonconfig.h = 96; - buttonconfig.label_x=40; - buttonconfig.label_y=0; - buttonconfig.Fontsize=30; - buttonconfig.ViewId=GPS_OPEN_CONFIRM_BUTTON; - buttonconfig.str=GPS_OPEN_CONFIRM_BUTTON; - buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT; - GPSbutton[0]=SetTheButton_ext(buttonconfig); - testGPSScrollView->Add( GPSbutton[0]); - //testcat1ScrollView->Add(button); - - buttonconfig.x = 220; - buttonconfig.y = 400; - buttonconfig.w = 180; - buttonconfig.h = 96; - buttonconfig.label_x=40; - buttonconfig.label_y=0; - buttonconfig.Fontsize=30; - buttonconfig.ViewId=GPS_CLOSE_CANCEL_BUTTON; - buttonconfig.str=GPS_CLOSE_CANCEL_BUTTON; - buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT; - GPSbutton[1]=SetTheButton_ext(buttonconfig); - testGPSScrollView->Add( GPSbutton[1]); + // 为可滚动区域设置拖拽属性和监听器 + contentScrollView->SetTouchable(true); + contentScrollView->SetDraggable(true); - - - + // 设置拖拽监听器以支持左滑退出功能 UIView::OnDragListener *draglistener = static_cast(testPresenter::GetInstance()); - if (draglistener == nullptr) + if (draglistener != nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::draglistener can not be nullptr!"); - return false; + contentScrollView->SetOnDragListener(draglistener); // 恢复左滑退出功能 } - testGPSScrollView->SetOnDragListener(draglistener); - - - labelButton_next= testAboutView::GetInstance()->init_button_next(267,320,Test_ViewMapper_t[id].viewid_str_next); - testGPSScrollView->Add(labelButton_next); - Title= testAboutView::GetInstance()->init_title(165,45,"GPS_TEST"); - testGPSScrollView->Add(Title); - - - if (tempImage == nullptr) - { - tempImage = new UIImageView(); - if (tempImage == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "tempImage can not be nullptr!"); - return false; - } - } - tempImage->SetPosition(193, GPSbutton[0]->GetY()+GPSbutton[0]->GetHeight() + 60, 40, 40); - testGPSScrollView->Add(tempImage); - - + // 将滚动区域添加到主容器 + mainContainer->Add(contentScrollView); - testGPSScrollView->SetTouchable(true); - testGPSScrollView->SetDraggable(true); + // 启动GPS数据更新定时器 uint32_t tick; osStatus_t retTimer; GPS_TEST_timer = osTimerNew((osTimerFunc_t)gpsdataTimerCallBackproc, osTimerPeriodic, NULL, NULL); - tick =2000;// osMs2Tick(1000); + tick = 2000; retTimer = osTimerStart(GPS_TEST_timer, tick); if (retTimer != osOK && GPS_TEST_timer != NULL) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer); @@ -303,13 +558,14 @@ namespace OHOS return true; } - UIScrollView *testGPSView::testGPSInitIView(uint8_t id) + UIViewGroup *testGPSView::testGPSInitIView(uint8_t id) { if (!testGPSScrollViewcrollViewinit(id)) { return nullptr; } - return testGPSScrollView; + // 返回主容器(包含固定元素和可滚动区域) + return mainContainer; } } 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 493765764..7db69b8e0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPresenter.cpp @@ -164,17 +164,40 @@ namespace OHOS { return true; } + + // 放宽的左滑退出限制条件 if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { - for (int i = 1; i < MAX_TESTVIEWID; i++) + // 获取拖拽的起始点和结束点 + Point startPoint = event.GetStartPoint(); + Point endPoint = event.GetLastPoint(); + + // 计算拖拽距离和速度 + int dragDistance = endPoint.x - startPoint.x; + int dragHeight = abs(endPoint.y - startPoint.y); + + // 放宽的退出条件: + // 1. 水平拖拽距离大于80像素(从150降低到80) + // 2. 垂直偏移不超过80像素(从50放宽到80) + // 3. 起始点在屏幕左侧50%区域内(从30%放宽到50%) + // 4. 水平拖拽距离大于垂直偏移的2倍(从3倍降低到2倍) + int screenWidth = Screen::GetInstance().GetWidth(); + + if (dragDistance > 80 && // 最小拖拽距离80像素 + dragHeight < 80 && // 垂直偏移不超过80像素 + startPoint.x < screenWidth * 0.5 && // 起始点在左侧50%区域 + dragDistance > dragHeight * 2) // 水平距离是垂直距离的2倍以上 { - if (p_SystemView->GetSystemScrollView(i)) + for (int i = 1; i < MAX_TESTVIEWID; i++) { - p_SystemView->ChangeView(i, TESTVIEW); - break; + if (p_SystemView->GetSystemScrollView(i)) + { + p_SystemView->ChangeView(i, TESTVIEW); + break; + } } + return true; } - return true; } return false; } @@ -376,16 +399,25 @@ namespace OHOS #if defined(SUPPORT_GNSS) if (strcmp(view.GetViewId(), GPS_OPEN_CONFIRM_BUTTON) == 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GPS On OnClick"); - gnss_start(); - + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GPS Toggle Button OnClick"); + + // 切换GPS开关状态 + testGPSView* gpsView = testGPSView::GetInstance(); + if (gpsView != nullptr) + { + gpsView->ToggleGPSState(); + } } - - - if (strcmp(view.GetViewId(), GPS_CLOSE_CANCEL_BUTTON) == 0) + else if (strcmp(view.GetViewId(), BDS_OPEN_CONFIRM_BUTTON) == 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GPS On OnClick"); - gnss_stop(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BDS Toggle Button OnClick"); + + // 切换北斗开关状态 + testGPSView* gpsView = testGPSView::GetInstance(); + if (gpsView != nullptr) + { + gpsView->ToggleBDSState(); + } } #endif return false; 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 b3c1bd231..ece6d4e90 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testView.cpp @@ -1,5 +1,8 @@ #include "producttest/include/testView.h" #include "producttest/include/testPresenter.h" +#include "producttest/include/testModel.h" +#include "components/ui_label_button.h" +#include "components/root_view.h" #include "power_display_service.h" #include "wearable_log.h" #ifdef SUPPORT_CAT1_SERVICE @@ -37,47 +40,45 @@ namespace OHOS static testView *g_pSystemView{nullptr}; // 2.ViewMapper[] 是一个静态的视图映射数组,将视图ID与MainStopWatchView类中的特定成员函数指针进行了绑定。 - test_ext Test_ViewMapper_t[] = { - {TESTVIEW,"","","",&testView::ChangeSystemAboutView,false},//占位,空的 - {VISON,"AboutTheWatchButton","Verison","AboutTheWatchButton_next",&testView::ChangeSystemAboutView,true}, - {LCD,"LCDButton","LCD","LCDButton_next",&testView::ChangeLCDTESTView,true}, - {TP,"TPButton","TP","TPButton_next", &testView::ChangeTPTESTView,true}, - {MAGETIC,"MAGETICButton","Magetic","MAGETICButton_next", &testView::ChangeMGTESTView,true}, - {LUMINANCE,"luminanceButton","luminance","luminanceButton_next", &testView::ChangLUMTESTView,true}, - {CHARG,"chargingButton","bat&charger","chargingButton_next",&testView::ChangchargingTESTView,true}, - {SPEAK,"speakButton","speak","speakButton_next" ,&testView::ChangspeakTESTView,true}, - - {MOTOR,"motorButton","motor","motorButton_next" ,&testView::ChangmotorTESTView,true}, - #ifdef SUPPORT_CAT1_SERVICE - {CAT1,"cat1button","CAT1", "cat1button_next",&testView::ChangeCAT1TESTView,true}, - #endif - {BUTTON,"buttonbutton","button" ,"buttonbutton_next",&testView::ChangKEYTESTView,true}, - {MICROPHONE,"microphonebutton","microphone", "microphonebutton_next",&testView::ChangeMPTESTView,true}, - {HRSENSON,"hrsensonbutton","hrsensor", "hrsensonbutton_next",&testView::ChangeHRTESTView,true}, - {GSENSON,"gsensonbutton","gsensor","gsensonbutton_next" ,&testView::ChangeGTESTView,true}, + test_ext Test_ViewMapper_t[] = { + {TESTVIEW, "", "", "", &testView::ChangeSystemAboutView, false}, // 占位,空的 + {VISON, "AboutTheWatchButton", "Verison", "AboutTheWatchButton_next", &testView::ChangeSystemAboutView, true}, + {LCD, "LCDButton", "LCD", "LCDButton_next", &testView::ChangeLCDTESTView, true}, + {TP, "TPButton", "TP", "TPButton_next", &testView::ChangeTPTESTView, true}, + {MAGETIC, "MAGETICButton", "Magetic", "MAGETICButton_next", &testView::ChangeMGTESTView, true}, + {LUMINANCE, "luminanceButton", "luminance", "luminanceButton_next", &testView::ChangLUMTESTView, true}, + {CHARG, "chargingButton", "bat&charger", "chargingButton_next", &testView::ChangchargingTESTView, true}, + {SPEAK, "speakButton", "speak", "speakButton_next", &testView::ChangspeakTESTView, true}, + {MOTOR, "motorButton", "motor", "motorButton_next", &testView::ChangmotorTESTView, true}, +#ifdef SUPPORT_CAT1_SERVICE + {CAT1, "cat1button", "CAT1", "cat1button_next", &testView::ChangeCAT1TESTView, true}, +#endif + {BUTTON, "buttonbutton", "Button", "buttonbutton_next", &testView::ChangKEYTESTView, true}, + {MICROPHONE, "microphonebutton", "microphone", "microphonebutton_next", &testView::ChangeMPTESTView, true}, + {HRSENSON, "hrsensonbutton", "hrsensor", "hrsensonbutton_next", &testView::ChangeHRTESTView, true}, + {GSENSON, "gsensonbutton", "gsensor", "gsensonbutton_next", &testView::ChangeGTESTView, true}, + {BTTEST, "BTbutton", "BT", "BTbutton_next", &testView::ChangeBTTESTView, true}, + {SEChipTest, "SEChipTestbutton", "SEChipTest", "SEChipTestbutton_next", &testView::ChangeSEChipTESTView, true}, + // {PingTest, "PingTestbutton", "PingTest", "PingTestbutton_next", &testView::ChangePingTESTView, true}, #if defined(SUPPORT_GNSS) - {GPSTEST,"GPSTestbutton","GPSTest","GPSTestbutton_next" ,&testView::ChangeGPSTESTView,true}, + {GPSTEST, "GPSTestbutton", "GPSTest", "GPSTestbutton_next", &testView::ChangeGPSTESTView, true}, #endif - {BTTEST,"BTbutton","BT" ,"BTbutton_next",&testView::ChangeBTTESTView,true}, - {SEChipTest,"SEChipTestbutton","SEChipTest","SEChipTestbutton_next" ,&testView::ChangeSEChipTESTView,true}, - {PingTest,"PingTestbutton","PingTest","PingTestbutton_next" ,&testView::ChangePingTESTView,true}, -#if defined(ENABLE_LQBP002TA) - {PRESSURETEST,"pressureTestbutton","pressureTest","pressureTestbutton_next" ,&testView::ChangepressureTestTESTView,true}, +#ifdef ENABLE_LQBP002TA + {PRESSURETEST, "pressureTestbutton", "pressureTest", "pressureTestbutton_next", &testView::ChangepressureTestTESTView, true}, +#endif +#ifdef AGINGTEST + {OLDTEST, "oldtestbutton", "aging", "oldtestexit", &testView::ChangeoldTESTView, true}, +#endif + {DEEPSLEEP, "deepsleep", "DeepSleepCurrent", "xxxxxxxxx", &testView::ChangeoldTESTView, true}, + {shutdown, "shutdown", "shutdown", "xxxxxxxxx", &testView::ChangeoldTESTView, true}, + {RESET, "reset", "reset", "xxxxxxxxx", &testView::ChangeoldTESTView, true}, + {FACTORYRESE, "FactoryReset", "FactoryReset", "xxxxxxxxx", &testView::ChangeoldTESTView, true}, +#ifdef SUPPORT_A5133_SERVICE + {RF5133, "RF5133", "RF5133", "xxxxxxxxx", &testView::ChangeA5133TESTView, true}, #endif -// #if defined(ENABLE_GYRO) -// {GYROTEST,"gyroTestbutton","gyroTest","gyroTestbutton_next" ,&testView::ChangegyroTestTESTView,true}, -// #endif - {OLDTEST,"oldtestbutton","aging" ,"oldtestexit",&testView::ChangeoldTESTView,true}, - {DEEPSLEEP,"deepsleep","DeepSleepCurrent","xxxxxxxxx" ,&testView::ChangeoldTESTView,true}, - {shutdown,"shutdown","shutdown", "xxxxxxxxx",&testView::ChangeoldTESTView,true}, - {RESET,"reset","reset", "xxxxxxxxx",&testView::ChangeoldTESTView,true}, - {FACTORYRESE,"FactoryReset","FactoryReset","xxxxxxxxx", &testView::ChangeoldTESTView,true}, - #ifdef SUPPORT_A5133_SERVICE - {RF5133,"RF5133","RF5133", "xxxxxxxxx",&testView::ChangeA5133TESTView,true}, - #endif }; - + testView::testView() { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "testView::testView"); @@ -98,111 +99,125 @@ namespace OHOS void testView::ClearAll() { - if (initViewStatus == true) + if (group) { - SystemScrollView[TESTVIEW]->RemoveAll(); - int funcSize = sizeof(Test_ViewMapper_t) / sizeof(Test_ViewMapper_t[TESTVIEW]); - for (int i = 0; i < funcSize; i++) + group->RemoveAll(); + delete group; + group = nullptr; + if (SystemScrollView[TESTVIEW]) { - if(button[i]) + SystemScrollView[TESTVIEW]->RemoveAll(); + delete SystemScrollView[TESTVIEW]; + SystemScrollView[TESTVIEW] = nullptr; + delete SystemLabel; + SystemLabel = nullptr; + int funcSize = sizeof(Test_ViewMapper_t) / sizeof(Test_ViewMapper_t[TESTVIEW]); + for (int i = 0; i < funcSize; i++) { - delete button[i]; - button[i]=NULL; + if (button[i]) + { + delete button[i]; + button[i] = NULL; + } } } - if(test_about_view) - { - delete test_about_view; //1 - test_about_view = nullptr; - } - - if(test_LCD_view) - { - delete test_LCD_view; //2 + } + if (test_about_view) + { + delete test_about_view; // 1 + test_about_view = nullptr; + } + + if (test_LCD_view) + { + delete test_LCD_view; // 2 test_LCD_view = nullptr; - } - if(test_TP_view) - { - delete test_TP_view; //3 + } + if (test_TP_view) + { + delete test_TP_view; // 3 test_TP_view = nullptr; - } - if(test_lum_view) - { - delete test_lum_view;//4 + } + if (test_lum_view) + { + delete test_lum_view; // 4 test_lum_view = nullptr; - } - if(test_charging_view) - { - delete test_charging_view;//5 + } + if (test_charging_view) + { + delete test_charging_view; // 5 test_charging_view = nullptr; - } - if(test_speak_view) - { - delete test_speak_view;//6 + } + if (test_speak_view) + { + delete test_speak_view; // 6 test_speak_view = nullptr; - } - if(test_motor_view) - { - delete test_motor_view;//7 + } + if (test_motor_view) + { + delete test_motor_view; // 7 test_motor_view = nullptr; - } + } #ifdef SUPPORT_CAT1_SERVICE - if(test_cat1_view) - { - delete test_cat1_view;//8 + if (test_cat1_view) + { + delete test_cat1_view; // 8 test_cat1_view = nullptr; - } + } #endif - if(test_KEY_view) - { - delete test_KEY_view;//9 + if (test_KEY_view) + { + delete test_KEY_view; // 9 test_KEY_view = nullptr; - } - if(test_MG_view) - { - delete test_MG_view;//10 + } + if (test_MG_view) + { + delete test_MG_view; // 10 test_MG_view = nullptr; - } - if(test_hr_view) - { - delete test_hr_view;//11 + } + if (test_hr_view) + { + delete test_hr_view; // 11 test_hr_view = nullptr; - } - if(test_MP_view) - { - delete test_MP_view;//12 + } + if (test_MP_view) + { + delete test_MP_view; // 12 test_MP_view = nullptr; - } - if(test_G_view) - { - delete test_G_view;//13 - test_G_view= nullptr; - } + } + if (test_G_view) + { + delete test_G_view; // 13 + test_G_view = nullptr; + } #ifdef SUPPORT_A5133_SERVICE - if(test_A5133_view) - { - delete test_A5133_view;//13 - test_A5133_view= nullptr; - } + if (test_A5133_view) + { + delete test_A5133_view; // 13 + test_A5133_view = nullptr; + } #endif - // delete test_G_view;//13 - // test_G_view= nullptr; + // delete test_G_view;//13 + // test_G_view= nullptr; - delete SystemLabel; - SystemLabel = nullptr; - if(SystemScrollView[TESTVIEW]) - { - delete SystemScrollView[TESTVIEW]; - SystemScrollView[TESTVIEW] = nullptr; - } - for(int i=1;i<13;i++) - { - if(SystemScrollView[i]) - SystemScrollView[i] = nullptr; - } - + for (int i = 1; i < 13; i++) + { + if (SystemScrollView[i]) + SystemScrollView[i] = nullptr; + } + if (test_Ping_view) + { + delete test_Ping_view; // PingTest + test_Ping_view = nullptr; + } +#ifdef SUPPORT_GNSS + if (test_GPS_view) + { + delete test_GPS_view; // GPS + test_GPS_view = nullptr; } +#endif } /// @brief 设置SystemScrollView @@ -315,33 +330,30 @@ namespace OHOS buttonconfig.w = w; buttonconfig.h = h; - int len =sizeof(Test_ViewMapper_t)/sizeof(Test_ViewMapper_t[0]); + int len = sizeof(Test_ViewMapper_t) / sizeof(Test_ViewMapper_t[0]); - for(int i=1;iAdd(SystemScrollView[thisView]); + group->Add(SystemScrollView[thisView]); } return true; } @@ -359,7 +371,7 @@ namespace OHOS return false; } SystemScrollView[thisView] = test_about_view->SystemAbouTheWatchtInitIView(thisView); - RootView::GetInstance()->Add(SystemScrollView[thisView]); + group->Add(SystemScrollView[thisView]); } return true; } @@ -376,7 +388,7 @@ namespace OHOS return false; } SystemScrollView[thisView] = test_LCD_view->testLCDInitIView(thisView); - RootView::GetInstance()->Add(SystemScrollView[thisView]); + group->Add(SystemScrollView[thisView]); } return true; } @@ -393,12 +405,12 @@ namespace OHOS return false; } SystemScrollView[thisView] = test_TP_view->testTPInitIView(thisView); - RootView::GetInstance()->Add(SystemScrollView[thisView]); + group->Add(SystemScrollView[thisView]); } return true; } - bool testView::ChangeMGTESTView(int16_t thisView) + bool testView::ChangeMGTESTView(int16_t thisView) { if (SystemScrollView[thisView] == nullptr) { @@ -410,7 +422,7 @@ namespace OHOS return false; } SystemScrollView[thisView] = test_MG_view->testmagicInitIView(thisView); - RootView::GetInstance()->Add(SystemScrollView[thisView]); + group->Add(SystemScrollView[thisView]); } return true; } @@ -427,11 +439,11 @@ namespace OHOS return false; } SystemScrollView[thisView] = test_lum_view->testLUMInitIView(thisView); - RootView::GetInstance()->Add(SystemScrollView[thisView]); + group->Add(SystemScrollView[thisView]); } return true; } - + bool testView::ChangchargingTESTView(int16_t thisView) { if (SystemScrollView[thisView] == nullptr) @@ -444,7 +456,7 @@ namespace OHOS return false; } SystemScrollView[thisView] = test_charging_view->testCHANINGInitIView(thisView); - RootView::GetInstance()->Add(SystemScrollView[thisView]); + group->Add(SystemScrollView[thisView]); } return true; } @@ -461,7 +473,7 @@ namespace OHOS return false; } SystemScrollView[thisView] = test_speak_view->testSPEAKInitIView(thisView); - RootView::GetInstance()->Add(SystemScrollView[thisView]); + group->Add(SystemScrollView[thisView]); } return true; } @@ -478,14 +490,14 @@ namespace OHOS return false; } SystemScrollView[thisView] = test_motor_view->testMOTORInitIView(thisView); - RootView::GetInstance()->Add(SystemScrollView[thisView]); + group->Add(SystemScrollView[thisView]); } return true; } - bool testView::ChangeCAT1TESTView(int16_t thisView) + bool testView::ChangeCAT1TESTView(int16_t thisView) { - #ifdef SUPPORT_CAT1_SERVICE +#ifdef SUPPORT_CAT1_SERVICE if (SystemScrollView[thisView] == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeCAT1TESTView"); @@ -496,9 +508,9 @@ namespace OHOS return false; } SystemScrollView[thisView] = test_cat1_view->testcat1InitIView(thisView); - RootView::GetInstance()->Add(SystemScrollView[thisView]); + group->Add(SystemScrollView[thisView]); } - #endif +#endif return true; } @@ -514,7 +526,7 @@ namespace OHOS return false; } SystemScrollView[thisView] = test_KEY_view->testBUTTONInitIView(thisView); - RootView::GetInstance()->Add(SystemScrollView[thisView]); + group->Add(SystemScrollView[thisView]); } return true; } @@ -531,7 +543,7 @@ namespace OHOS return false; } SystemScrollView[thisView] = test_MP_view->testmicrophoneInitIView(thisView); - RootView::GetInstance()->Add(SystemScrollView[thisView]); + group->Add(SystemScrollView[thisView]); } return true; } @@ -548,12 +560,11 @@ namespace OHOS return false; } SystemScrollView[thisView] = test_hr_view->testhrsensonInitIView(thisView); - RootView::GetInstance()->Add(SystemScrollView[thisView]); + group->Add(SystemScrollView[thisView]); } return true; } - bool testView::ChangeGTESTView(int16_t thisView) { if (SystemScrollView[thisView] == nullptr) @@ -566,14 +577,14 @@ namespace OHOS return false; } SystemScrollView[thisView] = test_G_view->testGSENSONInitIView(thisView); - RootView::GetInstance()->Add(SystemScrollView[thisView]); + group->Add(SystemScrollView[thisView]); } return true; } - - bool testView::ChangeoldTESTView(int16_t thisView) + bool testView::ChangeoldTESTView(int16_t thisView) { +#ifdef AGINGTEST if (SystemScrollView[thisView] == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeoldTESTView"); @@ -584,12 +595,11 @@ namespace OHOS return false; } SystemScrollView[thisView] = test_old_view->testoldInitIView(thisView); - RootView::GetInstance()->Add(SystemScrollView[thisView]); + group->Add(SystemScrollView[thisView]); } +#endif return true; - } - bool testView::ChangeBTTESTView(int16_t thisView) { @@ -603,12 +613,11 @@ namespace OHOS return false; } SystemScrollView[thisView] = test_BT_view->testBTInitIView(thisView); - RootView::GetInstance()->Add(SystemScrollView[thisView]); + group->Add(SystemScrollView[thisView]); } return true; } - bool testView::ChangeSEChipTESTView(int16_t thisView) { if (SystemScrollView[thisView] == nullptr) @@ -621,7 +630,7 @@ namespace OHOS return false; } SystemScrollView[thisView] = test_SEChip_view->SEChipInitIView(thisView); - RootView::GetInstance()->Add(SystemScrollView[thisView]); + group->Add(SystemScrollView[thisView]); } return true; } @@ -630,7 +639,7 @@ namespace OHOS { if (SystemScrollView[thisView] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSEChipTESTView"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangePingTESTView"); test_Ping_view = new testPingView(); if (test_Ping_view == nullptr) { @@ -638,7 +647,7 @@ namespace OHOS return false; } SystemScrollView[thisView] = test_Ping_view->testPingInitIView(thisView); - RootView::GetInstance()->Add(SystemScrollView[thisView]); + group->Add(SystemScrollView[thisView]); } return true; } @@ -656,15 +665,15 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); return false; } - SystemScrollView[thisView] = test_GPS_view->testGPSInitIView((uint8_t)thisView); - RootView::GetInstance()->Add(SystemScrollView[thisView]); + SystemScrollView[thisView] = static_cast(test_GPS_view->testGPSInitIView((uint8_t)thisView)); + group->Add(SystemScrollView[thisView]); } return true; } #endif -#if defined(ENABLE_LQBP002TA) - bool testView::ChangepressureTestTESTView(int16_t thisView) +#ifdef ENABLE_LQBP002TA + bool testView::ChangepressureTestTESTView(int16_t thisView) { if (SystemScrollView[thisView] == nullptr) @@ -677,33 +686,11 @@ namespace OHOS return false; } SystemScrollView[thisView] = test_pressure_view->testpressureInitIView((uint8_t)thisView); - RootView::GetInstance()->Add(SystemScrollView[thisView]); - } - - - return true; - } -#endif -#if defined(ENABLE_GYRO) - bool testView::ChangegyroTestTESTView(int16_t thisView) - { - - if (SystemScrollView[thisView] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSEChipTESTView"); - test_gyro_view = new testgyroView(); - if (test_gyro_view == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); - return false; - } - SystemScrollView[thisView] = test_gyro_view->testgyroInitIView((uint8_t)thisView); - RootView::GetInstance()->Add(SystemScrollView[thisView]); + group->Add(SystemScrollView[thisView]); } return true; } - #endif #ifdef SUPPORT_A5133_SERVICE bool testView::ChangeA5133TESTView(int16_t thisView) @@ -718,7 +705,7 @@ namespace OHOS return false; } SystemScrollView[thisView] = test_A5133_view->testA5133InitIView(thisView); - RootView::GetInstance()->Add(SystemScrollView[thisView]); + group->Add(SystemScrollView[thisView]); } return true; } @@ -735,7 +722,7 @@ namespace OHOS /* -------------------------------------------------------------------------- */ // 1.MainStopWatchViewMapper:结构体定义了一个将视图ID映射到特定成员函数指针的映射表。 - + // 3.根据传入的interface参数执行相应视图ID关联的成员函数。 bool testView::ClickFunc(int16_t interface) { @@ -763,226 +750,215 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: SystemViewId Overstep ones bounds"); return; } - SystemScrollView[hideView]->SetVisible(false); + if (SystemScrollView[hideView] != nullptr) + { + SystemScrollView[hideView]->SetVisible(false); + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: SystemScrollView[%d] is nullptr", hideView); + } ClickFunc(showView); - SystemScrollView[showView]->SetVisible(true); - Draw(); - if(hideView!=0) + if (SystemScrollView[showView] != nullptr) + { + SystemScrollView[showView]->SetVisible(true); + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: SystemScrollView[%d] is nullptr", showView); + } + if (hideView != 0) { - switch (hideView) - { + switch (hideView) + { case VISON: - RootView::GetInstance()->Remove(SystemScrollView[hideView]); - delete test_about_view; + group->Remove(SystemScrollView[hideView]); + delete test_about_view; test_about_view = nullptr; - SystemScrollView[hideView]=nullptr; - break; + SystemScrollView[hideView] = nullptr; + break; case LCD: - RootView::GetInstance()->Remove(SystemScrollView[hideView]); - delete test_LCD_view; + group->Remove(SystemScrollView[hideView]); + delete test_LCD_view; test_LCD_view = nullptr; - SystemScrollView[hideView]=nullptr; - break; + SystemScrollView[hideView] = nullptr; + break; case TP: - RootView::GetInstance()->Remove(SystemScrollView[hideView]); - delete test_TP_view; + group->Remove(SystemScrollView[hideView]); + delete test_TP_view; test_TP_view = nullptr; - SystemScrollView[hideView]=nullptr; - break; + SystemScrollView[hideView] = nullptr; + break; case MAGETIC: - RootView::GetInstance()->Remove(SystemScrollView[hideView]); - delete test_MG_view; + group->Remove(SystemScrollView[hideView]); + delete test_MG_view; test_MG_view = nullptr; - SystemScrollView[hideView]=nullptr; - break; + SystemScrollView[hideView] = nullptr; + break; case LUMINANCE: - RootView::GetInstance()->Remove(SystemScrollView[hideView]); - delete test_lum_view; + group->Remove(SystemScrollView[hideView]); + delete test_lum_view; test_lum_view = nullptr; - SystemScrollView[hideView]=nullptr; - break; + SystemScrollView[hideView] = nullptr; + break; case CHARG: - RootView::GetInstance()->Remove(SystemScrollView[hideView]); - delete test_charging_view; + group->Remove(SystemScrollView[hideView]); + delete test_charging_view; test_charging_view = nullptr; - SystemScrollView[hideView]=nullptr; - break; + SystemScrollView[hideView] = nullptr; + break; case SPEAK: - RootView::GetInstance()->Remove(SystemScrollView[hideView]); - delete test_speak_view; + group->Remove(SystemScrollView[hideView]); + delete test_speak_view; test_speak_view = nullptr; - SystemScrollView[hideView]=nullptr; - break; + SystemScrollView[hideView] = nullptr; + break; case MOTOR: - RootView::GetInstance()->Remove(SystemScrollView[hideView]); - delete test_motor_view; + group->Remove(SystemScrollView[hideView]); + delete test_motor_view; test_motor_view = nullptr; - SystemScrollView[hideView]=nullptr; - break; + SystemScrollView[hideView] = nullptr; + break; #ifdef SUPPORT_CAT1_SERVICE - case CAT1: - RootView::GetInstance()->Remove(SystemScrollView[hideView]); - delete test_cat1_view; + case CAT1: + group->Remove(SystemScrollView[hideView]); + delete test_cat1_view; test_cat1_view = nullptr; - SystemScrollView[hideView]=nullptr; - break; + SystemScrollView[hideView] = nullptr; + break; #endif - case BUTTON: - RootView::GetInstance()->Remove(SystemScrollView[hideView]); - delete test_KEY_view; + case BUTTON: + group->Remove(SystemScrollView[hideView]); + delete test_KEY_view; test_KEY_view = nullptr; - SystemScrollView[hideView]=nullptr; - break; + SystemScrollView[hideView] = nullptr; + break; case MICROPHONE: - RootView::GetInstance()->Remove(SystemScrollView[hideView]); - delete test_MP_view; + group->Remove(SystemScrollView[hideView]); + delete test_MP_view; test_MP_view = nullptr; - SystemScrollView[hideView]=nullptr; - break; + SystemScrollView[hideView] = nullptr; + break; case HRSENSON: - RootView::GetInstance()->Remove(SystemScrollView[hideView]); - delete test_hr_view; + group->Remove(SystemScrollView[hideView]); + delete test_hr_view; test_hr_view = nullptr; - SystemScrollView[hideView]=nullptr; - break; + SystemScrollView[hideView] = nullptr; + break; case GSENSON: - RootView::GetInstance()->Remove(SystemScrollView[hideView]); - delete test_G_view; + group->Remove(SystemScrollView[hideView]); + delete test_G_view; test_G_view = nullptr; - SystemScrollView[hideView]=nullptr; - break; + SystemScrollView[hideView] = nullptr; + break; case OLDTEST: - RootView::GetInstance()->Remove(SystemScrollView[hideView]); - delete test_old_view; + group->Remove(SystemScrollView[hideView]); + delete test_old_view; test_old_view = nullptr; - SystemScrollView[hideView]=nullptr; + SystemScrollView[hideView] = nullptr; break; case BTTEST: - RootView::GetInstance()->Remove(SystemScrollView[hideView]); - delete test_BT_view; + group->Remove(SystemScrollView[hideView]); + delete test_BT_view; test_BT_view = nullptr; - SystemScrollView[hideView]=nullptr; + SystemScrollView[hideView] = nullptr; break; case SEChipTest: - RootView::GetInstance()->Remove(SystemScrollView[hideView]); - delete test_SEChip_view; + group->Remove(SystemScrollView[hideView]); + delete test_SEChip_view; test_SEChip_view = nullptr; - SystemScrollView[hideView]=nullptr; - break; - case PingTest: - RootView::GetInstance()->Remove(SystemScrollView[hideView]); - delete test_Ping_view; - test_Ping_view = nullptr; - SystemScrollView[hideView]=nullptr; + SystemScrollView[hideView] = nullptr; break; + // case PingTest: + // group->Remove(SystemScrollView[hideView]); + // delete test_Ping_view; + // test_Ping_view = nullptr; + // SystemScrollView[hideView] = nullptr; + // break; #if defined(SUPPORT_GNSS) case GPSTEST: - RootView::GetInstance()->Remove(SystemScrollView[hideView]); - delete test_GPS_view; + group->Remove(SystemScrollView[hideView]); + delete test_GPS_view; test_GPS_view = nullptr; - SystemScrollView[hideView]=nullptr; - break; + SystemScrollView[hideView] = nullptr; + break; #endif #ifdef SUPPORT_A5133_SERVICE case RF5133: - RootView::GetInstance()->Remove(SystemScrollView[hideView]); - delete test_A5133_view; + group->Remove(SystemScrollView[hideView]); + delete test_A5133_view; test_A5133_view = nullptr; - SystemScrollView[hideView]=nullptr; + SystemScrollView[hideView] = nullptr; break; #endif #if defined(ENABLE_LQBP002TA) - case PRESSURETEST: - RootView::GetInstance()->Remove(SystemScrollView[hideView]); - delete test_pressure_view; + case PRESSURETEST: + group->Remove(SystemScrollView[hideView]); + delete test_pressure_view; test_pressure_view = nullptr; - SystemScrollView[hideView]=nullptr; + SystemScrollView[hideView] = nullptr; break; #endif -// #if defined(ENABLE_GYRO) -// case GYROTEST: -// RootView::GetInstance()->Remove(SystemScrollView[hideView]); -// delete test_gyro_view; -// test_gyro_view = nullptr; -// SystemScrollView[hideView]=nullptr; -// break; -// #endif - - default: - break; - } - } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "change>>>>>>>>>>>hideView %d > showView %d >>>",hideView,showView); - + default: + break; + } + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "change>>>>>>>>>>>hideView %d > showView %d >>>", hideView, showView); } /* -------------------------------------------------------------------------- */ void testView::OnStart() { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnStart>>>>>>>>>>>>>"); - View::OnStart(); - //InitIView(); - initView_ext(43,120,380,100,120,"/user/res/SETTING_NEXT.bin"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnStart>>>>>>>>>>>>>"); + + if (group == nullptr) + { + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::WatchQRCodeGroupView new fail!"); + } + } + group->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + group->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + group->SetTouchable(true); + group->SetDraggable(true); + + // InitIView(); + initView_ext(43, 120, 380, 100, 120, "/user/res/SETTING_NEXT.bin"); const power_display_svr_api_t *display_api = power_display_svr_get_api(); if (display_api->get_screen_state() != SCREEN_ON) - { - display_api->turn_on_screen(); - } + { + display_api->turn_on_screen(); + } display_api->set_auto_timeout_function(false); uint8_t cnt = pm_veto_get_id_cnt(PM_ID_P_TEST); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cnt : %d\n",cnt); - if (cnt == 0) + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cnt : %d\n", cnt); + if (cnt == 0) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_pm_add_sleep_veto(PM_ID_P_TEST);"); uapi_pm_add_sleep_veto(PM_ID_P_TEST); } - uapi_set4GCapability(true); + if (!uapi_dev_runtime_get_factory_test_status_flag()) + uapi_set4GCapability(true); start_custom_ble_service(); - } - void testView::OnSetUpView() - { - View::OnSetUpView(); if (SystemScrollView[TESTVIEW] == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: OnSetUpView has nullptr"); return; } - SystemScrollView[TESTVIEW]->Add(SystemLabel); - - int len =sizeof(Test_ViewMapper_t)/sizeof(Test_ViewMapper_t[0]); - - for(int i=0;iAdd(button[i]); + SystemScrollView[TESTVIEW]->Add(button[i]); } - - // SystemScrollView[SYSTEMVIEW]->Add(SuperviseButton); - // SystemScrollView[SYSTEMVIEW]->Add(SystemLanguageButton); - // SystemScrollView[SYSTEMVIEW]->Add(FactoryResetButton); - // SystemScrollView[SYSTEMVIEW]->Add(SystemUpgradeButtonExt); - - RootView::GetInstance()->Add(SystemScrollView[TESTVIEW]); - Draw(); - } - - void testView::OnTearDownView() - { - - View::OnTearDownView(); - return; - } - - void testView::OnStop() - { - - View::OnStop(); - RootView::GetInstance()->RemoveAll(); - return; + group->Add(SystemScrollView[TESTVIEW]); + RootView::GetInstance()->Add(group); } } \ No newline at end of file diff --git a/code/sdk/drivers/peripheral/gnss/sample/pgnss_sample/pgnss_sample.c b/code/sdk/drivers/peripheral/gnss/sample/pgnss_sample/pgnss_sample.c index ad761479b..2b39f55a8 100644 --- a/code/sdk/drivers/peripheral/gnss/sample/pgnss_sample/pgnss_sample.c +++ b/code/sdk/drivers/peripheral/gnss/sample/pgnss_sample/pgnss_sample.c @@ -53,6 +53,9 @@ static int g_is_pgnss_logon=0; static int g_pgnss_stopflag=0; static int g_cold_start_pgnss_stopflag = 0; +/**北斗定位标志位*/ +static int g_bds_mode_flag=0; // 0=GPS模式, 1=北斗模式 + static char *pgnss_log = NULL; static int32_t QryVersion(tiot_handle handle) @@ -104,6 +107,8 @@ const uint8_t CFG_TRK_LPW_DISABLE[] = {0x03, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, const uint8_t CFG_ACQ_LPW_DISABLE[] = {0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00}; const uint8_t CFG_ANTIJAM_ENABLE[] = {0x03, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x08, 0x00, 0x06, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00}; +const uint8_t CFG_BDS_MODE[] = {0x03,0x00,0x08 ,0x00 ,0x00 ,0x00 ,0x08 ,0x00 ,0x00 ,0x00 ,0x04 ,0x00 ,0x04 ,0x00 ,0x00 ,0x00}; + // 普通GNSS冷启动配置函数实现 int32_t CfgColdStartFixModeGpsNmeaAll(tiot_handle handle) { @@ -114,11 +119,26 @@ int32_t CfgColdStartFixModeGpsNmeaAll(tiot_handle handle) return 0; } - // 配置使能的GNSS星座:GPS - ret = tiot_service_write(handle, cfgFixModeAllCmd, sizeof(cfgFixModeAllCmd)); - if (ret < 0) { - printf("\nerror: cfgFixModeAllCmd error: %d\r\n", ret); - return 0; + // 根据北斗标志位选择星座配置 + if(g_bds_mode_flag) + { + // 北斗模式:配置北斗星座 + ret = tiot_service_write(handle, CFG_BDS_MODE, sizeof(CFG_BDS_MODE)); + if (ret < 0) { + printf("\nerror: CFG_BDS_MODE error: %d\r\n", ret); + return 0; + } + printf("BDS constellation configured\r\n"); + } + else + { + // GPS模式:配置GPS星座 + ret = tiot_service_write(handle, cfgFixModeAllCmd, sizeof(cfgFixModeAllCmd)); + if (ret < 0) { + printf("\nerror: cfgFixModeAllCmd error: %d\r\n", ret); + return 0; + } + printf("GPS constellation configured\r\n"); } // 配置上报NMEA类型:PNT/ZDA/VTG/RMC/GSV/GSA/GLL/GGA @@ -146,10 +166,77 @@ int32_t CfgColdStartFixModeGpsNmeaAll(tiot_handle handle) return 0; } - printf("Cold start mode configured successfully\r\n"); + printf("Cold start mode configured successfully (Mode: %s)\r\n", g_bds_mode_flag ? "BDS" : "GPS"); return 1; } +// 北斗定位配置函数 - 简化版本,只配置必要的北斗参数 +int32_t CfgBDSMode(tiot_handle handle) +{ + // 配置北斗模式 + int32_t ret = tiot_service_write(handle, CFG_BDS_MODE, sizeof(CFG_BDS_MODE)); + if (ret < 0) { + printf("\nerror: CFG_BDS_MODE error: %d\r\n", ret); + return 0; + } + + // 配置启动模式:冷启动模式 + ret = tiot_service_write(handle, cfgColdStartCmd, sizeof(cfgColdStartCmd)); + if (ret < 0) { + printf("\nerror: cfgColdStartCmd error: %d\r\n", ret); + return 0; + } + + printf("BDS mode configured successfully (minimal config)\r\n"); + return 1; +} + +// // 北斗定位配置函数 - 完整版本(如果需要更多配置选项) +// int32_t CfgBDSModeFull(tiot_handle handle) +// { +// // 配置北斗模式 +// int32_t ret = tiot_service_write(handle, CFG_BDS_MODE, sizeof(CFG_BDS_MODE)); +// if (ret < 0) { +// printf("\nerror: CFG_BDS_MODE error: %d\r\n", ret); +// return 0; +// } + +// // 配置启动模式:冷启动模式 +// ret = tiot_service_write(handle, cfgColdStartCmd, sizeof(cfgColdStartCmd)); +// if (ret < 0) { +// printf("\nerror: cfgColdStartCmd error: %d\r\n", ret); +// return 0; +// } + +// // 配置上报NMEA类型:PNT/ZDA/VTG/RMC/GSV/GSA/GLL/GGA +// ret = tiot_service_write(handle, cfgNmeaAllCmd, sizeof(cfgNmeaAllCmd)); +// if (ret < 0) { +// printf("\nerror: cfgNmeaAllCmd error: %d\r\n", ret); +// return 0; +// } + +// ret = tiot_service_write(handle, CFG_TRK_LPW_DISABLE, sizeof(CFG_TRK_LPW_DISABLE)); +// if (ret < 0) { +// printf("\nerror: CFG_TRK_LPW_DISABLE error: %d\r\n", ret); +// return 0; +// } + +// ret = tiot_service_write(handle, CFG_ACQ_LPW_DISABLE, sizeof(CFG_ACQ_LPW_DISABLE)); +// if (ret < 0) { +// printf("\nerror: CFG_ACQ_LPW_DISABLE error: %d\r\n", ret); +// return 0; +// } + +// ret = tiot_service_write(handle, CFG_ANTIJAM_ENABLE, sizeof(CFG_ANTIJAM_ENABLE)); +// if (ret < 0) { +// printf("\nerror: CFG_ANTIJAM_ENABLE error: %d\r\n", ret); +// return 0; +// } + +// printf("BDS mode configured successfully (full config)\r\n"); +// return 1; +// } + // 修改后的PGNSS配置函数,支持降级到普通GNSS int32_t InjectPgnssWithFallbackToColdStart(tiot_handle handle) { @@ -260,10 +347,10 @@ static void ListenGnssData(tiot_handle handle) // 写日志 for (;;) { // 写日志条件 - if (i >= LISTEN_DATA_MAX_LINES) { - printf("\r\ncnt enough\r\n"); - break; - } + // if (i >= LISTEN_DATA_MAX_LINES) { + // printf("\r\ncnt enough\r\n"); + // break; + // } if (g_pgnss_stopflag == 1) { break; @@ -459,7 +546,7 @@ void PGnssServerStartColdStart(void) void PGnssServerStart(void) { //未绑定直接冷启动 - if(cm_getisFirstTimeStart()) + if(cm_getisFirstTimeStart() || g_bds_mode_flag) { printf("PGnssServerStartColdStart \n"); PGnssServerStartColdStart(); @@ -602,3 +689,15 @@ void PGnssServerStart(void) } } + +// 北斗标志位接口 +void setBDSModeFlag(int flag) +{ + g_bds_mode_flag = flag; + printf("BDS mode flag set to: %d\r\n", flag); +} + +int getBDSModeFlag(void) +{ + return g_bds_mode_flag; +} diff --git a/code/sdk/drivers/peripheral/gnss/sample/pgnss_sample/pgnss_sample.h b/code/sdk/drivers/peripheral/gnss/sample/pgnss_sample/pgnss_sample.h index 37d7d51dd..ea2268fdf 100644 --- a/code/sdk/drivers/peripheral/gnss/sample/pgnss_sample/pgnss_sample.h +++ b/code/sdk/drivers/peripheral/gnss/sample/pgnss_sample/pgnss_sample.h @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2025-07-11 16:41:59 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-07-18 17:39:28 + * @LastEditTime: 2025-09-25 14:37:39 * @FilePath: /FD230/code/sdk/drivers/peripheral/gnss/sample/pgnss_sample/pgnss_sample.h * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -20,6 +20,10 @@ extern "C" { void PGnssServerStart(void); void PGnssServerStop(void); int getPGnssServerStat(void); + +// 北斗标志位接口 +void setBDSModeFlag(int flag); +int getBDSModeFlag(void); #ifdef __cplusplus } #endif /* __cplusplus */ -- 2.17.1