Request Size Management and Misc. Housekeeping #61
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.
The primary feature of this PR is changing the idiom surrounding
requestSize
.Previously,
requestSize
was handled exclusively by the user. The controller object was initialized using the smallest valid request size for control data (6 bytes) and the user had the option to increase it as needed. This was exclusive to each object, so in a program with multiple mixed controller objects the request size was saved and could potentially be unique for each one.This PR changes that approach.
requestSize
is a fundamental part of the communication flow and is now both:connect()
).This has two advantages. First, in programs using a shared "port" object (i.e multiple controller types), modifying the
requestSize
in one object will affect the others. This means that a controller type that requires 8 bytes for its updates (the NES Mini controller) can change therequestSize
for the generic "port" object, which will then successfully request 8 bytes for its control updates. Second, if the request size is increased, this is reset on connection so that other controller types that don't use a larger request size won't be bogged down by the extra requests on the I²C bus.This PR also fixes NES controller support, which was broken in the examples since #58 because the
connect()
function no longer populates the first data read.Also included in this PR are some miscellaneous housekeeping tweaks:
CtrlIndex
asIndexMap
for better conformity with theByteMap
andBitMap
typenames.