Beispiel #1
0
int main( void )
{
  LCD_init();
  LCD_write("Hello World");
  LCD_command(LCD_LINE2 | 5); // move cursor  to row 2, position 5 
  LCD_write("is here");
}
Beispiel #2
0
void LCD_clear(int fd)
{
  LCD_write(LCD_RS_CMD, LCD_CMD_CLEAR, fd);
  delay(2);
  LCD_write(LCD_RS_CMD, LCD_CMD_HOME, fd);
  delay(2);
}
Beispiel #3
0
void 
LCD_write_str(char *str, uint8_t pos){
    LCD_write(RS_ADDR,pos);
    while(*str != '\0'){
        LCD_write(RS_DATA,*(str++));    
    }
}
Beispiel #4
0
void LCD_writeChar(char c) {
	unsigned char i;
	LCD_write(LCD_DATA,0);			// blank vert col before char
	for(i=0; i<5; i++) {
		LCD_write(LCD_DATA,ASCII[c - 0x20][i]);
	}
	LCD_write(LCD_DATA,0);			// Blank vert col after char
}
Beispiel #5
0
/* This function will write n char even if its the null char*/
void
LCD_write_nstr_f(char *str, uint8_t n, uint8_t pos){
    LCD_write(RS_ADDR,pos);
    for(; n>0; n--)
    {
        LCD_write(RS_DATA,*(str++));
    }
}
Beispiel #6
0
/* This function will write the min of either the null char or n chars */
void 
LCD_write_nstr(char *str, uint8_t n, uint8_t pos){
    LCD_write(RS_ADDR,pos);
    for(; (n>0)&&(*str!='\0'); n--)
    {
        LCD_write(RS_DATA,*(str++));    
    }
}
Beispiel #7
0
void line_wrapping(int8_t number)
{
	if(number == 1)
	{
	 LCD_write(FIRS_LINE,RS_COM); 
	}
	else
	 LCD_write(SEC_LINE,RS_COM);	
}
Beispiel #8
0
void LCD_menu2_line1(void)
{
	LCD_write(LCD_LINE1_HOME, LCD_COMMAND);
	LCD_data_delay();
	LCD_write('M', LCD_DATA);   
	LCD_data_delay();
	LCD_write(':', LCD_DATA); 
	LCD_data_delay();
	LCD_write(' ', LCD_DATA); 
}
Beispiel #9
0
void LCD_menu1_line2(void)
{
	LCD_write(LCD_LINE2_HOME, LCD_COMMAND);
	LCD_data_delay();
	LCD_write('L', LCD_DATA);   
	LCD_data_delay();
	LCD_write(':', LCD_DATA);
	LCD_data_delay();
	LCD_write(' ', LCD_DATA); 
}
Beispiel #10
0
/*!
 * \brief Initializing LCD by Instruction - 4-bit initialization
 */
