Пример #1
0
// This function initializes the LCD plus any AVR ports etc
void lcd_init() {
 
	// Initialise the AVR ports and any other hardware bits
	DATA_PORT.OUT = 0x00;							// initial data lines all low
	DATA_PORT.DIRSET = 0xff;						// set the 8-bit data port to all outputs
	COMM_PORT.OUTCLR = LCD_E | LCD_RS;			// all LCD control lines low
	COMM_PORT.DIRSET = LCD_E | LCD_RS;  			// set the LCD control line pins to outputs
 
	// Now do the actual LCD initialisations
 
	// startup delay - make it long to allow time for power to settle
	// (you want wish to remove this line)
	_delay_ms(500);
 
	// LCD display initialization by instruction magic sequence
	lcd_write_byte(0x38);			// function set
	_delay_us(50);
	lcd_write_byte(0x0c);			// display on/off control
	_delay_us(50);
	lcd_write_byte(0x01);			// display clear
	_delay_ms(5);
	lcd_write_byte(0x06);			// entry mode set
	_delay_ms(5);
 
	lcd_write_byte(0x14); 			// Cursor shift
 
	lcd_clear_and_home(); 			// LCD cleared and cursor is brought to 
         						// the beginning of 1st line
}
Пример #2
0
// This function clears LCD and sets address to beginning of first line
void lcd_clear_and_home() {
	lcd_set_write_instruction();
	lcd_write_byte(0x01);
	_delay_ms(50);
	lcd_write_byte(0x02);
	_delay_ms(50);
}
Пример #3
0
void lcd_init(void)
{
    // Setup GPIO pins for LCD.
    gpio_mode_setup(GPIOD, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, 0xFF); // DB7-0 
    gpio_mode_setup(GPIOE, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, 0b00000111); // RS, R/W, E 

    lcd_write_byte(0x38, false);
    delay_ms(40);
    lcd_write_byte(0x0F, false);
    delay_ms(40);
    lcd_write_byte(0x01, false);
    delay_ms(40);

}
Пример #4
0
void lcd_write_data(uint8_t data)
{
    LCD_CTRL_PORT |= (1 << LCD_CTRL_RS);
    _nop();
	lcd_write_byte(data);
    _delay_us(40);
}
Пример #5
0
void lcd_write_cmd(uint8_t cmd)
{
    LCD_CTRL_PORT &= ~(1 << LCD_CTRL_RS);
	_nop();
    lcd_write_byte(cmd);
    _delay_ms(2);
}
Пример #6
0
void bghighscore_display_line(int8_t rank, int8_t lcd_line) {
    int8_t c;
    lcd_goto_position(lcd_line, 6);
    for (c = 0; c < INITIALS; c++)
        lcd_write_data(highscores[rank].initials[c]);
    lcd_write_byte(' ');
    lcd_write_int16(highscores[rank].score);
}
Пример #7
0
static void lcd_command(char command)
{
    // Clear RS to indicate 'command'
    LCD_RS_CLR();

    lcd_write_byte(command);

    task_delay(LCD_VERY_SHORT_DELAY);
}
Пример #8
0
void lcd_clear_char_columns(unsigned char x, unsigned char y, unsigned short number)
{
    lcd_set_address(x, y);
    unsigned short i;
    for (i = 0; i < number; i++)
    {
        lcd_write_byte(LCD_WRITE_DATA, 0x00);
    }
}
Пример #9
0
void LCD_Write(unsigned char *this_text)
{
	unsigned char i = 0;
	while(this_text[i] != 0) 
	{
		lcd_write_byte(this_text[i++]);
		long_delay();
	}
}
Пример #10
0
//ghi font luu trong chuoi *str vao vung cgram co dia chi 0-7
void lcd_make_font(char  code *str,sttchar){	// sao chep font toi cgram, sttchar la stt ma ascii (ty 0 den 7)
	unsigned char i;
	if(sttchar>7)i=0x40;else i=sttchar*8+0x40; // tinh toa do bat dau tu 0
	lcd_wait();
	lcd_writecmd(i);// di chuyen con tro toi vung cgram
	for (i=0; i<7; i++){	//khong ghi dlieu 8 vi dlieu nay la lua chon con tro
		lcd_wait(); 
		lcd_write_byte(str[i]); //ghi tung dlieu vao cgram
	}
}
Пример #11
0
void lcd_write_graphic(unsigned char x, unsigned char y, const unsigned char graphic[], unsigned short size)
{
    lcd_set_address(x, y);

    unsigned short i;
    for (i = 0; i < size; i++)
    {
        lcd_write_byte(LCD_WRITE_DATA, graphic[i]);
    }
}
Пример #12
0
static void lcd_data(char data)
{
    // Assert RS to indicate 'data'
    LCD_RS_SET();

    lcd_write_byte(data);

    // Wait for command to be processed
    task_delay(LCD_VERY_SHORT_DELAY);
}
Пример #13
0
void lcd_clear()
{
    lcd_set_address(0, 0);
    int c = 0;
    while(c < PCD8544_MAXBYTES) {
        lcd_write_byte(LCD_WRITE_DATA, 0);
        c++;
    }
    lcd_set_address(0, 0);
}
Пример #14
0
/**
 * [lcd_cls LCD��������]
 * @param screen [ѡ������]
 */
