Пример #1
0
//------------------------------------------------------------------------------------
// lcd_init
//------------------------------------------------------------------------------------
//
void lcd_init(void)
{
	char SFRPAGE_SAVE;

	SFRPAGE_SAVE = SFRPAGE;			// Save Current SFR page
	SFRPAGE = CONFIG_PAGE;
	
	LCD_CTRL_PORT = LCD_CTRL_PORT & ~RS_MASK;	// RS = 0
	LCD_CTRL_PORT = LCD_CTRL_PORT & ~RW_MASK;	// RW = 0
	LCD_CTRL_PORT = LCD_CTRL_PORT & ~E_MASK;	//  E = 0
	large_delay(200);				// 16ms delay

	LCD_DAT_PORT = 0x38;			// set 8-bit mode
	small_delay(1);		//RPK
	pulse_E();
	large_delay(50);				// 4.1ms delay	[50]

	LCD_DAT_PORT = 0x38;			// set 8-bit mode
	small_delay(1);		//RPK
	pulse_E();
	large_delay(3);					// 1.5ms delay		[2]

	LCD_DAT_PORT = 0x38;			// set 8-bit mode
	small_delay(1);		//RPK
	pulse_E();
	large_delay(3);					// 1.5ms delay		[2]

	lcd_cmd(0x06);					// curser moves right
	lcd_clear();
	lcd_cmd(0x0E);					// display and curser on

	SFRPAGE = SFRPAGE_SAVE;			// Restore SFR page
}
Пример #2
0
void display_row_var (unsigned char p_byRow, unsigned char str[16])
{
	unsigned char k,cpy_str[2];
	unsigned long int i = 0;
	if(p_byRow == 1)			// if row  is same as saying if row is non zero, in our case its row = 1
	{
		lcd_cmd(0xc0);
	}
	else
	{
		lcd_cmd(0x80);
	}
		
	for(k = 0 ; k < 16 ; k ++)
	{

		{
			if (str[k])
				lcd_dat(str[k]) ;
			else
				break ;
		}
	}
	while(k < 16)
	{
		lcd_dat(' ') ;
		k ++ ;
	}

}	
Пример #3
0
 lcd_init()
 {
 lcd_cmd(0x38);
 lcd_cmd(0x80);
 lcd_cmd(0x0E);
 lcd_cmd(0x01);
 }
