Button Pressed Event is not raised

Good morning gadgeteers,

Today I was unboxing my gadgeteer,
after plugging in some modules and writing some code I was encountered that the button Pressed event is not raised.

The ButtonState changes, but the event is not raised…

Do you have any idea?

Attached you can see the code I wrote,
I cant see any erors.

I also read the known issues, but my button dll is version 1.0.204, so I think its already fixed.

Thank you in advance for your help.

Weiti


        void ProgramStarted()
        {
            // Do one-time tasks here
            Debug.Print("Program Started");

            button.DebugPrintEnabled = true;
            camera.DebugPrintEnabled = true;

            button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);
            camera.PictureCaptured += new Camera.PictureCapturedEventHandler(camera_PictureCaptured);

        }

        private void camera_PictureCaptured(Camera sender, Picture picture)
        {
            Debug.Print("Picture taken");

            display.SimpleGraphics.DisplayImage(picture,5,5);
        }

        void button_ButtonPressed(Button sender, Button.ButtonState state)
        {
            Debug.Print("Button pressed");

            camera.TakePicture();
        }

Welcome to the forum!

I think the latest version of the button module is 1.1.0.0.

@ Weiti : You have the latest button DLL if file version == 1.0.1.0; product version == 1.0.204.0. Make sure you copy the new DLLs to your project under P:\rojectRoot\bin\Debug. If you’re not comfy with that, start a new project [italic]after[/italic] you run Gadgeteer Button Module Patch.exe.

FWIW, I’ve encountered time where repeated build, deploy, run, stop, edit, build, deploy cycles will result in flaky interrupts behavior; whether it’s buttons, Ethernet, WiFi, etc.

I’ve found the following process provides the most consistent results when interrupts start flaking:

  1. Stop Debugging
  2. Close VisStudio
  3. Open MfDeploy
  4. Click “Erase”, acknowledge the “you sure you wanna?” pop-up
  5. Close MfDeploy
  6. Open your project
  7. Continue your work

New SDK will be out shortly, check back in couple hours.

DROOOOOOOOOOOOOOL…
:clap:

This included the fix for the button and many other awesome additions!
http://tinyclr.com/forum/12/5117/

AWESOME!
Installed the new SDK and it works almost flawless :slight_smile:
Thank you so much!!!

Only one Exception is nagging me…
Program is working, just exception is a bit of a flaw…

Error invoking method "Gadgeteer.Interfaces.InterruptInput" (check arguments to Program.BeginInvoke are correct)
    #### Exception System.NullReferenceException - CLR_E_NULL_REFERENCE (1) ####
    #### Message: 
    #### Gadgeteer.Modules.GHIElectronics.Button::OnButtonEvent [IP: 0026] ####
    #### Gadgeteer.Modules.GHIElectronics.Button::_input_Interrupt [IP: 0068] ####
    #### Gadgeteer.Interfaces.InterruptInput::OnInterruptEvent [IP: 0055] ####
    #### System.Reflection.MethodBase::Invoke [IP: 0000] ####
    #### Gadgeteer.Program::DoOperation [IP: 001a] ####
    #### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 004a] ####
    #### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001d] ####
    #### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
    #### Gadgeteer.Program::Run [IP: 001c] ####

Will look into this immediately. Soon we will be out of beta and all will be smooth sailing.

There is a problem with the way the driver handles events. The exception occurs on the Up event. Until the next SDK, make sure you have an event handler assigned to both the Up and Down events.

Up == Released?

yes

I hit the same null refrence error and went to see what I had messed after upgrading to the latest SDK (always assume user error first). I think I may have stumbled upon the cause of the button error (or my crack dealer is cheating me again).

What I discovered is that of all the DLLs that are imported into my projects, the Gadgeteer.NETMF set are all still dated 6 Oct 2011 - even if I clean my project and reassociate references.

When I manually extracted the files from the GHI NETMF v4.1 SDK.msi that came in the latest SDK, I found that it contained the 6 Oct file set.

Should any or all of these components have been updated as well?