优化录音回环产测
authorpenglei <1624952103@qq.com>
Sat, 7 Sep 2024 10:51:34 +0000 (18:51 +0800)
committerpenglei <1624952103@qq.com>
Sat, 7 Sep 2024 10:51:34 +0000 (18:51 +0800)
code/sdk/application/wearable/fd230app/nativeui/producttest/include/testmicrophone.h
code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/producttest/src/testmicrophone.cpp
code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c
code/sdk/drivers/peripheral/utils/custom_utils.c
code/sdk/drivers/peripheral/utils/custom_utils.h

index 4c2b912..0af074d 100644 (file)
@@ -1,3 +1,13 @@
+/*
+ * @Author: penglei 1624952103@qq.com
+ * @Date: 2024-08-23 10:50:37
+ * @LastEditors: penglei 1624952103@qq.com
+ * @LastEditTime: 2024-09-07 18:04:07
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testmicrophone.h
+ * @Description: 
+ * 
+ * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. 
+ */
 #ifndef TEST_MICRPHONE_VIEW_H
 #define TEST_MICRPHONE_VIEW_H
 
@@ -41,7 +51,7 @@ namespace OHOS
         virtual ~testmicrohoneView();
         static testmicrohoneView *GetInstance(void);
         void buttoncallback();
-
+        void addvolumebuttoncallback();
         UIScrollView *testmicrophoneInitIView(uint8_t);
         void ClearAll(void);
     private:
@@ -49,7 +59,7 @@ namespace OHOS
         bool testphoneScrollViewcrollViewinit(uint8_t);
         UIScrollView *testmakephoneScrollView{nullptr};
         UILabelButtonExt* labelButton_next = nullptr;
-        UILabelButtonExt* button{NULL};
+        UILabelButtonExt* button[2]{NULL};
         bool initViewStatus{false};
         UILabel *Title{nullptr};           // 标题
     };
index 3cda8dc..cc2ffad 100644 (file)
@@ -255,6 +255,11 @@ namespace OHOS
 \r
             testBTView::GetInstance()->BT_discovery_callback();\r
         }\r
+        if(strcmp(view.GetViewId(),"addvolume") == 0)\r
+        { \r
+\r
+            testmicrohoneView::GetInstance()->addvolumebuttoncallback();\r
+        }\r
         #ifdef SUPPORT_A5133_SERVICE\r
         if(strcmp(view.GetViewId(),"receive") == 0)\r
         { \r
index 4c8b641..8b8f255 100644 (file)
@@ -44,16 +44,23 @@ namespace OHOS
         return g_pSystemAboutTheWatchView;
     }
 
+    int volume = 25;
+
     void testmicrohoneView::ClearAll()
     {
         if(testmakephoneScrollView)
         {
             testmakephoneScrollView->RemoveAll();
 
-            if(button!=NULL)
+            if(button[0]!=NULL)
+            {
+                delete button[0];
+                button[0]=nullptr;
+            }
+            if(button[1]!=NULL)
             {
-                delete button;
-                button=nullptr;
+                delete button[1];
+                button[1]=nullptr;
             }
             if(labelButton_next)
             {
@@ -74,15 +81,16 @@ namespace OHOS
             AlarmClockModel::GetInstance()->AlarmPlayerStop();
             delete testmakephoneScrollView;
             testmakephoneScrollView=nullptr;
+            volume = 25;
         }
     }
 
     UILabelButtonExt *testmicrohoneView::SetTheButton_ext(ButtonConfig_ext_t &buttonconfig)
     {
-        UILabelButtonExt *button = new UILabelButtonExt();
+        UILabelButtonExt *button= new UILabelButtonExt();
         if (button == nullptr)
         {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: button new  fail!");
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: button[0] new  fail!");
             return nullptr;
         }
         button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h);
@@ -101,9 +109,9 @@ namespace OHOS
         button->SetOnClickListener(touchListener);
 
         // UIView::OnDragListener *drgListener = static_cast<UIView::OnDragListener *>(testPresenter::GetInstance());
-        // button->SetOnDragListener(drgListener);
+        // button[0]->SetOnDragListener(drgListener);
 
-        // button->SetDraggable(false);
+        // button[0]->SetDraggable(false);
         return button;
     }
 
@@ -113,7 +121,7 @@ namespace OHOS
     static char *Path= "/user/userdata/microphone.mp3";
     void testmicrohoneView::buttoncallback()
     {
-        if(button!=NULL)
+        if(button[0]!=NULL)
         {
             errcode_t ret = 0;
             if(makphone_falg==0)
@@ -128,7 +136,7 @@ namespace OHOS
                 // }
                 // /* ---------------------------------- 开始录音 ---------------------------------- */
                 // AudioCaptureSample(6, (const char **)args);
-                ret = uapi_start_audio_test();
+                ret = uapi_start_audio_test(volume);
                 if(ret != ERRCODE_SUCC)
                 {
                     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " uapi_start_audio_test failed ret : %d ",ret);
@@ -136,7 +144,7 @@ namespace OHOS
                 }
                 else
                 {
-                    button->SetText("stop");
+                    button[0]->SetText("stop");
                     makphone_falg = 1;
                 }
 
@@ -146,7 +154,7 @@ namespace OHOS
                 // int32_t argc = 1;
                 // uint8_t *argv = (uint8_t*)"stop";
                 // AudioCaptureSample(argc, (const char **)&argv);
-                // button->SetText("play");
+                // button[0]->SetText("play");
                 // makphone_falg++;
 
                 // FILE *file =fopen("/user/userdata/microphone.mp3","rb");
@@ -156,7 +164,7 @@ namespace OHOS
                 // }
                 // fclose(file);
                 uapi_stop_audio_test();
-                button->SetText("start");
+                button[0]->SetText("start");
                 makphone_falg = 0;
             }
             // else if(makphone_falg==2)
