Closed nkpro2000sr closed 3 years ago
@bessman
I added tests for I2CMaster
and I2CSlave
except I2CSlave.capture
.
because it throws error on mocked handler.
also it is little difficult for me to understand. so i didn't touched it.
Thank you!
Regarding the error, previous versions of Handler accepted floats and just rounded then to the closest integer before transmission, but that behavior could lead to unexpected results so it was removed. This is a leftover from that which wasn't found and fixed yet. You can fix it by changing the operator to integer division (//).
Other than that, the old I2C class should raise a DeprecationWarning on initialization. You can also add # nosec
to the lines codacy complains about. That's not good practice, of course, but acceptable in this case since the class is being deprecated.
@bessman may i change I2CSlave.simpleRead
and I2CSlave.readBulk
to I2CSlave.simple_read
and I2CSlave.read_bulk
, according to PEP8 naming standards.
Please do!
I'm not sure why # nosec
isn't suppressing the codacy warnings here. I'll look into it.
Edit: The warning comes from pylint, not bandit, that's why. So # nosec
should be # pylint: disable=arguments-differ
instead. My bad!
@bessman
can you please add hacktoberfest-accepted
label to this pr, if doing so doesn't violates codeheat rules.
Sure! I'm not familiar with codeheat's rules, but I don't see why it should be a problem.
closes #136
[X] Currently, we need to pass the I2C address for every API call to the I2C bus. It would be great to have a simpler API where you could instead initialize a class with the address and keep using the object for further operations.
[X] When reading a single byte, we need to take it from an array for each read. A simpler read_single would be great, or maybe read_16 etc in addition for two bytes at once.
changes
I2C
->I2CMaster
andI2CSlave
added methods
simple_read_byte()
simple_read_int()
simple_read_long()
read_bulk_byte()
read_bulk_int()
read_bulk_long()