void lcd_cls(SCREEN screen){
	int x,y;
	select_screen(screen);		   //screen:0-ѡ��ȫ����1-ѡ���������2-ѡ���Ұ���
	for(x=0xb8;x<0xc0;x++){			//��0xb8-0xbf,��8ҳ
		lcd_write_cmd(x);
		lcd_write_cmd(0x40);			//�еij�ʼ��ַ��0x40
		for(y=0;y<64;y++){
			lcd_write_byte(0x00);
		}
  }	   
}
Пример #15
0
/////////////////////////////////////////////////////////////////////////
// External interfacse
//
void LCDInit(void)
{
    // HW init
    LCD_DATA_DDR = 0xff;
	LCD_DATA_PORT = 0;
    LCD_CTRL_DDR = LCD_CTRL_MASK;
	LCD_CTRL_PORT &= ~(LCD_CTRL_MASK);
	
	_delay_us(1);
	
    LCD_CTRL_PORT &= ~(1 << LCD_CTRL_RS);

    _delay_ms(50);

    lcd_write_byte(0x38);

    _delay_ms(5);

    lcd_write_byte(0x38);

    _delay_ms(1);

    lcd_write_byte(0x38);

    _delay_us(140);

	lcd_write_byte(0x38); _delay_ms(2);
	lcd_write_byte(0x0e); _delay_ms(2);
	lcd_write_byte(0x06); _delay_ms(2);
			
}
Пример #16
0
void init_lcd()
{
    P1DIR |= LCD_DC_PIN + LCD_SCE_PIN + LCD_RST_PIN + LCD_LED_PIN;
    
    // Set up SPI
    USICTL0 |= USIPE6 + USIPE5 + USIMST + USIOE;
    USICKCTL = USIDIV_1 + USISSEL_2;
    USICTL0 &= ~USISWRST;

    P1_LO(LCD_LED_PIN);

    P1_LO(LCD_SCE_PIN);

    // Send a reset to the LCD ('R)
    P1_HI(LCD_RST_PIN); P1_LO(LCD_RST_PIN); P1_HI(LCD_RST_PIN);

    LCD_PULSE_CLOCK;

    P1_HI(LCD_SCE_PIN);

    lcd_write_byte(LCD_WRITE_COMMAND, PCD8544_FUNCTIONSET | PCD8544_EXTENDEDINSTRUCTION);
    lcd_write_byte(LCD_WRITE_COMMAND, PCD8544_SETVOP | 0xBF);
    lcd_write_byte(LCD_WRITE_COMMAND, PCD8544_SETTEMP | 0x02);
    lcd_write_byte(LCD_WRITE_COMMAND, PCD8544_SETBIAS | 0x03);
    lcd_write_byte(LCD_WRITE_COMMAND, PCD8544_FUNCTIONSET);
    lcd_write_byte(LCD_WRITE_COMMAND, PCD8544_DISPLAYCONTROL | PCD8544_DISPLAYNORMAL);

    lcd_clear();
}
Пример #17
0
//ghi chuoi ky tu *str len man lcd, *str la bo nho gi cung ok
void lcd_puts(char *str){
       unsigned char i=0,x;
       while(x=str[i]){
//		   //x=lcd_wait();	 	  
		   #if (lines==2)
		    if(((x==daudong0)||(x==daudong1))&&(x==' ')&&(str[i+1]!=' ')) 
		   #elif (lines==4)		   
		   if(((x==daudong0)||(x==daudong1)||(x==daudong2)||(x==daudong3))&&(x==' ')&&(str[i+1]!=' ')) 		     
		   #elif (lines==1)
		    if((x==daudong0)&&(x==' ')&&(str[i+1]!=' '))
		   #endif 
			{i++;continue;}	else {lcd_write_byte(x);i++;}
	   }
}
Пример #18
0
// This function moves cursor to a given line and position
//  line is either 0 (first line) or 1 (second line)
//  pos is the character position from 0 to 15.
void lcd_goto(uint8_t line, uint8_t pos)
{
	uint8_t position = 0;
	
	lcd_set_write_instruction();
	switch(line)
	{
		case 0: position = 0;
		break;
		case 1: position = 0x40;
		break;
	}
	lcd_write_byte(0x80 | (position + pos));
}
Пример #19
0
/**
 * [lcd_write_char LCDд��һ���ֽ�]
 * @param row [������]
 * @param col [������]
 * @param c   [��д����ֽ�]
 */
