Touch Sensor example does not compile

HomeForumsMonoBrick EV3 FirmwareTouch Sensor example does not compile

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #4418

    Hi

    I’ve been trying MonoBrick for a few days, working with the display and EV3 buttons.

    And now I’m trying to add some functionalities to a program with the Touch Sensor (EV3 version) but I’m not able to configure it properly. In fact I’m not even able to compile the TouchSensorExample Program!!

    When I try to compile this program:

    using System;
    using MonoBrickFirmware.UserInput;
    using MonoBrickFirmware.Display;
    using MonoBrickFirmware.Sensors;
    using System.Threading;
    namespace TouchSensorExample
    {
    	class MainClass
    	{
    		public static void Main (string[] args)
    		{
    			ManualResetEvent terminateProgram = new ManualResetEvent(false);
    			var touchSensor = new EV3TouchSensor(SensorPort.In1);
    			//svar touchSensor = new NXTTouchSensor(SensorPort.In1);
    			ButtonEvents buts = new ButtonEvents ();
    			LcdConsole.WriteLine("Use touch on port1");
    			LcdConsole.WriteLine("Up read");
    			LcdConsole.WriteLine("Down read raw");
    			LcdConsole.WriteLine("Esc. terminate");
    			buts.EscapePressed += () => { 
    				terminateProgram.Set();
    			};
    			buts.UpPressed += () => { 
    				LcdConsole.WriteLine("Sensor value:" + touchSensor.ReadAsString());
    			};
    			buts.DownPressed += () => { 
    				LcdConsole.WriteLine("Raw sensor value: " + touchSensor.ReadRaw());
    			};  
    			terminateProgram.WaitOne();
    		}
    	}
    }

    I get the following error: “type or name space cannot be found, maybe yo need some “using” o assembler reference” (this is a free translation of the error)

    Can anyone help me?

    Thanks in advance

    #4419
    Author Image
    Tcm0
    Participant

    Do you have included the MonoBrick DLL? Which line has the error?

    #4420

    Yes, I added the monobrick DLL, in fact, I have redownloaded and reincluded it into the project (just in case), the problematic line is exactly the line where the declaration of the sensor is made:
    “var touchSensor = new EV3TouchSensor(SensorPort.In1);” y

    I have also tried with a NXT Sound Sensor and with the NXT declaration: “svar touchSensor = new NXTTouchSensor(SensorPort.In1);” with the same result, the error (translated from spanish): “type or name space cannot be found, maybe you have missed some “using” declaration o assembler reference” (this is a free translation of the error)

    But this program is the original SoundSensor Example, unmodified. Do I have an old dll? I have downloaded from the official link.

    Thanks

    #4421

    I answer myself, in the documentation Library () I have just discover that the Touch Sensor Class is no longer used with “var touchSensor = new EV3TouchSensor(SensorPort.In1);” but using the following statement: “var touchSensor = new TouchSensor(SensorPort.In1);”. This new declaration is valid for NXT and EV3 touch sensors, no difference has to be made.

    So the Example used before is no longer valid and declaration of touch sensor has to be changed in order to compile with the last MonoBrick DLL.

    Hope it helps

    #4423
    Author Image
    Anders Søborg
    Keymaster

    Hi

    Yes the documentation is not compliant with the dll from the Git repository…

    Will be updated when we make the next release. But as I have mentioned in another thread I am very busy at the moment with some private stuff. Hopefully I will have some time at the end of the week…

    Anders

    #4444

    Thanks for your answer Anders

    You are doing a great job with this project, of course we hope to see it grow and evolve but we can wait 😉

    Thanks!

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

Posted in

Make a donation