void Lcd::clear(){ resetRS(); setE(); setBits(0x01); Timer::wait_ms(1); resetE(); Timer::wait_ms(3); resetRS(); setE(); setBits(0x06); Timer::wait_ms(1); resetE(); Timer::wait_ms(2); }
/** * @brief Initialisiert das Display * */ void initDisplay() { DDRB |= 0xfc; resetRS(); PORTB |= 0x30; PORTB &= 0x3f; _delay_ms(15); toggleEnable(); _delay_ms(5); toggleEnable(); _delay_us(200); toggleEnable(); PORTB |= 0x20; PORTB &= 0x2f; toggleEnable(); _delay_ms(3); writeCommand(0x2C); writeCommand(0x0E); clearDisplay(); }
Lcd::Lcd(){ GPIO_InitTypeDef GPIO_InitStructure; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOH, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_10; GPIO_Init(GPIOB, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; GPIO_Init(GPIOH, &GPIO_InitStructure); resetRS(); setE(); setBits(0x38); Timer::wait_ms(1); resetE(); Timer::wait_ms(1); resetRS(); setE(); setBits(0x38); Timer::wait_ms(1); resetE(); Timer::wait_ms(1); resetRS(); setE(); setBits(0x0F); Timer::wait_ms(1); resetE(); Timer::wait_ms(1); resetRS(); setE(); setBits(0x01); Timer::wait_ms(1); resetE(); Timer::wait_ms(3); resetRS(); setE(); setBits(0x06); Timer::wait_ms(1); resetE(); Timer::wait_ms(1); resetRS(); setE(); setBits(0x80); Timer::wait_ms(1); resetE(); Timer::wait_ms(1); }
/** * @brief Sendet ein Kommando an das Display * * void writeCommand(char command) * @param command Zu sendendes Kommando in 8 Bit Form. */ void writeCommand(char command) { resetRS(); write4Bit((command&0xf0)>>4); write4Bit(command&0x0f); }
/** * @brief Sendet ein Zeichen an das Display * * void writeData(char data) * @param data Zu sendendes Zeichen */ void writeData(char data) { setRS(); write4Bit((data&0xf0)>>4); write4Bit(data&0x0f); resetRS(); }