static void display_TouchUp(DisplayNhd5 sender, TouchEventArgs e) { //point loc; touches[0].X = e.X; touches[0].Y = e.Y; GlideTouch.RaiseTouchUpEvent(null, new GHI.Glide.TouchEventArgs(touches)); //Debug.Print("Finger " + e.FingerNumber + " up!"); //loc.X = e.X; //loc.Y = e.Y; //Core.RaiseTouchEvent(TouchType.TouchUp, loc); }
//static bool roverHeadLights = false; //static bool roverTakePicture = false; public static void Main() { #region Newhaven 3.5" Display Graphic Setup /* * var lcdConfig3 = new Configuration.LCD.Configurations(); * * lcdConfig3.Width = 320; * lcdConfig3.Height = 240; * * lcdConfig3.OutputEnableIsFixed = true; * lcdConfig3.OutputEnablePolarity = true; * * lcdConfig3.HorizontalSyncPolarity = false; * lcdConfig3.VerticalSyncPolarity = false; * lcdConfig3.PixelPolarity = true; * * lcdConfig3.HorizontalSyncPulseWidth = 68; * lcdConfig3.HorizontalBackPorch = 2; * lcdConfig3.HorizontalFrontPorch = 18; * lcdConfig3.VerticalSyncPulseWidth = 10; * lcdConfig3.VerticalBackPorch = 3; * lcdConfig3.VerticalFrontPorch = 10; * * lcdConfig3.PixelClockRateKHz = 6400; * * Configuration.LCD.Set(lcdConfig3); * */ //if (Configuration.LCD.Set(lcdConfig3)) PowerState.RebootDevice(false); //Initialiazing and hooking to events var display = new DisplayNhd5(new Microsoft.SPOT.Hardware.I2CDevice(new Microsoft.SPOT.Hardware.I2CDevice.Configuration(0x38, 400))); //display.TouchUp += (sender, e) => Debug.Print("Finger " + e.FingerNumber + " up!"); display.TouchUp += new TouchEventHandler(display_TouchUp); //display.TouchDown += (sender, e) => Debug.Print("Finger " + e.FingerNumber + " down!"); display.TouchDown += new TouchEventHandler(display_TouchDown); display.ZoomIn += (sender, e) => Debug.Print("Zoom in"); display.ZoomOut += (sender, e) => Debug.Print("Zoom out"); /* * //Method one: polling manually. Uncomment the while cycle to use it. * * //while (true) { * // display.ReadAndProcessTouchData(); * // Thread.Sleep(50); * //} */ //Method two: using interrupt (for G120). var touchPin = new Microsoft.SPOT.Hardware.InterruptPort(GHI.Hardware.G120.Pin.P0_25, false, Microsoft.SPOT.Hardware.Port.ResistorMode.PullUp, Microsoft.SPOT.Hardware.Port.InterruptMode.InterruptEdgeLow); var wakePin = new Microsoft.SPOT.Hardware.InputPort(GHI.Hardware.G120.Pin.P0_24, false, Microsoft.SPOT.Hardware.Port.ResistorMode.Disabled); //var touchPin = new Microsoft.SPOT.Hardware.InterruptPort(GHI.Hardware.G120.Pin.P0_23, false, Microsoft.SPOT.Hardware.Port.ResistorMode.PullUp, Microsoft.SPOT.Hardware.Port.InterruptMode.InterruptEdgeLow); //I DID THIS touchPin.OnInterrupt += (data1, data2, time) => display.ReadAndProcessTouchData(); #endregion #region LAIRD XCVR SETUP //lairdWirelss.Configure(9600, GT.Interfaces.Serial.SerialParity.None, GT.Interfaces.Serial.SerialStopBits.One, 7); lairdComPort = new SerialPort("COM2", 115200); //TX2 = P2.0, RX2 = P0.16 //lairdComPort = new SerialPort("COM2", 9600); lairdComPort.Open(); lairdReset = new Microsoft.SPOT.Hardware.OutputPort(lairdResetPin, true); lairdCts = new Microsoft.SPOT.Hardware.OutputPort(lairdCtsPin, false); //lairdRts = new Microsoft.SPOT.Hardware.InputPort(lairdRtsPin, false, Microsoft.SPOT.Hardware.Port.ResistorMode.PullUp); lairdRange = new Microsoft.SPOT.Hardware.InputPort(lairdRangePin, false, Microsoft.SPOT.Hardware.Port.ResistorMode.Disabled); /* * lairdCtsPin = GT.Socket.GetSocket(5, true, null, null).CpuPins[6]; * //lairdRtsPin = GT.Socket.GetSocket(5, true, null, null).CpuPins[7]; * lairdResetPin = GT.Socket.GetSocket(5, true, null, null).CpuPins[3]; * lairdRangePin = GT.Socket.GetSocket(5, true, null, null).CpuPins[8]; */ lairdWirelessBuffer = new SerialBuffer(72); #endregion #region QUAD POWER SETUP quadPowerComPort = new SerialPort("COM3", 9600); quadPowerComPort.Open(); quadPowerBuffer = new SerialBuffer(36); #endregion // Load the window _mainWindow = GlideLoader.LoadWindow(OakhillLandroverController.Resources.GetString(OakhillLandroverController.Resources.StringResources.wndMain)); //pictureWindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.Picture_Window)); outputsWindow = new OutputsWindow();//gndEfxWindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.GroundEfx_Window)); ecoCamWindow = new EcoCamWindow(); setupWindow = new SetupWindow(); // Activate touch //GlideTouch.Initialize(); // Initialize the windows. initMainWindow(_mainWindow); // Assigning a window to MainWindow flushes it to the screen. // This also starts event handling on the window. Glide.MainWindow = _mainWindow; //bool mybool = SDCard.sdCardDetect; //bool yourBool = batChargeState.Read(); //lcdBacklight.Write(false); //turn lcd screen off //onBoardLed.Write(true); picCounter = -1; //Glide.MessageBoxManager.Show("SD Card not found.", "SD Card"); UpdateMainWindowTimer = new Timer(new TimerCallback(UpdateMainWindowTimer_Tick), null, 0, UpdateMainWindowTimerPeriod); PictureViewerTimer = new Timer(new TimerCallback(PictureViewerTimer_Tick), null, -1, PictureViewerTimerPeriod); RoverJoystickControlTimer = new Timer(new TimerCallback(RoverJoystickControlTimer_Tick), null, 0, RoverJoystickTimerPeriod); //display_T35.SimpleGraphics.DisplayImage(SD_ROOT_DIRECTORY + @"\roverPic17.jpg", Bitmap.BitmapImageType.Jpeg, 0, 0); Thread.Sleep(-1); }