January 27, 2021
Hot Topics:

Explore the Microsoft .NET Micro Framework

  • By Alex Gusev
  • Send Email »
  • More Articles »

The GPIOButtonInputProvider class defines and handles hardware input for you. There are 14 buttons and 16 CPU pins available. If the emulator or device supports it, you can implement quite a keyboard.

The windows may handle keyboard events (listed in the Microsoft.SPOT.Input namespace, so you may slightly extend the default implementation:

// From CreateWindow
// Connect the button handler to all of the buttons.
   new ButtonEventHandler(OnButtonUp), false);

private void OnButtonUp(object sender, ButtonEventArgs e)
   // Print the button code to the Visual Studio output window.
   // And also to the screen
   Text text = (Text)mainWindow.Child;
   text.TextContent = "Pressed button code = " +

The SDK samples give you an excellent overview of other functionality, such as presentation features, networking, web services, threading, and so forth.

Device Emulator

The .NET Micro Framework SDK has the default device emulator you can use as it is. Device starter kits may contain their own emulators. In case you need a new one, you can do it yourself! Select the "Device Emulator" template and you'll get the bare bones skeleton program. As you might expect, this is normal WinForms application with few additional features.

The main building UI blocks of the new emulator are:

  1. Background image
  2. LCD
  3. Keypad

The Microsoft.SPOT.Emulator.Emulator class provides access to the main hardware components, such as LcdDisplay, Battery, GPIO ports, and so on. Your task is to implement the User Interface part and handle all events as required. Don't be too scared; fortunately, SDK's Temperature sample gives you a fairly good idea of what to do. The TemperatureEmulator project represents the emulator itself. If you dig in into its settings a bit more, you can find that the command line for that project contains a list of the modules that should be loaded when the emulator starts:

"/load:%ProgramFiles%\Microsoft .NET Micro Framework\v2.0.3036\
"/load:%ProgramFiles%\Microsoft .NET Micro Framework\v2.0.3036\
"/load:%ProgramFiles%\Microsoft .NET Micro Framework\v2.0.3036\
"/load:%ProgramFiles%\Microsoft .NET Micro Framework\v2.0.3036\
"/load:%ProgramFiles%\Microsoft .NET Micro Framework\v2.0.3036\

Thus, you will need to define the entry point somewhere to run it, in this particular case within TemperatureSample. Because the emulator is a regular WinForms application, you can add everything in addition to the background image, display, and keyboard. The final result for the Temperature device emulator is shown in Figure 5:

Click here for a larger image.

Figure 5: Temperature Device Emulator

Coming back to the user interface elements, you can see that the Temperature emulator project contains a few User Controls to represent the LCD display and keyboard. They do all the work to handle multiple UI events and translate them into .NET Micro Framework ones where necessary. You may use those controls in your own projects too.

Page 3 of 4

This article was originally published on August 13, 2008

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date