G120HDR Gadgeteer programs

@ andre.m

Justin gave an example for a led, not for a gadgeteer module.

So you can use gadgeteer modules on the G120HDR Why did employee Gus said one cannot ?

I know that it is not a gadgeteer board, it has been said about 4 times now in this thread, the question is: can you use gadgeteer modules and how ??

"it require to use a plain netmf app this means a user must be familiar with netmf, pins, sockets and much more"
Of course you must be familiar, but how to get familiar if there is no documentation, no information, and no one gives answers.

How hard is it to understand that I need an example ?

BTW, I have experience in programming netduinos, furthermore, I write C# programs for work.

hi Steenis,

Just to reiterate what’s been said here. The idea of the G120HDR is to offer the simplicity of using Gadgeteer modules for CONNECTION only, not for the full gadgeteer software stack. But that doesn’t mean it’s going to be overly onerous on you to use modules on one, but it’s not as simple as just using the designer like you would with say a Spider.

You will need to do some wiring. The sockets on the G120HDR are intended to be “configurable” so you can map whatever pins to them you would like. You will then have to, in software, establish what pins you need to use for the module in question. You will then need the driver software, from Codeplex, for your module, and (depending on what module you’re using) you’ll need to re-write a bit (or a lot) of the driver to get things working.

So given all this, can you give us a module you’re interested in and we can help you step through this for the first time?

@ andre.m

To say it once more: I need information on the G12HDR, not NetMF or C#.

About getting answers: your last answer is the second answer I can work with. Finally. Justin’s answer was the first. So if you read this thread again, you must agree that it shouldn’t be longer than about 8 posts.

So thank you for this answer. I am already working on it.

But there is the next difficulty: one need a socket number for this software. Who knows where I can find the socket numbers of the G12HDR. I tried 0, 1, 2, 3, 4, 5 and 6. Well, I’m sorry, I guess the G120HDR has no socket-numbers because it is not a gadgeteer-board.

Andre, thank you once again and now I am going to bed.

This is explained on the G120HDR product page.

@ andre.m
I am sorry, but I do not see a way to circumvent the socket_number, which, I guess, the G12HDR does not have.

@ Gus
From the product page:
For additional flexibility, a Gadgeteer sockets are exposed to pads allowing developers to wire it to any signal which in turn allow the use of one or more for the ever expanding list of Gadgeteer modules. More user sockets can be added using the Breakout Module.

What do they mean with flexibility?
So you can use the ever expanding list of Gadgeteer modules, but, according to you, there is no straightforward way to use them and there is no documentation. Yes, that is flexible.

@ steenis - one way is to get the source for the module and change the constructor to use the relevant pins rather than the socket number. Should be only a couple of line of code change. You then instantiate the module with code instead of the designer.

@ Brett, thank you for your kind words. In fact I know that all, but don’t know how to do it. For now I am interested in the multicolorled. I hope that if I understand that I can go further. If you can help me, please.

@ Justin, thank you, can you give me just a little bit more info?

@ steenis - currently on phone…when i get near a pc will send example code…

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)
            // Initialize the LED to default color and state

            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);


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?

@ Brett - to me, it is much easier to build a mainboard driver.

@ Brett
I tried to follow your instructions exactly
I found the source code Multicolorled_42.cs and placed it in my project: that produced no errors.
I found the source code of DaidyLinkModule.cs and placed it in my project: this produced a lot of errors which I cannot resolve yet.
I found the constructor.
This is the first part of your instructions and I enclosed the resulting project as First.zip (that failed, I cannot upload zip-files)

The second part: I cannot find the HD44780 source code
You said make a new project and I did and placed in it your code and made the prescribed changes in the code. That looks now like this:

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHI.Premium.Hardware;

namespace G120TryThis_14
public class test
private OutputPort T3;
private OutputPort T4;
private OutputPort T5;
//private OutputPort T6;
//private OutputPort T7;
//private OutputPort T8;
//private OutputPort T9;

