OpenHarmony輕智能產品開發_第1頁
OpenHarmony輕智能產品開發_第2頁
OpenHarmony輕智能產品開發_第3頁
OpenHarmony輕智能產品開發_第4頁
OpenHarmony輕智能產品開發_第5頁
已閱讀5頁,還剩27頁未讀, 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、OpenHarmony何廉毅輕智能產品開發專注嵌入式BSP開發曾在優思通信,上?;j箕技術,HTC,深蘭科技,等多家公司從事嵌入式和BSP開發,現在好叭科技從事嵌入式和BSP開發。何廉毅適宜人群想要了解OpenHarmony想要從事OpenHarmony嵌入式開發正在從事OpenHarmony開發課程內容OpenHarmony cortex-m系列芯片開發環境搭建OpenHarmony cortex-m系列芯片圖形和輸入接口適配OpenHarmony輕智能產品介紹OpenHarmony cortex-m系列芯片添加工程OpenHarmony cortex-m系列芯片移植開發中的注意事項OpenH

2、armony輕智能產品介紹OpenHarmony是由開放原子開源基金會(OpenAtom Foundation)孵化及運營的開源項目,目標是面向全場景、全連接、全智能時代,基于開源的方式,搭建一個智能終端設備操作系統的框架和平臺,促進萬物互聯產業的繁榮發展??梢赃\行第三方JS應用,可以應用于輕智能穿戴設備,智能門鎖,智能傳感器模塊,智能電子玩具,智能家電等。OpenHarmony cortex-m系列芯片開發環境搭建開發工具OpenHarmony cortex-m的編譯環境是Ubuntu16.04及以上64位系統版本。開發和編譯工具,git git-lfs repo python3.8 pip

3、3 gn ninja hc-gen hb gcc openjdk-8。 其他工具, sudo apt-get install build-essential gcc g+ make zlib* libffi-dev e2fsprogs pkg-config flex bison perl bc openssl libssl-dev libelf-dev binutils binutils-dev libdwarf-dev u-boot-tools mtd-utils mtoolsOpenHarmony cortex-m系列芯片開發環境搭建具體搭建步驟:1. 創建存放編譯相關工具的目錄: mkd

4、ir /tools2. 安裝 git-lfs: cd /tools wget https:/packagecloud.io/install/repositories/github/git-lfs/script.deb.sh sudo chmod a+x script.deb.sh sudo os=ubuntu dist=trusty ./script.deb.sh sudo apt install git-lfs3. 安裝repo: mkdir /bin curl -s /oschina/repo/raw/fork_flow/repo-py3 /bin/repo chmod a+x /bin/

5、repoOpenHarmony cortex-m系列芯片開發環境搭建4. 安裝python3.8 sudo apt-get install python3.8 sudo update-alternatives -install /usr/bin/python python /usr/bin/python3.8 35. pip3安裝 sudo apt-get install python3-setuptools python3-pip -y sudo pip3 install -upgrade pip6. gn安裝 cd /tools mkdir gn wget /harmonyos/compi

6、ler/gn/1717/linux/gn-linux-x86-1717.tar.gz tar -zxvf gn-linux-x86-1717.tar.gz -C /tools/gnOpenHarmony cortex-m系列芯片開發環境搭建7. 安裝ninja cd /tools wget /harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar tar -xvf ninja.1.9.0.tar8. 安裝 hc-gen cd /tools wget /harmonyos/compiler/hc-gen/0.65/linux/hc-gen-0.6

7、5-linux.tar tar -xvf hc-gen-0.65-linux.tar9. 安裝hb (python版本需要大于3.7) python -m pip install -user ohos-buildOpenHarmony cortex-m系列芯片開發環境搭建10. 安裝交叉編譯器: arm cortex-m用arm-gcc交叉編譯鏈編譯 cd /tools git clone/harylee/gcc-arm-none-eabi-10-2020-q4-major.git 將交叉編譯器環境變量bin目錄配置到.bashrc文件中或者配置 device/xx/xxxxx/liteos_

