Hi,
I’ve been working on the touch screen and try to make some customize buttons without glide. When the programs starts the first image appears just a fraction of time and then dissapears turning the entire screen blank. If I touch the screen the program responds as expected printing the image back.
I Think is a Touch inizalitation problem, I don’t have this problem when I use the screen for printing images only (without touch events).
using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation.Shapes;
using Microsoft.SPOT.Touch;
using Microsoft.SPOT.Input;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
namespace GadgeteerApp6
{
public partial class Program
{
public Bitmap plantilla = new Bitmap(Resources.GetBytes(Resources.BinaryResources.plantilla),Bitmap.BitmapImageType.Jpeg);
public Bitmap imagen1 = new Bitmap(Resources.GetBytes(Resources.BinaryResources.Img1), Bitmap.BitmapImageType.Jpeg);
public Bitmap imagen2 = new Bitmap(Resources.GetBytes(Resources.BinaryResources.Img2), Bitmap.BitmapImageType.Jpeg);
public Bitmap imagen3 = new Bitmap(Resources.GetBytes(Resources.BinaryResources.Img3), Bitmap.BitmapImageType.Jpeg);
public Bitmap imagen4 = new Bitmap(Resources.GetBytes(Resources.BinaryResources.Img4), Bitmap.BitmapImageType.Jpeg);
public bool estatus = false;
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
//Touch.Initialize(Application.Current);
//displayTE35.SimpleGraphics.AutoRedraw = true;
button.ButtonPressed += new Button.ButtonEventHandler(presionar_boton);
//button.ButtonReleased += new Button.ButtonEventHandler(soltar_boton);
displayTE35.WPFWindow.TouchDown += new Microsoft.SPOT.Input.TouchEventHandler(touch_D);
//displayTE35.WPFWindow.TouchMove += new Microsoft.SPOT.Input.TouchEventHandler(touch_M);
//displayTE35.WPFWindow.TouchUp += new Microsoft.SPOT.Input.TouchEventHandler(touch_U);
displayTE35.SimpleGraphics.Clear();
displayTE35.SimpleGraphics.DisplayImage(plantilla, 0, 0);
this.plantilla.Flush();
//Debug.Print("Program Started");
displayTE35.WPFWindow.Invalidate();
}
private void touch_D(object sender, Microsoft.SPOT.Input.TouchEventArgs e)
{
if ((0 < (uint)e.Touches[0].X && (uint)e.Touches[0].X < 68) && (177 < (uint)e.Touches[0].Y && (uint)e.Touches[0].Y < 240))
{
//displayTE35.SimpleGraphics.Clear();
displayTE35.SimpleGraphics.DisplayImage(plantilla, 0, 0);
displayTE35.SimpleGraphics.DisplayImage(imagen1, 48, 23);
}
else if ((73 < (uint)e.Touches[0].X && (uint)e.Touches[0].X < 160) && (177 < (uint)e.Touches[0].Y && (uint)e.Touches[0].Y < 240))
{
//displayTE35.SimpleGraphics.Clear();
displayTE35.SimpleGraphics.DisplayImage(plantilla, 0, 0);
displayTE35.SimpleGraphics.DisplayImage(imagen2, 48, 23);
}
else if ((164 < (uint)e.Touches[0].X && (uint)e.Touches[0].X < 240) && (177 < (uint)e.Touches[0].Y && (uint)e.Touches[0].Y < 240))
{
//displayTE35.SimpleGraphics.Clear();
displayTE35.SimpleGraphics.DisplayImage(plantilla, 0, 0);
displayTE35.SimpleGraphics.DisplayImage(imagen3, 48, 23);
}
else if ((246 < (uint)e.Touches[0].X && (uint)e.Touches[0].X < 320) && (177 < (uint)e.Touches[0].Y && (uint)e.Touches[0].Y < 240))
{
//displayTE35.SimpleGraphics.Clear();
displayTE35.SimpleGraphics.DisplayImage(plantilla, 0, 0);
displayTE35.SimpleGraphics.DisplayImage(imagen4, 48, 23);
}
}
private void presionar_boton(Button sender, Button.ButtonState state)
{
if (estatus == false)
{
//displayTE35.SimpleGraphics.Clear();
Mainboard.SetDebugLED(true);
button.TurnLedOff();
displayTE35.SimpleGraphics.DisplayImage(imagen1, 48, 23);
estatus = true;
}
else
{
Mainboard.SetDebugLED(false);
button.TurnLedOn();
//displayTE35.SimpleGraphics.Clear();
displayTE35.SimpleGraphics.DisplayImage(imagen2, 48, 23);
estatus = false;
}
}
}
}