Giter Site home page Giter Site logo

soundanalogous / breakout Goto Github PK

View Code? Open in Web Editor NEW
180.0 180.0 20.0 25.66 MB

Breakout is a javascript library and toolkit for connecting Arduino and other IOBoards to the web

Home Page: www.breakoutjs.com

License: MIT License

JavaScript 81.92% CSS 5.11% HTML 2.97% Handlebars 9.22% C++ 0.78%

breakout's People

Contributors

fabaff avatar soundanalogous avatar stalib avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

breakout's Issues

hex color support for RGB LED

Add the ability to set an RGB LED color using a hex value or separate red, green and blue colors. Currently only the latter is supported.

pwd_led to blink_led

re all,

I'm trying make a change in pwd_led.html example to use the same slider issue to change the interval params in blink led method.

<script type="text/javascript"> $(document).ready(function() { var IOBoard = BO.IOBoard; var IOBoardEvent = BO.IOBoardEvent; var LED = BO.io.LED; var Pin = BO.Pin; var PinEvent = BO.PinEvent; var arduino = new IOBoard(location.hostname, 8887); var led; var delays; arduino.addEventListener(IOBoardEvent.READY, onReady); function onReady(event) { arduino.removeEventListener(IOBoardEvent.READY, onReady); led = new LED(arduino, arduino.getDigitalPin(9)); arduino.setDigitalPinMode(9, Pin.DOUT); $('#btnStart').click(function() { LedStart(2000); }); $('#btnStop').on('click', LedStop); $("#sliderBlink").slider({ step: 10, min : 200, max : 2000 }); } $( "#sliderBlink" ).bind( "slideBlink", function(event, ui) { var value2 = ui.value; delays.value = value2; }); function LedStart(delays) { led.blink(delays, 0); } function LedStop(evt) { ledOsc.stopBlinking(); } }); </script>

any idea?

thanks a lot for breakout, it's ool!

provide aliases for pins

When creating a instance of an io component, allow users to pass "A0" instead of boardRef.getAnalogPin(0) and "D5" instead of boardRef.getDigitalPin(5). Also passing just a number should call boardRef.getDigitalPin(num) for that number.

Can't select serial port other than top item

This issue is because of a routine that tries to refresh the list of available serial ports when Breakout Server is in the disconnected state. Need to figure out a better way to detect when a USB serial connection id connected or disconnected, or set a flag once a user clicks the drop-down to prevent the list from refreshing again until the server is disconnected.

update message structure

Consider prepending firmata websocket messages with 'serial:' so that if a server other than Breakout Server is used, additional data can be sent and received on the same websocket connection.

add onewire support

The configurable branch of Firmata provides support for the onewire protocol. Add this functionality to Breakout as well along with an example application.

64-bit JVM not supported in Windows

Currently you must have a 32-bit JVM installed to use Breakout in Windows. However you can have both a 32-bit and 64-bit JVM installed on your system simultaneously, you'll just need the 32-bit to run Breakout Server.

use BeagleBone Black with Breakout

I have a BeagleBone black and have been meaning to get it to work with Breakout. The plan is to use the Adafruit python library for the beaglebone to create a Firmata implementation. The beaglebone could then communicate with Breakout directly via a websocket interface (should be no need for Breakout Server).

New error on Firefox 11

I recently update to Firefox 11 and console start showing this error:

Component returned failure code: 0x80460001 (NS_ERROR_CANNOT_CONVERT_DATA)
Breakout-core.js (línea 17) I am using the minified version.

I not sure, but I think that it don't show this error in previous version of firefox.

Multiple simultaneous connections + Service

Hello,

First of all the auto connect option is a very good step to make the server more usable for production and i think it will be better if:

1- the server can tun as a service so no GUI unless we need to change the config.
2- we can use more than one serial<->TCP bridge so it can handle all ports either broadcasting all serial ports to one netport or one to one connection so in stead of listing serial ports in a dropdown we can have a table with all ports each in raw with the corresponding netport and connect button + auto connect check.

it will be pefect. thanks.

update documentation to use AdvancedFirmata

Moving from StandardFirmata to AdvancedFirmata so documentation needs to be updated to address this change. Keep reference to StandardFirmata for users with boards that have < 16k of flash memory.

using breakout.js in node app

Hi,

There are a way to require breakout.js in node app like jhonny-five?

I want to create an app server to handlers some breakoutjs functions like:

`
app.get('/led', function(req, res) {

});

app.get('/pot', function(req, res) {

});
`

best from brazil

stabilizing analog input

Is there a simple and useful method to stabilize analog input values?

I've made a little change in Scaler example to get values from analogIn to handler blink() led but doesn't work because the values from analogIn always change and the blink doen't fired correctly.

