• Home
Name Date Size #Lines LOC

..--

AppScope/12-May-2024-3533

entry/12-May-2024-916789

hvigor/12-May-2024-2019

README.mdD12-May-20242.5 KiB12080

build-profile.json5D12-May-20241.2 KiB5151

hvigorfile.tsD12-May-2024234 75

hvigorwD12-May-20241.4 KiB4928

hvigorw.batD12-May-20241.5 KiB6547

oh-package.json5D12-May-2024242 1312

README.md

1# APP读取ADC温度传感器
2
3**PS:建议学习该例程前先学习`..\..\hardware\adc`例程**
4
5## 例程使用方法
6
7### 一.添加子系统
8
9打开`build/subsystem_config.json`文件,**添加下列语句**
10
11```json
12  "napisubsys":{
13    "path":"vendor/unionman/unionpi_tiger/sample/napi/napisubsys",
14    "name":"napisubsys"
15  },
16```
17
18### 二.添加组件
19
20打开`vendor/unionman/unionpi_tiger/sample/napi/napisubsys/ohos.build`文件,修改为
21
22```json
23{
24    "subsystem": "napisubsys",
25    "parts": {
26        "adc_component": {
27            "variants": [
28                "phone"
29            ],
30            "module_list": [
31                "//vendor/unionman/unionpi_tiger/sample/napi/napisubsys/adc_component:adc_napi"
32            ]
33        }
34    }
35}
36```
37
38
39
40### 三.添加产品定义
41
42打开`vendor/unionman/unionpi_tiger/config.json`文件,在`"subsystems":`中添加下列语句
43
44```json
45    {
46      "subsystem": "napisubsys",
47      "components": [
48        {
49          "component": "adc_component",
50          "features": []
51        }
52      ]
53    },
54```
55
56
57
58### 四.编译 打包 烧录
59
60在`vendor/unionman/unionpi_tiger/sample/BUILD.gn`,在`"deps ="`中添加下列语句
61
62```gn
63"napi/napisubsys/adc_component:sample_server"
64```
65
66编译、打包、烧录参考:https://gitee.com/openharmony/device_board_unionman/blob/master/unionpi_tiger/README_zh.md#%E7%BC%96%E8%AF%91%E4%B8%8E%E8%B0%83%E8%AF%95
67
68### 五.使用
69
70- 重新挂载,打开权限
71```
72hdc_std shell
73mount -o rw,remount /
74```
75
76- 打开`cmd窗口`
77
78```
79hdc_std file send Z:\openharmony\OpenHarmony-3.1-release\out\a311d\common\common\sample_server /data
80```
81
82- 与开发板交互
83
84```
85hdc_std shell
86```
87
88- 修改权限
89
90```
91chmod 777 data/sample_server
92```
93
94- 运行`sample_server`
95
96```
97./data/sample_server
98```
99
100- 安装app
101
102(1).用DevEco Studio打开位于 `unionman\a311d\sample\app` 的 `adc_app` 文件夹
103
104(2).设置应用签名
105
106![2](../figures/i2c/2.png)
107
108![3](../figures/i2c/3.png)
109
110(3).将位于`vendor\unionman\unionpi_tiger\sample\napi\napisubsys`中的`@ohos.adc_napi.d.ts`复制并放在`X:\Users\XXXXX\AppData\Local\OpenHarmony\Sdk\ets\3.1.6.6\api`文件夹内
111
112(*此路径是由SDK安装目录决定,如不清楚自己路径可打开DevEco Studio—工具—SDK管理—外观和行为—OpenHarmony SDK中查看*)
113
114(4).安装app至开发板
115
116在DevEco Studio右上角点击图片上所示按钮![4](../figures/i2c/4.png)
117
118### 六.效果
119
120![5](../figures/adc_effect.gif)