Recently I have been trying to get a glide touch button example working on my fez raptor and have run into issues.
The first issue was touch events not firing correctly from the display. I was receiving “Failed to perform I2C transaction” message in the console window. Long story short i overcame that issue by downloading the cp7 driver source and modifying ReadRegister with code i found in another thread then recompiling the driver and referencing my modified driver in my example project.
static byte ReadRegister(byte Address)
{
int timeout=0x10;
I2CDevice.I2CTransaction[] xActions = new I2CDevice.I2CTransaction[2];
// create write buffer (we need one byte)
byte[] RegisterAddress = new byte[1] { Address };
xActions[0] = I2CDevice.CreateWriteTransaction(RegisterAddress);
// create read buffer to read the register
byte[] RegisterValue = new byte[1];
xActions[1] = I2CDevice.CreateReadTransaction(RegisterValue);
while(timeout>0)
{
if (i2cBus.Execute(xActions, 100) == 0)
{
//Debug.Print("Failed to perform I2C transaction");
Thread.sleep(10);
timeout--;
}
else
{
//Debug.Print("Register value: " + RegisterValue[0].ToString());
timeout = 0;
}
}
return RegisterValue[0];
}
This driver fix gets the following code working properly on my cp7
using Microsoft.SPOT;
namespace GadgeteerApp2
{
public partial class Program
{
void ProgramStarted()
{
this.display_CP7.ScreenPressed += (a, b) => display_CP7.SimpleGraphics.DisplayEllipse(Gadgeteer.Color.Red, (uint)b.touchPos[0].xPos, (uint)b.touchPos[0].yPos, 5, 5);
this.display_CP7.ScreenReleased += (a) => Debug.Print("R");
this.display_CP7.MenuPressed += (a) => Debug.Print("M");
this.display_CP7.HomePressed += (a) => Debug.Print("H");
this.display_CP7.BackPressed += (a) => Debug.Print("B");
}
}
}
So once i got that working i attempted to get the button press example working.
<Glide Version="1.0.7">
<Window Name="WindowRGB" Width="320" Height="240" BackColor="11AA88">
<Button Name="buttonRed" X="20" Y="100" Width="80" Height="32" Alpha="255" Text="Red" Font="4" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
<Button Name="buttonGreen" X="120" Y="100" Width="80" Height="32" Alpha="255" Text="Green" Font="4" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
<Button Name="buttonBlue" X="220" Y="100" Width="80" Height="32" Alpha="255" Text="Blue" Font="4" FontColor="000000" DisabledFontColor="808080" TintColor="000000" TintAmount="0"/>
</Window>
</Glide>
using System;
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;
using GHI.Glide;
using GHI.Glide.UI;
namespace GlideButtonDemo
{
public partial class Program
{
static GHI.Glide.Display.Window window;
void ProgramStarted()
{
// Do one-time tasks here
Debug.Print("Program Started");
GlideTouch.Initialize();
// Load the Window XML string.
window = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.Window1));
// Resize any loaded Window to the LCD's size.
Glide.FitToScreen = true;
// Assign the Window to MainWindow; rendering it to the LCD.
Glide.MainWindow = window;
// Get the Buttons
Button buttonRed = (Button)window.GetChildByName("buttonRed");
Button buttonGreen = (Button)window.GetChildByName("buttonGreen");
Button buttonBlue = (Button)window.GetChildByName("buttonBlue");
// Set up event handlers
buttonRed.TapEvent += new OnTap(buttonRed_TapEvent);
buttonGreen.TapEvent += new OnTap(buttonGreen_TapEvent);
buttonBlue.TapEvent += new OnTap(buttonBlue_TapEvent);
}
void buttonBlue_TapEvent(object sender)
{
Debug.Print("Blue tapped");
}
void buttonGreen_TapEvent(object sender)
{
Debug.Print("Green tapped");
}
void buttonRed_TapEvent(object sender)
{
Debug.Print("Red tapped");
}
}
}
The screen properly displays the three buttons but does not log output to the console when the buttons are pressed. I have tried downloading the glide source and recompiling it with netmf 4.2 as the target as that is what im currently using as the target for my example program. I have also tried using the supplied Glide dll in the GHI sdk.
For some reason it seems like glide is not intercepting display touch events properly and therefore no buttons are working. Any help or advice would be appreciated.