Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleaning up…

  • Loading branch information...
commit 9844d93197415bb6cb3d0ed608a43598fc3eb64f 1 parent 35fe330
@sbstjn sbstjn authored
View
24 srv.app.js
@@ -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});
});
View
5 srv.socket.js
@@ -7,6 +7,7 @@
* @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) {
/**
@@ -14,9 +15,9 @@ define(['socket.io', 'public/scripts/libs/Noduino', 'public/scripts/libs/Noduino
* @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();
View
8 srv.web.js
@@ -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);
});
View
40 views/home.jade
@@ -5,17 +5,17 @@ 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
@@ -23,23 +23,19 @@ section#homeContent
.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
@@ -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…
@@ -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
@@ -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
@@ -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…
View
5 views/layout.jade
@@ -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
@@ -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
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.