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<bool> stopThread;
UILabel *batteryLabel{nullptr};
UILabel *weekLabel{nullptr};
UILabel *heartRateLabel{nullptr};
+ UILabel *XTSLabel{nullptr};
ClockAnimatorCallback *callBack{nullptr};
Animator *clockAnimator{nullptr};
UISweepClock *mainSweepClock{nullptr};
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();
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);
mainSweepClock->Add(weekLabel);
mainSweepClock->Add(dataLabel);
mainSweepClock->Add(batteryLabel);
+ mainSweepClock->Add(XTSLabel);
mainSweepClock->Add(progress);
#if 0
mainSweepClock->Add(stepLabel);
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();