Multicolour LED. OK. That one might be harder (it relies on Daisylink) but hereās how Iād go about itā¦
Navigate to http://gadgeteer.codeplex.com/
Go to Source Code
Navigate to Main, Modules, GHIElectronics, MulticolorLED, Software, MulticolorLED, MulticolorLED_42
Click on the MulticolorLED_42.cs file ā this is the driver source. Copy it all (hereās the link http://gadgeteer.codeplex.com/SourceControl/latest#Main/Modules/GHIElectronics/MulticolorLed/Software/MulticolorLed/MulticolorLed_42/MulticolorLed_42.cs )
Then find the constructor. Yep, this one will exceed my knowledge - someone else might need to assist on the DaisyLink translation? Youāre going to need to include the DaisyLink code as well, another complexity I canāt assist with
public MulticolorLed(int socketNumber)
: base(socketNumber, GHI_DAISYLINK_MANUFACTURER, GHI_DAISYLINK_TYPE_MULTICOLORLED, GHI_DAISYLINK_VERSION_MULTICOLORLED, GHI_DAISYLINK_VERSION_MULTICOLORLED, 50, "MulticolorLed")
{
// Initialize the LED to default color and state
TurnOff();
DaisyLinkInterrupt += new DaisyLinkInterruptEventHandler(MulticolorLED_DaisyLinkInterrupt);
}
So lets use a different module as a simpler example. Hereās the global objects of interest and the constructor for the HD44780 module.
private GT.Interfaces.DigitalOutput LCD_RS;
private GT.Interfaces.DigitalOutput LCD_E;
private GT.Interfaces.DigitalOutput LCD_D4;
private GT.Interfaces.DigitalOutput LCD_D5;
private GT.Interfaces.DigitalOutput LCD_D6;
private GT.Interfaces.DigitalOutput LCD_D7;
private GT.Interfaces.DigitalOutput BackLight;
public Display_HD44780(int socketNumber)
{
// This finds the Socket instance from the user-specified socket number.
// This will generate user-friendly error messages if the socket is invalid.
// If there is more than one socket on this module, then instead of "null" for the last parameter,
// put text that identifies the socket to the user (e.g. "S" if there is a socket type S)
Socket socket = Socket.GetSocket(socketNumber, true, this, null);
socket.EnsureTypeIsSupported('Y', this);
LCD_RS = new GT.Interfaces.DigitalOutput(socket, GT.Socket.Pin.Four, false, null);
LCD_E = new GT.Interfaces.DigitalOutput(socket, GT.Socket.Pin.Three, false, null);
LCD_D4 = new GT.Interfaces.DigitalOutput(socket, GT.Socket.Pin.Five, false, null);
LCD_D5 = new GT.Interfaces.DigitalOutput(socket, GT.Socket.Pin.Seven, false, null);
LCD_D6 = new GT.Interfaces.DigitalOutput(socket, GT.Socket.Pin.Nine, false, null);
LCD_D7 = new GT.Interfaces.DigitalOutput(socket, GT.Socket.Pin.Six, false, null);
BackLight = new GT.Interfaces.DigitalOutput(socket, GT.Socket.Pin.Eight, true, null);
Initialize();
}
Copy that code into a new file in a new netmf console project, with the right references added.
Instead of GT.Interfaces.DigitalOutput, you can change those items to be just OutputPort. Do that for the 7 objects so they say āprivate OutputPort LCD_RS;ā etc.
Now remove the int socketNumber in the parameter of the constructor.
Then get rid of the two āsocketā related lines after the constructor comments.
Then change the object NEW statements to reflect the OutputPort statement needed for the pins you have wired up to the appropriate pin on the socket - so the LCD_RS line is meant to be on pin four of the socket; LCD_E is pin 3, etc etc⦠So say for example youāve wired the moduleās pin P0_10 to pin 4 (LCD_RS) on the socket you have plugged the module into, your statement would be
LCD_RS = new OutputPort(G120.Pin.P0_10, false);
Change that for all the items needed - note, the backlight has a TRUE parameter, to turn it on when started.
Then, you should be right to use this driver in your app. Let us know if that makes sense?