Since we have moved all tutorials to the wiki and we have a nice “tutorial” page here Support – GHI Electronics we decided to update book to be short and simple. Something a reader can go through in an evening.
Downloaded to my HTC Flyer for some bedtime reading! I know it’s not meant to be used for gadgeteer devices, but I always like to know what’s going on behind the scenes, and this books seems to be a nice starting point!
BTW: This layout is much better than the .NET Gadgeteer Ultimate Guide".
To elaborate a bit…when you reference an assembly (or DLL), you are telling Visual Studio to include it in your project, which is how a compiled assembly is made available.
The “using” directives are simply a convenience mechanism, which allow you to omit the fully-qualified namespace when you refer to members of that namespace.
In other words, the only thing that’s required in order to use some code from an assembly is to add a reference to that assembly. But if you do not add a using directive for the assembly’s namespace, your code would be a lot more verbose.
For example, in several projects I use GHI’s Glide UI library to create UI elements and forms. In order to use Glide, I have to reference the Glide assembly/DLL. Then, if I wanted to create a button, I could use code like this:
GHIElectronics.NETMF.Glide.UI.Button myButton = new GHIElectronics.NETMF.Glide.UI.Button();
That’s a lot of typing for one little button. By adding a using statement:
I can shorten my code to:
Button myButton = new Button();
Note that if you have multiple assemblies and using directives that have a class of the same name, you might have to still include the namespace in the code, but if that’s the case, the compiler will give you a heads up about the ambiguous reference(s).
using aliasM = Microsoft.Some.Very.Extra.Long.Assembly.Name.IO;
using aliasG = GHIElectronics.Some.Very.Extra.Long.Assembly.Name.IO;
AliasM.Button myMButton = new AliasM.Button(...);
AliasG.Button myGButton = new AliasG.Button(...);
Thank you all for the excellent answers. Last time I programmed it was Fortran77 on a PDP16 so you may understand why I am a little behind the curve. I’ve only just realised what a monster the Spider is. I had been following Gus’s “beginners” book using console applications, hence the little difficulty. I was going to finish it before reading his new “ultimate guide”. I now realise that having jumped straight to the top of the tree like the monkey, I need to read backwards, so, yes, I am now using gadgeteer applications in Microsoft Visual C# Express. And thoroughly enjoying it.
[quote]LED = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, true);
because FEZ_Pin is not recognised “using” any of the GHI namespaces, whether referenced or not.
Instead I got the diode blinking on a button attached to socket X with this line:
LED = new OutputPort((Cpu.Pin)5, true);[/quote]
Hi, I’m also new to Gadgeteer/FEZ - hoping someone could give me some direction on this. I’m using the Spider and have the eblock extender and some modules - trying to get the piezo to work.
In the previously stated issue, what reference should be used for FEZ_Pin? I’m getting the same error. Or if it’s to be done a different way, are there some code samples?
What I found is (with FEZ_Pin having the issue):
public Piezo(FEZ_Pin.PWM pin)
pwm = new PWM((PWM.Pin)pin);
I see that FEZ_Pin is in the FEZmini_… reference, but that won’t work.
I apologize if this is a dumb question. I’m reading a couple of the beginner guides and searching for answers, but not quite finding the answers.
Important note…sounds like you’re not using the Gadgeteer project template. If you didn’t see a design surface with the mainboard when you first started the project, then you probably have the wrong template, and you’ll be making your life a bit harder in the process.
Start with the Gadgeteer Application project template, and then use the code in the above post as a reference, and you should be making sounds in no time flat (note that while I use eblock pots for changing the tones, there’s also some commented out code that uses a timer if you don’t have the pots).