from serial import SerialException
-from board import BOARDS
+from board import BOARDS
# Message command bytes - straight from Firmata.h
def setup_layout(self, board_layout):
Setup the Pin instances based on the given board-layout. Maybe it will
be possible to do this automatically in the future, by polling the
# Create pin instances based on board layout
for i in board_layout['analog']:
Returns the activated pin given by the pin definition.
May raise an ``InvalidPinDefError`` or a ``PinAlreadyTakenError``.
- :arg pin_def: Pin definition as described in :ref:`arduino-pin-definitions`,
- but without the arduino name. So for example ``a:1:i``.
+ :arg pin_def: Pin definition as described in TODO,
+ but without the arduino name. So for example ``a:1:i``.
if type(pin_def) == list:
Reads and handles data from the microcontroller over the serial port.
+ This method should be called in a main loop, or in an
+ :class:`Iterator` instance to keep this boards pin values up to date
def _process_data(self, byte):
Does the actual processing of the data from the microcontroller and
- delegates the command processing to _process_command
+ delegates the command processing to _process_command
def _set_mode(self, mode):
Set the mode of operation for the pin
- :mode arg: Can be one of the pin modes: INPUT, OUTPUT, ANALOG or PWM
+ :arg mode: Can be one of the pin modes: INPUT, OUTPUT, ANALOG or PWM
Returns the output value of the pin. This value is updated by the
uios' ``iterate` ` method. Value is alway in the range 0.0 - 1.0
+ arditerate` method. Value is alway in the range 0.0 - 1.0
if self.mode == UNAVAILABLE:
raise IOError, "Cannot read pin %s"% self.__str__()
Output a voltage from the pin
- Uses value as a boolean if the pin is in output mode, or expects a
- float from 0 to 1 if the pin is in PWM mode.
+ :arg value: Uses value as a boolean if the pin is in output mode, or
+ expects a float from 0 to 1 if the pin is in PWM mode.
if self.mode is UNAVAILABLE:
raise IOError, "%s can not be used through Firmata" % self