Пример #4
0
void lcd_init()
{
	// Setup all lcd pins as outputs
	LCD_CONTROL_DDR |= _BV(LCD_RS_PIN) | _BV(LCD_E_PIN);
	LCD_DATA_DDR |= _BV(LCD_DATA0_PIN) | _BV(LCD_DATA1_PIN) | _BV(LCD_DATA2_PIN) | _BV(LCD_DATA3_PIN);

	// Wait for the module
	_delay_ms(200);
	
	// To be safe switch back to 8-bit interface for a moment (Function Set)
	LCD_CONTROL_PORT &= ~_BV(LCD_RS_PIN) & ~_BV(LCD_E_PIN);
	LCD_RST_DATA;
	LCD_DATA_PORT |= _BV(LCD_DATA0_PIN) | _BV(LCD_DATA1_PIN);
	lcd_strobe();
	_delay_ms(10);
	lcd_strobe();
	_delay_ms(10);
	lcd_strobe();
	_delay_ms(10);
	
	// Function Set: switch to 4 bit mode (last 8-bit command)
	LCD_RST_DATA;
	LCD_DATA_PORT |= _BV(LCD_DATA1_PIN);
	lcd_strobe();
	_delay_ms(10);
	
	// Using 4 bit mode now. Repeat Function Set command (2 lines, 5x8 chars, 4-bit mode)
	lcd_cmd(0x28);
	
	lcd_off();
	lcd_clr();
	lcd_cmd(LCD_CMD_DEFAULT_MODE);
	lcd_on();
}
Пример #5
0
main()
{
unsigned char temp;
unsigned char a[10];
	unsigned char i=0;

	uart_init();
lcd_init();

	do
	{		
		temp=uart_rx();
		uart_tx(temp);
		a[i++]=temp;
		lcd_cmd(0x01);
		lcd_data(temp);
		lcd_cmd(0x85);
		lcd_int(temp);
		lcd_cmd(0x89);
		lcd_string("0x");
		lcd_hex(temp);
		delay_ms(1000);
	}while(temp!=13);
	a[--i]='\0';
	lcd_cmd(0xc0);
	lcd_string(a);
	delay_ms(5000);
}
Пример #6
0
void lcd_init(void)
{
  lcd_cmd(LCD_FNSET(1,0)); /* Twoline, 5x8 font */
  lcd_cmd(LCD_ENTMODE(1,0)); /* Address increases, no display shift */
  lcd_cmd(LCD_DISPCTL(1,0,0)); /* On, no cursor */
  lcd_cmd(LCD_CLR); /* Clear display, home cursor */
}
Пример #7
0
//------------------------------------------------------------------------------------
// lcd_cursor
//------------------------------------------------------------------------------------
void lcd_cursor(bit on)	// 1 displays cursor, 0 hides it
{
	if (on)
		lcd_cmd(0x0E);	
	else
		lcd_cmd(0x0C);
}
Пример #8
0
void lcd_init(void) {
    lcd_cmd(LCD_SET_FUNC | LCD_FUNC_8BITS | LCD_FUNC_2LINE);
    lcd_cmd(LCD_DISP | LCD_DISP_ON);
//	lcd_cmd(LCD_ENT | LCD_ENT_INC);
//	lcd_cmd(8|LCD_SET_CG_ADDR);
    lcd_cmd(LCD_HOME);
    lcd_cmd(LCD_CLEAR);
}
Пример #9
0
//-------------------------------
void cursor_shift(int8u_t direction)
{
 switch(direction)
 {
  case RIGHT : lcd_cmd(0x14,0); break; // shift cursor to right
  case LEFT  : lcd_cmd(0x10,0); break; // shift cursor to left
 }
}
Пример #10
0
void turn_on_cursor(uint8_t blinking){
	if(blinking == CURSOR_BLINK){
		lcd_cmd(DISPLAY_CTRL_DispOn_BlkOn_CrsOn);
	}
	else{
		lcd_cmd(DISPLAY_CTRL_DispOn_BlkOff_CrsOn); // 1, lcd, cursor, blink
	}
}
Пример #11
0
//-------------------------------
void lcd_scroll(int8u_t direction)
{
 switch(direction)
 {
  case RIGHT : lcd_cmd(0x1C,0); break; // scroll display to right
  case LEFT  : lcd_cmd(0x18,0); break; // scroll display to left
 }
}
Пример #12
0
void main() {
int v1,v2,v3,x1,x2,i;
char txt[7];
lcd_init();
lcd_cmd(_lcd_clear); // clear lcd
lcd_cmd(_lcd_cursor_off );
lcd_out(1,1,"Sun Tracker");
trisc=0b00000000;
trisd=0b00000011;
while(1)
{
delay_ms(200);
v1=adc_read(1);
v2=adc_read(2);
v3=adc_read(3);
i=adc_read(4)*150;
x1=v2-v1;
x2=v2-v3;
inttostr(i,txt);
lcd_out(2,1,"I= ");
lcd_out(2,4,txt);
lcd_out_cp(" uA");
while(i>=1500)
{
en=0;
lcd_out(2,1,"Motor Off       ");
delay_ms(2000);
i=adc_read(4)*150;
}
if(rd0_bit==0)
{
en=1;
in1=1;
in2=0;
while(rd1_bit==1);
en=0;
in1=0;
in2=0;
}
if(x1<-20)
{
en=1;
in1=1;
in2=0;
}
 else if(x2<-20)
 {
in1=0;
in2=1;
en=1;
}
else
{
en=0;
}
}

}
Пример #13
0
main()
{
lcd_init();
lcd_cmd(0x80);
lcd_string("Abhyuday");
lcd_cmd(0xc0);
lcd_string("Rinkesh");
while(1);
}
Пример #14
0
main()
{
lcd_init();
lcd_cmd(0x80);
lcd_data('A');
lcd_cmd(0xc0);
lcd_data('B');
while(1);
}
Пример #15
0
void lcd_gotoxy(uint8_t x, uint8_t y)
{
	if (y==0) {
		lcd_cmd(LCD_CMD_DDRAM+LCD_LINE1_ADDR+x);
	}
	else {
		lcd_cmd(LCD_CMD_DDRAM+LCD_LINE2_ADDR+x);
	}
}
Пример #16
0
void shift_display(uint8_t direction)
{
	if(direction == '>'){
		lcd_cmd(0x1E);
	};
	if(direction == '<'){
		lcd_cmd(0x18);
	};
}
Пример #17
0
//-------------------------------
void lcd_goto(int8u_t line, int8u_t address)
{/* GO TO SPECIFIED ADDRESS */
 switch(line)
 {
  case     1: lcd_cmd(0x80|address,0); break;
  case     2: lcd_cmd(0xC0|address,0); break;
  case CGRAM: lcd_cmd(0x40|address,0); break; // CGRAM address
 }
}
Пример #18
0
void Init_LCD( void )             // initialize LCD display
{
        // turn off all analog functions on the pins used
    AD1PCFGH = 0xFF00;   //turns off channels AN24-31
    AD1PCFGL = 0x8000; //turns off channel AN15 for ADC1
    AD2PCFGL = 0x8000; //turns off channel AN15 for ADC2

	// 15mS delay after Vdd reaches nnVdc before proceeding with LCD initialization
	// not always required and is based on system Vdd rise rate
	Delay(Delay_15mS_Cnt);                  // 15ms delay

	/* set initial states for the data and control pins */
	LATE &= 0xFF00;
    RW = 0;                       // R/W state set low
	RS = 0;                       // RS state set low
	E = 0;                        // E state set low

	/* set data and control pins to outputs */
	TRISE &= 0xFF00;
 	RW_TRIS = 0;                  // RW pin set as output
	RS_TRIS = 0;                  // RS pin set as output
	E_TRIS = 0;                   // E pin set as output

	/* 1st LCD initialization sequence */
	DATA &= 0xFF00;
    DATA |= 0x0038;
    E = 1;
    Nop();
    Nop();
    Nop();
    E = 0;                        // toggle E signal
   	Delay(Delay_5mS_Cnt);         // 5ms delay

	/* 2nd LCD initialization sequence */
	DATA &= 0xFF00;
    DATA |= 0x0038;
    E = 1;
    Nop();
    Nop();
    Nop();
    E = 0;                        // toggle E signal
    Delay_Us( Delay200uS_count ); // 200uS delay

	/* 3rd LCD initialization sequence */
	DATA &= 0xFF00;
    DATA |= 0x0038;
    E = 1;
    Nop();
    Nop();
    Nop();
    E = 0;                        // toggle E signal
    Delay_Us( Delay200uS_count ); // 200uS delay

    lcd_cmd( 0x38 );              // function set
    lcd_cmd( 0x0C );              // Display on/off control, cursor blink off (0x0C)
    lcd_cmd( 0x06 );			  // entry mode set (0x06)
}
Пример #19
0
void lcd_clear (void)
{
    lcd_cmd (0x01); // Clear Display
    delayMs (5);
    lcd_cmd (0x39); // Function Set
    delayMs (5);
    lcd_cmd (0x06); // Cursor auto-increment
    delayMs (5);
}
Пример #20
0
void lcd_init (void)
{
    lcd_reset();         // Call LCD reset lcd_cmd(0×28);

    /* poll the Busy Flag => ok */

    lcd_cmd(0x0C);       // Display no cursor – no blink.
    lcd_cmd(0x06);       // Automatic Increment – No Display shift.
    lcd_cmd(0x80);       // Address DDRAM with 0 offset 80h.
}
void goto_col_row(unsigned char col,unsigned char row)
{

    lcd_cmd(0x80+col);                     // for col
    if (row>0)
    {
        lcd_cmd((0x80) | (0x40+col-1));    // for row
    }

}
Пример #22
0
//-------------------------------
void lcd_clearbar(void)
{
 int8u_t i;
 lcd_goto(DRAW_PROGRESS_BAR_ON_LINE, (PROGRESS_BAR_WIDTH - 1));
 lcd_cmd(ENTRY_MODE_DEC_NO_SHIFT,0); // decrement
 for(i=0;i<PROGRESS_BAR_WIDTH;i++)
  lcd_putc(' ');
 lcd_cmd(ENTRY_MODE_INC_NO_SHIFT,0); // increment
 current_bar_load = 0;
}
Пример #23
0
void lcd_init()
{
lcd_cmd(0X38);
delay();
lcd_cmd(0x0E);
delay();
lcd_cmd(0xC0);
delay();
//lcd_cmd(0x04);

}
Пример #24
0
	void lcd_init(void)

