From: Caisking <3449750381@qq.com> Date: Thu, 21 Dec 2023 06:41:49 +0000 (+0800) Subject: 增加XTS测试状态显示,更改测试逻辑 X-Git-Tag: release_V1.2.70_20241020_135402~1378 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=893e7043fa7cfc432d0ca355065c09046f185ed4;p=mirrors%2FFD230.git 增加XTS测试状态显示,更改测试逻辑 --- diff --git a/code/sdk/application/wearable/nativeapp/nativeui/clock/include/MainClockView.h b/code/sdk/application/wearable/nativeapp/nativeui/clock/include/MainClockView.h index a6769495b..2135b792f 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/clock/include/MainClockView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/clock/include/MainClockView.h @@ -89,47 +89,55 @@ private: class ProgressCallback : public AnimatorCallback { public: - explicit ProgressCallback(UIBoxProgress *progress, UILabel *label) : progress(progress), label(label) {} - ~ProgressCallback() {} + explicit ProgressCallback(UIBoxProgress *progress, UILabel *batterylabel, UILabel *XTSlabel) : progress(progress), batterylabel(batterylabel),XTSlabel(XTSlabel) {} + ~ProgressCallback() {} virtual void Callback(UIView *view) { - //int value = std::rand() % 101; // 生成一个介于 0 和 100 之间的随机数 - float voltage = 0.0F ; - // battery_get_voltage_by_channel(&voltage,channel); - uint8_t value = 0 ; - uint8_t xts_testing = 0 ; - + float voltage = 0.0F; + uint8_t value = 0; + uint8_t xts_testing = 1; uint32_t RunTime_ = HALTick::GetInstance().GetTime(); - - #ifdef XTS_SUPPORT + #ifdef XTS_SUPPORT xts_testing = is_xts_test_done(); - #endif - if(xts_testing){ + #endif + + if (!xts_testing) { + // XTS测试进行 + xts_flag = 1; + XTSlabel->SetText("XTS测试进行中"); + XTSlabel->SetTextColor(Color::GetColorFromRGBA(0xe6, 0x04, 0x09, 0xff)); value = 0; - printf("bat check stamp %u xts_testing %u\r\n",RunTime_,xts_testing); - return ; - }else{ + printf("bat check stamp %u xts_testing %u,xts_flag %u\r\n", RunTime_, xts_testing,xts_flag); + } else { + // XTS测试结束 + if (xts_flag) { + XTSlabel->SetText("XTS测试结束"); + XTSlabel->SetTextColor(Color::GetColorFromRGBA(0x4e, 0xe6, 0x04, 0xff)); + xts_flag = 0; // 复位 + } value = battery_get_voltage(&voltage); - printf("bat check stamp %u xts_testing %u\r\n",RunTime_,xts_testing); + printf("bat check stamp %u xts_testing %u,xts_flag %u\r\n", RunTime_, xts_testing,xts_flag); } + char* progress1ForeImageSrc = nullptr; char* progress1BackImageSrc = nullptr; if (value <= 10) { progress1ForeImageSrc = "/user/res/Battery/Battery_Limit.bin"; } else if (value <= 20) { progress1ForeImageSrc = "/user/res/Battery/Battery_Save.bin"; - } else { progress1ForeImageSrc = "/user/res/Battery/Battery_Nomoal.bin"; } + progress->SetImage(progress1ForeImageSrc, progress1BackImageSrc); progress->SetValue(value); // 更新界面 - label->SetText((std::to_string(value) + "%").c_str()); // 更新百分比显示 - //for(int i=0;i<1000000000;i++){}; + batterylabel->SetText((std::to_string(value) + "%").c_str()); // 更新百分比显示 } private: - UILabel *label{nullptr}; + uint8_t xts_flag = 0; //标志位 + UILabel *batterylabel{nullptr}; + UILabel *XTSlabel{nullptr}; UIBoxProgress *progress{nullptr}; //std::thread workerThread; //std::atomic stopThread; @@ -164,6 +172,7 @@ private: UILabel *batteryLabel{nullptr}; UILabel *weekLabel{nullptr}; UILabel *heartRateLabel{nullptr}; + UILabel *XTSLabel{nullptr}; ClockAnimatorCallback *callBack{nullptr}; Animator *clockAnimator{nullptr}; UISweepClock *mainSweepClock{nullptr}; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/clock/src/MainClockView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/clock/src/MainClockView.cpp index fba57b395..02e4dd151 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/clock/src/MainClockView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/clock/src/MainClockView.cpp @@ -456,6 +456,23 @@ bool MainClockView::InitSweepClock(void) weekLabel->SetRollSpeed(0); weekLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + // Add Label to App + if (XTSLabel == nullptr) { + XTSLabel = new UILabel(); + } + XTSLabel->SetPosition(130, 273); // widget's left position and top position + XTSLabel->Resize(200, 60); // widget's width and height + XTSLabel->SetViewId("label1");// Set style + XTSLabel->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + //XTSLabel->SetText("XTS测试进行中"); + XTSLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + //XTSLabel->SetTextColor(Color::GetColorFromRGBA(0xe6, 0x04, 0x09, 0xff)); + XTSLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + XTSLabel->SetRollSpeed(0); + XTSLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add BoxProgress to App if (progress == nullptr) { progress = new UIBoxProgress(); @@ -473,7 +490,7 @@ bool MainClockView::InitSweepClock(void) progress->SetForegroundStyle(STYLE_TEXT_COLOR, 0xff000000); progress->SetForegroundStyle(STYLE_LINE_COLOR, 0xff000000); progress->SetForegroundStyle(STYLE_LINE_WIDTH, 0); - char* progress1ForeImageSrc = "/user/res/Battery_Nomoal.bin"; + char* progress1ForeImageSrc = "/user/res/Battery/Battery_Nomoal.bin"; char * progress1BackImageSrc = nullptr; progress->SetImage(progress1ForeImageSrc, progress1BackImageSrc); @@ -524,6 +541,7 @@ bool MainClockView::InitView(void) mainSweepClock->Add(weekLabel); mainSweepClock->Add(dataLabel); mainSweepClock->Add(batteryLabel); + mainSweepClock->Add(XTSLabel); mainSweepClock->Add(progress); #if 0 mainSweepClock->Add(stepLabel); @@ -569,7 +587,7 @@ bool MainClockView::InitView(void) WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clockAnimator new fail"); return false; } - progress1callback_ = new ProgressCallback(progress,batteryLabel); + progress1callback_ = new ProgressCallback(progress,batteryLabel,XTSLabel); progress1animator_ = new Animator(progress1callback_,progress,10000,true); progress1animator_->Start(); clockAnimator->Start();