Closed robomike closed 7 years ago
Hi Mike, I'm really happy to see this pull. I'm glad you are figuring things out on your own.
However, we removed read_into and write intentionally because they don't add any value. Its the documentation that you pointed to that is wrong and it would be awesome if you corrected that instead. Inside the with
statement it should be spi.read_into()
instead of spi_device.read_into
. This works because with
calls __enter__
which returns self.spi
and its saved by the with as spi
.
Scott, working on the code example, SPI has no attribute read_into. Also, I2C devices has those functions, wouldn't be better for users if they worked the same way?
On SPI its readinto
which matches Python's formatting. We should switch I2CDevice to it too.
I2CDevice needs to wrap write
and readinto
because it stores the device address. Having SPIDevice return the spi object instead of itself means the structure is the same while saving a bit of memory by not having dumb wrapper functions.
This isn't needed because SPIDevice relies on SPI's methods directly. It does this by returning self.spi
from __enter__
unlike I2CDevice which returns self
. Thank you anyway for the pull request!
SPI device was missing read and write functionality. So I added it based on the I2CDevice , it works now.