The way that the documentation explains it here: http://beta-developer.wildernesslabs.co/Meadow/Meadow_Basics/IO/
it makes it seem like all shift registers should impliment IIODevice.
However, not all shift registers are both input, and output. Also, not all registers support the same things. It feels really odd to me, to force the implimentation of all of these methods, and functionality, every time we create a new shift register.
Can someone provide clarification on how the IIODevice relates to the expansion of GPIO pins in shift registers?
Yes. They should implement
IIODevice. It actually needs to be implemented, we have work there.
Not all IIODevice supports many of those things. But with C# 8, we can do default implementation in interfaces, so the work will be done there.
For a look at an IOExpander that is more complete, see this: https://github.com/WildernessLabs/Meadow.Foundation/blob/Mcp23008/Source/Meadow.Foundation.Peripherals/ICs.IOExpanders.Mcp23008/Driver/ICs.IOExpanders.MCP23008/Mcp23x08.cs
Just my opinion, but it seems like bad practice to force implementation of properties and methods that do not relate to the device that will be implementing the class. Doing so breaks the single responsibility principle.
All of that functionality should be broken up by purpose. So if IIODevice should be a base class that everything inherits from. Then there should be another layer, maybe a base ShiftRegister or IIOExpander class that defines the functionality that all ShiftRegisters/IOExpanders have in common. Then maybe an IOutputRegister, IInuputRegister, IIORegister, for the variations of the registers themselves, split by purpose.
IOutputRegister should not implement input register functionality, just as IInputRegister should not implement any IOutputRegister functionality. Then IIORegister would implement both sets of functionality, as its purpose is both input and output.
I could see using the current implementation if my goal was to chain Meadow boards together, but outside another micro controller, what other device will actually use all of the functionality implemented on the base IIODevice as currently written? I cant think of many. So at that point how re-usable is our interface? Not very, only 20-30% of the methods are going to be consumed on average. That’s a lot of bloat to carry around and duplicate each time, if its not needed.
I may also not be seeing the whole picture here, so constructive feedback is appreciated.