I'm thinking too about if there are a way to solve this controlling the bind values to blink() method instead of stabilize analog input values.

Anyone can help me?

cheers from brazil

location.hostname

Some users are having issues with location.hostname. Need to resolve while maintaining support for both mobile and desktop browsers.

use Arduino Yun without Breakout Server

It is theoretically possible to use an Arduino Yun with Breakout without the need for Breakout Server. This is because the Yun is powerful enough to handle the websocket connection and all Breakout Server does is proxy the serial data from the Arduino to a websocket connection with your web application. Once I get my hands on an Arduino Yun I'll start work on this.

Processing server

I would like to share with you another option for the server. Is a modified version of the https://github.com/kalanda/serial2socket-proxy coded for Processing but focused to use with BreakoutJS. Maybe you want to use it as another alternative like the node_server in you next release. Is your choice.

Just need to download Processing (2.0 alpha5 because some problems with rxtx in 1.5.1 are resolved in this version) and install two libraries for processing: controlP5 (http://www.sojamo.de/libraries/controlP5/#installation) and websocketp5 (http://p5.twelvebytes.net/websocketP5-0.1.2/). Then, open Processing and paste the code below.

Is very similar to the Java based Breakout Server, but is very easy to distribute because Processing can export this code to applications for osx, windows32, linux32 and linux64 with one click. The exported applications run out of the box in all OS. In linux just need Java VM but don't need to install the 'rxtx-java' package.

This code use a 'html' folder inside the scketch folder as server root. You can't change the server root path, but is more easy to distribute html applications based on breakoutjs because inside the application folder you only find the executable and some folders, including the "html" with the webapp.

I hope you like ;)

/**
 * Import libraries
 */
import processing.serial.*;
import controlP5.*;
import muthesius.net.*;
import org.webbitserver.*;

/**
 * Event IDs
  */
final static int ID_REFRESH_BUTTON         =  101;  
final static int ID_SERVER_PORT_TEXTFIELD  =  102; 
final static int ID_CONNECT_BUTTON         =  103;
final static int ID_SERIALPORTS_COMBO      =  104;


/**
 * Default values
 */
int DEFAULT_PORT = 8887;
int DEFAULT_SERIAL_SPEED = 57600;

/**
 * Status variables
 */
boolean isSerialConnected;
boolean isServerRunning;
String serialPortName;
int serverPortNumber;

/**
 * Objects
 */
Serial serialPort;
WebSocketP5 websocket;
ControlP5 gui;
DropdownList serialPortsCombo;
Button connectButton;
Button refreshButton;
Button createServerButton;
Textfield socketPortTextfield;
Textarea logTextarea;


/**
 * Setup
 */
void setup() {

  serialPortName = null;
  isSerialConnected = false;
  isServerRunning = false;
  serverPortNumber = DEFAULT_PORT;

  // GUI instance
  gui = new ControlP5(this);

  // Create GUI interface  
  size(320, 250);

  Textlabel socketPortTextfieldLabel = gui.addTextlabel("socketPortTextfieldLabel", "Socket", 15, 20);
  socketPortTextfieldLabel.setColorValue(0x444444);

  Textlabel serialListLabel = gui.addTextlabel("serialListLabel", "Serial port", 60, 20);
  serialListLabel.setColorValue(0x444444);

  // Textfield for socket port number
  socketPortTextfield = gui.addTextfield("Socket Port", 10, 30, 40, 19);
  socketPortTextfield.setId(ID_SERVER_PORT_TEXTFIELD);
  socketPortTextfield.setText(str(DEFAULT_PORT));
  socketPortTextfield.setAutoClear(false);
  socketPortTextfield.captionLabel().setVisible(false);
  socketPortTextfield.valueLabel().setWithCursorPosition(socketPortTextfield.getText(), 0);

  // Button for refresh serial ports list     
  refreshButton = gui.addButton("Refresh list", ID_REFRESH_BUTTON, 235, 30, 75, 20);
  refreshButton.setId(ID_REFRESH_BUTTON); 
  refreshButton.captionLabel().style().paddingLeft = 6;

  // Button for refresh serial ports list     
  createServerButton = gui.addButton("createServerButton", ID_CONNECT_BUTTON, 10, 60, 300, 20);
  createServerButton.setId(ID_CONNECT_BUTTON); 
  createServerButton.setLabel("connect");
  createServerButton.captionLabel().style().paddingLeft = 120;

  // Logging area
  logTextarea = gui.addTextarea("logTextarea", "", 10, 90, 290, 150);                                      
  logTextarea.setColorBackground(color(0));
  logTextarea.showScrollbar();
  logTextarea.scroll(1);

  // Combos from here to fix z-index
  serialPortsCombo = gui.addDropdownList("serialPortList", 55, 51, 170, 250);
  serialPortsCombo.setId(ID_SERIALPORTS_COMBO);
  serialPortsCombo.setLabel("Select");
  serialPortsCombo.setBarHeight(20);
  serialPortsCombo.captionLabel().style().paddingTop = 5;
  serialPortsCombo.captionLabel().style().paddingLeft = 5;
  serialPortsCombo.setItemHeight(20);    
  serialPortsCombo.setColorBackground(color(60));
  serialPortsCombo.setColorActive(color(255, 128));

  // Update the serial port list
  updateSerialPortsCombo();
}