void LCD_init(void)
{
	_delay_ms(30);        	                /* power on delay - wait more than 30 ms */
	LCD_write(0);      		        /* set RS, RW and EN low */

	LCD_write( P_LCD_EN1 | P_LCD_EN2 | 0x30 );  /* lcd enable high */
	LCD_write( 0x30 );                      /* lcd enable low */
	_delay_ms(5);			        /* wait 5 ms */

	LCD_write( P_LCD_EN1 | P_LCD_EN2 | 0x30 );  /* lcd enable high */
	LCD_write( 0x30 );                      /* lcd enable low */	
	_delay_us(100);                         /* wait more than 100us */

	LCD_write( P_LCD_EN1 | P_LCD_EN2 | 0x30 );  /* lcd enable high */
	LCD_write( 0x30 );                      /* lcd enable low */
	_delay_us(100);                         /* wait more than 100us */

	LCD_write( P_LCD_EN1 | P_LCD_EN2 | 0x20 );  /* lcd enable high */
	LCD_write( 0x20 );                      /* lcd enable low */
	_delay_us(100);                         /* wait more than 100us */

	LCD_sendcmd(LCD_EN1| LCD_EN2 | 0x28);                     /* 4 bit mode, 1/16 duty, 5x8 font */
	LCD_sendcmd(LCD_EN1| LCD_EN2 | 0x08);                     /* display off */
	LCD_sendcmd(LCD_EN1| LCD_EN2 | 0x01);                     /* display clear */
	LCD_sendcmd(LCD_EN1| LCD_EN2 | 0x06);                     /* entry mode */
	LCD_sendcmd(LCD_EN1| LCD_EN2 | 0x0f);                     /* display on, cursor off, blinking cursor off */

}
Beispiel #11
0
void LCD_init(int fd)
{
  delay(40);
  // Function Set。8bit bus mode, 2-line mode,normal font,normal instruction mode。
  LCD_write(LCD_RS_CMD, 0b00111000, fd);
  // Function Set。extension instruction modeへ。
  LCD_write(LCD_RS_CMD, 0b00111001, fd);
  // Internal OSC frequency(extension instruction mode)設定。
  LCD_write(LCD_RS_CMD, 0b00010100, fd);
  // Contrast set(extension instruction mode)。コントラスト値下位4bit設定。
  LCD_write(LCD_RS_CMD, 0b01110000 | (LCD_CONTRAST & 0xF), fd);
  // Power/ICON/Contrast set(extension instruction mode)。
  // アイコン On,booster On,コントラスト値上位2bit設定。
  LCD_write(LCD_RS_CMD, 0b01011100 | ((LCD_CONTRAST >> 4) & 0x3), fd);
  // Follower control。internal follower on, 
  LCD_write(LCD_RS_CMD, 0b01101100, fd);
  // 時間待ち。
  delay(300);
    
  // Function Set。normal instruction mode。
  LCD_write(LCD_RS_CMD, 0b00111000, fd);
  // Display On/Off。Display Onに設定。
  LCD_write(LCD_RS_CMD, 0b00001100, fd);
  // Clear Display。
  LCD_write(LCD_RS_CMD, 0b00001100, fd);
  // 時間待ち。
  delay(2);
}
Beispiel #12
0
//initialize the lcd when power up
//the initialize sequence can be refered to the LCD datasheet
void LCD_init(void)
{
    Databus_clear();
	LCDBUS = PORT_OUTPUT;
	delay_ms(50);       				// Wait VCC is rise

	LCD_write(0x00, LCD_COMMAND);
	LCD_startup_delay();
	LCD_write(0x00, LCD_COMMAND);
	LCD_startup_delay();
	LCD_write(0x00, LCD_COMMAND);
	LCD_startup_delay();
	LCD_write(0x00, LCD_COMMAND);
	LCD_startup_delay();

	LCD_write(0x28, LCD_COMMAND);       // Function Set
	LCD_com_delay();
	LCD_write(0x0C, LCD_COMMAND);       // Display ON/OFF	
	LCD_com_delay();
	LCD_write(0x06, LCD_COMMAND);       // Entry Mode set
	LCD_com_delay();
	LCD_write(0x01, LCD_COMMAND);       // Display Clear
	LCD_com_delay();

	LCD_menu_selection = LCD_MENU_PAGE_ONE;
	LCD_menu1_line1();				//display line 1 of lcd menu 1
	_delay_us(30);
	LCD_menu1_line2();				//display line 2 of lcd menu 1
}
void LCD_write_string(unsigned char *str)	//store address value of the string in pointer *str
{
	int i=0;
	char a;
	while(str[i]!='\0')				// loop will go on till the NULL character in the string
	{
		LCD_write(str[i]);				// sending data on LCD byte by byte
		i++;
	}
	a=248;
	LCD_write(a);
	a=67;
	LCD_write(a);
	return;
}
void main (void)
{
	Init_Device();
	SPI0CFG |= 0x07;	//8 Bits pro Master-SPI-Transfer
	EA=1;
	LCD_init = 1;  // Bit zur Verzweigung in der ISR
	P5=0x0F;
	CONTROL_LCD = SMB_BUS_ERROR;

	LCD_write();

	P2_0 = 1;

	while(1)
	{
//		switch(P5)
//		{
//			case 0x07:
//			{
			
					SPI_read();
					show_display(1,ken5);
//					break;
//			}
//
//			default:
//			{
//					break;
//			}
//		}
	}
}
Beispiel #15
0
LCDDriver::LCDDriver()
{
	g_IOSet = CSingleton<CGlobalIOSet>::instance();
	LCD_write(0x38,0);
	Delay_ms(5);
	LCD_write(0x38,0);
	Delay_ms(5);
	LCD_write(0x38,0);
	LCD_write(0x10,0);
	LCD_write(0x08,0);
	LCD_write(0x01,0);
	LCD_write(0x06,0);
	LCD_write(0x0C,0); 
	LCD_write(0x80,0);
	LCD_write('A',1);
}
Beispiel #16
0
void LCD_write_adress(uint8_t data, uint8_t adress)
{
	_delay_ms(40);
//	LCD_read_BF();
	LCD_write(adress, RS_COM);
	DDR_DATA |= 0xF0;
	PORT_DATA |= 0xF0;
	PORT_SIG &= ~(ON<<RW);
	PORT_SIG|= (ON<<RS);// иначе 1 то данные 
	uint8_t tmp = data;
	uint8_t temp = PORT_DATA & 0x0F;
	temp |= (data &0xF0);
	PORT_DATA = temp;
	PORT_SIG|= (ON<<E);
	_delay_ms(2);
	PORT_SIG &= ~(ON<<E);
	temp = PORT_DATA & 0x0F;
	temp|= (tmp<<4);
	PORT_DATA = temp;
	PORT_SIG|= (ON<<E);
	_delay_ms(2);
	PORT_SIG &= ~(ON<<E);
	_delay_ms(40);	

}
Beispiel #17
0
//update part one of the lcd data
void LCD_data_update(u08 start_pos, u16 data, u08 type)
{
	if(type == LCD_SHOW_BINARY)
	{
		u08tobinary(data);
	}
	else if(type == LCD_SHOW_U08)
	{
		u08toStr(data);
	}
	else if(type == LCD_SHOW_U16)
	{
		u16toStr(data);
	}
	else
	{
		return;
	}
	u08 i;
	for(i=0;i<8;i++)
	{
		lcd_print_data[i] = lcd_binary_data[i];
	}
	LCD_write(start_pos, LCD_COMMAND);
	LCD_data_delay();
	print_data(0, 7);
}
Beispiel #18
0
void LCD_clear(void) {
	unsigned char x,y;
	for(y=0; y< LCD_HEIGHT >> 3; y++) {
		for(x=0; x< LCD_WIDTH; x++) {
			LCD_write(LCD_DATA, 0x00);
		}
	}
}
Beispiel #19
0
void LCD_write_str(int8_t *string)
{
	while(*string)
	{
		LCD_write(*string,RS_DATA);
		string++;
	}
}
// Allows us to fill the first 8 CGRAM locations
// with custom characters
void LCD_createChar(uint8 location, uint8 charmap[]) {
    location &= 0x7; // we only have 8 locations 0-7
    LCD_command(LCD_SETCGRAMADDR | (location << 3));
    int i;
    for (i=0; i<8; i++) {
        LCD_write(charmap[i]);
    }
}
Beispiel #21
0
int LCDDriver::Show(void)
{
   // TODO : implement
   int i=0;
   LCD_write(0x80,0);
   for(i=0;i<16;i++)
   {
   	LCD_write(frame[i],1);
		Delay_ms(1);
   }

   LCD_write(0xC0,0);
   for(i=0;i<16;i++)
   {
   	LCD_write(frame[i+16],1);
		Delay_ms(1);
   }
}
/*****************************************************************************
Name:        	TransferBufferFixedLength
Parameters:  	position	Line number of display
			    *Buff		Buffer containing data to be written to display. 
			    			Last character should be null.
				controller  [1,2, 3(both)]
Returns:        none
Description:    This function controls LCD writes to line 1 or 2 of the LCD.  
*****************************************************************************/
void TransferBufferFixedLength( _far const char * string, BYTE length )
{
	BYTE controller =1;
	int i;		
	for (i=0; i < length; i++)
	{
		LCD_write(DATA,*(string+i),controller);
	}
}
Beispiel #23
0
void LCD_setCursor(unsigned char col, unsigned char row, int fd)
{
  unsigned char offset[] = {0x00, 0x40};
    
  if (row > 1)    row = 1;
  if (col > 16)    col = 16;
    
  LCD_write(LCD_RS_CMD, 0x80 | (col + offset[row]), fd);
}
void LCD_print(char data[])
{
    uint8 size;
    size = strlen(data);
    uint8 i;
    for (i = 0; i < size; i++) {
        LCD_write(data[i]);
    }
}
/*****************************************************************************
Name:        	TransferBuffer
Parameters:  	position	Line number of display
			    *Buff		Buffer containing data to be written to display. 
			    			Last character should be null.
				controller  [1,2, 3(both)]
Returns:        none
Description:    This function sends data in the buffer to LCD writes.
				Writing beyond a controller limit will result in smooth
				transition to the next controller.				
*****************************************************************************/
void TransferBuffer(_far char * buffer)
{
	BYTE controller=1;
	do
	{
		LCD_write(DATA, *buffer++, controller);
	}
	while(*buffer);
}
Beispiel #26
0
int main(void) {
  // Select 12MHz crystal oscillator
  LPC_SC ->CLKSRCSEL = 1;

  // Init PLL 0 to 100MHz
  PLL_init(25, 2, 3);
//  PLL_init(12, 1, 18); // 16MHz
  SystemCoreClockUpdate();

  volatile uint32_t i = 1;
  while (i < (1 << 23)) { ++i; }

  LCD_init();
  LCD_function_set(BUS_WIDTH_8, LINE_COUNT_2, FONT_5_8);

  i = 1;
  while (i < (1 << 23)) { ++i; }

  LCD_write('a');
  LCD_write('b');
  LCD_write('c');
  LCD_write('d');

  char c = 'e';
  uint_fast8_t x = 0, y = 0;
  while(1) {
    LCD_write(c);
    ++c;

    ++x;
    if (x > 15) {
      x = 0;
      y ^= 1;
    }

    LCD_move_cursor(x, y);

    i = 1;
    while (i < (1 << 23)) { ++i; }
  }

  return 0;
}
Beispiel #27
0
void display_volume(){
    // Assume vol is two digits
    char buf[2];   
    uint8_t i;    
    i = vol;

    buf[1] = i%10 + '0';
    buf[0] = i/10 + '0';

    // clear screen
    LCD_write(RS_ADDR, 0x01);
    if(i == 0){
       LCD_write_str("Mute",LCD_DDRAM_LINE1_ADDR+6);
    }else{
        LCD_write_nstr(buf,2,LCD_DDRAM_LINE1_ADDR+7);
    }
    LCD_write(RS_ADDR,LCD_DDRAM_LINE2_ADDR+3);
    while(i-- > 0) LCD_write(RS_DATA,255);    
}
Beispiel #28
0
/*!
 * \brief Send data to LCD 
 *
 * \param val   data for display                  
 *              low byte => character, high byte => control (EN1, EN2, RS)
 *
 */
