Skip to content
This repository has been archived by the owner on Mar 28, 2020. It is now read-only.

Commit

Permalink
version 2.15
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterYsLab@gmail.com committed Jul 31, 2016
1 parent ffad829 commit f1d0265
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 211 deletions.
13 changes: 13 additions & 0 deletions documentation/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Change Log

## Release 2.15

31 July 2016

* Added support for the SET_DIGITAL_PIN_VALUE Firmata command

* This release is now fully compatible with StandardFirmata 2.5.3
* On-Line API Documents Updated to reflect new command

* Update pymata_iot.py to use websockets instead of autobahn.

* setup.py added dependency of websockets and removed autobahn/txaio dependencies

## Release 2.14

26 July 2016
Expand Down
3 changes: 2 additions & 1 deletion pymata_aio/private_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class PrivateConstants:
REPORT_ANALOG = 0xC0 # enable analog input by pin #
REPORT_DIGITAL = 0xD0 # enable digital input by port pair
SET_PIN_MODE = 0xF4 # set a pin to INPUT/OUTPUT/PWM/etc
SET_DIGITAL_PIN_VALUE = 0xF5 # set a single digital pin value instead of entire port
START_SYSEX = 0xF0 # start a MIDI Sysex message
END_SYSEX = 0xF7 # end a MIDI Sysex message
SYSTEM_RESET = 0xFF # reset from MIDI
Expand Down Expand Up @@ -70,7 +71,7 @@ class PrivateConstants:
SYSEX_REALTIME = 0x7F # MIDI Reserved for realtime messages

# reserved for PyMata
PYMATA_VERSION = "2.14"
PYMATA_VERSION = "2.15"

# each byte represents a digital port
# and its value contains the current port settings
Expand Down
16 changes: 15 additions & 1 deletion pymata_aio/pymata3.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@

import asyncio

from .pymata_core import PymataCore
try:
from pymata_core import PymataCore
except ImportError:
from .pymata_core import PymataCore


class PyMata3:
Expand Down Expand Up @@ -95,6 +98,17 @@ def digital_read(self, pin):
value = self.loop.run_until_complete(task)
return value

def digital_pin_write(self, pin, value=0):
"""
Set the specified digital input pin to the provided value
:param pin: Digital pin to be set
:param value: 0 or 1
:returns: No return value
"""
task = asyncio.ensure_future(self.core.digital_pin_write(pin, value))
self.loop.run_until_complete(task)

def digital_write(self, pin, value=0):
"""
Set the specified digital input pin to the provided value
Expand Down
26 changes: 18 additions & 8 deletions pymata_aio/pymata_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@

import serial

from .constants import Constants
from .pin_data import PinData
from .private_constants import PrivateConstants
from .pymata_serial import PymataSerial
from .pymata_socket import PymataSocket
from pymata_aio.constants import Constants
from pymata_aio.pin_data import PinData
from pymata_aio.private_constants import PrivateConstants
from pymata_aio.pymata_serial import PymataSerial
from pymata_aio.pymata_socket import PymataSocket


# noinspection PyCallingNonCallable,PyCallingNonCallable,PyPep8,PyBroadException,PyBroadException
Expand Down Expand Up @@ -282,7 +282,6 @@ def start(self):
# wait for arduino to go through a reset cycle if need be
time.sleep(self.arduino_wait)


# register the get_command method with the event loop
# self.loop = asyncio.get_event_loop()
self.the_task = self.loop.create_task(self._command_dispatcher())
Expand Down Expand Up @@ -497,6 +496,19 @@ async def digital_read(self, pin):
"""
return self.digital_pins[pin].current_value

async def digital_pin_write(self, pin, value):
"""
Set the specified pin to the specified value directly without port manipulation.
:param pin: pin number
:param value: pin value
:returns: No return value
"""

command = (PrivateConstants.SET_DIGITAL_PIN_VALUE, pin, value)

await self._send_command(command)

async def digital_write(self, pin, value):
"""
Set the specified pin to the specified value.
Expand Down Expand Up @@ -1297,7 +1309,6 @@ async def _command_dispatcher(self):

await self.serial_port.close()


print("An exception occurred on the asyncio event loop while receiving data. Invalid message.")
loop = self.loop
for t in asyncio.Task.all_tasks(loop):
Expand All @@ -1307,7 +1318,6 @@ async def _command_dispatcher(self):
loop.stop()
sys.exit(0)


'''
Firmata message handlers
'''
Expand Down
Loading

0 comments on commit f1d0265

Please sign in to comment.