Skip to content

Commit

Permalink
Cleaning up…
Browse files Browse the repository at this point in the history
  • Loading branch information
sbstjn committed Mar 5, 2012
1 parent 35fe330 commit 9844d93
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 41 deletions.
24 changes: 17 additions & 7 deletions srv.app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,34 @@
* @license MIT License – http://www.opensource.org/licenses/mit-license.php
* @url https://github.com/semu/noduino
*/

define(['kickstart', 'module', 'path', 'fs'], function (kickstart, module, path, fs) {
var kickstart = kickstart.withConfig({'name': 'localhost', 'port': 8080, 'path': './'});
var srv = kickstart.srv();

var fileContents = fs.readFileSync('./examples.snippet');
var sections = (fileContents + '').split('###');
var examples = {};

/**
* Load file with example snippets
*/
var fileContents = fs.readFileSync('./examples.snippet'),
sections = (fileContents + '').split('###'),
examples = {};
for (var i = 0; i < sections.length; i++) {
var tmp = sections[i].split("\n");
var key = tmp.shift();
var tmp = sections[i].split("\n"),
key = tmp.shift();
tmp.pop();
examples[key] = tmp.join("\n");
}

/**
* Catch request for serving home page
*/
srv.all('/', function(req, res) {
res.render('home', {jsApp: 'main', active: 'home', title: 'noduino', 'examples': examples});
});


/**
* Catch request for serving walkLED example page
*/
srv.all('/examples/walkLED.html', function(req, res) {
res.render('example-walkLED', {jsApp: 'walkLED', active: 'examples', title: 'noduino', 'examples': examples});
});
Expand Down
5 changes: 3 additions & 2 deletions srv.socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
* @license MIT License – http://www.opensource.org/licenses/mit-license.php
* @url https://github.com/semu/noduino
*/

define(['socket.io', 'public/scripts/libs/Noduino', 'public/scripts/libs/Noduino.Serial', 'public/scripts/libs/Logger'], function(io, Noduino, Connector, Logger) {

/**
* Define SocketHandler
* @param object socket Socket.IO
*/
var SocketHandler = function(socket) {
this.sockets = {};
this.sockets = {};
this.arduinos = {};
this.handler = socket.listen(8090);
this.handler = socket.listen(8090);
this.pinCache = {};

this.bindings();
Expand Down
8 changes: 3 additions & 5 deletions srv.web.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
* @license MIT License – http://www.opensource.org/licenses/mit-license.php
* @url https://github.com/semu/noduino
*/

var requirejs = require('requirejs');
requirejs.config({nodeRequire: require});

/**
* Load Socket.IO and HTTP Server
*/
requirejs(['./srv.app', './srv.socket'],function(app, io) {
var kickstart = app.kickstart;
var router = kickstart.listen();
var kickstart = app.kickstart,
router = kickstart.listen();
console.log("Listening on http://%s:%d", kickstart.conf().name, router.address().port);
});
40 changes: 17 additions & 23 deletions views/home.jade
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,37 @@ header.jumbotron.subhead#overview
.span4
img.bs-icon(src="/images/glyphicons_155_show_thumbnails.png")
h2 Easy Arduino Access
p Initialize your Arduino board, define registered pins and send commands. Use digital and analog read or write to use control buttons or switch connected LEDs. <strong>Listen for events</strong> happening on your Arduino to control your Web Application with analog controls…
.span4
img.bs-icon(src="/images/glyphicons_009_magic.png")
h2 JS Proof of Concept
p The first version of
a(href="") noduino
| was completely built for fun. I had bought an Arduino, wanted to play and for no good reason tried sending commands with <strong>JavaScript</strong> using a nice <strong>HTML5</strong> interface with to my Arduino. Imagine controlling browser games with an old NES game pad!
p Initialize your Arduino board, define registered pins and send commands. Use digital and analog read or write to control buttons or switch connected LEDs. <strong>Listen for events</strong> happening on your Arduino to control your Web Application with analog controls…
.span4
img.bs-icon(src="/images/glyphicons_214_resize_small.png")
h2 Client and Server in JS
p Thanks to Node.js and modern web browsers all server code as well as all client code is written in JavaScript. There is no difference in accessing your Arduino over <strong>WebSocket</strong> or a <strong>Serial</strong> connection. All methods and objects remain the same, written code is highly portable.
.span4
img.bs-icon(src="/images/glyphicons_009_magic.png")
h2 JS Proof of Concept
p The first release of
a(href="") noduino
| is build for fun and as a proof of concept. For no good reason I tried sending commands to my Arduino with <strong>JavaScript</strong> using a nice <strong>HTML5</strong> interface. Imagine controlling browser games with an old NES game pad!
section#homeContent
.page-header
h1 Connect HTML Interface to Arduino
.row
.span3
p Make sure your
strong Arduino
| is connected with your computer, this commands works fine for Mac OS X.
| is connected with your computer, this commands works fine for me:
.span9
pre.prettyprint.linenums=examples.basics
.row
.span3
p
strong Download
| Node.js, installed needed packages with npm and start
a(href="#") noduino
| to see this page.
a(href="https://github.com/semu/noduino") Download noduino
| , install needed packages with npm, upload <code>duino/src/du.ino</code> to your Arduino and you are good to go…
.span9
pre.prettyprint.linenums=examples.node
.row
.span3
p See the provided
strong Examples
| or establish a connection to Arduino by yourself.
p See the included exmaples on this page or have a look at the example wiring for firing and catching events on your Arduino!
.span9
pre.prettyprint.linenums=examples.connect
.row.example
Expand All @@ -51,7 +47,6 @@ section#homeContent
.alert.alert-info Please connect to your Arduino using the button.
.alert.hide.alert-error Unable to connect to Arduino!
.alert.hide.alert-success Connection to Arduino established!

.page-header
h1 Switching LED modes
small Simple methods for switching LED modes, blinking and fading…
Expand All @@ -61,13 +56,15 @@ section#homeContent
strong Arduino
| it is very easy to
strong toggle an LED
| connected to pin 13. All communication between the web browser and server is handled with Socket.IO, on the server commands are send to Arduino using
a(href="#") duino.
| connected to a pin on you board. All data exchange between the web browser and server is handled with Socket.IO, on the server commands are send to Arduino using
a(href="https://github.com/ecto/duino") duino.
|
strong Noduino
| enables
strong Real-Time Arduino
| control using WebSockets!
| control using WebSockets! Please see the
a(href="#communication") communication schema
| to get how it works…
.span9
pre.prettyprint.linenums=examples.toggleLED
.row.example
Expand Down Expand Up @@ -101,9 +98,6 @@ section#homeContent
.alert.hide.alert-info Please connect to your Arduino using the button.
.alert.hide.alert-error Connect to Arduino first!
.alert.hide.alert-success Connection to Arduino established!



.page-header
h1 Listening for Events on Arduino
small Catch a button push event and fade on your LED
Expand Down Expand Up @@ -159,4 +153,4 @@ section#homeContent
a(href="#") Fritzing Project
| it's easy to get started with basic prototyping. The already existing
a(href="#") duino
| project helped developing the first steps and is now an imported part of noduino's core components. Thanks to the Open Source community, you made this possible! Keep the good work up…
| project helped developing the first steps and is now an imported part of noduino's core components. Thanks to the Open Source community, you made this possible! Keep the good work up…
5 changes: 1 addition & 4 deletions views/layout.jade
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ html(lang="en")
link(rel="stylesheet", href="/styles/init.css")
script(data-main="/scripts/app." + jsApp, type="text/javascript", src="/scripts/vendor/require-jquery.js")
script(type="text/javascript", src="http://localhost:8090/socket.io/socket.io.js")
// script(type="text/javascript", src="/scripts/init.js")
// script(type="text/javascript", src="/scripts/prettify.js")
body
.navbar.navbar-fixed-top(style="z-index: 4;position:absolute;")
.navbar-inner
Expand All @@ -18,7 +16,7 @@ html(lang="en")
li(class=(active == 'home' ? 'active' : ''))
a(href="/") Home
li.dropdown(class=(active == 'examples' ? 'active' : ''))
a.dropdown-toggle(href="#",data-toggle="dropdown") Example Wiring
a.dropdown-toggle(href="#",data-toggle="dropdown") Example Wirings
b.caret
ul.dropdown-menu
li
Expand All @@ -29,7 +27,6 @@ html(lang="en")
ul.nav
li
a(href="http://semu.mp") semu.mp

a(href="#")
img(style="position: absolute; top: 0; right: 0; border: 0; z-index: 10;",src="/images/forkme.png",alt="Fork me on GitHub")
.container!=body
Expand Down

0 comments on commit 9844d93

Please sign in to comment.