/**
 * Redraw 
 */
void draw() {
  background(0xcecece);
  fill(0);
  rect(10, 90, 300, 150);
  gui.draw();
}

/**
 * On stop applet
 */
void stop() {
  websocket.stop();
  serialPort.clear();
  serialPort.stop();
}

/**
 * Catch for serial data
 */
void serialEvent(Serial serialPort) {
  if (isSerialConnected) {
    while (serialPort.available () > 0) {
      int whatSerialSaid = serialPort.read();
      websocket.sendAll(Integer.toString(whatSerialSaid));
    }
  }
}

/**
 * Catch released keys
 */
void keyReleased() {
  if (socketPortTextfield.isFocus()) {
    socketPortTextfield.setText(removeNotNumbersAndCheckMaxlength(socketPortTextfield.getText(), 5));
    socketPortTextfield.valueLabel().setWithCursorPosition(socketPortTextfield.getText(), 0);
  }
}

/**
 * When is a new websocket connection
 */
void websocketOnOpen(WebSocketConnection con) {
  logActivity("A client joined of "+websocket.howManyConnections());
}

/**
 * When a websocket connection closes
 */
void websocketOnClosed(WebSocketConnection con) {
  logActivity("A client left");
}

/**
 * Catch for websocket messages
 */
void websocketOnMessage(WebSocketConnection con, String message) {

  if (message.indexOf(',') > -1) {
    String data[] = message.split(",");
    for (int i=0; i<data.length; i++) {
      serialSend(Integer.parseInt(data[i]));
    }
  } 
  else {
    serialSend(Integer.parseInt(message));
  }
}

/**
 * Create server
 */
void createServer(int _serverPortNumber, String _serialPortName) {

  removeServer();

  // Create serial connection
  try {
    serialPortName = _serialPortName;
    serialPort = new Serial(this, serialPortName, DEFAULT_SERIAL_SPEED);
    logActivity("Connected to serial port "+serialPortName);
    isSerialConnected = true;
  }
  catch(Exception e) {
    logActivity(">> ERROR: Connecting to "+serialPortName);
    logActivity(">> "+e.getMessage());
    e.printStackTrace();
    serialPortName = null;
    serialPort = null;
  }

  // create a new server instance
  websocket = new WebSocketP5(this, serverPortNumber, "websocket");
  isServerRunning = true;
  logActivity("Running server at: "+websocket.getUri());

  logActivity("");
}

/** 
 * Remove server
 */
void removeServer(){

  // Remove connection if previously connected
  if (serialPort != null) {
    isSerialConnected = false;
    logActivity("Removing connection to "+serialPortName);
    logActivity("");
    serialPort.clear();
    serialPort.stop();
    serialPort = null;
    serialPortName = null;
  }

  // Remove any previous server
  if (websocket!=null) {
    websocket.stop();
    websocket = null;
    isServerRunning = false;
    logActivity("Removing server");
    logActivity("");
  }

}

/**
 * Send a char to serial port
 */
public int serialSend(int data) {
  if (isSerialConnected) {
    serialPort.write((byte)data);
    return 0;
  } 
  else {
    return -1;
  }
}


/**
 * Update the serial port list combo with the current serial ports list
 */
void updateSerialPortsCombo() {
  String[] serialPortsList =  Serial.list(); 
  serialPortsCombo.clear();     
  for (int i=0; i< serialPortsList.length; i++) {
    if (!serialPortsList[i].startsWith("/dev/tty.") ) {
      serialPortsCombo.addItem(serialPortsList[i], i+1);
    }
  }
}

/**
 * Log activity
 */
public void logActivity(String inText) {
  this.logTextarea.setText(logTextarea.text()+inText+"\n");
  println(inText);
}

/**
 * Clean not numbers and limit the number of chars
 */
String removeNotNumbersAndCheckMaxlength(String strToClean, int maxlength) {
  String cleanedStr = "";
  for (int i=0;i<strToClean.length()&&i<maxlength;i++) {
    if ('0' <= strToClean.charAt(i) && strToClean.charAt(i) <= '9') {
      cleanedStr = cleanedStr+strToClean.charAt(i);
    }
  }
  return cleanedStr;
}

/**
 * GUI event listener
 */
