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="2892" name="processingjs" prototype="Page" created="1374308047101" lastModified="1375888514901">
5 <hop:parent idref="2471" prototyperef="Page"/>
6 <http_browser>Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.71 Safari/537.36</http_browser>
8 <uri>processingjs</uri>
9 <http_host>beagleboard.org</http_host>
10 <time type="date">21.07.2013 01:28:51 CDT</time>
11 <pseudoparent idref="2471" prototyperef="Page"/>
12 <http_remotehost>127.0.0.1</http_remotehost>
13 <hopsession>127.0.0.12.0.200.cbriq8cyreb6</hopsession>
14 <user>jkridner@gmail.com</user>
15 <body><h1><a href="http://processingjs.org/" class="external">Processing.JS</a></h1>
16 <canvas id="mysketch"></canvas>
17 <script src="/static/bonescript.js"></script>
18 <script src="/static/processing.js"></script>
21 var canvas = document.getElementById('mysketch');
22 var pjs = new Processing(canvas);
30 var buttonStatus = false;
31 var LED_RED = 'P9_42';
32 var LED_GREEN = 'P9_14';
33 var LED_BLUE = 'P9_16';
34 var BUTTON = 'P8_19';
35 var POT = 'P9_36';
37 // Get the BoneScript library and begin updating the canvas
38 setTargetAddress('192.168.7.2', {initialized: run});
40 var b = require('bonescript');
41 b.pinMode(LED_RED, b.OUTPUT);
42 b.pinMode(LED_GREEN, b.OUTPUT);
43 b.pinMode(LED_BLUE, b.OUTPUT);
44 b.pinMode(BUTTON, b.INPUT);
46 // Setup the Processing Canvas
47 pjs.setup = function() {
58 pjs.draw = function() {
59 // Calculate some fading values based on the frame count
60 radius = 50.0 + 10.0*pjs.sin(pjs.frameCount / 4);
61 brightness = (radius - 40.0) / 20.0;
63 // Set the RGB LED color based on the status of the button
65 b.analogWrite(LED_RED, brightness);
66 b.analogWrite(LED_BLUE, 0);
68 b.analogWrite(LED_RED, 0);
69 b.analogWrite(LED_BLUE, brightness);
72 // Track circle to new destination
79 // Set fill-color to blue or red, based on button status
80 if(buttonStatus) pjs.fill(200, 30, 20)
81 else pjs.fill(0, 121, 184);
83 // Set stroke-color white
87 pjs.ellipse(X, Y, radius, radius);
89 // Fetch slider location for next time
90 b.analogRead(POT, onAnalogRead);
92 // Fetch button status
93 b.digitalRead(BUTTON, onDigitalRead);
96 // Handle data back from potentiometer
97 function onAnalogRead(x) {
98 if(!x.err && (x.value >= 0) && (x.value <= 1)) {
99 nY = x.value * pjs.height;
103 // Handle data back from button
104 function onDigitalRead(x) {
105 buttonStatus = (x.value == b.LOW) ? true : false;
113 <div style="clear:both;"></div></body>
114 <http_language>en-US,en;q=0.8</http_language>
115 <is_xhtml type="boolean">true</is_xhtml>
116 <http_referer>http://beagleboard.org/support/BoneScript/processingjs/edit</http_referer>
117 <hop:child idref="3008" prototyperef="Page"/>