/* This function scrolls only the bottom row of the LCD display once to the left. If it is already at the end of the message, it resets the display to the home position */ void lcd_scroll (void) { int i=0; char temp; p5_3 = 0; //disable sensors if(bottom_length - 9 == lcd_pos) // if end of scrolling line { for(i = 0; 8 > i; i++) // copy top line to beginning { temp = lcd_char_read(lcd_pos + i); lcd_command_write(0x80 + i); lcd_char_write(temp); } lcd_command_write(0x02); // change scroll to beginning lcd_pos = 0; // reset position } else if (9 < bottom_length) // if not the end, scroll once to the left { for(i = 8; 0 < i; i--) // copy the top line one place ahead { temp = lcd_char_read(lcd_pos + i - 1); lcd_command_write(0x80 + lcd_pos + i); lcd_char_write(temp); } lcd_command_write (0x18); // now scroll lcd_pos++; } p5_3 = 1; //enable sensors prc2 = 1; pd0_0 = 0; prc2 = 1; pd0_1 = 0; prc2 = 1; pd0_2 = 0; prc2 = 1; pd0_3 = 0; }
/* This function takes the char array 'message' and displays it on the bottom line of the LCD */ void lcd_display_bottom (char message[]) { int i = 0; char temp; p5_3 = 0; //disable sensors lcd_command_write(0xA8); // set position to bottom line while(0 != message[i]) // send the charactors lcd_char_write(message[i++]); bottom_length = i + 1; // counter for the length of the bottom line for (i = 0; 9 > bottom_length + i; i++) lcd_char_write(' '); // make rest of line blank; for(i = 0; 8 > i; i++) // copy top line to beginning { temp = lcd_char_read(lcd_pos + i); lcd_command_write(0x80 + i); lcd_char_write(temp); } lcd_pos = 0; lcd_command_write(0x02); // reset scrolling to home position p5_3 = 1; //enable sensors prc2 = 1; pd0_0 = 0; prc2 = 1; pd0_1 = 0; prc2 = 1; pd0_2 = 0; prc2 = 1; pd0_3 = 0; }
void init_lcd( void ) { set_lcd_port_output(); delay(100*100); lcd_command_write(0x28); /* (Function Set) 4-bit interface, two line, 5X8 dots. */ lcd_clear() ; /* LCD clear */ lcd_command_write(0x02); /* cursor home */ lcd_command_write(0x06); /* (Entry Mode) Increment, Display Shift off */ lcd_command_write(0x0C) ; /* display on, Cursor & Blink off */ lcd_gotoxy(0, 0); lcd_clear(); lcd_putstring(0," JRM Technologies"); lcd_putstring(1," SAIRAM JAIRAM "); }
/** ******************************************************************************************** Function Name : init_lcd() Description : Input : Output : Void Note : ******************************************************************************************** */ void init_lcd( void ) { set_lcd_port_output(); delay(100*100); delay(100*100); lcd_command_write(0x28); /* 4-bit interface, two line, 5X7 dots. */ lcd_clear() ; /* LCD clear */ lcd_command_write(0x02); /* cursor home */ lcd_command_write(0x06); /* cursor move direction */ lcd_command_write(0x0C) ; /* display on */ lcd_gotoxy(0, 0); lcd_clear(); lcd_putstring(0," N G X "); lcd_putstring(1," TECHNOLOGIES "); }
int lcd_gotoxy( unsigned int x, unsigned int y) { int retval = 0; if( (x > 1) && (y > 15) ) { retval = -1; } else { if( x == 0 ) { lcd_command_write( 0x80 + y ); /* command - position cursor at 0x00 (0x80 + 0x00 ) */ } else if( x==1 ){ lcd_command_write( 0xC0 + y ); /* command - position cursor at 0x40 (0x80 + 0x00 ) */ } } return retval; }
void lcd_gotoxy( unsigned int x, unsigned int y) { if( x == 0 ) { lcd_command_write( 0x80 + y ); /* command - position cursor at 0x00 (0x80 + 0x00 ) */ } else if( x==1 ) { lcd_command_write( 0xC0 + y ); /* command - position cursor at 0x40 (0x80 + 0x00 ) */ } else if( x==2 ) { lcd_command_write( 0x80 + y + 20 ); /* command - position cursor at 0x40 (0x80 + 0x00 ) */ } else if( x==3 ) { lcd_command_write( 0xC0 + y + 20); /* command - position cursor at 0x40 (0x80 + 0x00 ) */ } }
/* This function clears the LCD display and resets the position to home */ void lcd_clear(void) { p5_3 = 0; //disable sensors lcd_command_write(0x01); // clear display and go to home position lcd_pos = 0; // reset position p5_3 = 1; //enable sensors prc2 = 1; pd0_0 = 0; prc2 = 1; pd0_1 = 0; prc2 = 1; pd0_2 = 0; prc2 = 1; pd0_3 = 0; }
/* This function takes the char array 'message' and displays it on the top line of the LCD */ void lcd_display_top (char message[]) { int i = 0; p5_3 = 0; //disable sensors lcd_command_write(0x80 + lcd_pos); // set position to top line while(0 != message[i]) // send the charactors lcd_char_write(message[i++]); top_length = i + 1; // counter for the length of the message for (i = 0; 9 > top_length + i; i++) lcd_char_write(' '); // make rest of line blank p5_3 = 1; //enable sensors prc2 = 1; pd0_0 = 0; prc2 = 1; pd0_1 = 0; prc2 = 1; pd0_2 = 0; prc2 = 1; pd0_3 = 0; }
void lcd_clear( void) { lcd_command_write( 0x01 ); }
void lcd_clear( void) { lcd_command_write( 0x01 ); delayMs(1,2); }
void setLCD( void ) { delayMs(1,50); lcd_command_write(0b00101001); // function set - 4-bit interface delayMs(1,2); lcd_command_write(0b00001000); // display off delayMs(1,2); lcd_clear(); lcd_command_write(0b00000110); // cursor move direction delayMs(1,2); // setup custom characters lcd_command_write(0b01000000); // move to first CGRAM location delayMs(1,2); lcd_data_write(0b00000000); delayMs(1,2); // 0x00 lcd_data_write(0b00000011); delayMs(1,2); lcd_data_write(0b00000100); delayMs(1,2); lcd_data_write(0b00001000); delayMs(1,2); lcd_data_write(0b00010000); delayMs(1,2); lcd_data_write(0b00010000); delayMs(1,2); lcd_data_write(0b00010000); delayMs(1,2); lcd_data_write(0b00010000); delayMs(1,2); lcd_data_write(0b00010000); delayMs(1,2); // 0x01 lcd_data_write(0b00010000); delayMs(1,2); lcd_data_write(0b00010000); delayMs(1,2); lcd_data_write(0b00010000); delayMs(1,2); lcd_data_write(0b00010000); delayMs(1,2); lcd_data_write(0b00001000); delayMs(1,2); lcd_data_write(0b00000111); delayMs(1,2); lcd_data_write(0b00000000); delayMs(1,2); lcd_data_write(0b00011111); delayMs(1,2); // 0x02 lcd_data_write(0b00000000); delayMs(1,2); lcd_data_write(0b00000000); delayMs(1,2); lcd_data_write(0b00000000); delayMs(1,2); lcd_data_write(0b00000000); delayMs(1,2); lcd_data_write(0b00000000); delayMs(1,2); lcd_data_write(0b00000000); delayMs(1,2); lcd_data_write(0b00001111); delayMs(1,2); lcd_data_write(0b00010010); delayMs(1,2); // 0x03 lcd_data_write(0b00001001); delayMs(1,2); lcd_data_write(0b00001001); delayMs(1,2); lcd_data_write(0b00001001); delayMs(1,2); lcd_data_write(0b00001001); delayMs(1,2); lcd_data_write(0b00010010); delayMs(1,2); lcd_data_write(0b00001100); delayMs(1,2); lcd_data_write(0b00000000); delayMs(1,2); lcd_data_write(0b00011111); delayMs(1,2); // 0x04 lcd_data_write(0b00000000); delayMs(1,2); lcd_data_write(0b00000000); delayMs(1,2); lcd_data_write(0b00000000); delayMs(1,2); lcd_data_write(0b00000000); delayMs(1,2); lcd_data_write(0b00000000); delayMs(1,2); lcd_data_write(0b00000000); delayMs(1,2); lcd_data_write(0b00011111); delayMs(1,2); lcd_data_write(0b00011100); delayMs(1,2); // 0x05 lcd_data_write(0b00000010); delayMs(1,2); lcd_data_write(0b00000001); delayMs(1,2); lcd_data_write(0b00000111); delayMs(1,2); lcd_data_write(0b00000001); delayMs(1,2); lcd_data_write(0b00000001); delayMs(1,2); lcd_data_write(0b00000010); delayMs(1,2); lcd_data_write(0b00011100); delayMs(1,2); lcd_command_write(0b00000010); // cursor home delayMs(1,2); lcd_command_write(0b00001100); // display on delayMs(1,2); lcd_gotoxy(0, 0); delayMs(1,2); lcd_clear(); }