Skip to content

Mixing in and out pins not possible #2

@niko084

Description

@niko084

I am really glad that I found your code to be used on an ESP32.

During implementation of my application I found out that mixing in and out pins not possible at the moment. Let's say

  • P0 is configured as Pin.IN
  • P1 is configured as Pin.OUT

Doing the following

  • Set P1 high (using digital_write_all_byte(0b00000010))
  • Read P0 (using self.pcf8574Instance.digital_read(0))

makes P1 fall to low after the read.

Looking into you code I found the line in the function 'read_buffer'

self._i2c.writeto(self._address, bytearray([self.read_mode]))

As self.read_mode only contains the Pin.IN-related configuration, it sets the Pin.OUTs to 0 respective low.

Maybe I am getting it wrong, but the i2c.writeto operation is basically not needed here. Commenting out this one and two similar lines (227, 261 and 304) solved the issue for me. Alternatively extending the line by applying a bitwise or with self.write_byte_buffered, or maybe something similar may help as well. I am not too deep into it here, and as I said, the line might not be needed at all

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions