omcaree/node-pololumaestro — pull request #2 by achingbrain (2013-08-19 07:51:15+00:00)
Title: Library refactor, implemented compact protocol and added test suite

I took what you'd done with the setPWM method and fleshed it out to implement the full compact protocol following [the docs](http://www.pololu.com/docs/0J40/all) & also added unit tests with a good level of coverage.

The existing setPWM method used the code 0x84 which appears to set the target of the given servo, rather than 0x8A which sets the value of the PWM output on boards that support it, so now setTarget uses 0x84 and setPWM uses 0x8A in line with the docs - this will break any existing code so I revved the library version number to 2.0.0.

There are a couple of helper classes, the interesting one being SerialPortWrapper which attempts to guarantee writes and reads to the serial port don't overlap.

Finally I renamed the src directory to lib as that seemed to be [recommended](http://webcache.googleusercontent.com/search?q=cache:Wd_9Sr6_IO4J:howtonode.org/how-to-module+&cd=1&hl=en&ct=clnk&gl=uk) for pure js npm libraries.

Happy to discuss any changes, let me know what you think.