Difference between revisions of "EBC Mini Project 04"

From eLinux.org
Jump to: navigation, search
m (Cleaning up for Fall 2013)
m (Remove Me)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:ECE497 |Mini04]]
+
Moved to hw.  No longer needed.
{{YoderHead}}
 
  
 
== Introduction ==
 
== Introduction ==
The goal here is to add a web-based graphical display to your sensor. In '''exercises/node.js/realtime''' you will find two examples of node.js servers that display realtime data from the beagle.
+
The goal here is to add a web-based graphical display to your sensor. In '''exercises/realtime''' you will find examples of a node.js server that displays realtime data from the beagle.
  
 +
; boneServer.js
 +
: This is the server that works with the following clients.
 +
; ioPlot.js, ioPlot.html
 +
: This is an example that reads a gpio port and analog in and plots the output in a web browser. It also has buttons to control the built-in USR LEDS.
 
; buttonBox.js, buttonBox.html
 
; buttonBox.js, buttonBox.html
: This is a bone-based example that reads a gpio port, analog in and an i2c device and displays the output in a web browser.
+
: This is an example that reads a gpio port, analog in and and i2c device and plots the output in a web browser. It also has buttons to control the built-in USR LEDS and a slider to control a PWD controlled LED.
; realtimeDemo.js, realtimeDemo.html
+
; audio.js, audio.html
: This is an xM-based example that reads realtime audio and displays it.
+
: This is an example that reads realtime audio and displays it.
 
+
; matrixLED.js, matrixLED.html
Modify one of these to work with your sensor. If you interfaced a display, modify to control your display. I'll leave it open to how you will do it.
+
: This is an example that controls the 8 by 8 bicolor LED matrix.
  
 
== Running the code ==
 
== Running the code ==
 
Here's how to run the demos
 
Here's how to run the demos
  beagle$ '''cd exercises/node.js/realtime'''
+
  beagle$ '''cd exercises/realtime'''
 
  beagle$ '''git pull'''
 
  beagle$ '''git pull'''
  beagle$ '''opkg update'''
+
  beagle$ '''node boneServer.js'''
beagle$ '''opkg install nodejs'''  (Don't install '''node''', it's not what you think.)
 
 
 
On the Bone:
 
beagle$ '''node buttonBox.js'''
 
 
 
Then point a browser to '''bone:8081'''.  The default port is 8081.  You can change it if you like.
 
 
 
On the xM;
 
beagle$ '''node realtimeDemo.js'''
 
  
Point to '''xM:8080''' and playYou may have to edit the code to use the right audio device. Search for '''arecord'''.
+
Then point a browser to '''192.168.7.2:8080'''.  (The default port is 8080, but you can change it if you like just by editing boneServer.js.)
  
 
== i2c ==
 
== i2c ==
Line 45: Line 39:
  
 
In either case I suggest you get the easy case working first, then do the challenge.
 
In either case I suggest you get the easy case working first, then do the challenge.
 
{{YoderFoot}}
 

Latest revision as of 13:47, 22 October 2013

Moved to hw. No longer needed.

Introduction

The goal here is to add a web-based graphical display to your sensor. In exercises/realtime you will find examples of a node.js server that displays realtime data from the beagle.

boneServer.js
This is the server that works with the following clients.
ioPlot.js, ioPlot.html
This is an example that reads a gpio port and analog in and plots the output in a web browser. It also has buttons to control the built-in USR LEDS.
buttonBox.js, buttonBox.html
This is an example that reads a gpio port, analog in and and i2c device and plots the output in a web browser. It also has buttons to control the built-in USR LEDS and a slider to control a PWD controlled LED.
audio.js, audio.html
This is an example that reads realtime audio and displays it.
matrixLED.js, matrixLED.html
This is an example that controls the 8 by 8 bicolor LED matrix.

Running the code

Here's how to run the demos

beagle$ cd exercises/realtime
beagle$ git pull
beagle$ node boneServer.js

Then point a browser to 192.168.7.2:8080. (The default port is 8080, but you can change it if you like just by editing boneServer.js.)

i2c

My buttonBox.js uses a very crude approach to i2c. I just call i2cget every time I want a value. There is lots of overhead in running i2cget each time. If you are using an i2c device, modify myi2cget.c (in exercises/i2c) to return the current value from your device every time the user hits return. Use this with your version of buttonBox.js to read your i2c device.

How it works

In my code the browser does a pull at a fixed time interval. That is, the function updateTop() sends the messages ain and gpio to the server and then sets a timer (setTimeout()) to send them again later. When the server receives a message, say ain, it reads the correct I/O and sends the data back via the ain message. When the browser receives the message it stores the value in the correct place in an array and tells the plotting routine to plot it.

Now, read the above paragraph with buttonBox.html (for the browser) and buttonBox.js (for the server) in front of you. Find the functions noted above and see what you can figure out.

Here's the challenge: Modify the code to do a push. That is, have the server set a timer and at a fixed interval send the data over to the browser.

Grading

If your solution uses my 'pull' code you will get at most 7 or 8 out of 10. If you are able to modify the code to do a 'push' you can get full credit.

If you are doing i2c the way I did it, you can get 7 or 8 out of 10, but if you made the change I request above, you can get full credit (without having to do the 'push').

In either case I suggest you get the easy case working first, then do the challenge.