通过intel xdk,如下的程序可以打印Hello world到grove lcd上
var mraa = require ('mraa'); var LCD = require ('jsupm_i2clcd'); console.log('Current version of MRAA is', mraa.getVersion()); var light = new mraa.Aio(0); var lightValue; var lcdMessage=" "; var myLCD = new LCD.Jhd1313m1(6, 0x3E, 0x62); loop(); function loop(){ lightValue = light.read(); lightValue = Math.round( lightValue*.1); lcdMessage = "Light is @ "+lightValue+"%"; myLCD.setCursor(0,1); console.log(lcdMessage); myLCD.write(lcdMessage); setTimeout(loop,1000); }
如果碰到如下错误
ERROR:Error: Cannot find module ‘jsupm_i2clcd‘
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/node_app_slot/main.js:5:12)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.run
可以通过下面的方法解决更新libmraa 和 upm
</pre><pre name="code" class="javascript">cat > /etc/opkg/mraa-upm.conf <<EOF src mraa-upm http://iotdk.intel.com/repos/1.1/intelgalactic EOF opkg upgrade opkg update
然后通过
opkg info upm | head -n2
查看是否得到类似于如下的信息
Package: upm Version: 0.1.8.32
opkg install upm
原文地址:http://blog.csdn.net/alexwang1983/article/details/40648657