Hi All,
I have a strange issue with the EMX module.
I have designed & fabricated a PCB for my home automation system, the EMX module is mounted in the centre and ethernet, USB Device & SD card components are around the outside. There is also a 60 pin IO header for extensibilty. On the reverse side of the PCB is a 40 pin connector which connects to another PCB which is responsible for the LCD FPC connectors and backlight circuit. I;m using the standard sharp 480x272 LCD touch screen.
When im debugging from VS2010 through USB1 the touch screen functions correctly - i can receive and consume touch events.
However - when the PCB is not connected to USB - and therefore powerd via PoE - the touch screen doesnt report any touch events.
Is there something specific about debug mode, and maybe some additional configuration I need to supply for this to work standalone?
I’m not sure at the moment if this is software or hardware related…
Any help you guys have would be much appreciated…
public static void Main()
{
var application = new Program();
//Configure Touch
Touch.Initialize(application);
SetTouchConfiguration();
Touch.ActiveTouchPanel.Enabled = true;
//Configure Display
var lcdBacklight = new OutputPort(EMX.Pin.IO48, true);
lcdBacklight.Write(true);
//Configure Network
SetNetworkConfiguration();
//Start Database
var tDatabase = new Thread(StartDatabase);
tDatabase.Start();
application.Run(application.CreateWindow());
}
static void SetTouchConfiguration()
{
var sx = new short[5] { 240, 48, 48, 432, 432 };
var sy = new short[5] { 136, 26, 246, 246, 26 };
var cx = new short[5] { 478, 189, 169, 781, 790 };
var cy = new short[5] { 481, 238, 741, 767, 231 };
Touch.ActiveTouchPanel.SetCalibration(5, sx, sy, cx, cy);
}
Using code tags will make your post more readable. This can be done in two ways:[ol]
Click the “101010” icon and paste your code between the
tags or...
Select the code within your post and click the "101010" icon.[/ol]
(Generated by QuickReply)
Where in the code do you subscribe for the events?
Hi Architect,
Thanks for the reply - and for the code paste tip… :o)
Here is my button class…
#region Using Directives
using Microsoft.SPOT;
using Microsoft.SPOT.Input;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
#endregion
namespace Intellitouch.UI.Controls
{
public class ControlButton : ContentControl
{
#region Private Members
private readonly Border _border;
private int _borderWidth;
private bool _isFocused;
private bool _isPressed;
private Brush _bground;
private Brush _borderBrush;
private Brush _pressedBackground;
private Brush _pressedBorderBrush;
#endregion
#region Public Events
public event EventHandler Click;
#endregion
#region Construct
public ControlButton(UIElement child)
{
_border = new Border
{
Background = new SolidColorBrush(Colors.White),
BorderBrush = new SolidColorBrush(Colors.Black),
};
PressedBackground = Background;
PressedBorderBrush = new SolidColorBrush(Colors.Gray);
_border.SetBorderThickness(_borderWidth);
Child = child;
base.Child = _border;
}
#endregion
#region Public Properties
public bool IsPressed
{
get { return _isPressed; }
set
{
if (value != _isPressed)
{
_isPressed = value;
if (_isPressed)
{
_border.Background = PressedBackground;
_border.BorderBrush = PressedBorderBrush;
}
else
{
_border.Background = Background;
_border.BorderBrush = BorderBrush;
}
}
}
}
public new Brush Background
{
get { return _bground; }
set
{
_bground = value;
if (!IsPressed)
{
_border.Background = _bground;
}
}
}
public Brush BorderBrush
{
get { return _borderBrush; }
set
{
_borderBrush = value;
if (!IsPressed)
{
_border.BorderBrush = _borderBrush;
}
}
}
public Brush PressedBackground
{
get { return _pressedBackground; }
set
{
_pressedBackground = value;
if (IsPressed)
{
_border.Background = value;
}
}
}
public Brush PressedBorderBrush
{
get { return _pressedBorderBrush; }
set
{
_pressedBorderBrush = value;
if (IsPressed)
{
_border.BorderBrush = value;
}
}
}
public int BorderWidth
{
set
{
_borderWidth = value;
_border.SetBorderThickness(_borderWidth);
}
}
public new UIElement Child
{
get { return _border.Child; }
set
{
_border.Child = value;
}
}
#endregion
#region Private Methods
protected virtual void OnClick()
{
if (Click != null)
{
Click(this, new EventArgs());
}
}
#endregion
#region Overrides
protected override void OnTouchDown(TouchEventArgs e)
{
base.OnTouchDown(e);
_isFocused = TouchCapture.Capture(this);
IsPressed = _isFocused;
}
protected override void OnTouchMove(TouchEventArgs e)
{
base.OnTouchMove(e);
if (_isFocused)
{
int x, y;
e.GetPosition(this, e.Touches.Length - 1, out x, out y);
IsPressed = x >= 0 && x <= ActualWidth && y >= 0 && y <= ActualHeight;
}
}
protected override void OnTouchUp(TouchEventArgs e)
{
base.OnTouchUp(e);
if (_isFocused)
{
int x, y;
IsPressed = false;
_isFocused = !TouchCapture.Capture(this, CaptureMode.None);
e.GetPosition(this, 0, out x, out y);
if (x >= 0 && x <= ActualWidth && y >= 0 && y <= ActualHeight)
{
OnClick();
}
}
}
#endregion
}
}