forked from nonolith/pixelpulse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c293b6f
commit e3d853b
Showing
12 changed files
with
189 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Copyright (C) Kevin Mehall | ||
Copyright (C) Ian Daniher | ||
Copyright (C) Nonolith Labs | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
1. Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
3. The name of the author may not be used to endorse or promote products | ||
derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
#!/usr/bin/env python2 | ||
# Arduino Firmata driver for Pixelpulse | ||
# Distributed under the terms of the BSD License | ||
# (C) 2011 Kevin Mehall (Nonolith Labs) <[email protected]> | ||
|
||
from optparse import OptionParser | ||
import time | ||
import tornado_serial | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
#!/usr/bin/env python2 | ||
# Example serial text input driver for Pixelpulse | ||
# Distributed under the terms of the BSD License | ||
# (C) 2011 Kevin Mehall (Nonolith Labs) <[email protected]> | ||
|
||
import pixelpulse | ||
import tornado_serial | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
#!/usr/bin/env python2 | ||
# BusPirate driver for Pixelpulse | ||
# Distributed under the terms of the BSD License | ||
# (C) 2011 Kevin Mehall (Nonolith Labs) <[email protected]> | ||
|
||
from optparse import OptionParser | ||
import time | ||
import tornado_serial | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,104 @@ | ||
# Pixelpulse browser UI | ||
# Distributed under the terms of the BSD License | ||
# (C) 2011 Kevin Mehall (Nonolith Labs) <[email protected]> | ||
|
||
dropdownButton = (options, callback) -> | ||
r = $("<div class='dropdownButton'>").delegate 'a', 'click', (e) -> | ||
if not $(this).siblings().length then return | ||
if not $(this).is(':first-child') | ||
$(this).detach().prependTo(d) | ||
callback($(this).text()) | ||
else if not r.hasClass('opened') | ||
r.addClass('opened') | ||
$(document.body).one 'click', -> | ||
r.removeClass('opened') | ||
e.stopPropagation() | ||
d = $('<div>').appendTo(r) | ||
|
||
for i in options | ||
$("<a>").text(i).appendTo(d) | ||
class PixelpulseApp | ||
constructor: -> | ||
@channels = {} | ||
@data = [] | ||
|
||
ts = $("#timeseries").get(0) | ||
|
||
@perfstat_count = 0 | ||
@perfstat_acc = 0 | ||
|
||
handleDragOver = (self, e, draggedElem, draggableMatch, posFunc) -> | ||
if $(e.target).hasClass('insertion-cursor') | ||
return e.preventDefault() | ||
|
||
r.set = (option) -> | ||
d.children().each -> | ||
if $(this).text() == option | ||
$(this).remove() | ||
d.prepend($("<a>").text(option)) | ||
tgt = $(e.target).closest(draggableMatch) | ||
|
||
getCursor = -> | ||
$(".insertion-cursor").remove() | ||
return $("<div class='insertion-cursor'>").addClass(window.draggedChannel.cssClass) | ||
|
||
if tgt.length | ||
if draggedElem == tgt.get(0) | ||
tgt.addClass('dnd-oldpos').hide().after(getCursor()) | ||
if tgt.is('#timesection') | ||
if not tgt.parent().children('.insertion-cursor:last-child').length | ||
tgt.parent().append(getCursor()) | ||
else if posFunc(tgt) | ||
if not tgt.prev().hasClass('insertion-cursor') | ||
tgt.before(getCursor()) | ||
else | ||
if not tgt.next().hasClass('insertion-cursor') | ||
tgt.after(getCursor()) | ||
else | ||
$(self).prepend(getCursor()) | ||
|
||
e.preventDefault() | ||
|
||
return r | ||
ts.ondragover = (e) -> | ||
draggedElem = window.draggedChannel.showGraph and window.draggedChannel.tsRow.get(0) | ||
handleDragOver(this, e, draggedElem, 'section', (tgt) -> e.offsetY < tgt.get(0).offsetHeight/2) | ||
|
||
ts.ondrop = (e) -> | ||
cur = $(this).find(".insertion-cursor") | ||
if cur.length | ||
cur.replaceWith(window.draggedChannel.showTimeseries()) | ||
ts = $("#timeseries").get(0) | ||
|
||
|
||
mp = $('#meters').get(0) | ||
|
||
mp.ondragover = (e) -> | ||
draggedElem = window.draggedChannel.tile.get(0) | ||
handleDragOver(this, e, draggedElem, '.meter', (tgt) -> e.offsetX < tgt.get(0).offsetWidth/2) | ||
|
||
mp.ondrop = (e) -> | ||
cur = $(this).find(".insertion-cursor") | ||
if cur.length | ||
window.draggedChannel.hideTimeseries() | ||
cur.replaceWith(window.draggedChannel.tile) | ||
|
||
mp.ondragend = ts.ondragend = (e) -> | ||
$('.insertion-cursor').remove() | ||
$('.dnd-oldpos').show().removeClass('dnd-oldpos') | ||
|
||
onConfig: (o) -> | ||
$('#meters, #meters-side').empty() | ||
@channels = {} | ||
self = this | ||
for c in o | ||
if c.id == 'time' | ||
n = new TimeChannel(c) | ||
else if c.type == 'digital' | ||
n = new DigitalChannel(c) | ||
else | ||
n = new AnalogChannel(c) | ||
@channels[n.id] = n | ||
n._setValue = (v, s) -> self.setChannel(this.id, v, s) | ||
|
||
onData: (data) -> | ||
if params.perfstat | ||
t1 = new Date() | ||
@data.push(data) | ||
for name, c of @channels | ||
if data[name]? then c.onValue(data.time, data[name]) | ||
if params.perfstat | ||
t2 = new Date() | ||
@perfstat_acc += t2-t1 | ||
if (@perfstat_count += 1) == 25 | ||
$('#perfstat').text(@perfstat_acc / 25 + "ms/render") | ||
@perfstat_acc = @perfstat_count = 0 | ||
|
||
onState: (channel, state) -> | ||
@channels[channel].onState(state) | ||
|
||
setChannel: (name, value, state) -> | ||
console.error("setChannel should be overridden by transport") | ||
|
||
|
||
class Channel | ||
constructor: (o) -> | ||
@name = o.name | ||
|
@@ -205,112 +278,38 @@ relMousePos = (elem, event) -> | |
o = $(elem).offset() | ||
return [event.pageX-o.left, event.pageY-o.top] | ||
|
||
class PixelpulseApp | ||
constructor: -> | ||
@channels = {} | ||
@data = [] | ||
|
||
ts = $("#timeseries").get(0) | ||
|
||
@perfstat_count = 0 | ||
@perfstat_acc = 0 | ||
|
||
handleDragOver = (self, e, draggedElem, draggableMatch, posFunc) -> | ||
if $(e.target).hasClass('insertion-cursor') | ||
return e.preventDefault() | ||
|
||
tgt = $(e.target).closest(draggableMatch) | ||
|
||
getCursor = -> | ||
$(".insertion-cursor").remove() | ||
return $("<div class='insertion-cursor'>").addClass(window.draggedChannel.cssClass) | ||
|
||
if tgt.length | ||
if draggedElem == tgt.get(0) | ||
tgt.addClass('dnd-oldpos').hide().after(getCursor()) | ||
if tgt.is('#timesection') | ||
if not tgt.parent().children('.insertion-cursor:last-child').length | ||
tgt.parent().append(getCursor()) | ||
else if posFunc(tgt) | ||
if not tgt.prev().hasClass('insertion-cursor') | ||
tgt.before(getCursor()) | ||
else | ||
if not tgt.next().hasClass('insertion-cursor') | ||
tgt.after(getCursor()) | ||
else | ||
$(self).prepend(getCursor()) | ||
|
||
e.preventDefault() | ||
|
||
ts.ondragover = (e) -> | ||
draggedElem = window.draggedChannel.showGraph and window.draggedChannel.tsRow.get(0) | ||
handleDragOver(this, e, draggedElem, 'section', (tgt) -> e.offsetY < tgt.get(0).offsetHeight/2) | ||
|
||
ts.ondrop = (e) -> | ||
cur = $(this).find(".insertion-cursor") | ||
if cur.length | ||
cur.replaceWith(window.draggedChannel.showTimeseries()) | ||
ts = $("#timeseries").get(0) | ||
|
||
|
||
mp = $('#meters').get(0) | ||
|
||
mp.ondragover = (e) -> | ||
draggedElem = window.draggedChannel.tile.get(0) | ||
handleDragOver(this, e, draggedElem, '.meter', (tgt) -> e.offsetX < tgt.get(0).offsetWidth/2) | ||
|
||
mp.ondrop = (e) -> | ||
cur = $(this).find(".insertion-cursor") | ||
if cur.length | ||
window.draggedChannel.hideTimeseries() | ||
cur.replaceWith(window.draggedChannel.tile) | ||
dropdownButton = (options, callback) -> | ||
r = $("<div class='dropdownButton'>").delegate 'a', 'click', (e) -> | ||
if not $(this).siblings().length then return | ||
if not $(this).is(':first-child') | ||
$(this).detach().prependTo(d) | ||
callback($(this).text()) | ||
else if not r.hasClass('opened') | ||
r.addClass('opened') | ||
$(document.body).one 'click', -> | ||
r.removeClass('opened') | ||
e.stopPropagation() | ||
d = $('<div>').appendTo(r) | ||
|
||
for i in options | ||
$("<a>").text(i).appendTo(d) | ||
|
||
mp.ondragend = ts.ondragend = (e) -> | ||
$('.insertion-cursor').remove() | ||
$('.dnd-oldpos').show().removeClass('dnd-oldpos') | ||
|
||
onConfig: (o) -> | ||
$('#meters, #meters-side').empty() | ||
@channels = {} | ||
self = this | ||
for c in o | ||
if c.id == 'time' | ||
n = new TimeChannel(c) | ||
else if c.type == 'digital' | ||
n = new DigitalChannel(c) | ||
else | ||
n = new AnalogChannel(c) | ||
@channels[n.id] = n | ||
n._setValue = (v, s) -> self.setChannel(this.id, v, s) | ||
|
||
onData: (data) -> | ||
if params.perfstat | ||
t1 = new Date() | ||
@data.push(data) | ||
for name, c of @channels | ||
if data[name]? then c.onValue(data.time, data[name]) | ||
if params.perfstat | ||
t2 = new Date() | ||
@perfstat_acc += t2-t1 | ||
if (@perfstat_count += 1) == 25 | ||
$('#perfstat').text(@perfstat_acc / 25 + "ms/render") | ||
@perfstat_acc = @perfstat_count = 0 | ||
|
||
onState: (channel, state) -> | ||
@channels[channel].onState(state) | ||
r.set = (option) -> | ||
d.children().each -> | ||
if $(this).text() == option | ||
$(this).remove() | ||
d.prepend($("<a>").text(option)) | ||
|
||
setChannel: (name, value, state) -> | ||
console.error("setChannel should be overridden by transport") | ||
return r | ||
|
||
|
||
setup = false | ||
|
||
#URL params | ||
params = {} | ||
|
||
for pair in document.location.search.slice(1).split('&') | ||
[key,params[key]] = pair.split('=') | ||
|
||
|
||
hostname = params.server || document.location.host | ||
window.graphmode = params.graphmode || 'canvas' | ||
window.ygrid = params.ygrid != '0' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
<!doctype html> | ||
<!-- | ||
Distributed under the terms of the BSD License | ||
(C) 2011 Kevin Mehall (Nonolith Labs) <[email protected]> | ||
--> | ||
<html> | ||
<head> | ||
<meta charset='utf-8'> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
# Real-time canvas plotting library | ||
# Distributed under the terms of the BSD License | ||
# (C) 2011 Kevin Mehall (Nonolith Labs) <[email protected]> | ||
|
||
PADDING = 10 | ||
AXIS_SPACING = 25 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
/* | ||
Distributed under the terms of the BSD License | ||
(C) 2011 Kevin Mehall (Nonolith Labs) <[email protected]> | ||
*/ | ||
|
||
html, body, div, span, applet, object, iframe, | ||
h1, h2, h3, h4, h5, h6, p, blockquote, pre, | ||
a, abbr, acronym, address, big, cite, code, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
#!/usr/bin/env python2 | ||
# -*- coding: utf8 -*- | ||
#Ian Daniher - Mar11-17 2011 | ||
# Olin ModCon SMU driver for Pixelpulse | ||
# Distributed under the terms of the BSD License | ||
# (C) 2011 Ian Daniher (Nonolith Labs) <[email protected]> | ||
|
||
import sys | ||
import usb.core | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
#coding: utf-8 | ||
|
||
# Pixelpulse - framework to visualize and control signals in a browser-based interface | ||
# Distributed under the terms of the BSD License | ||
# (C) 2011 Kevin Mehall (Nonolith Labs) <[email protected]> | ||
# (C) 2011 Ian Daniher (Nonolith Labs) <[email protected]> | ||
|
||
from tornado.httpserver import HTTPServer | ||
from tornado.ioloop import IOLoop, PeriodicCallback | ||
from tornado.web import Application, RequestHandler, StaticFileHandler | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
#!/usr/bin/env python2 | ||
# Example driver for Pixelpulse | ||
# Distributed under the terms of the BSD License | ||
# (C) 2011 Kevin Mehall (Nonolith Labs) <[email protected]> | ||
|
||
import math, time | ||
import pixelpulse | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
# PySerial wrapper for the Tornado IOLoop | ||
# Distributed under the terms of the BSD License | ||
# (C) 2011 Kevin Mehall (Nonolith Labs) <[email protected]> | ||
|
||
import serial | ||
from tornado.ioloop import IOLoop | ||
import os | ||
|