Look Here First

Curious why I created this blog? The following two posts explain it all. Click on the titles below to read more.

What this Blog is about.

Project Description.

Saturday, March 26, 2011

Display Driver Part 2

Screen Orientation.  Out of the box the screen looks to be oriented with the position 0,0 in the lower right hand corner.  It would be more convenient to re-orient the co-ordinates so that the 0,0 is in the lower left hand part of the screen (or even upper right).  It may or may not be worth the time that it takes to discover the command and syntax to re-orient the screen.  With a bit of fiddling the student was able to confirm that Columns correspond to to vertical columns and Pages correspond to Horizontal rows on the screen.

On the Epson Controller the command PASET sets the page boundary, the command CASET sets the column boundaries.  To define a box,  first send the command PASET  followed by the two individual rows that form the horizontal borders.  Then send the command CASET followed by two individual columns that form the vertical borders.  The intersection of these for lines forms the area which you can send color information to. The command RAMWR allows the controller to enter mode where The color data needs to be sent for each pixel in the area.  (If in 2048 color mode you send 3 bytes at a time that set two pixels at a time, the code example is for 2048 colors) The following code demonstrates how to set a rectangle to a solid color.

void LCDSetArea(int color,
unsigned char botRigX, unsigned char botRigY,
unsigned char width, unsigned char height)
{
LCDCommand(PASET);   // page start/end ram
LCDData(botRigY);
LCDData(botRigY + height);

LCDCommand(CASET);   // column start/end ram
LCDData(botRigX);
LCDData(botRigX + width);

LCDCommand(RAMWR);    // write
for(int count= 0; count < (width+1) * (height+1)/2; count ++)
{
LCDData((color>>4)&0x00FF);
LCDData(((color&0x0F)<<4)|(color>>8));
LCDData(color&0x0FF);  
}
}

The pixels in the area are set one by one sequentially, as seen in the loop of the function above.  The student knows that they are set either by column or by row.  To determine the exact order of this the student wrote and invoked the following function.  While running the function a few problems were discovered as outlined in Changes to Driver Initialization.


void LCDTestPixelSetOrder()
{
#ifdef EPSON
unsigned char botRigY = 20;
unsigned char botRigX = 20;
unsigned char width = 19;
unsigned char height = 19;
int color = GREEN;
LCDCommand(PASET);   // page start/end ram
LCDData(botRigY);
LCDData(botRigY + height);

LCDCommand(CASET);   // column start/end ram
LCDData(botRigX);
LCDData(botRigX + width);

LCDCommand(RAMWR);    // write
for(int count= 0; count < (width+1) * (height+1) /2; count ++)
{
// different color set when halfway done
if (count >= ((width+1) * (height+1)) / 4)
{
// red and green
if ( (count/5)%2 == 0)
color = RED;
else
color = GREEN;
}
else
{
// blue and Yellow
if ( (count/5)%2 == 0)
color = BLUE;
else
color = YELLOW;
}
LCDData((color>>4)&0x00FF);
LCDData(((color&0x0F)<<4)|(color>>8));
LCDData(color&0x0FF);   // nop(EPSON)
}
#endif
}

As one would expect the areas fill by rows in ascending order, as follows below.

10, 2<----<----0,2<---+
                              |
       +---------->-------+
        |
10,1<----<-----0,1<---+
                              |
         +-->----->-------+
          |
10,0<----<-----0,0

No comments:

Post a Comment