LCD_1_InitBG (); //Init graph buffer
ee_get_addr = ee_put_addr gr_time;
gr_index = 255; //Init EEPROM address and buffer index
gr_col = LCD_1_BG_WIDTH;
do {
gr_col ; //Fill graph columns in reverse
scale = gr_scale; //Combine several points into one column
do {
if (gr_index == 255) { //Check for EEPROM buffer empty
ee_get_addr = 64; //Update EEPROM address
Read_Meas_Blk (); //Read a block from EEPROM
gr_index = 63; //Start at end of block
}
LCD_1_DrawBG (ee_buf[gr_index] >> 4, gr_col);
//Graph the data point
gr_index ; //Decr buffer index and point counter
scale ;
} while (scale != 0);
} while (gr_col != 0);
LCD_1_WriteBG (); //Write out the graph data to LCD CG RAM
************************************************************************
; LCD_1_DrawBG: Draw a single dot with the given parameters:
; A = Row (0 to 15), X = Column (0 to 19)
;
_LCD_1_DrawBG:
add A,LCD_BG_HEIGHT*LCD_BG_NUM_CHARS
DBG_LOOP:
sub A,LCD_BG_HEIGHT ;Advance index to next character
swap A,X
sub A,LCD_BG_CHAR_WIDTH ;Skip another character?
swap A,X
jnc DBG_LOOP ;yes, repeat
push A
mov A,00h
DBG_LOOP2:
rlc A ;Shift to next column
inc X ;Skip another column?
jnc DBG_LOOP2 ;yes, repeat
pop X
or [X+LCD_BUFFER],A ;Insert column bit into buffer
ret
Listing 1The C routine plots one point at a time by calling LCD_1_DrawBG for each one. It then calls LCD_1_WriteBG to copy the drawing buffer to the LCD CG RAM. The graph is displayed by printing the special codes 0x080x0F to the LCD that accesses the eight CG RAM locations.