platypush/plugins/esp/__init__.py
def i2c_write(self, address: int, data: str, binary: bool = False, **kwargs):
        """
        Write data to the I2C bus.

        :param address: I2C address.
        :param data: Data to be sent.
        :param binary: By default data will be treated as a string. Set binary to True if it should
            instead be treated as a base64-encoded binary string to be decoded before being sent.
        :param kwargs: Parameters to pass to :meth:`platypush.plugins.esp.EspPlugin.i2c_open` and
            :meth:`platypush.plugins.esp.EspPlugin.execute`.
        :return: String representation of the read bytes, or base64-encoded representation if the
            data can't be decoded to a string.
        """
        if binary:
            data = base64.decodebytes(data.encode())
        else:
            data = data.encode()

        data = 'b"' + ''.join(['\\x{:02x}'.format(b) for b in data]) + '"'
        self.i2c_open(**kwargs)
        code = 'i2c.writeto({address}, {data})'.format(address=address, data=data)
        self.execute(code, **kwargs)

        Write data to the I2C bus.

        :param address: I2C address.
        :param data: Data to be sent.
        :param binary: By default data will be treated as a string. Set binary to True if it should
            instead be treated as a base64-encoded binary string to be decoded before being sent.
        :param kwargs: Parameters to pass to :meth:`platypush.plugins.esp.EspPlugin.i2c_open` and
            :meth:`platypush.plugins.esp.EspPlugin.execute`.
        :return: String representation of the read bytes, or base64-encoded representation if the
            data can't be decoded to a string.
        
Write data to the I2C bus.
Write data to the I2C bus .
def i2c_write(self, address: int, data: str, binary: bool = False, **kwargs):
        if binary:
            data = base64.decodebytes(data.encode())
        else:
            data = data.encode()
        data = 'b"' + ''.join(['\\x{:02x}'.format(b) for b in data]) + '"'
        self.i2c_open(**kwargs)
        code = 'i2c.writeto({address}, {data})'.format(address=address, data=data)
        self.execute(code, **kwargs)
def i2c_write ( self , address : int , data : str , binary : bool = False , ** kwargs ) : if binary : data = base64 . decodebytes ( data . encode ( ) ) else : data = data . encode ( ) data = 'b"' + '' . join ( [ '\\x{:02x}' . format ( b ) for b in data ] ) + '"' self . i2c_open ( ** kwargs ) code = 'i2c.writeto({address}, {data})' . format ( address = address , data = data ) self . execute ( code , ** kwargs )
Write data to the I2C bus.
Write data to the I2C bus .
"""
        Write data to the I2C bus.

        :param address: I2C address.
        :param data: Data to be sent.
        :param binary: By default data will be treated as a string. Set binary to True if it should
            instead be treated as a base64-encoded binary string to be decoded before being sent.
        :param kwargs: Parameters to pass to :meth:`platypush.plugins.esp.EspPlugin.i2c_open` and
            :meth:`platypush.plugins.esp.EspPlugin.execute`.
        :return: String representation of the read bytes, or base64-encoded representation if the
            data can't be decoded to a string.
        """
String representation of the read bytes, or base64-encoded representation if the
data can't be decoded to a string.
String representation of the read bytes or base64 - encoded representation if the data can ' t be decoded to a string .
self
address
int
None
data
str
Data to be sent.
Data to be sent .
binary
bool
By default data will be treated as a string. Set binary to True if it should
instead be treated as a base64-encoded binary string to be decoded before being sent.
By default data will be treated as a string . Set binary to True if it should instead be treated as a base64 - encoded binary string to be decoded before being sent .
kwargs
Parameters to pass to :meth:`platypush.plugins.esp.EspPlugin.i2c_open` and
:meth:`platypush.plugins.esp.EspPlugin.execute`.
Parameters to pass to : meth : ` platypush . plugins . esp . EspPlugin . i2c_open ` and : meth : ` platypush . plugins . esp . EspPlugin . execute ` .