*/
bool MainClockView::InitBatteryView(BatteryDisplayType type)
{
- #if !(defined(BOARD_W9) || defined(BOARD_N9))// N9和W9需要显示电池
// 不显示电池 icon
if (type == BATTERY_DISPLAY_NONE)
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "no show battery");
return false;
}
- #endif
// 创建电池框图像
batteryiamge = new UIImageView();
struct tm local_time = {0};
time_t seconds = time(nullptr);
- // Get local time
if (localtime_r(&seconds, &local_time) == nullptr) {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "get localtime error!");
return;
}
- // Extract hour and minute
uint8_t hour = local_time.tm_hour % HOURS_IN_DAY;
uint8_t minute = local_time.tm_min % MINUTES_IN_HOUR;
char timebuf[64] = {0};
sprintf_s(timebuf, sizeof(timebuf), "%02d:%02d", hour, minute);
#endif
- // Update display labels
if (timerlabel != nullptr)
timerlabel->SetText(timebuf);
- // Update date and week day
+
std::string weekStr = Cnweekdays[local_time.tm_wday];
std::string dateStr = std::to_string(local_time.tm_mon + 1) + "月" +
std::to_string(local_time.tm_mday) + "号 " + weekStr;
if (datelabel != nullptr)
datelabel->SetText(dateStr.c_str());
- // Update battery status
- #if !(defined(BOARD_W9) || defined(BOARD_N9))// N9和W9需要显示电池
+
+ //电量显示配置
if (batterySetting == BATTERY_DISPLAY_NONE)
return;
- #endif
+
UpdateBatteryColor();