public void controlEvent(ControlEvent event) {

  int idControl;

  if (event.isGroup()) idControl = event.group().id();
  else idControl = event.controller().id();

  switch(idControl) {

    case ID_REFRESH_BUTTON : 
      updateSerialPortsCombo();
      logActivity("Serial port list is updated");
      break; 

    case ID_CONNECT_BUTTON :

      if (serialPortsCombo.value()==0) { 
        logActivity("> Please, select a serial port"); 
        break;
      }

      int socketPort = int(socketPortTextfield.getText());
      if (!(socketPort>=2 && socketPort<=65535)) { 
        logActivity("> Please, set a server port number between 2 and 65535"); 
        break;
      }

      if(isServerRunning) {
        removeServer();
        createServerButton.setLabel("connect");
      } else {
        createServer(socketPort, serialPortsCombo.stringValue());
        createServerButton.setLabel("disconnect");
      }

      break;

    default: break;
  }
}

add auto connect to nodeJS version of breakout server

While you could write a script to "auto connect" by passing a known serial port name when launching node_server/server.js, it may be helpful to attempt to auto connect without passing a serial port name parameter.

node-serialport will report the manufacturer for some devices so highest priority match could be for /Arduino/. Next lower priority could be match common port names used by Arduino: /usbmodemfd/ /ACM/ etc. Windows is tricky because I've only ever seen 'COMx' for any Arduino. Not sure how you'd know what name relates to an Arduino if there are ever more than one COM port listed.

Thermal and barcode devices

Hi, can i use Breakout server to collect data from barcode scanner or send zpl/esc commands to thermal pos printers that uses serial ports by passing firmata?

LED toggle method not working properly for non PWM pins

Currently you have to call the LED object's on() or off() method before calling toggle() or it will not work properly for an LED attached to a non-PWM pin.

In the toggle method, the intensity should be set rather than the value.

Problem with button events

When 2 or more buttons are wired on the same port (for example on pins 2 - 7 or an Arduino Uno), pressing one button will fire a release event on all other buttons (even if there is no listener set). Seems to be an issue with the startup pin states of the Arduino not matching the expected startup pin states in the breakoutjs.

add stepper motor support

Need to first add to StandardFirmata. Should use the Arduino Stepper library since I don't want to create any external dependencies with StandardFirmata.

Could also create BreakoutFirmata and use a more advanced Stepper library.

Problem with Server on Mountain Lion 10.8.2

hi,
i have a problem with running breakout.js on Mountain Lion :-(
i tried it in a virtual machine with Windows 7 and the server runs. so my setup is correct and the examples work.

now the problems in os x:

  1. when using the breakout server app, it displays the GUI, but when i try to change the serial port to my arduino the selection flips back to the first entry which is in my case a wireless AP of my iPhone. it's impossible to select an other serial port than the first one in the list. btw. if connected to the first serial port, after running the server the button still states "connect" and not "disconnect" as in the windows version

  2. as the first approach didn't work i tried the node_server. again everything seems to work, i get the correct messages in the terminal, get the messages that client xyz connected or disconnected, but when actually clicking something in the hello world example or pressing the button on the arduino (which worked on windows) i get nothing. nothing happens, no error messages, nada.

i use mac os x 10.8.2, an arduino uno, uploaded advanced firmata, on the windows side everything works. I had to install JRE 7u15 in 64 bit, additionally to the default java on mountain lion to get JAVA applets running in Safari.

hopefully someone can help me.
thanks

add tone support

I have submitted a pull request to add Tone functionality to the configurable branch of Firmata. This enables users to access the tone() (and eventually noTone()) function for Arduino to play a tone (via a buzzer or other output).

Add tone() and noTone() methods to either IOBoard or Pin.

Pin Variables

Hi breakout crew!

Does it possible change the Pin value in arduino.getDigitalPin(XX)' by a spinner jQuery ui function?

I try do this:

`
var ledPort = 9; //Default port is 9.

function onReady(event) {

    arduino.removeEventListener(IOBoardEvent.READY, onReady);

    led = new LED(arduino, arduino.getDigitalPin(ledPort));
    $('#spinner').spinner({
           min: 3,
           max: 13,
           step: 1
    });

}

$( "#spinner" ).bind( "spinchange", function() {
var spinnerValue = $("#spinner").spinner("value");
ledPort = spinnerValue;

})
`

obrigado :)

make queryPinState method public

I made this private for a reason at some point. Have had requests for the functionality it provides however so I'll look into making it public again.

Scaler Equations not working

Equations in Scaler.js are not working because they are assigned to the prototype when they should be static.

Option to start the server gui-less

It would be great if one could start the server gui-less, giving the configuration via parameters or even without any parameters, by guessing and autoconnecting the correct port.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.