Thanks for the replies.
I managed to calibrate succesfully.
I am having difficulties to add it to my main code.
Touch.ActiveTouchPanel.SetCalibration(5, sx, sy, cx, cy); raising execption.
So I added the code Microsoft.SPOT.Touch.Touch.Initialize( );
But what parameter shall I pass?
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.Touch;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
using Microsoft.SPOT.Input;
namespace GadgeteerApp2
{
public partial class Program
{
private DispatcherTimer tmrIdleTimer;
private Window window;
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
short[] sx = null;
short[] sy = null;
short[] cx = null;
short[] cy = null;
sx = new short[5];
sy = new short[5];
cx = new short[5];
cy = new short[5];
sx[0] = (short)160;
sx[1] = (short)32;
sx[2] = (short)32;
sx[3] = (short)288;
sx[4] = (short)288;
sy[0] = (short)120;
sy[1] = (short)24;
sy[2] = (short)216;
sy[3] = (short)216;
sy[4] = (short)24;
cx[0] = (short)464;
cx[1] = (short)185;
cx[2] = (short)177;
cx[3] = (short)761;
cx[4] = (short)773;
cy[0] = (short)673;
cy[1] = (short)476;
cy[2] = (short)828;
cy[3] = (short)837;
cy[4] = (short)533;
window = display_TE35.WPFWindow;
Microsoft.SPOT.Touch.Touch.Initialize( );
Touch.ActiveTouchPanel.SetCalibration(5, sx, sy, cx, cy);
window.Background = new SolidColorBrush(GT.Color.White);
window.Child = WindowsManager.StartupScreen;
tmrIdleTimer = new DispatcherTimer();
tmrIdleTimer.Tick += new EventHandler(tmrIdleTimer_Tick);
tmrIdleTimer.Start();
}
void tmrIdleTimer_Tick(object sender, EventArgs e)
{ tmrIdleTimer.Stop();
System.Threading.Thread.Sleep(5000);
window.Child = WindowsManager.MainWindow;
WindowsManager.MainWindow.TouchDown +=
new TouchEventHandler(MainWindow_TouchDown);
}
void MainWindow_TouchDown(object sender, Microsoft.SPOT.Input.TouchEventArgs e)
{
}
}
}
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.1008
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace GadgeteerApp2 {
using Gadgeteer;
using GTM = Gadgeteer.Modules;
public partial class Program : Gadgeteer.Program {
private Gadgeteer.Modules.GHIElectronics.UsbClientDP usbClient;
private Gadgeteer.Modules.GHIElectronics.Display_TE35 display_TE35;
public static void Main() {
// Important to initialize the Mainboard first
Program.Mainboard = new GHIElectronics.Gadgeteer.FEZSpider();
Program p = new Program();
p.InitializeModules();
p.ProgramStarted();
// Starts Dispatcher
p.Run();
}
private void InitializeModules() {
this.usbClient = new GTM.GHIElectronics.UsbClientDP(1);
this.display_TE35 = new GTM.GHIElectronics.Display_TE35(14, 13, 12, 10);
}
}
}
/* Copyright 2012 Marco Minerva, marco.minerva@ gmail.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using System;
using System.Runtime.CompilerServices;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation;
using GadgeteerApp2.Extensions;
using GT = Gadgeteer;
using Microsoft.SPOT.Input;
namespace GadgeteerApp2.Windows
{
public class MainWindow : BaseWindow
{
private Text txtIPAddress;
private Text txtTime;
private DispatcherTimer tmrUpdate;
public Canvas canvasMenu;
private Canvas temperatureHumidityCanvas;
private Canvas switchesCanvas;
private Image cameraImage;
private Text txtTemperature;
private Text txtHumidity;
private Image imgSwitch1;
private Image imgSwitch2;
private Image imgSwitch3;
private Image imgSwitch4;
private static Bitmap OnBitmap = Resources.GetBitmap(Resources.BitmapResources.On);
private static Bitmap OffBitmap = Resources.GetBitmap(Resources.BitmapResources.Off);
public MainWindow()
{
AddTitleBar("Thuraya ", FontManager.NinaB,
GT.Color.White, GT.Color.Blue, GT.Color.White);
var statusCanvas = new Canvas();
txtIPAddress = new Text()
{
Font = FontManager.NinaB,
TextContent = "Teknomobil Uydu Haberlesme AS. "
};
statusCanvas.Children.Add(txtIPAddress);
txtTime = new Text()
{
Font = FontManager.NinaB,
Width = 310,
TextAlignment = TextAlignment.Right,
};
statusCanvas.Children.Add(txtTime);
this.AddStatusBar(statusCanvas, GT.Color.Gray);
// Creates menu item icons.
canvasMenu = new Canvas() { Height = 240, Width = 320 };
this.CreateMenuItem(Resources.GetBitmap(Resources.BitmapResources.address_book_icon ),
new TouchEventHandler(rehber1_TouchDown),25,
"Rehber", 0,0);
this.CreateMenuItem(Resources.GetBitmap(Resources.BitmapResources.call ),
new TouchEventHandler(arama1_TouchDown), 120,
"Arama", 80,0);
this.CreateMenuItem(Resources.GetBitmap(Resources.BitmapResources.Temp_Humidity_Menu),
new TouchEventHandler( sensor_TouchDown), 25,
"Sicaklik/Nem", 0,100);
// this.AddChild(canvasMenu, 30, 0);
this.CreateMenuItem(Resources.GetBitmap(Resources.BitmapResources.sms ),
new TouchEventHandler( sms_TouchDown), 220,
"SMS", 190,0);
this.AddChild(canvasMenu, 30, 0);
// Creates panels.
this.CreateTemperatureHumidityPanel();
//tmrUpdate = new DispatcherTimer();
//tmrUpdate.Tick += new EventHandler(tmrUpdate_Tick);
//tmrUpdate.Interval = TimeSpan.FromTicks(500 * TimeSpan.TicksPerMillisecond);
//tmrUpdate.Start();
}
private void CreateMenuItem(Bitmap bitmap, TouchEventHandler handler,
int iconMarginLeft, string labelContent, int labelMarginLeft,int top)
{
var image = new Image(bitmap);
image.TouchDown += handler;
canvasMenu.Children.Add(image, top , iconMarginLeft);
var label = new Text()
{
Font = FontManager.Arial10Bold,
Width = 120,
TextAlignment = TextAlignment.Center,
TextWrap = true,
TextContent = labelContent
};
label.TouchDown += handler;
canvasMenu.Children.Add(label, top+ 54, labelMarginLeft);
}
private void CreateTemperatureHumidityPanel()
{
temperatureHumidityCanvas = new Canvas() { Height = 240, Width = 320 };
CreateBackButton(temperatureHumidityCanvas,
"Geri",
new TouchEventHandler(geri_TouchDown));
var imgTemperature =
new Image(Resources.GetBitmap(Resources.BitmapResources.Temperature ));
txtTemperature = new Text() { Font = FontManager.Arial16Bold };
temperatureHumidityCanvas.Children.Add(imgTemperature, 63, 20);
temperatureHumidityCanvas.Children.Add(txtTemperature, 83, 80);
var imgHumidity =
new Image(Resources.GetBitmap(Resources.BitmapResources.Humidity));
txtHumidity = new Text() { Font = FontManager.Arial16Bold };
temperatureHumidityCanvas.Children.Add(imgHumidity, 70, 200);
temperatureHumidityCanvas.Children.Add(txtHumidity, 83, 255);
temperatureHumidityCanvas.Visibility = Visibility.Collapsed;
this.AddChild(temperatureHumidityCanvas, 30, 0);
}
private void CreateBackButton(Canvas canvas, string labelContent,
TouchEventHandler handler)
{
StackPanel panel = new StackPanel(Orientation.Horizontal);
var image = new Image(Resources.GetBitmap(Resources.BitmapResources.Back));
image.TouchDown += handler;
image.SetMargin(5, 3, 0, 0);
panel.Children.Add(image);
var label = new Text()
{
Font = FontManager.Arial14Bold,
TextContent = labelContent
};
label.SetMargin(10, 8, 0, 0);
panel.Children.Add(label);
canvas.Children.Add(panel);
}
void TemperatureHumidity_TouchDown(object sender, Microsoft.SPOT.Input.TouchEventArgs e)
{
temperatureHumidityCanvas.Visibility = Visibility.Visible;
canvasMenu.Visibility = Visibility.Hidden;
}
void arama1_TouchDown(object sender, Microsoft.SPOT.Input.TouchEventArgs e)
{
temperatureHumidityCanvas.Visibility = Visibility.Visible;
canvasMenu.Visibility = Visibility.Hidden;
}
void rehber1_TouchDown(object sender, Microsoft.SPOT.Input.TouchEventArgs e)
{
temperatureHumidityCanvas.Visibility = Visibility.Visible;
canvasMenu.Visibility = Visibility.Hidden;
}
void sms_TouchDown(object sender, Microsoft.SPOT.Input.TouchEventArgs e)
{
temperatureHumidityCanvas.Visibility = Visibility.Visible;
canvasMenu.Visibility = Visibility.Hidden;
}
void sensor_TouchDown(object sender, Microsoft.SPOT.Input.TouchEventArgs e)
{
temperatureHumidityCanvas.Visibility = Visibility.Visible;
canvasMenu.Visibility = Visibility.Hidden;
}
void geri_TouchDown(object sender, TouchEventArgs e)
{
canvasMenu.Visibility = Visibility.Visible;
temperatureHumidityCanvas.Visibility = Visibility.Collapsed;
}
void tmrUpdate_Tick(object sender, EventArgs e)
{
}
}
}