firmata/arduino — pull request #149 by soundanalogous (2014-08-18 03:22:48+00:00)
Title: Enable servo to be attached to pins higher than 15

There are a 3 big internal changes here to the servo functionality:

1. Memory for all servos is now allocated right away rather than dynamically allocating servo instances. This ensures the user will have enough memory if their intent is to use a ton of servos. It also enables servos to be detached and reattached without increasing the Servo instance count (since each time you instantiate a Servo a count is incremented in the Servo library, but this count is never decremented).

2. The way servos are mapped to pins was changed to allow servos to be used on a wider range of pins. This change has also been made in StandardFirmata (in the dev branch... I still need to copy those changes to StandardFirmata in configurable_dev).

3. There was a bug in configurable firmata in which servos could not be attached on pins higher than 15 for any board. This was not an easy issue to fix and my solution required coupling AnalogOutputFirmata and ServoFirmata. I'd like to find a more elegant solution here if possible.

@ntruchsess please take a look at this commit in particular if you have some time: https://github.com/soundanalogous/arduino-1/commit/5ae28d43acbad785ac5486f85514b59433ff8261 and let me know if you have any other ideas. The root of the issue was that the EXTENDED_ANALOG command (I moved it from AnalogInputFirmata to AnalogOutputFirmata) was calling analogWrite when it really needed to be calling analogWriteCallback (defined in AnalogWrite.h but now moved to AnalogOutputFirmata). This was preventing extended analog messages on servo pins from being set.

I think the better long term solution is going to be creating a new Sysex version of ServoFirmata and deprecating the old (current) version that used AnalogOutput to set the value.