1e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang/*
2e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang * Author: Brendan Le Foll <brendan.le.foll@intel.com>
3e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang * Copyright (c) 2014 Intel Corporation.
4e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang *
5e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang * Permission is hereby granted, free of charge, to any person obtaining
6e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang * a copy of this software and associated documentation files (the
7e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang * "Software"), to deal in the Software without restriction, including
8e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang * without limitation the rights to use, copy, modify, merge, publish,
9e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang * distribute, sublicense, and/or sell copies of the Software, and to
10e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang * permit persons to whom the Software is furnished to do so, subject to
11e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang * the following conditions:
12e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang *
13e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang * The above copyright notice and this permission notice shall be
14e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang * included in all copies or substantial portions of the Software.
15e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang *
16e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang */
24e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang
25e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhangvar m = require('mraa'); //require mraa
26e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang
27e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang// helper function to go from hex val to dec
28e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhangfunction char(x) { return parseInt(x, 16); }
29e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang
30e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhangx = new m.I2c(0)
31e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhangx.address(0x62)
32e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhangx.writeReg(0, 0)
33e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhangx.writeReg(1, 0)
34e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhang
35e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhangx.writeReg(char('0x08'), char('0xAA'))
36e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhangx.writeReg(char('0x04'), 255)
37e595125fe2f8ed6af763b9da7cfd817f576958dcJianxun Zhangx.writeReg(char('0x02'), 255)
38