Page 1 of 1

Strange behaviour with horizontal graphs on MX4?

Posted: Sun Jan 25, 2009 5:05 pm
by MarkuzLS1
Am I doing this wrong, or something? I've got an MX4 and I'm graphing my CPU usage with a horizontal graph. I call my InitGraph() function first:

Code: Select all

unsigned long CLCDControls::InitGraph()
{
	unsigned long writeCount = 0;
	BYTE writeArray[2] = {0xFE, 0x68};

	writeCount =  WriteToPort(writeArray, 2);

	return(writeCount);
}
Later, my DrawGraph() function gets called by the software to actually draw the graph:

Code: Select all

unsigned long CLCDControls::DrawGraph(int column, int row, int dir, int length)
{
	unsigned long writeCount = 0;
	BYTE writeArray[6];

	writeArray[0] = 0xFE;
	writeArray[1] = 0x7C;
	writeArray[2] = column;
	writeArray[3] = row;
	writeArray[4] = dir;
	writeArray[5] = length;

	writeCount = WriteToPort(writeArray, 6);

	return(writeCount);
}
For some reason, when the graph gets to be more than one character long, I get blocks with capital 'P's in them for all the full blocks. The partial block at the far end of the graph draws correctly. Am I doing something wrong? Text appears to be displayed just as it's supposed to.

Posted: Mon Jan 26, 2009 9:48 am
by Raquel
Hello Markuz,

Thank you for posting on the forum.

The reason why you are seeing inverted 'P's on the MX4 is because your display has European character set. As you may or may not know, the display is only capable of having 8 custom characters. With the old Japanese character set, a full block character was readily available as part of the character set, which is not the case anymore with the European character set.

If you are using the horizontal graph in one direction at a time only (ie. right facing or left facing) I can help you with a solution; otherwise, using the hor graph in both directions within one screen will make the 'P's appear.

I hope this helps.

Posted: Mon Jan 26, 2009 3:34 pm
by MarkuzLS1
Yeah, I don't have any intention of using bars in different directions, simultaneously. Really, what I've got coded up, right now, only draws them from left to right. I don't really see that changing. I appreciate the help.

Posted: Mon Jan 26, 2009 5:08 pm
by Raquel
Hello Markuz,

You will need to do a bit of changes from your existing code.
Here's the pseudo code for it:

Code: Select all

unsigned long CLCDControls::InitGraph() 
{
// basically making the custom characters
send 254 / 78 / 0 / 16 / 16 / 16 / 16 / 16 / 16 / 16 / 16
send 254 / 78 / 1 / 24 / 24 / 24 / 24 / 24 / 24 / 24 / 24
send 254 / 78 / 2 / 28 / 28 / 28 / 28 / 28 / 28 / 28 / 28
send 254 / 78 / 3 / 30 / 30 / 30 / 30 / 30 / 30 / 30 / 30
send 254 / 78 / 4 / 31 / 31 / 31 / 31 / 31 / 31 / 31 / 31 
}

DrawGraph(int column, int row, int dir, int length)  
{
for (i = column; i > 0 && i <= 20; i += dir) {
   send 254 /  71
   send i
   send row
   if (length >= 5) {		
     send 0x04	// custom char 4 has the full block character
     length -= 5;
   } else if (length > 0) {
       send (length - 1); 
       length = 0;
   } else
     send 32 
}
I hope this helps. Please let me know how it turns out.