From: penglei <1624952103@qq.com> Date: Thu, 18 Sep 2025 06:23:28 +0000 (+0800) Subject: 优化雷鸟LCD测试,雷鸟ssb增加马达控制,优化马达控制参数 X-Git-Tag: leiniao_debug_1.0.0_20250922_020716~54^2~1^2~1 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=906f371049734dbc0c414336910643f00347592a;p=mirrors%2FFD230.git 优化雷鸟LCD测试,雷鸟ssb增加马达控制,优化马达控制参数 --- diff --git a/code/sdk/application/brandy/brandy_standard/input_app.c b/code/sdk/application/brandy/brandy_standard/input_app.c index daa978f72..f380147f3 100644 --- a/code/sdk/application/brandy/brandy_standard/input_app.c +++ b/code/sdk/application/brandy/brandy_standard/input_app.c @@ -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 index 85770b920..000000000 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/include/lcdtest/LcdTestPresenter.h +++ /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 { -public: - LcdTestPresenter(); - ~LcdTestPresenter() override; - static LcdTestPresenter* GetInstance(); - -private: - static LcdTestPresenter* self_; -}; -} // namespace OHOS -#endif - - diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/include/lcdtest/LcdTestView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/include/lcdtest/LcdTestView.h index 58a74bc24..4c81f1a2c 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/include/lcdtest/LcdTestView.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/include/lcdtest/LcdTestView.h @@ -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 { -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 index b2e8099b7..000000000 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/lcdtest/src/LcdTestPresenter.cpp +++ /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 - - diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/lcdtest/src/LcdTestView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/lcdtest/src/LcdTestView.cpp index 3435de636..2c2c251ea 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/lcdtest/src/LcdTestView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/lcdtest/src/LcdTestView.cpp @@ -1,123 +1,146 @@ -#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(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 diff --git a/code/sdk/bootloader/flashboot/brandy/main.c b/code/sdk/bootloader/flashboot/brandy/main.c index 8eec94bb3..1f8bee0a6 100644 --- a/code/sdk/bootloader/flashboot/brandy/main.c +++ b/code/sdk/bootloader/flashboot/brandy/main.c @@ -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 diff --git a/code/sdk/zhihui/drivers/vibrator/service/vibrator_service.cpp b/code/sdk/zhihui/drivers/vibrator/service/vibrator_service.cpp index 1a37565ba..4585da310 100644 --- a/code/sdk/zhihui/drivers/vibrator/service/vibrator_service.cpp +++ b/code/sdk/zhihui/drivers/vibrator/service/vibrator_service.cpp @@ -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; diff --git a/code/sdk/zhihui/drivers/vibrator/vibrator.c b/code/sdk/zhihui/drivers/vibrator/vibrator.c index fe98004e0..e99be7992 100644 --- a/code/sdk/zhihui/drivers/vibrator/vibrator.c +++ b/code/sdk/zhihui/drivers/vibrator/vibrator.c @@ -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 ); diff --git a/code/sdk/zhihui/utils/custom_utils.c b/code/sdk/zhihui/utils/custom_utils.c index 795b500e7..920be2bb9 100644 --- a/code/sdk/zhihui/utils/custom_utils.c +++ b/code/sdk/zhihui/utils/custom_utils.c @@ -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);