Mikrobus.Net Quail and ThumbStick Click

Back in June I purchased a MikroBus.Net Quail board and a selection of Mikro Elektronika click boards. After figuring out I had purchased a couple of click boards which didn’t have NetMF driver support, I placed another order (ensuring drivers available) which arrived just before Christmas.

The mikroBUS connector standard has quite a different approach to my arduino style boards where the analog, digital, I2C , SPI and other functionality of the microcontroller are exposed on headers.

The mikroBUS standard specifies several different mechanical configurations (small, medium & large) for clicks and the connections available on the 16 pins (2 x 8 pin female headers).

mikrobus_pinout_thumb_b

This impacts on the way sensors are connected, for example with Arduino style devices there are shields with joysticks and buttons which are read using analog inputs and interrupt ports for the buttons

The mikroBus click boards only have one analog port so the x & y axis values of the joystick are read by an MCP3204 Analog to Digital convertor connected to the SPI Bus and the joystick button is connected to the interrupt port.

The microbus team have done a lot of work developing 60+ drivers and the ThumbStick driver was one of the first I downloaded. The interface provided by the driver is relatively straight forward to use

using MBN;
using MBN.Modules;
using Microsoft.SPOT;
using System.Threading;

namespace ThumbstickClickTestApp
{
   public class Program
   {
      public static void Main()
      {
         ThumbstickClick thumbStick = new ThumbstickClick(Hardware.SocketOne);

         thumbStick.ThumbstickOrientation = ThumbstickClick.Orientation.RotateZeroDegrees;
         thumbStick.ThumbstickPressed += thumbstickPressed;
         thumbStick.ThumbstickReleased += thumbstickReleased;
         thumbStick.Calibrate();

         while (true)
         {
            var position = thumbStick.GetPosition();

            Debug.Print("X,Y,IsPressed " + position.X.ToString("F1") + "," + position.Y.ToString("F1") + "," + thumbStick.IsPressed);

            Thread.Sleep(1000);
         }
      }

      static void thumbstickReleased(ThumbstickClick sender, ThumbstickClick.ButtonState state)
      {
         Debug.Print("Thumbstick Released");
      }

      static void thumbstickPressed(ThumbstickClick sender, ThumbstickClick.ButtonState state)
      {
         Debug.Print("Thumbstick Pressed");
      }
   }
}

From the diagnostics output window in Visual Studio
X,Y,IsPressed 0.0,0.0,False
X,Y,IsPressed 0.0,0.0,False
Thumbstick Pressed
Thumbstick Released
X,Y,IsPressed 0.0,-0.0,False
Thumbstick Pressed
X,Y,IsPressed 0.0,1.0,True
Thumbstick Released
X,Y,IsPressed 0.0,0.0,False
X,Y,IsPressed 0.0,0.0,False

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s