8、m/config.gni 文 件中board_toolchain_path宏為交叉編譯器bin路徑11. 安裝jdk: sudo apt-get install -y openjdk-8-jdk sudo echo export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/bin/.bashrc12.設置環境變量: vim /.bashrc 在文件末尾添加如下一行: export PATH=/tools/gn:/tools/ninja:/tools/llvm/bin:/tools/hc-gen:/.local/bin:$PATH source /.b

9、ashrcOpenHarmony cortex-m系列芯片開發環境搭建13. 安裝其他工具 sudo apt-get install build-essential gcc g+ make zlib* libffi-dev e2fsprogs pkg-config flex bison perl bc openssl libssl-dev libelf-dev binutils binutils-dev libdwarf-dev u-boot-tools mtd-utils mtools14. ssh key 生成 cd ssh-keygen 把 /.ssh/下的id_rsa.pub文件中的內

10、容添加到gitee網站上去OpenHarmony cortex-m系列芯片開發環境搭建15. 編譯命令 hb set # 這條命令是設置編譯環境,如代碼路徑,編譯工程 配置好代碼路徑和工程后,就可以 hb build f # 這條命令來編譯系統了OpenHarmony cortex-m系列芯片添加工程在hb set命令中需要選擇工程,我們現在來講如何添加工程在vendor目錄下創建對應的目錄。這個目錄下需要有 BUILD.gn config config.json README.md 這幾個文件BUILD.gn需要定義一個group,名字和目錄名字一樣 OpenHarmony cortex-m

11、系列芯片添加工程4. config.json配置: 這個文件中需要配置產品名,開發板型號,公司名字,及其需要使能的組件。 product_name: minidisplay_demo, ohos_version: OpenHarmony 1.0, device_company: st, board: stm32l4r9i_disco, kernel_type: liteos_m, kernel_version: 3.0.0,OpenHarmony cortex-m系列芯片添加工程4. config.json配置: 這個文件中需要配置產品名,開發板型號,公司名字,及其需要使能的組件。 subsy

12、stems: subsystem: kernel, components: component: liteos_m, features: enable_ohos_kernel_liteos_m_fs = true, enable_ohos_kernel_liteos_m_lwip = false, enable_ohos_kernel_liteos_m_shell = true, enable_ohos_kernel_liteos_m_fatfs = false, enable_ohos_kernel_liteos_m_littlefs = true, enable_ohos_kernel_l

13、iteos_m_kal = true ,OpenHarmony cortex-m系列芯片添加工程4. config.json配置: 這個文件中需要配置產品名,開發板型號,公司名字,及其需要使能的組件。 subsystem: graphic, components: component: graphic_utils, features: , component: ui, features: enable_graphic_font = true , vendor_adapter_dir: /device/st/stm32l4r9i_disco, third_party_dir: /third_pa

14、rty, product_adapter_dir: , ohos_product_type:, ohos_manufacture:,OpenHarmony cortex-m系列芯片添加工程4. config.json配置: 這個文件中需要配置產品名,開發板型號,公司名字,及其需要使能的組件。 ohos_brand:, ohos_market_name:, ohos_product_series:, ohos_product_model:, ohos_software_model:, ohos_hardware_model:, ohos_hardware_profile:, ohos_seria

15、l:, ohos_bootloader_version:, ohos_secure_patch_level:, ohos_abi_list:OpenHarmony cortex-m系列芯片添加工程在device目錄下創建對應的目錄,并添加工程文件OpenHarmony cortex-m系列芯片圖形和輸入接口適配圖形系統: 主要包括UI組件、布局、動畫、字體、輸入事件、窗口管理、渲染繪制等模塊,構建基于輕量OS應用框架滿足硬件資源較小的物聯網設備或者構建基于標準OS的應用框架滿足富設備(如平板和輕智能機等)的OpenHarmony系統應用開發。圖形系統在OpenHarmony中的位置:OpenH

