EENG 383

Graphics LCD

Multiple files

You will put all your LCD routines into a file called graphics.c. Amoung other things this file will contain the bitmaps for the ascii characters.
  1. Give the declaration of array of 128x8 int8's, called ascii, that are stored in program memory.
  2. Give an example of what the initialization will look like for the ascii array for a couple of characters.
  3. In order to use the ascii array in main, the defintion of ascii will have to be given in dev10.h using the extern modifier. Show the this defintion. You may want to check extern in Wiki.

Newhaven Display

The initialization sequence of the Newhaven display needed some minor tweeks to make it work in our application. Below is my initialization sequence used to generate the test file used in lab3. For each command below identify the command and its function.
  1. Command Command Function
    SEND_DISP(COMMAND_MODE,0xA0); (8) ADC Select Display RAM adress SEG output correspondence: normal
    SEND_DISP(COMMAND_MODE,0xAE);    
    SEND_DISP(COMMAND_MODE,0xC0);    
    SEND_DISP(COMMAND_MODE,0xA2);    
    SEND_DISP(COMMAND_MODE,0x2F);    
    SEND_DISP(COMMAND_MODE,0x20);    
    SEND_DISP(COMMAND_MODE,0x81);    
    SEND_DISP(COMMAND_MODE,0x3f);    
  2. Fill in the blanks in order to complete the SEND_PLANE command. Note the rows of the display are refered to as pages.
    void SEND_PLANE(int8 plane[128][4]) {
        int8 row,col;
    
    	SEND_DISP(COMMAND_MODE,     );		// LCD display off
    	for(row=0; row<4; row++) {
    		SEND_DISP(COMMAND_MODE,     );	// point to the first "row"
    		SEND_DISP(COMMAND_MODE,     );	// and the 0th column
    		SEND_DISP(COMMAND_MODE,     );	// Column Address Set requires two writes
    		for (col=0; col<128; col++) {
    			SEND_DISP(DATA_MODE,                );
    		} // end for column
    	} // end for row
    	SEND_DISP(COMMAND_MODE,    );		// LCD display on
    } // end for SEND_PLANE
    
  3. Import the following image into paint and show what happens for each of the operations.
Function Description
void INIT_LCD(void) Initializes the LCD,
void SEND_DISP(int8 mode, int8 data) Send the data to the display in the specified mode. The function should check the SSPIF before transmitting to insure the the transmitt buffer is not overrun.
void WRITE_STRING(int8 row, int8 col, char *ptr, int8 plane[128][4]) Writes the NULL terminated string to the display.
void POINT(int8 x0, int8 y0, int8 plane[128][4]) Draws a point at location (x0,y)
void CHANGE_MODE(int8 mode)
Mode Effect
OVER Overwrites anything on the graphics plane
AND ANDs new pixels into the graphics plane
OR ORs new pixels into the graphics plane
XOR XORs new pixels into the graphics plane
void INIT_PLANE(int8 display[128][4], int8 color) Clears all the pixels in the graphics plane to the defined color (black=1, white=0).
void COPY_PLANE(int8 src[128][4], int8 dest[128][4]) Copys the pixels from the source plane into the destination plane.
void SEND_PLANE(int8 display[128][4]) Sends the pixel array pointed to by display to the LCD.

Bonus functions

void LINE(int8 x0, int8 y0, int8 xf, int8 yf, int8 plane[128][4]) Draws a line on the LCD starting at (x0,y0) and finishing at (xf,yf)
void CIRCLE(int8 x, int8 y, int8 radius, int8 plane[128][4]); Draws a circle at x,y with the specified radius
void SPRITE(int8 *sprite, int8 width, int8 height, int8 x, int8 y, int8 plane[128][4]) Mask in the 2-D sprite with dimensions width x height into the graphics plane at location x,y
Its up to you to write an application which demonstrates that these functions work. You can write a simple terminal application, use the push buttons, or build a simple game of tic-tac-toe. Its your call.