1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <?xml-stylesheet type="text/xsl" href="helma.xsl"?>
3 <xmlroot xmlns:hop="http://www.helma.org/docs/guide/features/database">
4 <hopobject id="3016" name="shiftOut" prototype="Page" created="1376879636644" lastModified="1376886164210">
5 <hop:parent idref="2471" prototyperef="Page"/>
6 <is_xhtml type="boolean">true</is_xhtml>
7 <http_remotehost>192.91.75.29</http_remotehost>
8 <http_language>en-US,en;q=0.8</http_language>
10 <http_browser>Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36</http_browser>
11 <time type="date">18.08.2013 23:22:44 CDT</time>
12 <hopsession>192.91.75.172.24.112.yj2b7vxk8v3k</hopsession>
13 <body><script src="/static/bonescript-demo.js"></script>
\r
14 <div id='side-menu' class="t3_sidebar">
\r
15 <ul class="left-menu"><strong>Navigation</strong>
\r
16 <li><a href="/static/side-menu.html">Menu contents</a></li>
\r
19 <div class="t3_content_1"><div id='connect-status'></div><div id="content_child">
\r
20 <h1>shiftOut(dataPin, clockPin, bitOrder, val, [callback])</h1>
\r
21 <p><b><em>Note</em>: This doesn't work until BoneScript version 0.2.3</b></p>
\r
22 <p>Shift a byte out to a digital I/O pin clocking it with another digital
\r
24 <h2>Arguments</h2>
\r
26 <li><em>dataPin</em>: the pin for the serial data</li>
\r
27 <li><em>clockPin</em>: the pin for the clock</li>
\r
28 <li><em>bitOrder</em>: b.MSBFIRST or b.LSBFIRST</li>
\r
29 <li><em>val</em>: the byte to be written</li>
\r
30 <li><em>callback</em>: called upon completion</li>
\r
32 <h2>Return value</h2>
\r
34 <li><a href="/Support/BoneScript/#true">true</a> if successful</li>
\r
35 <li><a href="/Support/BoneScript/#false">false</a> on failure</li>
\r
37 <h2>callback(x)</h2>
\r
39 <li><em>x.err</em>: error status message</li>
\r
42 <button class="dynlink" onclick="demoRun('code')">run</button>
\r
43 <button class="dynlink" onclick="demoRestore('code')">restore</button>
\r
45 <pre id="code" class="use-editor" style="height:900px;">
\r
47 // Demonstrate shiftOut with a 7 segment display
\r
50 // read in the BoneScript library
\r
51 var b = require('bonescript');
\r
54 var sData = "P9_18";
\r
55 var sClock = "P9_22";
\r
56 var sLatch = "P9_17";
\r
57 var sClear = "P9_15";
\r
59 // define other global variables
\r
61 var segments = [ 0xC0, 0xF9, 0xA4, 0xB0, 0x99,
\r
62 0x92, 0x82, 0xF8, 0x80, 0x90 ];
\r
64 // configure pins as outputs
\r
65 b.pinMode(sData, b.OUTPUT);
\r
66 b.pinMode(sClock, b.OUTPUT);
\r
67 b.pinMode(sLatch, b.OUTPUT);
\r
68 b.pinMode(sClear, b.OUTPUT);
\r
71 b.digitalWrite(sData, b.LOW);
\r
72 b.digitalWrite(sClock, b.LOW);
\r
73 b.digitalWrite(sLatch, b.LOW);
\r
74 b.digitalWrite(sClear, b.HIGH);
\r
76 // call function to start updating the LED shift register
\r
79 // function to update the LED shift register
\r
80 function doUpdate() {
\r
81 // shift out the character LED pattern
\r
82 b.shiftOut(sData, sClock, b.MSBFIRST,
\r
83 segments[digit], doLatch);
\r
85 // update the digit for next time
\r
86 digit = (digit + 1) % 10;
\r
89 function doLatch() {
\r
90 // latch in the value
\r
91 b.digitalWrite(sLatch, b.HIGH, doLatchLow);
\r
94 function doLatchLow() {
\r
95 b.digitalWrite(sLatch, b.LOW, scheduleUpdate);
\r
98 function scheduleUpdate() {
\r
99 // update again in another 25ms
\r
100 setTimeout(doUpdate, 25);
\r
103 <div readonly id='console-output' style="height:80px;"></div>
\r
104 <h2>Build and execute instructions</h2>
\r
105 <img align="right" src="/static/uploads/shiftout_bb.png" width="60%" />
\r
107 <li>TBD</li>
\r
109 <h2>See also</h2>
\r
110 <h3>Topics</h3>
\r
112 <li><a href="/Support/BoneScript/#headers">BeagleBone expansion headers</a></li>
\r
113 <li><a href="/Support/BoneScript/#digitalio">Digital I/O</a></li>
\r
115 <h3>Related functions</h3>
\r
117 <li><a href="/Support/BoneScript/#require">require</a></li>
\r
118 <li><a href="/Support/BoneScript/pinMode">pinMode</a></li>
\r
120 </div></div><div style="clear: both;"></div>
\r
122 <pseudoparent idref="2471" prototyperef="Page"/>
123 <http_referer>http://beagleboard.org/support/BoneScript/shiftOut/edit</http_referer>
124 <http_host>beagleboard.org</http_host>
125 <user>jkridner@gmail.com</user>