Need help with the irReceiver!

I just received my IR Module today and wanted to try out if it works.
So i copied the TestApp from the Documents and i got 3 errors.


irreceiver.IREvent += new IR_Receiver.IREventDelegate(irreceiver_IREvent);

 

void irreceiver_IREvent(object sender, IR_Receiver.IREventArgs e)

{

    uint buttonPressed = e.Button;

}

Is there something wrong with the code ?

What are the errors you are getting?

A quick glance shows that this won’t work.

e.Button will return the button itself and you are trying to assign this to a uint. You need to expand the e.Button to something that is uint. Check it’s parameters to find the correct one you want. My system is not up and running so I can’t check what they are :slight_smile:

Hard to translate to english, but this is what i came up with:

  1. The name “irreceiver” is not existing in the current context.
    2/3. The Type- or Namespacename “IR_Receiver” could not be found. (Missing a Using-Direktive or Assembly reference)

Do i need to add a like .dll to my references ?

@ Dave McLaughlin
Even if you ignore the code there it is still messaging these errors

@ andre.m yes I added it to the designer.

Then please show us the content of the entire program.cs file. Seems like in your copying you’ve left something out, or named it something different. In fact, can you check what the IR Receiver is called in the designer ?

Have you tried to add the dll manually?

Here is the full cs file :

using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;

namespace GadgeteerApp6
{
    public partial class Program
    {
        void ProgramStarted()
        {
            irreceiver.IREvent += new IR_Receiver.IREventDelegate(irreceiver_IREvent);
        }

        void irreceiver_IREvent(object sender, IR_Receiver.IREventArgs e)
        {
            
        }
    }
}

please bear in mind im new to programming, we started in school with c# and .net microframework.

OK can you tell us the name of the IR recvr? In fact, you’ll find the name in the program.generated.cs file - how about you show us that next ? :slight_smile:

This is the content of the program.generated.cs file:

//------------------------------------------------------------------------------
// <auto-generated>
//     Dieser Code wurde von einem Tool generiert.
//     Laufzeitversion:4.0.30319.18034
//
//     Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
//     der Code erneut generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------

namespace GadgeteerApp6 {
    using Gadgeteer;
    using GTM = Gadgeteer.Modules;
    
    
    public partial class Program : Gadgeteer.Program {
        
        private Gadgeteer.Modules.GHIElectronics.IR_Receiver irReceiver;
        
        public static void Main() {
            // Important to initialize the Mainboard first
            Program.Mainboard = new GHIElectronics.Gadgeteer.FEZCerberus();
            Program p = new Program();
            p.InitializeModules();
            p.ProgramStarted();
            // Starts Dispatcher
            p.Run();
        }
        
        private void InitializeModules() {
            this.irReceiver = new GTM.GHIElectronics.IR_Receiver(3);
        }
    }
}

This line here defines your object:

 private Gadgeteer.Modules.GHIElectronics.IR_Receiver irReceiver;

This line is where you try to use it:

            irreceiver.IREvent += new IR_Receiver.IREventDelegate(irreceiver_IREvent);

Notice the difference? Capitalisation is important :wink:

1 Like

Well … now we cleared up 1 error, but there are still 2 left.
translated (both errors are the same):

The Type- or Namespacename “IR_Receiver” could not be found. (Missing a Using-Direktive or Assembly reference)

Thank you, its now working :smiley:

Wunderbar! :slight_smile: