Clark wrote:Hi Mike,
In older displays we offered the ability to lock out certain settings or text from updating the display, but these really just ignore the underlying problem; something is going wrong in communication. I understand we have explored the possibility of continuing the legacy here, but with the reporting power of the GTT it should be possible to find and handle the cause of these problems.
That said I understand finding the source of this problem won't be easy. With a 4KB buffer and flow control (I'm assuming this is activated on your end as I know you've been reading back from the display) a lot of information needs to travel to the GTT to force an error. I would recommend throwing long strings of data using the Echo command, and possibly experimenting with lower baud rates to learn more about where the error occurs and why.
However, as a possible work around, one of my colleagues suggested creating and loading a blank font; try deselecting all the options in the font generation window. Again, it would be great to know what is causing the error, but if time is short you may be able to load up this font when text is not desired to sidestep it for now.
Thanks,
~Troy
I set the text insertion window off the screen, and have disabled scrolling, so it just doesn't show. Inelegant, but that's how workarounds are
The USB cable I was using is pretty thin and long, so I'm testing with a better cable. You'd think that bit errors should be so low as to be a non-issue though.
A black font wouldn't work, since it will invariably overwrite some line that I'm not redrawing on every update.
This is a back burner issue since I can get it not to show up, and it only happens every 4 hours or so (and thus why it is so hard to troubleshoot!).
Sample code below. Timer is set for 200ms recurrence. If I do any more commands during the timer tick the display falls behind, so I'm just doing the one. I initially had put the value below each bar graph also, but that reduced mt to an update every couple of seconds (clear previous string with black rectangle, set insertion point, insert text) x 8 plus the update graph command takes about 5 seconds to execute, which just doesn't look pretty.
GTTDisplay is just a little wrapper that stuffs the bytes into an array and then sends out.
Code: Select all
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GTTDisplay;
namespace GTTTest
{
public partial class Form1 : Form
{
public Display T;
private String myStr;
Random R;
private int BarGraphWidth = 40;
private int BarGraphSpacing = 60;
private int BarGraphPadding = 10;
private int BottomSpacing = 30;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
R = new Random();
T = new Display(7);
T.TouchEvent = new Display.TouchEventDelegate(ProcessTouch);
if (T.InitializeDisplay() == false)
{
MessageBox.Show("booo");
}
T.EnableManualUpdate(true);
T.ClearScreen();
T.ChangeDrawingColor(Color.DarkOliveGreen);
T.DrawLine(new Point(0, T.Height-BottomSpacing), new Point(T.Width,T.Height-BottomSpacing));
T.ChangeTouchReportingStyle(11);
T.SetScrollMode(1);
T.SetTextWindow(new Point(0, 260), T.Width, T.Height);
T.SetTextColor(Color.White);
for (int i = 0; i < 8; i++)
{
T.CreateBarGraph(i, 0, 260, (i*BarGraphSpacing)+BarGraphPadding, 11, BarGraphWidth, 261-BottomSpacing, Color.Green,Color.FromArgb(18,18,55), 0);
T.UpdateSingleBargraph(i, 260);
T.DrawLine(new Point((i * BarGraphSpacing), 261 - BottomSpacing+11), new Point((i * BarGraphSpacing), 261 + BottomSpacing));
T.SetTextInsertionPoint(new Point((i * BarGraphSpacing) + (int)(BarGraphWidth / 2) + (int)(BarGraphPadding / 2), 1));
T.WriteText((i+1).ToString());
}
T.DrawLine(new Point(T.Width-1, 261 - BottomSpacing + 11), new Point(T.Width-1, 261 + BottomSpacing));
T.SetTextWindow(new Point(0, 260), T.Width, T.Height);
T.SetTextColor(Color.Blue);
T.SetTextWindow(new Point(0, 250), T.Width, T.Height);
T.ManualUpdate();
T.EnableManualUpdate(false);
timer1.Start();
}
private void ProcessTouch(string type, int X, int Y)
{
myStr = "Type: " + type + "\nX: " + X + "\nY: " + Y;
}
private void timer1_Tick(object sender, EventArgs e)
{
int[] r = new int[8];
for (int i = 0; i < 8; i++)
{
r[i] = R.Next() % 260;
}
T.UpdateMultipleBargraphs(0, r);
label1.Text = myStr;
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
T.ClosePort();
}
}
}
From the GTTDisplay class, some samples on how I'm initializing and sending the data
Code: Select all
public bool InitializeDisplay()
{
mySP = new SerialPort("COM"+myPort.ToString(), 115200, Parity.None, 8, StopBits.One);
try
{
mySP.Encoding = Encoding.ASCII;
mySP.Handshake = Handshake.RequestToSend;
mySP.Open();
mySP.ReceivedBytesThreshold = 9;
mySP.DataReceived += port_OnReceiveDatazz;
return true;
}
catch
{
return false;
}
}
public void ChangeDrawingColor(Color C)
{
byte[] b = new byte[5];
b[0] = 254;
b[1] = 99;
b[2] = C.R;
b[3] = C.G;
b[4] = C.B;
mySP.Write(b, 0, b.Length);
}
public void CreateBarGraph(int Index,int Min, int Max,int X,int Y,int Width,int Height, Color Foreground, Color Background, int Orientation)
{
byte[] b = new byte[22];
b[0] = 254;
b[1] = 103;
b[2] = (byte)Index;
b[3] = BitConverter.GetBytes((short)Min)[1];
b[4] = BitConverter.GetBytes((short)Min)[0];
b[5] = BitConverter.GetBytes((short)Max)[1];
b[6] = BitConverter.GetBytes((short)Max)[0];
b[7] = BitConverter.GetBytes((short)X)[1];
b[8] = BitConverter.GetBytes((short)X)[0];
b[9] = BitConverter.GetBytes((short)Y)[1];
b[10] = BitConverter.GetBytes((short)Y)[0];
b[11] = BitConverter.GetBytes((short)Width)[1];
b[12] = BitConverter.GetBytes((short)Width)[0];
b[13] = BitConverter.GetBytes((short)Height)[1];
b[14] = BitConverter.GetBytes((short)Height)[0];
b[15] = Foreground.R;
b[16] = Foreground.G;
b[17] = Foreground.B;
b[18] = Background.R;
b[19] = Background.G;
b[20] = Background.B;
b[21] = (byte)Orientation;
mySP.Write(b, 0, b.Length);
}
public void UpdateSingleBargraph(int Index, int Value)
{
byte[] b = new byte[5];
b[0] = 254;
b[1] = 105;
b[2] = (byte)(Index);
b[3] = BitConverter.GetBytes((short)Value)[1];
b[4] = BitConverter.GetBytes((short)Value)[0];
mySP.Write(b, 0, b.Length);
}
public void UpdateMultipleBargraphs(int StartIndex, int[] Values)
{
byte[] b = new byte[4+(Values.Length*2)];
b[0] = 254;
b[1] = 106;
b[2] = (byte)(StartIndex);
b[3] = (byte)(Values.Length);
int i = 4;
foreach (int Value in Values)
{
b[i++] = BitConverter.GetBytes((short)Value)[1];
b[i++] = BitConverter.GetBytes((short)Value)[0];
}
mySP.Write(b, 0, b.Length);
}