extern void DelayMSEC ( unsigned int k ) ; extern void LCDWait ( void ) ; extern void LCDClear ( void ) ; extern void LCDHome ( void ) ; extern void LCDShr ( void ) ; extern void LCDShl ( void ) ; extern void LCDEntryMode ( unsigned char mode ) ; extern void LCDInit ( void ) ; extern int LCDPutchar ( const int c ) ; extern void LCDPuts ( char * ptr ) ; extern void LCDDisplay ( char * ptr ) ; extern void LCDCrLf ( void ) ; extern void LCDCr ( void ) ; extern void clrscr ( void ) ; typedef struct sLCD { unsigned char iwr ; unsigned char dwr ; unsigned char ird ; unsigned char drd ; } tLCD ; at 0xE000 xdata tLCD LCD_demo ; static unsigned char dd_ram_addr = 0x80 ; void clrscr ( ) { LCDclear ( ) ; } int putchar ( const int v ) { unsigned char v1 ; v1 = ( unsigned char ) v ; switch ( v1 ) { case ' ' : LCDCrLf ( ) ; break ; case ' ' : LCDCrLf ( ) ; break ; default : LCDPutchar ( v ) ; break ; } return ( v ) ; } void DelayMSEC ( unsigned int k ) { unsigned int i , j ; for ( j = 0 ; j < k ; j ++ ) for ( i = 0 ; i <= 120 ; ) { i ++ ; } } void LCDWait ( void ) { while ( LCD_demo . ird & 0x80 ) ; } void LCDClear ( void ) { while ( LCD_demo . ird & 0x80 ) ; LCD_demo . iwr = 0x01 ; } void LCDHome ( void ) { while ( LCD_demo . ird & 0x80 ) ; LCD_demo . iwr = 0x02 ; } void LCDShr ( void ) { while ( LCD_demo . ird & 0x80 ) ; LCD_demo . iwr = 0x1c ; } void LCDShl ( void ) { while ( LCD_demo . ird & 0x80 ) ; LCD_demo . iwr = 0x18 ; } void LCDEntryMode ( unsigned char mode ) { while ( LCD_demo . ird & 0x80 ) ; LCD_demo . iwr = 0x04 + ( mode & 0x3 ) ; } void LCDCrLf ( void ) { int i ; while ( LCD_demo . ird & 0x80 ) ; dd_ram_addr ^= 0x40 ; LCD_demo . iwr = dd_ram_addr ; while ( LCD_demo . ird & 0x80 ) ; LCD_demo . iwr = dd_ram_addr ; } void LCDCr ( void ) { while ( LCD_demo . ird & 0x80 ) ; dd_ram_addr ^= 0x40 ; while ( LCD_demo . ird & 0x80 ) ; LCD_demo . iwr = dd_ram_addr ; } void LCDDisplay ( char * ptr ) { while ( * ptr ) { if ( * ptr == ' ' ) { LCDCrLf ( ) ; ptr ++ ; } else LCDPutchar ( * ptr ++ ) ; } } void LCDPuts ( char * ptr ) { while ( * ptr ) LCDPutchar ( * ptr ++ ) ; } void LCDInit ( void ) { DelayMSEC ( 15 ) ; LCD_demo . iwr = 0x38 ; DelayMSEC ( 10 ) ; LCD_demo . iwr = 0x38 ; DelayMSEC ( 10 ) ; LCD_demo . iwr = 0x38 ; LCDWait ( ) ; LCD_demo . iwr = 0x06 ; LCDWait ( ) ; LCD_demo . iwr = 0x0C ; LCDWait ( ) ; LCD_demo . iwr = 0x01 ; LCDWait ( ) ; LCD_demo . iwr = 0x80 ; dd_ram_addr = 0x80 ; } int LCDPutchar ( const int c ) { while ( LCD_demo . ird & 0x80 ) ; LCD_demo . dwr = ( unsigned char ) c ; return ( c ) ; }