-
Notifications
You must be signed in to change notification settings - Fork 1.1k
DAC
wuzhun.wz edited this page Jun 12, 2018
·
1 revision
API
|
说明
|
DAC.open(id)
|
功能:打开dac
参数: id:和板级配置文件中的id保持一致
返回值:成功:回资源handle,失败:-1
|
DAC.close(handle)
|
功能:关闭dac
参数: handle:资源handle,为DAC.open的返回值;
返回值:0=ok other=fail
|
DAC.setVol(handle,vol)
|
功能:设置dac输出电压
参数: handle:资源handle,为DAC.open的返回值;
vol:电压值
返回值:0=ok other=fail
|
DAC.getVol(handle)
|
功能:获取当前dac电压;
参数: handle:资源handle;
返回值:电压值;
|
参数名
|
类型/功能/值
|
说明
|
"id"
|
功能:资源唯一性标志;
类型:number
|
/*apps/js/board_config.json*/
{
"DAC":[
{
"id":"led",
"port":1,
"voltage":255
}
]
}
1)esp32Kit开发板 2)LED模块
EPS32 IO25引脚 连接 LED模块的正极; EPS32 GND引脚 连接 LED模块的负极;
/*apps/js/board_config.json*/
{
"DAC":[
{
"id":"led",
"port":1,
"voltage":255
}
]
}
var led_handle = DAC.open('led');
var cur_voltage = DAC.getVol(led_handle);
console.log('cur_voltage:'+cur_voltage);
setInterval(function(){
cur_voltage = cur_voltage + 1;
if(cur_voltage >= 255){
cur_voltage = 0;
}
DAC.setVol(led_handle,cur_voltage);
},50);
LED亮度由弱变强,当低于某个值是,LED完全熄灭;
�
| Home | Tutorial | Hardware | Porting Guide | Utilities | API Reference | Technical Docs | Certification |
Crafted with ❤️ by AliOS Things Team.