@@ -173,6 +181,14 @@ namespace OHOS
         RootView::GetInstance()->Invalidate();
     }
 
+    void testmicrohoneView::addvolumebuttoncallback()
+    {
+        if(volume <= 45)
+        {
+            volume+= 5;
+        }
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " volumebuttoncallback volume : %d ",volume);
+    }
 
     
     bool testmicrohoneView::testphoneScrollViewcrollViewinit(uint8_t id)
@@ -195,7 +211,7 @@ namespace OHOS
         /* -------------------------------------------------------------------------- */
         ButtonConfig_ext_t buttonconfig;
         buttonconfig.x = 200;
-        buttonconfig.y = 200;
+        buttonconfig.y = 100;
         buttonconfig.w = 250;
         buttonconfig.h = 116;
         buttonconfig.label_x=40;
@@ -204,10 +220,23 @@ namespace OHOS
         buttonconfig.ViewId="testmicrohoneView";
         buttonconfig.str="statr";
         buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT;
-        button=SetTheButton_ext(buttonconfig);
-        testmakephoneScrollView->Add(button);
+        button[0]=SetTheButton_ext(buttonconfig);
+        testmakephoneScrollView->Add(button[0]);
         makphone_falg=0;
-       
+
+        buttonconfig.x = 200;
+        buttonconfig.y = 300;
+        buttonconfig.w = 250;
+        buttonconfig.h = 116;
+        buttonconfig.label_x=40;
+        buttonconfig.label_y=0;
+        buttonconfig.Fontsize=30;
+        buttonconfig.ViewId="addvolume";
+        buttonconfig.str="+volume";
+        buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT;
+        button[1]=SetTheButton_ext(buttonconfig);
+        testmakephoneScrollView->Add(button[1]);
+ 
         UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(testPresenter::GetInstance());
         if (draglistener == nullptr)
         {
index 33e752a..abec351 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: penglei 1624952103@qq.com\r
  * @Date: 2024-06-17 14:31:08\r
  * @LastEditors: penglei 1624952103@qq.com\r
- * @LastEditTime: 2024-09-07 12:28:55\r
+ * @LastEditTime: 2024-09-07 17:59:45\r
  * @FilePath: /FD230/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c\r
  * @Description: \r
  * \r
@@ -1649,7 +1649,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
             {\r
                 //开始录音\r
                 uint8_t send_data= 0;\r
-                uapi_start_audio_test();\r
+                uapi_start_audio_test(25);\r
                 factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
                         BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER,\r
                         0x01,\r
index 0dcc41e..0ee82b1 100644 (file)
@@ -64,6 +64,7 @@
 #include "service/a5133_service.h"
 #include "input_app.h"
 #endif
+#include "broadcast_feature.h"
 
 errcode_t uapi_create_osThread_custom(app_task_definition_t *task_cfg)
 {
@@ -396,7 +397,8 @@ void startup_post_init_task(void)
     timeinfo = localtime(&rawtime);
     if(day > 0 && day != timeinfo->tm_mday)
     {
-        do_cywee_service_check_msg(CYWEE_SERVICE_CMD_RESET_DAILY_DATA,NULL);
+        CustomEventPublish(TOPIC_EVENT_NEXTDAY_UPDATE, NULL , 0);
+        //do_cywee_service_check_msg(CYWEE_SERVICE_CMD_RESET_DAILY_DATA,NULL);
     }
 #ifdef A5133_DEMO_SERVER
     uapi_button_register_event_cb(a5133_demo_msg_unbind_callback, BUTTON_PWR_CLICKUP_2);
@@ -2995,7 +2997,7 @@ typedef struct sample_ai_inst {
 
 
 
-errcode_t uapi_start_audio_test(void)
+errcode_t uapi_start_audio_test(int volume)
 {
     errcode_t ret;
     sample_ai_inst *inst = TD_NULL;
@@ -3017,8 +3019,8 @@ errcode_t uapi_start_audio_test(void)
     inst->pcm_format.channels = 1;
     inst->pcm_format.bit_depth = 16;
     sample_ai_ao_parse_port("adc0", inst);
-    inst->volume.integer = 25;
-
+    inst->volume.integer = volume;
+    PRINT("inst->volume.integer : %d\n",inst->volume.integer);
     ret = sample_ai_player_open(inst);
     if (ret != ERRCODE_SUCC) {
         PRINT("sample_ao_player_open error : %d\n", ret);
index 5e49f17..e3f41cd 100644 (file)
@@ -277,7 +277,7 @@ void uapi_get_a5133_rxdata_timestamp(uint32_t *timestamp);
 uint32_t uapi_get_a5133_update_state(void);
 uint32_t uapi_get_a5133_update_state1(void);
 
-errcode_t uapi_start_audio_test(void);
+errcode_t uapi_start_audio_test(int volume);
 errcode_t uapi_stop_audio_test(void);