Hardware Reference
In-Depth Information
NOTE
The BoneScript library convention is to use the index numbers provided in the hardware doc-
umentation. The version of the Linux kernel we use, however, begins index numbers at 0 for
the first one registered and increases by 1, so these numbers might not always match. The
BoneScript library attempts to hide this complication from you.
Run the i2cdetect -y -r 1 command to discover the address of the display, as
shown in Example 3-4 .
Example 3-4. Using I 2 C command-line tools to discover the address of the display
bone# i2cdetect -y -r 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- 49 -- -- -- -- -- --
50: -- -- -- -- UU UU UU UU -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: 70 -- -- -- -- -- -- --
Here, you can see a device at 0x49 and 0x70 . I know I have a temperature sensor at
0x49 , so the LED matrix must be at 0.70 .
Add the code in Example 3-5 to a file called matrixLEDi2c.js and run it by using the fol-
lowing command:
bone# npm install -g sleep
bone# ./matrixLEDi2c.js
Example 3-5. LED matrix display (matrixLEDi2c.js)
#!/usr/bin/env node
// npm install -g sleep
var b = require ( ' bonescript ' );
var sleep = require ( ' sleep ' );
var port = ' / dev / i2c - 2 '
var matrix = 0x70 ;
var time = 1000000 ; // Delay between images in us
 
 
Search WWH ::




Custom Search