--- /dev/null
+#ifndef TEST_HRSENSON_VIEW_H
+#define TEST_HRSENSON_VIEW_H
+
+#include "BaseView.h"
+#include "View.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_label.h"
+#include "components/ui_button.h"
+#include "components/ui_image_view.h"
+#include "components/ui_label_button_ext.h"
+
+//#include "cmsis_os.h"
+#include <iostream>
+namespace OHOS
+{
+
+ class testhrsenson1View
+ {
+
+ public:
+ struct ButtonConfig_ext_t
+ {
+ int x;
+ int y;
+ int w;
+ int h;
+ const char *str;
+ const char *ViewId;
+ const char *ImageSrc;
+
+ //label
+ int label_x;
+ int label_y;
+ uint8_t ALIGN;
+ int Fontsize;
+
+ };
+
+
+
+ struct LabelConfig
+ {
+ int16_t left;
+ int16_t top;
+ int16_t width;
+ int16_t height;
+ int16_t fontSize; // 字体大小
+ int16_t lineHeigh; // 行高
+ char *text; // 文本
+ uint8_t lineBreakMode; // 断行模式。
+ };
+
+
+ struct cat1_msg
+ {
+ char * imei;
+ int sim;
+ char * oper;
+ uint8_t signal;
+ };
+
+ struct cat1_Ver
+ {
+ char * modem_version;
+ char * cat1appver;
+ };
+
+
+
+
+ testhrsenson1View();
+ virtual ~testhrsenson1View();
+ static testhrsenson1View *GetInstance(void);
+ void gray_test(bool);
+ void leeklight_test(bool);
+ UIScrollView *testhrsensonInitIView(void);
+ void ClearAll(void);
+ void setgrayvalue(int,int,int);
+ void setlightvalue(int g,int r,int ir);
+ private:
+ UILabelButtonExt *SetTheButton_ext(ButtonConfig_ext_t &buttonconfig);//, UIView::OnTouchListener *clickListener);
+ UILabel *InitLabel(LabelConfig &labelConfig);
+ bool tesScat1ScrollViewcrollViewinit(void);
+ UIScrollView *testhrsensonScrollView{nullptr};
+ UILabel *label_1_cat1msg_1=NULL;
+ // UILabel *label_1_cat1msg_oper{nullptr};
+ // UILabel *label_1_cat1msg_sim{nullptr};
+ // UILabel *label_1_cat1msg_signal{nullptr};
+ UILabelButtonExt* button_1{NULL};
+ UILabelButtonExt* button_2{NULL};
+ UILabel *label_hrsenson_value_vison{nullptr};
+ bool initViewStatus{false};
+ };
+}
+#endif
\ No newline at end of file
{CAT1,"cat1button","CAT1", &testView::ChangeCAT1TESTView},\r
{BUTTON,"buttonbutton","button" ,&testView::ChangKEYTESTView},\r
{MAKEPHONE,"makephonebutton","makephone" ,&testView::ChangeMPTESTView},\r
+ {HRSENSON,"hrsensonbutton","hrsenson" ,&testView::ChangeHRTESTView},\r
// {FACTORYRESETVIEW,"FactoryResetButton","恢复出厂", &testView::ChangeSystemAboutView},\r
// {SYSTEMLUPGRADE,"systemupgread","系统升级",&testView::ChangeSystemAboutView},\r
// {TEST,"testButton","测试模式", &testView::ChangeSystemAboutView},\r
return true;\r
}\r
\r
+ bool testView::ChangeHRTESTView(int16_t thisView)\r
+ {\r
+ if (SystemScrollView[thisView] == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSystemAboutView");\r
+ test_hr_view = new testhrsenson1View();\r
+ if (test_hr_view == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView);\r
+ return false;\r
+ }\r
+ SystemScrollView[thisView] = test_hr_view->testhrsensonInitIView();\r
+ RootView::GetInstance()->Add(SystemScrollView[thisView]);\r
+ }\r
+ return true;\r
+ }\r
+\r
UIScrollView *testView::GetSystemScrollView(int ViewId)\r
{\r
if (SystemScrollView[ViewId] == nullptr)\r
--- /dev/null
+#include "wearable_log.h"
+#include "custom_utils.h"
+#include "producttest/include/testPresenter.h"
+#include "producttest/include/testhrsenson.h"
+#include "AlarmClockModel.h"
+#include "cmsis_os2.h"
+#include "cat1_server.h"
+#include "cat1_ctl.h"
+#include "cat1_server_hal.h"
+#include "ppg_service.h"
+namespace OHOS
+{
+
+ static testhrsenson1View *g_pSystemAboutTheWatchView{nullptr};
+
+ testhrsenson1View::testhrsenson1View()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::SystemAboutTheWatchView");
+ g_pSystemAboutTheWatchView = this;
+ }
+
+ testhrsenson1View::~testhrsenson1View()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::~SystemAboutTheWatchView");
+ ClearAll();
+ g_pSystemAboutTheWatchView = nullptr;
+ }
+
+ testhrsenson1View *testhrsenson1View::GetInstance()
+ {
+
+ return g_pSystemAboutTheWatchView;
+ }
+
+ void testhrsenson1View::ClearAll()
+ {
+ if (initViewStatus == true)
+ {
+ }
+ }
+ static bool button_falg=true;
+ void testhrsenson1View:: setgrayvalue(int g,int r,int ir)
+ {
+
+ if(label_hrsenson_value_vison!=NULL)
+ {
+
+ char buf[124]={0};
+ sprintf(buf,"gray:\n green:%d\nred:%d\nir:%d",g,r,ir);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",buf);
+ label_hrsenson_value_vison->SetText(buf);
+ RootView::GetInstance()->Invalidate();
+ int8_t md = PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST;
+ send_ppg_cmd_msg(md);
+ button_falg=true;
+ }
+
+ }
+ void testhrsenson1View:: setlightvalue(int g,int r,int ir)
+ {
+
+ if(label_hrsenson_value_vison!=nullptr)
+ {
+ char buf[124]={0};
+ sprintf(buf,"leaklight:\ngreen:%d\nred:%d\nir:%d",g,r,ir);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",buf);
+ label_hrsenson_value_vison->SetText(buf);
+ RootView::GetInstance()->Invalidate();
+ int8_t md = PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST;
+ send_ppg_cmd_msg(md);
+ button_falg=true;
+ }
+
+ }
+
+ UILabelButtonExt *testhrsenson1View::SetTheButton_ext(ButtonConfig_ext_t &buttonconfig)
+ {
+ UILabelButtonExt *button = new UILabelButtonExt();
+ if (button == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: button new fail!");
+ return nullptr;
+ }
+ button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h);
+ button->SetViewId(buttonconfig.ViewId);
+ button->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full);
+ //button->SetStyle(STYLE_BORDER_RADIUS,0);
+ button->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::Black().full, UIButton::PRESSED);
+ //button->SetStyleForState(STYLE_BORDER_RADIUS,0, UIButton::PRESSED);
+ button->SetTouchable(true);
+
+ button->SetText(buttonconfig.str);
+ button->SetAlign(TEXT_ALIGNMENT_LEFT);
+ button->SetLabelPosition(buttonconfig.label_x,buttonconfig.label_y );
+ button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, buttonconfig.Fontsize);
+ UIView:: OnClickListener *touchListener = static_cast<UIView::OnClickListener *>(testPresenter::GetInstance());
+ button->SetOnClickListener(touchListener);
+
+ // UIView::OnDragListener *drgListener = static_cast<UIView::OnDragListener *>(testPresenter::GetInstance());
+ // button->SetOnDragListener(drgListener);
+
+ // button->SetDraggable(false);
+ return button;
+ }
+ static bool speakfalg=false;
+
+
+
+ void testhrsenson1View::gray_test(bool falg)
+ {
+ if(button_1!=NULL)
+ {
+ int8_t md = PPG_SERVICE_CMD_TYPE_DO_GRAYCARD_TEST;
+ send_ppg_cmd_msg(md);
+ button_falg=false;
+ }
+ }
+
+ void testhrsenson1View::leeklight_test(bool falg)
+ {
+ if(button_2!=NULL)
+ {
+ int8_t md = PPG_SERVICE_CMD_TYPE_DO_LEAKLIGHT_TEST;
+ send_ppg_cmd_msg(md);
+ button_falg=false;
+ }
+ }
+
+ UILabel *testhrsenson1View::InitLabel(LabelConfig &labelConfig)
+ {
+ UILabel *label = new UILabel();
+ if (label == nullptr)
+ {
+ return nullptr;
+ }
+ label->SetPosition(labelConfig.left, labelConfig.top, labelConfig.width, labelConfig.height); // 位置大小
+ label->SetStyle(STYLE_TEXT_FONT, labelConfig.fontSize); // 字体大小
+ label->SetStyle(STYLE_LINE_HEIGHT, labelConfig.lineHeigh); // 字体行高
+ label->SetText(labelConfig.text); // 内容
+ label->SetLineBreakMode(labelConfig.lineBreakMode); // 断行模式。
+ label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_TOP);
+ label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelConfig.fontSize);
+ label->SetAlign(TEXT_ALIGNMENT_LEFT);
+ return label;
+ }
+
+
+
+
+
+ bool testhrsenson1View::tesScat1ScrollViewcrollViewinit(void)
+ {
+
+ testhrsensonScrollView = new UIScrollView();
+ if (testhrsensonScrollView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::testhrsensonScrollView new fail!");
+ return false;
+ }
+ testhrsensonScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+ testhrsensonScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ testhrsensonScrollView->SetStyle(STYLE_BORDER_RADIUS, 0);
+ testhrsensonScrollView->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+ testhrsensonScrollView->SetStyle(STYLE_BORDER_COLOR, Color::Yellow().blue);
+
+ LabelConfig Config = {
+ .left = 50,
+ .top = 70,
+ .width = 60,
+ .height = 35,
+ .fontSize = 30,
+ .lineHeigh = 35,
+ .text = "green:\nred:\nir:",
+ .lineBreakMode = UILabel::LINE_BREAK_ADAPT,
+ };
+ label_hrsenson_value_vison= InitLabel(Config);
+ if (label_hrsenson_value_vison == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemAboutTheWatchTitle new fail!");
+ return false;
+ }
+ testhrsensonScrollView->Add(label_hrsenson_value_vison);
+
+
+
+
+ // uapi_cat1_power_on(1);
+ // uapi_cat1_reset(0);
+
+ // cat1_getsignal();
+ // cat1_getver();
+ /* -------------------------------------------------------------------------- */
+ ButtonConfig_ext_t buttonconfig;
+ buttonconfig.x = 100;
+ buttonconfig.y = 300;
+ buttonconfig.w = 180;
+ buttonconfig.h = 116;
+ buttonconfig.label_x=40;
+ buttonconfig.label_y=0;
+ buttonconfig.Fontsize=30;
+ buttonconfig.ViewId="gray_card";
+ buttonconfig.str="gray_card";
+ buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT;
+ button_1=SetTheButton_ext(buttonconfig);
+ testhrsensonScrollView->Add(button_1);
+
+
+
+ buttonconfig.x = 300;
+ buttonconfig.ViewId="leeklight";
+ buttonconfig.str="light";
+ button_2=SetTheButton_ext(buttonconfig);
+ testhrsensonScrollView->Add(button_2);
+
+ // buttonconfig.x = 100;
+ // buttonconfig.y = 300;
+ // buttonconfig.w = 200;
+ // buttonconfig.h = 116;
+ // buttonconfig.label_x=40;
+ // buttonconfig.label_y=0;
+ // buttonconfig.Fontsize=30;
+ // buttonconfig.ViewId="DOWN_KEY";
+ // buttonconfig.str="DOWN_KEY";
+ // buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT;
+ // button[1]=SetTheButton_ext(buttonconfig);
+ // testhrsensonScrollView->Add(button[1]);
+
+ // UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(testPresenter::GetInstance());
+ // if (draglistener == nullptr)
+ // {
+ // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::draglistener can not be nullptr!");
+ // return false;
+ // }
+ // testhrsensonScrollView->SetOnDragListener(draglistener);
+
+
+
+
+
+ testhrsensonScrollView->SetTouchable(true);
+ testhrsensonScrollView->SetDraggable(false);
+
+ int8_t md = PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST;
+ send_ppg_cmd_msg(md);
+
+ return true;
+ }
+
+ UIScrollView *testhrsenson1View::testhrsensonInitIView()
+ {
+ if (!tesScat1ScrollViewcrollViewinit())
+ {
+ return nullptr;
+ }
+ return testhrsensonScrollView;
+ }
+}
\ No newline at end of file
#include "cat1_server.h"
#include "testchanging.h"
#include "testcat1.h"
+#include "testhrsenson.h"
namespace OHOS {
#ifdef __cplusplus
{
unused(topic);
unused(req);
+ //req->data;
+ //green,red,ir
+ int green,red,ir;
+ char* str= (char *)req->data;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",str);
+ char *tokbuf=NULL;
+ tokbuf=strtok(str,",");
+ green=atoi(tokbuf);
+ tokbuf=strtok(NULL,",");
+ red=atoi(tokbuf);
+ tokbuf=strtok(NULL,"\0");
+ ir=atoi(tokbuf);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d,%d,%d",green,red,ir);
+
+ testhrsenson1View * t= testhrsenson1View::GetInstance();
+ if(t!=NULL)
+ {
+ t->setgrayvalue(green,red,ir);
+ }
+
}
void MsgCenterNotifyleaklighthProc(const Topic topic, Request* req)
{
unused(topic);
unused(req);
+ //req->data;
+ //green,red,ir
+ int green,red,ir;
+ char* str= (char *)req->data;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",str);
+ char *tokbuf=NULL;
+ tokbuf=strtok(str,",");
+ green=atoi(tokbuf);
+ tokbuf=strtok(NULL,",");
+ red=atoi(tokbuf);
+ tokbuf=strtok(NULL,"\0");
+ ir=atoi(tokbuf);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d,%d,%d",green,red,ir);
+
+ testhrsenson1View * t= testhrsenson1View::GetInstance();
+ if(t!=NULL)
+ {
+ t->setlightvalue(green,red,ir);
+ }
}
//穿戴状态