{
	IO0DIR = 0XFFFFFFFF;
	lcd_cmd(0x01); // clear display
	lcd_cmd(0x38); // 8 bits, 2 line mode, 5*7 dot format
	lcd_cmd(0x08); // display off, underline off, blink off
	lcd_cmd(0x06); // increment cursor
	lcd_cmd(0x0F); // display on, underline on, blink on
	
}
Пример #25
0
//-------------------------------
void lcd_init(void)
{
 lcd_config(DEFAULT_DISPLAY_CONFIG); // 1, Data Lenght, Number of lines, character font
 lcd_cmd(DEFAULT_DISPLAY_CONTROL,0); // 1, lcd, cursor, blink
 lcd_cmd(DEFAULT_ENTRY_MODE,0); // 1,increment/decrement,display shift on/off 
 lcd_cmd(0x01,2); // clear display
 lcd_cmd(0x02,2); // 1, return home cursor
#if (USE_PROGRESS_BAR)
 lcd_readybar();
#endif
}
void lcd_init()
{
    setDirection_Port(DDR_LCD,OUT_PORT)           //to set lcd port as output port
    setDirection_Pin(DDR_EN,ENABLE_PIN,OUT_PIN)  //to set en_pin in en_port as output pin
    setDirection_Pin(DDR_EN,RW,OUT_PIN)          //to set RW in en_port as output pin
    setDirection_Pin(DDR_EN,RS,OUT_PIN)          //to set RS in en_port as output pin
    lcd_cmd(0x38);                                 // to init lcd
    lcd_cmd(0x0c);                                 //to lcd on
    lcd_cmd(0x01);                                 //to clear lcd

}
Пример #27
0
Файл: lcd.c Проект: kates/lcd
void lcd_go(uint8_t row, uint8_t col) {
    if (row == 4) {
        lcd_cmd(LCD_LINE_4 + col);
    } else if (row == 3) {
        lcd_cmd(LCD_LINE_3 + col);
    } else if (row == 2) {
        lcd_cmd(LCD_LINE_2 + col);
    } else {
        lcd_cmd(LCD_LINE_1 + col);
    }
}
void LCD_Init()
{
lcd_cmd(0x38);  //2 Line, 5X7 Matrix
delay(5);
lcd_cmd(0x0E);  //Display On, CuRSor Blink
delay(5);
lcd_cmd(0x06);
delay(5);
lcd_cmd(0x01);  // Clear Screen
delay(5);
}
Пример #29
0
/************** LCD INITIALIZATION ***************/
void lcd_inti()
{
lcd_cmd(0x38);
lcd_cmd(0x01); // clear screen
delay(10);
 
lcd_cmd(0x06); // 
delay(10);
lcd_cmd(0x80); // force cursor to 1st line
    delay(10);
 
}
Пример #30
0
void display_row (unsigned char p_byRow)
{
	unsigned char i,j;
	unsigned char k;
	if(p_byRow == 1)			// if row  is same as saying if row is non zero, in our case its row = 1
	{
	// Set the address to the second line
	lcd_cmd(0xC0);
	Delay10us(5);

	// Output second line
		for(i = 0; i < 16u; i++)
		{
		// Erase the rest of the line if a null char is 
		// encountered (good for printing strings directly)
		if(LCDText[i] == 0u)
		{
			for(j=i; j < 16u; j++)
			{
				LCDText[j] = ' ';
			}
		}
		
		lcd_dat(LCDText[i]);
		Delay10us(5);
		}
	
	}

	else
	{
		lcd_cmd(0x80);
		DelayMs(2);

		// Output first line
		for(i = 0; i < 16u; i++)
		{
		// Erase the rest of the line if a null char is 
		// encountered (good for printing strings directly)
		if(LCDText[i] == 0u)
		{
			for(j=i; j < 16u; j++)
			{
				LCDText[j] = ' ';
			}
		}
		lcd_dat(LCDText[i]);
		Delay10us(5);
		
		}
	}
}