void lcd_init4bitmode(){ lcd_reset(); _delay_ms(5); lcd_sendcmd(0x28); // 4data line lcd_sendcmd(clear); lcd_sendcmd(0x0c); // display on cursor off lcd_sendcmd(0x06); // increment cursor right lcd_sendcmd(0x80); // set courser at the beginning of the first line _delay_ms(20); }
void lcd_switch(uint8_t hb) { if(hb) { LCD_BL_DDR |= _BV(LCD_BL_PIN); // Switch on, init #ifdef LCD_BL_PWM LCD_BL_PWM = erb((uint8_t*)EE_BRIGHTNESS); #else LCD_BL_PORT |= _BV(LCD_BL_PIN); #endif lcd_init(); lcd_on = 1; } else { #ifdef LCD_BL_PWM LCD_BL_PWM = 0; my_delay_ms(1); // else the dpy is still on. #endif LCD_BL_PORT &= ~_BV(LCD_BL_PIN); // Switch off the display lcd_sendcmd (LCD_CMD_SLEEPIN); lcd_on = 0; } }
void lcd_contrast(uint8_t hb) { uint8_t contrast = erb((uint8_t*)EE_CONTRAST); if(hb == 0xFE) { contrast--; } else if (hb == 0xFD) { contrast++; } else if (hb == 0xFC) { //keep the eeprom value } else { contrast = hb; } if(contrast < 40) contrast = 40; if(contrast > 80) contrast = 80; ewb((uint8_t*)EE_CONTRAST, contrast); lcd_sendcmd (LCD_CMD_SETCON); lcd_senddata (contrast); DS_P( PSTR("Contrast:") ); DU(100-(contrast-40)*100/40, 3); DC('%'); DNL(); }