| 
	
	|  |  |  
	
		| View previous topic :: View next topic |  
		| Author | Message |  
		| bulentperktas 
 
 
 Joined: 11 Jul 2009
 Posts: 2
 
 
 
			      
 
 | 
			
				| more than 8 custom characters with hd44780 lcd driver CGRAM |  
				|  Posted: Thu Jun 14, 2012 5:53 pm |   |  
				| 
 |  
				| Is it possible that more than 8 custom characters with HD44780 lcd driver? 
 I want to say yes, but there is some of rules for this driver and also i hope so this legal way because of i have edited CCS C library's driver for LCD.C
 
 There are two versions of code below. First one is (LCD_CGRAM_TR.c) for all PIC, second one is (LCD_CGRAM_TR_RAM.c) for higher hardware source and RAM capacities for example 18F series PIC. But both of them do same work and i have tried a few times works nice. I could not find any bugs and problem.
 
 So if you want to use 6 pin (without R/W) just you write FALSE in related define RW line. But in this way you do not access more than 8 custom characters. you access TURKISH characters or some i created characters. I called them LCD_TURKISH and MORE_CUSTOM_CHARACTERS in the codes. You must define one of them with RW FALSE mode. We do not need R/W pin because we write just 8 characters to CGRAM in lcd_init(); function.
 
 On the other hand 7 pin (with R/W) just you write related PIN related define RW line. With this way you access more than 8 custom characters. so you must define LCD_TURKISH and MORE_CUSTOM_CHARACTERS before your codes. The program send custom characters to CGRAM before using and show on the lcd after load immediately. We use R/W pin because of we read last cursor's position from DDRAM's address. When we load the data of CGRAM,DDRAM's lost last address. We solve this problem before read DDRAM's address. You must be careful you do not show at same time same CGRAM data. I think that you understand when you work with this codes
   
 Best regards,
 
 
  	  | Code: |  	  | LCD_CGRAM_TR.C
 
 ///////////////////////////////////////////////////////////////////////////////
 ///////////////////LCD_CGRAM_TR.c CONFIGURATION////////////////////////////////
 //#define LCD_DATA_PORT getenv("SFR:PORTD")                                  //
 //#define LCD_DATA_PORT 0xf80 // port address                                 //
 //#define use_portb_lcd true                                                 //
 //#define LCD_EXTENDED_NEWLINE                                               //
 //#define LCD_TYPE 2           // 0=5x7, 1=5x10, 2=2 lines                   //
 //#define LCD_LINE_TWO 0x40    // LCD RAM address for the second line        //
 //#define LCD_LINE_LENGTH 20                                                 //
 //#define __PCB__                                                            //
 //#define __PCD__                                                            //
 //#define __PCH__                                                            //
 //#define __PCM__                                                            //
 //#define LCD_ENABLE_PIN PIN_D2                                              //
 //#define LCD_RS_PIN PIN_D0                                                  //
 //#define LCD_RW_PIN FALSE  //FALSE for 6 pin or PIN_NAME name for 7 pin     //
 //#define LCD_DATA0                                                          //
 //#define LCD_DATA1                                                          //
 //#define LCD_DATA2                                                          //
 //#define LCD_DATA3                                                          //
 //#define LCD_DATA4 PIN_C0                                                   //
 //#define LCD_DATA5 PIN_C1                                                   //
 //#define LCD_DATA6 PIN_C2                                                   //
 //#define LCD_DATA7 PIN_C3                                                   //
 //#define LCD_TURKISH                                                        //
 //#define MORE_CUSTOM_CHARACTERS                                             //
 ///////////////////////////////////////////////////////////////////////////////
 // Function Prototypes                                                       //
 ///////////////////////////////////////////////////////////////////////////////
 //BYTE lcd_read_nibble(void);                                                //
 //BYTE lcd_read_byte(void);                                                  //
 //void lcd_send_nibble(BYTE n);                                              //
 //void lcd_send_byte(BYTE address, BYTE n);                                  //
 //void lcd_set_CGRAM_character(BYTE character);                              //
 //void Character_Generator_RAM(BYTE character,int1 init);                    //
 //void lcd_init(void);                                                       //
 //void lcd_gotoxy(BYTE x, BYTE y);                                           //
 //void lcd_putc(char c);                                                     //
 //char lcd_getc(BYTE x, BYTE y);                                             //
 //BYTE lcd_get_address_counter(void)                                         //
 ///////////////////////////////////////////////////////////////////////////////
 
 // define the pinout.
 // only required if port access is being used.
 typedef struct
 {                            // This structure is overlayed
 BOOLEAN enable;           // on to an I/O port to gain
 BOOLEAN rs;               // access to the LCD pins.
 BOOLEAN rw;               // The bits are allocated from
 BOOLEAN unused;           // low order up.  ENABLE will
 int     data : 4;         // be LSB pin of that port.
 #if defined(__PCD__)       // The port used will be LCD_DATA_PORT.
 int    reserved: 8;
 #endif
 } LCD_PIN_MAP;
 
 // this is to improve compatibility with previous LCD drivers that accepted
 // a define labeled 'use_portb_lcd' that configured the LCD onto port B.
 #if ((defined(use_portb_lcd)) && (use_portb_lcd==TRUE))
 #define LCD_DATA_PORT getenv("SFR:PORTB")
 #endif
 
 #if defined(__PCB__)
 // these definitions only need to be modified for baseline PICs.
 // all other PICs use LCD_PIN_MAP or individual LCD_xxx pin definitions.
 /*                                    EN, RS,   RW,   UNUSED,  DATA  */
 const LCD_PIN_MAP LCD_OUTPUT_MAP =  {0,  0,    0,    0,       0};
 const LCD_PIN_MAP LCD_INPUT_MAP =   {0,  0,    0,    0,       0xF};
 #endif
 
 ////////////////////// END CONFIGURATION ///////////////////////////////////
 
 #ifndef LCD_ENABLE_PIN
 #define lcd_output_enable(x) lcdlat.enable=x
 #define lcd_enable_tris()   lcdtris.enable=0
 #else
 #define lcd_output_enable(x) output_bit(LCD_ENABLE_PIN, x)
 #define lcd_enable_tris()  output_drive(LCD_ENABLE_PIN)
 #endif
 
 #ifndef LCD_RS_PIN
 #define lcd_output_rs(x) lcdlat.rs=x
 #define lcd_rs_tris()   lcdtris.rs=0
 #else
 #define lcd_output_rs(x) output_bit(LCD_RS_PIN, x)
 #define lcd_rs_tris()  output_drive(LCD_RS_PIN)
 #endif
 
 #ifndef LCD_RW_PIN
 #define LCD_RW_PIN TRUE
 #define lcd_output_rw(x) lcdlat.rw=x
 #define lcd_rw_tris()   lcdtris.rw=0
 #elif ((defined(LCD_RW_PIN)) && (LCD_RW_PIN==FALSE))
 #else
 #define lcd_output_rw(x) output_bit(LCD_RW_PIN, x)
 #define lcd_rw_tris()  output_drive(LCD_RW_PIN)
 #endif
 
 // original version of this library incorrectly labeled LCD_DATA0 as LCD_DATA4,
 // LCD_DATA1 as LCD_DATA5, and so on.  this block of code makes the driver
 // compatible with any code written for the original library
 #if (defined(LCD_DATA0) && defined(LCD_DATA1) && defined(LCD_DATA2) && defined(LCD_DATA3) && !defined(LCD_DATA4) && !defined(LCD_DATA5) && !defined(LCD_DATA6) && !defined(LCD_DATA7))
 #define  LCD_DATA4    LCD_DATA0
 #define  LCD_DATA5    LCD_DATA1
 #define  LCD_DATA6    LCD_DATA2
 #define  LCD_DATA7    LCD_DATA3
 #endif
 
 #ifndef LCD_DATA4
 #ifndef LCD_DATA_PORT
 #if defined(__PCB__)
 #define LCD_DATA_PORT      0x06     //portb
 #define set_tris_lcd(x)   set_tris_b(x)
 #else
 #if defined(PIN_D0)
 #define LCD_DATA_PORT      getenv("SFR:PORTD")     //portd
 #else
 #define LCD_DATA_PORT      getenv("SFR:PORTB")     //portb
 #endif
 #endif
 #endif
 
 #if defined(__PCB__)
 LCD_PIN_MAP lcd, lcdlat;
 #byte lcd = LCD_DATA_PORT
 #byte lcdlat = LCD_DATA_PORT
 #elif defined(__PCM__)
 LCD_PIN_MAP lcd, lcdlat, lcdtris;
 #byte lcd = LCD_DATA_PORT
 #byte lcdlat = LCD_DATA_PORT
 #byte lcdtris = LCD_DATA_PORT+0x80
 #elif defined(__PCH__)
 LCD_PIN_MAP lcd, lcdlat, lcdtris;
 #byte lcd = LCD_DATA_PORT
 #byte lcdlat = LCD_DATA_PORT+9
 #byte lcdtris = LCD_DATA_PORT+0x12
 #elif defined(__PCD__)
 LCD_PIN_MAP lcd, lcdlat, lcdtris;
 #word lcd = LCD_DATA_PORT
 #word lcdlat = LCD_DATA_PORT+2
 #word lcdtris = LCD_DATA_PORT-0x02
 #endif
 #endif   //LCD_DATA4 not defined
 
 #ifndef LCD_TYPE
 #define LCD_TYPE 2           // 0=5x7, 1=5x10, 2=2 lines
 #endif
 
 #ifndef LCD_LINE_TWO
 #define LCD_LINE_TWO 0x40    // LCD RAM address for the second line
 #endif
 
 #ifndef LCD_LINE_LENGTH
 #define LCD_LINE_LENGTH 20
 #endif
 
 BYTE const LCD_INIT_STRING[4] = {0x20 | (LCD_TYPE << 2), 0xc, 1, 6};
 // These bytes need to be sent to the LCD
 // to start it up.
 
 #if ((defined(LCD_RW_PIN)) && (LCD_RW_PIN==FALSE))
 #else
 BYTE lcd_read_nibble(void);
 #endif
 
 #if ((defined(LCD_RW_PIN)) && (LCD_RW_PIN==FALSE))
 #else
 BYTE lcd_read_byte(void)
 {
 BYTE low,high;
 
 #if defined(__PCB__)
 set_tris_lcd(LCD_INPUT_MAP);
 #else
 #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
 output_float(LCD_DATA4);
 output_float(LCD_DATA5);
 output_float(LCD_DATA6);
 output_float(LCD_DATA7);
 #else
 lcdtris.data = 0xF;
 #endif
 #endif
 
 lcd_output_rw(1);
 delay_cycles(1);
 lcd_output_enable(1);
 delay_cycles(1);
 high = lcd_read_nibble();
 
 lcd_output_enable(0);
 delay_cycles(1);
 lcd_output_enable(1);
 delay_us(1);
 low = lcd_read_nibble();
 
 lcd_output_enable(0);
 
 #if defined(__PCB__)
 set_tris_lcd(LCD_OUTPUT_MAP);
 #else
 #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
 output_drive(LCD_DATA4);
 output_drive(LCD_DATA5);
 output_drive(LCD_DATA6);
 output_drive(LCD_DATA7);
 #else
 lcdtris.data = 0x0;
 #endif
 #endif
 
 return( (high<<4) | low);
 }
 #endif
 
 #if ((defined(LCD_RW_PIN)) && (LCD_RW_PIN==FALSE))
 #else
 BYTE lcd_read_nibble(void)
 {
 #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
 BYTE n = 0x00;
 
 /* Read the data port */
 n |= input(LCD_DATA4);
 n |= input(LCD_DATA5) << 1;
 n |= input(LCD_DATA6) << 2;
 n |= input(LCD_DATA7) << 3;
 
 return(n);
 #else
 return(lcd.data);
 #endif
 }
 #endif
 
 void lcd_send_nibble(BYTE n)
 {
 #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
 /* Write to the data port */
 output_bit(LCD_DATA4, bit_test(n, 0));
 output_bit(LCD_DATA5, bit_test(n, 1));
 output_bit(LCD_DATA6, bit_test(n, 2));
 output_bit(LCD_DATA7, bit_test(n, 3));
 #else
 lcdlat.data = n;
 #endif
 
 delay_cycles(1);
 lcd_output_enable(1);
 delay_us(2);
 lcd_output_enable(0);
 }
 
 void lcd_send_byte(BYTE address, BYTE n)
 {
 #if defined(__PCB__)
 set_tris_lcd(LCD_OUTPUT_MAP);
 #else
 lcd_enable_tris();
 lcd_rs_tris();
 #if ((defined(LCD_RW_PIN)) && (LCD_RW_PIN==FALSE))
 #else
 lcd_rw_tris();
 #endif
 #endif
 
 lcd_output_rs(0);
 #if ((defined(LCD_RW_PIN)) && (LCD_RW_PIN==FALSE))
 delay_ms(1);
 #else
 while ( bit_test(lcd_read_byte(),7) ) ;
 #endif
 lcd_output_rs(address);
 delay_cycles(1);
 #if ((defined(LCD_RW_PIN)) && (LCD_RW_PIN==FALSE))
 #else
 lcd_output_rw(0);
 #endif
 delay_cycles(1);
 lcd_output_enable(0);
 lcd_send_nibble(n >> 4);
 lcd_send_nibble(n & 0xf);
 }
 
 #if defined(LCD_EXTENDED_NEWLINE)
 unsigned int8 g_LcdX, g_LcdY;
 #endif
 
 #if ((defined(LCD_RW_PIN)) && (LCD_RW_PIN==FALSE))
 #else
 BYTE lcd_get_address_counter(void);
 #endif
 
 #if (defined(LCD_TURKISH) || defined(MORE_CUSTOM_CHARACTERS))
 void lcd_set_CGRAM_character(BYTE character)
 {
 switch(character)
 {
 case  0:   lcd_send_byte(0,0x40);
 // Ç    F8421
 lcd_send_byte(1,14); // 1     |||
 lcd_send_byte(1,17); // 2    |   |
 lcd_send_byte(1,16); // 3    |
 lcd_send_byte(1,16); // 4    |
 lcd_send_byte(1,21); // 5    | | |
 lcd_send_byte(1,14); // 6     |||
 lcd_send_byte(1,4);  // 7      |
 lcd_send_byte(1,0);  // 8
 break;
 case  1:  lcd_send_byte(0,0x48);
 // Ğ    F8421
 lcd_send_byte(1,14); // 1     |||
 lcd_send_byte(1,0);  // 2
 lcd_send_byte(1,15); // 3     ||||
 lcd_send_byte(1,16); // 4    |
 lcd_send_byte(1,23); // 5    | |||
 lcd_send_byte(1,17); // 6    |   |
 lcd_send_byte(1,14); // 7     |||
 lcd_send_byte(1,0);  // 8
 break;
 case  2:  lcd_send_byte(0,0x50);
 // İ    F8421
 lcd_send_byte(1,4);  // 1      |
 lcd_send_byte(1,0);  // 2
 lcd_send_byte(1,4);  // 3      |
 lcd_send_byte(1,4);  // 4      |
 lcd_send_byte(1,4);  // 5      |
 lcd_send_byte(1,4);  // 6      |
 lcd_send_byte(1,4);  // 7      |
 lcd_send_byte(1,0);  // 8
 break;
 case  3:  lcd_send_byte(0,0x58);
 // Ö    F8421
 lcd_send_byte(1,10); // 1     | |
 lcd_send_byte(1,0);  // 2
 lcd_send_byte(1,14); // 3     |||
 lcd_send_byte(1,17); // 4    |   |
 lcd_send_byte(1,17); // 5    |   |
 lcd_send_byte(1,17); // 6    |   |
 lcd_send_byte(1,14); // 7     |||
 lcd_send_byte(1,0);  // 8
 break;
 case  4:  lcd_send_byte(0,0x60);
 // Ş    F8421
 lcd_send_byte(1,15); // 1     ||||
 lcd_send_byte(1,16); // 2    |
 lcd_send_byte(1,14); // 3     |||
 lcd_send_byte(1,1);  // 4        |
 lcd_send_byte(1,21); // 5    | | |
 lcd_send_byte(1,14); // 6     |||
 lcd_send_byte(1,4);  // 7      |
 lcd_send_byte(1,0);  // 8
 break;
 case  5:  lcd_send_byte(0,0x68);
 // Ü    F8421
 lcd_send_byte(1,10); // 1    |   |
 lcd_send_byte(1,0);  // 2
 lcd_send_byte(1,17); // 3    |   |
 lcd_send_byte(1,17); // 4    |   |
 lcd_send_byte(1,17); // 5    |   |
 lcd_send_byte(1,17); // 6    |   |
 lcd_send_byte(1,14); // 7     |||
 lcd_send_byte(1,0);  // 8
 break;
 case  6: lcd_send_byte(0,0x70);
 // \p   F8421
 lcd_send_byte(1,31); // 1    |||||
 lcd_send_byte(1,17); // 2    |   |
 lcd_send_byte(1,23); // 3    | |||
 lcd_send_byte(1,20); // 4    | |
 lcd_send_byte(1,23); // 5    | |||
 lcd_send_byte(1,17); // 6    |   |
 lcd_send_byte(1,31); // 7    |||||
 lcd_send_byte(1,0);  // 8
 break;
 case  7:  lcd_send_byte(0,0x78);
 // \q   F8421
 lcd_send_byte(1,31); // 1    |||||
 lcd_send_byte(1,17); // 2    |   |
 lcd_send_byte(1,29); // 3    ||| |
 lcd_send_byte(1,5);  // 4      | |
 lcd_send_byte(1,29); // 5    ||| |
 lcd_send_byte(1,17); // 6    |   |
 lcd_send_byte(1,31); // 7    |||||
 lcd_send_byte(1,0);  // 8
 break;
 #if defined(MORE_CUSTOM_CHARACTERS)
 case  8:  lcd_send_byte(0,0x40);
 // \1   F8421
 lcd_send_byte(1,14); // 1     |||
 lcd_send_byte(1,27); // 2    || ||
 lcd_send_byte(1,30); // 3    ||||
 lcd_send_byte(1,28); // 4    |||
 lcd_send_byte(1,30); // 5    ||||
 lcd_send_byte(1,31); // 6    |||||
 lcd_send_byte(1,14); // 7     |||
 lcd_send_byte(1,0);  // 8
 break;
 case   9:  lcd_send_byte(0,0x48);
 // \2   F8421
 lcd_send_byte(1,14); // 1     |||
 lcd_send_byte(1,27); // 2    || ||
 lcd_send_byte(1,31); // 3    |||||
 lcd_send_byte(1,28); // 4    |||
 lcd_send_byte(1,31); // 5    |||||
 lcd_send_byte(1,31); // 6    |||||
 lcd_send_byte(1,14); // 7     |||
 lcd_send_byte(1,0);  // 8
 break;
 case  10:  lcd_send_byte(0,0x50);
 // \3   F8421
 lcd_send_byte(1,14); // 1     |||
 lcd_send_byte(1,27); // 2    || ||
 lcd_send_byte(1,31); // 3    |||||
 lcd_send_byte(1,7);  // 4      |||
 lcd_send_byte(1,31); // 5    |||||
 lcd_send_byte(1,31); // 6    |||||
 lcd_send_byte(1,14); // 7     |||
 lcd_send_byte(1,0);  // 8
 break;
 case  11:  lcd_send_byte(0,0x58);
 // \4   F8421
 lcd_send_byte(1,14); // 1     |||
 lcd_send_byte(1,27); // 2    || ||
 lcd_send_byte(1,15); // 3     ||||
 lcd_send_byte(1,7);  // 4      |||
 lcd_send_byte(1,15); // 5     ||||
 lcd_send_byte(1,31); // 6    |||||
 lcd_send_byte(1,14); // 7     |||
 lcd_send_byte(1,0);  // 8
 
 break;
 case  12:  lcd_send_byte(0,0x60);
 // \5   F8421
 lcd_send_byte(1,10); // 1     | |
 lcd_send_byte(1,10); // 2     | |
 lcd_send_byte(1,14); // 3     |||
 lcd_send_byte(1,17); // 4    |   |
 lcd_send_byte(1,17); // 5    |   |
 lcd_send_byte(1,17); // 6    |   |
 lcd_send_byte(1,31); // 7    |||||
 lcd_send_byte(1,0);  // 8
 break;
 case  13:  lcd_send_byte(0,0x68);
 // \6   F8421
 lcd_send_byte(1,31); // 1    |||||
 lcd_send_byte(1,17); // 2    |   |
 lcd_send_byte(1,17); // 3    |   |
 lcd_send_byte(1,17); // 4    |   |
 lcd_send_byte(1,14); // 5     |||
 lcd_send_byte(1,10); // 6     | |
 lcd_send_byte(1,10); // 7     | |
 lcd_send_byte(1,0);  // 8
 break;
 case  14:  lcd_send_byte(0,0x70);
 // \s   F8421
 lcd_send_byte(1,31); // 1    |||||
 lcd_send_byte(1,17); // 2    |   |
 lcd_send_byte(1,23); // 3    | |||
 lcd_send_byte(1,20); // 4    | |
 lcd_send_byte(1,23); // 5    | |||
 lcd_send_byte(1,17); // 6    |   |
 lcd_send_byte(1,31); // 7    |||||
 lcd_send_byte(1,0);  // 8
 break;
 case  15:  lcd_send_byte(0,0x78);
 // \t   F8421
 lcd_send_byte(1,31); // 1    |||||
 lcd_send_byte(1,17); // 2    |   |
 lcd_send_byte(1,29); // 3    ||| |
 lcd_send_byte(1,5);  // 4      | |
 lcd_send_byte(1,29); // 5    ||| |
 lcd_send_byte(1,17); // 6    |   |
 lcd_send_byte(1,31); // 7    |||||
 lcd_send_byte(1,0);  // 8
 break;
 #endif
 }
 }
 
 void Character_Generator_RAM(BYTE character,int1 init)
 {
 #if (defined(LCD_RW_PIN) && (LCD_RW_PIN==FALSE))
 if(init)
 {
 lcd_set_CGRAM_character(character);
 }
 else lcd_send_byte(1,character%8);
 #else
 BYTE address;
 address=lcd_get_address_counter();
 lcd_set_CGRAM_character(character);
 lcd_send_byte(0,0X80|address);
 lcd_send_byte(1,character%8);
 #endif
 }
 #endif
 
 void lcd_init(void)
 {
 BYTE i;
 
 #if defined(__PCB__)
 set_tris_lcd(LCD_OUTPUT_MAP);
 #else
 #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
 output_drive(LCD_DATA4);
 output_drive(LCD_DATA5);
 output_drive(LCD_DATA6);
 output_drive(LCD_DATA7);
 #else
 lcdtris.data = 0x0;
 #endif
 lcd_enable_tris();
 lcd_rs_tris();
 #if ((defined(LCD_RW_PIN)) && (LCD_RW_PIN==FALSE))
 #else
 lcd_rw_tris();
 #endif
 #endif
 lcd_output_rs(0);
 #if ((defined(LCD_RW_PIN)) && (LCD_RW_PIN==FALSE))
 #else
 lcd_output_rw(0);
 #endif
 lcd_output_enable(0);
 
 //delay_ms(15);               //////////////////////////////
 for(i=1;i<=3;++i)
 {
 lcd_send_nibble(3);
 delay_ms(5);
 }
 lcd_send_nibble(2);
 //delay_ms(5);               //////////////////////////////
 for(i=0;i<=3;++i)
 lcd_send_byte(0,LCD_INIT_STRING[i]);
 
 #if defined(LCD_EXTENDED_NEWLINE)
 g_LcdX = 0;
 g_LcdY = 0;
 #endif
 
 #if (defined(LCD_TURKISH) && ((defined(LCD_RW_PIN)) && (LCD_RW_PIN==FALSE)))
 for(i=0;i<=7;i++)
 Character_Generator_RAM(i,true);
 lcd_send_byte(0,0x01);
 #elif (defined(MORE_CUSTOM_CHARACTERS)&& ((defined(LCD_RW_PIN)) && (LCD_RW_PIN==FALSE)))
 for(i=8;i<=15;i++)
 Character_Generator_RAM(i,true);
 lcd_send_byte(0,0x01);
 #endif
 }
 
 void lcd_gotoxy(BYTE x, BYTE y)
 {
 BYTE address;
 
 switch(y) {
 case 1 : address=0x80;break;
 case 2 : address=0xc0;break;
 case 3 : address=0x94;break;
 case 4 : address=0xd4;break;
 }
 
 address+=x-1;
 lcd_send_byte(0,0x80|address);
 
 #if defined(LCD_EXTENDED_NEWLINE)
 g_LcdX = x - 1;
 g_LcdY = y - 1;
 #endif
 }
 
 void lcd_putc(char c)
 {
 switch (c)
 {
 case '\a'   :  lcd_gotoxy(1,1);     break;
 
 case '\f'   :  lcd_send_byte(0,1);
 delay_ms(2);
 #if defined(LCD_EXTENDED_NEWLINE)
 g_LcdX = 0;
 g_LcdY = 0;
 #endif
 break;
 
 #if defined(LCD_TURKISH)
 case 'Ç'    :   Character_Generator_RAM(0,false);
 break;
 case 'Ğ'    :   Character_Generator_RAM(1,false);
 break;
 case 'İ'    :   Character_Generator_RAM(2,false);
 break;
 case 'Ö'    :   Character_Generator_RAM(3,false);
 break;
 case 'Ş'    :   Character_Generator_RAM(4,false);
 break;
 case 'Ü'    :   Character_Generator_RAM(5,false);
 break;
 case '\p'   :   Character_Generator_RAM(6,false);
 break;
 case '\q'   :   Character_Generator_RAM(7,false);
 break;
 #endif
 #if defined(MORE_CUSTOM_CHARACTERS))
 case '\1'   :   Character_Generator_RAM(8,false);
 break;
 case '\2'   :   Character_Generator_RAM(9,false);
 break;
 case '\3'   :   Character_Generator_RAM(10,false);
 break;
 case '\4'   :   Character_Generator_RAM(11,false);
 break;
 case '\5'   :   Character_Generator_RAM(12,false);
 break;
 case '\6'   :   Character_Generator_RAM(13,false);
 break;
 case '\s'   :   Character_Generator_RAM(14,false);
 break;
 case '\t'   :   Character_Generator_RAM(15,false);
 break;
 #endif
 #if defined(LCD_EXTENDED_NEWLINE)
 case '\r'   :  lcd_gotoxy(1, g_LcdY+1);   break;
 case '\n'   :
 while (g_LcdX++ < LCD_LINE_LENGTH)
 {
 lcd_send_byte(1, ' ');
 }
 lcd_gotoxy(1, g_LcdY+2);
 break;
 #else
 case '\n'   : lcd_gotoxy(1,2);        break;
 #endif
 
 case '\b'   : lcd_send_byte(0,0x10);  break;
 
 #if defined(LCD_EXTENDED_NEWLINE)
 default     :
 if (g_LcdX < LCD_LINE_LENGTH)
 {
 lcd_send_byte(1, c);
 g_LcdX++;
 }
 break;
 #else
 default     : lcd_send_byte(1,c);     break;
 #endif
 }
 }
 
 #if (defined(LCD_RW_PIN) && (LCD_RW_PIN==FALSE))
 #else
 char lcd_getc(BYTE x, BYTE y)
 {
 char value;
 
 lcd_gotoxy(x,y);
 while ( bit_test(lcd_read_byte(),7) ); // wait until busy flag is low
 lcd_output_rs(1);
 value = lcd_read_byte();
 lcd_output_rs(0);
 
 return(value);
 }
 
 BYTE lcd_get_address_counter(void)
 {
 BYTE address;
 
 lcd_output_rs(0);
 address = lcd_read_byte();
 lcd_output_rs(1);
 
 return(address);
 }
 #endif
 
 
 | 
 
 
  	  | Code: |  	  | 
 LCD_CGRAM_TR_RAM.C
 
 ///////////////////////////////////////////////////////////////////////////////
 ///////////////////LCD_CGRAM_TR_RAM.c CONFIGURATION////////////////////////////
 //#define LCD_DATA_PORT getenv("SFR:PORTD")                                  //
 //#define LCD_DATA_PORT 0xf80 // port adress                                 //
 //#define use_portb_lcd true                                                 //
 //#define LCD_EXTENDED_NEWLINE                                               //
 //#define LCD_TYPE 2           // 0=5x7, 1=5x10, 2=2 lines                   //
 //#define LCD_LINE_TWO 0x40    // LCD RAM address for the second line        //
 //#define LCD_LINE_LENGTH 20                                                 //
 //#define __PCB__                                                            //
 //#define __PCD__                                                            //
 //#define __PCH__                                                            //
 //#define __PCM__                                                            //
 //#define LCD_ENABLE_PIN PIN_D2                                              //
 //#define LCD_RS_PIN PIN_D0                                                  //
 //#define LCD_RW_PIN FALSE  //FALSE for 6 pin or PIN_NAME name for 7 pin     //
 //#define LCD_DATA0                                                          //
 //#define LCD_DATA1                                                          //
 //#define LCD_DATA2                                                          //
 //#define LCD_DATA3                                                          //
 //#define LCD_DATA4 PIN_C0                                                   //
 //#define LCD_DATA5 PIN_C1                                                   //
 //#define LCD_DATA6 PIN_C2                                                   //
 //#define LCD_DATA7 PIN_C3                                                   //
 //#define LCD_TURKISH                                                        //
 //#define MORE_CUSTOM_CHARACTERS                                             //
 ///////////////////////////////////////////////////////////////////////////////
 // Function Prototypes                                                       //
 ///////////////////////////////////////////////////////////////////////////////
 //BYTE lcd_read_nibble(void);                                                //
 //BYTE lcd_read_byte(void);                                                  //
 //void lcd_send_nibble(BYTE n);                                              //
 //void lcd_send_byte(BYTE address, BYTE n);                                  //
 //void lcd_set_CGRAM_adress(BYTE character);                                 //
 //void Character_Generator_RAM(BYTE character,int1 init);                    //
 //void lcd_init(void);                                                       //
 //void lcd_gotoxy(BYTE x, BYTE y);                                           //
 //void lcd_putc(char c);                                                     //
 //char lcd_getc(BYTE x, BYTE y);                                             //
 //BYTE lcd_get_address_counter(void);                                        //
 ///////////////////////////////////////////////////////////////////////////////
 
 // define the pinout.
 // only required if port access is being used.
 typedef struct
 {                            // This structure is overlayed
 BOOLEAN enable;           // on to an I/O port to gain
 BOOLEAN rs;               // access to the LCD pins.
 BOOLEAN rw;               // The bits are allocated from
 BOOLEAN unused;           // low order up.  ENABLE will
 int     data : 4;         // be LSB pin of that port.
 #if defined(__PCD__)       // The port used will be LCD_DATA_PORT.
 int    reserved: 8;
 #endif
 } LCD_PIN_MAP;
 
 // this is to improve compatability with previous LCD drivers that accepted
 // a define labeled 'use_portb_lcd' that configured the LCD onto port B.
 #if ((defined(use_portb_lcd)) && (use_portb_lcd==TRUE))
 #define LCD_DATA_PORT getenv("SFR:PORTB")
 #endif
 
 #if defined(__PCB__)
 // these definitions only need to be modified for baseline PICs.
 // all other PICs use LCD_PIN_MAP or individual LCD_xxx pin definitions.
 /*                                    EN, RS,   RW,   UNUSED,  DATA  */
 const LCD_PIN_MAP LCD_OUTPUT_MAP =  {0,  0,    0,    0,       0};
 const LCD_PIN_MAP LCD_INPUT_MAP =   {0,  0,    0,    0,       0xF};
 #endif
 
 ////////////////////// END CONFIGURATION ///////////////////////////////////
 
 #ifndef LCD_ENABLE_PIN
 #define lcd_output_enable(x) lcdlat.enable=x
 #define lcd_enable_tris()   lcdtris.enable=0
 #else
 #define lcd_output_enable(x) output_bit(LCD_ENABLE_PIN, x)
 #define lcd_enable_tris()  output_drive(LCD_ENABLE_PIN)
 #endif
 
 #ifndef LCD_RS_PIN
 #define lcd_output_rs(x) lcdlat.rs=x
 #define lcd_rs_tris()   lcdtris.rs=0
 #else
 #define lcd_output_rs(x) output_bit(LCD_RS_PIN, x)
 #define lcd_rs_tris()  output_drive(LCD_RS_PIN)
 #endif
 
 #ifndef LCD_RW_PIN
 #define LCD_RW_PIN TRUE
 #define lcd_output_rw(x) lcdlat.rw=x
 #define lcd_rw_tris()   lcdtris.rw=0
 #elif ((defined(LCD_RW_PIN)) && (LCD_RW_PIN==FALSE))
 #else
 #define lcd_output_rw(x) output_bit(LCD_RW_PIN, x)
 #define lcd_rw_tris()  output_drive(LCD_RW_PIN)
 #endif
 
 // original version of this library incorrectly labeled LCD_DATA0 as LCD_DATA4,
 // LCD_DATA1 as LCD_DATA5, and so on.  this block of code makes the driver
 // compatible with any code written for the original library
 #if (defined(LCD_DATA0) && defined(LCD_DATA1) && defined(LCD_DATA2) && defined(LCD_DATA3) && !defined(LCD_DATA4) && !defined(LCD_DATA5) && !defined(LCD_DATA6) && !defined(LCD_DATA7))
 #define  LCD_DATA4    LCD_DATA0
 #define  LCD_DATA5    LCD_DATA1
 #define  LCD_DATA6    LCD_DATA2
 #define  LCD_DATA7    LCD_DATA3
 #endif
 
 #ifndef LCD_DATA4
 #ifndef LCD_DATA_PORT
 #if defined(__PCB__)
 #define LCD_DATA_PORT      0x06     //portb
 #define set_tris_lcd(x)   set_tris_b(x)
 #else
 #if defined(PIN_D0)
 #define LCD_DATA_PORT      getenv("SFR:PORTD")     //portd
 #else
 #define LCD_DATA_PORT      getenv("SFR:PORTB")     //portb
 #endif
 #endif
 #endif
 
 #if defined(__PCB__)
 LCD_PIN_MAP lcd, lcdlat;
 #byte lcd = LCD_DATA_PORT
 #byte lcdlat = LCD_DATA_PORT
 #elif defined(__PCM__)
 LCD_PIN_MAP lcd, lcdlat, lcdtris;
 #byte lcd = LCD_DATA_PORT
 #byte lcdlat = LCD_DATA_PORT
 #byte lcdtris = LCD_DATA_PORT+0x80
 #elif defined(__PCH__)
 LCD_PIN_MAP lcd, lcdlat, lcdtris;
 #byte lcd = LCD_DATA_PORT
 #byte lcdlat = LCD_DATA_PORT+9
 #byte lcdtris = LCD_DATA_PORT+0x12
 #elif defined(__PCD__)
 LCD_PIN_MAP lcd, lcdlat, lcdtris;
 #word lcd = LCD_DATA_PORT
 #word lcdlat = LCD_DATA_PORT+2
 #word lcdtris = LCD_DATA_PORT-0x02
 #endif
 #endif   //LCD_DATA4 not defined
 
 #ifndef LCD_TYPE
 #define LCD_TYPE 2           // 0=5x7, 1=5x10, 2=2 lines
 #endif
 
 #ifndef LCD_LINE_TWO
 #define LCD_LINE_TWO 0x40    // LCD RAM address for the second line
 #endif
 
 #ifndef LCD_LINE_LENGTH
 #define LCD_LINE_LENGTH 20
 #endif
 
 BYTE const LCD_INIT_STRING[4] = {0x20 | (LCD_TYPE << 2), 0xc, 1, 6};
 // These bytes need to be sent to the LCD
 // to start it up.
 
 #if ((defined(LCD_RW_PIN)) && (LCD_RW_PIN==FALSE))
 #else
 BYTE lcd_read_nibble(void);
 #endif
 
 #if ((defined(LCD_RW_PIN)) && (LCD_RW_PIN==FALSE))
 #else
 BYTE lcd_read_byte(void)
 {
 BYTE low,high;
 
 #if defined(__PCB__)
 set_tris_lcd(LCD_INPUT_MAP);
 #else
 #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
 output_float(LCD_DATA4);
 output_float(LCD_DATA5);
 output_float(LCD_DATA6);
 output_float(LCD_DATA7);
 #else
 lcdtris.data = 0xF;
 #endif
 #endif
 
 lcd_output_rw(1);
 delay_cycles(1);
 lcd_output_enable(1);
 delay_cycles(1);
 high = lcd_read_nibble();
 
 lcd_output_enable(0);
 delay_cycles(1);
 lcd_output_enable(1);
 delay_us(1);
 low = lcd_read_nibble();
 
 lcd_output_enable(0);
 
 #if defined(__PCB__)
 set_tris_lcd(LCD_OUTPUT_MAP);
 #else
 #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
 output_drive(LCD_DATA4);
 output_drive(LCD_DATA5);
 output_drive(LCD_DATA6);
 output_drive(LCD_DATA7);
 #else
 lcdtris.data = 0x0;
 #endif
 #endif
 
 return( (high<<4) | low);
 }
 #endif
 
 #if ((defined(LCD_RW_PIN)) && (LCD_RW_PIN==FALSE))
 #else
 BYTE lcd_read_nibble(void)
 {
 #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
 BYTE n = 0x00;
 
 /* Read the data port */
 n |= input(LCD_DATA4);
 n |= input(LCD_DATA5) << 1;
 n |= input(LCD_DATA6) << 2;
 n |= input(LCD_DATA7) << 3;
 
 return(n);
 #else
 return(lcd.data);
 #endif
 }
 #endif
 
 void lcd_send_nibble(BYTE n)
 {
 #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
 /* Write to the data port */
 output_bit(LCD_DATA4, bit_test(n, 0));
 output_bit(LCD_DATA5, bit_test(n, 1));
 output_bit(LCD_DATA6, bit_test(n, 2));
 output_bit(LCD_DATA7, bit_test(n, 3));
 #else
 lcdlat.data = n;
 #endif
 
 delay_cycles(1);
 lcd_output_enable(1);
 delay_us(2);
 lcd_output_enable(0);
 }
 
 void lcd_send_byte(BYTE address, BYTE n)
 {
 #if defined(__PCB__)
 set_tris_lcd(LCD_OUTPUT_MAP);
 #else
 lcd_enable_tris();
 lcd_rs_tris();
 #if ((defined(LCD_RW_PIN)) && (LCD_RW_PIN==FALSE))
 #else
 lcd_rw_tris();
 #endif
 #endif
 
 lcd_output_rs(0);
 #if ((defined(LCD_RW_PIN)) && (LCD_RW_PIN==FALSE))
 delay_ms(1);
 #else
 while ( bit_test(lcd_read_byte(),7) ) ;
 #endif
 lcd_output_rs(address);
 delay_cycles(1);
 #if ((defined(LCD_RW_PIN)) && (LCD_RW_PIN==FALSE))
 #else
 lcd_output_rw(0);
 #endif
 delay_cycles(1);
 lcd_output_enable(0);
 lcd_send_nibble(n >> 4);
 lcd_send_nibble(n & 0xf);
 }
 
 #if defined(LCD_EXTENDED_NEWLINE)
 unsigned int8 g_LcdX, g_LcdY;
 #endif
 
 #if ((defined(LCD_RW_PIN)) && (LCD_RW_PIN==FALSE))
 #else
 BYTE lcd_get_address_counter(void);
 #endif
 
 #if (defined(LCD_TURKISH) || defined(MORE_CUSTOM_CHARACTERS))
 void lcd_set_CGRAM_adress(BYTE character)
 {
 switch(character%8)
 {
 case 0: lcd_send_byte(0,0x40);
 break;
 case 1: lcd_send_byte(0,0x48);
 break;
 case 2: lcd_send_byte(0,0x50);
 break;
 case 3: lcd_send_byte(0,0x58);
 break;
 case 4: lcd_send_byte(0,0x60);
 break;
 case 5: lcd_send_byte(0,0x68);
 break;
 case 6: lcd_send_byte(0,0x70);
 break;
 case 7: lcd_send_byte(0,0x78);
 break;
 }
 }
 
 void Character_Generator_RAM(BYTE character,int1 init)
 {
 BYTE q;
 BYTE CGRAM_EXTENDED[16][8]={ 14,17,16,16,21,14, 4, 0,  // Ç
 14, 0,15,16,23,17,14, 0,  // Ğ
 4, 0, 4, 4, 4, 4, 4, 0,  // İ
 10, 0,14,17,17,17,14, 0,  // Ö
 15,16,14, 1,21,14, 4, 0,  // Ş
 10, 0,17,17,17,17,14, 0,  // Ü
 31,17,23,20,23,17,31, 0,  // \p
 31,17,29, 5,29,17,31, 0,  // \q
 14,27,30,28,30,31,14, 0,  // \1
 14,27,31,28,31,31,14, 0,  // \2
 14,27,31, 7,31,31,14, 0,  // \3
 14,27,15, 7,15,31,14, 0,  // \4
 10,10,14,17,17,17,31, 0,  // \5
 31,17,17,17,14,10,10, 0,  // \6
 31,17,23,20,23,17,31, 0,  // \s
 31,17,29, 5,29,17,31, 0,  // \t
 };
 /*
 //////////////////////////////////////////////////////////////////////////
 ///////CGRAM0////////////CGRAM1////////////CGRAM2////////////CGRAM3///////
 //////////////////////////////////////////////////////////////////////////
 //  Ç  F8421      //  Ğ  F8421      //  İ  F8421      //  Ö  F8421      //
 //  1   |||   14  //  1   |||   14  //  1    |     4  //  1   | |   10  //
 //  2  |   |  17  //  2          0  //  2          0  //  2          0  //
 //  3  |      16  //  3   ||||  15  //  3    |     4  //  3   |||   14  //
 //  4  |      16  //  4  |      16  //  4    |     4  //  4  |   |  17  //
 //  5  | | |  21  //  5  | |||  23  //  5    |     4  //  5  |   |  17  //
 //  6   |||   14  //  6  |   |  17  //  6    |     4  //  6  |   |  17  //
 //  7    |     4  //  7   |||   14  //  7    |     4  //  7   |||   14  //
 //  8          0  //  8          0  //  8          0  //  8          0  //
 //////////////////////////////////////////////////////////////////////////
 ///////CGRAM4////////////CGRAM5////////////CGRAM6////////////CGRAM7///////
 //////////////////////////////////////////////////////////////////////////
 //  Ş  F8421      //  Ü  F8421      // \p  F8421      // \q  F8421      //
 //  1   ||||  15  //  1   | |   10  //  1  |||||  31  //  1  |||||  31  //
 //  2  |      16  //  2          0  //  2  |   |  17  //  2  |   |  17  //
 //  3   |||   14  //  3  |   |  17  //  3  | |||  23  //  3  ||| |  29  //
 //  4      |   1  //  4  |   |  17  //  4  | |    20  //  4    | |   5  //
 //  5  | | |  21  //  5  |   |  17  //  5  | |||  23  //  5  ||| |  29  //
 //  6   |||   14  //  6  |   |  17  //  6  |   |  17  //  6  |   |  17  //
 //  7    |     4  //  7   |||   14  //  7  |||||  31  //  7  |||||  31  //
 //  8          0  //  8          0  //  8          0  //  8          0  //
 //////////////////////////////////////////////////////////////////////////
 ///////CGRAM0////////////CGRAM1////////////CGRAM2////////////CGRAM3///////
 //////////////////////////////////////////////////////////////////////////
 // \1  F8421      // \2  F8421      // \3  F8421      // \4  F8421      //
 //  1   |||   14  //  1   |||   14  //  1   |||   14  //  1   |||   14  //
 //  2  || ||  27  //  2  || ||  27  //  2  || ||  27  //  2  || ||  27  //
 //  3  ||||   30  //  3  |||||  31  //  3  |||||  31  //  3   ||||  15  //
 //  4  |||    28  //  4  |||    28  //  4    |||   7  //  4    |||   7  //
 //  5  ||||   30  //  5  |||||  31  //  5  |||||  31  //  5   ||||  15  //
 //  6  |||||  31  //  6  |||||  31  //  6  |||||  31  //  6  |||||  31  //
 //  7   |||   14  //  7   |||   14  //  7   |||   14  //  7   |||   14  //
 //  8          0  //  8          0  //  8          0  //  8          0  //
 //////////////////////////////////////////////////////////////////////////
 ///////CGRAM4////////////CGRAM5////////////CGRAM6////////////CGRAM7///////
 //////////////////////////////////////////////////////////////////////////
 // \5  F8421      // \6  F8421      // \p  F8421      // \q  F8421      //
 //  1   | |   10  //  1  |||||  31  //  1  |||||  31  //  1  |||||  31  //
 //  2   | |   10  //  2  |   |  17  //  2  |   |  17  //  2  |   |  17  //
 //  3   |||   14  //  3  |   |  17  //  3  | |||  23  //  3  ||| |  29  //
 //  4  |   |  17  //  4  |   |  17  //  4  | |    20  //  4    | |   5  //
 //  5  |   |  17  //  5   |||   14  //  5  | |||  23  //  5  ||| |  29  //
 //  6  |   |  17  //  6   | |   10  //  6  |   |  17  //  6  |   |  17  //
 //  7  |||||  31  //  7   | |   10  //  7  |||||  31  //  7  |||||  31  //
 //  8          0  //  8          0  //  8          0  //  8          0  //
 //////////////////////////////////////////////////////////////////////////
 */
 
 #if (defined(LCD_RW_PIN) && (LCD_RW_PIN==FALSE))
 if(init)
 {
 lcd_set_CGRAM_adress(character);
 for(q=0;q<=7;q++)
 lcd_send_byte(1,CGRAM_EXTENDED[character][q]);
 }
 else lcd_send_byte(1,character%8);
 #else
 BYTE address;
 address=lcd_get_address_counter();
 lcd_set_CGRAM_adress(character);
 for(q=0;q<=7;q++)
 lcd_send_byte(1,CGRAM_EXTENDED[character][q]);
 lcd_send_byte(0,0X80|address);
 lcd_send_byte(1,character%8);
 #endif
 
 }
 #endif
 
 void lcd_init(void)
 {
 BYTE i;
 
 #if defined(__PCB__)
 set_tris_lcd(LCD_OUTPUT_MAP);
 #else
 #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
 output_drive(LCD_DATA4);
 output_drive(LCD_DATA5);
 output_drive(LCD_DATA6);
 output_drive(LCD_DATA7);
 #else
 lcdtris.data = 0x0;
 #endif
 lcd_enable_tris();
 lcd_rs_tris();
 #if ((defined(LCD_RW_PIN)) && (LCD_RW_PIN==FALSE))
 #else
 lcd_rw_tris();
 #endif
 #endif
 lcd_output_rs(0);
 #if ((defined(LCD_RW_PIN)) && (LCD_RW_PIN==FALSE))
 #else
 lcd_output_rw(0);
 #endif
 lcd_output_enable(0);
 
 //delay_ms(15);               //////////////////////////////
 for(i=1;i<=3;++i)
 {
 lcd_send_nibble(3);
 delay_ms(5);
 }
 lcd_send_nibble(2);
 //delay_ms(5);               //////////////////////////////
 for(i=0;i<=3;++i)
 lcd_send_byte(0,LCD_INIT_STRING[i]);
 
 #if defined(LCD_EXTENDED_NEWLINE)
 g_LcdX = 0;
 g_LcdY = 0;
 #endif
 
 #if (defined(LCD_TURKISH) && ((defined(LCD_RW_PIN)) && (LCD_RW_PIN==FALSE)))
 for(i=0;i<=7;i++)
 Character_Generator_RAM(i,true);
 lcd_send_byte(0,0x01);
 #elif (defined(MORE_CUSTOM_CHARACTERS)&& ((defined(LCD_RW_PIN)) && (LCD_RW_PIN==FALSE)))
 for(i=8;i<=15;i++)
 Character_Generator_RAM(i,true);
 lcd_send_byte(0,0x01);
 #endif
 }
 
 void lcd_gotoxy(BYTE x, BYTE y)
 {
 BYTE address;
 
 switch(y) {
 case 1 : address=0x80;break;
 case 2 : address=0xc0;break;
 case 3 : address=0x94;break;
 case 4 : address=0xd4;break;
 }
 
 address+=x-1;
 lcd_send_byte(0,0x80|address);
 
 #if defined(LCD_EXTENDED_NEWLINE)
 g_LcdX = x - 1;
 g_LcdY = y - 1;
 #endif
 }
 
 void lcd_putc(char c)
 {
 switch (c)
 {
 case '\a'   :  lcd_gotoxy(1,1);     break;
 
 case '\f'   :  lcd_send_byte(0,1);
 delay_ms(2);
 #if defined(LCD_EXTENDED_NEWLINE)
 g_LcdX = 0;
 g_LcdY = 0;
 #endif
 break;
 
 #if defined(LCD_TURKISH)
 case 'Ç'    :   Character_Generator_RAM(0,false);
 break;
 case 'Ğ'    :   Character_Generator_RAM(1,false);
 break;
 case 'İ'    :   Character_Generator_RAM(2,false);
 break;
 case 'Ö'    :   Character_Generator_RAM(3,false);
 break;
 case 'Ş'    :   Character_Generator_RAM(4,false);
 break;
 case 'Ü'    :   Character_Generator_RAM(5,false);
 break;
 case '\p'   :   Character_Generator_RAM(6,false);
 break;
 case '\q'   :   Character_Generator_RAM(7,false);
 break;
 #endif
 #if defined(MORE_CUSTOM_CHARACTERS))
 case '\1'   :   Character_Generator_RAM(8,false);
 break;
 case '\2'   :   Character_Generator_RAM(9,false);
 break;
 case '\3'   :   Character_Generator_RAM(10,false);
 break;
 case '\4'   :   Character_Generator_RAM(11,false);
 break;
 case '\5'   :   Character_Generator_RAM(12,false);
 break;
 case '\6'   :   Character_Generator_RAM(13,false);
 break;
 case '\s'   :   Character_Generator_RAM(14,false);
 break;
 case '\t'   :   Character_Generator_RAM(15,false);
 break;
 #endif
 #if defined(LCD_EXTENDED_NEWLINE)
 case '\r'   :  lcd_gotoxy(1, g_LcdY+1);   break;
 case '\n'   :
 while (g_LcdX++ < LCD_LINE_LENGTH)
 {
 lcd_send_byte(1, ' ');
 }
 lcd_gotoxy(1, g_LcdY+2);
 break;
 #else
 case '\n'   : lcd_gotoxy(1,2);        break;
 #endif
 
 case '\b'   : lcd_send_byte(0,0x10);  break;
 
 #if defined(LCD_EXTENDED_NEWLINE)
 default     :
 if (g_LcdX < LCD_LINE_LENGTH)
 {
 lcd_send_byte(1, c);
 g_LcdX++;
 }
 break;
 #else
 default     : lcd_send_byte(1,c);     break;
 #endif
 }
 }
 
 #if (defined(LCD_RW_PIN) && (LCD_RW_PIN==FALSE))
 #else
 char lcd_getc(BYTE x, BYTE y)
 {
 char value;
 
 lcd_gotoxy(x,y);
 while ( bit_test(lcd_read_byte(),7) ); // wait until busy flag is low
 lcd_output_rs(1);
 value = lcd_read_byte();
 lcd_output_rs(0);
 
 return(value);
 }
 
 BYTE lcd_get_address_counter(void)
 {
 BYTE address;
 
 lcd_output_rs(0);
 address = lcd_read_byte();
 lcd_output_rs(1);
 
 return(address);
 }
 #endif
 
 
 | 
 
 
  	  | Code: |  	  | 
 example_1.c
 
 #include <16f877.h>
 #fuses XT,NOWDT,NOPROTECT,NOPUT,NODEBUG,BROWNOUT,NOLVP,NOCPD,NOWRT
 #use delay(clock=4000000)
 #define LCD_ENABLE_PIN PIN_D2
 #define LCD_RS_PIN PIN_D0
 #define LCD_RW_PIN PIN_D1
 #define LCD_DATA4 PIN_C0
 #define LCD_DATA5 PIN_C1
 #define LCD_DATA6 PIN_C2
 #define LCD_DATA7 PIN_C3
 #define MORE_CUSTOM_CHARACTERS
 #define LCD_TURKISH
 #include <LCD_CGRAM_TR.c>
 
 unsigned int i;
 
 void erase_pacman(int row, int column)
 {
 int x,y,z;
 printf(lcd_putc, "\f   \p PACMAN \q   \n   CHARACTER    ");
 delay_ms(2000);
 for(y=1;y<=row;y++)
 {
 z=column;
 for(x=1;x<=column;x++)
 {
 if(y%2)lcd_gotoxy(x,y);
 else lcd_gotoxy(z,y);
 if(x%2 && y%2) printf(lcd_putc, "\1");
 else if (x%2==0 && y%2) printf(lcd_putc, "\2");
 else if (x%2 && y%2==0) printf(lcd_putc, "\3");
 else if (x%2==0 && y%2==0) printf(lcd_putc, "\4");
 delay_ms(200);
 printf(lcd_putc, "\b ");
 z--;
 }
 }
 }
 
 void main()
 {
 setup_psp(PSP_DISABLED);
 setup_spi(SPI_SS_DISABLED);
 setup_adc_ports(NO_ANALOGS);
 setup_spi(FALSE);
 setup_timer_1(T1_DISABLED);
 setup_timer_2(T2_DISABLED,0,1);
 setup_adc_ports(NO_ANALOGS);
 setup_adc(ADC_OFF);
 setup_CCP1(CCP_OFF);
 setup_CCP2(CCP_OFF);
 lcd_init();
 erase_pacman(2,16);
 
 while(1)
 {
 printf(lcd_putc, "\f\s");
 delay_ms(2000);
 printf(lcd_putc, "\1");
 delay_ms(2000);
 printf(lcd_putc, "\2");
 delay_ms(2000);
 printf(lcd_putc, "\3");
 delay_ms(2000);
 printf(lcd_putc, "\4");
 delay_ms(2000);
 printf(lcd_putc, "\5");
 delay_ms(2000);
 printf(lcd_putc, "\6");
 delay_ms(2000);
 printf(lcd_putc, "Ç");
 delay_ms(2000);
 printf(lcd_putc, "Ğ");
 delay_ms(2000);
 printf(lcd_putc, "İ");
 delay_ms(2000);
 printf(lcd_putc, "Ö");
 delay_ms(2000);
 printf(lcd_putc, "Ş");
 delay_ms(2000);
 printf(lcd_putc, "Ü");
 delay_ms(2000);
 printf(lcd_putc, "\p");
 delay_ms(2000);
 printf(lcd_putc, "\q");
 delay_ms(2000);
 printf(lcd_putc, "\t");
 delay_ms(2000);
 printf(lcd_putc, "\n\s");
 delay_ms(2000);
 printf(lcd_putc, "\1");
 delay_ms(2000);
 printf(lcd_putc, "\2");
 delay_ms(2000);
 printf(lcd_putc, "\3");
 delay_ms(2000);
 printf(lcd_putc, "\4");
 delay_ms(2000);
 printf(lcd_putc, "\5");
 delay_ms(2000);
 printf(lcd_putc, "\6");
 delay_ms(2000);
 printf(lcd_putc, "Ç");
 delay_ms(2000);
 printf(lcd_putc, "Ğ");
 delay_ms(2000);
 printf(lcd_putc, "İ");
 delay_ms(2000);
 printf(lcd_putc, "Ö");
 delay_ms(2000);
 printf(lcd_putc, "Ş");
 delay_ms(2000);
 printf(lcd_putc, "Ü");
 delay_ms(2000);
 printf(lcd_putc, "\p");
 delay_ms(2000);
 printf(lcd_putc, "\q");
 delay_ms(2000);
 printf(lcd_putc, "\t");
 delay_ms(2000);
 lcd_gotoxy(1,1);
 for(i=0;i<=255;i++)
 {
 lcd_gotoxy(1,1);
 printf(lcd_putc,"%c          %05d",i,i);
 delay_ms(200);
 printf(lcd_putc,"\n\s\1\2\3\4\5\6\p\qÇĞİÖŞÜ\t");
 }
 }
 }
 
 
 | 
 
 
  	  | Code: |  	  | 
 example_2.c
 
 #include <18f4580.h>
 #fuses INTRC_IO,NOWDT,NOPROTECT,NOLVP,NOMCLR
 #use delay(clock=8000000)
 #define LCD_ENABLE_PIN PIN_D2
 #define LCD_RS_PIN PIN_D0
 #define LCD_RW_PIN FALSE
 #define LCD_DATA4 PIN_C0
 #define LCD_DATA5 PIN_C1
 #define LCD_DATA6 PIN_C2
 #define LCD_DATA7 PIN_C3
 //#define MORE_CUSTOM_CHARACTERS
 #define LCD_TURKISH
 #include <LCD_CGRAM_TR_RAM.c>
 
 unsigned int i;
 
 void main()
 {
 setup_psp(PSP_DISABLED);
 setup_spi(SPI_SS_DISABLED);
 setup_adc_ports(NO_ANALOGS);
 setup_spi(FALSE);
 setup_timer_1(T1_DISABLED);
 setup_timer_2(T2_DISABLED,0,1);
 setup_adc_ports(NO_ANALOGS);
 setup_adc(ADC_OFF);
 setup_CCP1(CCP_OFF);
 setup_CCP2(CCP_OFF);
 lcd_init();
 printf(lcd_putc,"   TURKISH    \n   CHARACTERS   ");
 
 while(1)
 {
 printf(lcd_putc, "\f\p");
 delay_ms(2000);
 printf(lcd_putc, "Ç");
 delay_ms(2000);
 printf(lcd_putc, "Ğ");
 delay_ms(2000);
 printf(lcd_putc, "İ");
 delay_ms(2000);
 printf(lcd_putc, "Ö");
 delay_ms(2000);
 printf(lcd_putc, "Ş");
 delay_ms(2000);
 printf(lcd_putc, "Ü");
 delay_ms(2000);
 printf(lcd_putc, "\q");
 delay_ms(2000);
 printf(lcd_putc, "\f");
 for(i=0;i<=255;i++)
 {
 lcd_gotoxy(1,1);
 printf(lcd_putc,"%c          %05d",i,i);
 delay_ms(200);
 printf(lcd_putc,"\n\pÇĞİÖŞÜ\q");
 }
 }
 }
 
 
 | 
 _________________
 Bülent PERKTAŞ
 
 Last edited by bulentperktas on Sat Oct 01, 2016 4:48 pm; edited 2 times in total
 |  |  
		|  |  
		| Arsenic 
 
 
 Joined: 23 Sep 2016
 Posts: 13
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Tue Nov 14, 2017 7:05 pm |   |  
				| 
 |  
				| Hi! Thanks for sharing your work. I note it that your library takes -along with my code- 91 percent of the ram of my uC. But I don't care that for now. |  |  
		|  |  
		| navneet 
 
 
 Joined: 24 Jun 2020
 Posts: 1
 
 
 
			    
 
 | 
			
				| regarding Arduino controller used |  
				|  Posted: Wed Jun 24, 2020 1:47 am |   |  
				| 
 |  
				| I wanted to ask if this code will work for the Arduino controller. Moreover, this code is for which controller. Please reply.
 |  |  
		|  |  
		| Ttelmah 
 
 
 Joined: 11 Mar 2010
 Posts: 19966
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed Jun 24, 2020 2:33 am |   |  
				| 
 |  
				| This is a forum for PIC's using CCS C. The header for the driver refers to the PIC18 family.
 So, no it won't work 'as is', but the basic idea can be adapted.
 |  |  
		|  |  
		|  |  
  
	| 
 
 | You cannot post new topics in this forum You cannot reply to topics in this forum
 You cannot edit your posts in this forum
 You cannot delete your posts in this forum
 You cannot vote in polls in this forum
 
 |  
 Powered by phpBB © 2001, 2005 phpBB Group
 
 |