16、armony cortex-m系列芯片圖形和輸入接口適配OpenHarmony cortex-m系列芯片圖形和輸入接口適配在現有的項目中獨立集成圖形子系統,需要做一些簡單的適配工作,主要分為以下幾部分:引擎初始化顯示設備適配輸入設備適配字體初始化屏幕刷新對接OpenHarmony cortex-m系列芯片圖形和輸入接口適配引擎初始化: 在圖形系統初始化階段直接調用 OHOS:GraphicStartUp:Init(); 就可以進行圖形引擎初始化2.顯示設備適配 設置屏幕大小、對接基礎圖元繪制,獲取圖形繪制的 buffer,把圖形繪制的數據刷到 屏幕上顯示等。 顯示層適配需要繼承實現 gfx_e

17、ngine_manager.h 中的 BaseGfxEngine 類, BaseGfxEngine 類中有3類接口: 第一類:獲取顯存、申請緩存、釋放緩存; 第二類:繪制類基礎接口,例如:畫線、Blit、Fill 等; 第三類:送顯接口,調用該接口完成把繪制內容送顯。 其中獲取顯存和送顯接口為移植不同平臺必須實現的,第二類接口, UIKit 框架有默認軟件 實現,不同平臺如有硬件加速,例如DMA2D,可選擇性適配。OpenHarmony cortex-m系列芯片圖形和輸入接口適配設置屏幕大?。?在graphic_config.h文件中設置屏幕的大小 foundation/graphic/uti

18、ls/interfaces/innerkits/graphic_config.h OpenHarmony cortex-m系列芯片圖形和輸入接口適配顯示層適配: 我們需要需要繼承實現 gfx_engine_manager.h 中的 BaseGfxEngine 類class StDevice : public BaseGfxEngine public: StDevice() virtual StDevice() void FlushRegion(const Rect& rect, const uint8_t* buffer, ColorMode mode); void Flush() overr

19、ide; BufferInfo* GetFBBufferInfo() override;我們至少要實現這幾個api, StDevice()和StDevice() 屬于構造函數和析構函數。 FlushRegion為在buffer的一塊區域上進行繪制。Flush把buffer中的內容刷到屏幕上。GetFBBufferInfo 接口為獲取圖形buffer的信息,包括buffer大小, 顏色模式(ARGB8888或RGB888),buffer的高度和寬度,及行的長度OpenHarmony cortex-m系列芯片圖形和輸入接口適配BufferInfo* StDevice:GetFBBufferInfo

20、() static BufferInfo* bufferInfo = nullptr; if (bufferInfo = nullptr) bufferInfo = new BufferInfo; bufferInfo-rect = 0, 0, 390 - 1, 390 - 1; bufferInfo-mode = RGB888; bufferInfo-color = 0 x44; bufferInfo-phyAddr = bufferInfo-virAddr = g_rectBuffer; bufferInfo-stride = 390 * 3; bufferInfo-width = 390

21、; bufferInfo-height = 390; return bufferInfo;OpenHarmony cortex-m系列芯片圖形和輸入接口適配如果使用的芯片有圖形加速模塊,則還需要實現Blit、Fill這些接口,Blit是圖像混合接口,Fill為顏色填充接口。 virtual void Blit(BufferInfo& dst, const Point& dstPos, const BufferInfo& src, const Rect& subRect, const BlendOption& blendOption); virtual void Fill(BufferInfo&

22、 dst, const Rect& fillArea, const ColorType color, const OpacityType opacity);OpenHarmony cortex-m系列芯片圖形和輸入接口適配輸入接口適配: 支持觸摸輸入、按鍵輸入和旋轉輸入。當前所有輸入設備都需要繼承 InputDevice 實現 Read 接口。 觸摸輸入繼承 PointerInputDevice 類實現 Read 接口,需要返回 x/y 坐標和按壓狀態;class TouchInput : public OHOS:PointerInputDevice public: TouchInput() virtual TouchInput() / implements read function bool Read(OHOS:DeviceData& data) override input_event touchMsg; osStatus_t ret = osMessageQueueGet(touch_screen_QueueId, &touchMsg, 0, 0); if (ret != osOK) data.state = 0;

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論