// 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 }
// 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); }
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); }
void lcd_write_data(uint8_t data) { LCD_CTRL_PORT |= (1 << LCD_CTRL_RS); _nop(); lcd_write_byte(data); _delay_us(40); }
void lcd_write_cmd(uint8_t cmd) { LCD_CTRL_PORT &= ~(1 << LCD_CTRL_RS); _nop(); lcd_write_byte(cmd); _delay_ms(2); }
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); }
static void lcd_command(char command) { // Clear RS to indicate 'command' LCD_RS_CLR(); lcd_write_byte(command); task_delay(LCD_VERY_SHORT_DELAY); }
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); } }
void LCD_Write(unsigned char *this_text) { unsigned char i = 0; while(this_text[i] != 0) { lcd_write_byte(this_text[i++]); long_delay(); } }
//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 } }
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]); } }
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); }
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); }
/** * [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); } } }
///////////////////////////////////////////////////////////////////////// // 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); }
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(); }
//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++;} } }
// 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)); }
/** * [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]); } }
/** * 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++); }
char LCD_Putchar(char zeichen) { short_delay(); lcd_write_byte((char) zeichen); return(1); }
// 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); }
int my_pput(int zeichen) { lcd_write_byte((char) zeichen); return(1); }
void lcd_command(uint8_t cmd) { lcd_write_byte(cmd, false); delay_us(40); //lcd_poll_busy(); }
/* 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++); }
// This function writes a character to the LCD void lcd_write_data(char c) { lcd_set_write_data(); lcd_write_byte(c); }
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? }