显示屏-display

描述

_image 显示屏,父对象为device.io,无子对象。


事件

screenshot: 截图完成,事件函数定义:onScreenshot(path, result), path为保存路径, result为布尔值,true-成功,false-失败。


属性

名称

功能说明

脚本例子

enabled

使能,当enabled为true,打开显示屏相关电路,否则关闭. 当关闭后,系统会切断显示屏供电,系统功耗会下降。

device.io.display.enabled=0 关闭显示屏供电

brightness

背光亮度,参数代表亮度,范围0-100, 100最亮, 0 关闭背光

device.io.display.brightness=100 将背光调到最亮

方法

名称

功能说明

脚本例子

screenshot(path)

截图当前页面并保存到文件路径,截图完成后会触发onScreenshot(path,result)

device.io.display.screenshot('/storage/d0/1.png');截图页面保存到U盘

screenshot(path,x,y,width,height)

截图当前页面指定区域保存到文件路径,适用于保存页面内控件区域。截图完成后会触发onScreenshot(path,result)

device.io.display.screenshot('/storage/d0/1.png', ui.main.plot.x,ui.main.plot.y, ui.main.plot.width, ui.main.plot.height);截取波形图保存到U盘

使用说明

如何防止截图保存U盘丢失

  • device.io.display.screenshot(path) 这个方法是异步方法,截图完成后会调用onScreenshot()方法。建议调用service.data.storage.sync(path);让文件立即保存,防止掉电丢失。

    device.io.display.onScreenshot = function(path, result) {
      if (result) {
         service.data.storage.sync(path);
      }
    };