// ================================================================================================ // Serial LCD v1.1 // ================================================================================================ bool LCDon = !exec.GetLED(25); // Reset LED double X = exec.GetXpos(); double Y = exec.GetYpos(); double Z = exec.GetZpos(); if (LCDon && (Status == 0)) { myPort = new System.IO.Ports.SerialPort(ComPort, ComBaud); myPort.Open(); if (myPort.IsOpen) { myPort.Write("?f?c0?BBF"); // ?f clear screen // ?c cursor mode (0..3) // ?B backlight (00..FF) LX = X + 1.0; LY = Y + 1.0; LZ = Z + 1.0; Status = 1; } } if (!LCDon && (Status == 1)) { if (myPort.IsOpen) { myPort.Write("?fRESET?c0?B0F"); } myPort.Close(); Status = 0; } if (Status == 1) { if (myPort.IsOpen) { if ((X != LX) || (Y != LY)) { LX = X; LY = Y; myPort.Write(String.Format("?!80X{0,6:F2} Y{1,6:F2}", X, Y)); // ?! send LCD command, 0x80 row1 pos1 } if (Z != LZ) { LZ = Z; myPort.Write(String.Format("?!C0Z{0,6:F2}", Z)); // ?! send LCD command, 0xC0 row1 pos1 } } } // ================================================================================================ #Events // ================================================================================================ const string ComPort = "COM4"; const int ComBaud = 19200; static System.IO.Ports.SerialPort myPort; static int Status = 0; static double LX = 0.0; static double LY = 0.0; static double LZ = 0.0;