-#include "notification_manager.h"
-#include "wearable_log.h"
-#include "components/ui_label_button.h"
-#include "components/ui_image_view.h"
-#include "components/ui_label_ext.h"
-#include "components/ui_scroll_view.h"
#include "../notify/debug_output_notification/debug_output_notification_adapter.h"
#include "../notify/debug_output_notification/debug_output_notification_itemview.h"
-#include <custom_runtime.h>
-#include <custom_utils.h>
-#include <sstream>
-#include <iomanip>
-#include <sys/types.h>
-#include "bluetooth/include/BluetoothModel.h"
-#include "system/include/SystemLogModel.h"
-#include "wearable_log.h"
#include "AppViewIDs.h"
#include "NativeAbility.h"
+#include "battery_hal.h"
+#include "battery_service.h"
#include "bleEvent.h"
+#include "bluetooth/include/BluetoothModel.h"
#include "broadcast_feature.h"
#include "broadcast_service.h"
#include "cat1_ctl.h"
#include "cat1_server.h"
+#include "components/ui_image_view.h"
+#include "components/ui_label_button.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_scroll_view.h"
#include "custom_runtime.h"
#include "custom_utils.h"
#include "graphic_service.h"
#include "lwip/apps/http_client.h"
+#include "notification_manager.h"
#include "samgr_lite.h"
+#include "system/include/SystemLogModel.h"
#include "tcxo.h"
#include "thread_adapter.h"
#include "thread_init.h"
#include <array>
#include <cmsis_os2.h>
#include <cstdint>
+#include <custom_runtime.h>
+#include <custom_utils.h>
#include <fstream>
+#include <iomanip>
#include <iostream>
#include <map>
#include <service/graphic_service.h>
+#include <sstream>
#include <string>
+#include <sys/types.h>
#include <vector>
namespace OHOS
{
debugOutputItemInfo[index++] = {1, "bt_ble_connectstat"};
debugOutputItemInfo[index++] = {2, "cat1_runtime_status_t"};
debugOutputItemInfo[index++] = {3, "runtime_status_t"};
+ //系统日志
debugOutputItemInfo[index++] = {4, "system_log"};
+ //电池服务
+ debugOutputItemInfo[index++] = {5, "battery_service"};
usedLen = index;
/* -------------------------------- Add data -------------------------------- */
for (uint8_t i = 0; i < usedLen; i++)
return result;
}
+ // 日志服务
std::string DebugOutputViewEventListener::get_system_log()
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DebugOutputViewEventListener::get_system_log");
return str.str(); // 返回拼接后的字符串
}
+
+ // 获取电池相关信息
+ std::string DebugOutputViewEventListener::get_battery_info() {
+ // 获取电池温度
+ float bat_temp = 0.0f;
+ batteryservice_get_battery_temp(&bat_temp);
+
+ // 获取 PCB 温度
+ float pcb_temp = 0.0f;
+ batteryservice_get_pcb_temp(&pcb_temp);
+
+ // 获取电量
+ float voltage = 0.0f;
+ uint8_t percent = batteryservice_get_voltage(&voltage);
+
+ // 获取充电状态
+ bool isCharging = get_charge_stat();
+
+ // 拼接字符串,并简化为保留两位小数
+ std::ostringstream oss;
+ oss << std::fixed
+ << std::setprecision(2) // 设置为固定小数位,保留两位小数
+ << "Bat Temp: " << bat_temp << " °C\n"
+ << "PCB Temp: " << pcb_temp << " °C\n"
+ << "Voltage: " << voltage << " V\n"
+ << "Percent: " << static_cast<int>(percent)
+ << " %\n"
+ << "Charge: " << (isCharging ? "Yes" : "No");
+
+ return oss.str();
+ }
bool DebugOutputViewEventListener::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event)
{
std::string viewId = view.GetViewId();
case 4:
str = get_system_log();
break;
+ case 5:
+ str = get_battery_info();
+ break;
default:
str = "--";
break;