publiclab / webjack-firmata

A wrapper for WebJack to use as transport layer for firmata.js, for firmata access to an Arduino from a web browser.

Home Page:https://publiclab.github.io/webjack-firmata/example/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

StandardFirmataPlusWebJack.ino (for advanced firmata features like serial)

jywarren opened this issue · comments

StandardFirmataPlus is a variant of Firmata (for Arduinos, at least in this case) which includes extra features which require a more powerful Arduino than the basic StandardFirmata.

I'd like to try porting in the Webjack changes from the StandardFirmataWebJack.ino which Richard prepared:

https://github.com/publiclab/webjack-firmata/blob/master/sketches/StandardFirmataWebJack/StandardFirmataWebJack.ino

...into the "Plus" version, to get access to things like serialWrite (which I've included in this new demo: https://publiclab.github.io/webjack-firmata/example/serial/)

@rmeister - can you link to the version of StandardFirmataWebJack.ino that this was based on, so we can look at the diffs and try to port over the changes you made to get it working with WebJack?

Thanks!

OK, reviewing @rmeister's work at:

StandardFirmataWebJack.ino

I made these changes to StandardFirmataPlus.ino from https://github.com/firmata/arduino:

https://gist.github.com/jywarren/b67e032f5e68c282fd328bfec0d1f32b/revisions

Really, only to this section including setup() and a few lines before it:

#include <SoftModem.h>

SoftModem modem = SoftModem();

void setup()
{
  modem.begin();
  delay(100);
  Firmata.setFirmwareVersion(FIRMATA_FIRMWARE_MAJOR_VERSION, FIRMATA_FIRMWARE_MINOR_VERSION);

  Firmata.attach(ANALOG_MESSAGE, analogWriteCallback);
  Firmata.attach(DIGITAL_MESSAGE, digitalWriteCallback);
  Firmata.attach(REPORT_ANALOG, reportAnalogCallback);
  Firmata.attach(REPORT_DIGITAL, reportDigitalCallback);
  Firmata.attach(SET_PIN_MODE, setPinModeCallback);
  Firmata.attach(SET_DIGITAL_PIN_VALUE, setPinValueCallback);
  Firmata.attach(START_SYSEX, sysexCallback);
  Firmata.attach(SYSTEM_RESET, systemResetCallback);

  // to use a port other than Serial, such as Serial1 on an Arduino Leonardo or Mega,
  // Call begin(baud) on the alternate serial port and pass it to Firmata to begin like this:
  // Serial1.begin(57600);
  // Firmata.begin(Serial1);
  // However do not do this if you are using SERIAL_MESSAGE

  Firmata.begin(modem);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for ATmega32u4-based boards and Arduino 101
  }

  systemResetCallback();  // reset to default config
}

I wonder if that'd work.