Remove run-time debug files
[beagleboard.org.git] / db / 3016.xml
blob92789290e54ea45b67729e890223e8a2592a48e0
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>
9     <uri>shiftOut</uri>
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>&lt;script src=&quot;/static/bonescript-demo.js&quot;&gt;&lt;/script&gt;\r
14 &lt;div id=&apos;side-menu&apos; class=&quot;t3_sidebar&quot;&gt;\r
15     &lt;ul class=&quot;left-menu&quot;&gt;&lt;strong&gt;Navigation&lt;/strong&gt;\r
16         &lt;li&gt;&lt;a href=&quot;/static/side-menu.html&quot;&gt;Menu contents&lt;/a&gt;&lt;/li&gt;\r
17     &lt;/ul&gt;\r
18 &lt;/div&gt;\r
19 &lt;div class=&quot;t3_content_1&quot;&gt;&lt;div id=&apos;connect-status&apos;&gt;&lt;/div&gt;&lt;div id=&quot;content_child&quot;&gt;\r
20 &lt;h1&gt;shiftOut(dataPin, clockPin, bitOrder, val, [callback])&lt;/h1&gt;\r
21 &lt;p&gt;&lt;b&gt;&lt;em&gt;Note&lt;/em&gt;: This doesn&apos;t work until BoneScript version 0.2.3&lt;/b&gt;&lt;/p&gt;\r
22 &lt;p&gt;Shift a byte out to a digital I/O pin clocking it with another digital\r
23 I/O pin.&lt;/p&gt;\r
24 &lt;h2&gt;Arguments&lt;/h2&gt;\r
25 &lt;ul&gt;\r
26  &lt;li&gt;&lt;em&gt;dataPin&lt;/em&gt;: the pin for the serial data&lt;/li&gt;\r
27  &lt;li&gt;&lt;em&gt;clockPin&lt;/em&gt;: the pin for the clock&lt;/li&gt;\r
28  &lt;li&gt;&lt;em&gt;bitOrder&lt;/em&gt;: b.MSBFIRST or b.LSBFIRST&lt;/li&gt;\r
29  &lt;li&gt;&lt;em&gt;val&lt;/em&gt;: the byte to be written&lt;/li&gt;\r
30  &lt;li&gt;&lt;em&gt;callback&lt;/em&gt;: called upon completion&lt;/li&gt;\r
31 &lt;/ul&gt;\r
32 &lt;h2&gt;Return value&lt;/h2&gt;\r
33 &lt;ul&gt;\r
34  &lt;li&gt;&lt;a href=&quot;/Support/BoneScript/#true&quot;&gt;true&lt;/a&gt; if successful&lt;/li&gt;\r
35  &lt;li&gt;&lt;a href=&quot;/Support/BoneScript/#false&quot;&gt;false&lt;/a&gt; on failure&lt;/li&gt;\r
36 &lt;/ul&gt;\r
37 &lt;h2&gt;callback(x)&lt;/h2&gt;\r
38 &lt;ul&gt;\r
39  &lt;li&gt;&lt;em&gt;x.err&lt;/em&gt;: error status message&lt;/li&gt;\r
40 &lt;/ul&gt;\r
41 &lt;h2&gt;Example\r
42  &lt;button class=&quot;dynlink&quot; onclick=&quot;demoRun(&apos;code&apos;)&quot;&gt;run&lt;/button&gt;\r
43  &lt;button class=&quot;dynlink&quot; onclick=&quot;demoRestore(&apos;code&apos;)&quot;&gt;restore&lt;/button&gt;\r
44 &lt;/h2&gt;\r
45 &lt;pre id=&quot;code&quot; class=&quot;use-editor&quot; style=&quot;height:900px;&quot;&gt;\r
46 //\r
47 // Demonstrate shiftOut with a 7 segment display\r
48 //\r
50 // read in the BoneScript library\r
51 var b = require(&apos;bonescript&apos;);\r
53 // define used pins\r
54 var sData  = &quot;P9_18&quot;;\r
55 var sClock = &quot;P9_22&quot;;\r
56 var sLatch = &quot;P9_17&quot;;\r
57 var sClear = &quot;P9_15&quot;;\r
59 // define other global variables\r
60 var digit = 0;\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
70 // initial states\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
77 doUpdate();\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
87 }\r
89 function doLatch() {\r
90     // latch in the value\r
91     b.digitalWrite(sLatch, b.HIGH, doLatchLow);\r
92 }\r
94 function doLatchLow() {\r
95     b.digitalWrite(sLatch, b.LOW, scheduleUpdate);\r
96 }\r
98 function scheduleUpdate() {\r
99     // update again in another 25ms\r
100     setTimeout(doUpdate, 25);\r
102 &lt;/pre&gt;\r
103 &lt;div readonly id=&apos;console-output&apos; style=&quot;height:80px;&quot;&gt;&lt;/div&gt;\r
104 &lt;h2&gt;Build and execute instructions&lt;/h2&gt;\r
105 &lt;img align=&quot;right&quot; src=&quot;/static/uploads/shiftout_bb.png&quot; width=&quot;60%&quot; /&gt;\r
106 &lt;ul&gt;\r
107     &lt;li&gt;TBD&lt;/li&gt;\r
108 &lt;/ul&gt;\r
109 &lt;h2&gt;See also&lt;/h2&gt;\r
110 &lt;h3&gt;Topics&lt;/h3&gt;\r
111 &lt;ul&gt;\r
112  &lt;li&gt;&lt;a href=&quot;/Support/BoneScript/#headers&quot;&gt;BeagleBone expansion headers&lt;/a&gt;&lt;/li&gt;\r
113  &lt;li&gt;&lt;a href=&quot;/Support/BoneScript/#digitalio&quot;&gt;Digital I/O&lt;/a&gt;&lt;/li&gt;\r
114 &lt;/ul&gt;\r
115 &lt;h3&gt;Related functions&lt;/h3&gt;\r
116 &lt;ul&gt;\r
117  &lt;li&gt;&lt;a href=&quot;/Support/BoneScript/#require&quot;&gt;require&lt;/a&gt;&lt;/li&gt;\r
118  &lt;li&gt;&lt;a href=&quot;/Support/BoneScript/pinMode&quot;&gt;pinMode&lt;/a&gt;&lt;/li&gt;\r
119 &lt;/ul&gt;\r
120 &lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;clear: both;&quot;&gt;&lt;/div&gt;\r
121 </body>
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>
126     <lang>en-us</lang>
127   </hopobject>
128 </xmlroot>