MrYsLab / PyMata

A Python client class library for Interaction with Standard Firmata
GNU Affero General Public License v3.0
95 stars 40 forks source link

How separate Digital Only from PWM? #12

Closed Vido closed 9 years ago

Vido commented 9 years ago

Firmata protocol tells you which pin has PWM. https://github.com/firmata/protocol/blob/master/protocol.md#capability-query

How does PyMate separate Digital Only from PWM?

MrYsLab commented 9 years ago

Are you asking how to determine if a pin is PWM or not from the capability report or if PyMata prevents an application from setting a non-PWM pin as PWM?

If you are asking how to do determine if a pin supports PWM from the capability report, PWM is indicated with a value of 3 in the list returned for the pin.

If it is the latter, PyMata does not prevent a user from picking a non supported pin mode for the pin, since that is not part of the Firmata protocol. The application should qualify the pin mode selection for validity. s2a_fm https://github.com/MrYsLab/s2a_fm, a program that utilizes the PyMata library does that when a user sets a pin mode. You can look at https://github.com/MrYsLab/s2a_fm/blob/master/scratch_command_handlers.py to see how it checks for pin mode validity.