From 084c861c51d57775561454a077ffdb2edda23939 Mon Sep 17 00:00:00 2001 From: zurgeg <46549042+zurgeg@users.noreply.github.com> Date: Thu, 19 Mar 2020 09:35:56 -0400 Subject: [PATCH 1/3] Add easier access to I2C control Add easier access to I2C control because I know there was #37 that was caused by confusion over how to use I2C on PyFirmata. This will do some simplifying by adding a send_i2c function. --- pyfirmata/pyfirmata.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyfirmata/pyfirmata.py b/pyfirmata/pyfirmata.py index 0963cea7..e0b7e80e 100755 --- a/pyfirmata/pyfirmata.py +++ b/pyfirmata/pyfirmata.py @@ -5,6 +5,8 @@ import serial +from . import I2C_REQUEST + from .util import pin_list_to_board_dict, to_two_bytes, two_byte_iter_to_str # Message command bytes (0x80(128) to 0xFF(255)) - straight from Firmata.h @@ -255,6 +257,8 @@ def send_sysex(self, sysex_cmd, data): msg.extend(data) msg.append(END_SYSEX) self.sp.write(msg) + def send_i2c(self,data): + self.send_sysex(I2C_REQUEST, data) def bytes_available(self): return self.sp.inWaiting() From b0ee745cc3aa9172ab6e3718b056a975a93d08a4 Mon Sep 17 00:00:00 2001 From: zurgeg <46549042+zurgeg@users.noreply.github.com> Date: Tue, 23 Jun 2020 15:53:47 -0400 Subject: [PATCH 2/3] Update pyfirmata.py --- pyfirmata/pyfirmata.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyfirmata/pyfirmata.py b/pyfirmata/pyfirmata.py index e0b7e80e..038f532f 100755 --- a/pyfirmata/pyfirmata.py +++ b/pyfirmata/pyfirmata.py @@ -257,7 +257,8 @@ def send_sysex(self, sysex_cmd, data): msg.extend(data) msg.append(END_SYSEX) self.sp.write(msg) - def send_i2c(self,data): + + def send_i2c(self, data): self.send_sysex(I2C_REQUEST, data) def bytes_available(self): From ce67db7da4978feddfef07cbf7a32b1b67613217 Mon Sep 17 00:00:00 2001 From: zurgeg <46549042+zurgeg@users.noreply.github.com> Date: Tue, 23 Jun 2020 15:54:06 -0400 Subject: [PATCH 3/3] Update pyfirmata.py --- pyfirmata/pyfirmata.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pyfirmata/pyfirmata.py b/pyfirmata/pyfirmata.py index 038f532f..dfd2ccd7 100755 --- a/pyfirmata/pyfirmata.py +++ b/pyfirmata/pyfirmata.py @@ -5,8 +5,6 @@ import serial -from . import I2C_REQUEST - from .util import pin_list_to_board_dict, to_two_bytes, two_byte_iter_to_str # Message command bytes (0x80(128) to 0xFF(255)) - straight from Firmata.h