-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for input shift registers (e.g. 74HC165) #77
Conversation
@@ -0,0 +1,56 @@ | |||
// MFInputShifter.h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The general shape of the MFInputShifter is modeled on the existing output shifter and button classes.
Firmware for this pull request: |
Firmware for this pull request: |
|
||
// Multiple chained modules are handled one at a time. As shiftIn() keeps getting | ||
// called it will pull in the data from each chained module. | ||
for (int i = 0; i < _moduleCount; i++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a different implementation approach than the one used for output shifters that I think is easier to understand.
|
||
// Triggers the event handler for the associated input shift register pin, | ||
// if a handler is registered. | ||
void MFInputShifter::trigger(uint8_t pin, bool state) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is identical to how buttons work other than the addition of sending the pin that triggered along with the event.
@@ -439,6 +455,43 @@ void ClearEncoders() | |||
#endif | |||
} | |||
|
|||
#if MF_INPUT_SHIFTER_SUPPORT == 1 | |||
//// INPUT SHIFT REGISTER ///// | |||
void AddInputShifter(uint8_t latchPin, uint8_t clockPin, uint8_t dataPin, uint8_t modules, char const *name = "Shifter") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a mashup of how output shifters and buttons are configured.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue warning: The name argument is not used anywhere in the function, therefore every shifter retains the same, default, name. All shifter chains will therefore send the same message for a given bit.
Currently, the "name" field of the object is initialized implicitly (to "InputShifter") during instantiation, and then it can no longer be modified; a method should be added to class MFInputShifter (e.g. MFInputShifter::setName(const char *newName)
) and invoked here.
Buttons behave differently because they are instantiated one by one, and thus named, upon registration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! This is fixed now, it just required assigning the name in the attach
method, as is done with the other modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, that makes more sense than a separate method!
(Sorry for adding my comment twice, I didn't notice I had already confirmed the first entry.)
Firmware for this pull request: |
No further coments to this pull request. Just a general remark. Maybe we should think about a "real" debouncing routine and not to use just a waiting time. I am wondering if there were "problems" with bouncing buttons reported in the past . |
Firmware for this pull request: |
Firmware for this pull request: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my side everything OK
@@ -439,6 +455,43 @@ void ClearEncoders() | |||
#endif | |||
} | |||
|
|||
#if MF_INPUT_SHIFTER_SUPPORT == 1 | |||
//// INPUT SHIFT REGISTER ///// | |||
void AddInputShifter(uint8_t latchPin, uint8_t clockPin, uint8_t dataPin, uint8_t modules, char const *name = "Shifter") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue warning: The name argument is not used anywhere in the function, therefore every shifter retains the same, default, name. All shifter chains will therefore send the same message for a given bit.
Currently, the "name" field of the object is initialized implicitly (to "InputShifter") during instantiation, and then it can no longer be modified; a method should be added to class MFInputShifter (e.g. MFInputShifter::setName(const char *newName)
) and invoked here.
Buttons behave differently because they are instantiated one by one, and thus named, upon registration.
Firmware for this pull request: |
Firmware for this pull request: |
Firmware for this pull request: |
Firmware for this pull request: |
Firmware for this pull request: |
Firmware for this pull request: |
Firmware for this pull request: |
Firmware for this pull request: |
Firmware for this pull request: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your effort! Looks good.
Let us please rename the original shifter to MFOutputShifter to have this analogy perfect.
That would be awesome!
Firmware for this pull request: |
How far do you want me to take this @DocMoebiuz? Just renaming the .cpp and .h file is easy, but there are also #define, class names, variable names, etc. I chose not to do the rename originally, both here and on the desktop, due to the amount of code churn it would cause. |
Firmware for this pull request: |
Firmware for this pull request: |
Description of changes
Fixes #73
Adds support for input shift registers like the 74HC165.