I got the update and verified the files were replaced as described, but I’m still not seeing any except button_release events.
…or is that the fix…?
Please show your code and your setup.
sorry - should have known better…
Everything except the button_pressed works.
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
namespace GadgeteerApp1
{
public partial class Program
{
void ProgramStarted()
{
/******************************************************************************************
Access modules defined in the designer by typing their name:
e.g. button
camera1
Initialize event handlers here.
e.g. button.ButtonPressed += new GTM.MSR.Button.ButtonEventHandler(button_ButtonPressed);
***************************************************************************************** */
// Do one-time tasks here
button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);
button.ButtonReleased += new Button.ButtonEventHandler(button_ButtonReleased);
camera.PictureCaptured += new Camera.PictureCapturedEventHandler(camera_PictureCaptured);
while(!camera.CameraReady)
{
Thread.Sleep(500);
Debug.Print("camera isn't ready");
}
Debug.Print("Program Started");
}
void camera_PictureCaptured(Camera sender, GT.Picture picture)
{
display.SimpleGraphics.DisplayImage(picture, 5, 5);
}
void button_ButtonPressed(Button sender, Button.ButtonState state)
{
button.ToggleLED();
camera.TakePicture();
}
void button_ButtonReleased(Button sender, Button.ButtonState state)
{
if (camera.CameraReady)
{
button.ToggleLED();
camera.TakePicture();
}
}
}
}
Test button alone itself. see code below please
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
namespace GadgeteerApp1
{
public partial class Program
{
void ProgramStarted()
{
/******************************************************************************************
Access modules defined in the designer by typing their name:
e.g. button
camera1
Initialize event handlers here.
e.g. button.ButtonPressed += new GTM.MSR.Button.ButtonEventHandler(button_ButtonPressed);
***************************************************************************************** */
// Do one-time tasks here
button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);
button.ButtonReleased += new Button.ButtonEventHandler(button_ButtonReleased);
Debug.Print("Program Started");
}
void button_ButtonPressed(Button sender, Button.ButtonState state)
{
Debug.Print("Press");
}
void button_ButtonReleased(Button sender, Button.ButtonState state)
{
Debug.Print("Release");
}
}
}
Hello,
Every time you take a picture, the module delay a short time, it also means the value of “camera.CameraReady” is always false, that why you can not see any toggle led.
Can you please help me to rewrite your code a little bit in your side:
void button_ButtonPressed(Button sender, Button.ButtonState state)
{
if (camera.CameraReady)
{
button.ToggleLED();
camera.TakePicture();
}
}
void button_ButtonReleased(Button sender, Button.ButtonState state)
{
button.ToggleLED();
}
OK - now my code looks like this:
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
namespace GadgeteerApp1
{
public partial class Program
{
void ProgramStarted()
{
/******************************************************************************************
Access modules defined in the designer by typing their name:
e.g. button
camera1
Initialize event handlers here.
e.g. button.ButtonPressed += new GTM.MSR.Button.ButtonEventHandler(button_ButtonPressed);
***************************************************************************************** */
// Do one-time tasks here
button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);
button.ButtonReleased += new Button.ButtonEventHandler(button_ButtonReleased);
Debug.Print("Program Started");
}
void button_ButtonPressed(Button sender, Button.ButtonState state)
{
button.ToggleLED();
Debug.Print("Pressed");
}
void button_ButtonReleased(Button sender, Button.ButtonState state)
{
button.ToggleLED();
Debug.Print("Released");
}
}
}
…but I’m still only getting released events:
The thread ‘’ (0x2) has exited with code 0 (0x0).
Using mainboard GHIElectronics-FEZSpider version 1.0
Program Started
Released
Released
Released
Released
The program ‘[7] Micro Framework application: Managed’ has exited with code 0 (0x0).
Go to properties of the button dll and check what version it is
Same as described in the readme.
I know it’s gotta be something blazingly simple that I’m overlooking…
One last thing to try, make a totally new project. with button and very simple code, let us know!
And make sure you are using the correct file. That file is usually located on:
C:\Program Files (x86)\GHI Electronics\GHI .NET Gadgeteer SDK\Modules\Button\NETMF 4.1
or C:\Program Files\GHI Electronics\GHI .NET Gadgeteer SDK\Modules\Button\NETMF 4.1
Can you please try to remove the old reference and add this new file by manual?
Buildiong a new project did the trick.
I guess the prior project had cached the old dlls…?
Thx!
Yes projects make thier own local copy of dlls.