public test(int socketNumber)

  T3 = new OutputPort(GHI.Premium.Hardware.G120.Pin.P0_15, false);
  T4 = new OutputPort(GHI.Premium.Hardware.G120.Pin.P1_28, false);
  T5 = new OutputPort(GHI.Premium.Hardware.G120.Pin.P1_29, false);
  //T6 = new OutputPort(GHI.Premium.Hardware.G120.Pin.P1_5, false);
  //T7 = new OutputPort(GHI.Premium.Hardware.G120.Pin.P1_5, false);
  //T8 = new OutputPort(GHI.Premium.Hardware.G120.Pin.P1_5, false);
  //T9 = new OutputPort(GHI.Premium.Hardware.G120.Pin.P1_5, false);



I cannot find the the HD44780 source so I cannot resolve Initialize()
I enclosed this project as Second.zip (that failed, I cannot upload zip-files)

At this point I am stuck. What can I do with the second project and how can I go further ?

(((I found the source code of HD44780, but I do not what to do with it)))

ok, but the complexity is that you need to be able to define / redefine pin mappings if you ever re-wire the sockets. And is the mainboard driver creation process easy? @ Taylorza did it for the G400, https://www.ghielectronics.com/community/codeshare/entry/739 and Steenis if you want to give that a crack you should feel free to use that as your starting point

@ Brett - if i can do it…then its easy :smiley:

@ Steenis,

When you create the new project, you get a program.cs file. Don’t put the entire driver in that file. In the Solution Explorer, add a new item, a code file, called the same as the file is called in codeplex. Then, copy the entire code from codeplex into that file, and replace any contents of that file with the copied source. You probably will need to remove the inherits from GTM.Module, as well as changing the code as above.

Then, in your program.cs, you will be able to use the Display_HD44780 class as needed.

OK, we’re waiting :wink:

@ Brett - I’ll whip it up tomorrow at the office…

@ Brett
I changed from MulticolorLed to Display_HD44780 and changed things according your description:
I created a new standerd NETMF console project.
Place in it
private OutputPort LCD_RS;
private OutputPort LCD_E;
private OutputPort LCD_D4;
private OutputPort LCD_D5;
private OutputPort LCD_D6;
private OutputPort LCD_D7;
private OutputPort BackLight;
LCD_RS = new OutputPort(GHI.Premium.Hardware.G120.Pin.P0_15, false);
LCD_E = new OutputPort(GHI.Premium.Hardware.G120.Pin.P1_21, false);
LCD_D4 = new OutputPort(GHI.Premium.Hardware.G120.Pin.P1_22, false);
LCD_D5 = new OutputPort(GHI.Premium.Hardware.G120.Pin.P1_23, false);
LCD_D6 = new OutputPort(GHI.Premium.Hardware.G120.Pin.P1_24, false);
LCD_D7 = new OutputPort(GHI.Premium.Hardware.G120.Pin.P1_25, false);
BackLight = new OutputPort(GHI.Premium.Hardware.G120.Pin.P1_26, true);

I placed the source <Display_HD44780.cs> in the project. Display_HD44780 has a base class GTM.Module, so I placed the source <module.cs> in the project.
using Gadgeteer.Modules.GHIElectronics;
using Gadgeteer.Modules;
to the namespaces in <program.cs>
Building this solution produces 1 error:

  • The type or namespace name ‘Mainboard’ could not be found (are you missing a using directive or an assembly reference?)
    Until now I cannot resolve this error.

I very elegantly commented out all error places until it was error-free.
I now can upload it without errors.
Well …
I do not have an HD44780 module, so I cannot really test it.

There still is the MultcolorLed.

@ andre.m: is this what you meant?

@ andre.m

You said
mainboard is a gadgeteer component, change your code to work without "mainboard"
How can I do that ?

I commented out the error places, is that the same as work without “mainboard”