void LCD_init() { LCD_CNTRL_DDR = 0xFF; LCD_CNTRL_PORT = 0x00; LCD_DATA_DDR = 0xFF; LCD_DATA_PORT = 0x00; _delay_ms(10); LCD_send_command(0x38); LCD_send_command(0x0C); LCD_send_command(0x01); _delay_ms(10); LCD_send_command(0x06); }
void LCD_init(){ RCC->APB2ENR |= RCC_APB2ENR_IOPAEN; LCD_setToWrite(); delay_ms(50); LCD_send_init_command(0x03, 10); /*Initiating program reset*/ LCD_send_init_command(0x03, 5); /*Program reset*/ LCD_send_init_command(0x03, 5); /*Program reset*/ LCD_send_init_command(0x02, DELAY); /*Switching to 4 bit mode*/ LCD_send_command(0x08); /*display off*/ LCD_send_command(0x2F); /*Setting 2 line mode*/ LCD_send_command(0x04); /*Entry mode set*/ LCD_send_command(0x01); /*clearing DDRAM*/ LCD_send_command(0x0C); /*display on*/ }
/* This function moves the cursor the line y column x on the LCD module*/ void LCD_goto(unsigned char y, unsigned char x) { unsigned char firstAddress[] = {0x80,0xC0,0x94,0xD4}; LCD_send_command(firstAddress[y-1] + x-1); _delay_ms(10); }
void LCD_goto(uint8_t x, uint8_t y){ uint8_t cmd = 0x80; uint8_t temp = 0; if((x > LCD_x_cnt - 1) || (y > LCD_y_cnt - 1)){ LCD_clear(); LCD_writeString("LCD_ERR!\nWRONG GOTO!"); delay_ms(3000); LCD_clear(); return; } LCD_x = x; LCD_y = y; temp = x/16; if(!y) cmd |= temp<<4; else cmd |= (temp<<4) + 0x40; cmd |= (x-temp*16); LCD_send_command(cmd); }
void LCD_clear(){ LCD_x = 0; LCD_y = 0; LCD_send_command(0x01); }