nonNoise / PyMCP2221A

MCP2221 & MCP2221A work in Python.
MIT License
36 stars 21 forks source link

Set GPIO using the GPIO commands, I2C use Exceptions instead of exiting #8

Closed rickeywang closed 3 years ago

rickeywang commented 4 years ago
  1. Instead using SRAM Setting 0x60 Set SRAM settings and 0x61 to set the GPIO direction and state, use the 0x50 Set GPIO Output Values command. (like the Linux kernel driver). Using the SRAM commands is harder to debug. Also make available a function that returns the GPIO state by an integer rather than tuple.
  2. I was having trouble with I2C not working because for my application I need the time.sleep() in _i2c_read(). I made this an environment variable so people can use it as they please
  3. The exit() in I2C_Init() has been removed and changed with exception, so the program no longer exits on error
  4. _i2c_read() now raises error if the return code from MCP2221 is not 0x00, instead of returning -1. An alternative is to have _i2c_read() return None. I think smbus returns None ? Not too sure.

Updated example and readme as appropriate