void lcd_write_char(u8 row,u8 col,u8 c){	
	u8 i,calc_col;
	calc_col = col;
	
	if(col <=7)
		select_screen(LEFT);
	else{
		calc_col = col - 8;
		select_screen(RIGHT);
	}
	lcd_set_coords(row,calc_col);

	c-=32;
	lcd_set_coords(row,calc_col);
	for(i=0;i<16;i++){
		if(i==8){
			lcd_set_coords(row+1,calc_col);
		}
		lcd_write_byte(font8x16[c][i]);
	}

}
Пример #20
0
/**
 * Function to define user character.
 *
 * @param {byte flash} *pc
 * @param {byte} char_code
 */
void define_char(byte flash *pc, byte char_code)
{
    byte i,a;
    a = (char_code << 3) | 0x40;
    for (i = 0; i < 8; i++) lcd_write_byte(a++, *pc++);
}
Пример #21
0
char LCD_Putchar(char zeichen)
{
	short_delay();
	lcd_write_byte((char) zeichen);
	return(1);
}
Пример #22
0
// lcd_set_address
//  Moves the current writing location to the specified coordinates
void lcd_set_address(unsigned char x, unsigned char y)
{
    lcd_write_byte(LCD_WRITE_COMMAND, PCD8544_SETXADDR | x);
    lcd_write_byte(LCD_WRITE_COMMAND, PCD8544_SETYADDR | y);
}
Пример #23
0
int my_pput(int zeichen)
{
	lcd_write_byte((char) zeichen);
	return(1);
}
Пример #24
0
void lcd_command(uint8_t cmd)
{
    lcd_write_byte(cmd, false);
    delay_us(40);
    //lcd_poll_busy();
}
Пример #25
0
/* function used to define user characters */
void define_char(unsigned char flash *pc,unsigned char char_code)
{
    unsigned char i,a;
    a=(char_code<<3) | 0x40;
    for (i=0; i<8; i++) lcd_write_byte(a++,*pc++);
}
Пример #26
0
// This function writes a character to the LCD
void lcd_write_data(char c) {
	lcd_set_write_data();
	lcd_write_byte(c);
}
Пример #27
0
void lcd_data(uint8_t data)
{
    lcd_write_byte(data, true);
    delay_us(40);
    //lcd_poll_busy(); // XXX: not working, replaced by above delay -- do I care?
}