* @Author: luozheng 1732036298@qq.com
* @Date: 2024-03-27 15:21:17
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-05-10 16:23:41
+ * @LastEditTime: 2024-09-30 11:10:19
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/include/FindPhoneModel.h
*/
#ifndef FINDPHONE_MODEL_H
static FindPhoneModel &GetInstance();
void SetBlueToothConnectedState(bool state);
bool GetBlueToothConnectedState();
+ void start_or_stop_find_phone(int val);
private:
FindPhoneModel() {}
~FindPhoneModel() {}
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-08-31 09:52:34
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-31 16:38:04
+ * @LastEditTime: 2024-09-30 11:15:01
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/include/FindPhoneView.h
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
UIImageView *FindPhoneImageView{nullptr};
const ImageInfo **FindPhonePathsArray{nullptr};
ImageAnimatorInfo FindPhoneImageInfo[FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES];
- bool viewInitStatus{false};
};
} // namespace OHOS
#endif
\ No newline at end of file
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-03-27 15:21:30
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-05-10 17:00:42
+ * @LastEditTime: 2024-09-30 11:11:00
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneModel.cpp
*/
#include "bletest.h"
#include <custom_runtime.h>
#include "wearable_log.h"
+#include "bleEvent.h"
namespace OHOS
{
/*获取与手机蓝牙是否已连接*/
bool FindPhoneModel::GetBlueToothConnectedState()
{
- //return ble_is_ready() && ble_is_connect_ready();
+ // return ble_is_ready() && ble_is_connect_ready();
uint8_t ret = uapi_dev_runtime_get_ble_connect_stat();
WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "ble phone connect stat = %d", ret);
if (ret == 1)
- return true;
- else
- return false;
+ return true;
+ else
+ return false;
+ }
+
+ // 开始或停止查找手机
+ void FindPhoneModel::start_or_stop_find_phone(int val)
+ {
+ // 发送指令停止震动
+ if (FindPhoneModel::GetInstance().GetBlueToothConnectedState())
+ {
+ senfindphoneSend(val);
+ }
}
}
\ No newline at end of file
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-03-27 10:47:40
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-31 16:43:28
+ * @LastEditTime: 2024-09-30 11:13:11
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhonePresenter.cpp
*/
#include "AppViewIDs.h"
void FindPhonePresenter::OnStop(void)
{
Presenter<FindPhoneView>::OnStop();
+ FindPhoneModel::GetInstance().start_or_stop_find_phone(FINDPHONE_STOP); // 发送指令停止震动
}
bool FindPhonePresenter::OnClick(UIView &view, const ClickEvent &event)
UNUSED(event);
if (strcmp(view.GetViewId(), FINDPHONE_LABELBUTTON) == 0)
{
- // 发送指令停止震动
- if (FindPhoneModel::GetInstance().GetBlueToothConnectedState())
- {
- senfindphoneSend(FINDPHONE_STOP);
- }
NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
}
return true;
if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && FindPhonePresenter::X_DRAG_FLAG)
{
NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
- // 发送指令停止震动
- if (FindPhoneModel::GetInstance().GetBlueToothConnectedState())
- {
- senfindphoneSend(FINDPHONE_STOP);
- }
FindPhonePresenter::X_DRAG_FLAG = false;
}
return true;
// 如果是power键,且是亮屏状态,按键释放就返回上一级
if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)
{
- // 发送指令停止震动
- if (FindPhoneModel::GetInstance().GetBlueToothConnectedState())
- {
- senfindphoneSend(FINDPHONE_STOP);
- }
NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
}
return true;
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-03-27 10:47:46
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-31 18:27:22
+ * @LastEditTime: 2024-09-30 11:31:16
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/findphone/src/FindPhoneView.cpp
*/
#include "findphone/include/FindPhoneView.h"
void FindPhoneView::ClearAll()
{
- if (viewInitStatus == true)
+ if (container_ != nullptr)
{
- // UIViewGroup *tmpGroup = dynamic_cast<UIViewGroup *>(container_);
- // UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup);
- // FreeImageInfoArray(FindPhonePathsArray, FIND_PONE_IMAGE_SRC, FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+ container_->RemoveAll();
+ delete container_;
+ container_ = nullptr;
+ }
+
+ if (FindPhoneGroupView != nullptr)
+ {
+ FindPhoneGroupView->RemoveAll();
- if (container_ != nullptr)
+ if (FindPhoneTitleLabel != nullptr)
{
- container_->RemoveAll();
- delete container_;
- container_ = nullptr;
+ delete FindPhoneTitleLabel;
+ FindPhoneTitleLabel = nullptr;
}
- if (FindPhoneGroupView != nullptr)
+ if (FindPhoneImageView != nullptr)
{
- FindPhoneGroupView->RemoveAll();
-
- if (FindPhoneTitleLabel != nullptr)
- {
- delete FindPhoneTitleLabel;
- FindPhoneTitleLabel = nullptr;
- }
- if (FindPhoneImageView != nullptr)
- {
- delete FindPhoneImageView;
- FindPhoneImageView = nullptr;
- }
- if (FindPhoneImageAnimator != nullptr)
- {
- FindPhoneImageAnimator->Stop();
- delete FindPhoneImageAnimator;
- FindPhoneImageAnimator = nullptr;
- // FreeImagePathsArray(FindPhonePathsArray, FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
- FreeImageInfoArray(FindPhonePathsArray, FIND_PONE_IMAGE_SRC, FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
- }
- if (FindPhoneLabel != nullptr)
- {
- delete FindPhoneLabel;
- FindPhoneLabel = nullptr;
- }
- if (FindPhoneLabelButton != nullptr)
- {
- delete FindPhoneLabelButton;
- FindPhoneLabelButton = nullptr;
- }
- delete FindPhoneGroupView;
- FindPhoneGroupView = nullptr;
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FindPhoneView::ClearAll over!!");
+ delete FindPhoneImageView;
+ FindPhoneImageView = nullptr;
+ }
+ if (FindPhoneImageAnimator != nullptr)
+ {
+ FindPhoneImageAnimator->Stop();
+ delete FindPhoneImageAnimator;
+ FindPhoneImageAnimator = nullptr;
+ FreeImageInfoArray(FindPhonePathsArray, FIND_PONE_IMAGE_SRC, FINDPHONE_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+ }
+ if (FindPhoneLabel != nullptr)
+ {
+ delete FindPhoneLabel;
+ FindPhoneLabel = nullptr;
}
+ if (FindPhoneLabelButton != nullptr)
+ {
+ delete FindPhoneLabelButton;
+ FindPhoneLabelButton = nullptr;
+ }
+ delete FindPhoneGroupView;
+ FindPhoneGroupView = nullptr;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FindPhoneView::ClearAll over!!");
}
}
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[FindPhoneViewInit_BlueToothConnected] FindPhoneTitleLabel new fail!!");
return;
}
- FindPhoneTitleLabel->SetPosition(133, 51, 200, 40);
+ FindPhoneTitleLabel->SetPosition(83, 50, 300, 35);
FindPhoneTitleLabel->SetStyle(STYLE_TEXT_FONT, 30);
FindPhoneTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
- // FindPhoneTitleLabel->SetText("查找手机");
- FindPhoneTitleLabel->SetTextId(STR_FIND_PHONE);
- FindPhoneTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+ FindPhoneTitleLabel->SetTextId(STR_FIND_PHONE);//查找手机
+ FindPhoneTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
FindPhoneTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
FindPhoneTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
/* ----------------------- FindPhoneImageView ---------------------- */
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] FindPhoneLabel new fail");
return;
}
- FindPhoneLabel->SetPosition(33, 270, 400, 40);
+ FindPhoneLabel->SetPosition(53, 270, 360, 35);
FindPhoneLabel->SetStyle(STYLE_TEXT_FONT, 30);
FindPhoneLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
- // FindPhoneLabel->SetText("蓝牙未连接");
- FindPhoneLabel->SetTextId(STR_BLUETOOTH_DISCONNECTED);
- FindPhoneLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+ FindPhoneLabel->SetTextId(STR_BLUETOOTH_DISCONNECTED);//蓝牙未连接
+ FindPhoneLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
FindPhoneLabel->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));
FindPhoneLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
FindPhoneLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
FindPhoneLabelButton->SetPosition(0, 366, 466, 100);
FindPhoneLabelButton->SetViewId(FINDPHONE_LABELBUTTON);
FindPhoneLabelButton->SetImageSrc(PNG_BUTTON_466x100_IMAGE, PNG_BUTTON_466x100_IMAGE);
- // FindPhoneLabelButton->SetText("关闭");
- FindPhoneLabelButton->SetTextId(STR_CLOSE);
+ FindPhoneLabelButton->SetTextId(STR_CLOSE);//关闭
FindPhoneLabelButton->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff));
FindPhoneLabelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
FindPhoneLabelButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
FindPhoneGroupView->Add(FindPhoneLabelButton);
container_->Add(FindPhoneGroupView);
}
- viewInitStatus = true;
}
/*蓝牙如果是已连接状态将初始化这个视图*/
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[FindPhoneViewInit_BlueToothConnected] FindPhoneTitleLabel new fail!!");
return;
}
- FindPhoneTitleLabel->SetPosition(133, 51, 200, 40);
+ FindPhoneTitleLabel->SetPosition(83, 50, 300, 35);
FindPhoneTitleLabel->SetStyle(STYLE_TEXT_FONT, 30);
FindPhoneTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
- // FindPhoneTitleLabel->SetText("查找手机");
- FindPhoneTitleLabel->SetTextId(STR_FIND_PHONE);
- FindPhoneTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+ FindPhoneTitleLabel->SetTextId(STR_FIND_PHONE);//查找手机
+ FindPhoneTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
FindPhoneTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
FindPhoneTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
/* ----------------------- FindPhoneImageAnimator ---------------------- */
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateDeviceUnBindingView] FindPhoneLabel new fail");
return;
}
- FindPhoneLabel->SetPosition(33, 270, 400, 40);
+ FindPhoneLabel->SetPosition(53, 270, 360, 35);
FindPhoneLabel->SetStyle(STYLE_TEXT_FONT, 30);
FindPhoneLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
- // FindPhoneLabel->SetText("手机正在响铃/震动");
- FindPhoneLabel->SetTextId(STR_PHONE_RINGING_VIBRATING);
- FindPhoneLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+ FindPhoneLabel->SetTextId(STR_PHONE_RINGING_VIBRATING);//手机正在响铃/震动
+ FindPhoneLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
FindPhoneLabel->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));
FindPhoneLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
FindPhoneLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
FindPhoneGroupView->Add(FindPhoneLabelButton);
container_->Add(FindPhoneGroupView);
}
- viewInitStatus = true;
}
void FindPhoneView::OnStart()
{
View<FindPhonePresenter>::OnStart();
- // if (FindPhoneModel::GetInstance().GetBlueToothConnectedState() == true) // 判断蓝牙是否是连接状态
- // {
- // FindPhoneViewInit_BlueToothConnected();
- // senfindphoneSend(FINDPHONE_START);
- // }
- // else
- // {
- // FindPhoneViewInit_BlueToothDisConnected();
- // }
SetContainerView(new UIViewGroup());
if (GetContainer() == nullptr)
{
container_->SetTouchable(true);
container_->SetDraggable(true);
- if (!viewInitStatus)
+ if (FindPhoneModel::GetInstance().GetBlueToothConnectedState() == true) // 判断蓝牙是否是连接状态
{
FindPhoneViewInit_BlueToothConnected();
- senfindphoneSend(FINDPHONE_START);
- viewInitStatus = true;
+ FindPhoneModel::GetInstance().start_or_stop_find_phone(FINDPHONE_START);
}
+ else
+ {
+ FindPhoneViewInit_BlueToothDisConnected();
+ }
+
RootView::GetInstance()->SetOnKeyActListener(presenter_);
}
}
else //亮屏状态下每2s刷新一次下拉数据
{
- MainPresenterSample::g_PullUpDownTimes = UPDATETIME;
if (PullUpDownView::GetInstance() != nullptr)
{
PullUpDownView::GetInstance()->UpdateSignalStrengthStatusAndBatteryPosition();
}
- else
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PullUpDownView::GetInstance fail!!");
- }
+ if (MainPresenterSample::g_PullUpDownTimes != UPDATETIME) // 如果是亮屏后息屏再亮屏(此时息屏时间没超过 UPDATETIME)则恢复
+ MainPresenterSample::g_PullUpDownTimes = UPDATETIME;
}
return;
}
* @Author: luozheng 1732036298@qq.com\r
* @Date: 2024-02-27 09:16:50\r
* @LastEditors: luozheng 1732036298@qq.com\r
- * @LastEditTime: 2024-09-02 09:57:10\r
+ * @LastEditTime: 2024-09-30 17:06:25\r
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/record/src/RecordListView.cpp\r
*/\r
\r
return false;\r
}\r
}\r
- recordList->SetPosition(43, 120, 380, 340);\r
+ recordList->SetPosition(43, 100, 380, 330);\r
recordList->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);\r
recordList->SetThrowDrag(true); // 设置手指抬起屏幕后是否继续滚动。\r
recordList->SetTouchable(true);\r
recordList->SetDragACCLevel(5);\r
recordList->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/\r
recordList->SetReboundSize(30);\r
- // recordList->SetScrollBlankSize(30);\r
+ recordList->SetScrollBlankSize(20);\r
recordList->SetIntercept(true); // 设置是否拦截输入事件。如果被截获,视图在本地处理后不会将输入事件传递给父视图。\r
recordList->SetAdapter(p_RecordingListAdapter);\r
RecordListScrollView->Add(recordList);\r
#include <unistd.h>
#include <sys/stat.h>
#include "ConfigModel.h"
+#include "cstring"
namespace OHOS
{
std::string RecordingModel::recordTempDuration = 0;
}
closedir(dir);
}
+ // 使用冒泡排序进行排序
+ for (int i = 0; i < mp3FileCount - 1; i++)
+ {
+ for (int j = 0; j < mp3FileCount - i - 1; j++)
+ {
+ if (strcmp(info[j].recordingFileName, info[j + 1].recordingFileName) < 0)
+ {
+ RecordingInfo temp = info[j];
+ info[j] = info[j + 1];
+ info[j + 1] = temp;
+ }
+ }
+ }
}
/*
void RecordingModel::InitRecordingListItem(void)
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordingModel::InitRecordingListItem");
+ /* ---------------------------------- 清空操作 --------------------------------- */
if (!Recordings.empty())
{
Recordings.clear();
memset(info[i].recordingTime, 0, sizeof(info[i].recordingTime));
}
RecordingMp3FileCount = 0;
+ MaxRecordingNumber = 0;
+ /* -------------------------------------------------------------------------- */
SearchFiles(directory, Recordings, RecordingMp3FileCount);
if (RecordingMp3FileCount != 0)
{
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-12 11:44:04
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-17 16:21:55
+ * @LastEditTime: 2024-09-30 15:48:53
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/watchQRcode/include/WatchQRCodeView.h
*/
#ifndef WATCH_QR_CODE_VIEW_H
#include "components/ui_label_ext.h"
namespace OHOS
{
+ static constexpr const char *WATCHQRCODEVIEWID = "WatchQRCodeView";
class WatchQRCodePresenter;
class WatchQRCodeView : public View<WatchQRCodePresenter>
{
virtual void OnTearDownView() override;
virtual void OnStop() override;
+ /* -------------------------------------------------------------------------- */
+ static uint8_t refresh_time;
+ std::string get_voltage_and_version_string(void);
+ void update_label(void);
+ void start_refresh_timer(uint32_t interval = 2000);
+ void stop_refresh_timer(void);
+ /* -------------------------------------------------------------------------- */
+
private:
void WatchQRCodeViewInit();
bool WatchQRCodeInitViewGroup(void);
bool WatchQRCodePresenter::OnClick(UIView &view, const ClickEvent &event)
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WatchQRCodePresenter::OnDrag");
- UNUSED(view);
UNUSED(event);
+ std::string viewId = view.GetViewId();
+ if (viewId == WATCHQRCODEVIEWID)
+ {
+ if (view_)
+ view_->start_refresh_timer();
+ }
return true;
}
#include "ui_resource_string.h"
#include "iostream"
#include "string"
+#include "graphic_service.h"
+#include <cmsis_os2.h>
+#include <cmsis_os.h>
namespace OHOS
{
DeviceNameLabel = nullptr;
}
- if (WatchQRCodeGroupView != nullptr)
- {
- delete WatchQRCodeGroupView;
- WatchQRCodeGroupView = nullptr;
- }
+ delete WatchQRCodeGroupView;
+ WatchQRCodeGroupView = nullptr;
}
}
extern "C"
{
#include "build_version.h"
-
+#include "battery_hal.h"
+ extern uint8_t battery_get_voltage(float *voltage);
const char *get_version_string(void);
}
return false;
}
WatchQRCodeGroupView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+ WatchQRCodeGroupView->SetViewId(WATCHQRCODEVIEWID);
WatchQRCodeGroupView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
WatchQRCodeGroupView->SetTouchable(true);
WatchQRCodeGroupView->SetDraggable(true);
- UIView::OnDragListener *dragListener = static_cast<UIView::OnDragListener *>(WatchQRCodePresenter::GetInstance());
- if (dragListener == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::dragListener new fail!");
- return false;
- }
- WatchQRCodeGroupView->SetOnDragListener(dragListener);
+ WatchQRCodeGroupView->SetOnDragListener(presenter_);
+ WatchQRCodeGroupView->SetOnClickListener(presenter_);
return true;
}
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::DeviceNameLabel new label fail");
return false;
}
- std::string temp = get_version_string();
- std::string version_string = "V" + temp;
- DeviceNameLabel->SetText(version_string.c_str());
- DeviceNameLabel->SetPosition(83, 402, 300, 35);
+ DeviceNameLabel->SetText(get_voltage_and_version_string().c_str());
+ DeviceNameLabel->SetPosition(83, 390, 300, 35);
DeviceNameLabel->SetStyle(STYLE_TEXT_FONT, 30);
DeviceNameLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
DeviceNameLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::OnStart");
View<WatchQRCodePresenter>::OnStart();
+ start_refresh_timer();
WatchQRCodeViewInit();
/* --------------------------------- 添加按键监听 --------------------------------- */
RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::WatchQRCodePresenter::GetInstance();
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::OnStop");
View<WatchQRCodePresenter>::OnStop();
+ stop_refresh_timer();
RootView::GetInstance()->RemoveAll();
RootView::GetInstance()->ClearOnKeyActListener();
ClearAll();
return;
}
+ std::string WatchQRCodeView::get_voltage_and_version_string(void)
+ {
+ // 电量:
+ float voltage = 0.0F;
+ uint8_t value = 0;
+ value = battery_get_voltage(&voltage);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "battery_get_voltage = %d", value);
+
+ // 版本号:
+ std::string temp = get_version_string();
+ std::string version_string = "V" + temp;
+ std::string str = "bat:" + std::to_string(value) + "%" + " " + version_string;
+ return str;
+ }
+
+ void WatchQRCodeView::update_label(void)
+ {
+ if (DeviceNameLabel)
+ {
+ std::string str = get_voltage_and_version_string();
+ DeviceNameLabel->SetText(str.c_str());
+ DeviceNameLabel->Invalidate();
+ }
+ }
+
+ // 声明定时器变量
+ static osTimerId_t g_timer = nullptr;
+ static uint8_t UPDATETIME_OUT = 30; // 30秒
+ uint8_t WatchQRCodeView::refresh_time = UPDATETIME_OUT;
+ /*定时器到期时的处理*/
+ static void QRCodeView_TimerCallbackProc(int data)
+ {
+ if (uapi_get_screen_state() == 0) // 如果在亮屏状态
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_get_screen_state() == 0");
+ if (WatchQRCodeView::GetInstance())
+ {
+ WatchQRCodeView::GetInstance()->update_label();
+ }
+ if (WatchQRCodeView::refresh_time != UPDATETIME_OUT) // 如果是亮屏后息屏再亮屏(此时息屏时间没超过 UPDATETIME_OUT)则恢复
+ {
+ WatchQRCodeView::refresh_time = UPDATETIME_OUT;
+ }
+ }
+ else
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_get_screen_state() == 1");
+ WatchQRCodeView::refresh_time -= 2;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d", WatchQRCodeView::refresh_time);
+ if (WatchQRCodeView::refresh_time <= 0) // 息屏状态下超时删除定时器
+ {
+ if (WatchQRCodeView::GetInstance())
+ {
+ GraphicService::GetInstance()->PostGraphicEvent(std::bind(&WatchQRCodeView::stop_refresh_timer, WatchQRCodeView::GetInstance()));
+ }
+ }
+ else
+ {
+ if (WatchQRCodeView::GetInstance())
+ {
+ WatchQRCodeView::GetInstance()->update_label();
+ }
+ }
+ }
+ return;
+ }
+
+ /*
+ * @brief 回调函数
+ */
+ static void QRCodeView_TimerCallback(int data)
+ {
+ GraphicService::GetInstance()->PostGraphicEvent(std::bind(QRCodeView_TimerCallbackProc, data));
+ }
+
+ /*
+ * @brief 开启定时器函数
+ * @param interval 时间间隔,单位ms
+ */
+ void WatchQRCodeView::start_refresh_timer(uint32_t interval)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "start_refresh_timer");
+ /* -------------------------- 1.检查定时器是否已经存在,如果存在则返回 ------------------------- */
+ if (g_timer != nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " Timer already exists!!");
+ return;
+ }
+ /* --------------------------------- 2.创建定时器 -------------------------------- */
+ g_timer = osTimerNew((osTimerFunc_t)QRCodeView_TimerCallback, osTimerPeriodic, nullptr, nullptr);
+ // 检查定时器创建是否成功
+ if (g_timer == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Timer create failed!!");
+ return;
+ }
+ /* ----------------------------- 3.将毫秒转换为系统时钟节拍数 ---------------------------- */
+ int tick = osMs2Tick(interval);
+ /* --------------------------------- 4.启动定时器 -------------------------------- */
+ osStatus_t ret = osTimerStart(g_timer, tick);
+ /* -------------------- 5.检查定时器启动是否成功,如果启动失败,删除定时器并置为 nullptr -------------------- */
+ if (ret != osOK)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "osTimerDelete failed, ret = %lx!!", ret);
+ if (g_timer != nullptr)
+ {
+ ret = osTimerDelete(g_timer);
+ }
+ g_timer = nullptr;
+ return;
+ }
+ return;
+ }
+
+ void WatchQRCodeView::stop_refresh_timer(void)
+ {
+ // 检查定时器是否存在
+ if (g_timer != nullptr)
+ {
+ osTimerStop(g_timer);
+ // 删除定时器并置为 nullptr
+ osStatus_t ret = osTimerDelete(g_timer);
+ if (ret != osOK)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "osTimerDelete failed, ret = %lx!!", ret);
+ }
+ g_timer = nullptr;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "g_timer stop success");
+ refresh_time = UPDATETIME_OUT;
+ }
+ }
}
constexpr int32_t NOTIFY_ONE_SECOND = 1000;
constexpr int32_t NOTIFY_THIRTY_SECONDS = 30 * 1000; // 30秒
constexpr int32_t NOTIFY_ONE_MINUTE = 60 * 1000;
- static int popalarm_time = 50;
+ static int popalarm_time = 40;
constexpr int32_t NOTOFY_NO_OPERATE_TIME = 30 * 1000; // 无操作30s超时时间
osTimerId_t g_notifyStopHandle = nullptr; // timer of close view and alarm ring view
osTimerId_t g_alarmRing = nullptr; // timer of alarm view
return;
}
g_alarmRing = nullptr;
- popalarm_time = 50;
+ popalarm_time = 40;
}
break;
default:
version https://git-lfs.github.com/spec/v1
-oid sha256:4c2c3a169bd01830d76de6bba0f282b4f34179255751879c7c4fb2a9279c8f2a
+oid sha256:71cb249158bffd0944ae9221c2d3d4211f1df1fbd9530288e963494b665c2da4
size 149896