I'm happy to help. I've mode some major and some minor changes. All major changes are listed below. The whole result was zipped and attached. But be aware that my Netduino GO hasn't arrived yet. So the code is completely untested.
- The "controller" isn't nested anymore. A nested type is only used if it is related to its parent in some way.
- The method "UpdateLeds" was moved inside "ShieldBaseController" because it was accessing only OutputPorts from it.
- All output ports are now private.
- The statement "bits[led]" and its "bits" array was replaced by a bit shift operation "1 << led".
- The "mask[led]" was also expressed as (inverted) bit shift "~(1<<led)". For example 1<<4 would result in 16 (or 0x10) and the "~" will invert every bit in the byte so you will get 0xEF or 239. Less manual calculations and less code results in less errors :-)
- Some minor renaming and other unimportant stuff
There is still room for improvement. You could change your SPI bit bang mode to native SPI from the Netduino. I've attached a class for the 74HC595 from my classic Netduino as example. You can also provide the parameter "GoSockets.Socket5" for your "new ShieldBase()" through the constructor of the class.
Regards
Guido
- Gutworks likes this