Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
An I2C transmission has a significant overhead of ~10+1 I2C clock cycles.
Reducing the number of beginTransmission()/endTransmission() pairs
from twice every nibble to once per _send() hence speeds up transmission
times significantly.
The specified I2C clock rate speed of the PCF8574 chip is 100KHz.
Transmitting a single byte over I2C takes 9 clock ticks or 90us.
Even if the I2C bus is operated beyond the chip's spec in fast mode
at 400 kHz, any additional delays during transmission shorter than this
are unnecessary.
Commands are only executed after the second nibble is transmitted.
The 37us delay after the first nibble is hence unnecessary.
We now omit any additional delays and perform a transmission only once
per _send() command. This reduces the time from 4x(11+9) = 80 cycles to
4x9 + 11 = 47 cycles. Taking the delays into account, this changes the
time per command from 800us + 4*38us = 952us to 470us at the default
100kHz bus speed.