void LCD_sendval( uint16_t val)
{
        uint8_t ctrl = 0;
        uint8_t tmp;
        if (LCD_RS & val)       ctrl |= P_LCD_RS;                       /* Do you expect a command ? */
        if (LCD_EN1 & val)      ctrl |= P_LCD_EN1;                      /* Do you expect work with first part of LCD ? */
        if (LCD_EN2 & val)      ctrl |= P_LCD_EN2;                      /* Do you expect work with second part of LCD ? */
        tmp = ctrl | (val & 0xF0);
        LCD_write( tmp );                                               /* high nibble ENABLE active */
        tmp = (ctrl & ~(P_LCD_EN1 | P_LCD_EN2)) | (val & 0xF0);
        LCD_write(tmp);                                                 /* high nibble */

        tmp = ctrl | ((val & 0xf) << 4) ;
        LCD_write( tmp ); /* low nibble ENABLE active */
        tmp = (ctrl & ~(P_LCD_EN1 | P_LCD_EN2)) | ((val & 0xf) << 4);
        LCD_write(  tmp );                       /* low nibble */

        _delay_ms(2);                                   /* The busy flag must be checked after the 4-bit data */
                                                        /* has been transferred twice. */
}
Beispiel #29
0
void LCD_menu2_line2(void)
{
	LCD_write(LCD_LINE2_HOME, LCD_COMMAND);
	LCD_data_delay();
	LCD_write('V', LCD_DATA);  
	LCD_data_delay();
	LCD_write('R', LCD_DATA);
	LCD_data_delay();
	LCD_write('0', LCD_DATA);
	LCD_data_delay();
	LCD_write(' ', LCD_DATA); 
//	LCD_write(0xC8, LCD_COMMAND);
//	LCD_write('I', LCD_DATA);  
//	LCD_data_delay();
//	LCD_write('R', LCD_DATA);
//	LCD_data_delay();
//	LCD_write(':', LCD_DATA);
//	LCD_data_delay();
//	LCD_write(' ', LCD_DATA); 
}
Beispiel #30
0
void LCD_set_cursor(uint8_t line, uint8_t character){
	uint8_t data = 0;
	
	if(line == 1){
		data = 0x80 + 0x00 + character;
		LCD_write(data);
	}
	else if(line == 2){
		data = 0x80 + 0x40 + character;
		LCD_write(data);
	}
	else if(line == 3){
		data = 0x80 + 0x10 + character;
		LCD_write(data);
	}
	else{
		data = 0x80 + 0x50 + character;
		LCD_write(data);
	}
}