优化雷鸟LCD测试,雷鸟ssb增加马达控制,优化马达控制参数
authorpenglei <1624952103@qq.com>
Thu, 18 Sep 2025 06:23:28 +0000 (14:23 +0800)
committerpenglei <1624952103@qq.com>
Thu, 18 Sep 2025 06:23:28 +0000 (14:23 +0800)
code/sdk/application/brandy/brandy_standard/input_app.c
code/sdk/application/wearable/ln/nativeapp/nativeui/include/lcdtest/LcdTestPresenter.h [deleted file]
code/sdk/application/wearable/ln/nativeapp/nativeui/include/lcdtest/LcdTestView.h
code/sdk/application/wearable/ln/nativeapp/nativeui/lcdtest/src/LcdTestPresenter.cpp [deleted file]
code/sdk/application/wearable/ln/nativeapp/nativeui/lcdtest/src/LcdTestView.cpp
code/sdk/bootloader/flashboot/brandy/main.c
code/sdk/zhihui/drivers/vibrator/service/vibrator_service.cpp
code/sdk/zhihui/drivers/vibrator/vibrator.c
code/sdk/zhihui/utils/custom_utils.c

index daa978f..f380147 100644 (file)
@@ -210,7 +210,7 @@ static void button_report_event_to_gui(button_id_t id, uint16_t state)
 static void button_report_event(button_id_t id, event_button_t event)
 {
     input_dev_data_t data;
-    // printf("fac:id : %d\n",id);
+    printf("fac:id : %d\n",id);
     switch (event) {
         case BUTTON_PWR_PRESS:
             #ifdef SUPPORT_POWER_MANAGER
diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/include/lcdtest/LcdTestPresenter.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/include/lcdtest/LcdTestPresenter.h
deleted file mode 100644 (file)
index 85770b9..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef LCD_TEST_PRESENTER_H
-#define LCD_TEST_PRESENTER_H
-
-#include "Presenter.h"
-#include "View.h"
-#include "drag_event.h"
-
-namespace OHOS {
-class LcdTestView;
-class LcdTestPresenter : public Presenter<LcdTestView> {
-public:
-    LcdTestPresenter();
-    ~LcdTestPresenter() override;
-    static LcdTestPresenter* GetInstance();
-
-private:
-    static LcdTestPresenter* self_;
-};
-} // namespace OHOS
-#endif
-
-
index 58a74bc..4c81f1a 100644 (file)
@@ -1,36 +1,11 @@
 #ifndef LCD_TEST_VIEW_H
 #define LCD_TEST_VIEW_H
 
-#include "lcdtest/LcdTestPresenter.h"
-#include "View.h"
-#include "components/ui_view_group.h"
-#include "components/ui_image_view.h"
-#include "cmsis_os2.h"
-
-namespace OHOS {
-class LcdTestView : public View<LcdTestPresenter> {
-public:
-    LcdTestView();
-    ~LcdTestView() override;
-    static LcdTestView* GetInstance();
-
-    void OnStart() override;
-    UIViewGroup* InitShowUpView();
-    void StartAnimation();
-    void SetLCDColor(int color);
-
-private:
-    void ClearAll();
-
-private:
-    UIViewGroup* group{nullptr};
-    UIImageView* overlay{nullptr};
-    osTimerId_t timer_{NULL};
-    uint8_t colorIndex_{0};
-    static LcdTestView* self_;
-};
-} // namespace OHOS
-#endif
-
-
-
+// 简化版LCD测试 - 只需要C接口函数声明
+extern "C" {
+    void start_lcd_test_view(void);
+    void stop_lcd_test_view(void);
+    void set_lcd_test_color(int color);
+}
+
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/lcdtest/src/LcdTestPresenter.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/lcdtest/src/LcdTestPresenter.cpp
deleted file mode 100644 (file)
index b2e8099..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "lcdtest/LcdTestPresenter.h"
-#include "lcdtest/LcdTestView.h"
-#include "NativeAbility.h"
-#include "AppViewIDs.h"
-#include "NativeRegisterManager.h"
-#include "wearable_log.h"
-#include "drag_event.h"
-
-namespace OHOS {
-REGIST_SLICE(VIEW_LCD_TEST, LcdTestView, LcdTestPresenter);
-
-LcdTestPresenter* LcdTestPresenter::self_{nullptr};
-
-LcdTestPresenter::LcdTestPresenter()
-{
-    self_ = this;
-}
-
-LcdTestPresenter::~LcdTestPresenter()
-{
-    self_ = nullptr;
-}
-
-LcdTestPresenter* LcdTestPresenter::GetInstance()
-{
-    return self_;
-}
-
-} // namespace OHOS
-
-
index 3435de6..2c2c251 100644 (file)
-#include "lcdtest/LcdTestView.h"
-#include "UiConfig.h"
+#include "components/ui_scroll_view.h"
 #include "components/root_view.h"
 #include "common/screen.h"
-#include "wearable_log.h"
+#include "UiConfig.h"
+#include "gfx_utils/style.h"
+#include "graphic_config.h"
+#include "View.h"
 
-namespace OHOS {
-static void LcdTestTick(void* arg)
-{
-    LcdTestView* v = reinterpret_cast<LcdTestView*>(arg);
-    if (v != nullptr) {
-        v->SetLCDColor(-1);
-    }
-}
+// 全局变量 - 最简单的方式
+static OHOS::UIScrollView* g_lcd_test_view = nullptr;
+static OHOS::UIView* g_current_view = nullptr;
 
-LcdTestView* LcdTestView::self_{nullptr};
 
-LcdTestView::LcdTestView()
+#ifdef __cplusplus
+#if __cplusplus
+extern "C"
 {
-    self_ = this;
-}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
 
-LcdTestView::~LcdTestView()
+/**
+ * @brief 启动LCD测试视图
+ */
+void start_lcd_test_view(void)
 {
-    ClearAll();
-    self_ = nullptr;
-}
-
-LcdTestView* LcdTestView::GetInstance()
-{
-    return self_;
-}
-
-void LcdTestView::ClearAll()
-{
-    if (timer_ != NULL) {
-        osTimerStop(timer_);
-        osTimerDelete(timer_);
-        timer_ = NULL;
-    }
-    if (overlay != nullptr) {
-        if (group != nullptr) {
-            group->Remove(overlay);
-        }
-        delete overlay;
-        overlay = nullptr;
-    }
-    if (group != nullptr) {
-        group->RemoveAll();
-        delete group;
-        group = nullptr;
+    printf("=== 启动LCD测试 ===\n");
+    
+    OHOS::RootView* rootView = OHOS::RootView::GetInstance();
+    if (rootView == nullptr) {
+        printf("ERROR: RootView not initialized\n");
+        return;
     }
-}
-
-UIViewGroup* LcdTestView::InitShowUpView()
-{
-    if (group != nullptr) {
-        return group;
+    
+    // 保存当前显示的view,然后切换到LCD测试view
+    g_current_view = rootView->GetChildrenHead();
+    if (g_current_view != nullptr) {
+        // 先从rootView中移除,但不删除
+        rootView->Remove(g_current_view);
+        printf("Saved and removed current view for later restore\n");
     }
-    group = new UIViewGroup();
-    if (group == nullptr) {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LcdTestView group new fail");
-        return nullptr;
+    
+    // 创建ScrollView用于LCD测试
+    g_lcd_test_view = new OHOS::UIScrollView();
+    if (g_lcd_test_view == nullptr) {
+        printf("ERROR: Failed to create LCD test view\n");
+        return;
     }
-    group->SetPosition(0, 0);
-    group->SetWidth(HORIZONTAL_RESOLUTION);
-    group->SetHeight(VERTICAL_RESOLUTION);
-    group->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
-    group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+    
+    // 设置全屏红色
+    printf("fac:LCD test red\n");
+    g_lcd_test_view->SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
+    g_lcd_test_view->SetStyle(OHOS::STYLE_BACKGROUND_OPA, 0xff);
+    g_lcd_test_view->SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xffff0000); // 红色
+    g_lcd_test_view->SetTouchable(false);
+    g_lcd_test_view->SetDraggable(false);
+    g_lcd_test_view->SetVisible(true);
+    
+    // 添加LCD测试view到根视图
+    rootView->Add(g_lcd_test_view);
+    rootView->Invalidate();
 
-    overlay = new UIImageView();
-    if (overlay != nullptr) {
-        overlay->SetPosition(0, 0, group->GetWidth(), group->GetHeight());
-        overlay->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
-        overlay->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
-        overlay->SetVisible(true);
-        group->Add(overlay);
-    }
-    return group;
+    printf("LCD test started - RED background\n");
 }
 
-void LcdTestView::StartAnimation()
+/**
+ * @brief 停止LCD测试视图
+ */
+void stop_lcd_test_view(void)
 {
-    if (timer_ == NULL) {
-        timer_ = osTimerNew((osTimerFunc_t)LcdTestTick, osTimerPeriodic, this, NULL);
-    }
-    colorIndex_ = 0;
-    if (timer_ != NULL) {
-        osTimerStart(timer_, 1000);
+    printf("=== 停止LCD测试 ===\n");
+    
+    OHOS::RootView* rootView = OHOS::RootView::GetInstance();
+    if (rootView != nullptr) {
+        // 删除LCD测试view
+        if (g_lcd_test_view != nullptr) {
+            rootView->Remove(g_lcd_test_view);
+            delete g_lcd_test_view;
+            g_lcd_test_view = nullptr;
+            printf("LCD test view removed\n");
+        }
+        
+        // 恢复原来的view
+        if (g_current_view != nullptr) {
+            printf("Attempting to restore view at address: %p\n", g_current_view);
+            
+            // 检查view是否还有效
+            if (g_current_view->GetParent() == nullptr) {
+                rootView->Add(g_current_view);
+                rootView->Invalidate();
+                printf("Original view restored successfully\n");
+            } else {
+                printf("Warning: Original view still has parent, cannot restore\n");
+            }
+            g_current_view = nullptr;
+        } else {
+            printf("No original view to restore\n");
+        }
     }
 }
 
-void LcdTestView::SetLCDColor(int color)
+/**
+ * @brief 设置LCD测试颜色
+ * @param color 颜色索引 (0-5): 0=绿色, 1=蓝色, 2=黄色, 3=红色, 4=白色, 5=黑色
+ */
+void set_lcd_test_color(int color)
 {
-    if (group == nullptr) {
+    if (g_lcd_test_view == nullptr) {
+        printf("LCD test not started\n");
         return;
     }
-    if (color < 0) {
-        color = colorIndex_++;
-    }
-    switch (color % 6) {
-        case 0: group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Green().full);  break;
-        case 1: group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full);   break;
-        case 2: group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Yellow().full); break;
-        case 3: group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full);    break;
-        case 4: group->SetStyle(STYLE_BACKGROUND_COLOR, Color::White().full);  break;
-        case 5: group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);  break;
-        default: break;
-    }
-    RootView::GetInstance()->Invalidate();
-}
+    
 
-void LcdTestView::OnStart()
-{
-    UIViewGroup* v = InitShowUpView();
-    if (v != nullptr) {
-        AddViewToRootContainer(v);
-        StartAnimation();
+    switch (color)
+    {
+    case 0:
+        printf("fac:LCD test green\n");
+        g_lcd_test_view->SetStyle(OHOS::STYLE_BACKGROUND_COLOR, OHOS::Color::Green().full);
+        break;
+    case 1:
+        printf("fac:LCD test blue\n");
+        g_lcd_test_view->SetStyle(OHOS::STYLE_BACKGROUND_COLOR, OHOS::Color::Blue().full);
+        break;
+    case 2:
+        g_lcd_test_view->SetStyle(OHOS::STYLE_BACKGROUND_COLOR, OHOS::Color::Yellow().full);
+        break;
+    case 3:
+        printf("fac:LCD test red\n");
+        g_lcd_test_view->SetStyle(OHOS::STYLE_BACKGROUND_COLOR, OHOS::Color::Red().full);
+        break;
+    case 4:
+        g_lcd_test_view->SetStyle(OHOS::STYLE_BACKGROUND_COLOR, OHOS::Color::White().full);
+        break;
+    case 5:
+        g_lcd_test_view->SetStyle(OHOS::STYLE_BACKGROUND_COLOR, OHOS::Color::Black().full);
+        break;
+    default:
+        break;
     }
+    OHOS::RootView::GetInstance()->Invalidate();
 }
-} // namespace OHOS
-
 
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
\ No newline at end of file
index 8eec94b..1f8bee0 100644 (file)
@@ -791,6 +791,21 @@ static void fs_init(void)
     uapi_gpio_set_val(S_AGPIO_L18,GPIO_LEVEL_HIGH);
 #endif
 #endif
+
+#ifdef BOARD_LEINIAO
+    uapi_gpio_set_dir(S_AGPIO_L32, GPIO_DIRECTION_OUTPUT);
+    uapi_gpio_set_val(S_AGPIO_L32, GPIO_LEVEL_HIGH);
+
+    uapi_gpio_set_dir(S_AGPIO_R0, GPIO_DIRECTION_OUTPUT);
+    uapi_gpio_set_val(S_AGPIO_R0, GPIO_LEVEL_HIGH);
+
+    uapi_gpio_set_dir(S_HGPIO4, GPIO_DIRECTION_OUTPUT);
+    uapi_gpio_set_val(S_HGPIO4, GPIO_LEVEL_LOW);
+
+    uapi_gpio_set_dir(S_HGPIO0, GPIO_DIRECTION_OUTPUT);
+    uapi_gpio_set_val(S_HGPIO0, GPIO_LEVEL_LOW);
+#endif
+
 #ifdef CFG_DRIVERS_NANDFLASH
     nandflash_qspi_init();
 #endif
index 1a37565..4585da3 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: penglei 1624952103@qq.com
  * @Date: 2024-08-08 16:33:23
  * @LastEditors: penglei 1624952103@qq.com
- * @LastEditTime: 2025-09-16 15:56:41
+ * @LastEditTime: 2025-09-18 10:56:36
  * @FilePath: /FD230/code/sdk/drivers/peripheral/vibrator/service/vibrator_service.cpp
  * @Description: 
  * 
@@ -61,17 +61,17 @@ void custom_VibratorFunc_int(int vibratorType)
     case 3:
         mail.cycle_time_ms = 235;
         mail.duty = 50;
-        mail.duration_time_ms = 600;
+        mail.duration_time_ms = 60;
         break;
     case 2:
         mail.cycle_time_ms = 235;
         mail.duty = 50;
-        mail.duration_time_ms = 400;
+        mail.duration_time_ms = 40;
         break;
     case 1:
         mail.cycle_time_ms = 235;
         mail.duty = 50;
-        mail.duration_time_ms = 200;
+        mail.duration_time_ms = 20;
         break;
     default:
         break;
index fe98004..e99be79 100644 (file)
@@ -203,7 +203,9 @@ static uint8_t switch_flag = 1;
 
 void g_VibratorFunc(uint16_t duty , uint16_t cycle_time_ms,uint16_t duration_time_ms)
 {
-
+#ifdef BOARD_LEINIAO
+    duration_time_ms *= 5;
+#endif
     if( duty>100 || duty ==0 ||cycle_time_ms == 0 || duration_time_ms == 0)
     {
         PRINT("Not Supported param duty %u cycle_time_ms %u duration_time_ms %u !\r\n",duty,cycle_time_ms,duration_time_ms );
index 795b500..920be2b 100644 (file)
@@ -640,6 +640,14 @@ void startup_post_init_task(void)
     //initializeMotionRecognition();
     cm_initBluetoothDeviceList();
     
+    uapi_gei_btmac_and_chipinfo();
+
+    uint8_t buildversion[128]={0};
+    uint16_t versionlen = 128;
+    uapi_get_buildversion(buildversion,versionlen);
+
+    wstp_print("\nfac:BuildVer:%s\n",buildversion);
+
     LOS_Msleep(5000);
 
     int ret = uapi_save_exc();
@@ -682,14 +690,7 @@ void startup_post_init_task(void)
         uapi_set4GCapability(false);
     }
 #endif
-    uapi_gei_btmac_and_chipinfo();
-
-    uint8_t buildversion[128]={0};
-    uint16_t versionlen = 128;
-    uapi_get_buildversion(buildversion,versionlen);
-
-    wstp_print("\nfac:BuildVer:%s\n",buildversion);
-
+    
     uint8_t len = 1;
     uapi_get_file_data("user/userdata/timestamp_of_day.bin",&day,&len);
     time(&rawtime);