#define APP_RES_PATH "/user/res"
#define APP_MUSIC_PATH "/user/music"
#define APP_VIDEO_PATH "/user/video"
-#define APP_DEFAULT_DIAL_PATH "/user/dial" /*默认表盘安装路径*/
-#define APP_DOWNLOAD_DIAL_PATH "/user/userdata/dial" /*表盘市场安装路径*/
-#define APP_CUSTOM_DIAL_PATH "user/userdata/constom_dial" /*自定义表盘安装路径*/
+#define APP_DEFAULT_DIAL_PATH "/user/dial" /*默认表盘安装路径*/
+#define APP_DOWNLOAD_DIAL_PATH "/user/userdata/dial" /*表盘市场安装路径*/
+#define APP_CUSTOM_DIAL_PATH "/user/userdata/constom_dial/" /*自定义表盘安装路径*/
#define APP_LIST_PATH "/user/res/applist_icon"
/* ---------------------------------- 卡片管理 --------------------------------- */
static constexpr const char *CARD_CONFIG_PATH = "/user/cardconfig.bin";
bool InitTimeView(TimeDisplayPosition type); // 时间
bool InitBatteryView(BatteryDisplayType type); // 电量
bool InitColor(ColorTypeSet type); // 颜色
+ /*返回文件夹路径*/
+ std::string GetSaveDir(int Id);
+
private:
void InitStepValue();
bool InitLabelView(void);
bool InitClock(void);
bool LoadClockImage(Image *view, uint32_t resId);
bool LoadClockImage(UIImageView *view, uint32_t resId);
+ void CreateDirectoryIfNotExists(const std::string &path);
/*表盘背景*/
UIImageView *curFace{nullptr};
#include <sstream>
#include <iomanip>
#include <string>
+#include <sys/stat.h>
+#include <unistd.h>
#include "custom_runtime.h"
#include "main/include/PullUpDownView.h"
#include "battery_hal.h"
static constexpr const char *CHAGE_BATTERY = "/user/res/Battery/Charge_Icon.bin";
static constexpr const char *WHITE_BATTERY = "/user/res/Battery/Battery-E.bin";
-static constexpr const char *BLACK_BATTERY = "/user/res/Battery/Charge_Icon.bin";
+static constexpr const char *BLACK_BATTERY = "/user/res/Battery/Battery-E.bin";
// 定义一些常量
constexpr int HOURS_IN_DAY = 24;
return true; // 成功读取配置
}
+ /*
+ 获取存储文件夹
+ Id(0~4)通过ID返回对应的文件夹路径
+ 0
+ 1
+ 2
+ 3
+ 4
+ */
+ /*创建文件夹*/
+ void MainClockView::CreateDirectoryIfNotExists(const std::string &path)
+ {
+ struct stat info;
+ if (stat(path.c_str(), &info) != 0)
+ {
+ if (mkdir(path.c_str(), 0755) != 0)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Error: Could not create directory %s. Errno: %d", path.c_str(), errno);
+ }
+ else
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Created directory: %s", path.c_str());
+ }
+ }
+ else if (info.st_mode & S_IFDIR)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Directory already exists: %s", path.c_str());
+ }
+ }
+ /*获取文件夹路径*/
+ std::string MainClockView::GetSaveDir(int Id)
+ {
+ // 首先检查Id是否在0~4的范围内
+ if (Id < 0 || Id > 4)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Error: Id must be between 0 and 4.");
+ return ""; // 或者返回一个空字符串
+ }
+
+ std::string folderPath = APP_CUSTOM_DIAL_PATH + std::to_string(Id);
+ CreateDirectoryIfNotExists(folderPath); // 确保目录存在
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Directory is %s", folderPath.c_str());
+
+ return folderPath; // 返回目录路径
+ }
bool MainClockView::InitClock(void)
{
color_ = color;
batteryprogress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, color_);
}
+
/*刷新步数*/
void MainClockView::RefreshStep(int step)
{
#ifdef CUSTOM_Z1\r
{DIAL_CLOCK, "Z1", DEFAULT_DIALPER_PATH, DEFAULT_TASK_PERIOD},\r
#else\r
- {DIAL_CLOCK, "KUMI", DEFAULT_DIALPER_PATH, DEFAULT_TASK_PERIOD},\r
+ {DIAL_CLOCK, "KUMI", DEFAULT_DIALPER_PATH, DEFAULT_TASK_PERIOD},//默认\r
+\r
#endif\r
};\r
\r
{
for (uint8_t i = DIAL_CLOCK; i < DIAL_MAX; i++)
{
+ // 获取表盘信息
const DialInfo *info = MainModel::GetInstance().GetDialInfo((DialId)i);
- if (info != nullptr)
+ if (info == nullptr)
{
- SetDialInfo dialInfo{0};
- dialInfo.dialFlag = 0;
- dialInfo.id = i;
- dialInfo.dialName = info->dialName;
- dialInfo.imageFullName = info->dialImg;
- ImageInfo *imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(info->dialImg, false);
- if (info == nullptr)
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "LoadAllDialFromRam loadimage %s fail",
- info->dialImg);
- continue;
- }
- dialInfo.preImageInfo = imageInfo;
- dialInfoList.push_back(dialInfo);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "LoadAllDialFromRam: Dial info for ID %u is nullptr", i);
+ continue;
+ }
+
+ // 初始化表盘信息
+ SetDialInfo dialInfo{0};
+ dialInfo.dialFlag = 0;
+ dialInfo.id = i;
+ dialInfo.dialName = info->dialName;
+ dialInfo.imageFullName = info->dialImg;
+
+ // 加载图像资源
+ ImageInfo *imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(info->dialImg, false);
+ if (imageInfo == nullptr)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "LoadAllDialFromRam load image %s failed", info->dialImg.c_str());
+ continue;
}
+
+ // 设置图像信息
+ dialInfo.preImageInfo = imageInfo;
+
+ // 添加到表盘列表
+ dialInfoList.push_back(dialInfo);
+
+ // 日志输出
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Parsed Dial: ID: %u, Name: %s, Image: %s",
+ dialInfo.id, dialInfo.dialName.c_str(), dialInfo.imageFullName.c_str());
}
}
/*加载离线表盘*/
{\r
case 0:\r
TraingModel::GetInstance()->SetSportEvent(STR_EXERCISE_OUTDOORWALKING);\r
- OpenSensor(ExerciseClass::FREE_TRAINING);\r
+ OpenSensor(ExerciseClass::OUTDOOR);\r
+ break;\r
case 1:\r
TraingModel::GetInstance()->SetSportEvent(STR_EXERCISE_OUTDOORRUNNING);\r
OpenSensor(ExerciseClass::OUTDOOR);\r