I’m getting started with my first projects here with the .NET MF and I have a FEZ Spider with a Temperature Humidity module from Seeed that I’m trying to use.
My code is really simple, below is my Program.cs for some clarity. I have a very simple setup, a single “image” that is being displayed to a WPF window. Once clicked I call “RequestMeasurement” on the TemperatureHumidity Module. I have a handler added to then update the UI. Debugging I can see that it does actually get called but the line to update the text content isn’t being fired off.
With WinForms I’d think of this as a threading issue, but I don’t see any way to actually see/fix it.
private Image imgButton1;
private Image imbButton2;
private Text txtFeedback;
// This method is run when the mainboard is powered up or reset.
temperatureHumidity.MeasurementComplete += new TemperatureHumidity.MeasurementCompleteEventHandler(tempUpdated);
// Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
void tempUpdated(TemperatureHumidity sender, double temperature, double relativeHumidity)
txtFeedback.TextContent = string.Concat("Temp: ", temperature.ToString("0.0"), " Humidity: ", relativeHumidity.ToString("0.0"));
public void SetupUI()
var window = display.WPFWindow;
var canvas = new Canvas();
window.Child = canvas;
//Add the first button
var imgButton1 = new Image(Resources.GetBitmap(Resources.BitmapResources.Button1));
imgButton1.TouchDown += new Microsoft.SPOT.Input.TouchEventHandler(Button1_Pressed);
PositionElemen(imgButton1, 10, 5);
//Add the textbox
txtFeedback = new Text(Resources.GetFont(Resources.FontResources.NinaB), string.Empty);
PositionElemen(txtFeedback, 20, 200);
private void PositionElemen(UIElement element, int x, int y)
void Button1_Pressed(object sender, Microsoft.SPOT.Input.TouchEventArgs e)
To add a bit more to this. I added some basic structure to the code to help debug, I added a LED and in my update method, I change the color based on difference in temp from previous readings. This appears to be working as one would expect. But my debug message isn’t displayed either
A first chance exception of type ‘System.ArgumentException’ occurred in mscorlib.dll
Error invoking method “Gadgeteer.Modules.Seeed.TemperatureHumidity” (check arguments to Program.BeginInvoke are correct)
I find your example very useful and tried to copy it but I cant find getBitmap and BitmapResources.Button1.
I think they must be defined before. How can I do it?? Have I to import the available buttons (I suggest that there are predefined standard buttons which can be used).
I see only Font Resources in Project Explorer.